Ubuntu

Merge lp:~jamesodhunt/ubuntu/raring/pbuilder/dep8-procenv into lp:ubuntu/raring/pbuilder

Proposed by James Hunt on 2013-04-18
Status: Merged
Merge reported by: Martin Pitt
Merged at revision: not available
Proposed branch: lp:~jamesodhunt/ubuntu/raring/pbuilder/dep8-procenv
Merge into: lp:ubuntu/raring/pbuilder
Diff against target: 152 lines (+123/-0) 4 files modified
To merge this branch: bzr merge lp:~jamesodhunt/ubuntu/raring/pbuilder/dep8-procenv
Reviewer Review Type Date Requested Status
Martin Pitt 2013-04-18 Approve on 2013-05-27
Jean-Baptiste Lallement (community) Approve on 2013-04-19
Review via email: mp+159690@code.launchpad.net

Description of the Change

Added a DEP-8 test to exercise pbuilder by performing the following:

- creates an pbuilder chroot for the current release
- builds the 'procenv' package (*)
- installs the resulting .deb
- runs the command provided by the .deb

(*) - procenv was chosen to allow both the pbuilder and AutoPkgTest environments to be seen by looking at the logfile for this test.

Analogous to lp:~jamesodhunt/ubuntu/raring/sbuild/dep8-procenv.

To post a comment you must log in.
Jean-Baptiste Lallement (jibel) wrote :

Thanks for this patch!

It worked fine in my test environment. Approved.

review: Approve
Dmitry Shachnev (mitya57) wrote :

I'm not sure if it's a good idea to require network connection for autopkgtests (for apt-get source), but if our server is connected to the web, I have no objections.

Also, please forward this to Debian (if you did not already).

54. By James Hunt on 2013-04-24

* 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.

Martin Pitt (pitti) wrote :

Tested on current saucy with "run-adt-test -sS lp:~jamesodhunt/ubuntu/raring/pbuilder/dep8-procenv pbuilder", success. Thanks!

review: Approve
Martin Pitt (pitti) wrote :

I merge this into saucy, thus closing manually.

Preview Diff

1=== modified file 'debian/changelog'
2--- debian/changelog 2012-11-05 23:27:25 +0000
3+++ debian/changelog 2013-04-24 08:46:12 +0000
4@@ -1,3 +1,9 @@
5+pbuilder (0.213ubuntu2) UNRELEASED; urgency=low
6+
7+ * Added basic DEP-8 autopkgtest.
8+
9+ -- James Hunt <james.hunt@ubuntu.com> Wed, 24 Apr 2013 09:34:33 +0100
10+
11 pbuilder (0.213ubuntu1) raring; urgency=low
12
13 * Merge from Debian unstable (LP: #1075347, LP: #1060101)
14
15=== modified file 'debian/control'
16--- debian/control 2012-11-05 23:27:25 +0000
17+++ debian/control 2013-04-24 08:46:12 +0000
18@@ -18,6 +18,7 @@
19 Standards-Version: 3.9.1
20 XS-Debian-Vcs-Git: git://git.debian.org/git/pbuilder/pbuilder.git
21 XS-Debian-Vcs-Browser: http://git.debian.org/?p=pbuilder/pbuilder.git
22+XS-Testsuite: autopkgtest
23
24 Package: pbuilder
25 Architecture: all
26
27=== added directory 'debian/tests'
28=== added file 'debian/tests/build_procenv'
29--- debian/tests/build_procenv 1970-01-01 00:00:00 +0000
30+++ debian/tests/build_procenv 2013-04-24 08:46:12 +0000
31@@ -0,0 +1,113 @@
32+#!/bin/sh -e
33+
34+#---------------------------------------------------------------------
35+# DEP-8 test for sbuild.
36+#
37+# Creates a sbuild chroot, builds a package, installs the resulting
38+# .deb, then runs the command provided by the .deb.
39+#---------------------------------------------------------------------
40+
41+die()
42+{
43+ msg="$*"
44+ echo "ERROR: $msg" >&2
45+ exit 1
46+}
47+
48+# The package we'll ask sbuild to build (we know its buildable since
49+# it's already in the archive :-)
50+#
51+# The advantage of choosing this particular package being that it runs
52+# *itself* at the end of its build, which has the nice side-effect of
53+# exposing the full sbuild environment to those perusing the autopkgtest
54+# logs.
55+pkg=procenv
56+
57+dir=/var/cache/pbuilder/result
58+
59+# Avoid conflict with ADT
60+unset TMPDIR
61+
62+distro=$(lsb_release --id|cut -d: -f2-|awk '{print $1}'|tr '[A-Z]' '[a-z]' || :)
63+[ -z "$distro" ] && die "cannot establish distribution"
64+
65+host_release=$(lsb_release --codename|cut -d: -f2-|awk '{print $1}' || :)
66+[ -z "$host_release" ] && die "cannot establish release running on host"
67+
68+if [ "$distro" = ubuntu ]
69+then
70+ # Build chroot for latest release.
71+ release=$(distro-info --devel)
72+
73+ url=http://archive.ubuntu.com/ubuntu
74+elif [ "$distro" = debian ]
75+then
76+ # Build chroot for latest stable release since
77+ # sid may not be buildable on a particular day.
78+ release=$(distro-info --stable)
79+
80+ url=http://archive.debian.org/debian
81+else
82+ die "need to know where archive is for distro '$distro'"
83+fi
84+
85+# Have to redirect stderr to avoid ADT thinking the test has failed
86+# (the return code is still being checked, so this seems reasonable).
87+echo "INFO: Creating pbuilder buildd chroot for release '$release'"
88+pbuilder --create --debug \
89+ --distribution "$release" \
90+ --mirror "$url" \
91+ --debootstrapopts --variant=buildd 2>&1
92+
93+if [ ! -d "$dir" ]
94+then
95+ echo "ERROR: cannot find directory $dir" >&2
96+ exit 1
97+fi
98+
99+# Use '--download-only' to avoid unpack which generates a
100+# signature warning to stderr, causing this test to fail.
101+# Take care to download the package version for the release we will
102+# create the chroot for.
103+echo "INFO: Downloading source for package '$pkg' release '$release'"
104+apt-get source --download-only "$pkg/$release"
105+
106+dsc=$(ls ${pkg}*.dsc)
107+
108+echo "INFO: Building package '$pkg' for release '$release' from '$dsc'"
109+pbuilder --build --debug "$dsc" 2>&1
110+
111+arch=$(dpkg --print-architecture 2>/dev/null)
112+[ -z "$arch" ] && die "cannot establish architecture"
113+
114+pkg_and_version=$(echo "$dsc"|sed 's/\.dsc$//g')
115+deb=${dir}/${pkg_and_version}_${arch}.deb
116+
117+# Do what we can to check if the .deb looks usable (since we may not
118+# be able to install it to test it properly)
119+echo "INFO: Listing information on '$deb'"
120+dpkg --info "$deb"
121+
122+echo "INFO: Listing contents of '$deb'"
123+dpkg --contents "$deb"
124+
125+extract="$ADTTMP/extract"
126+echo "INFO: Extracting '$deb' to '$extract'"
127+dpkg --extract "$deb" "$extract"
128+
129+if [ "$release" = "$host_release" ]
130+then
131+ echo "INFO: Installing package '$pkg' from '$deb'"
132+ dpkg -i "$deb"
133+
134+ # run the command to prove the build worked but also to expose the
135+ # auto-package-test environment used for this test.
136+ cmd=$pkg
137+ echo "INFO: Showing AutoPkgTest environment by running '$cmd' from package '$pkg'"
138+ "$cmd"
139+else
140+ echo "INFO: Not installing package '$pkg' as host release ('$host_release')"
141+ echo "INFO: differs to release package is built for ('$release')"
142+fi
143+
144+echo "INFO: SUCCESS"
145
146=== added file 'debian/tests/control'
147--- debian/tests/control 1970-01-01 00:00:00 +0000
148+++ debian/tests/control 2013-04-24 08:46:12 +0000
149@@ -0,0 +1,3 @@
150+Tests: build_procenv
151+Depends: @, debian-keyring, distro-info, lsb-release
152+Restrictions: needs-root

Subscribers

People subscribed via source and target branches

to all changes: