[buildd-tools-devel] Bug#705926: sbuild: Add basic DEP-8 autopkgtest

James Hunt james.hunt at ubuntu.com
Tue Apr 23 21:37:10 UTC 2013


An updated debdiff with the following changes:

  * debian/tests/build_procenv:
    - Revert to using lsb-release: os-release is available by default, but
      does not provide release name in a portable format.
    - Only install the built .deb if the release built for matches the
      running release.
    - Perform checks on .deb since we might not be able to install it.
  * debian/tests/control:
    - Removed breaks-testbed as this stops the test even running on
      Ubuntu.
    - Added lsb-release dependency.


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 sbuild-0.63.2/debian/changelog sbuild-0.63.2/debian/changelog
--- sbuild-0.63.2/debian/changelog	2013-01-17 14:00:53.000000000 +0000
+++ sbuild-0.63.2/debian/changelog	2013-04-23 22:30:44.000000000 +0100
@@ -1,3 +1,9 @@
+sbuild (0.63.2-1.1ubuntu2) UNRELEASED; urgency=low
+
+  * Added DEP-8 autopkgtest to build procenv.
+
+ -- James Hunt <james.hunt at ubuntu.com>  Tue, 23 Apr 2013 22:30:35 +0100
+
 sbuild (0.63.2-1.1ubuntu1) raring; urgency=low
 
   * Merge from Debian unstable. Remaining changes:
diff -Nru sbuild-0.63.2/debian/control sbuild-0.63.2/debian/control
--- sbuild-0.63.2/debian/control	2012-11-28 12:42:59.000000000 +0000
+++ sbuild-0.63.2/debian/control	2013-04-22 11:00:27.000000000 +0100
@@ -8,6 +8,7 @@
 Standards-Version: 3.9.1
 Vcs-Browser: http://git.debian.org/?p=buildd-tools/sbuild.git
 Vcs-Git: git://git.debian.org/git/buildd-tools/sbuild
+XS-Testsuite: autopkgtest
 
 Package: libsbuild-perl
 Architecture: all
diff -Nru sbuild-0.63.2/debian/tests/build_procenv sbuild-0.63.2/debian/tests/build_procenv
--- sbuild-0.63.2/debian/tests/build_procenv	1970-01-01 01:00:00.000000000 +0100
+++ sbuild-0.63.2/debian/tests/build_procenv	2013-04-23 22:01:46.000000000 +0100
@@ -0,0 +1,170 @@
+#!/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
+
+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
+
+arch=$(dpkg --print-architecture 2>/dev/null)
+[ -z "$arch" ] && die "cannot establish architecture"
+
+[ -z "$ADTTMP" ] && die "ADTTMP not set"
+dir="$ADTTMP/schroot-$release"
+
+# The expected name of the schroot that sbuild-createchroot will create
+chroot="${release}-${arch}-sbuild"
+
+# schroot does not allow a chroot name to be specified at creation time.
+# As such, we must take care to avoid stomping on a developers chroots.
+# If we find any that match the chroot we're about to try and make, exit
+# with a message.
+#
+# Note that we are very cautious in the grep check below; we purposely
+# don't match on the _type_ of schroot in case new schroot types are
+# added and this test is not updated to take account of the new types.
+
+schroots=$(schroot -l 2>/dev/null)
+
+if [ -n "$schroots" ] && echo "$schroots"|grep -q ":${release}-${arch}"
+then
+    echo "INFO:"
+    echo "INFO: Existing schroots detected for current release ($release)"
+    echo "INFO: and architecture ($arch)"
+    echo "INFO:"
+    echo "INFO: Not continuing."
+    echo "INFO:"
+
+    # exit successfully
+    exit 0
+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' from release '$release'"
+apt-get source --download-only "$pkg/$release"
+
+dsc=$(ls ${pkg}*.dsc)
+
+echo "INFO: Creating sbuild chroot '$chroot' for release '$release' in directory '$dir' from url '$url'"
+sbuild-createchroot "$release" "$dir" "$url"
+
+echo "INFO: Checking chroot '$chroot' is known"
+schroot --list --all-chroots|grep "^chroot:${chroot}$"
+
+echo "INFO: Displaying information about chroot '$chroot'"
+schroot --info "${chroot}"
+
+# crucial
+echo "INFO: Creating sbuild key pair"
+sbuild-update --keygen 2>&1
+
+echo "INFO: Building package '$pkg' for release '$release' from '$dsc'"
+sbuild -A -d "$release" $dsc 2>&1
+
+pkg_and_version=$(echo "$dsc"|sed 's/\.dsc$//g')
+deb=${pkg_and_version}_${arch}.deb
+
+echo "INFO: Displaying sbuild log"
+cat ${pkg_and_version}_${arch}*.build
+
+# 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
+
+# There is no sbuild/schroot command to actually delete the chroot, but
+# we do want to clean up fully. The best we can do is end the schroot
+# session, and remove the sym links. Removing the chroot itself is not
+# necessary since it is created below $ADTTMP so will be removed
+# automatically by the AutoPkgTest environment.
+
+echo "INFO: Establishing schroot sessions for chroot '$chroot'"
+session=$(schroot --list --all-sessions|grep "^session:${release}-${arch}-" || :)
+if [ -n "$session" ]
+then
+    count=$(echo "$session"|wc -l)
+    [ $count -eq 1 ] || die "expected 1 session, found $count"
+
+    echo "INFO: Ending schroot session '$session'"
+    schroot --end-session --chroot "$session"
+else
+    echo "INFO: No schroot session to end"
+fi
+
+echo "INFO: Cleaning up"
+
+echo "INFO: Removing sbuild chroot symbolic link for '$chroot'"
+link=$(ls /etc/sbuild/chroot/${chroot})
+# remove soon-to-be-broken symbolic link
+[ -h "$link" ] && rm "$link"
+
+# remove soon-to-be stale configuration file
+echo "INFO: Removing schroot configuration file for '$chroot'"
+config=$(ls /etc/schroot/chroot.d/${chroot}-*)
+[ -f "$config" ] && rm "$config"
+
+echo "INFO: SUCCESS"
diff -Nru sbuild-0.63.2/debian/tests/control sbuild-0.63.2/debian/tests/control
--- sbuild-0.63.2/debian/tests/control	1970-01-01 01:00:00.000000000 +0100
+++ sbuild-0.63.2/debian/tests/control	2013-04-23 22:26:49.000000000 +0100
@@ -0,0 +1,3 @@
+Tests: build_procenv
+Depends: @, distro-info, lsb-release
+Restrictions: needs-root


More information about the Buildd-tools-devel mailing list