25 # Copyright 2011 Nexenta Systems, Inc. All rights reserved.
26 #
27 # Uses supplied "env" file, based on /opt/onbld/etc/env, to set shell variables
28 # before spawning a shell for doing a release-style builds interactively
29 # and incrementally.
30 #
31
32 function fatal_error
33 {
34 print -u2 "${progname}: $*"
35 exit 1
36 }
37
38 function usage
39 {
40 OPTIND=0
41 getopts -a "${progname}" "${USAGE}" OPT '-?'
42 exit 2
43 }
44
45 function is_source_build
46 {
47 "${flags.s.e}" || "${flags.s.d}" || "${flags.s.h}" || "${flags.s.o}"
48 return $?
49 }
50
51 #
52 # single function for setting -S flag and doing error checking.
53 # usage: set_S_flag <type>
54 # where <type> is the source build type ("E", "D", ...).
55 #
56 function set_S_flag
57 {
58 if is_source_build; then
59 print 'Can only build one source variant at a time.'
60 exit 1
61 fi
62
63 case "$1" in
64 "E") flags.s.e=true ;;
65 "D") flags.s.d=true ;;
66 "H") flags.s.h=true ;;
67 "O") flags.s.o=true ;;
68 *) usage ;;
69 esac
70 }
71
72 typeset -r USAGE=$'+
73 [-?\n@(#)\$Id: bldenv (OS/Net) 2008-04-06 \$\n]
74 [-author?OS/Net community <tools-discuss@opensolaris.org>]
75 [+NAME?bldenv - spawn shell for interactive incremental OS-Net
76 consolidation builds]
77 [+DESCRIPTION?bldenv is a useful companion to the nightly(1) script for
78 doing interactive and incremental builds in a workspace
79 already built with nightly(1). bldenv spawns a shell set up
80 with the same environment variables taken from an env_file,
81 as prepared for use with nightly(1).]
82 [+?In addition to running a shell for interactive use, bldenv
83 can optionally run a single command in the given environment,
84 in the vein of sh -c or su -c. This is useful for
85 scripting, when an interactive shell would not be. If the
86 command is composed of multiple shell words or contains
87 other shell metacharacters, it must be quoted appropriately.]
88 [+?bldenv is particularly useful for testing Makefile targets
89 like clobber, install and _msg, which otherwise require digging
90 through large build logs to figure out what is being
91 done.]
92 [+?bldenv is also useful if you run into build issues with the
93 source product or when generating OpenSolaris deliverables.
94 If a source product build is flagged, the environment is set
95 up for building the indicated source product tree, which is
96 assumed to have already been created. If the OpenSolaris
97 deliverables flag (-O) is set in NIGHTLY_OPTIONS, the
98 environment is set up for building just the open source.
99 This includes using an alternate proto area, as well as
100 using the closed binaries in $CODEMGR_WS/closed.skel (which
101 is assumed to already exist).]
102 [+?By default, bldenv will invoke the shell specified in
103 $SHELL. If $SHELL is not set or is invalid, csh will be
104 used.]
105 [c?force the use of csh, regardless of the value of $SHELL.]
106 [f?invoke csh with the -f (fast-start) option. This option is valid
107 only if $SHELL is unset or if it points to csh.]
108 [d?set up environment for doing DEBUG builds (default is non-DEBUG)]
109 [t?set up environment to use the tools in usr/src/tools (this is the
110 default, use +t to use the tools from /opt/onbld)]
111 [S]:[option?Build a variant of the source product.
112 The value of \aoption\a must be one of the following:]{
113 [+E?build the exportable source variant of the source product.]
114 [+D?build the domestic source (exportable + crypt) variant of
115 the source product.]
116 [+H?build hybrid source (binaries + deleted source).]
117 [+O?simulate an OpenSolaris (open source only) build.]
118 }
119
120 <env_file> [command]
121
122 [+EXAMPLES]{
123 [+?Example 1: Interactive use]{
124 [+?Use bldenv to spawn a shell to perform a DEBUG build and
125 testing of the Makefile targets clobber and install for
126 usr/src/cmd/true.]
127 [+\n% rlogin wopr-2 -l gk
128 {root::wopr-2::49} bldenv -d /export0/jg/on10-se.env
129 Build type is DEBUG
130 RELEASE is 5.10
131 VERSION is wopr-2::on10-se::11/01/2001
132 RELEASE_DATE is May 2004
133 The top-level `setup\' target is available to build headers
134 and tools.
135 Using /usr/bin/tcsh as shell.
136 {root::wopr-2::49}
137 {root::wopr-2::49} cd $SRC/cmd/true
138 {root::wopr-2::50} make
171 typeset d=false
172 typeset o=false
173 )
174 )
175
176 typeset progname="$(basename -- "${0}")"
177
178 OPTIND=1
179 SUFFIX="-nd"
180
181 while getopts -a "${progname}" "${USAGE}" OPT ; do
182 case ${OPT} in
183 c) flags.c=true ;;
184 +c) flags.c=false ;;
185 f) flags.f=true ;;
186 +f) flags.f=false ;;
187 d) flags.d=true SUFFIX="" ;;
188 +d) flags.d=false SUFFIX="-nd" ;;
189 t) flags.t=true ;;
190 +t) flags.t=false ;;
191 S) set_S_flag "$OPTARG" ;;
192 \?) usage ;;
193 esac
194 done
195 shift $((OPTIND-1))
196
197 # test that the path to the environment-setting file was given
198 if (( $# < 1 )) ; then
199 usage
200 fi
201
202 # force locale to C
203 export \
204 LC_COLLATE=C \
205 LC_CTYPE=C \
206 LC_MESSAGES=C \
207 LC_MONETARY=C \
208 LC_NUMERIC=C \
209 LC_TIME=C
210
211 # clear environment variables we know to be bad for the build
256 printf \
257 'Cannot find env file as either %s or /opt/onbld/env/%s\n' \
258 "$1" "$1"
259 exit 1
260 fi
261 fi
262 shift
263
264 # contents of stdenv.sh inserted after next line:
265 # STDENV_START
266 # STDENV_END
267
268 # Check if we have sufficient data to continue...
269 [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
270 [[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory."
271 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
272
273 # must match the getopts in nightly.sh
274 OPTIND=1
275 NIGHTLY_OPTIONS="-${NIGHTLY_OPTIONS#-}"
276 while getopts '+0AaBCDdFfGIilMmNnOopRrS:tUuWwXxz' FLAG "$NIGHTLY_OPTIONS"
277 do
278 case "$FLAG" in
279 O) flags.O=true ;;
280 +O) flags.O=false ;;
281 o) flags.o=true ;;
282 +o) flags.o=false ;;
283 t) flags.t=true ;;
284 +t) flags.t=false ;;
285 S) set_S_flag "$OPTARG" ;;
286 *) ;;
287 esac
288 done
289
290 POUND_SIGN="#"
291 # have we set RELEASE_DATE in our env file?
292 if [ -z "$RELEASE_DATE" ]; then
293 RELEASE_DATE=$(LC_ALL=C date +"%B %Y")
294 fi
295 BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d)
296 BASEWSDIR=$(basename -- "${CODEMGR_WS}")
297 DEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\""
298 export DEV_CM RELEASE_DATE POUND_SIGN
299
300 export INTERNAL_RELEASE_BUILD=
301
302 print 'Build type is \c'
303 if ${flags.d} ; then
304 print 'DEBUG'
305 unset RELEASE_BUILD
306 unset EXTRA_OPTIONS
307 unset EXTRA_CFLAGS
308 else
309 # default is a non-DEBUG build
310 print 'non-DEBUG'
311 export RELEASE_BUILD=
312 unset EXTRA_OPTIONS
313 unset EXTRA_CFLAGS
314 fi
315
316 [[ "${flags.O}" == "true" ]] && export MULTI_PROTO="yes"
317
318 # update build-type variables
319 PKGARCHIVE="${PKGARCHIVE}${SUFFIX}"
320
321 # Append source version
322 if "${flags.s.e}" ; then
323 VERSION+=":EXPORT"
324 SRC="${EXPORT_SRC}/usr/src"
325 fi
326
327 if "${flags.s.d}" ; then
328 VERSION+=":DOMESTIC"
329 SRC="${EXPORT_SRC}/usr/src"
330 fi
331
332 if "${flags.s.h}" ; then
333 VERSION+=":HYBRID"
334 SRC="${EXPORT_SRC}/usr/src"
335 fi
336
337 if "${flags.s.o}" ; then
338 VERSION+=":OPEN_ONLY"
339 SRC="${OPEN_SRCDIR}/usr/src"
340 fi
341
342 # Set PATH for a build
343 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:."
344 if [[ "${SUNWSPRO}" != "" ]]; then
345 export PATH="${SUNWSPRO}/bin:$PATH"
346 fi
347
348 TOOLS="${SRC}/tools"
349 TOOLS_PROTO="${TOOLS}/proto/root_${MACH}-nd" ; export TOOLS_PROTO
350
351 if "${flags.t}" ; then
352 export ONBLD_TOOLS="${ONBLD_TOOLS:=${TOOLS_PROTO}/opt/onbld}"
353
354 export STABS="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/stabs"
355 export CTFSTABS="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfstabs"
356 export GENOFFSETS="${TOOLS_PROTO}/opt/onbld/bin/genoffsets"
357
358 export CTFCONVERT="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfconvert"
359 export CTFMERGE="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfmerge"
360
361 export CTFCVTPTBL="${TOOLS_PROTO}/opt/onbld/bin/ctfcvtptbl"
393 # a la ws
394 ENVLDLIBS1=
395 ENVLDLIBS2=
396 ENVLDLIBS3=
397 ENVCPPFLAGS1=
398 ENVCPPFLAGS2=
399 ENVCPPFLAGS3=
400 ENVCPPFLAGS4=
401 PARENT_ROOT=
402 PARENT_TOOLS_ROOT=
403
404 if [[ "$MULTI_PROTO" != "yes" && "$MULTI_PROTO" != "no" ]]; then
405 printf \
406 'WARNING: invalid value for MULTI_PROTO (%s); setting to "no".\n' \
407 "$MULTI_PROTO"
408 export MULTI_PROTO="no"
409 fi
410
411 [[ "$MULTI_PROTO" == "yes" ]] && export ROOT="${ROOT}${SUFFIX}"
412
413 if "${flags.O}" ; then
414 print "OpenSolaris closed binary generation requires "
415 print "closed tree"
416 exit 1
417 fi
418
419 ENVLDLIBS1="-L$ROOT/lib -L$ROOT/usr/lib"
420 ENVCPPFLAGS1="-I$ROOT/usr/include"
421 MAKEFLAGS=e
422
423 export \
424 ENVLDLIBS1 \
425 ENVLDLIBS2 \
426 ENVLDLIBS3 \
427 ENVCPPFLAGS1 \
428 ENVCPPFLAGS2 \
429 ENVCPPFLAGS3 \
430 ENVCPPFLAGS4 \
431 MAKEFLAGS \
432 PARENT_ROOT \
433 PARENT_TOOLS_ROOT
434
435 printf 'RELEASE is %s\n' "$RELEASE"
436 printf 'VERSION is %s\n' "$VERSION"
437 printf 'RELEASE_DATE is %s\n\n' "$RELEASE_DATE"
438
|
25 # Copyright 2011 Nexenta Systems, Inc. All rights reserved.
26 #
27 # Uses supplied "env" file, based on /opt/onbld/etc/env, to set shell variables
28 # before spawning a shell for doing a release-style builds interactively
29 # and incrementally.
30 #
31
32 function fatal_error
33 {
34 print -u2 "${progname}: $*"
35 exit 1
36 }
37
38 function usage
39 {
40 OPTIND=0
41 getopts -a "${progname}" "${USAGE}" OPT '-?'
42 exit 2
43 }
44
45 typeset -r USAGE=$'+
46 [-?\n@(#)\$Id: bldenv (OS/Net) 2008-04-06 \$\n]
47 [-author?OS/Net community <tools-discuss@opensolaris.org>]
48 [+NAME?bldenv - spawn shell for interactive incremental OS-Net
49 consolidation builds]
50 [+DESCRIPTION?bldenv is a useful companion to the nightly(1) script for
51 doing interactive and incremental builds in a workspace
52 already built with nightly(1). bldenv spawns a shell set up
53 with the same environment variables taken from an env_file,
54 as prepared for use with nightly(1).]
55 [+?In addition to running a shell for interactive use, bldenv
56 can optionally run a single command in the given environment,
57 in the vein of sh -c or su -c. This is useful for
58 scripting, when an interactive shell would not be. If the
59 command is composed of multiple shell words or contains
60 other shell metacharacters, it must be quoted appropriately.]
61 [+?bldenv is particularly useful for testing Makefile targets
62 like clobber, install and _msg, which otherwise require digging
63 through large build logs to figure out what is being
64 done.]
65 [+?By default, bldenv will invoke the shell specified in
66 $SHELL. If $SHELL is not set or is invalid, csh will be
67 used.]
68 [c?force the use of csh, regardless of the value of $SHELL.]
69 [f?invoke csh with the -f (fast-start) option. This option is valid
70 only if $SHELL is unset or if it points to csh.]
71 [d?set up environment for doing DEBUG builds (default is non-DEBUG)]
72 [t?set up environment to use the tools in usr/src/tools (this is the
73 default, use +t to use the tools from /opt/onbld)]
74
75 <env_file> [command]
76
77 [+EXAMPLES]{
78 [+?Example 1: Interactive use]{
79 [+?Use bldenv to spawn a shell to perform a DEBUG build and
80 testing of the Makefile targets clobber and install for
81 usr/src/cmd/true.]
82 [+\n% rlogin wopr-2 -l gk
83 {root::wopr-2::49} bldenv -d /export0/jg/on10-se.env
84 Build type is DEBUG
85 RELEASE is 5.10
86 VERSION is wopr-2::on10-se::11/01/2001
87 RELEASE_DATE is May 2004
88 The top-level `setup\' target is available to build headers
89 and tools.
90 Using /usr/bin/tcsh as shell.
91 {root::wopr-2::49}
92 {root::wopr-2::49} cd $SRC/cmd/true
93 {root::wopr-2::50} make
126 typeset d=false
127 typeset o=false
128 )
129 )
130
131 typeset progname="$(basename -- "${0}")"
132
133 OPTIND=1
134 SUFFIX="-nd"
135
136 while getopts -a "${progname}" "${USAGE}" OPT ; do
137 case ${OPT} in
138 c) flags.c=true ;;
139 +c) flags.c=false ;;
140 f) flags.f=true ;;
141 +f) flags.f=false ;;
142 d) flags.d=true SUFFIX="" ;;
143 +d) flags.d=false SUFFIX="-nd" ;;
144 t) flags.t=true ;;
145 +t) flags.t=false ;;
146 \?) usage ;;
147 esac
148 done
149 shift $((OPTIND-1))
150
151 # test that the path to the environment-setting file was given
152 if (( $# < 1 )) ; then
153 usage
154 fi
155
156 # force locale to C
157 export \
158 LC_COLLATE=C \
159 LC_CTYPE=C \
160 LC_MESSAGES=C \
161 LC_MONETARY=C \
162 LC_NUMERIC=C \
163 LC_TIME=C
164
165 # clear environment variables we know to be bad for the build
210 printf \
211 'Cannot find env file as either %s or /opt/onbld/env/%s\n' \
212 "$1" "$1"
213 exit 1
214 fi
215 fi
216 shift
217
218 # contents of stdenv.sh inserted after next line:
219 # STDENV_START
220 # STDENV_END
221
222 # Check if we have sufficient data to continue...
223 [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
224 [[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory."
225 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
226
227 # must match the getopts in nightly.sh
228 OPTIND=1
229 NIGHTLY_OPTIONS="-${NIGHTLY_OPTIONS#-}"
230 while getopts '+0AaBCDdFfGIilMmNnopRrtUuWwXxz' FLAG "$NIGHTLY_OPTIONS"
231 do
232 case "$FLAG" in
233 o) flags.o=true ;;
234 +o) flags.o=false ;;
235 t) flags.t=true ;;
236 +t) flags.t=false ;;
237 *) ;;
238 esac
239 done
240
241 POUND_SIGN="#"
242 # have we set RELEASE_DATE in our env file?
243 if [ -z "$RELEASE_DATE" ]; then
244 RELEASE_DATE=$(LC_ALL=C date +"%B %Y")
245 fi
246 BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d)
247 BASEWSDIR=$(basename -- "${CODEMGR_WS}")
248 DEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\""
249 export DEV_CM RELEASE_DATE POUND_SIGN
250
251 export INTERNAL_RELEASE_BUILD=
252
253 print 'Build type is \c'
254 if ${flags.d} ; then
255 print 'DEBUG'
256 unset RELEASE_BUILD
257 unset EXTRA_OPTIONS
258 unset EXTRA_CFLAGS
259 else
260 # default is a non-DEBUG build
261 print 'non-DEBUG'
262 export RELEASE_BUILD=
263 unset EXTRA_OPTIONS
264 unset EXTRA_CFLAGS
265 fi
266
267 # update build-type variables
268 PKGARCHIVE="${PKGARCHIVE}${SUFFIX}"
269
270 # Set PATH for a build
271 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:."
272 if [[ "${SUNWSPRO}" != "" ]]; then
273 export PATH="${SUNWSPRO}/bin:$PATH"
274 fi
275
276 TOOLS="${SRC}/tools"
277 TOOLS_PROTO="${TOOLS}/proto/root_${MACH}-nd" ; export TOOLS_PROTO
278
279 if "${flags.t}" ; then
280 export ONBLD_TOOLS="${ONBLD_TOOLS:=${TOOLS_PROTO}/opt/onbld}"
281
282 export STABS="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/stabs"
283 export CTFSTABS="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfstabs"
284 export GENOFFSETS="${TOOLS_PROTO}/opt/onbld/bin/genoffsets"
285
286 export CTFCONVERT="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfconvert"
287 export CTFMERGE="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfmerge"
288
289 export CTFCVTPTBL="${TOOLS_PROTO}/opt/onbld/bin/ctfcvtptbl"
321 # a la ws
322 ENVLDLIBS1=
323 ENVLDLIBS2=
324 ENVLDLIBS3=
325 ENVCPPFLAGS1=
326 ENVCPPFLAGS2=
327 ENVCPPFLAGS3=
328 ENVCPPFLAGS4=
329 PARENT_ROOT=
330 PARENT_TOOLS_ROOT=
331
332 if [[ "$MULTI_PROTO" != "yes" && "$MULTI_PROTO" != "no" ]]; then
333 printf \
334 'WARNING: invalid value for MULTI_PROTO (%s); setting to "no".\n' \
335 "$MULTI_PROTO"
336 export MULTI_PROTO="no"
337 fi
338
339 [[ "$MULTI_PROTO" == "yes" ]] && export ROOT="${ROOT}${SUFFIX}"
340
341 ENVLDLIBS1="-L$ROOT/lib -L$ROOT/usr/lib"
342 ENVCPPFLAGS1="-I$ROOT/usr/include"
343 MAKEFLAGS=e
344
345 export \
346 ENVLDLIBS1 \
347 ENVLDLIBS2 \
348 ENVLDLIBS3 \
349 ENVCPPFLAGS1 \
350 ENVCPPFLAGS2 \
351 ENVCPPFLAGS3 \
352 ENVCPPFLAGS4 \
353 MAKEFLAGS \
354 PARENT_ROOT \
355 PARENT_TOOLS_ROOT
356
357 printf 'RELEASE is %s\n' "$RELEASE"
358 printf 'VERSION is %s\n' "$VERSION"
359 printf 'RELEASE_DATE is %s\n\n' "$RELEASE_DATE"
360
|