author | Jon Tibble <meths@btinternet.com> |
Sat, 06 Oct 2012 16:11:50 +0100 | |
branch | s11express-2010-11 |
changeset 22109 | db10202d5f6d |
parent 18339 | ca68b22933c2 |
child 21136 | de7b6f1af9c6 |
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 |
||
17962 | 61 |
# check which subversion should be used |
62 |
if [ -x /usr/bin/svn ]; then |
|
63 |
svn_cmd=/usr/bin/svn |
|
64 |
else |
|
65 |
svn_cmd=svn |
|
66 |
fi |
|
67 |
||
9398 | 68 |
# ------------ nothing to configure below this line -------------- |
69 |
||
70 |
if [ "x$I_KNOW_WHAT_IM_DOING" != xyes ]; then |
|
71 |
echo " ,---------------------------------------------------------------." |
|
72 |
echo "| This script is intended to be run from cron for producing |" |
|
73 |
echo "| official nightly builds. It will mail responsible engineers |" |
|
74 |
echo "| if any build failure occurs, sends build reports to v" |
|
75 |
echo "| RE and update web pages." |
|
76 |
echo "|" |
|
77 |
echo "| Don't run it unless you know what you are doing. Thanks." |
|
78 |
echo "|" |
|
79 |
echo "| Mail [email protected] if you need more info." |
|
80 |
echo "\`------> +" |
|
81 |
exit 1 |
|
82 |
fi |
|
83 |
||
84 |
MYNAME="$0" |
|
85 |
MYDIR=$(cd `dirname $0`; pwd) |
|
86 |
||
87 |
if [ "x$1" != x ]; then |
|
88 |
SPECDIR="$1" |
|
89 |
else |
|
90 |
SPECDIR="$MYDIR" |
|
91 |
fi |
|
92 |
||
93 |
# remove temporary files on exit |
|
94 |
clean_up () { |
|
95 |
case "$MYNAME" in |
|
96 |
/tmp/cron-script.copy.* ) |
|
97 |
rm -f $MYNAME |
|
98 |
;; |
|
99 |
esac |
|
100 |
exit |
|
101 |
} |
|
102 |
||
103 |
trap clean_up HUP INT TERM QUIT EXIT |
|
104 |
||
105 |
# make a copy of the cron script in /tmp and execute that in order to |
|
106 |
# avoid disasters caused by cvs update. |
|
107 |
case "$MYNAME" in |
|
108 |
/tmp/cron-script.copy.* ) |
|
109 |
;; |
|
110 |
*) |
|
111 |
cp $MYNAME /tmp/cron-script.copy.$$ |
|
112 |
chmod 755 /tmp/cron-script.copy.$$ |
|
113 |
cd /tmp |
|
114 |
exec /tmp/cron-script.copy.$$ "$MYDIR" |
|
115 |
;; |
|
116 |
esac |
|
117 |
||
118 |
fatal_error () { |
|
119 |
echo "ERROR: $*" |
|
120 |
exit 1 |
|
121 |
} |
|
122 |
||
12047 | 123 |
# Uninstall and cleanup spec-files packages. |
9398 | 124 |
cd $SPECDIR || fatal_error "$SPECDIR not found" |
125 |
||
126 |
#revert any local changes |
|
17962 | 127 |
$svn_cmd revert -R . |
9398 | 128 |
|
129 |
# checkout-out SVN copy *MUST* be read-only, or "update" needs passwd |
|
17962 | 130 |
$svn_cmd -q up > /dev/null 2>&1 || fatal_error "SVN update failed" |
9398 | 131 |
|
132 |
# if the script changed during cvs update, restart with the updated script |
|
13535 | 133 |
cd $SPECDIR |
9398 | 134 |
if ! /usr/bin/cmp -s ./cron-script.sh $MYNAME; then exec ./cron-script.sh; fi |
135 |
||
136 |
# uninstall all pkgs left behind by a previous build |
|
18337
a540efd3b7dd
removed the lines those were used to rename atspi2 spec files, which have been removed from gnome2.30 branch; improve the cmd line of "pkgtool uninstall-pkgs ..."
davelam
parents:
18166
diff
changeset
|
137 |
pkgtool uninstall-pkgs --nonotify --with-l10n --download --without-dt --with-indiana-branding --without-blueprint --define 'jds_version JDS4' --define 'support_level supported' specs/*.spec |
a540efd3b7dd
removed the lines those were used to rename atspi2 spec files, which have been removed from gnome2.30 branch; improve the cmd line of "pkgtool uninstall-pkgs ..."
davelam
parents:
18166
diff
changeset
|
138 |
|
9398 | 139 |
# remove-gnome will now remove anything left from uninstall-pkgs in case |
140 |
# or a packaging change for example |
|
9401 | 141 |
$SPECDIR/scripts/remove-gnome --version jds -q -f --no_extras > /dev/null 2>&1 |
9398 | 142 |
|
11858 | 143 |
|
9398 | 144 |
rm -rf /jds/packages/PKGS/* |
145 |
rm -rf /jds/packages/SPKGS/* |
|
146 |
rm -rf /jds/packages/BUILD/* |
|
9401 | 147 |
rm -rf /var/tmp/pkgbuild-*/* |
9398 | 148 |
|
149 |
# if the log directory exists, open a new one with numbered suffix |
|
150 |
NEW_LOGDIR=$LOGDIR |
|
151 |
N=1 |
|
152 |
while [ -d $WEBROOT/$NEW_LOGDIR ]; do |
|
153 |
NEW_LOGDIR=$LOGDIR.$N |
|
154 |
N=`expr $N + 1` |
|
155 |
done |
|
156 |
||
157 |
LOGDIR=$NEW_LOGDIR |
|
158 |
mkdir -p $WEBROOT/$LOGDIR || exit 5 |
|
159 |
||
160 |
mkdir -p $RPMSDIR |
|
161 |
touch $LOCKFILE |
|
162 |
||
163 |
# Rebuild the manpage tarballs |
|
10583 | 164 |
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
|
165 |
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
|
166 |
/usr/gnu/bin/make |
11406 | 167 |
|
9398 | 168 |
cd $SPECDIR |
169 |
||
15776 | 170 |
#FIXME: The smf service could not run correctly in jail, hack the script here. |
171 |
if [ -f /THIS_IS_JAIL_* ]; then |
|
17952
49667778fa53
merged two parts of workarounds for the issues in jail where smf doesn't work
davelam
parents:
17951
diff
changeset
|
172 |
# remove libsqlite.so* that are manually copied when jail is created. |
49667778fa53
merged two parts of workarounds for the issues in jail where smf doesn't work
davelam
parents:
17951
diff
changeset
|
173 |
pfexec rm -f /usr/lib/libsqlite3.so* |
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
|
174 |
|
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
|
175 |
# build SUNWdesktop-cache.spec and SUNWsqlite3.spec at beginning |
17903 | 176 |
egrep -v '^(Requires|BuildRequires):' specs/SUNWdesktop-cache.spec > specs/SUNWdesktop-cache.spec.tmp.$$ |
17952
49667778fa53
merged two parts of workarounds for the issues in jail where smf doesn't work
davelam
parents:
17951
diff
changeset
|
177 |
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 specs/SUNWgnome-xml.spec |
17903 | 178 |
rm -f specs/SUNWdesktop-cache.spec.tmp.$$ |
17422 | 179 |
|
17952
49667778fa53
merged two parts of workarounds for the issues in jail where smf doesn't work
davelam
parents:
17951
diff
changeset
|
180 |
# upload log file |
49667778fa53
merged two parts of workarounds for the issues in jail where smf doesn't work
davelam
parents:
17951
diff
changeset
|
181 |
cp /tmp/SUNWgnome-xml.log $WEBROOT/$LOGDIR/ |
49667778fa53
merged two parts of workarounds for the issues in jail where smf doesn't work
davelam
parents:
17951
diff
changeset
|
182 |
|
49667778fa53
merged two parts of workarounds for the issues in jail where smf doesn't work
davelam
parents:
17951
diff
changeset
|
183 |
# build gnome-xml separately. It creates an smf manifest which generates some |
49667778fa53
merged two parts of workarounds for the issues in jail where smf doesn't work
davelam
parents:
17951
diff
changeset
|
184 |
# docbook manifests. Generate them manually since this won't work in a jail. |
18057
0b18ea19bd2d
fix permission issue of docbook-catalog-(un)install.sh
davelam
parents:
17962
diff
changeset
|
185 |
pfexec bash /usr/share/sgml/docbook/docbook-catalog-uninstall.sh |
0b18ea19bd2d
fix permission issue of docbook-catalog-(un)install.sh
davelam
parents:
17962
diff
changeset
|
186 |
pfexec bash /usr/share/sgml/docbook/docbook-catalog-install.sh |
17952
49667778fa53
merged two parts of workarounds for the issues in jail where smf doesn't work
davelam
parents:
17951
diff
changeset
|
187 |
|
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
|
188 |
#FIXME: The smf service could not run correctly in jail, hack desktop-cache smf script here. |
17952
49667778fa53
merged two parts of workarounds for the issues in jail where smf doesn't work
davelam
parents:
17951
diff
changeset
|
189 |
if (egrep -i "(Solaris Next|OpenSolaris)" /etc/release >/dev/null 2>&1); then |
17422 | 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 |
||
9398 | 202 |
# start the build |
17903 | 203 |
pkgtool -v --nightly --date "$RELEASE_DATE" build specs/SUNWevolution-bdb-devel.spec specs/*.spec \ |
16090 | 204 |
--download \ |
9398 | 205 |
--logdir=$WEBROOT/$LOGDIR \ |
9652 | 206 |
--logdir-url=http://jds.ireland/$LOGDIR \ |
9398 | 207 |
[email protected] \ |
208 |
--prodname="${PRODNAME}/s${OSrel}${OSarch}" \ |
|
15542 | 209 |
--live --with-l10n ${DEBUG_BUILD} \ |
17263 | 210 |
--define "nightly 1" --with-indiana-branding \ |
211 |
--without-dt --without-blueprint \ |
|
212 |
--define 'support_level supported' \ |
|
9398 | 213 |
--summary-log=$WEBROOT/$LOGDIR.html \ |
214 |
--summary-title="${PRODNAME} S${OSrel}/${OSarch_full} Nightly Build Report `date +'%d %B %Y'`" \ |
|
9648 | 215 |
--rpm-url=file:///net/jdsserv.ireland/$RPMSDIR/all_pkgs \ |
9398 | 216 |
> /tmp/build.log.$$ 2>&1 |
217 |
||
218 |
# the number of failed pkgs is returned |
|
219 |
FAILED=$? |
|
220 |
||
18339
ca68b22933c2
don't remove SUNWdesktop-cache in order to keep the script /usr/share/desktop-cache/restart_fmri for uninstallation
davelam
parents:
18337
diff
changeset
|
221 |
#FIXME: Rebuild SUNWdesktop-cache a regular one at the end |
15856
ee66ac49d3ed
fixed nightly build with SUNWdesktop-cache issue in jail
davelam
parents:
15813
diff
changeset
|
222 |
if [ -f /THIS_IS_JAIL_* ]; then |
17903 | 223 |
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
|
224 |
fi |
ee66ac49d3ed
fixed nightly build with SUNWdesktop-cache issue in jail
davelam
parents:
15813
diff
changeset
|
225 |
|
9398 | 226 |
# rotate rpms dir |
227 |
rm -rf $RPMSDIR.prev |
|
228 |
mv $RPMSDIR $RPMSDIR.prev; mkdir -p $RPMSDIR |
|
229 |
||
230 |
# make dist |
|
12725 | 231 |
/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 | 232 |
cp -r /jds/dist/nightly-/${OSarch_full}/* /jds/dist/nightly-/${OSarch_full}/.??* $RPMSDIR |
233 |
chmod a+x $RPMSDIR/install-jds |
|
234 |
mkdir -p $RPMSDIR/all_pkgs |
|
235 |
cd $RPMSDIR/all_pkgs |
|
236 |
ln -s ../*/*.tar.gz . |
|
12735 | 237 |
rm -rf /jds/dist/nightly- |
9398 | 238 |
|
12293 | 239 |
# Send output of make-jds-dist.pl to GNOME RE for review. |
12725 | 240 |
/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 | 241 |
mailx -s "${PRODNAME} S${OSrel} ${OSarch_full} nightly build: make-jds-dist.pl output" "[email protected]" |
11995 | 242 |
|
9398 | 243 |
ALL_REPORTS=$WEBROOT/$WEBDIR/all_reports.html |
244 |
touch $ALL_REPORTS |
|
245 |
||
246 |
cp $ALL_REPORTS $ALL_REPORTS.old |
|
11809 | 247 |
export FAILED FAILED_OTHER ALL_REPORTS |
9398 | 248 |
|
249 |
# update web page |
|
11809 | 250 |
( echo "<tr><td><a href=/$LOGDIR.html>$DIR_DATE</a></td>"; \ |
251 |
echo " <td>$FAILED package(s) failed</td></tr>"; \ |
|
9398 | 252 |
cat $ALL_REPORTS.old ) > $ALL_REPORTS |
253 |
||
254 |
# Report absolute symlinks. These are blockers for Solaris integration. |
|
255 |
grep 'is an absolute symlink' $WEBROOT/$LOGDIR/*.log >>/tmp/build.log.$$ |
|
256 |
||
257 |
# Count the number of local patches. |
|
9401 | 258 |
patch_count=`ls $SPECDIR/patches/*.diff | wc -l` |
9398 | 259 |
echo "PATCH COUNT: $patch_count local patches used in this build.">>/tmp/build.log.$$ |
260 |
||
261 |
# send warnings, errors and summary in email |
|
262 |
grep -v '^INFO:' /tmp/build.log.$$ | \ |
|
263 |
mailx -s "${PRODNAME} S${OSrel} ${OSarch_full} nightly build: $FAILED pkgs failed" $EMAIL_ADDR |
|
264 |
||
265 |
rm -f /tmp/build.log.$$ |
|
266 |
||
267 |
# Email Beijing team to begin downloading packages. |
|
9648 | 268 |
/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
|
269 |
mailx -s "${PRODNAME} S${OSrel} ${OSarch_full} Development nightly build: $FAILED pkgs failed" "[email protected],[email protected]" |
9398 | 270 |
|
271 |
||
272 |
rm $LOCKFILE |
|
273 |
||
274 |
# find any differences from the prototype files saved after the |
|
275 |
# last milestone build |
|
276 |
cd /jds/spec-files/prototypes/${OSarch_full} |
|
277 |
for f in *.proto; do |
|
278 |
test -f /jds/packages/PKGMAPS/proto/$f || continue |
|
279 |
cmp -s $f /jds/packages/PKGMAPS/proto/$f && continue |
|
280 |
echo $f: |
|
281 |
diff $f /jds/packages/PKGMAPS/proto/$f |
|
282 |
echo |
|
283 |
done > /tmp/proto-changes.$$ |
|
284 |
||
285 |
# if any diffs found mail the result to RE |
|
286 |
test -s /tmp/proto-changes.$$ && { |
|
287 |
( echo "Prototype changes found since the last milestone build:" |
|
288 |
echo |
|
289 |
cat /tmp/proto-changes.$$ ) | \ |
|
290 |
mailx -s "${PRODNAME} S${OSrel} ${OSarch_full} prototype changes" \ |
|
291 |
$EMAIL_ADDR |
|
292 |
} |
|
293 |
||
294 |
rm -f /tmp/proto-changes.$$ |
|
295 |
||
296 |
exit 0 |