Debian Codegraph @

debian/tests/stretch

raw
1 #!/usr/bin/env bash
2 set -Eeuo pipefail
3
4 suite='stretch'
5 timestamp='2017-01-01T00:00:00Z'
6
7 expectedEpoch='1483228800'
8
9 # https://people.debian.org/~tianon/debuerreotype/
10 declare -A expectedSha256s=(
11 ['amd64']='cff511450d3ddec4defc51be1850ca44e527e126aabfa1b6649354f2f2a568f4'
12 ['arm64']='81ad4f5e7c10b15fc8389c1386e1fe1b2d05bc61d404e10473f5f5a0acde464c'
13 ['armel']='596117e125f6e0828471564bd5d4f9bdd1ed654f7d84c21e7ab9d640e789763f'
14 ['armhf']='9e0f63a3d5442fcd1408d61a9c592355138334ddc5c3fb471d5f131511cf286c'
15 ['i386']='b4e574904703114291f1c42bd80744b1da333d95cf5c00e8e71ba09241ca66ae'
16 ['mips64el']='767982e9ca353058d9ca44f410e0367071ebf9938a4a996e3ed9139d57bc987f'
17 ['ppc64el']='99bc8a072448360be9ff741b98466835bc0f270041784cacbcb3803f8d3fbb6a'
18 ['riscv64']='ports'
19 ['s390x']='7ad6fa1abaf9d8cb3fd9d1257e24363bc842f0fe204e98d0a2aa995541b62b1c'
20 )
21 dpkgArch="$(dpkg --print-architecture)"
22 expectedSha256="${expectedSha256s["$dpkgArch"]:-}"
23
24 if [ "$expectedSha256" = 'ports' ]; then
25 echo >&2 "aw, '$dpkgArch' is a ports arch -- bailing early!"
26 exit 0
27 fi
28
29 expectedCompareUrl="https://people.debian.org/~tianon/debuerreotype/$suite--$timestamp--0.14--$dpkgArch--$expectedSha256.txz"
30
31 tempDir="$(mktemp -d)"
32 trap "rm -rf '$tempDir'" EXIT
33 rootfs="$tempDir/rootfs"
34
35 set -x
36
37 # make a new keyring that contains all archive keys so this still works in the future too
38 # (see also "debian.sh" in the debuerreotype examples, which this is a hyper-simplified version of)
39 keyring="$tempDir/keyring.gpg"
40 gpg --batch --no-default-keyring --keyring "$keyring" --import \
41 /usr/share/keyrings/debian-archive-keyring.gpg \
42 /usr/share/keyrings/debian-archive-removed-keys.gpg
43
44 debuerreotype-init --arch="$dpkgArch" --keyring="$keyring" "$rootfs" "$suite" "$timestamp"
45 [ "$(< "$rootfs/debuerreotype-epoch")" = "$expectedEpoch" ]
46
47 debuerreotype-chroot "$rootfs" true
48
49 debuerreotype-debian-sources-list "$rootfs" "$suite"
50 # remove effect of https://github.com/debuerreotype/debuerreotype/pull/56 (to avoid regenerating expected tarballs to compensate)
51 sed -i -e '/^#/d' "$rootfs/etc/apt/sources.list"
52 # remove effect of https://github.com/debuerreotype/debuerreotype/pull/135 (^^^)
53 sed -i -e 's!deb.debian.org/debian-security!security.debian.org/debian-security!g' "$rootfs/etc/apt/sources.list"
54
55 debuerreotype-tar "$rootfs" "$tempDir/actual.tar"
56 sha256="$(sha256sum "$tempDir/actual.tar" | cut -d' ' -f1)"
57
58 # see https://people.debian.org/~tianon/debuerreotype/
59
60 if [ "$sha256" != "$expectedSha256" ]; then
61 if [ -z "$expectedSha256" ]; then
62 (
63 set +x
64 echo >&2
65 echo >&2 "WARNING: no expected SHA256 for '$dpkgArch' known -- please file a bug with this full build output against src:debuerreotype!"
66 echo >&2
67 )
68 exit 0
69 fi
70
71 (
72 set +x
73 echo >&2
74 echo >&2 'ERROR: expected SHA256 does not match actual -- downloading pristine source to compare (via diffoscope)'
75 echo >&2 " - $expectedCompareUrl"
76 echo >&2
77 )
78
79 wget -qO "$tempDir/expected.txz" "$expectedCompareUrl"
80 xz -d < "$tempDir/expected.txz" > "$tempDir/expected.tar"
81 diffoscope >&2 "$tempDir/expected.tar" "$tempDir/actual.tar"
82 exit 1
83 fi