Skip to content

Building a package

Implementing a chroot with Sid: https://perl-team.pages.debian.net/autopkgtest.html#SETUP

In the host

File ~/.sbuildrc:

$maintainer_name='Name Surname <email@example.com>';
$distribution = "unstable";
$chroot = "sid-amd64-sbuild";
$build_arch_all = 1;
$purge_build_directory = 'successful';
$purge_session = 'successful';
$purge_build_deps = 'successful';
$build_source = 1;
$source_only_changes = 1;
1;

File `~/.devscripts:

DEBSIGN_KEYID="0x40-CHARS-GPG-KEY-ID"

In the chroot

Install:

sudo apt install --no-install-recommends devscripts debhelper pbuilder git vim build-essential dh-make dh-python python3-setuptools lintian quilt autopkgtest eatmydata blhc

File ~/.lintianrc:

profile=debian
pedantic=yes
display-experimental=yes
verbose=yes
display-info=yes

File ~/.pbuilderrc and /root/.pbuilderrc:

APTCACHE=/var/cache/pbuilder/aptcache
ARCHITECTURE=$(dpkg --print-architecture)
AUTO_DEBSIGN=no
BUILDRESULT=/build
DEBEMAIL="Name Surname <email@example.com>"
DISTRIBUTION=sid
MIRRORSITE=http://deb.debian.org/debian
EATMYDATA=yes

Export DEBEMAIL:

echo 'DEBEMAIL="Name Surname <email@example.com>"' > /etc/profile.d/01-debemail.sh
echo "export DEBEMAIL" >> /etc/profile.d/01-debemail.sh

Set Quilt patches path:

echo "QUILT_PATCHES=debian/patches" > /home/<user>/.quiltrc
chown <user>:<user> /home/<user>/.quiltrc

Create the environment:

pbuilder create

From now on, when we need to build a package we will just have to enter in a chroot running schroot -c sid-amd64-sbuild.

Inside the directory with the source code of the package:

sudo pbuilder update && pdebuild

The resulting files will be in /build.
/build can be found in the host system in /var/lib/sbuild/build.

Run a test

If there are tests configured in debian/tests you can test them with:

sudo autopkgtest -- null

Export Display

In the host:

xhost +local:

In the chroot:

export DISPLAY=:0

Check package reproducibility

Install eatmydata and reprotest in the host:

sudo apt install eatmydata reprotest

Then, to check if a package is reproducible, run the following command inside the package directory:

sudo eatmydata reprotest --vary=domain_host.use_sudo=1 --auto-build . --min-cpu $(nproc) -- schroot sid-amd64-sbuild

The --auto-build argument will try to find the cause of the difference if the package is not reproducible.

Configure Salsa CI

First read the Salsa CI Team documentation to activate it: https://salsa.debian.org/salsa-ci-team/pipeline

Setting up a pristine-tar branch

  1. Create a upstream/<version> branch with the content of the upstream file (usually a .tar.gz).
  2. Rename the upstream package to <package>_<version>.orig.tar.gz.
  3. Create and push the pristine-tar branch:
pristine-tar commit <package>_<version>.orig.tar.gz upstream/<version>
git push -u origin pristine-tar

Creating the Git Build Package configuration file

Create the file debian/gbp.conf with the following content:

[DEFAULT]
pristine-tar = True

Commit and push the changes.

Forward patches to upstream

Based on the Perl Team documentation: https://perl-team.pages.debian.net/forward.html

Install Perl Team packaging tools:

sudo apt install pkg-perl-tools

Create the file debian/upstream/metadata with the following content:

Name: <PROJECT NAME>
Archive: GitHub
Repository: https://github.com/<AUTHOR>/<REPO>.git
Repository-Browse: https://github.com/<AUTHOR>/<REPO>
Bug-Database: https://github.com/<AUTHOR>/<REPO>/issues
Bug-Submit: https://github.com/<AUTHOR>/<REPO>/issues/new

Create the file ~/.dpt.conf with the following content:

DPT_GITHUB_ORGNAME=<ORGANIZATION NAME>
DPT_GITHUB_OAUTH=<PERSONAL ACCESS TOKEN>
DPT_GITHUB_BRANCH=pkg-debian-$(date +%s)

To forward the patch just run:

dpt forward debian/patches/<PATCH FILE>

Uploading a package

In your host run the following command inside the package directory:

sbuild -s -d unstable -c sid-amd64-sbuild --source-only-changes

Sign the package:

debsign <package>_<version>_source.changes

Upload the package:

dput <package>_<version>_source.changes

Using pdebuild

If we just want to use pbuilder without sbuild we first create the base:

sudo pbuilder create --mirror http://deb.debian.org/debian --distribution sid

In order to install packages inside the chroot we can use:

sudo pbuilder --login --save-after-login

To build a package, from its source directory run:

sudo pdebuild --use-pdebuild-internal

This command places the binary in /var/cache/pbuilder/result.

Finally, to obtain the source-only files:

sudo pbuilder --build --source-only-changes <package>_<version>.dsc