Bug#705917: pbuilder/autopkgtest: modified patch

Jean-Baptiste Lallement jean-baptiste.lallement at canonical.com
Mon Nov 4 09:55:13 UTC 2013


Tags: patch

This updated version of the patch addresses the following points:
    - Enable component 'universe' on Ubuntu to satisfy dependencies of 
procenv (and is also test components)
    - Use option --short of lsb_release instead of awk
    - Use set -e on a separate call instead of shebang line. The test 
script can be called with sh directly and -e applied even if not 
mentioned on command line.

-- 
Jean-Baptiste
IRC: jibel

-------------- next part --------------
diff -Nru pbuilder-0.215/debian/changelog pbuilder-0.216/debian/changelog
--- pbuilder-0.215/debian/changelog	2013-03-30 03:06:05.000000000 +0100
+++ pbuilder-0.216/debian/changelog	2013-11-04 10:49:36.000000000 +0100
@@ -1,3 +1,9 @@
+pbuilder (0.216) UNRELEASED; urgency=low
+
+  * Added basic DEP-8 autopkgtest.
+
+ -- James Hunt <james.hunt at ubuntu.com>  Mon, 04 Nov 2013 10:49:19 +0100
+
 pbuilder (0.215) unstable; urgency=low
 
   * Do not try to use /dev/shm if /run/shm is not present. (closes: #702811, #702102)
diff -Nru pbuilder-0.215/debian/control pbuilder-0.216/debian/control
--- pbuilder-0.215/debian/control	2012-05-31 00:20:36.000000000 +0200
+++ pbuilder-0.216/debian/control	2013-11-04 10:47:55.000000000 +0100
@@ -17,6 +17,7 @@
 Standards-Version: 3.9.1
 Vcs-Git: git://git.debian.org/git/pbuilder/pbuilder.git
 Vcs-Browser: http://git.debian.org/?p=pbuilder/pbuilder.git
+XS-Testsuite: autopkgtest
 
 Package: pbuilder
 Architecture: all
diff -Nru pbuilder-0.215/debian/tests/build_procenv pbuilder-0.216/debian/tests/build_procenv
--- pbuilder-0.215/debian/tests/build_procenv	1970-01-01 01:00:00.000000000 +0100
+++ pbuilder-0.216/debian/tests/build_procenv	2013-11-04 10:50:59.000000000 +0100
@@ -0,0 +1,118 @@
+#!/bin/sh
+set -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
+components=""
+
+dir=/var/cache/pbuilder/result
+
+# Avoid conflict with ADT
+unset TMPDIR
+
+distro=$(lsb_release --id --short|tr '[A-Z]' '[a-z]' || :)
+[ -z "$distro" ] && die "cannot establish distribution"
+
+host_release=$(lsb_release --codename --short || :)
+[ -z "$host_release" ] && die "cannot establish release running on host"
+
+if [ "$distro" = ubuntu ]
+then
+    # Build chroot for latest release.
+    release=$(distro-info --devel)
+    components="main universe"
+
+    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)
+    components="main"
+
+    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" \
+    --components "$components"	\
+    --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.215/debian/tests/control pbuilder-0.216/debian/tests/control
--- pbuilder-0.215/debian/tests/control	1970-01-01 01:00:00.000000000 +0100
+++ pbuilder-0.216/debian/tests/control	2013-11-04 10:47:15.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