]> git.decadent.org.uk Git - dak.git/blob - config/debian/cron.dinstall
afa2571074eb82bb34e752380a3cb592b9126006
[dak.git] / config / debian / cron.dinstall
1 #! /bin/sh
2 #
3 # Executed daily via cron, out of dak's crontab.
4
5 set -e
6 export SCRIPTVARS=/srv/ftp.debian.org/dak/config/debian/vars
7 . $SCRIPTVARS
8
9 ################################################################################
10
11 # Start logging
12 NOW=`date "+%Y.%m.%d-%H:%M:%S"`
13 LOGFILE="$logdir/dinstall_${NOW}.log"
14 exec > "$LOGFILE" 2>&1
15
16 ts() {
17         TS=$(($TS+1));
18         echo "Archive maintenance timestamp $TS ($1): $(date +%H:%M:%S)"
19 }
20
21 TS=-1
22 ts "startup"
23
24 NOTICE="$ftpdir/Archive_Maintenance_In_Progress"
25 LOCKCU="$lockdir/daily.lock"
26 LOCKAC="$lockdir/unchecked.lock"
27 BRITNEYLOCK="$lockdir/britney.lock"
28 lockac=0
29
30 cleanup() {
31   rm -f "$NOTICE"
32   rm -f "$LOCKCU"
33   if [ "$lockac" -eq "1" ]; then
34     rm -f "$LOCKAC"
35   fi
36   echo "Cleanup"
37 }
38 lockfile -l 3600 $LOCKCU
39 trap cleanup 0
40
41 # This file is simply used to indicate to britney whether or not
42 # the Packages file updates completed sucessfully.  It's not a lock
43 # from our point of view
44 touch ${BRITNEYLOCK}
45
46 rm -f "$NOTICE"
47 cat > "$NOTICE" <<EOF
48 Packages are currently being installed and indices rebuilt.
49 Maintenance is automatic, starting at 07:52 and 19:52 UTC, and
50 ending about an hour later.  This file is then removed.
51
52 You should not mirror the archive during this period.
53 EOF
54
55 # Push merkels qa user, so the qa pages can show "dinstall is running" information
56 echo "Telling merkels QA user that we start dinstall"
57 ssh -2 -i ~dak/.ssh/push_merkel_qa  -o BatchMode=yes -o SetupTimeOut=90 -o ConnectTimeout=90 qa@merkel.debian.org sleep 1 || true
58 ts "init"
59
60 ################################################################################
61
62 echo "Creating pre-daily-cron-job backup of projectb database..."
63 pg_dump projectb > $base/backup/dump_$(date +%Y.%m.%d-%H:%M:%S)
64 ts "pg_dump1"
65
66 ################################################################################
67
68 echo "Updating Bugs docu, Mirror list and mailing-lists.txt"
69 cd $configdir
70 $scriptsdir/update-bugdoctxt
71 $scriptsdir/update-mirrorlists
72 $scriptsdir/update-mailingliststxt
73 $scriptsdir/update-pseudopackages.sh
74 ts "External Updates"
75
76 ################################################################################
77
78 echo "Doing automated p-u-new processing"
79 cd $queuedir/p-u-new
80 date -u -R >> REPORT
81 dak process-new -a -C COMMENTS >> REPORT || true
82 echo >> REPORT
83 ts "p-u-new"
84
85 echo "Doing automated o-p-u-new processing"
86 cd $queuedir/o-p-u-new
87 date -u -R >> REPORT
88 dak process-new -a -C COMMENTS >> REPORT || true
89 echo >> REPORT
90 ts "o-p-u-new"
91
92 ################################################################################
93
94
95 echo "Synchronizing i18n package descriptions"
96 # First sync their newest data
97 cd ${scriptdir}/i18nsync
98 rsync -aq --delete --delete-after ddtp-sync:/does/not/matter . || true
99
100 # Now check if we still know about the packages for which they created the files
101 # is the timestamp signed by us?
102 if $(gpgv --keyring /srv/ftp.debian.org/s3kr1t/dot-gnupg/pubring.gpg timestamp.gpg timestamp); then
103     # now read it. As its signed by us we are sure the content is what we expect, no need
104         # to do more here. And we only test -d a directory on it anyway.
105     TSTAMP=$(cat timestamp)
106     # do we have the dir still?
107     if [ -d ${scriptdir}/i18n/${TSTAMP} ]; then
108         # Lets check!
109         if ${scriptsdir}/ddtp-i18n-check.sh . ${scriptdir}/i18n/${TSTAMP}; then
110                         # Yay, worked, lets copy around
111                         for dir in lenny sid; do
112                                 if [ -d dists/${dir}/ ]; then
113                                         cd dists/${dir}/main/i18n
114                                         rsync -aq --delete --delete-after  . ${ftpdir}/dists/${dir}/main/i18n/.
115                                 fi
116                                 cd ${scriptdir}/i18nsync
117                         done
118                 else
119                         echo "ARRRR, bad guys, wrong files, ARRR"
120                         echo "Arf, Arf, Arf, bad guys, wrong files, arf, arf, arf" | mail debian-l10n-devel@lists.alioth.debian.org
121                 fi
122     else
123                 echo "ARRRR, missing the timestamp ${TSTAMP} directory, not updating i18n, ARRR"
124                 echo "Arf, Arf, Arf, missing the timestamp ${TSTAMP} directory, not updating i18n, arf, arf, arf" | mail debian-l10n-devel@lists.alioth.debian.org
125         fi
126 else
127     echo "ARRRRRRR, could not verify our timestamp signature, ARRR. Don't mess with our files, i18n guys, ARRRRR."
128         echo "Arf, Arf, Arf, could not verify our timestamp signature, arf. Don't mess with our files, i18n guys, arf, arf, arf" | mail debian-l10n-devel@lists.alioth.debian.org
129 fi
130 ts "i18n 1"
131
132 ################################################################################
133
134 lockfile $LOCKAC
135 lockac=1
136 echo "Processing queue/accepted"
137 cd $accepted
138 rm -f REPORT
139 dak process-accepted -pa *.changes | tee REPORT | \
140      mail -s "Install for $(date +%D)" ftpmaster@ftp-master.debian.org
141 chgrp debadmin REPORT
142 chmod 664 REPORT
143 ts "accepted"
144
145 echo "Checking for cruft in overrides"
146 dak check-overrides
147 rm -f $LOCKAC
148 lockac=0
149
150 echo "Fixing symlinks in $ftpdir"
151 symlinks -d -r $ftpdir
152 ts "cruft"
153
154 echo "Generating suite file lists for apt-ftparchive"
155 dak make-suite-file-list
156 ts "make-suite-file-list"
157
158 echo "Updating fingerprints"
159 # Update fingerprints
160 dak import-keyring -L /srv/keyring.debian.org/keyrings/debian-keyring.gpg || true
161 ts "import-keyring"
162
163 # Generate override files
164 echo "Writing overrides into text files"
165 cd $overridedir
166 dak make-overrides
167
168 # FIXME
169 rm -f override.sid.all3
170 for i in main contrib non-free main.debian-installer; do cat override.sid.$i >> override.sid.all3; done
171 ts "overrides"
172
173
174 # Generate Packages and Sources files
175 echo "Generating Packages and Sources files"
176 cd $configdir
177 apt-ftparchive generate apt.conf
178 ts "apt-ftparchive"
179
180 # Generate *.diff/ incremental updates
181 echo "Generating pdiff files"
182 dak generate-index-diffs
183 ts "pdiff"
184
185 # Generate Release files
186 echo "Generating Release files"
187 dak generate-releases
188 ts "release files"
189
190 # Clean out old packages
191 echo "Cleanup old packages/files"
192 dak clean-suites
193 dak clean-queues
194 ts "cleanup"
195
196 # Needs to be rebuilt, as files have moved.  Due to unaccepts, we need to
197 # update this before wanna-build is updated.
198 echo "Regenerating wanna-build/buildd information"
199 psql projectb -A -t -q -c "SELECT filename FROM queue_build WHERE suite = 5 AND queue = 0 AND in_queue = true AND filename ~ 'd(sc|eb)$'" > $dbdir/dists/unstable_accepted.list
200 symlinks -d /srv/incoming.debian.org/buildd > /dev/null
201 apt-ftparchive generate apt.conf.buildd
202 ts "buildd"
203
204 echo "Running various scripts from $scriptsdir"
205 cd $scriptsdir
206 ./mkmaintainers
207 ./copyoverrides
208 ./mklslar
209 ./mkfilesindices
210 ./mkchecksums
211 ts "scripts"
212
213 # (Re)generate the hardlinked mirror directory for "public" buildd / mirror access
214 echo "Regenerating mirror/ hardlink fun"
215 cd ${mirrordir}
216 rsync -aH --link-dest ${ftpdir} --delete --delete-after --ignore-errors ${ftpdir}/. .
217 ts "mirror hardlinks"
218
219 echo "Trigger daily wanna-build run"
220 ssh -o BatchMode=yes -o SetupTimeOut=90 -o ConnectTimeout=90 wbadm@buildd /org/wanna-build/trigger.daily || echo "W-B trigger.daily failed" | mail -s "W-B Daily trigger failed" ftpmaster@ftp-master.debian.org
221 ts "w-b"
222
223 rm -f $NOTICE
224 rm -f $LOCKCU
225
226 ts "locked part finished"
227
228 ################################################################################
229
230 echo "Creating post-daily-cron-job backup of projectb database..."
231 POSTDUMP=$base/backup/dump_$(date +%Y.%m.%d-%H:%M:%S)
232 pg_dump projectb > $POSTDUMP
233 (cd $base/backup; ln -sf $POSTDUMP current)
234 ts "pg_dump2"
235
236 ################################################################################
237
238
239 echo "Expiring old database dumps..."
240 (cd $base/backup; $scriptsdir/expire_dumps -d . -p -f "dump_*")
241 ts "expire_dumps"
242
243 ################################################################################
244
245
246 # Send a report on NEW/BYHAND packages
247 echo "Nagging ftpteam about NEW/BYHAND packages"
248 dak queue-report | mail -e -s "NEW and BYHAND on $(date +%D)" ftpmaster@ftp-master.debian.org
249 # and one on crufty packages
250 echo "Sending information about crufty packages"
251 dak cruft-report > $webdir/cruft-report-daily.txt
252 dak cruft-report -s experimental >> $webdir/cruft-report-daily.txt
253 cat $webdir/cruft-report-daily.txt | mail -e -s "Debian archive cruft report for $(date +%D)" ftpmaster@ftp-master.debian.org
254 ts "reports"
255
256 echo "Updating DM html page"
257 $scriptsdir/dm-monitor >$webdir/dm-uploaders.html
258
259 echo "Categorizing uncategorized bugs filed against ftp.debian.org"
260 dak bts-categorize
261
262 ################################################################################
263
264 # Push katie@merkel so it syncs the projectb there. Returns immediately, the sync runs detached
265 echo "Trigger merkels projectb sync"
266 ssh -2 -o BatchMode=yes -o SetupTimeOut=30 -o ConnectTimeout=30 -i ~/.ssh/push_merkel_projectb katie@merkel.debian.org sleep 1 || true
267 ts "merkel projectb push"
268
269 ################################################################################
270
271
272 ulimit -m 90000 -d 90000 -s 10000 -v 200000
273
274 echo "Using run-parts to run scripts in $base/scripts/distmnt"
275 run-parts --report $base/scripts/distmnt
276 ts "run-parts"
277
278 echo "Exporting package data foo for i18n project"
279 STAMP=$(date "+%Y%m%d%H%M")
280 mkdir -p ${scriptdir}/i18n/${STAMP}
281 cd ${scriptdir}/i18n/${STAMP}
282 dak control-suite -l stable > etch
283 dak control-suite -l testing > lenny
284 dak control-suite -l unstable > sid
285 echo "${STAMP}" > timestamp
286 gpg --secret-keyring /srv/ftp.debian.org/s3kr1t/dot-gnupg/secring.gpg --keyring /srv/ftp.debian.org/s3kr1t/dot-gnupg/pubring.gpg --no-options --batch --no-tty --armour --default-key 6070D3A1 --detach-sign -o timestamp.gpg timestamp
287 rm -f md5sum
288 md5sum * > md5sum
289 cd ${webdir}/
290 ln -sfT ${scriptdir}/i18n/${STAMP} i18n
291
292 cd ${scriptdir}
293 find ./i18n -mtime +2 -mindepth 1 -maxdepth 1 -not -name "${STAMP}" -type d -print0 | xargs --no-run-if-empty -0 rm -rf
294 ts "i18n 2"
295
296 echo "Daily cron scripts successful."
297
298 # Stats pr0n
299 echo "Updating stats data"
300 cd $configdir
301 $scriptsdir/update-ftpstats $base/log/* > $base/misc/ftpstats.data
302 R --slave --vanilla < $base/misc/ftpstats.R
303 ts "stats"
304
305 # Remove the britney lock
306 rm -f ${BRITNEYLOCK}
307
308 # Clean up apt-ftparchive's databases
309 echo "Clean up apt-ftparchive's databases"
310 cd $configdir
311 apt-ftparchive -q clean apt.conf
312 ts "apt-ftparchive cleanup"
313
314 # Compress psql backups
315 echo "Compress old psql backups"
316 (cd $base/backup/
317         find -maxdepth 1 -mindepth 1 -type f -name 'dump_*' \! -name '*.bz2' \! -name '*.gz' -mtime +1 | 
318         while read dumpname; do
319                 echo "Compressing $dumpname"
320                 bzip2 -9 "$dumpname"
321         done
322 )
323 ts "compress"
324
325 echo "Removing old dinstall logfiles"
326 (cd $logdir
327         find -maxdepth 1 -mindepth 1 -type f -name 'dinstall_*' -mtime +60 | 
328         while read dumpname; do
329                 echo "Removing $dumpname"
330                 rm -f "$dumpname"
331         done
332
333         find -maxdepth 1 -mindepth 1 -type f -name 'weekly_*' -mtime +60 | 
334         while read dumpname; do
335                 echo "Removing $dumpname"
336                 rm -f "$dumpname"
337         done
338 )
339 ts "logremove"
340
341 echo "Finally, all is done, sending mail and compressing logfile"
342 exec > /dev/null 2>&1
343
344 $masterdir/tools/logs.py "$LOGFILE"
345
346 cat "$LOGFILE" | mail -s "Log for dinstall run of ${NOW}" cron@ftp-master.debian.org
347 bzip2 -9 "$LOGFILE"
348
349 ################################################################################