]> git.decadent.org.uk Git - dak.git/blob - config/debian/common
signing key
[dak.git] / config / debian / common
1 # log something (basically echo it together with a timestamp)
2 #
3 # Set $PROGRAM to a string to have it added to the output.
4 function log () {
5         if [ -z "${PROGRAM}" ]; then
6                 echo "$(date +"%b %d %H:%M:%S") $(hostname -s) [$$] $@"
7         else
8                 echo "$(date +"%b %d %H:%M:%S") $(hostname -s) ${PROGRAM}[$$]: $@"
9         fi
10 }
11
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 () {
15         log "$@"
16         if [ -z "${MAILTO}" ]; then
17                 echo "$@" | mail -e -s "[$PROGRAM@$(hostname -s)] ERROR [$$]" ${MAILTO}
18         fi
19 }
20
21 # debug log, only output when DEBUG=1
22 function debug () {
23     if [ $DEBUG -eq 1 ]; then
24         log "$*"
25     fi
26 }
27
28 # used by cron.dinstall *and* cron.unchecked.
29 function make_buildd_dir () {
30         cd $configdir
31         apt-ftparchive -qq -o APT::FTPArchive::Contents=off generate apt.conf.buildd
32
33         cd  ${incoming}
34         rm -f buildd/Release*
35         apt-ftparchive -qq -o APT::FTPArchive::Release::Origin="Debian" -o APT::FTPArchive::Release::Label="Debian" -o APT::FTPArchive::Release::Description="buildd incoming" -o APT::FTPArchive::Release::Architectures="${archs}" release buildd > Release
36         gpg --secret-keyring /srv/ftp.debian.org/s3kr1t/dot-gnupg/secring.gpg --keyring /srv/ftp.debian.org/s3kr1t/dot-gnupg/pubring.gpg --no-options --batch --no-tty --armour --default-key 55BE302B --detach-sign -o Release.gpg Release
37         mv Release* buildd/.
38
39         cd ${incoming}
40         mkdir -p tree/${STAMP}
41         cp -al ${incoming}/buildd/. tree/${STAMP}/
42         ln -sfT tree/${STAMP} ${incoming}/builddweb
43         find ./tree -mindepth 1 -maxdepth 1 -not -name "${STAMP}" -type d -print0 | xargs --no-run-if-empty -0 rm -rf
44 }
45
46 # move accepted NEW packages from stagedir into queue/accepted
47 function acceptnew () {
48     cd $newstage
49     for file in $(find . -maxdepth 1 -mindepth 1 -type f -name \*.changes | sed -e "s,./,," | xargs); do
50         sed '1,/Files:/d' "${file}" | sed '/BEGIN PGP SIGNATURE/,$d' \
51             | while read notused1 notused2 notused3 notused4 NAME; do
52             if [ -z "${NAME}" ]; then
53                 # Sometimes there is a newline after the Files:, ignore it
54                 continue
55             fi
56             if [ -f "${NAME}" ]; then
57                 mv --target-directory="${accepted}" "${NAME}"
58             else
59                 log_error "Error, couldn't find file ${NAME} to move to ${accepted}"
60             fi
61         done
62         mv --target-directory="${accepted}"  "${file}" "${file%%.changes}.dak"
63     done
64 }
65
66 # Do the unchecked processing, in case we have files.
67 function do_unchecked () {
68     cd $unchecked
69
70     changes=$(find . -maxdepth 1 -mindepth 1 -type f -name \*.changes | sed -e "s,./,," | xargs)
71     report=$queuedir/REPORT
72     timestamp=$(date "+%Y-%m-%d %H:%M")
73     UNCHECKED_WITHOUT_LOCK=${UNCHECKED_WITHOUT_LOCK:-""}
74
75     echo "$timestamp": ${changes:-"Nothing to do"}  >> $report
76     dak process-unchecked -a ${UNCHECKED_WITHOUT_LOCK} -d "$unchecked" >> $report
77 }
78
79 function sync_debbugs () {
80     # sync with debbugs
81     echo "--" >> $report
82     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
83     NOW=$(date +%s)
84     TSTAMP=$(stat -c %Y $lockdir/synced_bts_version)
85     DIFF=$(( NOW - TSTAMP ))
86     if [ $DIFF -ge 259200 ]; then
87         log "Kids, you tried your best and you failed miserably. The lesson is, never try. (Homer Simpson)"
88     fi
89 }