Bug#705917: pbuilder: Add basic DEP-8 autopkgtest

James Hunt james.hunt at ubuntu.com
Wed Apr 24 08:41:37 UTC 2013


Updated debdiff attached that makes the following changes:

* debian/tests/build_procenv: Aligned with sbuild DEP-8 script:
  - Use appropriate archive based on distribution.
  - Build package for specified distribution (stable for debian to
    ensure chroot is creatable).
  - Download package source for specified release.
  - Only install build .deb if host environment matches the release the
    package was built for.
  - Perform basic checks on built .dep in case it is not possible to
    install it.
* debian/tests/control: Add distro-info and lsb-release dependencies.

Adding breaks-testbed stops this test running in the Ubuntu test environment so
I'd like to understand further how this option is used (or is intended to be
used) in Debian.

Kind regards,

James.
--
James Hunt
____________________________________
#upstart on freenode
http://upstart.ubuntu.com/cookbook
https://lists.ubuntu.com/mailman/listinfo/upstart-devel
-------------- next part --------------
diff -Nru pbuilder-0.213ubuntu1/debian/changelog pbuilder-0.213ubuntu2/debian/changelog
--- pbuilder-0.213ubuntu1/debian/changelog	2012-11-07 16:11:40.000000000 +0000
+++ pbuilder-0.213ubuntu2/debian/changelog	2013-04-24 09:34:41.000000000 +0100
@@ -1,3 +1,9 @@
+pbuilder (0.213ubuntu2) UNRELEASED; urgency=low
+
+  * Added basic DEP-8 autopkgtest.
+
+ -- James Hunt <james.hunt at ubuntu.com>  Wed, 24 Apr 2013 09:34:33 +0100
+
 pbuilder (0.213ubuntu1) raring; urgency=low
 
   * Merge from Debian unstable (LP: #1075347, LP: #1060101)
diff -Nru pbuilder-0.213ubuntu1/debian/control pbuilder-0.213ubuntu2/debian/control
--- pbuilder-0.213ubuntu1/debian/control	2012-11-07 16:11:40.000000000 +0000
+++ pbuilder-0.213ubuntu2/debian/control	2013-04-22 08:41:08.000000000 +0100
@@ -18,6 +18,7 @@
 Standards-Version: 3.9.1
 XS-Debian-Vcs-Git: git://git.debian.org/git/pbuilder/pbuilder.git
 XS-Debian-Vcs-Browser: http://git.debian.org/?p=pbuilder/pbuilder.git
+XS-Testsuite: autopkgtest
 
 Package: pbuilder
 Architecture: all
diff -Nru pbuilder-0.213ubuntu1/debian/tests/build_procenv pbuilder-0.213ubuntu2/debian/tests/build_procenv
--- pbuilder-0.213ubuntu1/debian/tests/build_procenv	1970-01-01 01:00:00.000000000 +0100
+++ pbuilder-0.213ubuntu2/debian/tests/build_procenv	2013-04-24 08:51:33.000000000 +0100
@@ -0,0 +1,113 @@
+#!/bin/sh -e
+
+#---------------------------------------------------------------------
+# DEP-8 test for sbuild.
+#
+# Creates a sbuild chroot, builds a package, installs the resulting
+# .deb, then runs the command provided by the .deb.
+#---------------------------------------------------------------------
+
+die()
+{
+    msg="$*"
+    echo "ERROR: $msg" >&2
+    exit 1
+}
+
+# The package we'll ask sbuild to build (we know its buildable since
+# it's already in the archive :-)
+#
+# The advantage of choosing this particular package being that it runs
+# *itself* at the end of its build, which has the nice side-effect of
+# exposing the full sbuild environment to those perusing the autopkgtest
+# logs.
+pkg=procenv
+
+dir=/var/cache/pbuilder/result
+
+# Avoid conflict with ADT
+unset TMPDIR
+
+distro=$(lsb_release --id|cut -d: -f2-|awk '{print $1}'|tr '[A-Z]' '[a-z]' || :)
+[ -z "$distro" ] && die "cannot establish distribution"
+
+host_release=$(lsb_release --codename|cut -d: -f2-|awk '{print $1}' || :)
+[ -z "$host_release" ] && die "cannot establish release running on host"
+
+if [ "$distro" = ubuntu ]
+then
+    # Build chroot for latest release.
+    release=$(distro-info --devel)
+
+    url=http://archive.ubuntu.com/ubuntu
+elif [ "$distro" = debian ]
+then
+    # Build chroot for latest stable release since
+    # sid may not be buildable on a particular day.
+    release=$(distro-info --stable)
+
+    url=http://archive.debian.org/debian
+else
+    die "need to know where archive is for distro '$distro'"
+fi
+
+# Have to redirect stderr to avoid ADT thinking the test has failed
+# (the return code is still being checked, so this seems reasonable).
+echo "INFO: Creating pbuilder buildd chroot for release '$release'"
+pbuilder --create --debug \
+    --distribution "$release" \
+    --mirror "$url" \
+    --debootstrapopts --variant=buildd 2>&1
+
+if [ ! -d "$dir" ]
+then
+    echo "ERROR: cannot find directory $dir" >&2
+    exit 1
+fi
+
+# Use '--download-only' to avoid unpack which generates a
+# signature warning to stderr, causing this test to fail.
+# Take care to download the package version for the release we will
+# create the chroot for. 
+echo "INFO: Downloading source for package '$pkg' release '$release'"
+apt-get source --download-only "$pkg/$release"
+
+dsc=$(ls ${pkg}*.dsc)
+
+echo "INFO: Building package '$pkg' for release '$release' from '$dsc'"
+pbuilder --build --debug "$dsc" 2>&1
+
+arch=$(dpkg --print-architecture 2>/dev/null)
+[ -z "$arch" ] && die "cannot establish architecture"
+
+pkg_and_version=$(echo "$dsc"|sed 's/\.dsc$//g')
+deb=${dir}/${pkg_and_version}_${arch}.deb
+
+# Do what we can to check if the .deb looks usable (since we may not
+# be able to install it to test it properly)
+echo "INFO: Listing information on '$deb'"
+dpkg --info "$deb"
+
+echo "INFO: Listing contents of '$deb'"
+dpkg --contents "$deb"
+
+extract="$ADTTMP/extract"
+echo "INFO: Extracting '$deb' to '$extract'"
+dpkg --extract "$deb" "$extract"
+
+if [ "$release" = "$host_release" ]
+then
+    echo "INFO: Installing package '$pkg' from '$deb'"
+    dpkg -i "$deb"
+
+    # run the command to prove the build worked but also to expose the
+    # auto-package-test environment used for this test.
+    cmd=$pkg
+    echo "INFO: Showing AutoPkgTest environment by running '$cmd' from package '$pkg'"
+    "$cmd"
+else
+    echo "INFO: Not installing package '$pkg' as host release ('$host_release')"
+    echo "INFO: differs to release package is built for ('$release')"
+fi
+
+echo "INFO: SUCCESS"
diff -Nru pbuilder-0.213ubuntu1/debian/tests/control pbuilder-0.213ubuntu2/debian/tests/control
--- pbuilder-0.213ubuntu1/debian/tests/control	1970-01-01 01:00:00.000000000 +0100
+++ pbuilder-0.213ubuntu2/debian/tests/control	2013-04-24 08:28:12.000000000 +0100
@@ -0,0 +1,3 @@
+Tests: build_procenv
+Depends: @, debian-keyring, distro-info, lsb-release
+Restrictions: needs-root


More information about the Pbuilder-maint mailing list