author | davelam |
Tue, 11 Dec 2007 04:08:22 +0000 | |
changeset 11309 | 22f4fb76dac8 |
parent 11097 | c8fb4a1a9c78 |
child 11356 | ffc41bf86652 |
permissions | -rwxr-xr-x |
9398 | 1 |
#!/bin/bash |
2 |
||
3 |
# Sample usage in crontab: |
|
4 |
# Run, Mon-Fri at 1:30am. Add to build user's crontab. |
|
9401 | 5 |
# 30 1 * * 1-5 . /jds/cbe/bin/env.sh; cd /jds/spec-files; I_KNOW_WHAT_IM_DOING=yes ./cron-script.sh |
9398 | 6 |
# |
7 |
# The same with a jail. Add to root's crontab. Example assumes 'gbuild' is the |
|
8 |
# build user |
|
9401 | 9 |
# 30 1 * * 1-5 /usr/sbin/chroot /path/to/jail/root /usr/bin/su - gbuild -c ". /jds/cbe/bin/env.sh; cd /jds/spec-files; I_KNOW_WHAT_IM_DOING=yes ./cron-script.sh" |
9398 | 10 |
# |
11 |
# $Id$ |
|
12 |
||
13 |
||
14 |
OSrel=`uname -r | cut -f2 -d.` |
|
15 |
OSarch_full=`uname -p` |
|
16 |
if [ "x$OSarch_full" = "xsparc" ]; then |
|
17 |
OSarch=s |
|
18 |
else |
|
19 |
OSarch_full=x86 |
|
20 |
OSarch=x |
|
21 |
fi |
|
22 |
||
11097 | 23 |
PRODNAME="G2.22" |
9398 | 24 |
|
25 |
# directory to copy rpms/srpms to on the remote host |
|
11097 | 26 |
RPMSDIR=/sgnome/pkgs/gnome2.22/S${OSrel}${OSarch}/nightly |
27 |
LOCKFILE=/sgnome/pkgs/gnome2.22/S${OSrel}${OSarch}/.build.lock |
|
9398 | 28 |
|
29 |
# reply-to/to address to send the build log as/to |
|
30 |
[email protected] |
|
31 |
[email protected] |
|
32 |
||
33 |
# date format appended to the Release tag in the spec files |
|
34 |
# (passed to the date command on the cmd line) |
|
35 |
RELEASE_DATE_FMT="%y%m%d" |
|
36 |
||
37 |
# date format used for naming the directories |
|
38 |
DIR_DATE_FMT="%Y-%m-%d" |
|
39 |
||
40 |
RELEASE_DATE=`date +$RELEASE_DATE_FMT` |
|
41 |
DIR_DATE=`date +$DIR_DATE_FMT` |
|
42 |
||
43 |
# document root of the web server |
|
9652 | 44 |
WEBROOT=/net/jdsserv.ireland/webroots/jds.ireland/htdocs |
9398 | 45 |
|
46 |
# subdir to keep logs and reports on the webserver |
|
11097 | 47 |
WEBDIR=build_reports/gnome2.22/nightly/S${OSrel}${OSarch} |
9398 | 48 |
LOGDIR=$WEBDIR/$DIR_DATE |
49 |
||
50 |
# ------------ nothing to configure below this line -------------- |
|
51 |
||
52 |
if [ "x$I_KNOW_WHAT_IM_DOING" != xyes ]; then |
|
53 |
echo " ,---------------------------------------------------------------." |
|
54 |
echo "| This script is intended to be run from cron for producing |" |
|
55 |
echo "| official nightly builds. It will mail responsible engineers |" |
|
56 |
echo "| if any build failure occurs, sends build reports to v" |
|
57 |
echo "| RE and update web pages." |
|
58 |
echo "|" |
|
59 |
echo "| Don't run it unless you know what you are doing. Thanks." |
|
60 |
echo "|" |
|
61 |
echo "| Mail [email protected] if you need more info." |
|
62 |
echo "\`------> +" |
|
63 |
exit 1 |
|
64 |
fi |
|
65 |
||
66 |
MYNAME="$0" |
|
67 |
MYDIR=$(cd `dirname $0`; pwd) |
|
68 |
||
69 |
if [ "x$1" != x ]; then |
|
70 |
SPECDIR="$1" |
|
71 |
else |
|
72 |
SPECDIR="$MYDIR" |
|
73 |
fi |
|
74 |
||
75 |
# remove temporary files on exit |
|
76 |
clean_up () { |
|
77 |
case "$MYNAME" in |
|
78 |
/tmp/cron-script.copy.* ) |
|
79 |
rm -f $MYNAME |
|
80 |
;; |
|
81 |
esac |
|
82 |
exit |
|
83 |
} |
|
84 |
||
85 |
trap clean_up HUP INT TERM QUIT EXIT |
|
86 |
||
87 |
# make a copy of the cron script in /tmp and execute that in order to |
|
88 |
# avoid disasters caused by cvs update. |
|
89 |
case "$MYNAME" in |
|
90 |
/tmp/cron-script.copy.* ) |
|
91 |
;; |
|
92 |
*) |
|
93 |
cp $MYNAME /tmp/cron-script.copy.$$ |
|
94 |
chmod 755 /tmp/cron-script.copy.$$ |
|
95 |
cd /tmp |
|
96 |
exec /tmp/cron-script.copy.$$ "$MYDIR" |
|
97 |
;; |
|
98 |
esac |
|
99 |
||
100 |
fatal_error () { |
|
101 |
echo "ERROR: $*" |
|
102 |
exit 1 |
|
103 |
} |
|
104 |
||
105 |
cd $SPECDIR || fatal_error "$SPECDIR not found" |
|
106 |
||
107 |
#revert any local changes |
|
108 |
svn revert -R . |
|
109 |
||
110 |
# checkout-out SVN copy *MUST* be read-only, or "update" needs passwd |
|
111 |
svn -q up > /dev/null 2>&1 || fatal_error "SVN update failed" |
|
112 |
cd $SPECDIR |
|
113 |
||
114 |
# if the script changed during cvs update, restart with the updated script |
|
115 |
if ! /usr/bin/cmp -s ./cron-script.sh $MYNAME; then exec ./cron-script.sh; fi |
|
116 |
||
117 |
# uninstall all pkgs left behind by a previous build |
|
10572 | 118 |
pkgtool uninstall-pkgs --with-l10n --with-tjds --with-apoc-adapter --with-sun-branding closed/*.spec *.spec >/dev/null |
9398 | 119 |
# remove-gnome will now remove anything left from uninstall-pkgs in case |
120 |
# or a packaging change for example |
|
9401 | 121 |
$SPECDIR/scripts/remove-gnome --version jds -q -f --no_extras > /dev/null 2>&1 |
9398 | 122 |
|
123 |
rm -rf /jds/packages/PKGS/* |
|
124 |
rm -rf /jds/packages/SPKGS/* |
|
125 |
rm -rf /jds/packages/BUILD/* |
|
9401 | 126 |
rm -rf /var/tmp/pkgbuild-*/* |
9398 | 127 |
|
128 |
# if the log directory exists, open a new one with numbered suffix |
|
129 |
NEW_LOGDIR=$LOGDIR |
|
130 |
N=1 |
|
131 |
while [ -d $WEBROOT/$NEW_LOGDIR ]; do |
|
132 |
NEW_LOGDIR=$LOGDIR.$N |
|
133 |
N=`expr $N + 1` |
|
134 |
done |
|
135 |
||
136 |
LOGDIR=$NEW_LOGDIR |
|
137 |
mkdir -p $WEBROOT/$LOGDIR || exit 5 |
|
138 |
||
139 |
mkdir -p $RPMSDIR |
|
140 |
touch $LOCKFILE |
|
141 |
||
142 |
# Rebuild the manpage tarballs |
|
10583 | 143 |
cd $SPECDIR |
144 |
rm -r po-sun/po-sun-tarballs manpages/sun-manpage-tarballs |
|
145 |
make |
|
9398 | 146 |
cd $SPECDIR |
147 |
||
148 |
# start the build |
|
9465 | 149 |
pkgtool -v --nightly --date "$RELEASE_DATE" build closed/SUNWevolution-bdb-devel.spec closed/*.spec *.spec \ |
9398 | 150 |
--logdir=$WEBROOT/$LOGDIR \ |
9652 | 151 |
--logdir-url=http://jds.ireland/$LOGDIR \ |
9398 | 152 |
[email protected] \ |
153 |
--prodname="${PRODNAME}/s${OSrel}${OSarch}" \ |
|
9493 | 154 |
--live --with-l10n --with-tjds --with-apoc-adapter \ |
10582 | 155 |
--define "nightly 1" --with-sun-branding \ |
9398 | 156 |
--summary-log=$WEBROOT/$LOGDIR.html \ |
157 |
--summary-title="${PRODNAME} S${OSrel}/${OSarch_full} Nightly Build Report `date +'%d %B %Y'`" \ |
|
9648 | 158 |
--rpm-url=file:///net/jdsserv.ireland/$RPMSDIR/all_pkgs \ |
9398 | 159 |
> /tmp/build.log.$$ 2>&1 |
160 |
||
161 |
# the number of failed pkgs is returned |
|
162 |
FAILED=$? |
|
163 |
||
164 |
# rotate rpms dir |
|
165 |
rm -rf $RPMSDIR.prev |
|
166 |
mv $RPMSDIR $RPMSDIR.prev; mkdir -p $RPMSDIR |
|
167 |
||
168 |
# make dist |
|
169 |
/sgnome/tools/re-scripts/jds-build/make-jds-dist.pl -l /sgnome/tools/re-scripts/jds-build/vermillion-devel.lst /jds/packages/PKGS /jds/dist nightly- > /dev/null 2>&1 |
|
170 |
cp -r /jds/dist/nightly-/${OSarch_full}/* /jds/dist/nightly-/${OSarch_full}/.??* $RPMSDIR |
|
171 |
chmod a+x $RPMSDIR/install-jds |
|
172 |
mkdir -p $RPMSDIR/all_pkgs |
|
173 |
cd $RPMSDIR/all_pkgs |
|
174 |
ln -s ../*/*.tar.gz . |
|
175 |
# Disable deletion of nightly- dir as network area often full - this is backup. |
|
176 |
#rm -rf /jds/dist/nightly- |
|
177 |
||
178 |
ALL_REPORTS=$WEBROOT/$WEBDIR/all_reports.html |
|
179 |
touch $ALL_REPORTS |
|
180 |
||
181 |
cp $ALL_REPORTS $ALL_REPORTS.old |
|
182 |
export FAILED ALL_REPORTS |
|
183 |
||
184 |
# update web page |
|
185 |
( echo "<TR><TD><A HREF=/$LOGDIR.html>$DIR_DATE</A></TD>"; \ |
|
186 |
echo " <TD>$FAILED package(s) failed</TD></TR>"; \ |
|
187 |
cat $ALL_REPORTS.old ) > $ALL_REPORTS |
|
188 |
||
189 |
# Report absolute symlinks. These are blockers for Solaris integration. |
|
190 |
grep 'is an absolute symlink' $WEBROOT/$LOGDIR/*.log >>/tmp/build.log.$$ |
|
191 |
||
192 |
# Count the number of local patches. |
|
9401 | 193 |
patch_count=`ls $SPECDIR/patches/*.diff | wc -l` |
9398 | 194 |
echo "PATCH COUNT: $patch_count local patches used in this build.">>/tmp/build.log.$$ |
195 |
||
196 |
# send warnings, errors and summary in email |
|
197 |
grep -v '^INFO:' /tmp/build.log.$$ | \ |
|
198 |
mailx -s "${PRODNAME} S${OSrel} ${OSarch_full} nightly build: $FAILED pkgs failed" $EMAIL_ADDR |
|
199 |
||
200 |
rm -f /tmp/build.log.$$ |
|
201 |
||
202 |
# Email Beijing team to begin downloading packages. |
|
9648 | 203 |
/usr/bin/echo "*Date: `date '+%Y-%m-%d'`*\n${PRODNAME} S${OSrel} ${OSarch_full} Development nightly build finished: jdsserv.ireland:${RPMSDIR}/download" | |
11309
22f4fb76dac8
Add [email protected] in notification email list for new download server in BJ site
davelam
parents:
11097
diff
changeset
|
204 |
mailx -s "${PRODNAME} S${OSrel} ${OSarch_full} Development nightly build: $FAILED pkgs failed" "[email protected],[email protected]" |
9398 | 205 |
|
206 |
||
207 |
rm $LOCKFILE |
|
208 |
||
209 |
# find any differences from the prototype files saved after the |
|
210 |
# last milestone build |
|
211 |
cd /jds/spec-files/prototypes/${OSarch_full} |
|
212 |
for f in *.proto; do |
|
213 |
test -f /jds/packages/PKGMAPS/proto/$f || continue |
|
214 |
cmp -s $f /jds/packages/PKGMAPS/proto/$f && continue |
|
215 |
echo $f: |
|
216 |
diff $f /jds/packages/PKGMAPS/proto/$f |
|
217 |
echo |
|
218 |
done > /tmp/proto-changes.$$ |
|
219 |
||
220 |
# if any diffs found mail the result to RE |
|
221 |
test -s /tmp/proto-changes.$$ && { |
|
222 |
( echo "Prototype changes found since the last milestone build:" |
|
223 |
echo |
|
224 |
cat /tmp/proto-changes.$$ ) | \ |
|
225 |
mailx -s "${PRODNAME} S${OSrel} ${OSarch_full} prototype changes" \ |
|
226 |
$EMAIL_ADDR |
|
227 |
} |
|
228 |
||
229 |
rm -f /tmp/proto-changes.$$ |
|
230 |
||
231 |
exit 0 |