]> git.decadent.org.uk Git - dak.git/blob - config/backports/common
config/*/common: do not touch incoming
[dak.git] / config / backports / 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
42 # Do the unchecked processing, in case we have files.
43 function do_unchecked () {
44     cd $unchecked
45
46     changes=$(find . -maxdepth 1 -mindepth 1 -type f -name \*.changes | sed -e "s,./,," | xargs)
47     report=$queuedir/REPORT
48     timestamp=$(date "+%Y-%m-%d %H:%M")
49     UNCHECKED_WITHOUT_LOCK=${UNCHECKED_WITHOUT_LOCK:-""}
50
51     echo "$timestamp": ${changes:-"Nothing to do"}  >> $report
52     dak process-upload -a ${UNCHECKED_WITHOUT_LOCK} -d "$unchecked" >> $report
53 }
54
55 # Do the newstage processing, in case we have files.
56 function do_newstage () {
57     cd $newstage
58
59     changes=$(find . -maxdepth 1 -mindepth 1 -type f -name \*.changes | sed -e "s,./,," | xargs)
60     report=$queuedir/REPORT
61     timestamp=$(date "+%Y-%m-%d %H:%M")
62     UNCHECKED_WITHOUT_LOCK=${UNCHECKED_WITHOUT_LOCK:-""}
63
64     echo "$timestamp": ${changes:-"Nothing to do in newstage"}  >> $report
65     dak process-upload -a ${UNCHECKED_WITHOUT_LOCK} -d "$newstage" >> $report
66 }
67
68 function sync_debbugs () {
69     # sync with debbugs
70     echo "--" >> $report
71     timestamp=$(date "+%Y-%m-%d-%H:%M")
72     mkdir -p $queuedir/bts_version_track_archive/${timestamp}
73     rsync -aq --remove-source-files $queuedir/bts_version_track/ $queuedir/bts_version_track_archive/${timestamp}
74     rmdir --ignore-fail-on-non-empty $queuedir/bts_version_track_archive/${timestamp} # remove if empty.
75     return 0
76     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
77     NOW=$(date +%s)
78     TSTAMP=$(stat -c %Y $lockdir/synced_bts_version)
79     DIFF=$(( NOW - TSTAMP ))
80     if [ $DIFF -ge 259200 ]; then
81         log "Kids, you tried your best and you failed miserably. The lesson is, never try. (Homer Simpson)"
82     fi
83 }
84
85 function reports() {
86     # Send a report on NEW/BYHAND packages
87     log "Nagging ftpteam about NEW/BYHAND packages"
88     dak queue-report | mail -e -s "NEW and BYHAND on $(date +%D)" team@backports.debian.org
89     # and one on crufty packages
90     log "Sending information about crufty packages"
91     dak cruft-report -R > $webdir/cruft-report-daily.txt
92 #    dak cruft-report -R -s experimental >> $webdir/cruft-report-daily.txt
93     cat $webdir/cruft-report-daily.txt | mail -e -s "Debian archive cruft report for $(date +%D)" team@backports.debian.org
94 }
95
96 function pg_timestamp() {
97     tsname=${1:-"unknown"}
98     log "Saving postgres transaction id for ${tsname}"
99     psql -tAc 'select txid_current();' > $base/backup/txid_${tsname}_$(date +%Y.%m.%d-%H:%M:%S)
100 }