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
37 dak generate-packages-sources2 -a build-queues
38 dak generate-releases -a build-queues
40 for suite in unstable experimental; do
41 rm -rf "$incoming/dists/$suite/buildd"
42 dak export-suite -s "buildd-$suite" -d "$incoming/dists/$suite/buildd"
45 # export to old build queue directories
46 # XXX: Remove once the buildds use the version generated above.
47 for suite in $(ls -1 $incoming/dists/); do
48 # Skip project trace directory
49 if [ "${suite}x" = "projectx" ]; then continue; fi
50 cd ${incoming}/dists/${dist}/buildd
52 dpkg-scanpackages . $overridedir/override.sid.all3 >Packages
53 gzip -9c --rsyncable <Packages >Packages.gz
54 dpkg-scansources . $override/override.sid.all3.src >Sources
55 gzip -9c --rsyncable <Sources >Sources.gz
59 apt-ftparchive -qq -o APT::FTPArchive::Release::Origin="Debian" -o APT::FTPArchive::Release::Label="Debian" -o APT::FTPArchive::Release::Description="buildd $suite incoming" -o APT::FTPArchive::Release::Architectures="$archs" release buildd >Release
60 if [ "$suite" = "experimental" ]; then
61 echo "NotAutomatic: yes" >>Release
64 gpg --secret-keyring /srv/ftp-master.debian.org/s3kr1t/dot-gnupg/secring.gpg --keyring /srv/ftp-master.debian.org/s3kr1t/dot-gnupg/pubring.gpg --no-options --batch --no-tty --armour --default-key 473041FA --detach-sign -o Release.gpg Release
66 mv Release Release.gpg buildd/
69 for dist in $(ls -1 ${incoming}/dists/); do
70 # Skip project trace directory
71 if [ "${dist}x" = "projectx" ]; then continue; fi
72 cd ${incoming}/dists/${dist}
73 mkdir -p tree/${STAMP}
74 cp -al ${incoming}/dists/${dist}/buildd/. tree/${STAMP}/
75 ln -sfT tree/${STAMP} ${incoming}/dists/${dist}/current
76 find ./tree -mindepth 1 -maxdepth 1 -not -name "${STAMP}" -type d -print0 | xargs --no-run-if-empty -0 rm -rf
80 # Process (oldstable)-proposed-updates "NEW" queue
84 dak process-policy "${queue}" | tee -a REPORT | mail -a "X-Debian: DAK" -e -s "NEW changes in ${queue}" debian-release@lists.debian.org -- -F "Debian FTP Masters" -f ftpmaster@ftp-master.debian.org
87 dak generate-packages-sources2 -s "${queue}"
89 local exportdir="${queuedir}/${queue}/export"
91 dak export -q "${queue}" -d "${exportdir}" --all
94 # These versions used in dinstall
96 if [ "${PROGRAM}" = "dinstall" ]; then
97 log "Doing automated p-u-new processing"
99 cd "${queuedir}/p-u-new"
104 if [ "${PROGRAM}" = "dinstall" ]; then
105 log "Doing automated o-p-u-new processing"
107 cd "${queuedir}/o-p-u-new"
111 # Do the unchecked processing, in case we have files.
112 function do_unchecked () {
115 changes=$(find . -maxdepth 1 -mindepth 1 -type f -name \*.changes | sed -e "s,./,," | xargs)
116 report=$queuedir/REPORT
117 timestamp=$(date "+%Y-%m-%d %H:%M")
118 UNCHECKED_WITHOUT_LOCK=${UNCHECKED_WITHOUT_LOCK:-""}
120 echo "$timestamp": ${changes:-"Nothing to do"} >> $report
121 dak process-upload -a ${UNCHECKED_WITHOUT_LOCK} -d "$unchecked" >> $report
124 # process NEW policy queue
126 if [ "${PROGRAM}" = "dinstall" ]; then
127 log "Doing NEW processing"
129 (dak process-policy new; dak process-policy byhand) | mail -a "X-Debian: DAK" -e -s "NEW and BYHAND processing" ftpmaster@ftp-master.debian.org -- -F "Debian FTP Masters" -f ftpmaster@ftp-master.debian.org
130 dak clean-suites -a new
133 function sync_debbugs () {
136 timestamp=$(date "+%Y-%m-%d-%H:%M")
137 mkdir -p $queuedir/bts_version_track_archive/${timestamp}
138 rsync -aq $queuedir/bts_version_track/ $queuedir/bts_version_track_archive/${timestamp}
139 rmdir --ignore-fail-on-non-empty $queuedir/bts_version_track_archive/${timestamp} # remove if empty.
140 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
142 TSTAMP=$(stat -c %Y $lockdir/synced_bts_version)
143 DIFF=$(( NOW - TSTAMP ))
144 if [ $DIFF -ge 259200 ]; then
145 log "Kids, you tried your best and you failed miserably. The lesson is, never try. (Homer Simpson)"
149 function clean_debbugs () {
150 # Delete files older than 60 days
151 find $queuedir/bts_version_track_archive/ -mtime +60 -type f -delete
152 # Delete empty directories
153 find $queuedir/bts_version_track_archive/ -empty -type d -delete
157 # Send a report on NEW/BYHAND packages
158 log "Nagging ftpteam about NEW/BYHAND packages"
159 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
160 # and one on crufty packages
161 log "Sending information about crufty packages"
162 dak cruft-report -R > $webdir/cruft-report-daily.txt
163 dak cruft-report -R -s experimental >> $webdir/cruft-report-daily.txt
164 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
167 function pg_timestamp() {
168 tsname=${1:-"unknown"}
169 log "Saving postgres transaction id for ${tsname}"
170 psql -tAc 'select txid_current();' > $base/backup/txid_${tsname}_$(date +%Y.%m.%d-%H:%M:%S)