Add Flatpak support#8
Conversation
|
Rebased on the current main branch. I threw the Flatpak Action into the "enabled" GitHub Action for now, as that makes testing easier (later those two files should obviously be merged and be enabled or disabled together, not separately) |
878a09d to
b4bdabf
Compare
|
Sorry I haven't had time to review this yet. It's on my list for |
|
I'm just gonna say that I tested this by following the above instructions on Ubuntu 20.04 and it seems to work perfectly so far. |
Awesome, thank you! I could also submit this to Flathub, however I am not sure whether this particular package would be welcomed, because we not only not properly build all code from scratch (Maven is downloading a lot of prebuilt components) but also don't have any separation between parts of Fiji and plugins, so the Flatpak has to copy all executable files to a mutable volume in the user's home directory because any one of them might be modified by new plugins or updated by Fiji's updater. That's pretty problematic. At the same time though, a thing like Steam is allowed, and the Steam Flatpak is handling this only slightly better, so Fiji might actually be fine if I polish the code a little ;-) |
|
Sorry again for the slow review and merge on this. Had crunch time for the I2K conference, and now at another conference, so my normal PR reviewing schedule was thrown off. But I just wanted to say again that I'm enthusiastic. I will shoot to review this during my next PR day on Wednesday, May 18.
And I can't resist the opportunity to rant here about packaging systems that want to rebuild Java code. The entire point of Java is "write ONCE" so downloading prebuilt binaries is exactly fine and correct, unlike with native code... 😞 |
You often do want to verify though that the shipped code you have yields exactly the binaries you want, and that the code to generate said binaries is fully available in the first place (in case you want to modify it). The best way to ensure that is to build things from scratch. |
|
I started looking at this today! But got distracted by the ImageJ Launcher patch. The good news is, that PR imagej/imagej-launcher#85 is now merged; the bad news is, the CI never got fully migrated to GitHub Actions after Travis stopped working, so I still need to complete that migration. But I'll punt on it for the moment in favor of testing and merging this PR here, since the patch is also applied manually when building the Flatpak package. I have some conflicts though for the rest of the day, so probably won't finish the review today. Will keep y'all updated. |
|
Since this is linked on the Fiji download page, and since the patch needs rebasing and probably an update as well now, I created a pre-built bundle for people who navigate here and just want to give the easy Fiji installation a try. |
This comment was marked as off-topic.
This comment was marked as off-topic.
|
@ctrueden Would it be okay with you and others if I made an attempt to submit this to Flathub so Linux users can easily install the app? This will be a bit of a challenge, because in order to work well, Fiji/ImageJ will basically require maximum permissions (nearly no sandboxing, so plugins continue to work) and Fiji currently cannot be built from scratch - Maven just downloads a whole bunch of binary stuff at "build" time. So, by attempting this, Fiji will become super easy to install after being available on Flathub, but I will need to submit a few patches to add some metadata and we may actually need versioned release tarballs that the Flatpak bundle will just use as "source" instead of building from scratch, as I currently see no way to build Fiji without network access (which is a requirement for Flathub). I could do the work and talk to the Flathub admins, but I would need blessing from the Fiji authors to make this official, and would definitely like it if one of you would co-maintain the result (or at least have access to the resulting page on Flathub / Flathub GitHub to make changes if needed). |
|
@ximion Yes, I definitely want to help make this happen! Thank you for the ping, and I apologize for my continual deferral of it as a priority for years. 😞 I am willing to maintain it going forward once it is in place. I just pushed an update modernizing the recipe to current standards—but I leaned on Claude quite a lot, so please let me know (or fix) if anything looks suboptimal. Edit: I also rebased over the latest main branch to resolve the conflicts.
Can we use the timestamps from https://downloads.imagej.net/fiji/archive/latest/ ? What else needs to happen to move this forward? |
* Bump runtime to 23.08: the previous 21.08 runtime is end-of-life and would be rejected by Flathub. 23.08 is the oldest currently-supported freedesktop Platform release that still carries the openjdk8 SDK extension Fiji requires. * Rename launch-imagej.sh to launch-fiji.sh: this is a Fiji-specific Flatpak package, not a generic ImageJ one. The launcher script is Fiji's entry point and should reflect that. * Remove DEBUG=1 from fiji-update build step: this was left on inadvertently. Build output is captured by flatpak-builder regardless; setting DEBUG=1 is not intentional here. * Add explanatory comment to fiji-update: the network build-arg is intentional because Fiji's updater must fetch plugins and the Java-8 JRE from the official update sites at build time. This is a known deviation from reproducible-build best practice and warrants a note. * Pin fiji-make to branch main explicitly, with a TODO to pin a commit: the previous source block had no branch or tag, making it implicit and non-obvious. A specific commit hash should be chosen once the desired Fiji release is identified. * Add <releases> to AppStream metainfo: Flathub validation requires at least one <release> entry. Added 2.14.0 as the baseline; update to match the actual bundled version as needed. * Use debian:bookworm in Dockerfile: debian:testing is a rolling target that can change package versions unexpectedly between builds. Bookworm is the current Debian stable release and gives a reproducible build environment. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
We would need to decide whether we want to distribute this via Flathub or roll our own. If we go via Flathub, it would reach the widest user audience, be simple to install, and have automatic updates (although we copy Fiji to the user's home directory anyway and use the local updater, since this is the only way that updates work...). The problems we will run into with Flathub is that some arguing is needed to get it in, because we will have to disable basically all sandboxing features to make this work, which always raises concern. In addition to that, no network-enabled builds are permitted, so we would likely need to fetch a tarball from somewhere. Flatpak builds on Flathub need to be reproducible, so we can't just fetch a "latest" tarball, but we need one with a defined version number. So, Fiji would need to provide versioned tarballs. Fiji still requires Java 8, right? We can not make it use any newer JDK? We'll also have to justify that, most likely. Plus, once the application is accepted, verification for the app would need to be set up via the Fiji website, have a look at https://docs.flathub.org/docs/for-app-authors/verification for details. All of these items I can help with because I have now done them many times and know the Flathub devs (and have annoyed them with sandbox-less scientific apps many times by now). The alternative is just shipping a Flatpak file or setting up our own repo, which comes with its own drawbacks, but tbh, I'd make an attempt at Flathub before going that route. |
That could work, but only if we have the automation also generate a MetaInfo file with the right version number. We need to attach a version number to Fiji, and ideally make that part of the tarball name (but not required, as long as it's in the path and the MetaInfo file has it). So, e.g. we could version the release from |
|
Oh, and I almost forgot: We also need a good screenshot of Fiji hosted somewhere on the web, although that most certainly won't be an issue ^^ For reference, I just recently submitted a tiny app to Flathub, this is how the resulting page looks like: https://flathub.org/en/apps/io.github.bothlab.omerewriter And this is how the review process for Flathub looked like: flathub/flathub#7960 I can take care of most of the work (since the heavy lifting is done), but you would need to version Fiji first, and we would have to add a MetaInfo file with a proper screenshot and description first. I can have a look if that can be automated somehow, then making the Flatpak becomes easy. |
Hi!
I saw your request for a Debian packager on https://imagej.net/software/fiji/downloads - since I am one, I decided to give this a go, but then ultimately ended up creating a Flatpak bundle for Fiji instead, which I think users may be a bit happier with :-)
Flatpak is a widely supported bundling system on Linux, which makes it possible to "freeze" and app with its dependencies, to deploy it easily to pretty much any Linux distribution.
It's a pretty convenient and widely available way to make software available on Linux nowadays.
I created this recipe so we could use Fiji easily on our more powerful shared servers where people connect to from remote locations (and where having every user download Fiji manually is pretty inconvenient, compared to just selecting it from the menu and it just working).
There is one huge issue with Fiji in a Flatpak currently though: Flatpak apps are run from a read-only filesystem by design, while ImageJ/Fiji was written to modify its own files at runtime with its own updater. Originally I just intended to remove the updater and use Flatpak's own very efficient update mechanism to automatically keep Fiji up-to-date.
Unfortunately, removing the updater also cuts off any way for users to easily install ImageJ plugins, which is not an acceptable compromise.
So, what this bundle will do instead is copy the entire Fiji distribution into the user's writable data location and then run it from there. It still runs in the isolated Flatpak environment, but Fiji can modify itself now. Of course this is bad design, as it duplicates data for every user who runs Fiji on the machine, is less secure, and if the home directory is on a filesystem that prevents executables, it won't work either.
Ideally, ImageJ/Fiji would be modified to allow loading modules from separate writable paths and to split the externally-managed plugins from the ones Fiji ships with, so one half can be on a read-only filesystem, while users can still add their own plugin sources. But that would require quite a few changes on the existing codebase, so for now the Flatpak bundle uses the copy-everything compromise.
Another pretty evil thing is that network access is enabled during build, but the advantage of that is that the Flatpak bundle can be created very easily using the same process as all the other binary distributions are using.
If you just want a Fiji Flatpak build that you can use on your machine, download a test-build from here: https://github.com/ximion/fiji-builds/releases/tag/x-test
So, how can you create the build yourself?
1. Install Flatpak
sudo apt install flatpak flatpak-builder sudo systemctl reboot # restarts the computer2. Configure Flatpak to use Flathub for SDKs/Runtimes
3. Build the bundle
cd flatpak/ ./autobuild-bundle.sh4. Install the application!
You can open the resulting
Fiji.flatpakin KDE Discover or GNOME Software for a GUI to install it, or install it via the command-line:You can then just launch Fiji by clicking its icon on the menu!
I included changes to the GitHub action with this PR, which makes it build the Flatpak bundle in a separate job and uploads it as an artifact, so you can fetch it from there for testing purposes.
I deliberately didn't touch the code that uploads directly to the Fiji download site.
This PR will address Fiji issue fiji/fiji#287
Thanks for considering! :-)
Cheers,
Matthias