]> git.decadent.org.uk Git - dak.git/blob - config/debian/dinstall.functions
add pickle file db-metadata-0.5.2.pkl
[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     GZIP='--rsyncable' ; export GZIP
211     #apt-ftparchive generate apt.conf
212     dak generate-packages-sources
213 }
214
215 function pdiff() {
216     log "Generating pdiff files"
217     dak generate-index-diffs
218 }
219
220 function release() {
221     log "Generating Release files"
222     dak generate-releases
223 }
224
225 function dakcleanup() {
226     log "Cleanup old packages/files"
227     dak clean-suites -m 10000
228     dak clean-queues
229 }
230
231 function buildd_dir() {
232     # Rebuilt the buildd dir to avoid long times of 403
233     log "Regenerating the buildd incoming dir"
234     STAMP=$(date "+%Y%m%d%H%M")
235     make_buildd_dir
236 }
237
238 function mklslar() {
239     cd $ftpdir
240
241     FILENAME=ls-lR
242
243     log "Removing any core files ..."
244     find -type f -name core -print0 | xargs -0r rm -v
245
246     log "Checking permissions on files in the FTP tree ..."
247     find -type f \( \! -perm -444 -o -perm +002 \) -ls
248     find -type d \( \! -perm -555 -o -perm +002 \) -ls
249
250     log "Checking symlinks ..."
251     symlinks -rd .
252
253     log "Creating recursive directory listing ... "
254     rm -f .${FILENAME}.new
255     TZ=UTC ls -lR > .${FILENAME}.new
256
257     if [ -r ${FILENAME}.gz ] ; then
258         mv -f ${FILENAME}.gz ${FILENAME}.old.gz
259         mv -f .${FILENAME}.new ${FILENAME}
260         rm -f ${FILENAME}.patch.gz
261         zcat ${FILENAME}.old.gz | diff -u - ${FILENAME} | gzip --rsyncable -9cfn - >${FILENAME}.patch.gz
262         rm -f ${FILENAME}.old.gz
263     else
264         mv -f .${FILENAME}.new ${FILENAME}
265     fi
266
267     gzip --rsyncable -9cfN ${FILENAME} >${FILENAME}.gz
268     rm -f ${FILENAME}
269 }
270
271 function mkmaintainers() {
272     log 'Creating Maintainers index ... '
273
274     cd $indices
275     dak make-maintainers ${scriptdir}/masterfiles/pseudo-packages.maintainers | \
276         sed -e "s/~[^  ]*\([   ]\)/\1/"  | \
277         awk '{printf "%-20s ", $1; for (i=2; i<=NF; i++) printf "%s ", $i; printf "\n";}' > .new-maintainers
278
279     if ! cmp -s .new-maintainers Maintainers || [ ! -f Maintainers ]; then
280             log "installing Maintainers ... "
281             mv -f .new-maintainers Maintainers
282             gzip --rsyncable -9v <Maintainers >.new-maintainers.gz
283             mv -f .new-maintainers.gz Maintainers.gz
284     else
285         rm -f .new-maintainers
286     fi
287 }
288
289 function mkuploaders() {
290     log 'Creating Uploaders index ... '
291
292     cd $indices
293     dak make-maintainers -u ${scriptdir}/masterfiles/pseudo-packages.maintainers | \
294         sed -e "s/~[^  ]*\([   ]\)/\1/"  | \
295         awk '{printf "%-20s ", $1; for (i=2; i<=NF; i++) printf "%s ", $i; printf "\n";}' > .new-uploaders
296
297     if ! cmp -s .new-uploaders Uploaders || [ ! -f Uploaders ]; then
298             log "installing Uploaders ... "
299             mv -f .new-uploaders Uploaders
300             gzip --rsyncable -9v <Uploaders >.new-uploaders.gz
301             mv -f .new-uploaders.gz Uploaders.gz
302     else
303         rm -f .new-uploaders
304     fi
305 }
306
307 function copyoverrides() {
308     log 'Copying override files into public view ...'
309
310     for ofile in $copyoverrides ; do
311             cd $overridedir
312             chmod g+w override.$ofile
313
314             cd $indices
315
316             newofile=override.$ofile.gz
317             rm -f .newover-$ofile.gz
318             pc="`gzip 2>&1 -9nv <$overridedir/override.$ofile >.newover-$ofile.gz`"
319         if ! cmp -s .newover-$ofile.gz $newofile || [ ! -f $newofile ]; then
320                     log "   installing new $newofile $pc"
321                     mv -f .newover-$ofile.gz $newofile
322                     chmod g+w $newofile
323         else
324                     rm -f .newover-$ofile.gz
325             fi
326     done
327 }
328
329 function mkfilesindices() {
330     umask 002
331     cd $base/ftp/indices/files/components
332
333     ARCHLIST=$(tempfile)
334
335     log "Querying $PGDATABASE..."
336     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
337
338     includedirs () {
339         perl -ne 'print; while (m,/[^/]+$,) { $_=$`; print $_ . "\n" unless $d{$_}++; }'
340     }
341     poolfirst () {
342         perl -e '@nonpool=(); while (<>) { if (m,^\./pool/,) { print; } else { push @nonpool, $_; } } print for (@nonpool);'
343     }
344
345     log "Generating sources list"
346     (
347         sed -n 's/|$//p' $ARCHLIST
348         cd $base/ftp
349         find ./dists -maxdepth 1 \! -type d
350         find ./dists \! -type d | grep "/source/"
351     ) | sort -u | gzip --rsyncable -9 > source.list.gz
352
353     log "Generating arch lists"
354
355     ARCHES=$( (<$ARCHLIST sed -n 's/^.*|//p'; echo amd64) | grep . | grep -v all | sort -u)
356     for a in $ARCHES; do
357         (sed -n "s/|$a$//p" $ARCHLIST
358             sed -n 's/|all$//p' $ARCHLIST
359
360             cd $base/ftp
361             find ./dists -maxdepth 1 \! -type d
362             find ./dists \! -type d | grep -E "(proposed-updates.*_$a.changes$|/main/disks-$a/|/main/installer-$a/|/Contents-$a|/binary-$a/)"
363         ) | sort -u | gzip --rsyncable -9 > arch-$a.list.gz
364     done
365
366     log "Generating suite lists"
367
368     suite_list () {
369         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
370
371         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
372     }
373
374     printf 'SELECT id, suite_name FROM suite\n' | psql -F' ' -At |
375     while read id suite; do
376         [ -e $base/ftp/dists/$suite ] || continue
377         (
378             (cd $base/ftp
379                 distname=$(cd dists; readlink $suite || echo $suite)
380                 find ./dists/$distname \! -type d
381                 for distdir in ./dists/*; do
382                     [ "$(readlink $distdir)" != "$distname" ] || echo $distdir
383                 done
384             )
385             suite_list $id | tr -d ' ' | sed 's,^/srv/ftp-master.debian.org/ftp,.,'
386         ) | sort -u | gzip --rsyncable -9 > suite-${suite}.list.gz
387     done
388
389     log "Finding everything on the ftp site to generate sundries"
390     (cd $base/ftp; find . \! -type d \! -name 'Archive_Maintenance_In_Progress' | sort) >$ARCHLIST
391
392     rm -f sundries.list
393     zcat *.list.gz | cat - *.list | sort -u |
394     diff - $ARCHLIST | sed -n 's/^> //p' > sundries.list
395
396     log "Generating files list"
397
398     for a in $ARCHES; do
399         (echo ./project/trace; zcat arch-$a.list.gz source.list.gz) |
400         cat - sundries.list dists.list project.list docs.list indices.list |
401         sort -u | poolfirst > ../arch-$a.files
402     done
403
404     (cd $base/ftp/
405             for dist in sid squeeze; do
406                     find ./dists/$dist/main/i18n/ \! -type d | sort -u | gzip --rsyncable -9 > $base/ftp/indices/files/components/translation-$dist.list.gz
407             done
408     )
409
410     (cat ../arch-i386.files ../arch-amd64.files; zcat suite-proposed-updates.list.gz ; zcat translation-sid.list.gz ; zcat translation-squeeze.list.gz) |
411     sort -u | poolfirst > ../typical.files
412
413     rm -f $ARCHLIST
414     log "Done!"
415 }
416
417 function mkchecksums() {
418     dsynclist=$dbdir/dsync.list
419     md5list=$indices/md5sums
420
421     log -n "Creating md5 / dsync index file ... "
422
423     cd "$ftpdir"
424     ${bindir}/dsync-flist -q generate $dsynclist --exclude $dsynclist --md5
425     ${bindir}/dsync-flist -q md5sums $dsynclist | gzip -9n --rsyncable > ${md5list}.gz
426     ${bindir}/dsync-flist -q link-dups $dsynclist || true
427 }
428
429 function mirror() {
430     log "Regenerating \"public\" mirror/ hardlink fun"
431     DATE_SERIAL=$(date +"%Y%m%d01")
432     FILESOAPLUS1=$(awk '/serial/ { print $3+1 }' ${TRACEFILE} )
433     if [ "$DATE_SERIAL" -gt "$FILESOAPLUS1" ]; then
434         SERIAL="$DATE_SERIAL"
435     else
436         SERIAL="$FILESOAPLUS1"
437     fi
438     date -u > ${TRACEFILE}
439     echo "Using dak v1" >> ${TRACEFILE}
440     echo "Running on host: $(hostname -f)" >> ${TRACEFILE}
441     echo "Archive serial: ${SERIAL}" >> ${TRACEFILE}
442     cd ${mirrordir}
443     rsync -aH --link-dest ${ftpdir} --delete --delete-after --ignore-errors ${ftpdir}/. .
444 }
445
446 function expire() {
447     log "Expiring old database dumps..."
448     cd $base/backup
449     $scriptsdir/expire_dumps -d . -p -f "dump_*"
450 }
451
452 function transitionsclean() {
453     log "Removing out of date transitions..."
454     cd $base
455     dak transitions -c -a
456 }
457
458 function dm() {
459     log "Updating DM html page"
460     $scriptsdir/dm-monitor >$webdir/dm-uploaders.html
461 }
462
463 function bts() {
464     log "Categorizing uncategorized bugs filed against ftp.debian.org"
465     dak bts-categorize
466 }
467
468 function merkel2() {
469     # Push dak@merkel so it syncs the projectb there. Returns immediately, the sync runs detached
470     log "Trigger merkel/flotows $PGDATABASE sync"
471     ssh -2 -o BatchMode=yes -o SetupTimeOut=30 -o ConnectTimeout=30 -i ~/.ssh/push_merkel_projectb dak@merkel.debian.org sleep 1
472     # Also trigger flotow, the ftpmaster test box
473     ssh -2 -o BatchMode=yes -o SetupTimeOut=30 -o ConnectTimeout=30 -i ~/.ssh/push_flotow_projectb dak@flotow.debconf.org sleep 1
474 }
475
476 function merkel3() {
477     # Push dak@merkel to tell it to sync the dd accessible parts. Returns immediately, the sync runs detached
478     log "Trigger merkels dd accessible parts sync"
479     ssh -2 -o BatchMode=yes -o SetupTimeOut=30 -o ConnectTimeout=30 -i ~/.ssh/push_merkel_ddaccess dak@merkel.debian.org sleep 1
480 }
481
482 function mirrorpush() {
483     log "Starting the mirrorpush"
484     date -u > /srv/ftp.debian.org/web/mirrorstart
485     echo "Using dak v1" >> /srv/ftp.debian.org/web/mirrorstart
486     echo "Running on host $(hostname -f)" >> /srv/ftp.debian.org/web/mirrorstart
487     sudo -H -u archvsync /home/archvsync/runmirrors > ~dak/runmirrors.log 2>&1 &
488 }
489
490 function i18n2() {
491     log "Exporting package data foo for i18n project"
492     STAMP=$(date "+%Y%m%d%H%M")
493     mkdir -p ${scriptdir}/i18n/${STAMP}
494     cd ${scriptdir}/i18n/${STAMP}
495     dak control-suite -l stable > lenny
496     dak control-suite -l testing > squeeze
497     dak control-suite -l unstable > sid
498     echo "${STAMP}" > timestamp
499     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
500     rm -f md5sum
501     md5sum * > md5sum
502     cd ${webdir}/
503     ln -sfT ${scriptdir}/i18n/${STAMP} i18n
504
505     cd ${scriptdir}
506     find ./i18n -mindepth 1 -maxdepth 1 -mtime +2 -not -name "${STAMP}" -type d -print0 | xargs --no-run-if-empty -0 rm -rf
507 }
508
509 function stats() {
510     log "Updating stats data"
511     cd $configdir
512     $scriptsdir/update-ftpstats $base/log/* > $base/misc/ftpstats.data
513     R --slave --vanilla < $base/misc/ftpstats.R
514     dak stats arch-space > $webdir/arch-space
515     dak stats pkg-nums > $webdir/pkg-nums
516 }
517
518 function aptftpcleanup() {
519     log "Clean up apt-ftparchive's databases"
520     cd $configdir
521     apt-ftparchive -q clean apt.conf
522 }
523
524 function compress() {
525     log "Compress old psql backups"
526     cd $base/backup/
527     find -maxdepth 1 -mindepth 1 -type f -name 'dump_pre_*' -mtime +2 -print0 | xargs -0 --no-run-if-empty rm
528
529     find -maxdepth 1 -mindepth 1 -type f -name 'dump_*' \! -name '*.bz2' \! -name '*.gz' -mmin +720 |
530     while read dumpname; do
531         echo "Compressing $dumpname"
532         bzip2 -9fv "$dumpname"
533     done
534     find -maxdepth 1 -mindepth 1 -type f -name "dumpall_*" \! -name '*.bz2' \! -name '*.gz' -mmin +720 |
535     while read dumpname; do
536         echo "Compressing $dumpname"
537         bzip2 -9fv "$dumpname"
538     done
539     finddup -l -d $base/backup
540 }
541
542 function logstats() {
543     $masterdir/tools/logs.py "$1"
544 }
545
546 # save timestamp when we start
547 function savetimestamp() {
548         NOW=`date "+%Y.%m.%d-%H:%M:%S"`
549         echo ${NOW} > "${dbdir}/dinstallstart"
550 }
551
552 function maillogfile() {
553     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
554 }
555
556 function renamelogfile() {
557     if [ -f "${dbdir}/dinstallstart" ]; then
558         NOW=$(cat "${dbdir}/dinstallstart")
559 #        maillogfile
560         mv "$LOGFILE" "$logdir/dinstall_${NOW}.log"
561         logstats "$logdir/dinstall_${NOW}.log"
562         bzip2 -9 "$logdir/dinstall_${NOW}.log"
563     else
564         error "Problem, I don't know when dinstall started, unable to do log statistics."
565         NOW=`date "+%Y.%m.%d-%H:%M:%S"`
566 #        maillogfile
567         mv "$LOGFILE" "$logdir/dinstall_${NOW}.log"
568         bzip2 -9 "$logdir/dinstall_${NOW}.log"
569     fi
570 }
571
572 function testingsourcelist() {
573     dak ls -s testing -f heidi -r .| egrep 'source$' > ${webdir}/testing.list
574 }
575
576 # do a last run of process-unchecked before dinstall is on.
577 function process_unchecked() {
578     log "Processing the unchecked queue"
579     UNCHECKED_WITHOUT_LOCK="-p"
580     do_unchecked
581     sync_debbugs
582 }
583
584 # do a run of newstage only before dinstall is on.
585 function newstage() {
586     log "Processing the newstage queue"
587     UNCHECKED_WITHOUT_LOCK="-p"
588     do_newstage
589 }
590
591 # Function to update a "statefile" telling people what we are doing
592 # (more or less).
593 #
594 # This should be called with the argument(s)
595 #  - Status name we want to show.
596 #
597 function state() {
598     RIGHTNOW="$(date -u +"%a %b %d %T %Z %Y (%s)")"
599     cat >"${DINSTALLSTATE}" <<EOF
600 Dinstall start: ${DINSTALLBEGIN}
601 Current action: ${1}
602 Action start: ${RIGHTNOW}
603 EOF
604 }
605
606 # extract changelogs and stuff
607 function changelogs() {
608     log "Extracting changelogs"
609     dak make-changelog -e
610     mkdir -p ${exportpublic}/changelogs
611     cd ${exportpublic}/changelogs
612     rsync -aHW --delete --delete-after --ignore-errors ${exportdir}/changelogs/. .
613     sudo -H -u archvsync /home/archvsync/runmirrors metaftpdo > ~dak/runmirrors-metadata.log 2>&1 &
614 }