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