]> git.decadent.org.uk Git - dak.git/blob - scripts/debian/trigger.daily
Fixed 822 queue report to actually print out the timestamp sanely
[dak.git] / scripts / debian / trigger.daily
1 #!/bin/bash
2 #
3 # Updates wanna-build databases after the archive maintenance
4 # finishes
5 #
6 # Files:
7 #     Sources-* == upstream fetched file
8 #     Sources.* == uncompressed, concat'd version
9 PATH="/bin:/usr/bin"
10 #testing must be before unstable so late upld don't build for testing needlessly
11 DISTS="oldstable-security stable-security testing-security stable testing unstable"
12 STATS_DISTS="unstable testing stable"
13 SECTIONS="main contrib non-free"
14 ARCHS_oldstable="m68k arm sparc alpha powerpc i386 mips mipsel ia64 hppa s390"
15 ARCHS_stable="$ARCHS_oldstable"
16 ARCHS_testing="$ARCHS_stable"
17 ARCHS_unstable="$ARCHS_testing hurd-i386"
18 TMPDIR="/org/wanna-build/tmp"
19 WGETOPT="-q -t2 -w0 -T10"
20 CURLOPT="-q -s -S -f -y 5 -K /org/wanna-build/trigger.curlrc"
21 LOCKFILE="/org/wanna-build/tmp/DB_Maintenance_In_Progress"
22
23 DAY=`date +%w`
24
25 if lockfile -! -l 3600 $LOCKFILE; then
26         echo "Cannot lock $LOCKFILE"
27         exit 1
28 fi
29
30 cleanup() {
31         rm -f "$LOCKFILE"
32 }
33 trap cleanup 0
34
35 echo Updating wanna-build databases...
36 umask 027
37
38 if [ "$DAY" = "0" ]; then
39         savelog -c 26 -p /org/wanna-build/db/merge.log
40 fi
41
42 exec >> /org/wanna-build/db/merge.log 2>&1
43
44 echo -------------------------------------------------------------------------
45 echo "merge triggered `date`"
46
47 cd $TMPDIR
48
49 #
50 # Make one big Packages and Sources file.
51 #
52 for d in $DISTS ; do
53         dist=`echo $d | sed s/-.*$//`
54         case "$dist" in
55                 oldstable)
56                         ARCHS="$ARCHS_oldstable"
57                         ;;
58                 stable)
59                         ARCHS="$ARCHS_stable"
60                         ;;
61                 testing)
62                         ARCHS="$ARCHS_testing"
63                         ;;
64                 *)
65                         ARCHS="$ARCHS_unstable"
66                         ;;
67         esac
68         rm -f Sources.$d
69         if [ "$d" = "unstable" ]; then
70                 gzip -dc /org/incoming.debian.org/buildd/Sources.gz >> Sources.$d
71         fi
72         for a in $ARCHS ; do
73                 rm -f Packages.$d.$a quinn-$d.$a
74                 if [ "$d" = "unstable" ]; then
75                         gzip -dc /org/incoming.debian.org/buildd/Packages.gz >> Packages.$d.$a
76                 fi
77         done
78
79         for s in $SECTIONS ; do
80                 if echo $d | grep -qv -- -security; then
81                         rm -f Sources.gz
82                         gzip -dc /org/ftp.debian.org/ftp/dists/$d/$s/source/Sources.gz >> Sources.$d
83                         if [ "$d" = "testing" -o "$d" = "stable" ]; then
84                                 gzip -dc /org/ftp.debian.org/ftp/dists/$d-proposed-updates/$s/source/Sources.gz >> Sources.$d
85                         fi
86
87                         rm -f Packages.gz
88                         for a in $ARCHS ; do
89                                 gzip -dc /org/ftp.debian.org/ftp/dists/$d/$s/binary-$a/Packages.gz >> Packages.$d.$a
90                                 if [ "$d" = "testing" -o "$d" = "stable" ]; then
91                                         gzip -dc /org/ftp.debian.org/ftp/dists/$d-proposed-updates/$s/binary-$a/Packages.gz >> Packages.$d.$a
92                                 fi
93                                 if [ "$d" = "unstable" -a "$s" = "main" ]; then
94                                         gzip -dc /org/ftp.debian.org/ftp/dists/$d/$s/debian-installer/binary-$a/Packages.gz >> Packages.$d.$a
95                                 fi
96                         done
97                 else
98                         rm -f Sources.gz
99                         if wget $WGETOPT http://security.debian.org/debian-security/dists/$dist/updates/$s/source/Sources.gz; then
100                                 mv Sources.gz Sources-$d.$s.gz
101                         fi
102                         gzip -dc Sources-$d.$s.gz >> Sources.$d
103                         if [ "$s" = "main" ]; then
104                                 if curl $CURLOPT http://security.debian.org/buildd/$dist/Sources.gz -o Sources.gz; then
105                                         mv Sources.gz Sources-$d.accepted.gz
106                                 fi
107                                 gzip -dc Sources-$d.accepted.gz >> Sources.$d
108                                 if curl $CURLOPT http://security.debian.org/buildd/$dist/Packages.gz -o Packages.gz; then
109                                         mv Packages.gz Packages.$d.accepted.gz
110                                 fi
111                         fi
112                         rm -f Packages.gz
113                         for a in $ARCHS ; do
114                                 if wget $WGETOPT http://security.debian.org/debian-security/dists/$dist/updates/$s/binary-$a/Packages.gz; then
115                                         mv Packages.gz Packages.$d.$s.$a.gz
116                                 fi
117                                 gzip -dc Packages.$d.$s.$a.gz >> Packages.$d.$a
118                                 if [ "$s" = "main" ]; then
119                                         gzip -dc Packages.$d.accepted.gz >> Packages.$d.$a
120                                 fi
121                         done
122                 fi
123         done
124
125         for a in $ARCHS ; do
126                 if [ "$d" = "unstable" -o ! -e "quinn-unstable.$a-old" ]; then
127                         quinn-diff -A $a -a /org/buildd.debian.org/web/quinn-diff/Packages-arch-specific -s Sources.$d -p Packages.$d.$a >> quinn-$d.$a
128                 else
129                         if echo $d | grep -qv -- -security; then
130                                 quinn-diff -A $a -a /org/buildd.debian.org/web/quinn-diff/Packages-arch-specific -s Sources.$d -p Packages.$d.$a | fgrep -v -f quinn-unstable.$a-old | grep ":out-of-date\]$" >> quinn-$d.$a
131                                 sed -e 's/\[\w*:\w*]$//' quinn-$d-security.$a > quinn-$d-security.$a.grep
132                                 grep -vf quinn-$d-security.$a quinn-$d.$a > quinn-$d.$a.grep
133                                 mv quinn-$d.$a.grep quinn-$d.$a
134                                 rm quinn-$d-security.$a.grep
135                         else
136                                 quinn-diff -A $a -a /org/buildd.debian.org/web/quinn-diff/Packages-arch-specific -s Sources.$d -p Packages.$d.$a >> quinn-$d.$a
137                         fi
138                 fi
139         done
140 done
141
142 umask 002
143 for a in $ARCHS_unstable ; do
144         wanna-build --create-maintenance-lock --database=$a/build-db
145
146         for d in $DISTS ; do
147                 dist=`echo $d | sed s/-.*$//`
148                 case "$dist" in
149                         oldstable)
150                                 if echo $ARCHS_oldstable | grep -q -v "\b$a\b"; then
151                                         continue
152                                 fi
153                                 ;;
154                         stable)
155                                 if echo $ARCHS_stable | grep -q -v "\b$a\b"; then
156                                         continue
157                                 fi
158                                 ;;
159                         testing)
160                                 if echo $ARCHS_testing | grep -q -v "\b$a\b"; then
161                                         continue
162                                 fi
163                                 ;;
164                         *)
165                                 if echo $ARCHS_unstable | grep -q -v "\b$a\b"; then
166                                         continue
167                                 fi
168                                 ;;
169                 esac
170                 perl -pi -e 's#^(non-free)/.*$##msg' quinn-$d.$a
171                 wanna-build --merge-all --arch=$a --dist=$d --database=$a/build-db Packages.$d.$a quinn-$d.$a Sources.$d
172                 mv Packages.$d.$a Packages.$d.$a-old
173                 mv quinn-$d.$a quinn-$d.$a-old
174         done
175         if [ "$DAY" = "0" ]; then
176                 savelog -p -c 26 /org/wanna-build/db/$a/transactions.log
177         fi
178         wanna-build --remove-maintenance-lock --database=$a/build-db
179 done
180 umask 022
181 for d in $DISTS; do
182         mv Sources.$d Sources.$d-old
183 done
184
185 echo "merge ended `date`"
186 /org/wanna-build/bin/wb-graph >> /org/wanna-build/etc/graph-data
187 /org/wanna-build/bin/wb-graph -p >> /org/wanna-build/etc/graph2-data
188 rm -f "$LOCKFILE"
189 trap -
190 /org/buildd.debian.org/bin/makegraph
191 for a in $ARCHS_stable; do
192         echo Last Updated: `date -u` > /org/buildd.debian.org/web/stats/$a.txt
193         for d in $STATS_DISTS; do
194                 /org/wanna-build/bin/wanna-build-statistics --database=$a/build-db --dist=$d >> /org/buildd.debian.org/web/stats/$a.txt
195         done
196 done