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:
deboostrap
- create a Debian encironmentchroot
- the core function to switch on/off the isolated build environment (created by debootstrap)schroot
- a wrapper ofchroot
to makechroot
easiler to use (by feeding a configuration file)
The whole picture of the process is:
- Setup
schroot
- Create the target Debian environment with
debootstrap
- Tell
sbuild
where to find the above environment, usechroot
to get into the enviroment, and execute build commands.
Steps
Setup schroot
You may refer to this script. Please note my "host" environment is Ubuntu-Mate 18.04. The key ideas are:
- Install schroot by
apt install schroot
- Setup the configuration file, e.g.
/etc/schroot/chroot.d/poetry-build.conf
in my case, the will be used later
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:
- pull the source ``
- build
gbp buildpackage --git-ignore-new --git-builder=sbuild
--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.