profile picture

Michael Stapelberg

pk4: a new tool to avail the Debian source package producing the specified package (2017)

published 2017-10-21, last modified 2019-02-04
in tag debian
Edit Icon

UNIX distributions used to come with the system source code in /usr/src. This is a concept which fascinates me: if you want to change something in any part of your system, just make your change in the corresponding directory, recomile, reinstall, and you can immediately see your changes in action.

So, I decided I wanted to build a tool which can give you the impression of that, without the downsides of additional disk space usage and slower update times because of /usr/src maintenance.

The result of this effort is a tool called pk4 (mnemonic: get me the package for…) which I just uploaded to Debian.

What distinguishes this tool from an apt source call is the combination of a number of features:

  • pk4 defaults to the version of the package which is installed on your system. This means when installing the resulting packages, you won’t be forced to upgrade your system in case you’re not running the latest available version.
    In case the package is not installed on your system, the candidate (see apt policy) will be used.
  • pk4 tries hard to resolve the provided argument(s): you can specify Debian binary package names, Debian source package names, or file paths on your system (in which case the owning package will be used).
  • pk4 comes with tab completion for bash and zsh.
  • pk4 caps the disk usage of the checked out packages by deleting the oldest ones after crossing a limit (default: 2GiB).
  • pk4 allows users to enable supplied or shipped-with-pk4 hooks, e.g. git-init.
    The git-init hook in particular results in an experience that reminds of dgit, and in fact it might be useful to combine the two tools in some way.
  • pk4 optimizes for low latency of each operation.
  • pk4 respects your APT configuration, i.e. should work in company intranets.
  • tries hard to download source packages, with fallback to snapshot.debian.org.

If you don’t want to wait for the package to clear the NEW queue, you can get it from here in the meantime:

wget https://people.debian.org/~stapelberg/pk4/pk4_1_amd64.deb
sudo apt install ./pk4_1_amd64.deb

You can find the sources and issue tracker at https://github.com/Debian/pk4.

Here is a terminal screencast of the tool in action, availing the sources of i3, applying a patch, rebuilding the package and replacing the installed binary packages:

I run a blog since 2005, spreading knowledge and experience for almost 20 years! :)

If you want to support my work, you can buy me a coffee.

Thank you for your support! ❤️