blob: c64e2fa994fd87f44c37f84a0982ba5f7e4990f4 (
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
#!/bin/bash
# Copyright 2014-2017 Holger Levsen <holger@layer-acht.org>
# released under the GPLv=2
DEBUG=false
. /srv/jenkins/bin/common-functions.sh
common_init "$@"
# common code defining db access
. /srv/jenkins/bin/reproducible_common.sh
# support different suites
if [ -z "$1" ] ; then
SUITE="unstable"
else
SUITE="$1"
fi
#
# create script to configure a pbuilder chroot
#
create_customized_tmpfile() {
TMPFILE=$1
shift
cat >> $TMPFILE <<- EOF
#
# this script is run within the pbuilder environment to further customize initially
#
echo
echo "Configuring APT to ignore the Release file expiration"
echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/398future
echo
echo "Working around debootstrap bug https://bugs.debian.org/817236"
if [ -L /dev/ptmx ]; then
rm /dev/ptmx
mknod -m 666 /dev/ptmx c 5 2
fi
echo ".. done"
echo
EOF
}
create_setup_our_repo_tmpfile() {
TMPFILE=$1
shift
cat >> $TMPFILE <<- EOF
#
# this script is run within the pbuilder environment to further customize once more
#
echo "-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.12 (GNU/Linux)
mQINBFQsy/gBEADKGF55qQpXxpTn7E0Vvqho82/HFB/yT9N2wD8TkrejhJ1I6hfJ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fnfJeH7xVDOyMH4A8YemNniKE40LSrZVUbW
QMkJC3VjUF+nSOM+nQSgdSQ2XKfygagv1rWcVqj0etVbcjIMgF+YtQtX5WhXo1de
XTUO1y0rsCyX7mbfEqBDVCGMOvQmwrwk0uLGzzdgzam3/ZTgPoy+n5Adg4x1gU30
nh5rjOKWAyzbLNCt9KXmps+PwuwPSR643q/zr/r4WJTruSyVJAMjwXf8tbYYg8X3
unSrmrxS5T0YA3TfY34ThtHtmjA9d2lzv270ALc3ELv83fTnQ/3Sxkwu+KKIagXQ
KzXCKzHjI89kJT5+7GBHd/nLG1z/3yw/TBzH5zSTgwC+3/EHNMH7WrY2DOzdEZTF
peNsYNcna2Ca8Imozzc5L424lXN3MaiTql7Y1lZJFF5Y/wznbjUQj/5YXj3LVB3W
=5CAZ
-----END PGP PUBLIC KEY BLOCK-----" | apt-key add -
echo 'deb http://reproducible.alioth.debian.org/debian/ ./' > /etc/apt/sources.list.d/reproducible.list
echo
apt-get update
apt-get -y upgrade
apt-get install -y $@
echo
apt-cache policy
echo
dpkg -l
echo
for i in \$(dpkg -l |grep ^ii |awk -F' ' '{print \$2}'); do apt-cache madison "\$i" | head -1 | grep reproducible.alioth.debian.org || true ; done
echo
EOF
}
#
# setup pbuilder for reproducible builds
#
setup_pbuilder() {
SUITE=$1
shift
NAME=$1
shift
PACKAGES="$@" # from our repo
EXTRA_PACKAGES="locales-all fakeroot disorderfs gnupg2" # from sid
echo "$(date -u) - creating /var/cache/pbuilder/${NAME}.tgz now..."
TMPFILE=$(mktemp --tmpdir=$TEMPDIR pbuilder-XXXXXXXXX)
LOG=$(mktemp --tmpdir=$TEMPDIR pbuilder-XXXXXXXX)
if [ "$SUITE" = "experimental" ] ; then
SUITE=unstable
echo "echo 'deb $MIRROR experimental main' > /etc/apt/sources.list.d/experimental.list" > ${TMPFILE}
echo "echo 'deb-src $MIRROR experimental main' >> /etc/apt/sources.list.d/experimental.list" >> ${TMPFILE}
fi
# use host apt proxy configuration for pbuilder too
if [ ! -z "$http_proxy" ] ; then
echo "echo '$(cat /etc/apt/apt.conf.d/80proxy)' > /etc/apt/apt.conf.d/80proxy" >> ${TMPFILE}
pbuilder_http_proxy="--http-proxy $http_proxy"
fi
# setup base.tgz
sudo pbuilder --create $pbuilder_http_proxy --basetgz /var/cache/pbuilder/${NAME}-new.tgz --distribution $SUITE --extrapackages "$EXTRA_PACKAGES"
# customize pbuilder
create_customized_tmpfile ${TMPFILE}
if [ "$DEBUG" = "true" ] ; then
cat "$TMPFILE"
fi
sudo pbuilder --execute $pbuilder_http_proxy --save-after-exec --basetgz /var/cache/pbuilder/${NAME}-new.tgz -- ${TMPFILE} | tee ${LOG}
rm ${TMPFILE}
# add repo only for experimental and sid - keep stretch "real" (and sid progressive!)
if [ "$SUITE" != "stretch" ] ; then
# apply further customisations, eg. install $PACKAGES from our repo
create_setup_our_repo_tmpfile ${TMPFILE} "${PACKAGES}"
if [ "$DEBUG" = "true" ] ; then
cat "$TMPFILE"
fi
sudo pbuilder --execute $pbuilder_http_proxy --save-after-exec --basetgz /var/cache/pbuilder/${NAME}-new.tgz -- ${TMPFILE} | tee ${LOG}
rm ${TMPFILE}
if [ ! -z "$PACKAGES" ] ; then
# finally, confirm things are as they should be
echo
echo "Now let's see whether the correct packages where installed..."
for PKG in ${PACKAGES} ; do
egrep "http://reproducible.alioth.debian.org/debian(/|) ./ Packages" ${LOG} \
| grep -v grep | grep "${PKG} " \
|| ( echo ; echo "Package ${PKG} is not installed at all or probably rather not in our version, so removing the chroot and exiting now." ; sudo rm -v /var/cache/pbuilder/${NAME}-new.tgz ; rm $LOG ; exit 1 )
done
fi
fi
sudo mv /var/cache/pbuilder/${NAME}-new.tgz /var/cache/pbuilder/${NAME}.tgz
# create stamp file to record initial creation date minus some hours so the file will be older than 24h when checked in <24h...
touch -d "$(date -u -d '6 hours ago' '+%Y-%m-%d %H:%M')" /var/log/jenkins/${NAME}.tgz.stamp
rm ${LOG}
}
#
# main
#
BASETGZ=/var/cache/pbuilder/$SUITE-reproducible-base.tgz
STAMP=/var/log/jenkins/$SUITE-reproducible-base.tgz.stamp
if [ -f "$STAMP" ] ; then
if [ -f "$STAMP" -a $(stat -c %Y "$STAMP") -gt $(date +%s) ]; then
if [ $(stat -c %Y "$STAMP") -gt $(date +%s -d "+ 6 months") ]; then
echo "Warning: stamp file is too far in the future, assuming something is wrong and deleting it"
rm -v "$STAMP"
else
echo "stamp file has a timestamp from the future."
exit 1
fi
fi
fi
OLDSTAMP=$(find $STAMP -mtime +1 -exec ls -lad {} \; || echo "nostamp")
if [ -n "$OLDSTAMP" ] || [ ! -f $BASETGZ ] || [ ! -f $STAMP ] ; then
if [ ! -f $BASETGZ ] ; then
echo "No $BASETGZ exists, creating a new one..."
else
echo "$BASETGZ outdated, creating a new one..."
fi
setup_pbuilder $SUITE $SUITE-reproducible-base # list packages which must be installed from our repo here
else
echo "$BASETGZ not old enough, doing nothing..."
fi
echo
|