Build Debian Package With schroot on Ubuntu

The Approach of Packaging Poetry Debian Package

Recently I am trying to involve the poetry deb packaging. In this case, the work is based on the conventional (and respectable) debootstrap, chroot and schroot. Let me summarize the approach.

Isolate and build

The key concept is to first create an isolated build environment, and then build/package. In short, the approach is composed of:

The whole picture of the process is:

Steps

Setup schroot

You may refer to this script. Please note my "host" environment is Ubuntu-Mate 18.04. The key ideas are:

Prepare a Base Chroot Environment

All debian environments could be created by deboostrap. For example, I use this command to build a Debian Sid environment sudo debootstrap sid /var/chroot/sid http://deb.debian.org/debian/.

Please note debootstrap could not be used in a container (e.g. LXC) because it will create a special file by invoking mknod, which is usually not supported in a container.

Build!

Now everything is ready, we can pull the source and simply build the poetry deb by:

--git-builder=sbuild may be a must, depending on which gbp and the corresponding configuration of gbp you are currently using.

More Information

If you are interested in more details, you may refer to the threads on debian-python mailing list. You may see how the others worked on it and what challenges happened to them.

For example, the whole packaging work spent a lot of time to get its dependencies ready. Before the dependencies are ready, --extra-package of gbp is the solution for packaging.

The whole threads are worthy of reading if you are interested in packaging upstream source from scratch.