]> git.decadent.org.uk Git - dak.git/blob - config/debian/dinstall.functions
remove more unused code
[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 daily lock
8 function remove_daily_lock() {
9     rm -f $LOCK_DAILY
10 }
11
12 # Remove changelog lock
13 function remove_changelog_lock() {
14     rm -f $LOCK_CHANGELOG
15 }
16
17 # Remove all locks
18 function remove_all_locks() {
19     rm -f $LOCK_DAILY $LOCK_ACCEPTED
20 }
21
22 function remove_locks {
23     remove_all_locks
24     trap - EXIT TERM HUP INT QUIT
25     ts "locked part finished"
26 }
27
28 function lockaccepted {
29     lockfile "$LOCK_ACCEPTED"
30     trap remove_all_locks EXIT TERM HUP INT QUIT
31 }
32
33 # If we error out this one is called, *FOLLOWED* by cleanup above
34 function onerror() {
35     ERRDATE=$(date "+%Y.%m.%d-%H:%M:%S")
36
37     subject="ATTENTION ATTENTION!"
38     if [ "${error}" = "false" ]; then
39         subject="${subject} (continued)"
40     else
41         subject="${subject} (interrupted)"
42     fi
43     subject="${subject} dinstall error at ${ERRDATE} in ${STAGEFILE} - (Be quiet, Brain, or I'll stab you with a Q-tip)"
44
45     if [ -r "${STAGEFILE}.log" ]; then
46         cat "${STAGEFILE}.log"
47     else
48         echo "file ${STAGEFILE}.log does not exist, sorry"
49     fi | mail -s "${subject}" -a "X-Debian: DAK" -a "From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>" cron@ftp-master.debian.org
50 }
51
52 ########################################################################
53 # the actual dinstall functions follow                                 #
54 ########################################################################
55
56 # pushing merkels QA user, part one
57 function qa1() {
58     log "Telling QA user that we start dinstall"
59     ssh -n -2 -i ~dak/.ssh/push_merkel_qa  -o BatchMode=yes -o SetupTimeOut=90 -o ConnectTimeout=90 qa@qa.debian.org sleep 1
60 }
61
62 # Updating various files
63 function updates() {
64     log "Updating Bugs docu, Mirror list and mailing-lists.txt"
65     cd $configdir
66     $scriptsdir/update-bugdoctxt
67     $scriptsdir/update-mirrorlists
68     $scriptsdir/update-mailingliststxt
69     $scriptsdir/update-pseudopackages.sh
70 }
71
72 # The first i18n one, syncing new descriptions
73 function i18n1() {
74     log "Synchronizing i18n package descriptions"
75     # First sync their newest data
76     cd ${scriptdir}/i18nsync
77     rsync -aq --delete --delete-after ddtp-sync:/does/not/matter . || true
78
79     # Now check if we still know about the packages for which they created the files
80     # is the timestamp signed by us?
81     if $(gpgv --keyring /srv/ftp-master.debian.org/s3kr1t/dot-gnupg/pubring.gpg timestamp.gpg timestamp); then
82         # now read it. As its signed by us we are sure the content is what we expect, no need
83         # to do more here. And we only test -d a directory on it anyway.
84         TSTAMP=$(cat timestamp)
85         # do we have the dir still?
86         if [ -d ${scriptdir}/i18n/${TSTAMP} ]; then
87             # Lets check!
88             if ${scriptsdir}/ddtp-i18n-check.sh . ${scriptdir}/i18n/${TSTAMP}; then
89                 # Yay, worked, lets copy around
90                 for dir in ${extimportdists}; do
91                     if [ -d dists/${dir}/ ]; then
92                         cd dists/${dir}/main/i18n
93                         rsync -aq --delete --delete-after --exclude Translation-en.bz2 --exclude Translation-*.diff/ . ${ftpdir}/dists/${dir}/main/i18n/.
94                     fi
95                     cd ${scriptdir}/i18nsync
96                 done
97             else
98                 echo "ARRRR, bad guys, wrong files, ARRR"
99                 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." -a "From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>" debian-l10n-devel@lists.alioth.debian.org
100             fi
101         else
102             echo "ARRRR, missing the timestamp ${TSTAMP} directory, not updating i18n, ARRR"
103             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." -a "From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>" debian-l10n-devel@lists.alioth.debian.org
104         fi
105     else
106         echo "ARRRRRRR, could not verify our timestamp signature, ARRR. Don't mess with our files, i18n guys, ARRRRR."
107         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." -a "From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>" debian-l10n-devel@lists.alioth.debian.org
108     fi
109 }
110
111 # Syncing AppStream/DEP-11 data
112 function dep11() {
113     log "Synchronizing AppStream metadata"
114     # First sync their newest data
115     local dep11dir="${scriptdir}/dep11"
116     mkdir -p ${dep11dir}
117     cd ${dep11dir}
118     rsync -aq --delete --delete-after dep11-sync:/does/not/matter . || true
119
120     # Lets check!
121     if ${scriptsdir}/dep11-basic-validate.py . ${dep11dir}/; then
122         # Yay, worked, lets copy around
123         for dir in ${extimportdists}; do
124             if [ -d ${dir}/ ]; then
125                 for comp in main contrib non-free; do
126                     mkdir -p ${ftpdir}/dists/${dir}/${comp}/dep11
127                     cd ${dir}/${comp}
128                     rsync -aq --delete --delete-after --exclude *.tmp . ${ftpdir}/dists/${dir}/${comp}/dep11/.
129                     cd ${dep11dir}
130                 done
131             fi
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." -a "From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>" mak@debian.org
136     fi
137 }
138
139 function cruft() {
140     log "Checking for cruft in overrides"
141     dak check-overrides
142 }
143
144 function dominate() {
145     log "Removing obsolete source and binary associations"
146     dak dominate
147     dak manage-debug-suites unstable-debug experimental-debug
148 }
149
150 function autocruft() {
151     log "Check for obsolete binary packages"
152     dak auto-decruft -s unstable
153     dak auto-decruft -s experimental --if-newer-version-in unstable --if-newer-version-in-rm-msg "NVIU"
154 }
155
156 function fingerprints() {
157     log "Updating fingerprints"
158     dak import-keyring -L /srv/keyring.debian.org/keyrings/debian-keyring.gpg
159
160     OUTFILE=$(mktemp)
161     dak import-keyring --generate-users "%s" /srv/keyring.debian.org/keyrings/debian-maintainers.gpg >"${OUTFILE}"
162
163     if [ -s "${OUTFILE}" ]; then
164         /usr/sbin/sendmail -odq -oi -t -f envelope@ftp-master.debian.org <<EOF
165 From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>
166 To: <debian-project@lists.debian.org>
167 Subject: Debian Maintainers Keyring changes
168 Content-Type: text/plain; charset=utf-8
169 X-Debian: DAK
170 MIME-Version: 1.0
171
172 The following changes to the debian-maintainers keyring have just been activated:
173
174 $(cat $OUTFILE)
175
176 Debian distribution maintenance software,
177 on behalf of the Keyring maintainers
178
179 EOF
180     fi
181     rm -f "$OUTFILE"
182 }
183
184 function overrides() {
185     log "Writing overrides into text files"
186     cd $overridedir
187     dak make-overrides
188 }
189
190 function mpfm() {
191     local archiveroot
192
193     log "Generating package / file mapping"
194     for archive in "${public_archives[@]}"; do
195         archiveroot="$(get_archiveroot "${archive}")"
196         dak make-pkg-file-mapping "${archive}" | bzip2 -9 > "${archiveroot}/indices/package-file.map.bz2"
197     done
198 }
199
200 function packages() {
201     log "Generating Packages and Sources files"
202     for archive in "${public_archives[@]}"; do
203         log "  Generating Packages/Sources for ${archive}"
204         dak generate-packages-sources2 -a "${archive}"
205         log "  Generating Contents for ${archive}"
206         dak contents generate -a "${archive}"
207     done
208 }
209
210 function pdiff() {
211     log "Generating pdiff files"
212     dak generate-index-diffs
213 }
214
215 function release() {
216     log "Generating Release files"
217     for archive in "${public_archives[@]}"; do
218         dak generate-releases -a "${archive}"
219     done
220 }
221
222 function dakcleanup() {
223     log "Cleanup old packages/files"
224     dak clean-suites -m 10000
225     dak clean-queues -i "$unchecked"
226 }
227
228 function mklslar() {
229     local archiveroot
230     local FILENAME=ls-lR
231
232     for archive in "${public_archives[@]}"; do
233         archiveroot="$(get_archiveroot "${archive}")"
234         cd "${archiveroot}"
235
236         log "Removing any core files ..."
237         find -type f -name core -print -delete
238
239         log "Checking symlinks ..."
240         symlinks -rd .
241
242         log "Creating recursive directory listing ... "
243         rm -f ${FILENAME}.gz
244         TZ=UTC ls -lR | gzip -9c --rsyncable > ${FILENAME}.gz
245     done
246 }
247
248 function mkmaintainers() {
249     local archiveroot
250     local indices
251
252     log 'Creating Maintainers index ... '
253
254     for archive in "${public_archives[@]}"; do
255         archiveroot="$(get_archiveroot "${archive}")"
256         indices="${archiveroot}/indices"
257         if ! [ -d "${indices}" ]; then
258             mkdir "${indices}"
259         fi
260         cd "${indices}"
261
262         dak make-maintainers -a "${archive}" ${scriptdir}/masterfiles/pseudo-packages.maintainers
263         gzip -9v --rsyncable <Maintainers >Maintainers.gz
264         gzip -9v --rsyncable <Uploaders >Uploaders.gz
265     done
266 }
267
268 function copyoverrides() {
269     log 'Copying override files into public view ...'
270
271     (
272         shopt -s nullglob
273         for ofile in ${overridedir}/override.{squeeze,wheezy,jessie,stretch,sid}.{,extra.}{main,contrib,non-free}*; do
274             bname=${ofile##*/}
275             gzip -9cv --rsyncable ${ofile} > ${indices}/${bname}.gz
276             chmod g+w ${indices}/${bname}.gz
277         done
278     )
279 }
280
281 function mkfilesindices() {
282     set +o pipefail
283     umask 002
284     cd $base/ftp/indices/files/components
285
286     ARCHLIST=$(tempfile)
287
288     log "Querying postgres"
289     local query="
290       SELECT './pool/' || c.name || '/' || f.filename AS path, a.arch_string AS arch_string
291       FROM files f
292       JOIN files_archive_map af ON f.id = af.file_id
293       JOIN component c ON af.component_id = c.id
294       JOIN archive ON af.archive_id = archive.id
295       LEFT OUTER JOIN
296         (binaries b
297          JOIN architecture a ON b.architecture = a.id)
298         ON f.id = b.file
299       WHERE archive.name = 'ftp-master'
300       ORDER BY path, arch_string
301     "
302     psql -At -c "$query" >$ARCHLIST
303
304     includedirs () {
305         perl -ne 'print; while (m,/[^/]+$,) { $_=$`; print $_ . "\n" unless $d{$_}++; }'
306     }
307     poolfirst () {
308         perl -e '@nonpool=(); while (<>) { if (m,^\./pool/,) { print; } else { push @nonpool, $_; } } print for (@nonpool);'
309     }
310
311     log "Generating sources list"
312     (
313         sed -n 's/|$//p' $ARCHLIST
314         cd $base/ftp
315         find ./dists -maxdepth 1 \! -type d
316         find ./dists \! -type d | grep "/source/"
317     ) | sort -u | gzip -9 > source.list.gz
318
319     log "Generating arch lists"
320
321     ARCHES=$( (<$ARCHLIST sed -n 's/^.*|//p'; echo amd64) | grep . | grep -v all | sort -u)
322     for a in $ARCHES; do
323         (sed -n "s/|$a$//p" $ARCHLIST
324             sed -n 's/|all$//p' $ARCHLIST
325
326             cd $base/ftp
327             find ./dists -maxdepth 1 \! -type d
328             find ./dists \! -type d | grep -E "(proposed-updates.*_$a.changes$|/main/disks-$a/|/main/installer-$a/|/Contents-$a|/binary-$a/)"
329         ) | sort -u | gzip -9 > arch-$a.list.gz
330     done
331
332     log "Generating suite lists"
333
334     suite_list () {
335         local suite_id="$(printf %d $1)"
336         local query
337         query="
338           SELECT DISTINCT './pool/' || c.name || '/' || f.filename
339           FROM
340             (SELECT sa.source AS source
341                FROM src_associations sa
342               WHERE sa.suite = $suite_id
343              UNION
344              SELECT esr.src_id
345                FROM extra_src_references esr
346                JOIN bin_associations ba ON esr.bin_id = ba.bin
347                WHERE ba.suite = $suite_id
348              UNION
349              SELECT b.source AS source
350                FROM bin_associations ba
351                JOIN binaries b ON ba.bin = b.id WHERE ba.suite = $suite_id) s
352             JOIN dsc_files df ON s.source = df.source
353             JOIN files f ON df.file = f.id
354             JOIN files_archive_map af ON f.id = af.file_id
355             JOIN component c ON af.component_id = c.id
356             JOIN archive ON af.archive_id = archive.id
357             WHERE archive.name = 'ftp-master'
358         "
359         psql -F' ' -A -t -c "$query"
360
361         query="
362           SELECT './pool/' || c.name || '/' || f.filename
363           FROM bin_associations ba
364           JOIN binaries b ON ba.bin = b.id
365           JOIN files f ON b.file = f.id
366           JOIN files_archive_map af ON f.id = af.file_id
367           JOIN component c ON af.component_id = c.id
368           JOIN archive ON af.archive_id = archive.id
369           WHERE ba.suite = $suite_id AND archive.name = 'ftp-master'
370         "
371         psql -F' ' -A -t -c "$query"
372     }
373
374     psql -F' ' -At -c "SELECT id, suite_name FROM suite" |
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
386         ) | sort -u | gzip -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 jessie stretch; do
406                     find ./dists/$dist/main/i18n/ \! -type d | sort -u | gzip -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-jessie.list.gz ; zcat translation-stretch.list.gz) |
411     sort -u | poolfirst > ../typical.files
412
413     rm -f $ARCHLIST
414     log "Done!"
415     set -o pipefail
416 }
417
418 function mkchecksums() {
419     local archiveroot dsynclist md5list
420
421     for archive in "${public_archives[@]}"; do
422         archiveroot="$(get_archiveroot "${archive}")"
423         dsynclist=$dbdir/dsync.${archive}.list
424         md5list=${archiveroot}/indices/md5sums
425
426         log -n "Creating md5 / dsync index file for ${archive}... "
427
428         cd "$archiveroot"
429         ${bindir}/dsync-flist -q generate $dsynclist --exclude $dsynclist --md5
430         ${bindir}/dsync-flist -q md5sums $dsynclist | gzip -9n > ${md5list}.gz
431         ${bindir}/dsync-flist -q link-dups $dsynclist || true
432     done
433 }
434
435 function mirror() {
436     local archiveroot targetpath TRACEFILE
437
438     for archive in "${public_archives[@]}"; do
439         archiveroot="$(get_archiveroot "${archive}")"
440         targetpath="${mirrordir}/${archive}"
441         TRACEFILE="${archiveroot}/project/trace/ftp-master.debian.org"
442         mkdir -p "${archiveroot}/project/trace/"
443
444         log "Regenerating \"public\" mirror/${archive} hardlink fun"
445         DATE_SERIAL=$(date +"%Y%m%d01")
446         FILESOAPLUS1=$(awk '/serial/ { print $3+1 }' ${TRACEFILE} || echo ${DATE_SERIAL} )
447         if [ "$DATE_SERIAL" -gt "$FILESOAPLUS1" ]; then
448             SERIAL="$DATE_SERIAL"
449         else
450             SERIAL="$FILESOAPLUS1"
451         fi
452         date -u > ${TRACEFILE}
453         echo "Using dak v1" >> ${TRACEFILE}
454         echo "Running on host: $(hostname -f)" >> ${TRACEFILE}
455         echo "Archive serial: ${SERIAL}" >> ${TRACEFILE}
456
457         mkdir -p ${targetpath}
458         cd ${targetpath}
459         rsync -aH --link-dest ${archiveroot} --delete --delete-after --delete-excluded --exclude Packages.*.new --exclude Sources.*.new  --ignore-errors ${archiveroot}/. .
460     done
461 }
462
463 function expire() {
464     log "Expiring old database dumps..."
465     cd $base/backup
466     $scriptsdir/expire_dumps -d . -p -f "dump_*"
467 }
468
469 function transitionsclean() {
470     log "Removing out of date transitions..."
471     cd $base
472     dak transitions -c -a
473 }
474
475 function dm() {
476     log "Updating DM permissions page"
477     dak acl export-per-source dm >$exportdir/dm.txt
478 }
479
480 function bts() {
481     log "Categorizing uncategorized bugs filed against ftp.debian.org"
482     sudo -u dak-unpriv dak bts-categorize
483 }
484
485 function ddaccess() {
486     # Tell our dd accessible mirror to sync itself up. Including ftp dir.
487     log "Trigger dd accessible parts sync including ftp dir"
488     ${scriptsdir}/sync-dd dd-sync dd-sync1 dd-sync2 sync
489 }
490
491 function mirrorpush() {
492     log "Checking the public archive copies..."
493
494     local archiveroot targetpath
495
496     for archive in "${public_archives[@]}"; do
497         log "... archive: ${archive}"
498         archiveroot="$(get_archiveroot "${archive}")"
499         targetpath="${mirrordir}/${archive}"
500         cd ${archiveroot}/dists
501
502         broken=0
503         for release in $(find . -name "InRelease"); do
504             echo "Processing: ${release}"
505             subdir=${release%/InRelease}
506             while read SHASUM SIZE NAME; do
507                 if ! [ -f "${subdir}/${NAME}" ]; then
508                     bname=$(basename ${NAME})
509                     if [[ "${bname}" =~ ^(Packages|Sources|Contents-[a-zA-Z0-9-]+|Translation-[a-zA-Z_]+|Components-(amd64|i386)\.yml|icons-(128x128|64x64)\.tar)$ ]]; then
510
511                         # We don't keep unpacked files, don't check for their existance.
512                         # We might want to go and check their unpacked shasum, but right now
513                         # I don't care. I believe it should be enough if all the packed shasums
514                         # match.
515                         continue
516                     fi
517                     broken=$(( broken + 1 ))
518                     echo "File ${subdir}/${NAME} is missing"
519                     continue
520                 fi
521
522                 # We do have symlinks in the tree (see the contents files currently).
523                 # So we use "readlink -f" to check the size of the target, as thats basically
524                 # what gen-releases does
525                 fsize=$(stat -c %s $(readlink -f "${subdir}/${NAME}"))
526                 if [ ${fsize} -ne ${SIZE} ]; then
527                     broken=$(( broken + 1 ))
528                     echo "File ${subdir}/${NAME} has size ${fsize}, expected is ${SIZE}"
529                     continue
530                 fi
531
532                 fshasum=$(sha1sum $(readlink -f "${subdir}/${NAME}"))
533                 fshasum=${fshasum%% *}
534                 if [ "${fshasum}" != "${SHASUM}" ]; then
535                     broken=$(( broken + 1 ))
536                     echo "File ${subdir}/${NAME} has checksum ${fshasum}, expected is ${SHASUM}"
537                     continue
538                 fi
539             done < <(sed '1,/SHA1:/d' "${release}" | sed '/SHA256:/,$d')
540         done
541
542         if [ $broken -gt 0 ]; then
543             log_error "Trouble with the public mirror for ${archive}, found ${broken} errors"
544             continue
545         else
546             log "Starting the mirrorpush for ${archive}"
547             case ${archive} in
548                 ftp-master)
549                     fname="mirrorstart"
550                     pusharg=""
551                     ;;
552                 debian-debug)
553                     pusharg="-a debug"
554                     ;;&
555                 backports)
556                     pusharg="-a backports"
557                     ;;&
558                 *)
559                     fname="mirrorstart.${archive}"
560                     ;;
561             esac
562             date -u > /srv/ftp.debian.org/web/${fname}
563             echo "Using dak v1" >> /srv/ftp.debian.org/web/${fname}
564             echo "Running on host $(hostname -f)" >> /srv/ftp.debian.org/web/${fname}
565             sudo -H -u archvsync /home/archvsync/runmirrors ${pusharg} > ~dak/runmirrors-${archive}.log 2>&1 &
566         fi
567     done
568 }
569
570 function mirrorpush-backports() {
571     log "Syncing backports mirror"
572     sudo -u backports /home/backports/bin/update-archive
573 }
574
575 function i18n2() {
576     log "Exporting package data foo for i18n project"
577     STAMP=$(date "+%Y%m%d%H%M")
578     mkdir -p ${scriptdir}/i18n/${STAMP}
579     cd ${scriptdir}/i18n/${STAMP}
580     for suite in stable testing unstable; do
581         codename=$(dak admin s show ${suite}|grep '^Codename')
582         codename=${codename##* }
583         echo "Codename is ${codename}"
584         dak control-suite -l ${suite} >${codename}
585     done
586     echo "${STAMP}" > timestamp
587     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 473041FA --detach-sign -o timestamp.gpg timestamp
588     rm -f md5sum
589     md5sum * > md5sum
590     cd ${webdir}/
591     ln -sfT ${scriptdir}/i18n/${STAMP} i18n
592
593     cd ${scriptdir}
594     find ./i18n -mindepth 1 -maxdepth 1 -mtime +2 -not -name "${STAMP}" -type d -print0 | xargs --no-run-if-empty -0 rm -rf
595 }
596
597 function stats() {
598     log "Updating stats data"
599     cd $configdir
600     $scriptsdir/update-ftpstats $base/log/* > $base/misc/ftpstats.data
601     R --slave --vanilla < $base/misc/ftpstats.R
602     dak stats arch-space > $webdir/arch-space
603     dak stats pkg-nums > $webdir/pkg-nums
604 }
605
606 function cleantransactions() {
607     log "Cleanup transaction ids older than 3 months"
608     cd $base/backup/
609     find -maxdepth 1 -mindepth 1 -type f -name 'txid_*' -mtime +90 -delete
610 }
611
612 function logstats() {
613     $masterdir/tools/logs.py "$1"
614 }
615
616 # save timestamp when we start
617 function savetimestamp() {
618     NOW=`date "+%Y.%m.%d-%H:%M:%S"`
619     echo ${NOW} > "${dbdir}/dinstallstart"
620 }
621
622 function maillogfile() {
623     cat "$LOGFILE" | mail -a "X-Debian: DAK" -s "Log for dinstall run of ${NOW}" -a "From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>" cron@ftp-master.debian.org
624 }
625
626 function testingsourcelist() {
627     dak ls -s testing -f heidi -r .| egrep 'source$' > ${webdir}/testing.list
628 }
629
630 # Function to update a "statefile" telling people what we are doing
631 # (more or less).
632 #
633 # This should be called with the argument(s)
634 #  - Status name we want to show.
635 #
636 function state() {
637     RIGHTNOW="$(date -u +"%a %b %d %T %Z %Y (%s)")"
638     cat >"${DINSTALLSTATE}" <<EOF
639 Dinstall start: ${DINSTALLBEGIN}
640 Current action: ${1}
641 Action start: ${RIGHTNOW}
642 EOF
643 }
644
645 # extract changelogs and stuff
646 function changelogs() {
647     if lockfile -r3 $LOCK_CHANGELOG; then
648         log "Extracting changelogs"
649         dak make-changelog -e -a ftp-master
650         [ -f ${exportdir}/changelogs/filelist.yaml ] && xz -f ${exportdir}/changelogs/filelist.yaml
651         mkdir -p ${exportpublic}/changelogs
652         cd ${exportpublic}/changelogs
653         rsync -aHW --delete --delete-after --ignore-errors ${exportdir}/changelogs/. .
654         sudo -H -u staticsync /usr/local/bin/static-update-component metadata.ftp-master.debian.org >/dev/null 2>&1 &
655
656         dak make-changelog -e -a backports
657         [ -f /srv/backports-master.debian.org/export/changelogs/filelist.yaml ] && xz -f /srv/backports-master.debian.org/export/changelogs/filelist.yaml
658         mkdir -p /srv/backports-master.debian.org/rsync/export/changelogs
659         cd /srv/backports-master.debian.org/rsync/export/changelogs
660         rsync -aHW --delete --delete-after --ignore-errors /srv/backports-master.debian.org/export/changelogs/. .
661         remove_changelog_lock
662         trap remove_changelog_lock EXIT TERM HUP INT QUIT
663     fi
664 }