autopkgtest

The autopkgtest package runs DEP-8 tests.

Direct run

In your test VM, example with the firejail package, stretch+ syntax:

cd firejail-0.9.58.2/
apt-get build-dep .
debuild

apt install autopkgtest
autopkgtest ../firejail_0.9.58.2-2+deb9u1_amd64.changes -- null
# save the test logs (but no more colors):
autopkgtest -o ../test.outdir ../firejail_0.9.58.2-2+deb9u1_amd64.changes -- null

In your test VM, example with rails, old (jessie) syntax:

cd rails-4.1.8/
apt-get build-dep rails
debuild

apt install autopkgtest
apt install ruby-spring ruby-jquery-rails ruby-sqlite3 ruby-sass-rails ruby-uglifier ruby-coffee-rails ruby-turbolinks ruby-jbuilder ruby-sdoc
apt install ruby-byebug ruby-web-console # stretch
# TODO: autopkgtest should install dependencies automatically, possibly those weren't due to APT::Install-Recommends "false", or it's a bug somewhere

adt-run -B ./ --- null
adt-run ../rails_4.1.8-1+deb8u7_amd64.changes --- null

Full LXC environment

In your test VM, example with apache2, new (stretch+) syntax.

LXC setup (buster):

apt install autopkgtest
apt install lxc lxc-templates debootstrap rsync ebtables
# Create network
apt install libvirt-daemon-system
# edit /etc/libvirt/qemu/networks/default.xml if needed (IP range...)
virsh net-autostart default
service libvirtd restart
cat > /etc/lxc/default.conf <<'EOF'
lxc.net.0.type = veth
lxc.net.0.flags = up
lxc.net.0.link = virbr0
lxc.apparmor.profile = unconfined
EOF

# Create base container
# Add security updates to better match target environment
cat <<'EOF' > ~/apt-security.sh
#!/bin/bash
echo 'deb http://security.debian.org/debian-security buster/updates main' >> /etc/apt/sources.list
echo 'deb-src http://security.debian.org/debian-security buster/updates main' >> /etc/apt/sources.list
apt update
apt -y upgrade
EOF
autopkgtest-build-lxc debian buster amd64 ~/apt-security.sh

LXC setup (stretch):

apt install autopkgtest
apt install lxc debootstrap rsync ebtables
# Create network
apt install libvirt-daemon-system
# edit /etc/libvirt/qemu/networks/default.xml if needed (IP range...)
virsh net-autostart default
service libvirtd restart
cat > /etc/lxc/default.conf <<'EOF'
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = virbr0
EOF

# Create base container
# Add security updates to better match target environment
cat <<'EOF' > ~/apt-security.sh
#!/bin/bash
echo 'deb http://security.debian.org/debian-security stretch/updates main' >> /etc/apt/sources.list
echo 'deb-src http://security.debian.org/debian-security stretch/updates main' >> /etc/apt/sources.list
apt update
apt -y upgrade
EOF
autopkgtest-build-lxc debian stretch amd64 ~/apt-security.sh

Testing the package (buster):

cd apache2-2.4.38/
apt-get build-dep .
debuild

# Test the package you're working on
autopkgtest ../apache2_2.4.38-3+deb10u9_amd64.changes -- lxc autopkgtest-buster-amd64
# Caveat: tests the package *from the archive*
#autopkgtest -B -- lxc autopkgtest-buster-amd64

Testing the package (stretch):

cd apache2-2.4.25/
apt-get build-dep apache2
debuild

# Test the package you're working on
autopkgtest ../apache2_2.4.25-3+deb9u11_amd64.changes -- lxc autopkgtest-stretch-amd64
# Caveat: tests the package *from the archive*
#autopkgtest -B -- lxc autopkgtest-stretch-amd64

Testing the package (jessie syntax):

adt-build-lxc debian jessie amd64
# TODO: apply security updates in adt-jessie-amd64
adt-run ../apache2_2.4.10-10+deb8u19_amd64.changes --- lxc adt-jessie-amd64

Local APT archive

adt-run (jessie) can be confused by e.g. conflicting binary packages from the same source package, in which case you need to setup a local APT archive for your packages:

cd /usr/src/mysourcepackage/
apt-ftparchive packages . > Packages
apt-ftparchive release . > Release
echo 'deb [trusted=yes] file:///usr/src/mysourcepackage ./' >> /etc/apt/sources.list
apt update

See for instance nginx.

Backporting

stretch -> jessie:

  • $AUTOPKGTEST_TMP -> $ADTTMP

  • build-essential (e.g. gcc) not installed by default, re-add it if necessary

Copyright (C) 2021, 2022, 2023 Sylvain Beucler