Zp - source-based package manager

Hello Zig community,

A while ago I shared zp, a minimal source-based package manager written in Zig. Thanks to everyone who gave feedback last time. We’ve kept working on it and I’d like to share what has changed.

GitHub: GitHub - understratum/zp: A minimal, source-based package manager · GitHub

What is zp?

zp fetches package source tarballs, builds them and installs them on the system, with no prebuilt binaries. It’s inspired by CRUX/KISS Linux ports and Void’s xbps-src. It keeps a list of the files each package installed, so removal is clean.

The basic flow is:

zp sync          # update the recipe repository
zp search htop
sudo zp add htop
sudo zp update   # update all installed packages
sudo zp remove htop

Targeting Zig 0.17.

What’s new

Our own recipe repository. Until now recipes had to come from somewhere else. We now have a dedicated repository, zp-repo, and we plan to add new packages to it very actively. Every package is a directory with:

  • <name>.zon: metadata (name, version, license, source URL, dependencies)
  • BuildFile: the shell script that builds and installs the package
  • update.json: only for packages that are not hosted on GitHub, describing where to look for new versions

For example, htop.zon looks like this:

.{
    .name = "htop",
    .version = "3.5.3",
    .license = "GPL-2.0-or-later",
    .url = "https://github.com/htop-dev/htop/releases/download/3.5.3/htop-3.5.3.tar.xz",
    .hash = "abcdhash",
    .deps = .{ "ncurses" },
}

New behavior. If a package fails to build, zp now removes it, so a failed build doesn’t leave a half-installed package behind.

Bug fixes and refactoring. We fixed a handful of bugs and cleaned up parts of the code (parsing, file tracking, the build flow).

What is NOT verified yet

Please keep in mind that this is still an early project. A lot of it is untested:

  • most recipes in the repository have only been built on one machine (a CRUX-based system), so expect broken BuildFiles on other setups
  • error paths (interrupted downloads, failing builds, partially installed packages) have had little testing
  • there is no checksum verification of downloaded sources yet
  • installing requires root, so please read a recipe before you run it: a BuildFile is an ordinary shell script and runs with your privileges

How you can help

We’d be glad to get pull requests. Especially useful:

  • new or fixed recipes for the repository
  • testing on other distributions and reporting what breaks
  • bug fixes, and review of the Zig code (the harsh feedback last time helped a lot!)
  • ideas for the architecture and recipe format

Issues and pull requests are welcome. Thanks for reading, and any feedback is appreciated.

zp-repo: GitHub - understratum/zp-repo: Repository · GitHub

2 posts were merged into an existing topic: Zp - A source-based package manager written in Zig