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

Proposed by James Hunt
Status: Merged
Merge reported by: Martin Pitt
Merged at revision: not available
Proposed branch: lp:~jamesodhunt/ubuntu/raring/sbuild/dep8-procenv
Merge into: lp:ubuntu/raring/sbuild
Diff against target: 209 lines (+180/-0)
4 files modified
debian/changelog (+6/-0)
debian/control (+1/-0)
debian/tests/build_procenv (+170/-0)
debian/tests/control (+3/-0)
To merge this branch: bzr merge lp:~jamesodhunt/ubuntu/raring/sbuild/dep8-procenv
Reviewer Review Type Date Requested Status
Martin Pitt Approve
Jean-Baptiste Lallement (community) Needs Fixing
Review via email: mp+159596@code.launchpad.net

Description of the change

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

- creates an sbuild 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 sbuild and AutoPkgTest environments to be seen by looking at the logfile for this test.

To post a comment you must log in.
Revision history for this message
James Hunt (jamesodhunt) wrote :
Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

Thanks for your work!

The test passes on first run, but next run will fail because schroot and sbuild configuration files created during the test are not removed at the end while the target chroot has been destroyed.

The 2 files remaining after the tests are:
- /etc/sbuild/chroot/raring-amd64-sbuild which is a broken symlink to the chroot directory
- /etc/schroot/chroot.d/raring-amd64-sbuild-XXXXXX

Note that it can potentially harm the host system if autopkgtest is run with the virt-null driver.

review: Needs Fixing
54. By James Hunt

* debian/tests/build_procenv:
  - Since schroot chroots cannot be named, avoid interfering with
    existing chroots for the current release and architecture.
  - Check schroot chroot is known.
  - Display schroot chroot info.
  - Cleanup by ending a schroot session for the chroot (if there is one)
    and removing the sbuild chroot symlink and schroot config file.

Revision history for this message
James Hunt (jamesodhunt) wrote :

Hi Jibel - thanks for testing. I've now updated the test to:

- bail (successfully) if it detects existing chroots that would interfere with the test.
- cleanup after itself.

55. By James Hunt

* debian/tests/build_procenv: Use the Debian archive as appropriate.

Revision history for this message
James Hunt (jamesodhunt) wrote :
56. By James Hunt

* debian/tests/build_procenv:
  - Use /etc/os-release rather than lsb_release for maximum portability.
  - Explicit archive url handling for debian.
  - Create chroot for latest stable debian release but latest ubuntu
    release.
  - Abort if archive cannot be determined for distribution.
  - More checks and comments.
  - Ensure package source is downloaded for correct release.
* debian/tests/control:
  - add Depends for distro-info.
  - Add 'breaks-testbed' restriction as the test manipulates files in
    /etc.

57. By James Hunt

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

Revision history for this message
Martin Pitt (pitti) wrote :

Verified on current saucy with "run-adt-test -sS lp:~jamesodhunt/ubuntu/raring/sbuild/dep8-procenv". Thanks!

I merged this into the saucy branch, so closing manually.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2013-01-17 08:59:27 +0000
+++ debian/changelog 2013-04-23 21:33:26 +0000
@@ -1,3 +1,9 @@
1sbuild (0.63.2-1.1ubuntu2) UNRELEASED; urgency=low
2
3 * Added DEP-8 autopkgtest to build procenv.
4
5 -- James Hunt <james.hunt@ubuntu.com> Tue, 23 Apr 2013 22:30:35 +0100
6
1sbuild (0.63.2-1.1ubuntu1) raring; urgency=low7sbuild (0.63.2-1.1ubuntu1) raring; urgency=low
28
3 * Merge from Debian unstable. Remaining changes:9 * Merge from Debian unstable. Remaining changes:
410
=== modified file 'debian/control'
--- debian/control 2012-06-23 22:27:58 +0000
+++ debian/control 2013-04-23 21:33:26 +0000
@@ -8,6 +8,7 @@
8Standards-Version: 3.9.18Standards-Version: 3.9.1
9Vcs-Browser: http://git.debian.org/?p=buildd-tools/sbuild.git9Vcs-Browser: http://git.debian.org/?p=buildd-tools/sbuild.git
10Vcs-Git: git://git.debian.org/git/buildd-tools/sbuild10Vcs-Git: git://git.debian.org/git/buildd-tools/sbuild
11XS-Testsuite: autopkgtest
1112
12Package: libsbuild-perl13Package: libsbuild-perl
13Architecture: all14Architecture: all
1415
=== added directory 'debian/tests'
=== added file 'debian/tests/build_procenv'
--- debian/tests/build_procenv 1970-01-01 00:00:00 +0000
+++ debian/tests/build_procenv 2013-04-23 21:33:26 +0000
@@ -0,0 +1,170 @@
1#!/bin/sh -e
2#---------------------------------------------------------------------
3# DEP-8 test for sbuild.
4#
5# Creates a sbuild chroot, builds a package, installs the resulting
6# .deb, then runs the command provided by the .deb.
7#---------------------------------------------------------------------
8
9die()
10{
11 msg="$*"
12 echo "ERROR: $msg" >&2
13 exit 1
14}
15
16# The package we'll ask sbuild to build (we know its buildable since
17# it's already in the archive :-)
18#
19# The advantage of choosing this particular package being that it runs
20# *itself* at the end of its build, which has the nice side-effect of
21# exposing the full sbuild environment to those perusing the autopkgtest
22# logs.
23pkg=procenv
24
25distro=$(lsb_release --id|cut -d: -f2-|awk '{print $1}'|tr '[A-Z]' '[a-z]')
26[ -z "$distro" ] && die "cannot establish distribution"
27
28host_release=$(lsb_release --codename|cut -d: -f2-|awk '{print $1}')
29[ -z "$host_release" ] && die "cannot establish release running on host"
30
31if [ "$distro" = ubuntu ]
32then
33 # Build chroot for latest release.
34 release=$(distro-info --devel)
35
36 url=http://archive.ubuntu.com/ubuntu
37elif [ "$distro" = debian ]
38then
39 # Build chroot for latest stable release since
40 # sid may not be buildable on a particular day.
41 release=$(distro-info --stable)
42
43 url=http://archive.debian.org/debian
44else
45 die "need to know where archive is for distro '$distro'"
46fi
47
48arch=$(dpkg --print-architecture 2>/dev/null)
49[ -z "$arch" ] && die "cannot establish architecture"
50
51[ -z "$ADTTMP" ] && die "ADTTMP not set"
52dir="$ADTTMP/schroot-$release"
53
54# The expected name of the schroot that sbuild-createchroot will create
55chroot="${release}-${arch}-sbuild"
56
57# schroot does not allow a chroot name to be specified at creation time.
58# As such, we must take care to avoid stomping on a developers chroots.
59# If we find any that match the chroot we're about to try and make, exit
60# with a message.
61#
62# Note that we are very cautious in the grep check below; we purposely
63# don't match on the _type_ of schroot in case new schroot types are
64# added and this test is not updated to take account of the new types.
65
66schroots=$(schroot -l 2>/dev/null)
67
68if [ -n "$schroots" ] && echo "$schroots"|grep -q ":${release}-${arch}"
69then
70 echo "INFO:"
71 echo "INFO: Existing schroots detected for current release ($release)"
72 echo "INFO: and architecture ($arch)"
73 echo "INFO:"
74 echo "INFO: Not continuing."
75 echo "INFO:"
76
77 # exit successfully
78 exit 0
79fi
80
81# Use '--download-only' to avoid unpack which generates a
82# signature warning to stderr, causing this test to fail.
83# Take care to download the package version for the release we will
84# create the chroot for.
85echo "INFO: Downloading source for package '$pkg' from release '$release'"
86apt-get source --download-only "$pkg/$release"
87
88dsc=$(ls ${pkg}*.dsc)
89
90echo "INFO: Creating sbuild chroot '$chroot' for release '$release' in directory '$dir' from url '$url'"
91sbuild-createchroot "$release" "$dir" "$url"
92
93echo "INFO: Checking chroot '$chroot' is known"
94schroot --list --all-chroots|grep "^chroot:${chroot}$"
95
96echo "INFO: Displaying information about chroot '$chroot'"
97schroot --info "${chroot}"
98
99# crucial
100echo "INFO: Creating sbuild key pair"
101sbuild-update --keygen 2>&1
102
103echo "INFO: Building package '$pkg' for release '$release' from '$dsc'"
104sbuild -A -d "$release" $dsc 2>&1
105
106pkg_and_version=$(echo "$dsc"|sed 's/\.dsc$//g')
107deb=${pkg_and_version}_${arch}.deb
108
109echo "INFO: Displaying sbuild log"
110cat ${pkg_and_version}_${arch}*.build
111
112# Do what we can to check if the .deb looks usable (since we may not
113# be able to install it to test it properly)
114echo "INFO: Listing information on '$deb'"
115dpkg --info "$deb"
116
117echo "INFO: Listing contents of '$deb'"
118dpkg --contents "$deb"
119
120extract="$ADTTMP/extract"
121echo "INFO: Extracting '$deb' to '$extract'"
122dpkg --extract "$deb" "$extract"
123
124if [ "$release" = "$host_release" ]
125then
126 echo "INFO: Installing package '$pkg' from '$deb'"
127 dpkg -i "$deb"
128
129 # run the command to prove the build worked but also to expose the
130 # auto-package-test environment used for this test.
131 cmd=$pkg
132 echo "INFO: Showing AutoPkgTest environment by running '$cmd' from package '$pkg'"
133 "$cmd"
134else
135 echo "INFO: Not installing package '$pkg' as host release ('$host_release')"
136 echo "INFO: differs to release package is built for ('$release')"
137fi
138
139# There is no sbuild/schroot command to actually delete the chroot, but
140# we do want to clean up fully. The best we can do is end the schroot
141# session, and remove the sym links. Removing the chroot itself is not
142# necessary since it is created below $ADTTMP so will be removed
143# automatically by the AutoPkgTest environment.
144
145echo "INFO: Establishing schroot sessions for chroot '$chroot'"
146session=$(schroot --list --all-sessions|grep "^session:${release}-${arch}-" || :)
147if [ -n "$session" ]
148then
149 count=$(echo "$session"|wc -l)
150 [ $count -eq 1 ] || die "expected 1 session, found $count"
151
152 echo "INFO: Ending schroot session '$session'"
153 schroot --end-session --chroot "$session"
154else
155 echo "INFO: No schroot session to end"
156fi
157
158echo "INFO: Cleaning up"
159
160echo "INFO: Removing sbuild chroot symbolic link for '$chroot'"
161link=$(ls /etc/sbuild/chroot/${chroot})
162# remove soon-to-be-broken symbolic link
163[ -h "$link" ] && rm "$link"
164
165# remove soon-to-be stale configuration file
166echo "INFO: Removing schroot configuration file for '$chroot'"
167config=$(ls /etc/schroot/chroot.d/${chroot}-*)
168[ -f "$config" ] && rm "$config"
169
170echo "INFO: SUCCESS"
0171
=== added file 'debian/tests/control'
--- debian/tests/control 1970-01-01 00:00:00 +0000
+++ debian/tests/control 2013-04-23 21:33:26 +0000
@@ -0,0 +1,3 @@
1Tests: build_procenv
2Depends: @, distro-info, lsb-release
3Restrictions: needs-root

Subscribers

People subscribed via source and target branches

to all changes: