bldenv.sh revision cb4d1691226e6583657e84c8ca7e3835499528a0
#
# 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
# 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 2011 Nexenta Systems, Inc. All rights reserved.
#
# before spawning a shell for doing a release-style builds interactively
# and incrementally.
#
function fatal_error
{
print -u2 "${progname}: $*"
exit 1
}
function usage
{
OPTIND=0
exit 2
}
typeset -r USAGE=$'+
[+NAME?bldenv - spawn shell for interactive incremental OS-Net
consolidation builds]
[+DESCRIPTION?bldenv is a useful companion to the nightly(1) script for
doing interactive and incremental builds in a workspace
already built with nightly(1). bldenv spawns a shell set up
with the same environment variables taken from an env_file,
as prepared for use with nightly(1).]
[+?In addition to running a shell for interactive use, bldenv
can optionally run a single command in the given environment,
in the vein of sh -c or su -c. This is useful for
scripting, when an interactive shell would not be. If the
command is composed of multiple shell words or contains
other shell metacharacters, it must be quoted appropriately.]
[+?bldenv is particularly useful for testing Makefile targets
like clobber, install and _msg, which otherwise require digging
through large build logs to figure out what is being
done.]
[+?By default, bldenv will invoke the shell specified in
$SHELL. If $SHELL is not set or is invalid, csh will be
used.]
[c?force the use of csh, regardless of the value of $SHELL.]
[f?invoke csh with the -f (fast-start) option. This option is valid
only if $SHELL is unset or if it points to csh.]
[d?set up environment for doing DEBUG builds (default is non-DEBUG)]
<env_file> [command]
[+EXAMPLES]{
[+?Example 1: Interactive use]{
[+?Use bldenv to spawn a shell to perform a DEBUG build and
testing of the Makefile targets clobber and install for
[+\n% rlogin wopr-2 -l gk
{root::wopr-2::49} bldenv -d /export0/jg/on10-se.env
Build type is DEBUG
RELEASE is 5.10
VERSION is wopr-2::on10-se::11/01/2001
RELEASE_DATE is May 2004
The top-level `setup\' target is available to build headers
and tools.
{root::wopr-2::49}
{root::wopr-2::50} make
{root::wopr-2::51} make clobber
{root::wopr-2::52} make
cat true.sh > true
chmod +x true
{root::wopr-2::53} make install
`install\' is up to date.]
}
[+?Example 2: Non-interactive use]{
[+?Invoke bldenv to create SUNWonbld with a single command:]
}
}
[+SEE ALSO?\bnightly\b(1)]
'
# main
builtin basename
typeset flags=(
typeset c=false
typeset f=false
typeset d=false
typeset O=false
typeset o=false
typeset t=true
typeset s=(
typeset e=false
typeset h=false
typeset d=false
typeset o=false
)
)
OPTIND=1
SUFFIX="-nd"
while getopts -a "${progname}" "${USAGE}" OPT ; do
c) flags.c=true ;;
+c) flags.c=false ;;
f) flags.f=true ;;
+f) flags.f=false ;;
t) flags.t=true ;;
+t) flags.t=false ;;
\?) usage ;;
esac
done
# test that the path to the environment-setting file was given
if (( $# < 1 )) ; then
fi
# force locale to C
export \
LC_COLLATE=C \
LC_CTYPE=C \
LC_MESSAGES=C \
LC_MONETARY=C \
LC_NUMERIC=C \
LC_TIME=C
# clear environment variables we know to be bad for the build
unset \
LD_AUDIT \
LD_DEBUG \
LD_FLAGS \
CONFIG \
GROUP \
OWNER \
REMOTE \
ENV \
ARCH \
#
# Setup environment variables
#
if [[ -f /etc/nightly.conf ]]; then
source /etc/nightly.conf
fi
if [[ -f "$1" ]]; then
if [[ "$1" == */* ]]; then
source "$1"
else
source "./$1"
fi
else
else
printf \
"$1" "$1"
exit 1
fi
fi
shift
# contents of stdenv.sh inserted after next line:
# STDENV_START
# STDENV_END
# Check if we have sufficient data to continue...
[[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
# must match the getopts in nightly.sh
OPTIND=1
NIGHTLY_OPTIONS="-${NIGHTLY_OPTIONS#-}"
do
t) flags.t=true ;;
+t) flags.t=false ;;
*) ;;
esac
done
POUND_SIGN="#"
# have we set RELEASE_DATE in our env file?
if [ -z "$RELEASE_DATE" ]; then
fi
BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d)
DEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\""
print 'Build type is \c'
if ${flags.d} ; then
print 'DEBUG'
unset RELEASE_BUILD
unset EXTRA_OPTIONS
unset EXTRA_CFLAGS
else
# default is a non-DEBUG build
print 'non-DEBUG'
export RELEASE_BUILD=
unset EXTRA_OPTIONS
unset EXTRA_CFLAGS
fi
# update build-type variables
PKGARCHIVE="${PKGARCHIVE}${SUFFIX}"
# Set PATH for a build
PATH="/opt/onbld/bin:/opt/onbld/bin/${MACH}:/opt/SUNWspro/bin:/usr/ccs/bin:/usr/bin:/usr/sbin:/usr/ucb:/usr/etc:/usr/openwin/bin:/usr/sfw/bin:/opt/sfw/bin:."
if [[ "${SUNWSPRO}" != "" ]]; then
fi
if [[ -n "${MAKE}" ]]; then
if [[ -x "${MAKE}" ]]; then
else
print "\$MAKE (${MAKE}) is not a valid executible"
exit 1
fi
fi
TOOLS="${SRC}/tools"
if "${flags.t}" ; then
export ONBLD_TOOLS="${ONBLD_TOOLS:=${TOOLS_PROTO}/opt/onbld}"
export GENOFFSETS="${TOOLS_PROTO}/opt/onbld/bin/genoffsets"
export CTFCONVERT="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfconvert"
export CTFCVTPTBL="${TOOLS_PROTO}/opt/onbld/bin/ctfcvtptbl"
export CTFFINDMOD="${TOOLS_PROTO}/opt/onbld/bin/ctffindmod"
export PATH
fi
DEF_STRIPFLAG="-s"
TMPDIR="/tmp"
export \
unset \
CFLAGS \
# a la ws
printf \
'WARNING: invalid value for MULTI_PROTO (%s); setting to "no".\n' \
export MULTI_PROTO="no"
fi
ENVLDLIBS1="-L$ROOT/lib -L$ROOT/usr/lib"
ENVCPPFLAGS1="-I$ROOT/usr/include"
export \
print "The top-level 'setup' target is available \c"
print "to build headers and tools."
print ""
elif "${flags.t}" ; then
printf \
'The tools can be (re)built with the install target in %s.\n\n' \
"${TOOLS}"
fi
#
# place ourselves in a new task, respecting BUILD_PROJECT if set.
#
# $SHELL is set, and it's not csh.
if "${flags.f}" ; then
print 'WARNING: -f is ignored when $SHELL is not csh'
fi
exec "$SHELL" ${@:+-c "$@"}
elif "${flags.f}" ; then
print 'Using csh -f as shell.'
exec csh -f ${@:+-c "$@"}
else
print 'Using csh as shell.'
exec csh ${@:+-c "$@"}
fi
# not reached