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