|
1 #!/bin/sh |
|
2 |
|
3 set -e |
|
4 set -x |
|
5 |
|
6 if [ -z "$AUTOPKGTEST_TMP" ]; then |
|
7 echo "Not running as part as autopkgtest" >&2 |
|
8 exit 250 |
|
9 fi |
|
10 |
|
11 # Switch to unprivileged user if needed |
|
12 if [ "$(id -u)" = 0 ]; then |
|
13 apt-get install -q -y sudo |
|
14 echo 'Defaults !fqdn' > /etc/sudoers.d/fqdn |
|
15 echo 'nobody ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/nobody |
|
16 chown nobody:nogroup "$AUTOPKGTEST_TMP" |
|
17 exec su nobody -s /bin/sh -c "$0" |
|
18 fi |
|
19 |
|
20 cd "$AUTOPKGTEST_TMP" |
|
21 |
|
22 # Create a cube |
|
23 PACKAGE="cubicweb-mytest" |
|
24 cubicweb-ctl newcube -s 'Just a test cube' ${PACKAGE#cubicweb-} |
|
25 cd "$PACKAGE" |
|
26 |
|
27 UPSTREAM_VERSION=$(python3 setup.py --version) |
|
28 DEBIAN_VERSION=$(dpkg-parsechangelog -S Version) |
|
29 |
|
30 # Create source tarball |
|
31 python3 setup.py sdist |
|
32 mv "dist/${PACKAGE}-${UPSTREAM_VERSION}.tar.gz" "../${PACKAGE}_${UPSTREAM_VERSION}.orig.tar.gz" |
|
33 |
|
34 # Install build-dependencies |
|
35 mk-build-deps --install --root-cmd sudo --remove \ |
|
36 --tool 'apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends --quiet --assume-yes' |
|
37 |
|
38 # Build! |
|
39 dpkg-buildpackage |
|
40 |
|
41 # Output .buildinfo for posterity |
|
42 cat ../*.buildinfo |
|
43 |
|
44 # Output package content, again for posterity |
|
45 debc |
|
46 |
|
47 # Install the package |
|
48 sudo debi --with-depends |
|
49 |
|
50 lintian -i ../*.dsc ../*.changes |
|
51 |
|
52 # Test if Python module is usable |
|
53 python3 -c 'import cubicweb_mytest; print(dir(cubicweb_mytest))' |
|
54 |
|
55 # Run autopkgtest (uh… inception, anyone?) |
|
56 sudo autopkgtest ../*.changes -- null |