[buildd-tools-devel] Bug#705926: sbuild/autopkgtest: modified patch
Jean-Baptiste Lallement
jean-baptiste.lallement at canonical.com
Mon Nov 4 09:43:45 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 sbuild-0.64.1/debian/changelog sbuild-0.64.1/debian/changelog
--- sbuild-0.64.1/debian/changelog 2013-10-13 21:47:06.000000000 +0200
+++ sbuild-0.64.1/debian/changelog 2013-11-04 10:29:00.000000000 +0100
@@ -1,3 +1,9 @@
+sbuild (0.64.1-2) UNRELEASED; urgency=low
+
+ * Added DEP-8 autopkgtest to build procenv.
+
+ -- James Hunt <james.hunt at ubuntu.com> Mon, 04 Nov 2013 10:28:31 +0100
+
sbuild (0.64.1-1) unstable; urgency=low
[ Roger Leigh ]
diff -Nru sbuild-0.64.1/debian/control sbuild-0.64.1/debian/control
--- sbuild-0.64.1/debian/control 2013-05-19 23:31:41.000000000 +0200
+++ sbuild-0.64.1/debian/control 2013-11-04 10:24:57.000000000 +0100
@@ -7,6 +7,7 @@
Standards-Version: 3.9.4
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.64.1/debian/tests/build_procenv sbuild-0.64.1/debian/tests/build_procenv
--- sbuild-0.64.1/debian/tests/build_procenv 1970-01-01 01:00:00.000000000 +0100
+++ sbuild-0.64.1/debian/tests/build_procenv 2013-11-04 10:37:31.000000000 +0100
@@ -0,0 +1,174 @@
+#!/bin/sh
+#---------------------------------------------------------------------
+# DEP-8 test for sbuild.
+#
+# Creates a sbuild chroot, builds a package, installs the resulting
+# .deb, then runs the command provided by the .deb.
+#---------------------------------------------------------------------
+set -e
+
+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=""
+
+distro=$(lsb_release -is|tr '[A-Z]' '[a-z]')
+[ -z "$distro" ] && die "cannot establish distribution"
+
+host_release=$(lsb_release -cs)
+[ -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)
+
+ 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'"
+[ -n "$components" ] && components="--components=$components"
+sbuild-createchroot $components "$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.64.1/debian/tests/control sbuild-0.64.1/debian/tests/control
--- sbuild-0.64.1/debian/tests/control 1970-01-01 01:00:00.000000000 +0100
+++ sbuild-0.64.1/debian/tests/control 2013-11-04 10:24:57.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