]> git.decadent.org.uk Git - dak.git/blob - config/debian/dinstall.functions
Merge branch 'master' into dbtests
[dak.git] / config / debian / dinstall.functions
1 # -*- mode:sh -*-
2 # Timestamp. Used for dinstall stat graphs
3 function ts() {
4         echo "Archive maintenance timestamp ($1): $(date +%H:%M:%S)"
5 }
6
7 # Remove all locks
8 function remove_locks() {
9     rm -f $LOCK_DAILY $LOCK_ACCEPTED $LOCK_NEW
10 }
11
12 # trap handler for cleaning up on signal / error
13 function cleanup() {
14     remove_locks
15 }
16
17 # If we error out this one is called, *FOLLOWED* by cleanup above
18 function onerror() {
19     ERRDATE=$(date "+%Y.%m.%d-%H:%M:%S")
20
21     subject="ATTENTION ATTENTION!"
22     if [ "${error}" = "false" ]; then
23         subject="${subject} (continued)"
24     else
25         subject="${subject} (interrupted)"
26     fi
27     subject="${subject} dinstall error at ${ERRDATE} in ${STAGEFILE} - (Be quiet, Brain, or I'll stab you with a Q-tip)"
28
29     if [ -r "${STAGEFILE}.log" ]; then
30         cat "${STAGEFILE}.log"
31     else
32         echo "file ${STAGEFILE}.log does not exist, sorry"
33     fi | mail -s "${subject}" -a "X-Debian: DAK" cron@ftp-master.debian.org -- -F "Debian FTP Masters" -f ftpmaster@ftp-master.debian.org
34 }
35
36 ########################################################################
37 # the actual dinstall functions follow                                 #
38 ########################################################################
39
40 # pushing merkels QA user, part one
41 function merkel1() {
42     log "Telling merkels QA user that we start dinstall"
43     ssh -2 -i ~dak/.ssh/push_merkel_qa  -o BatchMode=yes -o SetupTimeOut=90 -o ConnectTimeout=90 qa@qa.debian.org sleep 1
44 }
45
46 # Create the postgres dump files
47 function pgdump_pre() {
48     log "Creating pre-daily-cron-job backup of $PGDATABASE database..."
49     pg_dump > $base/backup/dump_pre_$(date +%Y.%m.%d-%H:%M:%S)
50 }
51
52 function pgdump_post() {
53     log "Creating post-daily-cron-job backup of $PGDATABASE database..."
54     cd $base/backup
55     POSTDUMP=$(date +%Y.%m.%d-%H:%M:%S)
56     pg_dump > $base/backup/dump_$POSTDUMP
57     #pg_dumpall --globals-only > $base/backup/dumpall_$POSTDUMP
58     ln -sf $base/backup/dump_$POSTDUMP current
59     #ln -sf $base/backup/dumpall_$POSTDUMP currentall
60 }
61
62 # Load the dak-dev projectb
63 function pgdakdev() {
64     # Make sure to unset any possible psql variables so we don't drop the wrong
65     # f****** database by accident
66     local PGDATABASE
67     unset PGDATABASE
68     local PGHOST
69     unset PGHOST
70     local PGPORT
71     unset PGPORT
72     local PGUSER
73     unset PGUSER
74     cd $base/backup
75     echo "drop database projectb" | psql -p 5434 template1
76         #cat currentall | psql -p 5433 template1
77     createdb -p 5434 -T template1 projectb
78     fgrep -v '\connect' current | psql -p 5434 projectb
79 }
80
81 # Updating various files
82 function updates() {
83     log "Updating Bugs docu, Mirror list and mailing-lists.txt"
84     cd $configdir
85     $scriptsdir/update-bugdoctxt
86     $scriptsdir/update-mirrorlists
87     $scriptsdir/update-mailingliststxt
88     $scriptsdir/update-pseudopackages.sh
89 }
90
91 # Process (oldstable)-proposed-updates "NEW" queue
92 function punew_do() {
93     date -u -R >> REPORT
94     dak process-policy $1 | tee -a REPORT | mail -a "X-Debian: DAK" -e -s "NEW changes in $1" debian-release@lists.debian.org -- -F "Debian FTP Masters" -f ftpmaster@ftp-master.debian.org
95     echo >> REPORT
96 }
97 function punew() {
98     log "Doing automated p-u-new processing"
99     cd "${queuedir}/p-u-new"
100     punew_do "$1"
101 }
102 function opunew() {
103     log "Doing automated o-p-u-new processing"
104     cd "${queuedir}/o-p-u-new"
105     punew_do "$1"
106 }
107
108 # The first i18n one, syncing new descriptions
109 function i18n1() {
110     log "Synchronizing i18n package descriptions"
111     # First sync their newest data
112     cd ${scriptdir}/i18nsync
113     rsync -aq --delete --delete-after ddtp-sync:/does/not/matter . || true
114
115     # Now check if we still know about the packages for which they created the files
116     # is the timestamp signed by us?
117     if $(gpgv --keyring /srv/ftp-master.debian.org/s3kr1t/dot-gnupg/pubring.gpg timestamp.gpg timestamp); then
118         # now read it. As its signed by us we are sure the content is what we expect, no need
119         # to do more here. And we only test -d a directory on it anyway.
120         TSTAMP=$(cat timestamp)
121         # do we have the dir still?
122         if [ -d ${scriptdir}/i18n/${TSTAMP} ]; then
123             # Lets check!
124             if ${scriptsdir}/ddtp-i18n-check.sh . ${scriptdir}/i18n/${TSTAMP}; then
125                 # Yay, worked, lets copy around
126                 for dir in squeeze sid; do
127                     if [ -d dists/${dir}/ ]; then
128                         cd dists/${dir}/main/i18n
129                         rsync -aq --delete --delete-after  . ${ftpdir}/dists/${dir}/main/i18n/.
130                     fi
131                     cd ${scriptdir}/i18nsync
132                 done
133             else
134                 echo "ARRRR, bad guys, wrong files, ARRR"
135                 echo "Arf, Arf, Arf, bad guys, wrong files, arf, arf, arf" | mail -a "X-Debian: DAK" -s "Don't you kids take anything. I'm watching you. I've got eye implants in the back of my head." debian-l10n-devel@lists.alioth.debian.org -- -F "Debian FTP Masters" -f ftpmaster@ftp-master.debian.org
136             fi
137         else
138             echo "ARRRR, missing the timestamp ${TSTAMP} directory, not updating i18n, ARRR"
139             echo "Arf, Arf, Arf, missing the timestamp ${TSTAMP} directory, not updating i18n, arf, arf, arf" | mail -a "X-Debian: DAK" -s "Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way." debian-l10n-devel@lists.alioth.debian.org -- -F "Debian FTP Masters" -f ftpmaster@ftp-master.debian.org
140         fi
141     else
142         echo "ARRRRRRR, could not verify our timestamp signature, ARRR. Don't mess with our files, i18n guys, ARRRRR."
143         echo "Arf, Arf, Arf, could not verify our timestamp signature, arf. Don't mess with our files, i18n guys, arf, arf, arf" | mail -a "X-Debian: DAK" -s "You can't keep blaming yourself. Just blame yourself once, and move on." debian-l10n-devel@lists.alioth.debian.org -- -F "Debian FTP Masters" -f ftpmaster@ftp-master.debian.org
144     fi
145 }
146
147 function cruft() {
148     log "Checking for cruft in overrides"
149     dak check-overrides
150 }
151
152 function dominate() {
153     log "Removing obsolete source and binary associations"
154     dak dominate
155 }
156
157 function filelist() {
158     log "Generating file lists for apt-ftparchive"
159     dak generate-filelist
160 }
161
162 function fingerprints() {
163     log "Not updating fingerprints - scripts needs checking"
164
165     log "Updating fingerprints"
166     dak import-keyring -L /srv/keyring.debian.org/keyrings/debian-keyring.gpg
167
168     OUTFILE=$(mktemp)
169     dak import-keyring --generate-users "%s" /srv/keyring.debian.org/keyrings/debian-maintainers.gpg >"${OUTFILE}"
170
171     if [ -s "${OUTFILE}" ]; then
172         /usr/sbin/sendmail -odq -oi -t -f envelope@ftp-master.debian.org <<EOF
173 From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>
174 To: <debian-project@lists.debian.org>
175 Subject: Debian Maintainers Keyring changes
176 Content-Type: text/plain; charset=utf-8
177 X-Debian: DAK
178 MIME-Version: 1.0
179
180 The following changes to the debian-maintainers keyring have just been activated:
181
182 $(cat $OUTFILE)
183
184 Debian distribution maintenance software,
185 on behalf of the Keyring maintainers
186
187 EOF
188     fi
189     rm -f "$OUTFILE"
190 }
191
192 function overrides() {
193     log "Writing overrides into text files"
194     cd $overridedir
195     dak make-overrides
196
197     # FIXME
198     rm -f override.sid.all3
199     for i in main contrib non-free main.debian-installer; do cat override.sid.$i >> override.sid.all3; done
200 }
201
202 function mpfm() {
203     log "Generating package / file mapping"
204     dak make-pkg-file-mapping | bzip2 -9 > $base/ftp/indices/package-file.map.bz2
205 }
206
207 function packages() {
208     log "Generating Packages and Sources files"
209     cd $configdir
210     #apt-ftparchive generate apt.conf
211     dak generate-packages-sources
212 }
213
214 function pdiff() {
215     log "Generating pdiff files"
216     dak generate-index-diffs
217 }
218
219 function release() {
220     log "Generating Release files"
221     dak generate-releases
222 }
223
224 function dakcleanup() {
225     log "Cleanup old packages/files"
226     dak clean-suites -m 10000
227     dak clean-queues
228 }
229
230 function buildd_dir() {
231     # Rebuilt the buildd dir to avoid long times of 403
232     log "Regenerating the buildd incoming dir"
233     STAMP=$(date "+%Y%m%d%H%M")
234     make_buildd_dir
235 }
236
237 function mklslar() {
238     cd $ftpdir
239
240     FILENAME=ls-lR
241
242     log "Removing any core files ..."
243     find -type f -name core -print0 | xargs -0r rm -v
244
245     log "Checking permissions on files in the FTP tree ..."
246     find -type f \( \! -perm -444 -o -perm +002 \) -ls
247     find -type d \( \! -perm -555 -o -perm +002 \) -ls
248
249     log "Checking symlinks ..."
250     symlinks -rd .
251
252     log "Creating recursive directory listing ... "
253     rm -f .${FILENAME}.new
254     TZ=UTC ls -lR > .${FILENAME}.new
255
256     if [ -r ${FILENAME}.gz ] ; then
257         mv -f ${FILENAME}.gz ${FILENAME}.old.gz
258         mv -f .${FILENAME}.new ${FILENAME}
259         rm -f ${FILENAME}.patch.gz
260         zcat ${FILENAME}.old.gz | diff -u - ${FILENAME} | gzip -9cfn - >${FILENAME}.patch.gz
261         rm -f ${FILENAME}.old.gz
262     else
263         mv -f .${FILENAME}.new ${FILENAME}
264     fi
265
266     gzip -9cfN ${FILENAME} >${FILENAME}.gz
267     rm -f ${FILENAME}
268 }
269
270 function mkmaintainers() {
271     log 'Creating Maintainers index ... '
272
273     cd $indices
274     dak make-maintainers ${scriptdir}/masterfiles/pseudo-packages.maintainers | \
275         sed -e "s/~[^  ]*\([   ]\)/\1/"  | \
276         awk '{printf "%-20s ", $1; for (i=2; i<=NF; i++) printf "%s ", $i; printf "\n";}' > .new-maintainers
277
278     if ! cmp -s .new-maintainers Maintainers || [ ! -f Maintainers ]; then
279             log "installing Maintainers ... "
280             mv -f .new-maintainers Maintainers
281             gzip -9v <Maintainers >.new-maintainers.gz
282             mv -f .new-maintainers.gz Maintainers.gz
283     else
284         rm -f .new-maintainers
285     fi
286 }
287
288 function mkuploaders() {
289     log 'Creating Uploaders index ... '
290
291     cd $indices
292     dak make-maintainers -u ${scriptdir}/masterfiles/pseudo-packages.maintainers | \
293         sed -e "s/~[^  ]*\([   ]\)/\1/"  | \
294         awk '{printf "%-20s ", $1; for (i=2; i<=NF; i++) printf "%s ", $i; printf "\n";}' > .new-uploaders
295
296     if ! cmp -s .new-uploaders Uploaders || [ ! -f Uploaders ]; then
297             log "installing Uploaders ... "
298             mv -f .new-uploaders Uploaders
299             gzip -9v <Uploaders >.new-uploaders.gz
300             mv -f .new-uploaders.gz Uploaders.gz
301     else
302         rm -f .new-uploaders
303     fi
304 }
305
306 function copyoverrides() {
307     log 'Copying override files into public view ...'
308
309     for ofile in $copyoverrides ; do
310             cd $overridedir
311             chmod g+w override.$ofile
312
313             cd $indices
314
315             newofile=override.$ofile.gz
316             rm -f .newover-$ofile.gz
317             pc="`gzip 2>&1 -9nv <$overridedir/override.$ofile >.newover-$ofile.gz`"
318         if ! cmp -s .newover-$ofile.gz $newofile || [ ! -f $newofile ]; then
319                     log "   installing new $newofile $pc"
320                     mv -f .newover-$ofile.gz $newofile
321                     chmod g+w $newofile
322         else
323                     rm -f .newover-$ofile.gz
324             fi
325     done
326 }
327
328 function mkfilesindices() {
329     umask 002
330     cd $base/ftp/indices/files/components
331
332     ARCHLIST=$(tempfile)
333
334     log "Querying $PGDATABASE..."
335     echo 'SELECT l.path, f.filename, a.arch_string FROM location l JOIN files f ON (f.location = l.id) LEFT OUTER JOIN (binaries b JOIN architecture a ON (b.architecture = a.id)) ON (f.id = b.file)' | psql -At | sed 's/|//;s,^/srv/ftp-master.debian.org/ftp,.,' | sort >$ARCHLIST
336
337     includedirs () {
338         perl -ne 'print; while (m,/[^/]+$,) { $_=$`; print $_ . "\n" unless $d{$_}++; }'
339     }
340     poolfirst () {
341         perl -e '@nonpool=(); while (<>) { if (m,^\./pool/,) { print; } else { push @nonpool, $_; } } print for (@nonpool);'
342     }
343
344     log "Generating sources list"
345     (
346         sed -n 's/|$//p' $ARCHLIST
347         cd $base/ftp
348         find ./dists -maxdepth 1 \! -type d
349         find ./dists \! -type d | grep "/source/"
350     ) | sort -u | gzip -9 > source.list.gz
351
352     log "Generating arch lists"
353
354     ARCHES=$( (<$ARCHLIST sed -n 's/^.*|//p'; echo amd64) | grep . | grep -v all | sort -u)
355     for a in $ARCHES; do
356         (sed -n "s/|$a$//p" $ARCHLIST
357             sed -n 's/|all$//p' $ARCHLIST
358
359             cd $base/ftp
360             find ./dists -maxdepth 1 \! -type d
361             find ./dists \! -type d | grep -E "(proposed-updates.*_$a.changes$|/main/disks-$a/|/main/installer-$a/|/Contents-$a|/binary-$a/)"
362         ) | sort -u | gzip -9 > arch-$a.list.gz
363     done
364
365     log "Generating suite lists"
366
367     suite_list () {
368         printf 'SELECT DISTINCT l.path, f.filename FROM (SELECT sa.source AS source FROM src_associations sa WHERE sa.suite = %d UNION SELECT b.source AS source FROM bin_associations ba JOIN binaries b ON (ba.bin = b.id) WHERE ba.suite = %d) s JOIN dsc_files df ON (s.source = df.source) JOIN files f ON (df.file = f.id) JOIN location l ON (f.location = l.id)\n' $1 $1 | psql -F' ' -A -t
369
370         printf 'SELECT l.path, f.filename FROM bin_associations ba JOIN binaries b ON (ba.bin = b.id) JOIN files f ON (b.file = f.id) JOIN location l ON (f.location = l.id) WHERE ba.suite = %d\n' $1 | psql -F' ' -A -t
371     }
372
373     printf 'SELECT id, suite_name FROM suite\n' | psql -F' ' -At |
374     while read id suite; do
375         [ -e $base/ftp/dists/$suite ] || continue
376         (
377             (cd $base/ftp
378                 distname=$(cd dists; readlink $suite || echo $suite)
379                 find ./dists/$distname \! -type d
380                 for distdir in ./dists/*; do
381                     [ "$(readlink $distdir)" != "$distname" ] || echo $distdir
382                 done
383             )
384             suite_list $id | tr -d ' ' | sed 's,^/srv/ftp-master.debian.org/ftp,.,'
385         ) | sort -u | gzip -9 > suite-${suite}.list.gz
386     done
387
388     log "Finding everything on the ftp site to generate sundries"
389     (cd $base/ftp; find . \! -type d \! -name 'Archive_Maintenance_In_Progress' | sort) >$ARCHLIST
390
391     rm -f sundries.list
392     zcat *.list.gz | cat - *.list | sort -u |
393     diff - $ARCHLIST | sed -n 's/^> //p' > sundries.list
394
395     log "Generating files list"
396
397     for a in $ARCHES; do
398         (echo ./project/trace; zcat arch-$a.list.gz source.list.gz) |
399         cat - sundries.list dists.list project.list docs.list indices.list |
400         sort -u | poolfirst > ../arch-$a.files
401     done
402
403     (cd $base/ftp/
404             for dist in sid squeeze; do
405                     find ./dists/$dist/main/i18n/ \! -type d | sort -u | gzip -9 > $base/ftp/indices/files/components/translation-$dist.list.gz
406             done
407     )
408
409     (cat ../arch-i386.files ../arch-amd64.files; zcat suite-proposed-updates.list.gz ; zcat translation-sid.list.gz ; zcat translation-squeeze.list.gz) |
410     sort -u | poolfirst > ../typical.files
411
412     rm -f $ARCHLIST
413     log "Done!"
414 }
415
416 function mkchecksums() {
417     dsynclist=$dbdir/dsync.list
418     md5list=$indices/md5sums
419
420     log -n "Creating md5 / dsync index file ... "
421
422     cd "$ftpdir"
423     ${bindir}/dsync-flist -q generate $dsynclist --exclude $dsynclist --md5
424     ${bindir}/dsync-flist -q md5sums $dsynclist | gzip -9n > ${md5list}.gz
425     ${bindir}/dsync-flist -q link-dups $dsynclist || true
426 }
427
428 function mirror() {
429     log "Regenerating \"public\" mirror/ hardlink fun"
430     DATE_SERIAL=$(date +"%Y%m%d01")
431     FILESOAPLUS1=$(awk '/serial/ { print $3+1 }' ${TRACEFILE} )
432     if [ "$DATE_SERIAL" -gt "$FILESOAPLUS1" ]; then
433         SERIAL="$DATE_SERIAL"
434     else
435         SERIAL="$FILESOAPLUS1"
436     fi
437     date -u > ${TRACEFILE}
438     echo "Using dak v1" >> ${TRACEFILE}
439     echo "Running on host: $(hostname -f)" >> ${TRACEFILE}
440     echo "Archive serial: ${SERIAL}" >> ${TRACEFILE}
441     cd ${mirrordir}
442     rsync -aH --link-dest ${ftpdir} --delete --delete-after --ignore-errors ${ftpdir}/. .
443 }
444
445 function expire() {
446     log "Expiring old database dumps..."
447     cd $base/backup
448     $scriptsdir/expire_dumps -d . -p -f "dump_*"
449 }
450
451 function transitionsclean() {
452     log "Removing out of date transitions..."
453     cd $base
454     dak transitions -c -a
455 }
456
457 function dm() {
458     log "Updating DM html page"
459     $scriptsdir/dm-monitor >$webdir/dm-uploaders.html
460 }
461
462 function bts() {
463     log "Categorizing uncategorized bugs filed against ftp.debian.org"
464     dak bts-categorize
465 }
466
467 function merkel2() {
468     # Push dak@merkel so it syncs the projectb there. Returns immediately, the sync runs detached
469     log "Trigger merkel/flotows $PGDATABASE sync"
470     ssh -2 -o BatchMode=yes -o SetupTimeOut=30 -o ConnectTimeout=30 -i ~/.ssh/push_merkel_projectb dak@merkel.debian.org sleep 1
471     # Also trigger flotow, the ftpmaster test box
472     ssh -2 -o BatchMode=yes -o SetupTimeOut=30 -o ConnectTimeout=30 -i ~/.ssh/push_flotow_projectb dak@flotow.debconf.org sleep 1
473 }
474
475 function merkel3() {
476     # Push dak@merkel to tell it to sync the dd accessible parts. Returns immediately, the sync runs detached
477     log "Trigger merkels dd accessible parts sync"
478     ssh -2 -o BatchMode=yes -o SetupTimeOut=30 -o ConnectTimeout=30 -i ~/.ssh/push_merkel_ddaccess dak@merkel.debian.org sleep 1
479 }
480
481 function mirrorpush() {
482     log "Starting the mirrorpush"
483     date -u > /srv/ftp.debian.org/web/mirrorstart
484     echo "Using dak v1" >> /srv/ftp.debian.org/web/mirrorstart
485     echo "Running on host $(hostname -f)" >> /srv/ftp.debian.org/web/mirrorstart
486     sudo -H -u archvsync /home/archvsync/runmirrors > ~dak/runmirrors.log 2>&1 &
487 }
488
489 function i18n2() {
490     log "Exporting package data foo for i18n project"
491     STAMP=$(date "+%Y%m%d%H%M")
492     mkdir -p ${scriptdir}/i18n/${STAMP}
493     cd ${scriptdir}/i18n/${STAMP}
494     dak control-suite -l stable > lenny
495     dak control-suite -l testing > squeeze
496     dak control-suite -l unstable > sid
497     echo "${STAMP}" > timestamp
498     gpg --secret-keyring /srv/ftp-master.debian.org/s3kr1t/dot-gnupg/secring.gpg --keyring /srv/ftp-master.debian.org/s3kr1t/dot-gnupg/pubring.gpg --no-options --batch --no-tty --armour --default-key 55BE302B --detach-sign -o timestamp.gpg timestamp
499     rm -f md5sum
500     md5sum * > md5sum
501     cd ${webdir}/
502     ln -sfT ${scriptdir}/i18n/${STAMP} i18n
503
504     cd ${scriptdir}
505     find ./i18n -mindepth 1 -maxdepth 1 -mtime +2 -not -name "${STAMP}" -type d -print0 | xargs --no-run-if-empty -0 rm -rf
506 }
507
508 function stats() {
509     log "Updating stats data"
510     cd $configdir
511     $scriptsdir/update-ftpstats $base/log/* > $base/misc/ftpstats.data
512     R --slave --vanilla < $base/misc/ftpstats.R
513     dak stats arch-space > $webdir/arch-space
514     dak stats pkg-nums > $webdir/pkg-nums
515 }
516
517 function aptftpcleanup() {
518     log "Clean up apt-ftparchive's databases"
519     cd $configdir
520     apt-ftparchive -q clean apt.conf
521 }
522
523 function compress() {
524     log "Compress old psql backups"
525     cd $base/backup/
526     find -maxdepth 1 -mindepth 1 -type f -name 'dump_pre_*' -mtime +2 -print0 | xargs -0 --no-run-if-empty rm
527
528     find -maxdepth 1 -mindepth 1 -type f -name 'dump_*' \! -name '*.bz2' \! -name '*.gz' -mmin +720 |
529     while read dumpname; do
530         echo "Compressing $dumpname"
531         bzip2 -9fv "$dumpname"
532     done
533     find -maxdepth 1 -mindepth 1 -type f -name "dumpall_*" \! -name '*.bz2' \! -name '*.gz' -mmin +720 |
534     while read dumpname; do
535         echo "Compressing $dumpname"
536         bzip2 -9fv "$dumpname"
537     done
538     finddup -l -d $base/backup
539 }
540
541 function logstats() {
542     $masterdir/tools/logs.py "$1"
543 }
544
545 # save timestamp when we start
546 function savetimestamp() {
547         NOW=`date "+%Y.%m.%d-%H:%M:%S"`
548         echo ${NOW} > "${dbdir}/dinstallstart"
549 }
550
551 function maillogfile() {
552     cat "$LOGFILE" | mail -a "X-Debian: DAK" -s "Log for dinstall run of ${NOW}" cron@ftp-master.debian.org -- -F "Debian FTP Masters" -f ftpmaster@ftp-master.debian.org
553 }
554
555 function renamelogfile() {
556     if [ -f "${dbdir}/dinstallstart" ]; then
557         NOW=$(cat "${dbdir}/dinstallstart")
558 #        maillogfile
559         mv "$LOGFILE" "$logdir/dinstall_${NOW}.log"
560         logstats "$logdir/dinstall_${NOW}.log"
561         bzip2 -9 "$logdir/dinstall_${NOW}.log"
562     else
563         error "Problem, I don't know when dinstall started, unable to do log statistics."
564         NOW=`date "+%Y.%m.%d-%H:%M:%S"`
565 #        maillogfile
566         mv "$LOGFILE" "$logdir/dinstall_${NOW}.log"
567         bzip2 -9 "$logdir/dinstall_${NOW}.log"
568     fi
569 }
570
571 function testingsourcelist() {
572     dak ls -s testing -f heidi -r .| egrep 'source$' > ${webdir}/testing.list
573 }
574
575 # do a last run of process-unchecked before dinstall is on.
576 function process_unchecked() {
577     log "Processing the unchecked queue"
578     UNCHECKED_WITHOUT_LOCK="-p"
579     do_unchecked
580     sync_debbugs
581 }
582
583 # do a run of newstage only before dinstall is on.
584 function newstage() {
585     log "Processing the newstage queue"
586     UNCHECKED_WITHOUT_LOCK="-p"
587     do_newstage
588 }
589
590 # Function to update a "statefile" telling people what we are doing
591 # (more or less).
592 #
593 # This should be called with the argument(s)
594 #  - Status name we want to show.
595 #
596 function state() {
597     RIGHTNOW="$(date -u +"%a %b %d %T %Z %Y (%s)")"
598     cat >"${DINSTALLSTATE}" <<EOF
599 Dinstall start: ${DINSTALLBEGIN}
600 Current action: ${1}
601 Action start: ${RIGHTNOW}
602 EOF
603 }
604
605 # extract changelogs and stuff
606 function changelogs() {
607     log "Extracting changelogs"
608     dak make-changelog -e
609     mkdir -p ${exportpublic}/changelogs
610     cd ${exportpublic}/changelogs
611     rsync -aHW --delete --delete-after --ignore-errors ${exportdir}/changelogs/. .
612     sudo -H -u archvsync /home/archvsync/runmirrors metaftpdo > ~dak/runmirrors-metadata.log 2>&1 &
613 }