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 () {
36 dak manage-build-queues -a
38 for dist in $(ls -1 ${incoming}/dists/); do
39 # Skip project trace directory
40 if [ "${dist}x" = "projectx" ]; then continue; fi
41 cd ${incoming}/dists/${dist}
42 mkdir -p tree/${STAMP}
43 cp -al ${incoming}/dists/${dist}/buildd/. tree/${STAMP}/
44 ln -sfT tree/${STAMP} ${incoming}/dists/${dist}/current
45 find ./tree -mindepth 1 -maxdepth 1 -not -name "${STAMP}" -type d -print0 | xargs --no-run-if-empty -0 rm -rf
50 # Process (oldstable)-proposed-updates "NEW" queue
53 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
57 # These versions used in dinstall
59 if [ "${PROGRAM}" = "dinstall" ]; then
60 log "Doing automated p-u-new processing"
62 cd "${queuedir}/p-u-new"
67 if [ "${PROGRAM}" = "dinstall" ]; then
68 log "Doing automated o-p-u-new processing"
70 cd "${queuedir}/o-p-u-new"
74 # Do the unchecked processing, in case we have files.
75 function do_unchecked () {
78 changes=$(find . -maxdepth 1 -mindepth 1 -type f -name \*.changes | sed -e "s,./,," | xargs)
79 report=$queuedir/REPORT
80 timestamp=$(date "+%Y-%m-%d %H:%M")
81 UNCHECKED_WITHOUT_LOCK=${UNCHECKED_WITHOUT_LOCK:-""}
83 echo "$timestamp": ${changes:-"Nothing to do"} >> $report
84 dak process-upload -a ${UNCHECKED_WITHOUT_LOCK} -d "$unchecked" >> $report
87 # Do the newstage processing, in case we have files.
88 function do_newstage () {
91 changes=$(find . -maxdepth 1 -mindepth 1 -type f -name \*.changes | sed -e "s,./,," | xargs)
92 report=$queuedir/REPORT
93 timestamp=$(date "+%Y-%m-%d %H:%M")
94 UNCHECKED_WITHOUT_LOCK=${UNCHECKED_WITHOUT_LOCK:-""}
96 echo "$timestamp": ${changes:-"Nothing to do in newstage"} >> $report
97 dak process-upload -a ${UNCHECKED_WITHOUT_LOCK} -d "$newstage" >> $report
100 function sync_debbugs () {
103 timestamp=$(date "+%Y-%m-%d-%H:%M")
104 mkdir -p $queuedir/bts_version_track_archive/${timestamp}
105 rsync -aq $queuedir/bts_version_track/ $queuedir/bts_version_track_archive/${timestamp}
106 rmdir --ignore-fail-on-non-empty $queuedir/bts_version_track_archive/${timestamp} # remove if empty.
107 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
109 TSTAMP=$(stat -c %Y $lockdir/synced_bts_version)
110 DIFF=$(( NOW - TSTAMP ))
111 if [ $DIFF -ge 259200 ]; then
112 log "Kids, you tried your best and you failed miserably. The lesson is, never try. (Homer Simpson)"
116 function clean_debbugs () {
117 # Delete files older than 60 days
118 find $queuedir/bts_version_track_archive/ -mtime +60 -type f -delete
119 # Delete empty directories
120 find $queuedir/bts_version_track_archive/ -empty -type d -delete
124 # Send a report on NEW/BYHAND packages
125 log "Nagging ftpteam about NEW/BYHAND packages"
126 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
127 # and one on crufty packages
128 log "Sending information about crufty packages"
129 dak cruft-report -R > $webdir/cruft-report-daily.txt
130 dak cruft-report -R -s experimental >> $webdir/cruft-report-daily.txt
131 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
134 function pg_timestamp() {
135 tsname=${1:-"unknown"}
136 log "Saving postgres transaction id for ${tsname}"
137 psql -tAc 'select txid_current();' > $base/backup/txid_${tsname}_$(date +%Y.%m.%d-%H:%M:%S)