We will install a current Debian release to a build environment which will spawn in an isolated light-weight namespace container.
mount /var/lib/machines/build debootstrap --arch amd64bookworm /var/lib/machines/build/ http://ftp.de.debian.org/debian/
Create a start script to spawn the container.
cat << EOF > ~/bin/c-buildstart.sh #!/bin/sh mount /var/lib/machines/build systemd-nspawn -D /var/lib/machines/build EOF
Copy custom shell configuration to the container.
cp ~/.bashrc /var/lib/machines/build/root/ umount /var/lib/machines/build/
Namespace container
Prepare the container which will be used as our build environment.
c-buildstart.sh apt purge nano isc-dhcp-client isc-dhcp-common; \ apt install vim locales; \ dpkg-reconfigure locales
We will be using the following locales.
Generating locales (this might take a while)... de_DE.UTF-8... done en_GB.UTF-8... done en_US.UTF-8... done Generation complete.
Create a very basic vim configuration.
cat << EOF > ~/.vimrc syntax on colorscheme default set ruler EOF
We will make sure the current release gets preferred over other available sources.
cat << EOF > /etc/apt/preferences.d/99-debian package: * Pin: release o=Debian,n=bookworm Pin-Priority: 1001 EOF
Add the binary and source repositories.
cat << EOF > /etc/apt/sources.list deb http://ftp.de.debian.org/debian/ bookworm main contrib non-free non-free-firmware deb http://ftp.de.debian.org/debian/ bookworm-updates main contrib non-free non-free-firmware deb https://deb.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware EOF cat << EOF > /etc/apt/sources.list.d/sources.list deb-src http://ftp.de.debian.org/debian/ testing main contrib non-free deb-src http://ftp.de.debian.org/debian/ unstable main contrib non-free deb-src http://ftp.de.debian.org/debian/ experimental main contrib non-free EOF
Finalize our build environment.
apt install ca-certificates && apt update && apt upgrade
Build packages
apt install debian-keyring dpkg-dev fakeroot debhelper chown _apt /usr/local/src
cd /usr/local/src apt source<package> cd <package-dir> build-package
Skip tests
If some tests fail during our build, we may want to disable these extra checks.
DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage
Add packages to repository
We want to add our packages to our custom repository.
cp /var/lib/machines/build/usr/local/src/*.deb /home/builds/<package> c-buildstop.sh find /home/builds/<package> -name '*1.2.3-4*' | xargs reprepro includedeb bookworm
reprepro listmatched bookworm 'postfix*' reprepro listfilter bookworm 'Version (% *3.8.3* )' reprepro --list-format '${package}\n' listfilter bookworm 'Version (% *3.8.3* )'