Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: AppImage support. #75

Open
MagicalDrizzle opened this issue Jan 26, 2025 · 3 comments
Open

Feature request: AppImage support. #75

MagicalDrizzle opened this issue Jan 26, 2025 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@MagicalDrizzle
Copy link

Version and Environment

  • GSmartControl version: 2.0.1
  • OS: Fedora Kinoite 41

Is your feature request related to a problem? Please describe.
Fedora Atomic images uses a read-only root filesystem and discourage installing packages the traditional way (i.e dnf) and prioritize Flatpaks/AppImages/brew/"things not installing into /usr"

Describe the solution you'd like
It would be nice if gsmartcontrol can be distributed as an AppImage to be able to use it on these systems.

Describe alternatives you've considered
Creating a rootful distrobox and installing gsmartcontrol in it, but that's a lot of disk space wasted for just one app.
Layering traditional dnf packages in Fedora Atomic is possible - but highly discouraged.

Additional context

  • I had to make gsmartcontrol look for its data files in a portable way (i.e not hardcoding /usr/share) and this is how I managed to do that. (gsc_init.c)
	} else {
		if constexpr(BuildEnv::is_kernel_family_windows()) {
			hz::data_file_add_search_directory("icons", application_dir / "icons");
			hz::data_file_add_search_directory("ui", application_dir / "ui");
			hz::data_file_add_search_directory("doc", application_dir / "doc");
		} else {
			// old
			// hz::data_file_add_search_directory("icons", hz::fs_path_from_string(BuildEnv::package_pkgdata_dir()) / BuildEnv::package_name() / "icons");  // /usr/share/program_name/icons
			// hz::data_file_add_search_directory("ui", hz::fs_path_from_string(BuildEnv::package_pkgdata_dir()) / BuildEnv::package_name() / "ui");  // /usr/share/program_name/ui
			// hz::data_file_add_search_directory("doc", hz::fs_path_from_string(BuildEnv::package_doc_dir()));  // /usr/share/doc/[packages/]gsmartcontrol
			// new
			hz::data_file_add_search_directory("icons", application_dir.parent_path() / "share" / BuildEnv::package_name() / "icons");  // bin/../share/program_name/icons
			hz::data_file_add_search_directory("ui", application_dir.parent_path() / "share" / BuildEnv::package_name() / "ui");  // bin/../share/program_name/ui
			hz::data_file_add_search_directory("doc", application_dir.parent_path() / "share" / "doc" / BuildEnv::package_name());  // bin/../share/doc/[packages/]gsmartcontrol
		}
	}
  • I had to remove the gsmartcontrol-root script and just put the binary in /bin like a regular package (plus changing the desktop file exec entry to match) - because the AppImage format does not support running an embedded binary in it with sudo. This also require the AppImage to be run with sudo.
  • The gsmartcontrol.appdata.in.xml file had to either be deleted or changed a little as currently it does not pass appstreamcli's checks.
    • IDs should be in rDNS format, so <id>dev.shaduri.gsmartcontrol</id> instead of <id>gsmartcontrol</id>
    • Desktop filename must match ID - so <launchable type="desktop-id">dev.shaduri.gsmartcontrol.desktop</launchable> instead of <launchable type="desktop-id">gsmartcontrol.desktop</launchable> (plus the real desktop filename must be changed to match also).

After all that was done I successfully built the AppImage and confirm it works.

@MagicalDrizzle MagicalDrizzle added the enhancement New feature or request label Jan 26, 2025
@ashaduri
Copy link
Owner

ashaduri commented Feb 3, 2025

Hi,

Thanks a lot for the work.

Would you mind sharing the steps you did (aside from patching) to build the AppImage? A script, for example.

Regarding the data file search, since I do not want to lose the pkgdir feature, I'm inclined to add a cmake switch (visible via BuildEnv) for AppImage builds. Do you think there is a better solution?

@MagicalDrizzle
Copy link
Author

  1. Patch the source code and build with -DCMAKE_INSTALL_PREFIX=/usr, then DESTDIR=gsmartcontrol make install to create the base appimage folder, named gsmartcontrol.
  2. Patch the gsmartcontrol.appdata.in.xml file as above, and change the desktop entry filename to match.
  3. Remove the gsmartcontrol-root script from /bin, put the original binary and delete the empty /sbin folder (more or less launching the app the "standard way" due to appimage limitations), then change the desktop entry Exec line to gsmartcontrol
  4. Download linuxdeploy-static-x86_64.AppImage from here: https://github.com/linuxdeploy/linuxdeploy/releases/latest and run ./linuxdeploy-static-x86_64.AppImage --appdir path/to/gsmartcontrol (the folder we created in step 1)
  • If it fails with some weird error about stripping (happens on Fedora 41), try running the command again with NO_STRIP=1
  1. Download appimagetool-x86_64.AppImage from https://github.com/AppImage/appimagetool/releases/tag/continuous, and run VERSION=2.0.1 ./appimagetool-x86_64.AppImage /path/to/gsmartcontrol (the folder we created in step 1)

That should be all!

@ashaduri
Copy link
Owner

ashaduri commented Feb 5, 2025

Thanks, I'll try to set it up using CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants