Debian Codegraph @

contrib/ftp.cron

raw
1 #!/bin/bash
2
3 set -e
4
5 TOPDIR=`pwd`
6 . $TOPDIR/settings.sh
7 . $TOPDIR/.ftp.buildnum
8
9 MYCOPY=$TOPDIR/.ftp.cron
10 BUILDLOCK=$HOME/.debian-cd.lock
11 MAILLIST=$TOPDIR/.debian-cd.mail
12
13 # Change these to abort daily/weekly builds as appropriate
14 ABORT_DAILY=n
15 ABORT_WEEKLY=n
16
17 if [ "$1"x = "-f"x ] ; then
18 FORCE=1
19 fi
20
21 mail_list() {
22 if [ -e "$MAILLIST" ] ; then
23 MYEMAIL=`grep -v "^#" "$MAILLIST"`
24 else
25 MYEMAIL=`whoami`
26 fi
27 for i in $MYEMAIL
28 do
29 cat "$MYCOPY"|mail -s "$1" "$i"
30 done
31 return 0
32 }
33
34 if [ -f "$TRACE" ] ; then
35 if [ "$FORCE"x = "1"x ] || ! /usr/bin/cmp -s "$MYCOPY".lastbuild "$TRACE" ; then
36 if [ -e "$BUILDLOCK" ]; then
37 if ! /usr/bin/cmp -s "$MYCOPY" "$TRACE" ; then
38 if ! /usr/bin/cmp -s "$MYCOPY" "$MYCOPY".building ; then
39 mail_list "testingcds missed the daily build for the pulse because of a lock"
40 fi
41 cp "$TRACE" "$MYCOPY"
42 cat "$MYCOPY" >> "$MYCOPY".stats
43 fi
44 else
45 if ! /usr/bin/cmp -s "$MYCOPY" "$TRACE" ; then
46 cp "$TRACE" "$MYCOPY"
47 cat "$MYCOPY" >> "$MYCOPY".stats
48 fi
49
50 # Work out the next build date/number combo
51 if [ "$LASTDATE"x != "$DATE"x ] ; then
52 BUILDNUM=1
53 else
54 BUILDNUM=$(($LASTBUILDNUM + 1))
55 fi
56 echo "LASTDATE=$DATE" > $TOPDIR/.ftp.buildnum
57 echo "LASTBUILDNUM=$BUILDNUM" >> $TOPDIR/.ftp.buildnum
58 export DATE BUILDNUM
59
60 echo "Last build was $LASTDATE-$LASTBUILDNUM"
61 echo "New build will be $DATE-$BUILDNUM"
62
63 cp "$MYCOPY" "$MYCOPY".building
64
65 BUILD_DONE=0
66
67 # "Daily" builds
68 # Only run certain builds, otherwise we're just wasting
69 # time reproducing identical results:
70 # - archive changes are likely to be minimal
71 # - packages only get uploaded at best once daily for most buildds
72 # - it's fairly unlikely they'll actually affect/improve installs,
73 # especially for the small images
74 # - D-I images only get built once or at most twice daily
75 DAILIES_DESIRED="1 5"
76 ODD_BUILD=`echo "$BUILDNUM % 2" | bc`
77 if [ "$ABORT_DAILY"x = "y"x ] && [ "$FORCE"x != "1"x ] ; then
78 echo "BAILING OUT OF DAILY BUILD"
79 mail_list "$HOSTNAME BAILING OUT OF DAILY BUILD"
80 elif [ "$ODD_BUILD" = "0" ] && [ "$FORCE"x != "1"x ] ; then
81 echo "Not running even-numbered daily build #$BUILDNUM"
82 else
83 echo "Running daily build #$BUILDNUM."
84 BUILD_DONE=1
85 if [ "$FORCE"x = "1"x ] ; then
86 echo "Build forced by hand"
87 else
88 echo "Triggered by mirror pulse:"
89 cat "$TRACE"
90 fi
91 $TOPDIR/cronjob.daily 2>&1 | tee ~/build/log/cronjob.daily-$DATE-$BUILDNUM.log
92 cp "$MYCOPY" "$MYCOPY".lastbuild
93 if ! /usr/bin/cmp -s "$MYCOPY".lastbuild "$TRACE" ; then
94 mail_list "testingcds has detected a pulse while we were building dailies"
95 fi
96 fi
97
98 # Weekly build
99 if [ `date +%a` = "Mon" -a "$BUILDNUM"x = "1"x ] ; then
100 if [ "$ABORT_WEEKLY"x = "y"x ] && [ "$FORCE"x != "1"x ] ; then
101 echo "BAILING OUT OF WEEKLY BUILD"
102 mail_list "$HOSTNAME BAILING OUT OF WEEKLY BUILD"
103 else
104 $TOPDIR/cronjob.weekly 2>&1 | tee ~/build/log/cronjob.weekly-$DATE.log
105 BUILD_DONE=1
106 fi
107 fi
108 cd $HOME && ./bin/cdbuilder_log_analyser > build/log/analysis.html
109 if [ "$BUILD_DONE"x = "1"x ]; then
110 /usr/local/bin/static-update-component cdbuilder-logs.debian.org
111 fi
112 exit 0
113 fi
114 fi
115 fi
116 exit 1
117
118