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 () {
39 dak manage-build-queues -a
40 dak generate-packages-sources2 -a build-queues
41 dak generate-releases -a build-queues >/dev/null
42 ${scriptsdir}/update-buildd-archive ${base}/build-queues ${incoming}/debian-buildd
44 for suite in unstable experimental squeeze-backports; do
45 rm -rf "$incoming/dists/$suite/buildd"
46 dak export-suite -s "buildd-$suite" -d "$incoming/dists/$suite/buildd"
48 rm -f ${incoming}/public/*
49 dak export-suite -s "accepted" -d "$incoming/public"
51 # export to old build queue directories
52 # XXX: Remove once the buildds use the version generated above.
53 for suite in $(ls -1 $incoming/dists/); do
54 # Skip project trace directory
55 if [ "${suite}x" = "projectx" ]; then continue; fi
56 cd ${incoming}/dists/${suite}/buildd
59 if [ "${suite}" = "squeeze-backports" ]; then
60 overridesuite="${suite}"
63 apt-ftparchive packages . $overridedir/override.${overridesuite}.all3 >Packages
64 gzip -9c --rsyncable <Packages >Packages.gz
65 apt-ftparchive sources . $overridedir/override.${overridesuite}.all3 >Sources
66 gzip -9c --rsyncable <Sources >Sources.gz
70 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
71 if [ "$suite" = "experimental" -o "${suite}" = "squeeze-backports" ]; then
72 echo "NotAutomatic: yes" >>Release
75 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
77 mv Release Release.gpg buildd/
80 STAMP=${STAMP:-$(date "+%Y%m%d%H%M")}
82 for dist in $(ls -1 ${incoming}/dists/); do
83 # Skip project trace directory
84 if [ "${dist}x" = "projectx" ]; then continue; fi
85 cd ${incoming}/dists/${dist}
86 mkdir -p tree/${STAMP}
87 cp -al ${incoming}/dists/${dist}/buildd/. tree/${STAMP}/
88 ln -sfT tree/${STAMP} ${incoming}/dists/${dist}/current
89 find ./tree -mindepth 1 -maxdepth 1 -not -name "${STAMP}" -type d -print0 | xargs --no-run-if-empty -0 rm -rf
93 # Process (oldstable)-proposed-updates "NEW" queue
98 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
101 dak generate-packages-sources2 -s "${queue}"
103 STAMP=${STAMP:-$(date "+%Y%m%d%H%M")}
105 local exportdir="${queuedir}${qdir}/tree/${STAMP}"
106 local targetdir="${queuedir}${qdir}/export"
107 dak export -q "${queue}" -d "${exportdir}" --all
108 ln -sfT ${exportdir} ${targetdir}
109 find ${queuedir}${qdir}/tree -mindepth 1 -maxdepth 1 -not -name "${STAMP}" -type d -print0 | xargs --no-run-if-empty -0 rm -rf
112 # These versions used in dinstall
114 if [ "${PROGRAM}" = "dinstall" ]; then
115 log "Doing automated p-u-new processing"
117 cd "${queuedir}/p-u-new"
118 punew_do "$1" "p-u-new"
122 if [ "${PROGRAM}" = "dinstall" ]; then
123 log "Doing automated o-p-u-new processing"
125 cd "${queuedir}/o-p-u-new"
126 punew_do "$1" "o-p-u-new"
129 # Do the unchecked processing, in case we have files.
130 function do_unchecked () {
133 changes=$(find . -maxdepth 1 -mindepth 1 -type f -name \*.changes | sed -e "s,./,," | xargs)
134 report=$queuedir/REPORT
135 timestamp=$(date "+%Y-%m-%d %H:%M")
136 UNCHECKED_WITHOUT_LOCK=${UNCHECKED_WITHOUT_LOCK:-""}
138 echo "$timestamp": ${changes:-"Nothing to do"} >> $report
139 dak process-upload -a ${UNCHECKED_WITHOUT_LOCK} -d "$unchecked" >> $report
140 dak process-commands -d "$unchecked" >> $report
143 # process NEW policy queue
145 if [ "${PROGRAM}" = "dinstall" ]; then
146 log "Doing NEW processing"
148 (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
150 dak process-policy backports-new | mail -a "X-Debian: DAK" -e -s "NEW processing for backports-new" team@backports.debian.org -- -F "Debian FTP Masters" -f ftpmaster@ftp-master.debian.org
152 dak clean-suites -a new,backports-new
155 function sync_debbugs () {
158 timestamp=$(date "+%Y-%m-%d-%H:%M")
159 mkdir -p $queuedir/bts_version_track_archive/${timestamp}
160 rsync -aq $queuedir/bts_version_track/ $queuedir/bts_version_track_archive/${timestamp}
161 rmdir --ignore-fail-on-non-empty $queuedir/bts_version_track_archive/${timestamp} # remove if empty.
162 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
164 TSTAMP=$(stat -c %Y $lockdir/synced_bts_version)
165 DIFF=$(( NOW - TSTAMP ))
166 if [ $DIFF -ge 259200 ]; then
167 log "Kids, you tried your best and you failed miserably. The lesson is, never try. (Homer Simpson)"
171 function clean_debbugs () {
172 # Delete files older than 60 days
173 find $queuedir/bts_version_track_archive/ -mtime +60 -type f -delete
174 # Delete empty directories
175 find $queuedir/bts_version_track_archive/ -empty -type d -delete
179 # Send a report on NEW/BYHAND packages
180 log "Nagging ftpteam about NEW/BYHAND packages"
181 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
182 # and one on crufty packages
183 log "Sending information about crufty packages"
184 dak cruft-report -R > $webdir/cruft-report-daily.txt
185 dak cruft-report -R -s experimental >> $webdir/cruft-report-daily.txt
186 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
189 function pg_timestamp() {
190 tsname=${1:-"unknown"}
191 log "Saving postgres transaction id for ${tsname}"
192 psql -tAc 'select txid_current();' > $base/backup/txid_${tsname}_$(date +%Y.%m.%d-%H:%M:%S)
195 function get_archiveroot() {
196 local archivename="$1"
197 local query="SELECT path FROM archive WHERE name='${archivename}'"
198 local archiveroot="$(psql -tAc "${query}")"
199 if [ -z "${archiveroot}" ]; then
200 echo "get_archiveroot: couldn't get archiveroot for '${archivename}'" >&2
203 echo "${archiveroot}"