author | laca |
Tue, 18 Nov 2003 10:31:07 +0000 | |
changeset 1418 | d6ff07e7887d |
parent 1351 | a6141f0beecb |
child 1521 | 281281f01ef5 |
permissions | -rwxr-xr-x |
482 | 1 |
#!/bin/bash |
2 |
||
850 | 3 |
# host to rcp the rpms to |
482 | 4 |
RHOST=blader |
850 | 5 |
|
6 |
# user to rcp as (has to have root@<this host> in it's .rhosts file) |
|
482 | 7 |
RUSER=gbuild |
850 | 8 |
|
9 |
# directory to copy rpms/srpms to on the remote host |
|
1418 | 10 |
RPMSDIR=/sgnome/pkgs/jds.next/rpms |
11 |
SRPMSDIR=/sgnome/pkgs/jds.next/srpms |
|
1351 | 12 |
LOCKFILE=$RPMSDIR/.build.lock |
850 | 13 |
|
14 |
# reply-to/to address to send the build log as/to |
|
482 | 15 |
[email protected] |
1058 | 16 |
[email protected] |
17 |
||
18 |
# date format appended to the Release tag in the spec files |
|
19 |
# (passed to the date command on the cmd line) |
|
20 |
RELEASE_DATE_FMT="%y%m%d" |
|
21 |
||
22 |
# date format used for naming the directories |
|
23 |
DIR_DATE_FMT="%Y-%m-%d" |
|
850 | 24 |
|
1058 | 25 |
RELEASE_DATE=`date +$RELEASE_DATE_FMT` |
26 |
DIR_DATE=`date +$DIR_DATE_FMT` |
|
27 |
||
28 |
# document root of the web server |
|
29 |
WEBROOT=/scde/web/docs |
|
30 |
||
31 |
# subdir to keep logs and reports on the webserver |
|
1418 | 32 |
WEBDIR=gnome/releng/jds/jds.next/nightly |
1058 | 33 |
LOGDIR=$WEBDIR/$DIR_DATE |
850 | 34 |
|
35 |
# ------------ nothing to configure below this line -------------- |
|
36 |
||
482 | 37 |
MYNAME="$0" |
852 | 38 |
MYDIR=$(cd `dirname $0`; pwd) |
482 | 39 |
|
850 | 40 |
if [ "x$1" != x ]; then |
41 |
SPECDIR="$1" |
|
42 |
else |
|
43 |
SPECDIR="$MYDIR" |
|
44 |
fi |
|
45 |
||
46 |
# remove temporary files on exit |
|
482 | 47 |
clean_up () { |
48 |
case "$MYNAME" in |
|
49 |
/tmp/cron-script.copy.* ) |
|
50 |
rm -f $MYNAME |
|
51 |
;; |
|
52 |
esac |
|
853 | 53 |
exit |
482 | 54 |
} |
55 |
||
56 |
trap clean_up HUP INT TERM QUIT EXIT |
|
57 |
||
850 | 58 |
# make a copy of the cron script in /tmp and execute that in order to |
59 |
# avoid disasters caused by cvs update. |
|
485 | 60 |
case "$MYNAME" in |
61 |
/tmp/cron-script.copy.* ) |
|
62 |
;; |
|
63 |
*) |
|
482 | 64 |
cp $MYNAME /tmp/cron-script.copy.$$ |
65 |
chmod 755 /tmp/cron-script.copy.$$ |
|
66 |
cd /tmp |
|
850 | 67 |
exec /tmp/cron-script.copy.$$ "$MYDIR" |
482 | 68 |
;; |
69 |
esac |
|
70 |
||
71 |
fatal_error () { |
|
72 |
echo "ERROR: $*" |
|
73 |
exit 1 |
|
74 |
} |
|
75 |
||
76 |
cd $SPECDIR || fatal_error "$SPECDIR not found" |
|
77 |
||
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
78 |
cvs -q up -Pd > /dev/null 2>&1 || fatal_error "CVS update failed" |
482 | 79 |
|
850 | 80 |
# if the script changed during cvs update, restart with the updated script |
608 | 81 |
if ! /usr/bin/cmp -s ./cron-script.sh $MYNAME; then exec ./cron-script.sh; fi |
482 | 82 |
|
83 |
rm -f GNOME*Template*.spec |
|
84 |
||
850 | 85 |
# uninstall all pkgs left behind by a previous build |
484 | 86 |
./build-gnome2 -q uninstall-pkgs *.spec |
482 | 87 |
|
88 |
rm -f /usr/src/packages/SRPMS/* /usr/src/packages/RPMS/*/* |
|
89 |
||
850 | 90 |
# if the log directory exists, open a new one with numbered suffix |
91 |
NEW_LOGDIR=$LOGDIR |
|
92 |
N=1 |
|
853 | 93 |
while [ -d $WEBROOT/$NEW_LOGDIR ]; do |
850 | 94 |
NEW_LOGDIR=$LOGDIR.$N |
95 |
N=`expr $N + 1` |
|
96 |
done |
|
97 |
||
98 |
LOGDIR=$NEW_LOGDIR |
|
648 | 99 |
mkdir -p $WEBROOT/$LOGDIR |
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
100 |
|
1351 | 101 |
echo '' | rsh $RHOST -l $RUSER "touch $LOCKFILE" |
102 |
||
850 | 103 |
# start the build |
1058 | 104 |
./build-gnome2 -v --nightly --date "$RELEASE_DATE" build --target i586 *.spec \ |
609 | 105 |
--logdir=$WEBROOT/$LOGDIR \ |
1058 | 106 |
--logdir-url=$DIR_DATE \ |
1418 | 107 |
--mail-errors-file=MAINTAINERS \ |
108 |
[email protected] \ |
|
109 |
[email protected] \ |
|
110 |
--prodname=jds.next \ |
|
786
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
648
diff
changeset
|
111 |
--good-rpms-copy-dir=/tmp/old-rpms-used.$$ \ |
609 | 112 |
--summary-log=$WEBROOT/$LOGDIR.html \ |
608 | 113 |
--summary-title="Nightly Build Report `date +'%d %B %Y'`" \ |
1418 | 114 |
--rpm-url=file:///net/dtserv1.ireland/dtserv1/sgnome/buildenv$RPMSDIR \ |
115 |
--srpm-url=file:///net/dtserv1.ireland/dtserv1/sgnome/buildenv$SRPMSDIR > /tmp/build.log.$$ 2>&1 |
|
1181 | 116 |
# --good-build-dir=/sgnome/pkgs/gnome-2.2/rpms \ FIXME |
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
117 |
|
850 | 118 |
# the number of failed pkgs is returned |
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
119 |
FAILED=$? |
482 | 120 |
|
850 | 121 |
# rotate rpms dir |
122 |
echo '' | rsh $RHOST -l $RUSER "rm -f $RPMSDIR.prev/*; rmdir $RPMSDIR.prev" |
|
123 |
echo '' | rsh $RHOST -l $RUSER "mv $RPMSDIR $RPMSDIR.prev; mkdir -p $RPMSDIR" |
|
124 |
||
125 |
# copy new rpms |
|
1058 | 126 |
echo '' | rcp `./build-gnome2 --nightly --date "$RELEASE_DATE" install-order \ |
127 |
--full-path --target i586 \ |
|
482 | 128 |
*.spec` $RUSER@$RHOST:$RPMSDIR |
129 |
||
786
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
648
diff
changeset
|
130 |
if [ -d /tmp/old-rpms-used.$$ ]; then |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
648
diff
changeset
|
131 |
echo '' | rcp /tmp/old-rpms-used.$$/*.rpm $RUSER@$RHOST:$RPMSDIR |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
648
diff
changeset
|
132 |
rm -rf /tmp/old-rpms-used.$$ |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
648
diff
changeset
|
133 |
fi |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
648
diff
changeset
|
134 |
|
850 | 135 |
# rotate srpms dir |
136 |
echo '' | rsh $RHOST -l $RUSER "rm -f $SRPMSDIR.prev/*; rmdir $SRPMSDIR.prev" |
|
137 |
echo '' | rsh $RHOST -l $RUSER "mv $SRPMSDIR $SRPMSDIR.prev; mkdir -p $SRPMSDIR" |
|
138 |
# copy new srpms |
|
1058 | 139 |
echo '' | rcp /usr/src/packages/SRPMS/*.$RELEASE_DATE.src.rpm \ |
482 | 140 |
$RUSER@$RHOST:$SRPMSDIR |
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
141 |
|
609 | 142 |
ALL_REPORTS=$WEBROOT/$WEBDIR/all_reports.html |
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
143 |
touch $ALL_REPORTS |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
144 |
|
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
145 |
cp $ALL_REPORTS $ALL_REPORTS.old |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
146 |
export FAILED ALL_REPORTS |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
147 |
|
850 | 148 |
# update web page |
1058 | 149 |
( echo "<TR><TD><A HREF=/$LOGDIR.html>$DIR_DATE</A></TD>"; \ |
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
150 |
echo " <TD>$FAILED package(s) failed</TD></TR>"; \ |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
151 |
cat $ALL_REPORTS.old ) > $ALL_REPORTS |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
152 |
|
850 | 153 |
# send log by email |
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
154 |
cat /tmp/build.log.$$ | \ |
1418 | 155 |
mail -s "JDS.next nightly build: $FAILED pkgs failed" \ |
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
156 |
-R $REPLY_TO $EMAIL_ADDR |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
157 |
|
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
158 |
rm -f /tmp/build.log.$$ |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
159 |
|
1351 | 160 |
echo '' | rsh $RHOST -l $RUSER "rm $LOCKFILE" |
161 |
||
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
162 |
exit 0 |