author | laca |
Sat, 04 Jun 2005 22:46:08 +0000 | |
branch | gnome-2-10 |
changeset 19365 | cf6ebcb9c095 |
parent 5216 | 8d8ac459facf |
child 19377 | 27a5aa8e43a4 |
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 |
|
19365 | 10 |
RPMSDIR=/sgnome/pkgs/gnome2.10/rpms/nightly |
11 |
SRPMSDIR=/sgnome/pkgs/gnome2.10/srpms/nightly |
|
12 |
LOCKFILE=/sgnome/pkgs/gnome2.10/rpms/.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 |
|
19365 | 32 |
WEBDIR=gnome/releng/jds/gnome2.10/nightly |
1058 | 33 |
LOGDIR=$WEBDIR/$DIR_DATE |
850 | 34 |
|
35 |
# ------------ nothing to configure below this line -------------- |
|
36 |
||
1521 | 37 |
#if [ "x$I_KNOW_WHAT_IM_DOING" != xyes ]; then |
38 |
# echo " ,---------------------------------------------------------------." |
|
39 |
# echo "| This script is intended to be run from cron for producing |" |
|
40 |
# echo "| official nightly builds. It will mail responsible engineers |" |
|
41 |
# echo "| if any build failure occurs, sends build reports to v" |
|
42 |
# echo "| RE and update web pages." |
|
43 |
# echo "|" |
|
44 |
# echo "| Don't run it unless you know what you are doing. Thanks." |
|
45 |
# echo "|" |
|
46 |
# echo "| Mail [email protected] if you need more info." |
|
47 |
# echo "\`------> +" |
|
48 |
# exit 1 |
|
49 |
#fi |
|
50 |
||
482 | 51 |
MYNAME="$0" |
852 | 52 |
MYDIR=$(cd `dirname $0`; pwd) |
482 | 53 |
|
850 | 54 |
if [ "x$1" != x ]; then |
55 |
SPECDIR="$1" |
|
56 |
else |
|
57 |
SPECDIR="$MYDIR" |
|
58 |
fi |
|
59 |
||
60 |
# remove temporary files on exit |
|
482 | 61 |
clean_up () { |
62 |
case "$MYNAME" in |
|
63 |
/tmp/cron-script.copy.* ) |
|
64 |
rm -f $MYNAME |
|
65 |
;; |
|
66 |
esac |
|
853 | 67 |
exit |
482 | 68 |
} |
69 |
||
70 |
trap clean_up HUP INT TERM QUIT EXIT |
|
71 |
||
850 | 72 |
# make a copy of the cron script in /tmp and execute that in order to |
73 |
# avoid disasters caused by cvs update. |
|
485 | 74 |
case "$MYNAME" in |
75 |
/tmp/cron-script.copy.* ) |
|
76 |
;; |
|
77 |
*) |
|
482 | 78 |
cp $MYNAME /tmp/cron-script.copy.$$ |
79 |
chmod 755 /tmp/cron-script.copy.$$ |
|
80 |
cd /tmp |
|
850 | 81 |
exec /tmp/cron-script.copy.$$ "$MYDIR" |
482 | 82 |
;; |
83 |
esac |
|
84 |
||
85 |
fatal_error () { |
|
86 |
echo "ERROR: $*" |
|
87 |
exit 1 |
|
88 |
} |
|
89 |
||
90 |
cd $SPECDIR || fatal_error "$SPECDIR not found" |
|
91 |
||
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
92 |
cvs -q up -Pd > /dev/null 2>&1 || fatal_error "CVS update failed" |
482 | 93 |
|
850 | 94 |
# if the script changed during cvs update, restart with the updated script |
608 | 95 |
if ! /usr/bin/cmp -s ./cron-script.sh $MYNAME; then exec ./cron-script.sh; fi |
482 | 96 |
|
850 | 97 |
# uninstall all pkgs left behind by a previous build |
484 | 98 |
./build-gnome2 -q uninstall-pkgs *.spec |
482 | 99 |
|
100 |
rm -f /usr/src/packages/SRPMS/* /usr/src/packages/RPMS/*/* |
|
101 |
||
850 | 102 |
# if the log directory exists, open a new one with numbered suffix |
103 |
NEW_LOGDIR=$LOGDIR |
|
104 |
N=1 |
|
853 | 105 |
while [ -d $WEBROOT/$NEW_LOGDIR ]; do |
850 | 106 |
NEW_LOGDIR=$LOGDIR.$N |
107 |
N=`expr $N + 1` |
|
108 |
done |
|
109 |
||
110 |
LOGDIR=$NEW_LOGDIR |
|
648 | 111 |
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
|
112 |
|
1351 | 113 |
echo '' | rsh $RHOST -l $RUSER "touch $LOCKFILE" |
114 |
||
850 | 115 |
# start the build |
1058 | 116 |
./build-gnome2 -v --nightly --date "$RELEASE_DATE" build --target i586 *.spec \ |
609 | 117 |
--logdir=$WEBROOT/$LOGDIR \ |
2749 | 118 |
--logdir-url=http://gnome.ireland/$LOGDIR \ |
1418 | 119 |
--mail-errors-file=MAINTAINERS \ |
120 |
[email protected] \ |
|
19365 | 121 |
--prodname="G2.10/Linux" \ |
122 |
--good-build-dir=/sgnome/pkgs/gnome2.10/rpms \ |
|
786
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
648
diff
changeset
|
123 |
--good-rpms-copy-dir=/tmp/old-rpms-used.$$ \ |
609 | 124 |
--summary-log=$WEBROOT/$LOGDIR.html \ |
608 | 125 |
--summary-title="Nightly Build Report `date +'%d %B %Y'`" \ |
1418 | 126 |
--rpm-url=file:///net/dtserv1.ireland/dtserv1/sgnome/buildenv$RPMSDIR \ |
127 |
--srpm-url=file:///net/dtserv1.ireland/dtserv1/sgnome/buildenv$SRPMSDIR > /tmp/build.log.$$ 2>&1 |
|
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
128 |
|
850 | 129 |
# 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
|
130 |
FAILED=$? |
482 | 131 |
|
850 | 132 |
# rotate rpms dir |
133 |
echo '' | rsh $RHOST -l $RUSER "rm -f $RPMSDIR.prev/*; rmdir $RPMSDIR.prev" |
|
134 |
echo '' | rsh $RHOST -l $RUSER "mv $RPMSDIR $RPMSDIR.prev; mkdir -p $RPMSDIR" |
|
135 |
||
136 |
# copy new rpms |
|
1058 | 137 |
echo '' | rcp `./build-gnome2 --nightly --date "$RELEASE_DATE" install-order \ |
138 |
--full-path --target i586 \ |
|
482 | 139 |
*.spec` $RUSER@$RHOST:$RPMSDIR |
140 |
||
786
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
648
diff
changeset
|
141 |
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
|
142 |
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
|
143 |
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
|
144 |
fi |
164d94045f68
added support for using known good rpms when a component fails to build.
laca
parents:
648
diff
changeset
|
145 |
|
850 | 146 |
# rotate srpms dir |
147 |
echo '' | rsh $RHOST -l $RUSER "rm -f $SRPMSDIR.prev/*; rmdir $SRPMSDIR.prev" |
|
148 |
echo '' | rsh $RHOST -l $RUSER "mv $SRPMSDIR $SRPMSDIR.prev; mkdir -p $SRPMSDIR" |
|
149 |
# copy new srpms |
|
2861 | 150 |
echo '' | rcp /usr/src/packages/SRPMS/*.$RELEASE_DATE.*src.rpm \ |
482 | 151 |
$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
|
152 |
|
609 | 153 |
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
|
154 |
touch $ALL_REPORTS |
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
155 |
|
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
156 |
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
|
157 |
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
|
158 |
|
850 | 159 |
# update web page |
1058 | 160 |
( 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
|
161 |
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
|
162 |
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
|
163 |
|
850 | 164 |
# 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
|
165 |
cat /tmp/build.log.$$ | \ |
19365 | 166 |
mail -s "G2.10/Linux 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
|
167 |
-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
|
168 |
|
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
169 |
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
|
170 |
|
1351 | 171 |
echo '' | rsh $RHOST -l $RUSER "rm $LOCKFILE" |
172 |
||
606
53d75f521e46
added some command line options to the build script for use in the nightly builds.
laca
parents:
581
diff
changeset
|
173 |
exit 0 |