author | davelam |
Thu, 18 Feb 2010 14:59:55 +0000 | |
changeset 17558 | c3cb1eb93805 |
parent 17503 | 9250898104ca |
child 17608 | cae11c53264f |
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 |
|
120 |
svn revert -R . |
|
121 |
||
122 |
# checkout-out SVN copy *MUST* be read-only, or "update" needs passwd |
|
123 |
svn -q up > /dev/null 2>&1 || fatal_error "SVN update of spec-files-other failed" |
|
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 |
|
132 |
svn revert -R . |
|
133 |
||
134 |
# checkout-out SVN copy *MUST* be read-only, or "update" needs passwd |
|
135 |
svn -q up > /dev/null 2>&1 || fatal_error "SVN update failed" |
|
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 |
|
17263 | 142 |
pkgtool uninstall-pkgs --with-l10n --with-indiana-branding --define 'support_level supported' closed/*.spec *.spec indiana/*.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 |
10583 | 170 |
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 |
13048 | 173 |
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 |
|
15856
ee66ac49d3ed
fixed nightly build with SUNWdesktop-cache issue in jail
davelam
parents:
15813
diff
changeset
|
179 |
egrep -v '^(Requires|BuildRequires):' SUNWdesktop-cache.spec > SUNWdesktop-cache.spec.tmp.$$ |
17263 | 180 |
pkgtool build --nonotify --with-l10n ${DEBUG_BUILD} --define "nightly 1" --with-indiana-branding --define 'support_level supported' SUNWdesktop-cache.spec.tmp.$$ |
15856
ee66ac49d3ed
fixed nightly build with SUNWdesktop-cache issue in jail
davelam
parents:
15813
diff
changeset
|
181 |
rm -f SUNWdesktop-cache.spec.tmp.$$ |
17422 | 182 |
|
183 |
# hack the svc script |
|
184 |
grep -i "OpenSolaris" /etc/release >/dev/null 2>&1 |
|
185 |
if [ $? -eq 0 ]; then |
|
186 |
printf "1a\n\nexit 0\n.\nw"| pfexec ed -s /usr/share/desktop-cache/restart_fmri |
|
187 |
else |
|
188 |
su<<EO_SU |
|
189 |
cat<<EOF>/usr/share/desktop-cache/restart_fmri |
|
15776 | 190 |
#!/bin/ksh |
191 |
||
192 |
exit 0 |
|
193 |
EOF |
|
194 |
EO_SU |
|
17422 | 195 |
fi |
15776 | 196 |
fi |
197 |
||
17503 | 198 |
# build gnome-xml separately. It creates an smf manifest which generates some |
199 |
# docbook manifests. Generate them manually since this won't work in a jail. |
|
200 |
||
201 |
if [ -f /THIS_IS_JAIL_* ]; then |
|
202 |
pkgtool build --no-notify --with-l10n ${DEBUG_BUILD} --define "nightly 1" \ |
|
203 |
--with-indiana-branding --define 'support_level supported' SUNWgnome-xml.spec |
|
204 |
pfexec /usr/share/sgml/docbook/docbook-catalog-uninstall.sh |
|
205 |
pfexec /usr/share/sgml/docbook/docbook-catalog-install.sh |
|
206 |
fi |
|
207 |
||
9398 | 208 |
# start the build |
17263 | 209 |
pkgtool -v --nightly --date "$RELEASE_DATE" build closed/SUNWevolution-bdb-devel.spec closed/*.spec *.spec indiana/*.spec \ |
16090 | 210 |
--download \ |
9398 | 211 |
--logdir=$WEBROOT/$LOGDIR \ |
9652 | 212 |
--logdir-url=http://jds.ireland/$LOGDIR \ |
9398 | 213 |
[email protected] \ |
214 |
--prodname="${PRODNAME}/s${OSrel}${OSarch}" \ |
|
15542 | 215 |
--live --with-l10n ${DEBUG_BUILD} \ |
17263 | 216 |
--define "nightly 1" --with-indiana-branding \ |
217 |
--without-dt --without-blueprint \ |
|
218 |
--define 'support_level supported' \ |
|
9398 | 219 |
--summary-log=$WEBROOT/$LOGDIR.html \ |
220 |
--summary-title="${PRODNAME} S${OSrel}/${OSarch_full} Nightly Build Report `date +'%d %B %Y'`" \ |
|
9648 | 221 |
--rpm-url=file:///net/jdsserv.ireland/$RPMSDIR/all_pkgs \ |
9398 | 222 |
> /tmp/build.log.$$ 2>&1 |
223 |
||
224 |
# the number of failed pkgs is returned |
|
225 |
FAILED=$? |
|
226 |
||
11798 | 227 |
# Build spec-files-other |
228 |
cd $SPECDIR/../spec-files-other |
|
229 |
||
230 |
pkgtool -v --nightly --date "$RELEASE_DATE" build core/*.spec experimental/*.spec l10n/*.spec \ |
|
16090 | 231 |
--download \ |
11798 | 232 |
--logdir=$WEBROOT/$LOGDIR \ |
233 |
--logdir-url=http://jds.ireland/$LOGDIR \ |
|
234 |
[email protected] \ |
|
235 |
--prodname="${PRODNAME}/s${OSrel}${OSarch}" \ |
|
12649 | 236 |
--live --with-l10n ${DEBUG_BUILD} \ |
17263 | 237 |
--define "nightly 1" --with-indiana-branding \ |
238 |
--without-dt --without-blueprint \ |
|
239 |
--define 'support_level supported' \ |
|
11798 | 240 |
--summary-log=$WEBROOT/$LOGDIR-other.html \ |
241 |
--summary-title="${PRODNAME} S${OSrel}/${OSarch_full} SFO Nightly Build Report `date +'%d %B %Y'`" \ |
|
242 |
--rpm-url=file:///net/jdsserv.ireland/$RPMSDIR/all_pkgs \ |
|
243 |
>> /tmp/build.log.$$ 2>&1 |
|
11809 | 244 |
|
245 |
# The number of failed pkgs is returned |
|
246 |
FAILED_OTHER=$? |
|
11798 | 247 |
# End spec-files-other build. |
248 |
||
15856
ee66ac49d3ed
fixed nightly build with SUNWdesktop-cache issue in jail
davelam
parents:
15813
diff
changeset
|
249 |
#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
|
250 |
if [ -f /THIS_IS_JAIL_* ]; then |
ee66ac49d3ed
fixed nightly build with SUNWdesktop-cache issue in jail
davelam
parents:
15813
diff
changeset
|
251 |
pkgtool uninstall-pkgs --nonotify --with-l10n SUNWdesktop-cache.spec |
17263 | 252 |
pkgtool build-only --nonotify --with-l10n ${DEBUG_BUILD} --define "nightly 1" --with-indiana-branding --define 'support_level supported' SUNWdesktop-cache.spec |
15856
ee66ac49d3ed
fixed nightly build with SUNWdesktop-cache issue in jail
davelam
parents:
15813
diff
changeset
|
253 |
fi |
ee66ac49d3ed
fixed nightly build with SUNWdesktop-cache issue in jail
davelam
parents:
15813
diff
changeset
|
254 |
|
9398 | 255 |
# rotate rpms dir |
256 |
rm -rf $RPMSDIR.prev |
|
257 |
mv $RPMSDIR $RPMSDIR.prev; mkdir -p $RPMSDIR |
|
258 |
||
259 |
# make dist |
|
12725 | 260 |
/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 | 261 |
cp -r /jds/dist/nightly-/${OSarch_full}/* /jds/dist/nightly-/${OSarch_full}/.??* $RPMSDIR |
262 |
chmod a+x $RPMSDIR/install-jds |
|
263 |
mkdir -p $RPMSDIR/all_pkgs |
|
264 |
cd $RPMSDIR/all_pkgs |
|
265 |
ln -s ../*/*.tar.gz . |
|
12735 | 266 |
rm -rf /jds/dist/nightly- |
9398 | 267 |
|
12293 | 268 |
# Send output of make-jds-dist.pl to GNOME RE for review. |
12725 | 269 |
/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 | 270 |
mailx -s "${PRODNAME} S${OSrel} ${OSarch_full} nightly build: make-jds-dist.pl output" "[email protected]" |
11995 | 271 |
|
9398 | 272 |
ALL_REPORTS=$WEBROOT/$WEBDIR/all_reports.html |
273 |
touch $ALL_REPORTS |
|
274 |
||
275 |
cp $ALL_REPORTS $ALL_REPORTS.old |
|
11809 | 276 |
export FAILED FAILED_OTHER ALL_REPORTS |
9398 | 277 |
|
278 |
# update web page |
|
11809 | 279 |
( echo "<tr><td><a href=/$LOGDIR.html>$DIR_DATE</a></td>"; \ |
280 |
echo " <td>$FAILED package(s) failed</td></tr>"; \ |
|
281 |
echo "<tr><td><a href=/$LOGDIR-other.html>$DIR_DATE</a></td>"; \ |
|
282 |
echo " <td>$FAILED_OTHER SFO package(s) failed</td></tr>"; \ |
|
9398 | 283 |
cat $ALL_REPORTS.old ) > $ALL_REPORTS |
284 |
||
285 |
# Report absolute symlinks. These are blockers for Solaris integration. |
|
286 |
grep 'is an absolute symlink' $WEBROOT/$LOGDIR/*.log >>/tmp/build.log.$$ |
|
287 |
||
288 |
# Count the number of local patches. |
|
9401 | 289 |
patch_count=`ls $SPECDIR/patches/*.diff | wc -l` |
9398 | 290 |
echo "PATCH COUNT: $patch_count local patches used in this build.">>/tmp/build.log.$$ |
291 |
||
292 |
# send warnings, errors and summary in email |
|
293 |
grep -v '^INFO:' /tmp/build.log.$$ | \ |
|
294 |
mailx -s "${PRODNAME} S${OSrel} ${OSarch_full} nightly build: $FAILED pkgs failed" $EMAIL_ADDR |
|
295 |
||
296 |
rm -f /tmp/build.log.$$ |
|
297 |
||
298 |
# Email Beijing team to begin downloading packages. |
|
9648 | 299 |
/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
|
300 |
mailx -s "${PRODNAME} S${OSrel} ${OSarch_full} Development nightly build: $FAILED pkgs failed" "[email protected],[email protected]" |
9398 | 301 |
|
302 |
||
303 |
rm $LOCKFILE |
|
304 |
||
305 |
# find any differences from the prototype files saved after the |
|
306 |
# last milestone build |
|
307 |
cd /jds/spec-files/prototypes/${OSarch_full} |
|
308 |
for f in *.proto; do |
|
309 |
test -f /jds/packages/PKGMAPS/proto/$f || continue |
|
310 |
cmp -s $f /jds/packages/PKGMAPS/proto/$f && continue |
|
311 |
echo $f: |
|
312 |
diff $f /jds/packages/PKGMAPS/proto/$f |
|
313 |
echo |
|
314 |
done > /tmp/proto-changes.$$ |
|
315 |
||
316 |
# if any diffs found mail the result to RE |
|
317 |
test -s /tmp/proto-changes.$$ && { |
|
318 |
( echo "Prototype changes found since the last milestone build:" |
|
319 |
echo |
|
320 |
cat /tmp/proto-changes.$$ ) | \ |
|
321 |
mailx -s "${PRODNAME} S${OSrel} ${OSarch_full} prototype changes" \ |
|
322 |
$EMAIL_ADDR |
|
323 |
} |
|
324 |
||
325 |
rm -f /tmp/proto-changes.$$ |
|
326 |
||
327 |
exit 0 |