What solutions out there can package software in the native package format? I only found fpm (effing package management) and OBS (Open Build Service) so far.
Edit history:
- 2023-11-02: Change title from “How to package software for many distributions?” to “How to package software for many distributions in their native package format?”
- 2023-11-02: Highlight the word native.
Your options are reduced to the following:
Flatpak
Linux only package manager that works across distros. It supports sandboxing via bubblewrap, but be cautious because by default most programs in Flathub are not as sandboxed as they should. You can host your own repository but it is heavily centralized towards Flathub, controlled by Red Hat, IBM.
AppImage
You’re basically packaging your program and every single dependency up to the C library. Linux only.
source (incredibly biased towards AppImage)
Snap
Canonical’s take at flatpaks. They are quite similar, but snaps use AppArmor instead of bubblewrap and the server is proprietary, so an inferior option and should be avoided. The only “advantage” is that it’s used by default in Ubuntu.
Nix/Guix
multi distro package manager with reproducible builds support, more akin to a traditional package manager (eg apt)
source
Pkgsrc
this one is something in between Nix and traditional package managers. It’s main advantage is that it works in other UNIX-like OSs, like FreeBSD, NetBSD, IllumOS as well as in Linux. The only not Linux specific option in this list (other than docker, which is not a package manager but a container)
Docker
I wouldn’t recommend this one, since it requires packaging a whole OS that creates a lot of overhead. And it can be tricky to use with GUI programs.
Overall, I think that Nix/Guix present the most advantages, with Pkgsrc being a less known close second and Flatpak being in the third position due to it’s relative popularity and overall advantages over snaps and docker. Docker might be decent option if it’s a program designed for servers, tho.
I’d also recommend that you add your program to the AUR, because even if it only works on Arch and Arch based distros, it’s incredibly easy to do and maintain as long as the building of your program doesn’t change drastically between versions.
Edit: formatting
I appreciate universal package formats, but I’m looking for solutions that generate native packages.
I believe Pkgsrc compiles the program at install, so it’s native. But it’s been a long time since I used it, you might need to look into it.
And you’ll have a hard time finding a “native” package format, because distros have different libraries versions: arch libraries will be much more updated than Debian’s, so things might break trying to execute programs depending on those libraries. That’s why Flatpak, AppImages, Nix, etc bring their own libraries, because if they don’t, things will break.
They are native in the sense that they are Linux executables, but it’s true that they bring their own dependencies, but as I said, that’s necessary for cross distro support.
Nix is the native NixOS format!
Flatpak for sure because AppImages are slow to launch and Snap is Canonical garbage with tons of overhead.
Nix allows you to download a binary of a proprietary package because every input is hashed. You may need to patch it to work with the correct paths, but these tools already exist.