3 # Updates wanna-build databases after the archive maintenance
7 # Sources-* == upstream fetched file
8 # Sources.* == uncompressed, concat'd version
12 #testing must be before unstable so late upld don't build for testing needlessly
13 DISTS="oldstable-security stable-security testing-security oldstable stable testing unstable"
14 STATS_DISTS="unstable testing stable"
15 SECTIONS="main contrib non-free"
16 ARCHS_oldstable="m68k arm sparc alpha powerpc i386 mips mipsel ia64 hppa s390"
17 ARCHS_stable="arm sparc alpha powerpc i386 amd64 mips mipsel ia64 hppa s390"
18 ARCHS_testing="$ARCHS_stable armel"
19 ARCHS_unstable="$ARCHS_testing"
20 TMPDIR="/org/wanna-build/tmp"
21 LOCKFILE="/org/wanna-build/tmp/DB_Maintenance_In_Progress"
22 MASTER="http://incoming.debian.org/debian/dists"
23 MASTERBUILDD="http://incoming.debian.org/buildd"
24 SECMASTER="http://security-master.debian.org/debian-security/dists"
25 SECMASTERBUILDD=http://security-master.debian.org/buildd
26 CURLOPT="-q -s -S -R -f -Y 10 -y 120 -K /srv/wanna-build/trigger.curlrc"
30 local url tmpname destname appendname curlopt
37 if [ -e "$destname" ]; then
38 refdate=`perl -e "print scalar gmtime(((stat ('$destname'))[9]))"`
39 curl $CURLOPT -z "$refdate" "$url" -o "$tmpname"
42 curl $CURLOPT "$url" -o "$tmpname"
45 if [ $rc -eq 0 -a -e "$tmpname" ]; then
46 if gzip -t "$tmpname"; then
47 mv "$tmpname" "$destname"
52 gzip -dc "$destname" >> "$appendname"
58 if lockfile -! -l 3600 $LOCKFILE; then
59 echo "Cannot lock $LOCKFILE"
68 echo Updating wanna-build databases...
71 if [ "$DAY" = "0" ]; then
72 savelog -c 26 -p /srv/wanna-build/db/merge.log
75 exec 3<&1 >> /srv/wanna-build/db/merge.log 2>&1
77 echo -------------------------------------------------------------------------
78 echo "merge triggered: `date`"
79 echo "merge triggered : `date -u`" >&3
84 # Make one big Packages and Sources file.
87 dist=`echo $d | sed s/-.*$//`
90 ARCHS="$ARCHS_oldstable"
96 ARCHS="$ARCHS_testing"
99 ARCHS="$ARCHS_unstable"
102 rm -f Sources.$d Sources.$d-p-u
105 rm -f Packages.$d.$a Packages.$d-p-u.$a quinn-$d-p-u.$a
108 for s in $SECTIONS; do
109 if echo $d | grep -qv -- -security; then
110 curl_index "$MASTER/$dist/$s/source/Sources.gz" "Sources-$d.$s.gz" "Sources.$d"
111 if [ "$d" != "unstable" ]; then
112 curl_index "$MASTER/$dist-proposed-updates/$s/source/Sources.gz" "Sources-$d-proposed-updates.$s.gz" "Sources.$d-p-u"
116 curl_index "$MASTER/$dist/$s/binary-$a/Packages.gz" "Packages-$d.$s.$a.gz" "Packages.$d.$a"
117 if [ "$d" != "unstable" ]; then
118 curl_index "$MASTER/$dist-proposed-updates/$s/binary-$a/Packages.gz" "Packages-$d-proposed-updates.$s.$a.gz" "Packages.$d-p-u.$a"
119 if [ "$d" != "oldstable" -o "$s" = "main" ]; then
120 curl_index "$MASTER/$dist-proposed-updates/$s/debian-installer/binary-$a/Packages.gz" "Packages-$d-proposed-updates-debian-installer.$s.$a.gz" "Packages.$d-p-u.$a"
123 if [ "$d" != "oldstable" -o "$s" = "main" ]; then
124 curl_index "$MASTER/$d/$s/debian-installer/binary-$a/Packages.gz" "Packages-$d-debian-installer.$s.$a.gz" "Packages.$d.$a"
128 curl_index "$SECMASTER/$dist/updates/$s/source/Sources.gz" "Sources-$d.$s.gz" "Sources.$d"
129 if [ "$s" = "main" ]; then
130 curl_index "$SECMASTERBUILDD/$dist/Sources.gz" "Sources-$d.accepted.gz" "Sources.$d"
131 curl_index "$SECMASTERBUILDD/$dist/Packages.gz" "Packages-$d.accepted.gz" "/dev/null"
134 curl_index "$SECMASTER/$dist/updates/$s/binary-$a/Packages.gz" "Packages-$d.$s.$a.gz" "Packages.$d.$a"
135 if [ "$s" = "main" ]; then
136 gzip -dc "Packages-$d.accepted.gz" >> "Packages.$d.$a"
143 # It's important that the accepted file is rebuilt before the daily run,
144 # and that you have that should-be-empty version, to avoid unaccepts and
147 if [ "$d" = "unstable" ]; then
148 rm -f "Sources.$d.base"
149 cp "Sources.$d" "Sources.$d.base"
150 curl_index "$MASTERBUILDD/Sources.gz" "Sources-$d.accepted.gz" "Sources.$d"
151 curl_index "$MASTERBUILDD/Packages.gz" "Packages-$d.accepted.gz" "/dev/null"
154 rm -f "Packages.$d.$a.base"
155 cp "Packages.$d.$a" "Packages.$d.$a.base"
156 gzip -dc "Packages-$d.accepted.gz" >> "Packages.$d.$a"
159 if [ -e "Sources.$d-p-u" ]; then
160 cat "Sources.$d" >> "Sources.$d-p-u"
165 quinn-diff -A $a -a /srv/buildd.debian.org/web/quinn-diff/Packages-arch-specific -s Sources.$d -p Packages.$d.$a >> quinn-$d.$a 2>/dev/null
166 if echo $d | grep -qv -- -security; then
167 if [ "$d" != "unstable" ]; then
168 cat "Packages.$d.$a" >> "Packages.$d-p-u.$a"
169 quinn-diff -A $a -a /srv/buildd.debian.org/web/quinn-diff/Packages-arch-specific -s Sources.$d-p-u -p Packages.$d-p-u.$a >> quinn-$d-p-u.$a 2>/dev/null
170 sed -e 's/\[[-a-z]*:[-a-z]*\]$//' quinn-$d.$a > quinn-$d.$a.grep
171 if [ ! -z quinn-$d.$a.grep ]; then
172 fgrep -vf quinn-$d.$a.grep quinn-$d-p-u.$a > quinn-$d.$a
174 cp quinn-$d-p-u.$a quinn-$d.$a
177 mv "Packages.$d-p-u.$a" "Packages.$d.$a"
181 if [ -e "Sources.$d-p-u" ]; then
182 mv "Sources.$d-p-u" "Sources.$d"
185 echo "fetch and quinn completed: `date -u`"
186 echo "fetch and quinn completed: `date -u`" >&3
189 for a in $ARCHS_unstable ; do
190 wanna-build --create-maintenance-lock --database=$a/build-db
193 dist=`echo $d | sed s/-.*$//`
196 if echo $ARCHS_oldstable | grep -q -v "\b$a\b"; then
201 if echo $ARCHS_stable | grep -q -v "\b$a\b"; then
206 if echo $ARCHS_testing | grep -q -v "\b$a\b"; then
211 if echo $ARCHS_unstable | grep -q -v "\b$a\b"; then
216 # non-free is excluded for legal reasons. buildd needs to
217 # confirm on a per-package and per-buildd basis whether or not
219 perl -pi -e 's#^(non-free)/.*$##msg' quinn-$d.$a
220 if [ "$a" = "$NEWARCH" ]; then
221 wanna-build -v --merge-all --arch=$a --dist=$d --database=$a/build-db Packages.$d.$a quinn-$d.$a Sources.unstable.$NEWARCH
223 wanna-build -v --merge-all --arch=$a --dist=$d --database=$a/build-db Packages.$d.$a quinn-$d.$a Sources.$d
225 mv Packages.$d.$a Packages.$d.$a-old
226 mv quinn-$d.$a quinn-$d.$a-old
228 if [ "$DAY" = "0" ]; then
229 savelog -p -c 26 /srv/wanna-build/db/$a/transactions.log
231 wanna-build --remove-maintenance-lock --database=$a/build-db
235 mv Sources.$d Sources.$d-old
238 echo "merge ended: `date`"
240 # Only update stats if it's been at least 20h since the last time.
243 last=`stat --format="%Y" /srv/wanna-build/etc/graph-data`
245 if (( $last + $interval < $now )); then
246 echo "stats start: `date`"
247 /srv/wanna-build/bin/wb-graph >> /srv/wanna-build/etc/graph-data
248 /srv/wanna-build/bin/wb-graph -p >> /srv/wanna-build/etc/graph2-data
251 /srv/buildd.debian.org/bin/makegraph
252 for a in $ARCHS_stable; do
253 echo Last Updated: `date -u` > /srv/buildd.debian.org/web/stats/$a.txt
254 for d in $STATS_DISTS; do
255 /srv/wanna-build/bin/wanna-build-statistics --database=$a/build-db --dist=$d >> /srv/buildd.debian.org/web/stats/$a.txt
258 echo "stats ended: `date`"