aboutsummaryrefslogtreecommitdiff
path: root/debian
diff options
context:
space:
mode:
authorMattia Rizzolo <mattia@mapreri.org>2015-06-23 11:54:41 +0000
committerMattia Rizzolo <mattia@mapreri.org>2015-06-23 11:54:41 +0000
commit9d159d3b06ef7aa208d86304a8b6e005b38a7720 (patch)
tree7c47ead2891e3719b3e5a40dac66e2a312a87c62 /debian
parent67f2946263b26224df788de5d40191994cafb02f (diff)
downloadpbuilder-9d159d3b06ef7aa208d86304a8b6e005b38a7720.tar
pbuilder-9d159d3b06ef7aa208d86304a8b6e005b38a7720.tar.gz
Add a "basic" DEP-8 test
Thanks: James Hunt <james.hunt@ubuntu.com> for the initial patch Closes: #705917
Diffstat (limited to 'debian')
-rw-r--r--debian/control1
-rw-r--r--debian/tests/build-procenv101
-rw-r--r--debian/tests/control3
3 files changed, 105 insertions, 0 deletions
diff --git a/debian/control b/debian/control
index 31daf20..45e7faa 100644
--- a/debian/control
+++ b/debian/control
@@ -17,6 +17,7 @@ Build-Depends: debhelper (>= 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
+Testsuite: autopkgtest
Package: pbuilder
Architecture: all
diff --git a/debian/tests/build-procenv b/debian/tests/build-procenv
new file mode 100644
index 0000000..bab2824
--- /dev/null
+++ b/debian/tests/build-procenv
@@ -0,0 +1,101 @@
+#!/bin/sh
+set -e
+
+#---------------------------------------------------------------------
+# 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.
+pkg=procenv
+
+resultdir=/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" = debian ] ; then
+ release=$(distro-info --testing)
+ components="main"
+ mirror="http://httpredir.debian.org/debian"
+elif [ "$distro" = ubuntu ] ; then
+ release=$(distro-info --devel)
+ components="main universe"
+ mirror="http://archive.ubuntu.com/ubuntu"
+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 chroot for release '$release'"
+echo "+ pbuilder --create --debug --distribution $release --components '$components' --mirror '$mirror'"
+pbuilder --create --debug \
+ --distribution "$release" \
+ --components "$components" \
+ --mirror "$mirror" 2>&1
+
+if [ ! -d "$resultdir" ] ; then
+ die "cannot find directory $resultdir"
+fi
+
+# Use '--download-only' to avoid unpack which generates a
+# signature warning to stderr, causing this test to fail.
+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=${resultdir}/${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"
+
+echo "INFO: Trying to install package '$pkg' from '$deb'"
+echo "INFO: (this might not succeed, that's not a bug)"
+if dpkg -i "$deb" 2>&1 ; then
+ # 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: The install step failed. This can be expected if the host release is different than our target."
+ echo "host release: $host_release"
+ echo "target release: $release"
+fi
+
+echo "INFO: SUCCESS"
diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644
index 0000000..ac186d2
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1,3 @@
+Tests: build-procenv
+Depends: @, debian-keyring, distro-info, lsb-release
+Restrictions: needs-root