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
39 # Process (oldstable)-proposed-updates "NEW" queue
42 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
46 # These versions used in dinstall
48 if [ "${PROGRAM}" = "dinstall" ]; then
49 log "Doing automated p-u-new processing"
51 cd "${queuedir}/p-u-new"
56 if [ "${PROGRAM}" = "dinstall" ]; then
57 log "Doing automated o-p-u-new processing"
59 cd "${queuedir}/o-p-u-new"
63 # Do the unchecked processing, in case we have files.
64 function do_unchecked () {
67 changes=$(find . -maxdepth 1 -mindepth 1 -type f -name \*.changes | sed -e "s,./,," | xargs)
68 report=$queuedir/REPORT
69 timestamp=$(date "+%Y-%m-%d %H:%M")
70 UNCHECKED_WITHOUT_LOCK=${UNCHECKED_WITHOUT_LOCK:-""}
72 echo "$timestamp": ${changes:-"Nothing to do"} >> $report
73 dak process-upload -a ${UNCHECKED_WITHOUT_LOCK} -d "$unchecked" >> $report
76 # Do the newstage processing, in case we have files.
77 function do_newstage () {
80 changes=$(find . -maxdepth 1 -mindepth 1 -type f -name \*.changes | sed -e "s,./,," | xargs)
81 report=$queuedir/REPORT
82 timestamp=$(date "+%Y-%m-%d %H:%M")
83 UNCHECKED_WITHOUT_LOCK=${UNCHECKED_WITHOUT_LOCK:-""}
85 echo "$timestamp": ${changes:-"Nothing to do in newstage"} >> $report
86 dak process-upload -a ${UNCHECKED_WITHOUT_LOCK} -d "$newstage" >> $report
89 function sync_debbugs () {
92 timestamp=$(date "+%Y-%m-%d-%H:%M")
93 mkdir -p $queuedir/bts_version_track_archive/${timestamp}
94 rsync -aq $queuedir/bts_version_track/ $queuedir/bts_version_track_archive/${timestamp}
95 rmdir --ignore-fail-on-non-empty $queuedir/bts_version_track_archive/${timestamp} # remove if empty.
96 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
98 TSTAMP=$(stat -c %Y $lockdir/synced_bts_version)
99 DIFF=$(( NOW - TSTAMP ))
100 if [ $DIFF -ge 259200 ]; then
101 log "Kids, you tried your best and you failed miserably. The lesson is, never try. (Homer Simpson)"
105 function clean_debbugs () {
106 # Delete files older than 60 days
107 find $queuedir/bts_version_track_archive/ -mtime +60 -type f -delete
108 # Delete empty directories
109 find $queuedir/bts_version_track_archive/ -empty -type d -delete
113 # Send a report on NEW/BYHAND packages
114 log "Nagging ftpteam about NEW/BYHAND packages"
115 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
116 # and one on crufty packages
117 log "Sending information about crufty packages"
118 dak cruft-report -R > $webdir/cruft-report-daily.txt
119 dak cruft-report -R -s experimental >> $webdir/cruft-report-daily.txt
120 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
123 function pg_timestamp() {
124 tsname=${1:-"unknown"}
125 log "Saving postgres transaction id for ${tsname}"
126 psql -tAc 'select txid_current();' > $base/backup/txid_${tsname}_$(date +%Y.%m.%d-%H:%M:%S)