Debian Codegraph @

examples/B20autopkgtest

raw
1 #!/bin/bash
2 # Copyright © 2012 Christoph Berg <[email protected]>
3 # © 2013 Michael Prokop <[email protected]>
4 # © 2015 Mattia Rizzolo <[email protected]>
5 #
6 # This file is part of pbuilder -- personal Debian package builder
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
22
23 BUILDDIR="${BUILDDIR:-/tmp/buildd}"
24
25 if [ "${ADT:-}" = "skip" ]; then
26 echo "Skipping autopkgtests as requested (ADT is set to 'skip')"
27 exit 0
28 fi
29
30 if [ "${ADT:-}" = "external" ]; then
31 echo "Skipping internal autopkgtests as external testing was requested via ADT variable"
32 exit 0
33 fi
34
35 set -ex
36
37 cd "$BUILDDIR"/*/debian/..
38
39 apt-get --yes install autodep8
40
41 if [ -z "$(autodep8)" ]; then
42 echo "Package does not have autopkgtest support. Either file"
43 echo "debian/tests/control is missing or there is no autodep8 support."
44 exit 0
45 fi
46
47 if [ ! -f debian/files ]; then
48 echo "Package source is not built, debian/files is missing" >&2
49 exit 1
50 fi
51
52 OPTS="${AUTOPKGTEST_OPTIONS:-$ADT_OPTIONS}"
53 if [ -n "${OPTS}" ]; then
54 echo "*** Using provided AUTOPKGTEST_OPTIONS ${OPTS} ***"
55 fi
56
57 # try to launch autopkgtest in a new PID namespace so several testsuites can run
58 # in parallel, newpid exists in jessie and newer only though
59 unset newpid_name
60 if ! apt-cache policy newpid | grep -q 'newpid:' ; then
61 echo "The newpid package doesn't seem to be available, not considering for installation"
62 else
63 echo "The newpid package seems to be available, considering for installation"
64 newpid_name='newpid'
65 fi
66
67 # runner/adt-run uses apt-utils's apt-ftparchive and
68 # pbuilder's pbuilder-satisfydepends-classic
69 apt-get install -y "${APTGETOPT[@]}" autopkgtest apt-utils pbuilder $newpid_name
70
71 mkdir -p "$BUILDDIR/autopkgtest.out"
72
73 if which autopkgtest >/dev/null; then
74 $newpid_name autopkgtest \
75 --output-dir "$BUILDDIR/autopkgtest.out" \
76 --summary "$BUILDDIR/autopkgtest.summary" \
77 "$BUILDDIR"/*.deb \
78 "${PWD}" \
79 ${OPTS} -- autopkgtest-virt-null || EXIT=$?
80 else
81 # since autopkgtest 3.16 the --tmp-dir option is gone, make sure
82 # we've --output-dir available though before using it
83 if adt-run --help | grep -q -- --output-dir 2>/dev/null ; then
84 OUTPUT_OPTION='--output-dir'
85 else
86 OUTPUT_OPTION='--tmp-dir'
87 fi
88
89 $newpid_name adt-run \
90 ${OUTPUT_OPTION} "$BUILDDIR/autopkgtest.out" \
91 --summary "$BUILDDIR/autopkgtest.summary" \
92 "$BUILDDIR"/*.deb \
93 --built-tree "${PWD}" \
94 ${OPTS} --- adt-virt-null || EXIT=$?
95 fi
96
97 # collect autopkgtest output in a single file so pbuilder automatically copies it
98 tar -caf "$BUILDDIR/autopkgtest.tar.gz" "$BUILDDIR/autopkgtest.out"
99
100 case ${EXIT:-0} in
101 2|4|6|8) # let adtsummary_tap report the failure
102 exit 0
103 ;;
104 *)
105 exit ${EXIT:-0}
106 ;;
107 esac