Haiku: Package Manager – Doing Things Right

The Haiku community is living a very peculiar moment these days.  They are witnessing the creation of its Package Manager. Generally considered as the last missing piece before the Beta, Haiku Inc. was recently awarded two contracts to allow full-time work on this sub-project.

Meanwhile, here is a presentation of how it is expected to work:

First of all, to answer a potentially frequently asked question (PFAQ?), no, it isn’t reusing another package format from the open-source world. Following the Haiku (and BeOS) philosophy, they thrive to do things right. « It would have been faster » isn’t really an argument here. Actually, a lot of decisions would have actually been made differently if it was only for time considerations. Instead, a file system based solution was devised which is both elegant and simple.

So, how does the Package Manager work? It’s fairly simple. Like many systems, Haiku allow processes to watch the content of given directories. Thus, the Package Manager watches the content of several per-determined directories, and receive events when files are either added or removed from them. You would place the package file into /boot/common/packages for a system-wide installation, or /boot/home/config/packages for a single user installation (by the way, the latter might not make much sense yet since Haiku is still a single user OS, but it’s future-proofing).

So, when a package is moved into one of those directories, the Package Manager takes notice. It looks if there are any missing dependencies and the content is then virtually extracted into the adequate directories. Virtually, yes, because /boot/common is a mount point of a filesystem called packagefs and its content is actually the union of all the package files in its package sub-directory.  In other words, in /boot/common, you will see the files contained in every HPKG files sitting in /boot/common/packages, and the same can be said for /boot/home/config.

This installation process can either be done manually by placing those files using the file explorer (copy-paste, download directly to that location), or with the help of a tool. Either way, the “behind the scene mechanism” is alike.

Also, as you could guess, to remove a package, one would simply remove that package file from its “packages” directory (either by deleting the file, or moving it in another folder). The package manager daemon will manage cases where dependencies that were installed with the removed package are no longer required and offer to clean your system.

If you are interested to learn more about this new Package Manager, the definitive source of information on the matter is the Wiki. From there, you will find links to the repository where the code is being worked on, the specifications of the file format, and policies about how to build a package. It’s already testable, and the list of available packages is growing. It should hopefully help 3rd party developers to try to port their software and package it for Haiku.