author | chrisk |
Thu, 22 Apr 2010 11:27:41 +0000 | |
changeset 17903 | 59c41f11ecf8 |
parent 17750 | 73ddfd53952a |
child 17951 | f079fefb78e2 |
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 |
||
12735 | 14 |
# Determine whether to do debug or non-debug build. |
15 |
# On 'even' days of the week (Sun, Tues, Thur, Sat) to a debug build. |
|
16 |
DEBUG_BUILD= |
|
17 |
DEBUG_DIR= |
|
18 |
DOW=$[ $(date +"%w") % 2 ] |
|
13278 | 19 |
#if [ $DOW -eq "0" ]; then |
20 |
# DEBUG_BUILD="--with-debug" |
|
21 |
# DEBUG_DIR=.dbg |
|
22 |
#fi |
|
12735 | 23 |
|
9398 | 24 |
OSrel=`uname -r | cut -f2 -d.` |
25 |
OSarch_full=`uname -p` |
|
26 |
if [ "x$OSarch_full" = "xsparc" ]; then |
|
27 |
OSarch=s |
|
28 |
else |
|
29 |
OSarch_full=x86 |
|
30 |
OSarch=x |
|
31 |
fi |
|
32 |
||
17026 | 33 |
GNOME_VER="2.30" |
14453 | 34 |
PRODNAME="G${GNOME_VER}" |
9398 | 35 |
|
36 |
# directory to copy rpms/srpms to on the remote host |
|
14453 | 37 |
RPMSDIR=/sgnome/pkgs/gnome${GNOME_VER}/S${OSrel}${OSarch}/nightly${DEBUG_DIR} |
38 |
LOCKFILE=/sgnome/pkgs/gnome${GNOME_VER}/S${OSrel}${OSarch}/.build.lock |
|
9398 | 39 |
|
40 |
# reply-to/to address to send the build log as/to |
|
41 |
[email protected] |
|
42 |
[email protected] |
|
43 |
||
44 |
# date format appended to the Release tag in the spec files |
|
45 |
# (passed to the date command on the cmd line) |
|
46 |
RELEASE_DATE_FMT="%y%m%d" |
|
47 |
||
48 |
# date format used for naming the directories |
|
49 |
DIR_DATE_FMT="%Y-%m-%d" |
|
50 |
||
51 |
RELEASE_DATE=`date +$RELEASE_DATE_FMT` |
|
52 |
DIR_DATE=`date +$DIR_DATE_FMT` |
|
53 |
||
54 |
# document root of the web server |
|
9652 | 55 |
WEBROOT=/net/jdsserv.ireland/webroots/jds.ireland/htdocs |
9398 | 56 |
|
57 |
# subdir to keep logs and reports on the webserver |
|
14453 | 58 |
WEBDIR=build_reports/gnome${GNOME_VER}/nightly/S${OSrel}${OSarch} |
9398 | 59 |
LOGDIR=$WEBDIR/$DIR_DATE |
60 |
||
61 |
# ------------ nothing to configure below this line -------------- |
|
62 |
||
63 |
if [ "x$I_KNOW_WHAT_IM_DOING" != xyes ]; then |
|
64 |
echo " ,---------------------------------------------------------------." |
|
65 |
echo "| This script is intended to be run from cron for producing |" |
|
66 |
echo "| official nightly builds. It will mail responsible engineers |" |
|
67 |
echo "| if any build failure occurs, sends build reports to v" |
|
68 |
echo "| RE and update web pages." |
|
69 |
echo "|" |
|
70 |
echo "| Don't run it unless you know what you are doing. Thanks." |
|
71 |
echo "|" |
|
72 |
echo "| Mail [email protected] if you need more info." |
|
73 |
echo "\`------> +" |
|
74 |
exit 1 |
|
75 |
fi |
|
76 |
||
77 |
MYNAME="$0" |
|
78 |
MYDIR=$(cd `dirname $0`; pwd) |
|
79 |
||
80 |
if [ "x$1" != x ]; then |
|
81 |
SPECDIR="$1" |
|
82 |
else |
|
83 |
SPECDIR="$MYDIR" |
|
84 |
fi |
|
85 |
||
86 |
# remove temporary files on exit |
|
87 |
clean_up () { |
|
88 |
case "$MYNAME" in |
|
89 |
/tmp/cron-script.copy.* ) |
|
90 |
rm -f $MYNAME |
|
91 |
;; |
|
92 |
esac |
|
93 |
exit |
|
94 |
} |
|
95 |
||
96 |
trap clean_up HUP INT TERM QUIT EXIT |
|
97 |
||
98 |
# make a copy of the cron script in /tmp and execute that in order to |
|
99 |
# avoid disasters caused by cvs update. |
|
100 |
case "$MYNAME" in |
|
101 |
/tmp/cron-script.copy.* ) |
|
102 |
;; |
|
103 |
*) |
|
104 |
cp $MYNAME /tmp/cron-script.copy.$$ |
|
105 |
chmod 755 /tmp/cron-script.copy.$$ |
|
106 |
cd /tmp |
|
107 |
exec /tmp/cron-script.copy.$$ "$MYDIR" |
|
108 |
;; |
|
109 |
esac |
|
110 |
||
111 |
fatal_error () { |
|
112 |
echo "ERROR: $*" |
|
113 |
exit 1 |
|
114 |
} |
|
115 |
||
12047 | 116 |
# Update spec-files-other files and uninstall packages. |
117 |
cd $SPECDIR/../spec-files-other |
|
118 |
||
119 |
# Revert any local changes |
|
17749
d36307d8a2be
cron-script: OK, change back to /usr/bin/svn for now.
chrisk
parents:
17748
diff
changeset
|
120 |
/usr/bin/svn revert -R . |
12047 | 121 |
|
122 |
# checkout-out SVN copy *MUST* be read-only, or "update" needs passwd |
|
17749
d36307d8a2be
cron-script: OK, change back to /usr/bin/svn for now.
chrisk
parents:
17748
diff
changeset
|
123 |
/usr/bin/svn -q up > /dev/null 2>&1 || fatal_error "SVN update of spec-files-other failed" |
12047 | 124 |
|
125 |
# Uninstall the spec-files-other packages. |
|
17263 | 126 |
pkgtool uninstall-pkgs --with-l10n --with-indiana-branding core/*.spec experimental/*.spec l10n/*.spec |
12047 | 127 |
|
128 |
# Uninstall and cleanup spec-files packages. |
|
9398 | 129 |
cd $SPECDIR || fatal_error "$SPECDIR not found" |
130 |
||
131 |
#revert any local changes |
|
17749
d36307d8a2be
cron-script: OK, change back to /usr/bin/svn for now.
chrisk
parents:
17748
diff
changeset
|
132 |
/usr/bin/svn revert -R . |
9398 | 133 |
|
134 |
# checkout-out SVN copy *MUST* be read-only, or "update" needs passwd |
|
17749
d36307d8a2be
cron-script: OK, change back to /usr/bin/svn for now.
chrisk
parents:
17748
diff
changeset
|
135 |
/usr/bin/svn -q up > /dev/null 2>&1 || fatal_error "SVN update failed" |
9398 | 136 |
|
137 |
# if the script changed during cvs update, restart with the updated script |
|
13535 | 138 |
cd $SPECDIR |
9398 | 139 |
if ! /usr/bin/cmp -s ./cron-script.sh $MYNAME; then exec ./cron-script.sh; fi |
140 |
||
141 |
# uninstall all pkgs left behind by a previous build |
|
17903 | 142 |
pkgtool uninstall-pkgs --with-l10n --with-indiana-branding --define 'support_level supported' specs/*.spec >/dev/null |
9398 | 143 |
# remove-gnome will now remove anything left from uninstall-pkgs in case |
144 |
# or a packaging change for example |
|
9401 | 145 |
$SPECDIR/scripts/remove-gnome --version jds -q -f --no_extras > /dev/null 2>&1 |
9398 | 146 |
|
11858 | 147 |
|
9398 | 148 |
rm -rf /jds/packages/PKGS/* |
149 |
rm -rf /jds/packages/SPKGS/* |
|
150 |
rm -rf /jds/packages/BUILD/* |
|
9401 | 151 |
rm -rf /var/tmp/pkgbuild-*/* |
9398 | 152 |
|
153 |
# if the log directory exists, open a new one with numbered suffix |
|
154 |
NEW_LOGDIR=$LOGDIR |
|
155 |
N=1 |
|
156 |
while [ -d $WEBROOT/$NEW_LOGDIR ]; do |
|
157 |
NEW_LOGDIR=$LOGDIR.$N |
|
158 |
N=`expr $N + 1` |
|
159 |
done |
|
160 |
||
161 |
LOGDIR=$NEW_LOGDIR |
|
162 |
mkdir -p $WEBROOT/$LOGDIR || exit 5 |
|
163 |
||
164 |
mkdir -p $RPMSDIR |
|
165 |
touch $LOCKFILE |
|
166 |
||
167 |
# Rebuild the manpage tarballs |
|
10583 | 168 |
cd $SPECDIR |
17558
c3cb1eb93805
run make to generate both manpage and po tarballs in the top dir of spec-files-other
davelam
parents:
17503
diff
changeset
|
169 |
rm -r po-sun/po-sun-tarballs manpages*/sun-manpage-tarballs |
17748
018356abb525
cron-script.sh: explicitly call /usr/gnu/bin/make when building manpages
chrisk
parents:
17747
diff
changeset
|
170 |
/usr/gnu/bin/make |
17558
c3cb1eb93805
run make to generate both manpage and po tarballs in the top dir of spec-files-other
davelam
parents:
17503
diff
changeset
|
171 |
cd $SPECDIR/../spec-files-other |
c3cb1eb93805
run make to generate both manpage and po tarballs in the top dir of spec-files-other
davelam
parents:
17503
diff
changeset
|
172 |
rm -r po-sun/po-sun-tarballs manpages/sun-manpage-tarballs |
17748
018356abb525
cron-script.sh: explicitly call /usr/gnu/bin/make when building manpages
chrisk
parents:
17747
diff
changeset
|
173 |
/usr/gnu/bin/make |
11406 | 174 |
|
9398 | 175 |
cd $SPECDIR |
176 |
||
15776 | 177 |
#FIXME: The smf service could not run correctly in jail, hack the script here. |
178 |
if [ -f /THIS_IS_JAIL_* ]; then |
|
17608
cae11c53264f
SUNWsqlite3 is moved from sfw to desktop consolidation, so changed to build it at beginning, which is required by svbversion
davelam
parents:
17558
diff
changeset
|
179 |
# make sure there is no libsqlite3.so because it will be built out later on |
cae11c53264f
SUNWsqlite3 is moved from sfw to desktop consolidation, so changed to build it at beginning, which is required by svbversion
davelam
parents:
17558
diff
changeset
|
180 |
rm -f /usr/lib/libsqlite3.so* |
cae11c53264f
SUNWsqlite3 is moved from sfw to desktop consolidation, so changed to build it at beginning, which is required by svbversion
davelam
parents:
17558
diff
changeset
|
181 |
|
cae11c53264f
SUNWsqlite3 is moved from sfw to desktop consolidation, so changed to build it at beginning, which is required by svbversion
davelam
parents:
17558
diff
changeset
|
182 |
# build SUNWdesktop-cache.spec and SUNWsqlite3.spec at beginning |
17903 | 183 |
egrep -v '^(Requires|BuildRequires):' specs/SUNWdesktop-cache.spec > specs/SUNWdesktop-cache.spec.tmp.$$ |
184 |
pkgtool build --nonotify --with-l10n ${DEBUG_BUILD} --define "nightly 1" --with-indiana-branding --define 'support_level supported' specs/SUNWdesktop-cache.spec.tmp.$$ specs/SUNWsqlite3.spec |
|
185 |
rm -f specs/SUNWdesktop-cache.spec.tmp.$$ |
|
17422 | 186 |
|
17608
cae11c53264f
SUNWsqlite3 is moved from sfw to desktop consolidation, so changed to build it at beginning, which is required by svbversion
davelam
parents:
17558
diff
changeset
|
187 |
#FIXME: The smf service could not run correctly in jail, hack desktop-cache smf script here. |
17750 | 188 |
grep -i "Solaris Next" /etc/release >/dev/null 2>&1 |
17422 | 189 |
if [ $? -eq 0 ]; then |
190 |
printf "1a\n\nexit 0\n.\nw"| pfexec ed -s /usr/share/desktop-cache/restart_fmri |
|
191 |
else |
|
192 |
su<<EO_SU |
|
193 |
cat<<EOF>/usr/share/desktop-cache/restart_fmri |
|
15776 | 194 |
#!/bin/ksh |
195 |
||
196 |
exit 0 |
|
197 |
EOF |
|
198 |
EO_SU |
|
17422 | 199 |
fi |
15776 | 200 |
fi |
201 |
||
17503 | 202 |
# build gnome-xml separately. It creates an smf manifest which generates some |
203 |
# docbook manifests. Generate them manually since this won't work in a jail. |
|
204 |
||
205 |
if [ -f /THIS_IS_JAIL_* ]; then |
|
206 |
pkgtool build --no-notify --with-l10n ${DEBUG_BUILD} --define "nightly 1" \ |
|
17903 | 207 |
--with-indiana-branding --define 'support_level supported' specs/SUNWgnome-xml.spec |
17503 | 208 |
pfexec /usr/share/sgml/docbook/docbook-catalog-uninstall.sh |
209 |
pfexec /usr/share/sgml/docbook/docbook-catalog-install.sh |
|
210 |
fi |
|
211 |
||
9398 | 212 |
# start the build |
17903 | 213 |
pkgtool -v --nightly --date "$RELEASE_DATE" build specs/SUNWevolution-bdb-devel.spec specs/*.spec \ |
16090 | 214 |
--download \ |
9398 | 215 |
--logdir=$WEBROOT/$LOGDIR \ |
9652 | 216 |
--logdir-url=http://jds.ireland/$LOGDIR \ |
9398 | 217 |
[email protected] \ |
218 |
--prodname="${PRODNAME}/s${OSrel}${OSarch}" \ |
|
15542 | 219 |
--live --with-l10n ${DEBUG_BUILD} \ |
17263 | 220 |
--define "nightly 1" --with-indiana-branding \ |
221 |
--without-dt --without-blueprint \ |
|
222 |
--define 'support_level supported' \ |
|
9398 | 223 |
--summary-log=$WEBROOT/$LOGDIR.html \ |
224 |
--summary-title="${PRODNAME} S${OSrel}/${OSarch_full} Nightly Build Report `date +'%d %B %Y'`" \ |
|
9648 | 225 |
--rpm-url=file:///net/jdsserv.ireland/$RPMSDIR/all_pkgs \ |
9398 | 226 |
> /tmp/build.log.$$ 2>&1 |
227 |
||
228 |
# the number of failed pkgs is returned |
|
229 |
FAILED=$? |
|
230 |
||
11798 | 231 |
# Build spec-files-other |
232 |
cd $SPECDIR/../spec-files-other |
|
233 |
||
234 |
pkgtool -v --nightly --date "$RELEASE_DATE" build core/*.spec experimental/*.spec l10n/*.spec \ |
|
16090 | 235 |
--download \ |
11798 | 236 |
--logdir=$WEBROOT/$LOGDIR \ |
237 |
--logdir-url=http://jds.ireland/$LOGDIR \ |
|
238 |
[email protected] \ |
|
239 |
--prodname="${PRODNAME}/s${OSrel}${OSarch}" \ |
|
12649 | 240 |
--live --with-l10n ${DEBUG_BUILD} \ |
17263 | 241 |
--define "nightly 1" --with-indiana-branding \ |
242 |
--without-dt --without-blueprint \ |
|
243 |
--define 'support_level supported' \ |
|
11798 | 244 |
--summary-log=$WEBROOT/$LOGDIR-other.html \ |
245 |
--summary-title="${PRODNAME} S${OSrel}/${OSarch_full} SFO Nightly Build Report `date +'%d %B %Y'`" \ |
|
246 |
--rpm-url=file:///net/jdsserv.ireland/$RPMSDIR/all_pkgs \ |
|
247 |
>> /tmp/build.log.$$ 2>&1 |
|
11809 | 248 |
|
249 |
# The number of failed pkgs is returned |
|
250 |
FAILED_OTHER=$? |
|
11798 | 251 |
# End spec-files-other build. |
252 |
||
15856
ee66ac49d3ed
fixed nightly build with SUNWdesktop-cache issue in jail
davelam
parents:
15813
diff
changeset
|
253 |
#FIXME: Removed the hacked package SUNWdesktop-cache and build a regular one at the end |
ee66ac49d3ed
fixed nightly build with SUNWdesktop-cache issue in jail
davelam
parents:
15813
diff
changeset
|
254 |
if [ -f /THIS_IS_JAIL_* ]; then |
17903 | 255 |
pkgtool uninstall-pkgs --nonotify --with-l10n specs/SUNWdesktop-cache.spec |
256 |
pkgtool build-only --nonotify --with-l10n ${DEBUG_BUILD} --define "nightly 1" --with-indiana-branding --define 'support_level supported' specs/SUNWdesktop-cache.spec |
|
15856
ee66ac49d3ed
fixed nightly build with SUNWdesktop-cache issue in jail
davelam
parents:
15813
diff
changeset
|
257 |
fi |
ee66ac49d3ed
fixed nightly build with SUNWdesktop-cache issue in jail
davelam
parents:
15813
diff
changeset
|
258 |
|
9398 | 259 |
# rotate rpms dir |
260 |
rm -rf $RPMSDIR.prev |
|
261 |
mv $RPMSDIR $RPMSDIR.prev; mkdir -p $RPMSDIR |
|
262 |
||
263 |
# make dist |
|
12725 | 264 |
/sgnome/tools/re-scripts/jds-build/make-jds-dist.pl -l /sgnome/tools/re-scripts/jds-build/vermillion-devel.lst --nightly /jds/packages/PKGS /jds/dist nightly- > /dev/null 2>&1 |
9398 | 265 |
cp -r /jds/dist/nightly-/${OSarch_full}/* /jds/dist/nightly-/${OSarch_full}/.??* $RPMSDIR |
266 |
chmod a+x $RPMSDIR/install-jds |
|
267 |
mkdir -p $RPMSDIR/all_pkgs |
|
268 |
cd $RPMSDIR/all_pkgs |
|
269 |
ln -s ../*/*.tar.gz . |
|
12735 | 270 |
rm -rf /jds/dist/nightly- |
9398 | 271 |
|
12293 | 272 |
# Send output of make-jds-dist.pl to GNOME RE for review. |
12725 | 273 |
/sgnome/tools/re-scripts/jds-build/make-jds-dist.pl -l /sgnome/tools/re-scripts/jds-build/vermillion-devel.lst --nightly /jds/packages/PKGS /jds/dist nightly- -dryrun 2>&1 | \ |
12293 | 274 |
mailx -s "${PRODNAME} S${OSrel} ${OSarch_full} nightly build: make-jds-dist.pl output" "[email protected]" |
11995 | 275 |
|
9398 | 276 |
ALL_REPORTS=$WEBROOT/$WEBDIR/all_reports.html |
277 |
touch $ALL_REPORTS |
|
278 |
||
279 |
cp $ALL_REPORTS $ALL_REPORTS.old |
|
11809 | 280 |
export FAILED FAILED_OTHER ALL_REPORTS |
9398 | 281 |
|
282 |
# update web page |
|
11809 | 283 |
( echo "<tr><td><a href=/$LOGDIR.html>$DIR_DATE</a></td>"; \ |
284 |
echo " <td>$FAILED package(s) failed</td></tr>"; \ |
|
285 |
echo "<tr><td><a href=/$LOGDIR-other.html>$DIR_DATE</a></td>"; \ |
|
286 |
echo " <td>$FAILED_OTHER SFO package(s) failed</td></tr>"; \ |
|
9398 | 287 |
cat $ALL_REPORTS.old ) > $ALL_REPORTS |
288 |
||
289 |
# Report absolute symlinks. These are blockers for Solaris integration. |
|
290 |
grep 'is an absolute symlink' $WEBROOT/$LOGDIR/*.log >>/tmp/build.log.$$ |
|
291 |
||
292 |
# Count the number of local patches. |
|
9401 | 293 |
patch_count=`ls $SPECDIR/patches/*.diff | wc -l` |
9398 | 294 |
echo "PATCH COUNT: $patch_count local patches used in this build.">>/tmp/build.log.$$ |
295 |
||
296 |
# send warnings, errors and summary in email |
|
297 |
grep -v '^INFO:' /tmp/build.log.$$ | \ |
|
298 |
mailx -s "${PRODNAME} S${OSrel} ${OSarch_full} nightly build: $FAILED pkgs failed" $EMAIL_ADDR |
|
299 |
||
300 |
rm -f /tmp/build.log.$$ |
|
301 |
||
302 |
# Email Beijing team to begin downloading packages. |
|
9648 | 303 |
/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
|
304 |
mailx -s "${PRODNAME} S${OSrel} ${OSarch_full} Development nightly build: $FAILED pkgs failed" "[email protected],[email protected]" |
9398 | 305 |
|
306 |
||
307 |
rm $LOCKFILE |
|
308 |
||
309 |
# find any differences from the prototype files saved after the |
|
310 |
# last milestone build |
|
311 |
cd /jds/spec-files/prototypes/${OSarch_full} |
|
312 |
for f in *.proto; do |
|
313 |
test -f /jds/packages/PKGMAPS/proto/$f || continue |
|
314 |
cmp -s $f /jds/packages/PKGMAPS/proto/$f && continue |
|
315 |
echo $f: |
|
316 |
diff $f /jds/packages/PKGMAPS/proto/$f |
|
317 |
echo |
|
318 |
done > /tmp/proto-changes.$$ |
|
319 |
||
320 |
# if any diffs found mail the result to RE |
|
321 |
test -s /tmp/proto-changes.$$ && { |
|
322 |
( echo "Prototype changes found since the last milestone build:" |
|
323 |
echo |
|
324 |
cat /tmp/proto-changes.$$ ) | \ |
|
325 |
mailx -s "${PRODNAME} S${OSrel} ${OSarch_full} prototype changes" \ |
|
326 |
$EMAIL_ADDR |
|
327 |
} |
|
328 |
||
329 |
rm -f /tmp/proto-changes.$$ |
|
330 |
||
331 |
exit 0 |