Print this page
4030 remove useless nightly/bldenv options
Reviewed by: Andy Stormont <andyjstormont@gmail.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/tools/scripts/bldenv.sh
+++ new/usr/src/tools/scripts/bldenv.sh
1 1 #!/usr/bin/ksh93
2 2 #
3 3 # CDDL HEADER START
4 4 #
5 5 # The contents of this file are subject to the terms of the
6 6 # Common Development and Distribution License (the "License").
7 7 # You may not use this file except in compliance with the License.
8 8 #
9 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 # or http://www.opensolaris.org/os/licensing.
11 11 # See the License for the specific language governing permissions
12 12 # and limitations under the License.
13 13 #
14 14 # When distributing Covered Code, include this CDDL HEADER in each
15 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 # If applicable, add the following below this CDDL HEADER, with the
17 17 # fields enclosed by brackets "[]" replaced with your own identifying
18 18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 19 #
20 20 # CDDL HEADER END
21 21 #
22 22
23 23 #
24 24 # Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
25 25 # Copyright 2011 Nexenta Systems, Inc. All rights reserved.
26 26 #
27 27 # Uses supplied "env" file, based on /opt/onbld/etc/env, to set shell variables
28 28 # before spawning a shell for doing a release-style builds interactively
29 29 # and incrementally.
30 30 #
31 31
32 32 function fatal_error
33 33 {
34 34 print -u2 "${progname}: $*"
↓ open down ↓ |
34 lines elided |
↑ open up ↑ |
35 35 exit 1
36 36 }
37 37
38 38 function usage
39 39 {
40 40 OPTIND=0
41 41 getopts -a "${progname}" "${USAGE}" OPT '-?'
42 42 exit 2
43 43 }
44 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 45 typeset -r USAGE=$'+
73 46 [-?\n@(#)\$Id: bldenv (OS/Net) 2008-04-06 \$\n]
74 47 [-author?OS/Net community <tools-discuss@opensolaris.org>]
75 48 [+NAME?bldenv - spawn shell for interactive incremental OS-Net
76 49 consolidation builds]
77 50 [+DESCRIPTION?bldenv is a useful companion to the nightly(1) script for
78 51 doing interactive and incremental builds in a workspace
79 52 already built with nightly(1). bldenv spawns a shell set up
80 53 with the same environment variables taken from an env_file,
81 54 as prepared for use with nightly(1).]
82 55 [+?In addition to running a shell for interactive use, bldenv
83 56 can optionally run a single command in the given environment,
84 57 in the vein of sh -c or su -c. This is useful for
85 58 scripting, when an interactive shell would not be. If the
86 59 command is composed of multiple shell words or contains
87 60 other shell metacharacters, it must be quoted appropriately.]
88 61 [+?bldenv is particularly useful for testing Makefile targets
89 62 like clobber, install and _msg, which otherwise require digging
90 63 through large build logs to figure out what is being
91 64 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 65 [+?By default, bldenv will invoke the shell specified in
103 66 $SHELL. If $SHELL is not set or is invalid, csh will be
104 67 used.]
105 68 [c?force the use of csh, regardless of the value of $SHELL.]
106 69 [f?invoke csh with the -f (fast-start) option. This option is valid
107 70 only if $SHELL is unset or if it points to csh.]
108 71 [d?set up environment for doing DEBUG builds (default is non-DEBUG)]
109 72 [t?set up environment to use the tools in usr/src/tools (this is the
110 73 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 74
120 75 <env_file> [command]
121 76
122 77 [+EXAMPLES]{
123 78 [+?Example 1: Interactive use]{
124 79 [+?Use bldenv to spawn a shell to perform a DEBUG build and
125 80 testing of the Makefile targets clobber and install for
126 81 usr/src/cmd/true.]
127 82 [+\n% rlogin wopr-2 -l gk
128 83 {root::wopr-2::49} bldenv -d /export0/jg/on10-se.env
129 84 Build type is DEBUG
130 85 RELEASE is 5.10
131 86 VERSION is wopr-2::on10-se::11/01/2001
132 87 RELEASE_DATE is May 2004
133 88 The top-level `setup\' target is available to build headers
134 89 and tools.
135 90 Using /usr/bin/tcsh as shell.
136 91 {root::wopr-2::49}
137 92 {root::wopr-2::49} cd $SRC/cmd/true
138 93 {root::wopr-2::50} make
139 94 {root::wopr-2::51} make clobber
140 95 /usr/bin/rm -f true true.po
141 96 {root::wopr-2::52} make
142 97 /usr/bin/rm -f true
143 98 cat true.sh > true
144 99 chmod +x true
145 100 {root::wopr-2::53} make install
146 101 install -s -m 0555 -u root -g bin -f /export0/jg/on10-se/proto/root_sparc/usr/bin true
147 102 `install\' is up to date.]
148 103 }
149 104 [+?Example 2: Non-interactive use]{
150 105 [+?Invoke bldenv to create SUNWonbld with a single command:]
151 106 [+\nexample% bldenv onnv_06 \'cd $SRC/tools && make pkg\']
152 107 }
153 108 }
154 109 [+SEE ALSO?\bnightly\b(1)]
155 110 '
156 111
157 112 # main
158 113 builtin basename
159 114
160 115 # boolean flags (true/false)
161 116 typeset flags=(
162 117 typeset c=false
163 118 typeset f=false
164 119 typeset d=false
165 120 typeset O=false
166 121 typeset o=false
167 122 typeset t=true
168 123 typeset s=(
169 124 typeset e=false
170 125 typeset h=false
171 126 typeset d=false
172 127 typeset o=false
173 128 )
174 129 )
175 130
176 131 typeset progname="$(basename -- "${0}")"
177 132
178 133 OPTIND=1
179 134 SUFFIX="-nd"
180 135
↓ open down ↓ |
52 lines elided |
↑ open up ↑ |
181 136 while getopts -a "${progname}" "${USAGE}" OPT ; do
182 137 case ${OPT} in
183 138 c) flags.c=true ;;
184 139 +c) flags.c=false ;;
185 140 f) flags.f=true ;;
186 141 +f) flags.f=false ;;
187 142 d) flags.d=true SUFFIX="" ;;
188 143 +d) flags.d=false SUFFIX="-nd" ;;
189 144 t) flags.t=true ;;
190 145 +t) flags.t=false ;;
191 - S) set_S_flag "$OPTARG" ;;
192 146 \?) usage ;;
193 147 esac
194 148 done
195 149 shift $((OPTIND-1))
196 150
197 151 # test that the path to the environment-setting file was given
198 152 if (( $# < 1 )) ; then
199 153 usage
200 154 fi
201 155
202 156 # force locale to C
203 157 export \
204 158 LC_COLLATE=C \
205 159 LC_CTYPE=C \
206 160 LC_MESSAGES=C \
207 161 LC_MONETARY=C \
208 162 LC_NUMERIC=C \
209 163 LC_TIME=C
210 164
211 165 # clear environment variables we know to be bad for the build
212 166 unset \
213 167 LD_OPTIONS \
214 168 LD_LIBRARY_PATH \
215 169 LD_AUDIT \
216 170 LD_BIND_NOW \
217 171 LD_BREADTH \
218 172 LD_CONFIG \
219 173 LD_DEBUG \
220 174 LD_FLAGS \
221 175 LD_LIBRARY_PATH_64 \
222 176 LD_NOVERSION \
223 177 LD_ORIGIN \
224 178 LD_LOADFLTR \
225 179 LD_NOAUXFLTR \
226 180 LD_NOCONFIG \
227 181 LD_NODIRCONFIG \
228 182 LD_NOOBJALTER \
229 183 LD_PRELOAD \
230 184 LD_PROFILE \
231 185 CONFIG \
232 186 GROUP \
233 187 OWNER \
234 188 REMOTE \
235 189 ENV \
236 190 ARCH \
237 191 CLASSPATH
238 192
239 193 #
240 194 # Setup environment variables
241 195 #
242 196 if [[ -f /etc/nightly.conf ]]; then
243 197 source /etc/nightly.conf
244 198 fi
245 199
246 200 if [[ -f "$1" ]]; then
247 201 if [[ "$1" == */* ]]; then
248 202 source "$1"
249 203 else
250 204 source "./$1"
251 205 fi
252 206 else
253 207 if [[ -f "/opt/onbld/env/$1" ]]; then
254 208 source "/opt/onbld/env/$1"
255 209 else
256 210 printf \
257 211 'Cannot find env file as either %s or /opt/onbld/env/%s\n' \
258 212 "$1" "$1"
259 213 exit 1
260 214 fi
261 215 fi
262 216 shift
263 217
264 218 # contents of stdenv.sh inserted after next line:
265 219 # STDENV_START
↓ open down ↓ |
64 lines elided |
↑ open up ↑ |
266 220 # STDENV_END
267 221
268 222 # Check if we have sufficient data to continue...
269 223 [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
270 224 [[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory."
271 225 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
272 226
273 227 # must match the getopts in nightly.sh
274 228 OPTIND=1
275 229 NIGHTLY_OPTIONS="-${NIGHTLY_OPTIONS#-}"
276 -while getopts '+0AaBCDdFfGIilMmNnOopRrS:tUuWwXxz' FLAG "$NIGHTLY_OPTIONS"
230 +while getopts '+0AaBCDdFfGIilMmNnopRrtUuWwXxz' FLAG "$NIGHTLY_OPTIONS"
277 231 do
278 232 case "$FLAG" in
279 - O) flags.O=true ;;
280 - +O) flags.O=false ;;
281 233 o) flags.o=true ;;
282 234 +o) flags.o=false ;;
283 235 t) flags.t=true ;;
284 236 +t) flags.t=false ;;
285 - S) set_S_flag "$OPTARG" ;;
286 237 *) ;;
287 238 esac
288 239 done
289 240
290 241 POUND_SIGN="#"
291 242 # have we set RELEASE_DATE in our env file?
292 243 if [ -z "$RELEASE_DATE" ]; then
293 244 RELEASE_DATE=$(LC_ALL=C date +"%B %Y")
294 245 fi
295 246 BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d)
296 247 BASEWSDIR=$(basename -- "${CODEMGR_WS}")
297 248 DEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\""
298 249 export DEV_CM RELEASE_DATE POUND_SIGN
299 250
300 251 export INTERNAL_RELEASE_BUILD=
301 252
302 253 print 'Build type is \c'
303 254 if ${flags.d} ; then
304 255 print 'DEBUG'
305 256 unset RELEASE_BUILD
↓ open down ↓ |
10 lines elided |
↑ open up ↑ |
306 257 unset EXTRA_OPTIONS
307 258 unset EXTRA_CFLAGS
308 259 else
309 260 # default is a non-DEBUG build
310 261 print 'non-DEBUG'
311 262 export RELEASE_BUILD=
312 263 unset EXTRA_OPTIONS
313 264 unset EXTRA_CFLAGS
314 265 fi
315 266
316 -[[ "${flags.O}" == "true" ]] && export MULTI_PROTO="yes"
317 -
318 267 # update build-type variables
319 268 PKGARCHIVE="${PKGARCHIVE}${SUFFIX}"
320 269
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 270 # Set PATH for a build
343 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:."
344 272 if [[ "${SUNWSPRO}" != "" ]]; then
345 273 export PATH="${SUNWSPRO}/bin:$PATH"
346 274 fi
347 275
348 276 TOOLS="${SRC}/tools"
349 277 TOOLS_PROTO="${TOOLS}/proto/root_${MACH}-nd" ; export TOOLS_PROTO
350 278
351 279 if "${flags.t}" ; then
352 280 export ONBLD_TOOLS="${ONBLD_TOOLS:=${TOOLS_PROTO}/opt/onbld}"
353 281
354 282 export STABS="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/stabs"
355 283 export CTFSTABS="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfstabs"
356 284 export GENOFFSETS="${TOOLS_PROTO}/opt/onbld/bin/genoffsets"
357 285
358 286 export CTFCONVERT="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfconvert"
359 287 export CTFMERGE="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfmerge"
360 288
361 289 export CTFCVTPTBL="${TOOLS_PROTO}/opt/onbld/bin/ctfcvtptbl"
362 290 export CTFFINDMOD="${TOOLS_PROTO}/opt/onbld/bin/ctffindmod"
363 291
364 292 PATH="${TOOLS_PROTO}/opt/onbld/bin/${MACH}:${PATH}"
365 293 PATH="${TOOLS_PROTO}/opt/onbld/bin:${PATH}"
366 294 export PATH
367 295 fi
368 296
369 297 export DMAKE_MODE=${DMAKE_MODE:-parallel}
370 298
371 299 if "${flags.o}" ; then
372 300 export CH=
373 301 else
374 302 unset CH
375 303 fi
376 304 DEF_STRIPFLAG="-s"
377 305
378 306 TMPDIR="/tmp"
379 307
380 308 # "o_FLAG" is used by "nightly.sh" (it may be useful to rename this
381 309 # variable using a more descriptive name later)
382 310 export o_FLAG="$(${flags.o} && print 'y' || print 'n')"
383 311
384 312 export \
385 313 PATH TMPDIR \
386 314 POUND_SIGN \
387 315 DEF_STRIPFLAG \
388 316 RELEASE_DATE
389 317 unset \
390 318 CFLAGS \
391 319 LD_LIBRARY_PATH
392 320
393 321 # a la ws
394 322 ENVLDLIBS1=
395 323 ENVLDLIBS2=
396 324 ENVLDLIBS3=
397 325 ENVCPPFLAGS1=
398 326 ENVCPPFLAGS2=
399 327 ENVCPPFLAGS3=
400 328 ENVCPPFLAGS4=
401 329 PARENT_ROOT=
402 330 PARENT_TOOLS_ROOT=
↓ open down ↓ |
51 lines elided |
↑ open up ↑ |
403 331
404 332 if [[ "$MULTI_PROTO" != "yes" && "$MULTI_PROTO" != "no" ]]; then
405 333 printf \
406 334 'WARNING: invalid value for MULTI_PROTO (%s); setting to "no".\n' \
407 335 "$MULTI_PROTO"
408 336 export MULTI_PROTO="no"
409 337 fi
410 338
411 339 [[ "$MULTI_PROTO" == "yes" ]] && export ROOT="${ROOT}${SUFFIX}"
412 340
413 -if "${flags.O}" ; then
414 - print "OpenSolaris closed binary generation requires "
415 - print "closed tree"
416 - exit 1
417 -fi
418 -
419 341 ENVLDLIBS1="-L$ROOT/lib -L$ROOT/usr/lib"
420 342 ENVCPPFLAGS1="-I$ROOT/usr/include"
421 343 MAKEFLAGS=e
422 344
423 345 export \
424 346 ENVLDLIBS1 \
425 347 ENVLDLIBS2 \
426 348 ENVLDLIBS3 \
427 349 ENVCPPFLAGS1 \
428 350 ENVCPPFLAGS2 \
429 351 ENVCPPFLAGS3 \
430 352 ENVCPPFLAGS4 \
431 353 MAKEFLAGS \
432 354 PARENT_ROOT \
433 355 PARENT_TOOLS_ROOT
434 356
435 357 printf 'RELEASE is %s\n' "$RELEASE"
436 358 printf 'VERSION is %s\n' "$VERSION"
437 359 printf 'RELEASE_DATE is %s\n\n' "$RELEASE_DATE"
438 360
439 361 if [[ -f "$SRC/Makefile" ]] && egrep -s '^setup:' "$SRC/Makefile" ; then
440 362 print "The top-level 'setup' target is available \c"
441 363 print "to build headers and tools."
442 364 print ""
443 365
444 366 elif "${flags.t}" ; then
445 367 printf \
446 368 'The tools can be (re)built with the install target in %s.\n\n' \
447 369 "${TOOLS}"
448 370 fi
449 371
450 372 #
451 373 # place ourselves in a new task, respecting BUILD_PROJECT if set.
452 374 #
453 375 /usr/bin/newtask -c $$ ${BUILD_PROJECT:+-p$BUILD_PROJECT}
454 376
455 377 if [[ "${flags.c}" == "false" && -x "$SHELL" && \
456 378 "$(basename -- "${SHELL}")" != "csh" ]]; then
457 379 # $SHELL is set, and it's not csh.
458 380
459 381 if "${flags.f}" ; then
460 382 print 'WARNING: -f is ignored when $SHELL is not csh'
461 383 fi
462 384
463 385 printf 'Using %s as shell.\n' "$SHELL"
464 386 exec "$SHELL" ${@:+-c "$@"}
465 387
466 388 elif "${flags.f}" ; then
467 389 print 'Using csh -f as shell.'
468 390 exec csh -f ${@:+-c "$@"}
469 391
470 392 else
471 393 print 'Using csh as shell.'
472 394 exec csh ${@:+-c "$@"}
473 395 fi
474 396
475 397 # not reached
↓ open down ↓ |
47 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX