Mercurial > illumos > illumos-gate
changeset 4973:e9e56fdeb64d
6584986 *nightly* needs a hook for shared build machines
author | sommerfe |
---|---|
date | Fri, 31 Aug 2007 14:10:02 -0700 |
parents | b6da5df14183 |
children | c7454a80ea3d |
files | usr/src/tools/scripts/nightly.1 usr/src/tools/scripts/nightly.conf usr/src/tools/scripts/nightly.sh |
diffstat | 3 files changed, 145 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/tools/scripts/nightly.1 Fri Aug 31 12:48:28 2007 -0700 +++ b/usr/src/tools/scripts/nightly.1 Fri Aug 31 14:10:02 2007 -0700 @@ -109,7 +109,12 @@ .I env file that does what you want. .LP - +Like most of the other build tools in usr/src/tools, this script tends +to change on a fairly regular basis; do not expect to be able to build +OS/Net with a version of nightly significantly older than your source +tree. It has what is effectively a Consolidation Private relationship +to other build tools and with many parts of the OS/Net makefiles, +although it may also be used to build other consolidations. .LP .SH NIGHTLY_OPTIONS The environment variable NIGHTLY_OPTIONS controls the actions @@ -510,16 +515,6 @@ version of dmake to be used. .RE .LP -.B POST_NIGHTLY -.RS 5 -The command specified here will be executed at the end of nightly. The -return status of nightly - one of "Completed", "Interrupted", or "Failed" - -will be available in the environment variable NIGHTLY_STATUS. Any other -environment variables exported in the environment file or by nightly are -available, although these are not stable, and should be checked before use. -The command output will be appended to the mail message and log file. -.RE -.LP .B MULTI_PROTO .RS 5 If "no" (the default), @@ -531,6 +526,49 @@ flag forces MULTI_PROTO to "yes". .RE .LP +.SH NIGHTLY HOOK ENVIRONMENT VARIABLES +.LP +Several optional environment variables may specify commands to run at +various points during the build. Commands specified in the hook +variable will be run in a subshell; command output will be appended to +the mail message and log file. If the hook exits with a non-zero +status, the build is aborted immediately. Environment variables +defined in the environment file will be available. +.LP +.B SYS_PRE_NIGHTLY +.RS 5 +Run just after the workspace lock is acquired. This is reserved for +per-build-machine customizations and should be set only in /etc/nightly.conf +.RE +.LP +.B PRE_NIGHTLY +.RS 5 +Run just after SYS_PRE_NIGHTLY. +.RE +.LP +.B PRE_BRINGOVER +.RS 5 +Run just before bringover is started; not run if no bringover is done. +.RE +.LP +.B POST_BRINGOVER +.RS 5 +Run just after bringover completes; not run if no bringover is done. +.RE +.LP +.B POST_NIGHTLY +.RS 5 +Run after the build completes, with the return status of nightly - one +of "Completed", "Interrupted", or "Failed" - available in the +environment variable NIGHTLY_STATUS +.RE +.LP +.B SYS_POST_NIGHTLY +.RS 5 +This is reserved for per-build-machine customizations, and runs +immedately after POST_NIGHTLY. +.RE +.LP .SH REALMODE ENVIRONMENT VARIABLES .LP The following environment variables referenced by @@ -566,6 +604,15 @@ .RS 5 Destination for sparc realmode package SUNWrmodu. Yes, this sparc package really is built on x86. +.SH FILES +.LP +.RS 5 +/etc/nightly.conf +.RE +.LP +If present, nightly executes this file just prior to executing the +.I env +file. .SH BUILDING THE IHV WORKSPACE .LP The IHV workspace can be built with
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/tools/scripts/nightly.conf Fri Aug 31 14:10:02 2007 -0700 @@ -0,0 +1,44 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# +# Sample system-wide /etc/nightly.conf file for shared build servers. +# +sys_pre_nightly() { + if [ -f /etc/nonightly ]; then + cat /etc/nonightly + exit 1 + fi +} + +BUILD_PROJECT=batch +SYS_PRE_NIGHTLY=sys_pre_nightly + +export BUILD_PROJECT SYS_PRE_NIGHTLY + +renice -n 5 -p $$
--- a/usr/src/tools/scripts/nightly.sh Fri Aug 31 12:48:28 2007 -0700 +++ b/usr/src/tools/scripts/nightly.sh Fri Aug 31 14:10:02 2007 -0700 @@ -144,6 +144,36 @@ } # +# usage: run_hook HOOKNAME ARGS... +# +# If variable "$HOOKNAME" is defined, insert a section header into +# our logs and then run the command with ARGS +# +run_hook() { + HOOKNAME=$1 + eval HOOKCMD=\$$HOOKNAME + shift + + if [ -n "$HOOKCMD" ]; then + ( + echo "\n==== Running $HOOKNAME command: $HOOKCMD ====\n" + ( $HOOKCMD "$@" 2>&1 ) + if [ "$?" -ne 0 ]; then + # Let exit status propagate up + touch $TMPDIR/abort + fi + ) | tee -a $mail_msg_file >> $LOGFILE + + if [ -f $TMPDIR/abort ]; then + build_ok=n + echo "\nAborting at request of $HOOKNAME" | + tee -a $mail_msg_file >> $LOGFILE + exit 1 + fi + fi +} + +# # usage: filelist DESTDIR PATTERN # filelist() { @@ -1137,6 +1167,10 @@ # # Setup environmental variables # +if [ -f /etc/nightly.conf ]; then + . /etc/nightly.conf +fi + if [ -f $1 ]; then if [[ $1 = */* ]]; then . $1 @@ -1578,11 +1612,8 @@ NIGHTLY_STATUS=$state export NIGHTLY_STATUS - if [ -n "$POST_NIGHTLY" ]; then - echo "\n==== Running POST_NIGHTLY command:" \ - "$POST_NIGHTLY ====\n" | tee -a $mail_msg_file >> $LOGFILE - $POST_NIGHTLY $state 2>&1 | tee -a $mail_msg_file >> $LOGFILE - fi + run_hook POST_NIGHTLY $state + run_hook SYS_POST_NIGHTLY $state cat $build_time_file $mail_msg_file > ${LLOG}/mail_msg if [ "$m_FLAG" = "y" ]; then @@ -1733,6 +1764,9 @@ build_noise_file="${TMPDIR}/build_noise" exec </dev/null >$build_noise_file 2>&1 +run_hook SYS_PRE_NIGHTLY +run_hook PRE_NIGHTLY + echo "\n==== list of environment variables ====\n" >> $LOGFILE env >> $LOGFILE @@ -2013,6 +2047,8 @@ # Decide whether to bringover to the codemgr workspace # if [ "$n_FLAG" = "n" ]; then + run_hook PRE_BRINGOVER + echo "\n==== bringover to $CODEMGR_WS at `date` ====\n" >> $LOGFILE # sleep on the parent workspace's lock while egrep -s write $BRINGOVER_WS/Codemgr_wsdata/locks @@ -2043,6 +2079,8 @@ exit 1 fi + run_hook POST_BRINGOVER + # # Possible transition from pre-split workspace to split # workspace. See if the bringover changed anything.