benini / scid

Other
44 stars 14 forks source link

Add flatpak manifest #97

Closed rolandlo closed 1 year ago

rolandlo commented 1 year ago

Closes #96

This PR adds a flatpak manifest to create a flatpak for scid. The engines Stockfish and Lc0 (Leela chess) are bundled as well. When running the flatpak they are found in the folder /app/bin/Engines/stockfish and /app/bin/Engines/lc0, respectively.

Here is how to build the flatpak (c.f. https://docs.flatpak.org/en/latest/first-build.html):

First install flatpak and add the flathub repo as described in https://flatpak.org/setup/ (if you do not use flatpaks yet) and then install the freedesktop runtime (which contains all the build tools among other things)

flatpak install flathub org.freedesktop.Platform//22.08 org.freedesktop.Sdk//22.08

This has to be done only once.

Then in order to build the flatpak and create a user installation of it run

flatpak-builder --user --install --force-clean build-dir com.github.benini.scid.yml

from inside the repository root folder (containing the flatpak manifest). Here build-dir is the name of a temporary build folder and can be changed if wanted. This will take a while, but should run without issues.

If everything goes well, you can run the flatpak via

flatpak run com.github.benini.scid

According to my tests, both engines run fine and using FICS works fine as well.

Some more remarks:

benini commented 1 year ago

Thanks! I tried it in a fresh installation of Fedora 37. It seems to work fine, with just a few issues:

rolandlo commented 1 year ago

The paths are fixed now.

I think the neural network from that link is stable, see https://training.lczero.org/networks/2 (first line). So it must have been a typo, which flatpak-builder overlooked when caching.

I changed wayland to x11. It ran without that on my Ubuntu 22.04 installation because I happened to be in a x11 session. By the way the flatpak also run fine when starting it via

flatpak run --command=sh com.github.benini.scid
DISPLAY=:0.0 scid

I don't know if the environment variable can be set in a different way. Adding it as --env=DISPLAY=:0.0 to the finish-args didn't work for me. I didn't recompile the whole thing though, so it might be due to caching. Anyway I think there is nothing wrong in forcing x11.

What do you think about adding ratings/spellchecking/player photos files to the flatpak?

benini commented 1 year ago

Thanks, I have pushed the commits, moved the manifest to a flatpak directory and added a readme.txt with the instructions you gave. Please check if it is ok and let me know if you want to change something.

There is just a last issue: the current scid code no longer installs the shell script /app/bin/scid. It works changing command: in the manifest to /app/scid/scid but I don't know if there is a better way.

Adding ratings and player photos would be great. However they take a lot of space so the older version are deleted from sourceforge when a new one is available. Would that be a problem with flatpak?

rolandlo commented 1 year ago

Thanks, I have pushed the commits, moved the manifest to a flatpak directory and added a readme.txt with the instructions you gave. Please check if it is ok and let me know if you want to change something.

In the readme the line https://github.com/benini/scid/blob/e2762d81739dfdd40ab1e05be980b697fe30e7f5/flatpak/readme.txt#L20 would have to be corrected, since the manifest is not longer in the repository root folder. Otherwise the readme LGTM.

There is just a last issue: the current scid code no longer installs the shell script /app/bin/scid. It works changing command: in the manifest to /app/scid/scid but I don't know if there is a better way.

That looks fine to me. An alternative way might be to move the executable to the standard location /app/bin in the build process.

Adding ratings and player photos would be great. However they take a lot of space so the older version are deleted from sourceforge when a new one is available. Would that be a problem with flatpak?

It's a problem, but it has a solution named external data checker, in this case probably using the HTML checker. You would have to add a static HTML page to the sourceforge repo from which the latest versions of the ratings and player photos could be gathered. The links in that HTML page would have to be updated whenever the ratings or player photos change, but that shouldn't be too troublesome. It would also be possible to add external checker data for other modules, so it would be easier to update them when a new version is released. On flathub when external data checkers are included and a version is updated, it will automatically create an update pull request (with the latest version and correct sha256) and run the build process. It just remains to test out the build (by installing via the link that you get sent automatically via email) and accept the pull request when the test was successful. The bot checks for updates 4 times a day, so it's amazingly easy to always have up to date modules/dependencies, see https://github.com/flathub/flatpak-external-data-checker#on-flathub

One thing that is missing in this repository (and should be included in the flatpak) are a .desktop file (for desktop integration of the app, so that you can e.g. add it to the favorites on the dock on Linux) and a .metainfo.xml (or .appdata.xml) file (describing the app for software centers). See https://docs.flatpak.org/en/latest/conventions.html and https://www.freedesktop.org/software/appstream/docs/sect-Metadata-Application.html for some info about that. You can also compare with the first two files in this folder for a practical example. Moreover the icon (or a copy thereof) should be renamed to com.github.benini.scid.svg, which can also be done in the manifest via rename-icon, see https://docs.flatpak.org/en/latest/manifests.html?highlight=rename-icon#file-renaming

In case you want me to help, let me know.

benini commented 1 year ago

Yes, please help, I don't want to read all the flatpak docs :)

Let's leave the ratings and player photos for later. I have copied the .desktop file from debian and asked chatGPT to create the appdata.xml. Could you review and ajust them and add the rename-icon too please?