blob: df1c4d70668ba513dec2358b4c541d73b5dc60df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
#!/bin/sh
set -e
#---------------------------------------------------------------------
# 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 pbuilder 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.
pkg=procenv
resultdir=/var/cache/pbuilder/result
# Avoid conflict with ADT
unset TMPDIR
distro=$(lsb_release --id --short|tr '[A-Z]' '[a-z]' || :)
[ -z "$distro" ] && die "cannot establish distribution"
arch=$(dpkg --print-architecture 2>/dev/null)
[ -z "$arch" ] && die "cannot establish architecture"
host_release=$(lsb_release --codename --short || :)
[ -z "$host_release" ] && die "cannot establish release running on host"
if [ "$distro" = debian ] ; then
release=$(distro-info --testing)
components="main"
mirror="http://httpredir.debian.org/debian"
keyring="/usr/share/keyrings/debian-archive-keyring.gpg"
elif [ "$distro" = ubuntu ] ; then
case "$arch" in
amd64|i386) mirror="http://archive.ubuntu.com/ubuntu" ;;
*) mirror="http://ports.ubuntu.com" ;;
esac
release=$(distro-info --devel)
components="main universe"
keyring="/usr/share/keyrings/ubuntu-archive-keyring.gpg"
else
die "need to know where archive is for distro '$distro' on arch '$arch'"
fi
# Have to redirect stderr to avoid ADT thinking the test has failed
# (the return code is still being checked, so this seems reasonable).
echo "INFO: Creating pbuilder chroot for release '$release'"
echo "+ pbuilder --create --debug --distribution '$release' --components '$components' --debootstrapopts --keyring='$keyring' --mirror '$mirror'"
pbuilder --create --debug \
--distribution "$release" \
--components "$components" \
--debootstrapopts --keyring="$keyring" \
--mirror "$mirror" 2>&1
if [ ! -d "$resultdir" ] ; then
die "cannot find directory $resultdir"
fi
# Use '--download-only' to avoid unpack which generates a
# signature warning to stderr, causing this test to fail.
echo "INFO: Downloading source for package '$pkg' release '$release'"
apt-get source --download-only "$pkg/$release"
dsc=$(ls ${pkg}*.dsc)
echo "INFO: Building package '$pkg' for release '$release' from '$dsc'"
pbuilder --build --debug "$dsc" 2>&1
pkg_and_version=$(echo "$dsc"|sed 's/\.dsc$//g')
deb=${resultdir}/${pkg_and_version}_${arch}.deb
# 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"
echo "INFO: Trying to install package '$pkg' from '$deb'"
echo "INFO: (this might not succeed, that's not a bug)"
if dpkg -i "$deb" 2>&1 ; then
# 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: The install step failed. This can be expected if the host release is different than our target."
echo "host release: $host_release"
echo "target release: $release"
fi
echo "INFO: SUCCESS"
|