]> git.decadent.org.uk Git - dak.git/blob - config/debian/cron.dinstall
Create a hardlinked tree for the buildds
[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: $(date +%H:%M:%S)
19 }
20
21 echo Archive maintenance started at $(date +%H:%M:%S)
22 TS=0
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
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
65 ################################################################################
66
67 ts
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
74 ################################################################################
75
76 ts
77 echo "Doing automated p-u-new processing"
78 cd $queuedir/p-u-new
79 date -u -R >> REPORT
80 dak process-new -a -C COMMENTS >> REPORT || true
81 echo >> REPORT
82
83 ts
84 echo "Doing automated o-p-u-new processing"
85 cd $queuedir/o-p-u-new
86 date -u -R >> REPORT
87 dak process-new -a -C COMMENTS >> REPORT || true
88 echo >> REPORT
89
90 ################################################################################
91
92 ts
93 lockfile $LOCKAC
94 lockac=1
95 echo "Processing queue/accepted"
96 cd $accepted
97 rm -f REPORT
98 dak process-accepted -pa *.changes | tee REPORT | \
99      mail -s "Install for $(date +%D)" ftpmaster@ftp-master.debian.org
100 chgrp debadmin REPORT
101 chmod 664 REPORT
102
103 ts
104 echo "Checking for cruft in overrides"
105 dak check-overrides
106 rm -f $LOCKAC
107 lockac=0
108
109 echo "Fixing symlinks in $ftpdir"
110 symlinks -d -r $ftpdir
111
112 ts
113
114 echo "Generating suite file lists for apt-ftparchive"
115 dak make-suite-file-list
116
117 ts
118
119 echo "Updating fingerprints"
120 # Update fingerprints
121 dak import-keyring -L /srv/keyring.debian.org/keyrings/debian-keyring.gpg || true
122
123 ts
124
125 # Generate override files
126 echo "Writing overrides into text files"
127 cd $overridedir
128 dak make-overrides
129
130 ts
131
132 # FIXME
133 rm -f override.sid.all3
134 for i in main contrib non-free main.debian-installer; do cat override.sid.$i >> override.sid.all3; done
135
136 ts
137
138 # Generate Packages and Sources files
139 echo "Generating Packages and Sources files"
140 cd $configdir
141 apt-ftparchive generate apt.conf
142
143 ts
144
145 # Generate *.diff/ incremental updates
146 echo "Generating pdiff files"
147 dak generate-index-diffs
148
149 ts
150
151 # Generate Release files
152 echo "Generating Release files"
153 dak generate-releases
154
155 ts
156
157 # Clean out old packages
158 echo "Cleanup old packages/files"
159 dak clean-suites
160 dak clean-queues
161
162 ts
163
164 # Needs to be rebuilt, as files have moved.  Due to unaccepts, we need to
165 # update this before wanna-build is updated.
166 echo "Regenerating wanna-build/buildd information"
167 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
168 symlinks -d /srv/incoming.debian.org/buildd > /dev/null
169 apt-ftparchive generate apt.conf.buildd
170
171 ts
172
173 echo "Running various scripts from $scriptsdir"
174 cd $scriptsdir
175 ./mkmaintainers
176 ./copyoverrides
177 ./mklslar
178 ./mkfilesindices
179 ./mkchecksums
180
181 ts
182
183 # (Re)generate the hardlinked mirror directory for "public" buildd / mirror access
184 echo "Regenerating mirror/ hardlink fun"
185 cd ${mirrordir}
186 rsync -aH --link-dest ${ftpdir} --delete --delete-after --ignore-errors ${ftpdir}/. .
187
188
189 ts
190
191 echo "Trigger daily wanna-build run"
192 ssh -o BatchMode=yes -o SetupTimeOut=90 -o ConnectTimeout=90 buildd@buildd /org/wanna-build/trigger.daily || echo "W-B trigger.daily failed" | mail -s "W-B Daily trigger failed" ftpmaster@ftp-master.debian.org
193
194 rm -f $NOTICE
195 rm -f $LOCKCU
196 echo Archive maintenance finished at $(date +%H:%M:%S)
197
198 ################################################################################
199
200 echo "Creating post-daily-cron-job backup of projectb database..."
201 POSTDUMP=$base/backup/dump_$(date +%Y.%m.%d-%H:%M:%S)
202 pg_dump projectb > $POSTDUMP
203 (cd $base/backup; ln -sf $POSTDUMP current)
204
205 ################################################################################
206
207 ts
208
209 echo "Expiring old database dumps..."
210 (cd $base/backup; $scriptsdir/expire_dumps -d . -p -f "dump_*")
211
212 ################################################################################
213
214 ts
215
216 # Send a report on NEW/BYHAND packages
217 echo "Nagging ftpteam about NEW/BYHAND packages"
218 dak queue-report | mail -e -s "NEW and BYHAND on $(date +%D)" ftpmaster@ftp-master.debian.org
219 # and one on crufty packages
220 echo "Sending information about crufty packages"
221 dak cruft-report > $webdir/cruft-report-daily.txt
222 dak cruft-report -s experimental >> $webdir/cruft-report-daily.txt
223 cat $webdir/cruft-report-daily.txt | mail -e -s "Debian archive cruft report for $(date +%D)" ftpmaster@ftp-master.debian.org
224
225 ts
226
227 echo "Updating DM html page"
228 $scriptsdir/dm-monitor >$webdir/dm-uploaders.html
229
230 ################################################################################
231
232 # Push katie@merkel so it syncs the projectb there. Returns immediately, the sync runs detached
233 echo "Trigger merkels projectb sync"
234 ssh -2 -o BatchMode=yes -o SetupTimeOut=30 -o ConnectTimeout=30 -i ~/.ssh/push_merkel_projectb katie@merkel.debian.org sleep 1 || true
235
236 ################################################################################
237
238 ts
239
240 ulimit -m 90000 -d 90000 -s 10000 -v 200000
241
242 echo "Using run-parts to run scripts in $base/scripts/distmnt"
243 run-parts --report $base/scripts/distmnt
244
245 echo "Daily cron scripts successful."
246
247 ts
248
249 # Stats pr0n
250 echo "Updating stats data"
251 cd $configdir
252 $scriptsdir/update-ftpstats $base/log/* > $base/misc/ftpstats.data
253 R --slave --vanilla < $base/misc/ftpstats.R
254
255 ts
256
257 # Remove the britney lock
258 rm -f ${BRITNEYLOCK}
259
260 # Clean up apt-ftparchive's databases
261 echo "Clean up apt-ftparchive's databases"
262 cd $configdir
263 apt-ftparchive -q clean apt.conf
264
265 ts
266
267 # Compress psql backups
268 echo "Compress old psql backups"
269 (cd $base/backup/
270         find -maxdepth 1 -mindepth 1 -type f -name 'dump_*' \! -name '*.bz2' \! -name '*.gz' -mtime +1 | 
271         while read dumpname; do
272                 echo "Compressing $dumpname"
273                 bzip2 -9 "$dumpname"
274         done
275 )
276
277 ts
278
279 echo "Finally, all is done, sending mail and compressing logfile"
280 exec > /dev/null 2>&1
281
282 cat "$LOGFILE" | mail -s "Log for dinstall run of ${NOW}" cron@ftp-master.debian.org
283 bzip2 -9 "$LOGFILE"
284
285 ################################################################################