1 # log something (basically echo it together with a timestamp)
3 # Set $PROGRAM to a string to have it added to the output.
5 if [ -z "${PROGRAM}" ]; then
6 echo "$(date +"%b %d %H:%M:%S") $(hostname -s) [$$] $@"
8 echo "$(date +"%b %d %H:%M:%S") $(hostname -s) ${PROGRAM}[$$]: $@"
12 # log the message using log() but then also send a mail
13 # to the address configured in MAILTO (if non-empty)
14 function log_error () {
16 if [ -z "${MAILTO}" ]; then
17 echo "$@" | mail -e -s "[$PROGRAM@$(hostname -s)] ERROR [$$]" ${MAILTO}
21 # debug log, only output when DEBUG=1
23 if [ $DEBUG -eq 1 ]; then
28 function wbtrigger() {
29 SSHOPT="-o BatchMode=yes -o ConnectTimeout=30 -o SetupTimeout=240"
30 if lockfile -r 3 -l 3600 "${LOCK_BUILDD}"; then
31 ssh -q -q ${SSHOPT} wbadm@buildd /org/wanna-build/trigger.often
33 rm -f "${LOCK_BUILDD}"
36 # used by cron.dinstall *and* cron.unchecked.
37 function make_buildd_dir () {
38 dak manage-build-queues -a
41 mkdir -p tree/${STAMP}
42 cp -al ${incoming}/buildd/. tree/${STAMP}/
43 ln -sfT tree/${STAMP} ${incoming}/builddweb
44 find ./tree -mindepth 1 -maxdepth 1 -not -name "${STAMP}" -type d -print0 | xargs --no-run-if-empty -0 rm -rf
46 for dist in experimental
48 cd ${incoming}/dists/${dist}
49 mkdir -p tree/${STAMP}
50 cp -al ${incoming}/dists/${dist}/buildd/. tree/${STAMP}/
51 ln -sfT tree/${STAMP} ${incoming}/dists/${dist}/current
52 find ./tree -mindepth 1 -maxdepth 1 -not -name "${STAMP}" -type d -print0 | xargs --no-run-if-empty -0 rm -rf
56 # Do the unchecked processing, in case we have files.
57 function do_unchecked () {
60 changes=$(find . -maxdepth 1 -mindepth 1 -type f -name \*.changes | sed -e "s,./,," | xargs)
61 report=$queuedir/REPORT
62 timestamp=$(date "+%Y-%m-%d %H:%M")
63 UNCHECKED_WITHOUT_LOCK=${UNCHECKED_WITHOUT_LOCK:-""}
65 echo "$timestamp": ${changes:-"Nothing to do"} >> $report
66 dak process-upload -a ${UNCHECKED_WITHOUT_LOCK} -d "$unchecked" >> $report
69 # Do the newstage processing, in case we have files.
70 function do_newstage () {
73 changes=$(find . -maxdepth 1 -mindepth 1 -type f -name \*.changes | sed -e "s,./,," | xargs)
74 report=$queuedir/REPORT
75 timestamp=$(date "+%Y-%m-%d %H:%M")
76 UNCHECKED_WITHOUT_LOCK=${UNCHECKED_WITHOUT_LOCK:-""}
78 echo "$timestamp": ${changes:-"Nothing to do in newstage"} >> $report
79 dak process-upload -a ${UNCHECKED_WITHOUT_LOCK} -d "$newstage" >> $report
82 function sync_debbugs () {
85 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
87 TSTAMP=$(stat -c %Y $lockdir/synced_bts_version)
88 DIFF=$(( NOW - TSTAMP ))
89 if [ $DIFF -ge 259200 ]; then
90 log "Kids, you tried your best and you failed miserably. The lesson is, never try. (Homer Simpson)"