2 # log something (basically echo it together with a timestamp)
4 # Set $PROGRAM to a string to have it added to the output.
6 local prefix=${PROGRAM:-}
7 echo "$(date +"%b %d %H:%M:%S") $(hostname -s) ${prefix}[$$]: $@"
10 # log the message using log() but then also send a mail
11 # to the address configured in MAILTO (if non-empty)
12 function log_error () {
14 if [ -z "${MAILTO}" ]; then
15 echo "$@" | mail -a "X-Debian: DAK" -e -s "[$PROGRAM@$(hostname -s)] ERROR [$$]" ${MAILTO} -- -F "Debian FTP Masters" -f ftpmaster@ftp-master.debian.org
19 # debug log, only output when DEBUG=1
21 if [ $DEBUG -eq 1 ]; then
26 function wbtrigger() {
27 SSHOPT="-o BatchMode=yes -o ConnectTimeout=30 -o SetupTimeout=240"
28 if lockfile -r 3 -l 3600 "${LOCK_BUILDD}"; then
29 ssh -q -q ${SSHOPT} wbadm@buildd /org/wanna-build/trigger.often
31 rm -f "${LOCK_BUILDD}"
34 # used by cron.dinstall *and* cron.unchecked.
35 function make_buildd_dir () {
39 dak manage-build-queues -a
40 dak generate-packages-sources2 -a build-queues
41 dak generate-releases -a build-queues >/dev/null
42 ${scriptsdir}/update-buildd-archive ${base}/build-queues ${incoming}/debian-buildd
44 for suite in unstable experimental squeeze-backports; do
45 rm -rf "$incoming/dists/$suite/buildd"
46 mkdir -p "$incoming/dists/$suite/buildd"
47 dak export-suite -s "buildd-$suite" -d "$incoming/dists/$suite/buildd"
49 rm -f ${incoming}/public/*
50 dak export-suite -s "accepted" -d "$incoming/public"
53 # Process (oldstable)-proposed-updates "NEW" queue
60 dak process-policy "${queue}" | tee -a REPORT | mail -a "X-Debian: DAK" -e -s "NEW changes in ${queue}" "${to}" -- -F "Debian FTP Masters" -f ftpmaster@ftp-master.debian.org
63 dak generate-packages-sources2 -s "${queue}"
65 STAMP=${STAMP:-$(date "+%Y%m%d%H%M")}
67 local exportdir="${qdir}/tree/${STAMP}"
68 local targetdir="${qdir}/export"
69 dak export -q "${queue}" -d "${exportdir}" --all
70 ln -sfT ${exportdir} ${targetdir}
71 find "${qdir}/tree" -mindepth 1 -maxdepth 1 -not -name "${STAMP}" -type d -print0 | xargs --no-run-if-empty -0 rm -rf
74 # These versions used in dinstall
76 if [ "${PROGRAM}" = "dinstall" ]; then
77 log "Doing automated p-u-new processing"
79 cd "${queuedir}/p-u-new"
80 punew_do "$1" "${queuedir}/p-u-new" "debian-release@lists.debian.org"
84 if [ "${PROGRAM}" = "dinstall" ]; then
85 log "Doing automated o-p-u-new processing"
87 cd "${queuedir}/o-p-u-new"
88 punew_do "$1" "${queuedir}/o-p-u-new" "debian-release@lists.debian.org"
91 function backports_policy() {
92 local queue="backports-policy"
93 local qdir="/srv/backports-master.debian.org/queue/policy"
94 local to="backports-team@debian.org"
96 if [ "${PROGRAM}" = "dinstall" ]; then
97 log "Doing automated ${queue} processing"
101 punew_do "${queue}" "${qdir}" "${to}"
104 # Do the unchecked processing, in case we have files.
105 function do_unchecked () {
108 changes=$(find . -maxdepth 1 -mindepth 1 -type f -name \*.changes | sed -e "s,./,," | xargs)
109 report=$queuedir/REPORT
110 timestamp=$(date "+%Y-%m-%d %H:%M")
111 UNCHECKED_WITHOUT_LOCK=${UNCHECKED_WITHOUT_LOCK:-""}
113 echo "$timestamp": ${changes:-"Nothing to do"} >> $report
114 dak process-upload -a ${UNCHECKED_WITHOUT_LOCK} -d "$unchecked" >> $report
115 dak process-commands -d "$unchecked" >> $report
118 # process NEW policy queue
120 if [ "${PROGRAM}" = "dinstall" ]; then
121 log "Doing NEW processing"
123 (dak process-policy new; dak process-policy byhand) | mail -a "X-Debian: DAK" -e -s "NEW and BYHAND processing" ftpmaster@ftp-master.debian.org -- -F "Debian FTP Masters" -f ftpmaster@ftp-master.debian.org
125 dak process-policy backports-new | mail -a "X-Debian: DAK" -e -s "NEW processing for backports-new" backports-team@debian.org -- -F "Debian FTP Masters" -f ftpmaster@ftp-master.debian.org
127 dak clean-suites -a new,backports-new
130 function sync_debbugs () {
133 timestamp=$(date "+%Y-%m-%d-%H:%M")
134 mkdir -p $queuedir/bts_version_track_archive/${timestamp}
135 rsync -aq $queuedir/bts_version_track/ $queuedir/bts_version_track_archive/${timestamp}
136 rmdir --ignore-fail-on-non-empty $queuedir/bts_version_track_archive/${timestamp} # remove if empty.
137 rsync -aq -e "ssh -o Batchmode=yes -o ConnectTimeout=30 -o SetupTimeout=30" --remove-source-files $queuedir/bts_version_track/ bugs-sync:/org/bugs.debian.org/versions/queue/ftp-master/ 2>/dev/null && touch $lockdir/synced_bts_version || true
139 TSTAMP=$(stat -c %Y $lockdir/synced_bts_version)
140 DIFF=$(( NOW - TSTAMP ))
141 if [ $DIFF -ge 259200 ]; then
142 log "Kids, you tried your best and you failed miserably. The lesson is, never try. (Homer Simpson)"
146 function clean_debbugs () {
147 # Delete files older than 60 days
148 find $queuedir/bts_version_track_archive/ -mtime +60 -type f -delete
149 # Delete empty directories
150 find $queuedir/bts_version_track_archive/ -empty -type d -delete
154 # Send a report on NEW/BYHAND packages
155 log "Nagging ftpteam about NEW/BYHAND packages"
156 dak queue-report | mail -a "X-Debian: DAK" -e -s "NEW and BYHAND on $(date +%D)" ftpmaster@ftp-master.debian.org -- -F "Debian FTP Masters" -f ftpmaster@ftp-master.debian.org
157 dak queue-report -d backports-new,backports-policy | mail -a "X-Debian: DAK" -e -s "NEW and POLICY on $(date +%D)" backports-team@debian.org -- -F "Debian FTP Masters" -f ftpmaster@ftp-master.debian.org
158 # and one on crufty packages
159 log "Sending information about crufty packages"
160 dak cruft-report -R > $webdir/cruft-report-daily.txt
161 dak cruft-report -R -s experimental >> $webdir/cruft-report-daily.txt
162 cat $webdir/cruft-report-daily.txt | mail -a "X-Debian: DAK" -e -s "Debian archive cruft report for $(date +%D)" ftpmaster@ftp-master.debian.org -- -F "Debian FTP Masters" -f ftpmaster@ftp-master.debian.org
165 function pg_timestamp() {
166 tsname=${1:-"unknown"}
167 log "Saving postgres transaction id for ${tsname}"
168 psql -tAc 'select txid_current();' > $base/backup/txid_${tsname}_$(date +%Y.%m.%d-%H:%M:%S)
171 function get_archiveroot() {
172 local archivename="$1"
173 local query="SELECT path FROM archive WHERE name='${archivename}'"
174 local archiveroot="$(psql -tAc "${query}")"
175 if [ -z "${archiveroot}" ]; then
176 echo "get_archiveroot: couldn't get archiveroot for '${archivename}'" >&2
179 echo "${archiveroot}"