Rust Implementation of Debian Packaging Primitives

January 03, 2022 at 04:00 PM | categories: packaging, Rust

Does your Linux distribution use tools with apt in their name to manage system packages? If so, your system packages are using Debian packaging.

Most tools interfacing with Debian packages (.deb files) and repositories use functionality provided by the apt repository. This repository provides libraries like libapt as well as tools like apt-get and apt. Most of the functionality is implemented in C++.

I wanted to raise awareness that I've begun implementing Debian packaging primitives in pure Rust. The debian-packaging crate is published on crates.io. For now, it is developed inside the PyOxidizer repository (because I like monorepos).

So far, a handful of useful functionality is implemented:

  • Parsing and serializing control files
  • Reading repository indices files and parsing their content.
  • Reading HTTP hosted repositories.
  • Publishing repositories to the filesystem and S3.
  • Writing changelog files.
  • Reading and writing .deb files.
  • Copying repositories.
  • Creating repositories.
  • PGP signing and verification operations.
  • Parsing and sorting version strings.
  • Dependency syntax parsing.
  • Dependency resolution.

Hopefully the documentation contains all you would want to know for how to use the crate.

The crate is designed to be used as a library so any Rust program can (hopefully) easily tap the power of the Debian packaging ecosystem.

As with most software, there are likely several bugs and many features not yet implemented. But I have bulk downloaded the entirety of some distribution's repositories without running into obvious parse/reading failures. So I'm reasonably confident that important parts of the code (like control file parsing, repository indices file handling, and .deb file reading) work as advertised.

Hopefully someone out there finds this work useful!