]> git.decadent.org.uk Git - dak.git/blob - config/debian/cron.unchecked
Merge branch 'merge'
[dak.git] / config / debian / cron.unchecked
1 #!/bin/bash
2 # No way I try to deal with a crippled sh just for POSIX foo.
3
4 # Copyright (C) 2009 Joerg Jaspert <joerg@debian.org>
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation; version 2.
9 #
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 # General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 # exit on errors
20 set -e
21 # make sure to only use defined variables
22 set -u
23 # ERR traps should be inherited from functions too. (And command
24 # substitutions and subshells and whatnot, but for us the functions is
25 # the important part here)
26 set -E
27
28 # import the general variable set.
29 export SCRIPTVARS=/srv/ftp.debian.org/dak/config/debian/vars
30 . $SCRIPTVARS
31
32 LOCKDAILY=""
33 LOCKFILE="$lockdir/unchecked.lock"
34 LOCK_NEW="$lockdir/processnew.lock"
35 NOTICE="$lockdir/daily.lock"
36
37 # our name
38 PROGRAM="unchecked"
39
40 if [ -e $NOTICE ]; then
41     exit 0;
42 fi
43
44 ########################################################################
45 # Functions                                                            #
46 ########################################################################
47 # common functions are "outsourced"
48 . "${configdir}/common"
49
50 STAMP=$(date "+%Y%m%d%H%M")
51
52 cleanup() {
53     rm -f "$LOCKFILE"
54     if [ ! -z "$LOCKDAILY" ]; then
55         rm -f "$NOTICE"
56     fi
57 }
58
59 function do_buildd () {
60     if lockfile -r3 $NOTICE; then
61         LOCKDAILY="YES"
62         psql projectb -A -t -q -c "SELECT build_queue.path || '/' || build_queue_files.filename FROM build_queue_files LEFT JOIN build_queue ON (build_queue.id = build_queue_files.build_queue_id) WHERE queue_name = 'buildd' AND filename ~ 'd(sc|eb)$';" > $dbdir/dists/unstable_accepted.list
63         cd $overridedir
64         dak make-overrides &>/dev/null
65         rm -f override.sid.all3 override.sid.all3.src
66         for i in main contrib non-free main.debian-installer; do
67             cat override.sid.$i >> override.sid.all3
68             if [ "$i" != "main.debian-installer" ]; then
69                 cat override.sid.$i.src >> override.sid.all3.src
70             fi
71         done
72         make_buildd_dir
73
74         . $configdir/cron.buildd
75     fi
76 }
77
78 ########################################################################
79 # the actual unchecked functions follow                                #
80 ########################################################################
81
82 #lockfile -r3 "$LOCK_NEW"
83 # acceptnew
84 #rm -f "$LOCK_NEW"
85
86 # only run one cron.unchecked
87 lockfile -r3 $LOCKFILE || exit 0
88 trap cleanup 0
89
90 do_unchecked
91
92 if [ ! -z "$changes" ]; then
93     sync_debbugs
94     do_buildd
95 fi