+function i18n2() {
+ log "Exporting package data foo for i18n project"
+ STAMP=$(date "+%Y%m%d%H%M")
+ mkdir -p ${scriptdir}/i18n/${STAMP}
+ cd ${scriptdir}/i18n/${STAMP}
+ dak control-suite -l stable > lenny
+ dak control-suite -l testing > squeeze
+ dak control-suite -l unstable > sid
+ echo "${STAMP}" > timestamp
+ 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
+ rm -f md5sum
+ md5sum * > md5sum
+ cd ${webdir}/
+ ln -sfT ${scriptdir}/i18n/${STAMP} i18n
+
+ cd ${scriptdir}
+ find ./i18n -mindepth 1 -maxdepth 1 -mtime +2 -not -name "${STAMP}" -type d -print0 | xargs --no-run-if-empty -0 rm -rf
+}
+
+function stats() {
+ log "Updating stats data"
+ cd $configdir
+ $scriptsdir/update-ftpstats $base/log/* > $base/misc/ftpstats.data
+ R --slave --vanilla < $base/misc/ftpstats.R
+}
+
+function aptftpcleanup() {
+ log "Clean up apt-ftparchive's databases"
+ cd $configdir
+ apt-ftparchive -q clean apt.conf
+}
+
+function compress() {
+ log "Compress old psql backups"
+ cd $base/backup/
+ find -maxdepth 1 -mindepth 1 -type f -name 'dump_pre_*' -mtime +2 -print0 | xargs -0 --no-run-if-empty rm
+
+ find -maxdepth 1 -mindepth 1 -type f -name 'dump_*' \! -name '*.bz2' \! -name '*.gz' -mmin 720 |
+ while read dumpname; do
+ echo "Compressing $dumpname"
+ bzip2 -9v "$dumpname"
+ done
+ find -maxdepth 1 -mindepth 1 -type f -name "dumpall_*" \! -name '*.bz2' \! -name '*.gz' -mmin 720 |
+ while read dumpname; do
+ echo "Compressing $dumpname"
+ bzip2 -9v "$dumpname"
+ done
+ finddup -l -d $base/backup
+}
+
+function logstats() {
+ $masterdir/tools/logs.py "$1"
+}
+
+# save timestamp when we start
+function savetimestamp() {
+ NOW=`date "+%Y.%m.%d-%H:%M:%S"`
+ echo ${NOW} > "${dbdir}/dinstallstart"
+}
+
+function maillogfile() {
+ cat "$LOGFILE" | mail -s "Log for dinstall run of ${NOW}" cron@ftp-master.debian.org
+}
+
+function renamelogfile() {
+ if [ -f "${dbdir}/dinstallstart" ]; then
+ NOW=$(cat "${dbdir}/dinstallstart")
+ maillogfile
+ mv "$LOGFILE" "$logdir/dinstall_${NOW}.log"
+ logstats "$logdir/dinstall_${NOW}.log"
+ bzip2 -9 "$logdir/dinstall_${NOW}.log"
+ else
+ error "Problem, I don't know when dinstall started, unable to do log statistics."
+ NOW=`date "+%Y.%m.%d-%H:%M:%S"`
+ maillogfile
+ mv "$LOGFILE" "$logdir/dinstall_${NOW}.log"
+ bzip2 -9 "$logdir/dinstall_${NOW}.log"
+ fi
+}
+
+function testingsourcelist() {
+ dak ls -s testing -f heidi -r .| egrep 'source$' > ${webdir}/testing.list
+}
+########################################################################
+########################################################################
+
+# Function to save which stage we are in, so we can restart an interrupted
+# dinstall. Or even run actions in parallel, if we dare to, by simply
+# backgrounding the call to this function. But that should only really be
+# done for things we dont care much about.
+#
+# This should be called with the first argument being an array, with the
+# members
+# - FUNC - the function name to call
+# - ARGS - Possible arguments to hand to the function. Can be the empty string
+# - TS - The timestamp name. Can be the empty string
+# - ERR - if this is the string false, then the call will be surrounded by
+# set +e ... set -e calls, so errors in the function do not exit
+# dinstall. Can be the empty string, meaning true.