]> git.decadent.org.uk Git - dak.git/blob - config/debian-security/cron.unchecked
Use a better name for function name and output string
[dak.git] / config / debian-security / cron.unchecked
1 #! /bin/bash
2
3 set -e
4 set -o pipefail
5 set -u
6
7 export SCRIPTVARS=/srv/security-master.debian.org/dak/config/debian-security/vars
8 . $SCRIPTVARS
9
10 # And use one locale, no matter what the caller has set
11 export LANG=C
12 export LC_ALL=C
13
14 report=$queuedir/REPORT
15 reportdis=$queuedir/REPORT.disembargo
16 timestamp=$(date "+%Y-%m-%d %H:%M")
17 doanything=false
18 dopolicy=false
19 LOCKFILE="$lockdir/unchecked.lock"
20
21 cleanup() {
22     rm -f "$LOCKFILE"
23 }
24
25 if ! lockfile -r8 "$LOCKFILE"; then
26     echo "aborting cron.unchecked because $LOCKFILE has already been locked"
27     exit 0
28 fi
29 trap cleanup EXIT
30
31 cd $unchecked
32 changes=$(find . -maxdepth 1 -mindepth 1 -type f -name \*.changes | sed -e "s,./,," | xargs)
33 if [ -n "$changes" ]; then
34     doanything=true
35     echo "$timestamp": ${changes:-"Nothing to do in unchecked"}  >> $report
36     dak process-upload -a -d "$unchecked" >> $report
37 fi
38
39 cd $disembargo
40 changes=$(find . -maxdepth 1 -mindepth 1 -type f -name \*.changes | sed -e "s,./,," | xargs)
41 if [ -n "$changes" ]; then
42     doanything=true
43     echo "$timestamp": ${changes:-"Nothing to do in disembargo"}  >> $reportdis
44     dak process-upload -a -d "$disembargo" >> $reportdis
45 fi
46
47 for queue in embargoed unembargoed; do
48     echo "$timestamp: processing ${queue}" >> ${report}
49     dak process-policy ${queue} | mail -a "X-Debian: DAK" -e -s "Automatically accepted from ${queue}" team@security.debian.org -- -F "Debian FTP Masters" -f ftpmaster@ftp-master.debian.org
50 done
51 accepted=$(find ${queuedir}/accepted -type f -name "*.changes")
52 if [ -n "${accepted}" ]; then
53     dopolicy=true
54 fi
55
56 # sync accepted files to ftpmaster
57 cd ${base}
58 find ${queuedir}/accepted -type f -exec mv -t /srv/queued/ftpmaster '{}' +
59
60 # export policy queues
61 for queue in embargoed; do
62     cd ${queuedir}/${queue}
63     rm -rf export.new
64     mkdir export.new
65     dak export -q ${queue} -d export.new --all
66     rsync -a --delete export.new/. export/.
67     rm -rf export.new
68     cd ${base}
69 done
70
71 if [ "${doanything}" = "false" ] && [ "${dopolicy}" = "false" ]; then
72     echo "$timestamp": Nothing to do >> $report
73     exit 0
74 fi
75
76 # manage build queues
77 dak manage-build-queues -a
78 dak generate-packages-sources2 -a build-queues
79 dak generate-releases -a build-queues >/dev/null
80 ${scriptsdir}/update-buildd-archive ${base}/build-queues ${incoming}/debian-security-buildd
81
82 # export build queues in old format
83 # XXX: This should be removed later.
84 for suite in stable testing; do
85     overridecodename=$(dak admin suite show ${suite} | awk '$1 == "OverrideCodename:" { print $2 }')
86     rm -rf ${incoming}/${suite}.new
87     mkdir ${incoming}/${suite}.new
88     dak export-suite -s buildd-${suite} -d ${incoming}/${suite}.new
89
90     cd ${incoming}/${suite}.new
91     apt-ftparchive packages . ${overridedir}/override.${overridecodename}.all3 >Packages
92     gzip -9c --rsyncable <Packages >Packages.gz
93     apt-ftparchive sources . ${overridedir}/override.${overridecodename}.all3 >Sources
94     gzip -9c --rsyncable <Sources >Sources.gz
95     rm -f Release
96
97     cd ${incoming}
98     apt-ftparchive -qq -o APT::FTPArchive::Release::Origin="Debian" -o APT::FTPArchive::Release::Label="Debian" -o APT::FTPArchive::Release::Description="buildd $suite security" -o APT::FTPArchive::Release::Architectures="$archs" release ${suite}.new >${suite}.Release
99
100     gpg --secret-keyring /srv/security-master.debian.org/s3kr1t/dot-gnupg/secring.gpg --keyring /srv/security-master.debian.org/s3kr1t/dot-gnupg/pubring.gpg --no-options --batch --no-tty --armour --default-key 473041FA --detach-sign -o ${suite}.Release.gpg ${suite}.Release
101
102     mv ${suite}.Release ${suite}.new/Release
103     mv ${suite}.Release.gpg ${suite}.new/Release.gpg
104
105     if [ -d ${suite} ]; then
106         mv ${suite} ${suite}.old
107     fi
108     mv ${suite}.new ${suite}
109     rm -rf ${suite}.old
110 done
111
112 if [ "x${dopolicy}x" = "xtruex" ]; then
113     # We had something approved from a policy queue, push out new archive
114     dak dominate
115     #dak generate-filelist
116     cd $configdir
117     $configdir/map.sh
118     #apt-ftparchive generate apt.conf
119     dak generate-packages-sources2 -a security
120     dak generate-releases -a security
121     /srv/security-master.debian.org/dak/config/debian-security/make-mirror.sh
122     sudo -u archvsync -H /home/archvsync/signal_security
123 fi
124
125 cleanup
126 trap - EXIT
127
128 $configdir/cron.buildd