Print this page
4526 nightly contains a great deal of effectively dead code
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}: $*"
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 45 typeset -r USAGE=$'+
46 46 [-?\n@(#)\$Id: bldenv (OS/Net) 2008-04-06 \$\n]
47 47 [-author?OS/Net community <tools-discuss@opensolaris.org>]
48 48 [+NAME?bldenv - spawn shell for interactive incremental OS-Net
49 49 consolidation builds]
50 50 [+DESCRIPTION?bldenv is a useful companion to the nightly(1) script for
51 51 doing interactive and incremental builds in a workspace
52 52 already built with nightly(1). bldenv spawns a shell set up
53 53 with the same environment variables taken from an env_file,
54 54 as prepared for use with nightly(1).]
55 55 [+?In addition to running a shell for interactive use, bldenv
56 56 can optionally run a single command in the given environment,
57 57 in the vein of sh -c or su -c. This is useful for
58 58 scripting, when an interactive shell would not be. If the
59 59 command is composed of multiple shell words or contains
60 60 other shell metacharacters, it must be quoted appropriately.]
61 61 [+?bldenv is particularly useful for testing Makefile targets
62 62 like clobber, install and _msg, which otherwise require digging
63 63 through large build logs to figure out what is being
64 64 done.]
65 65 [+?By default, bldenv will invoke the shell specified in
66 66 $SHELL. If $SHELL is not set or is invalid, csh will be
67 67 used.]
68 68 [c?force the use of csh, regardless of the value of $SHELL.]
69 69 [f?invoke csh with the -f (fast-start) option. This option is valid
70 70 only if $SHELL is unset or if it points to csh.]
71 71 [d?set up environment for doing DEBUG builds (default is non-DEBUG)]
72 72 [t?set up environment to use the tools in usr/src/tools (this is the
73 73 default, use +t to use the tools from /opt/onbld)]
74 74
75 75 <env_file> [command]
76 76
77 77 [+EXAMPLES]{
78 78 [+?Example 1: Interactive use]{
79 79 [+?Use bldenv to spawn a shell to perform a DEBUG build and
80 80 testing of the Makefile targets clobber and install for
81 81 usr/src/cmd/true.]
82 82 [+\n% rlogin wopr-2 -l gk
83 83 {root::wopr-2::49} bldenv -d /export0/jg/on10-se.env
84 84 Build type is DEBUG
85 85 RELEASE is 5.10
86 86 VERSION is wopr-2::on10-se::11/01/2001
87 87 RELEASE_DATE is May 2004
88 88 The top-level `setup\' target is available to build headers
89 89 and tools.
90 90 Using /usr/bin/tcsh as shell.
91 91 {root::wopr-2::49}
92 92 {root::wopr-2::49} cd $SRC/cmd/true
93 93 {root::wopr-2::50} make
94 94 {root::wopr-2::51} make clobber
95 95 /usr/bin/rm -f true true.po
96 96 {root::wopr-2::52} make
97 97 /usr/bin/rm -f true
98 98 cat true.sh > true
99 99 chmod +x true
100 100 {root::wopr-2::53} make install
101 101 install -s -m 0555 -u root -g bin -f /export0/jg/on10-se/proto/root_sparc/usr/bin true
102 102 `install\' is up to date.]
103 103 }
104 104 [+?Example 2: Non-interactive use]{
105 105 [+?Invoke bldenv to create SUNWonbld with a single command:]
106 106 [+\nexample% bldenv onnv_06 \'cd $SRC/tools && make pkg\']
107 107 }
108 108 }
109 109 [+SEE ALSO?\bnightly\b(1)]
110 110 '
111 111
112 112 # main
113 113 builtin basename
114 114
115 115 # boolean flags (true/false)
116 116 typeset flags=(
117 117 typeset c=false
118 118 typeset f=false
119 119 typeset d=false
120 120 typeset O=false
121 121 typeset o=false
122 122 typeset t=true
123 123 typeset s=(
124 124 typeset e=false
125 125 typeset h=false
126 126 typeset d=false
127 127 typeset o=false
128 128 )
129 129 )
130 130
131 131 typeset progname="$(basename -- "${0}")"
132 132
133 133 OPTIND=1
134 134 SUFFIX="-nd"
135 135
136 136 while getopts -a "${progname}" "${USAGE}" OPT ; do
137 137 case ${OPT} in
138 138 c) flags.c=true ;;
139 139 +c) flags.c=false ;;
140 140 f) flags.f=true ;;
141 141 +f) flags.f=false ;;
142 142 d) flags.d=true SUFFIX="" ;;
143 143 +d) flags.d=false SUFFIX="-nd" ;;
144 144 t) flags.t=true ;;
145 145 +t) flags.t=false ;;
146 146 \?) usage ;;
147 147 esac
148 148 done
149 149 shift $((OPTIND-1))
150 150
151 151 # test that the path to the environment-setting file was given
152 152 if (( $# < 1 )) ; then
153 153 usage
154 154 fi
155 155
156 156 # force locale to C
↓ open down ↓ |
156 lines elided |
↑ open up ↑ |
157 157 export \
158 158 LC_COLLATE=C \
159 159 LC_CTYPE=C \
160 160 LC_MESSAGES=C \
161 161 LC_MONETARY=C \
162 162 LC_NUMERIC=C \
163 163 LC_TIME=C
164 164
165 165 # clear environment variables we know to be bad for the build
166 166 unset \
167 + CH \
167 168 LD_OPTIONS \
168 - LD_LIBRARY_PATH \
169 - LD_AUDIT \
170 - LD_BIND_NOW \
171 - LD_BREADTH \
172 - LD_CONFIG \
169 + LD_LIBRARY_PATH \
170 + LD_AUDIT \
171 + LD_BIND_NOW \
172 + LD_BREADTH \
173 + LD_CONFIG \
173 174 LD_DEBUG \
174 - LD_FLAGS \
175 - LD_LIBRARY_PATH_64 \
176 - LD_NOVERSION \
177 - LD_ORIGIN \
175 + LD_FLAGS \
176 + LD_LIBRARY_PATH_64 \
177 + LD_NOVERSION \
178 + LD_ORIGIN \
178 179 LD_LOADFLTR \
179 - LD_NOAUXFLTR \
180 - LD_NOCONFIG \
181 - LD_NODIRCONFIG \
182 - LD_NOOBJALTER \
180 + LD_NOAUXFLTR \
181 + LD_NOCONFIG \
182 + LD_NODIRCONFIG \
183 + LD_NOOBJALTER \
183 184 LD_PRELOAD \
184 - LD_PROFILE \
185 + LD_PROFILE \
185 186 CONFIG \
186 187 GROUP \
187 188 OWNER \
188 189 REMOTE \
189 190 ENV \
190 191 ARCH \
191 192 CLASSPATH
192 193
193 194 #
194 195 # Setup environment variables
195 196 #
196 197 if [[ -f /etc/nightly.conf ]]; then
197 198 source /etc/nightly.conf
198 199 fi
199 200
200 201 if [[ -f "$1" ]]; then
201 202 if [[ "$1" == */* ]]; then
202 203 source "$1"
203 204 else
204 205 source "./$1"
205 206 fi
206 207 else
207 208 if [[ -f "/opt/onbld/env/$1" ]]; then
208 209 source "/opt/onbld/env/$1"
209 210 else
210 211 printf \
211 212 'Cannot find env file as either %s or /opt/onbld/env/%s\n' \
212 213 "$1" "$1"
213 214 exit 1
214 215 fi
215 216 fi
216 217 shift
217 218
218 219 # contents of stdenv.sh inserted after next line:
219 220 # STDENV_START
↓ open down ↓ |
25 lines elided |
↑ open up ↑ |
220 221 # STDENV_END
221 222
222 223 # Check if we have sufficient data to continue...
223 224 [[ -v CODEMGR_WS ]] || fatal_error "Error: Variable CODEMGR_WS not set."
224 225 [[ -d "${CODEMGR_WS}" ]] || fatal_error "Error: ${CODEMGR_WS} is not a directory."
225 226 [[ -f "${CODEMGR_WS}/usr/src/Makefile" ]] || fatal_error "Error: ${CODEMGR_WS}/usr/src/Makefile not found."
226 227
227 228 # must match the getopts in nightly.sh
228 229 OPTIND=1
229 230 NIGHTLY_OPTIONS="-${NIGHTLY_OPTIONS#-}"
230 -while getopts '+0AaBCDdFfGIilMmNnopRrtUuWwXxz' FLAG "$NIGHTLY_OPTIONS"
231 +while getopts '+0ABCDdFfGIilMmNnpRrtUuw' FLAG "$NIGHTLY_OPTIONS"
231 232 do
232 233 case "$FLAG" in
233 - o) flags.o=true ;;
234 - +o) flags.o=false ;;
235 234 t) flags.t=true ;;
236 235 +t) flags.t=false ;;
237 236 *) ;;
238 237 esac
239 238 done
240 239
241 240 POUND_SIGN="#"
242 241 # have we set RELEASE_DATE in our env file?
243 242 if [ -z "$RELEASE_DATE" ]; then
244 243 RELEASE_DATE=$(LC_ALL=C date +"%B %Y")
245 244 fi
246 245 BUILD_DATE=$(LC_ALL=C date +%Y-%b-%d)
247 246 BASEWSDIR=$(basename -- "${CODEMGR_WS}")
248 247 DEV_CM="\"@(#)SunOS Internal Development: $LOGNAME $BUILD_DATE [$BASEWSDIR]\""
249 248 export DEV_CM RELEASE_DATE POUND_SIGN
250 249
251 250 print 'Build type is \c'
252 251 if ${flags.d} ; then
253 252 print 'DEBUG'
254 253 unset RELEASE_BUILD
255 254 unset EXTRA_OPTIONS
256 255 unset EXTRA_CFLAGS
257 256 else
258 257 # default is a non-DEBUG build
259 258 print 'non-DEBUG'
260 259 export RELEASE_BUILD=
261 260 unset EXTRA_OPTIONS
262 261 unset EXTRA_CFLAGS
263 262 fi
264 263
265 264 # update build-type variables
266 265 PKGARCHIVE="${PKGARCHIVE}${SUFFIX}"
267 266
268 267 # Set PATH for a build
269 268 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:."
270 269 if [[ "${SUNWSPRO}" != "" ]]; then
271 270 export PATH="${SUNWSPRO}/bin:$PATH"
272 271 fi
273 272
274 273 if [[ -n "${MAKE}" ]]; then
275 274 if [[ -x "${MAKE}" ]]; then
276 275 export PATH="$(dirname -- "${MAKE}"):$PATH"
277 276 else
278 277 print "\$MAKE (${MAKE}) is not a valid executible"
279 278 exit 1
280 279 fi
281 280 fi
282 281
283 282 TOOLS="${SRC}/tools"
284 283 TOOLS_PROTO="${TOOLS}/proto/root_${MACH}-nd" ; export TOOLS_PROTO
285 284
286 285 if "${flags.t}" ; then
287 286 export ONBLD_TOOLS="${ONBLD_TOOLS:=${TOOLS_PROTO}/opt/onbld}"
288 287
289 288 export STABS="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/stabs"
290 289 export CTFSTABS="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfstabs"
291 290 export GENOFFSETS="${TOOLS_PROTO}/opt/onbld/bin/genoffsets"
292 291
293 292 export CTFCONVERT="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfconvert"
294 293 export CTFMERGE="${TOOLS_PROTO}/opt/onbld/bin/${MACH}/ctfmerge"
295 294
↓ open down ↓ |
51 lines elided |
↑ open up ↑ |
296 295 export CTFCVTPTBL="${TOOLS_PROTO}/opt/onbld/bin/ctfcvtptbl"
297 296 export CTFFINDMOD="${TOOLS_PROTO}/opt/onbld/bin/ctffindmod"
298 297
299 298 PATH="${TOOLS_PROTO}/opt/onbld/bin/${MACH}:${PATH}"
300 299 PATH="${TOOLS_PROTO}/opt/onbld/bin:${PATH}"
301 300 export PATH
302 301 fi
303 302
304 303 export DMAKE_MODE=${DMAKE_MODE:-parallel}
305 304
306 -if "${flags.o}" ; then
307 - export CH=
308 -else
309 - unset CH
310 -fi
311 305 DEF_STRIPFLAG="-s"
312 306
313 307 TMPDIR="/tmp"
314 308
315 -# "o_FLAG" is used by "nightly.sh" (it may be useful to rename this
316 -# variable using a more descriptive name later)
317 -export o_FLAG="$(${flags.o} && print 'y' || print 'n')"
318 -
319 309 export \
320 310 PATH TMPDIR \
321 311 POUND_SIGN \
322 312 DEF_STRIPFLAG \
323 313 RELEASE_DATE
324 314 unset \
325 315 CFLAGS \
326 316 LD_LIBRARY_PATH
327 317
328 318 # a la ws
329 319 ENVLDLIBS1=
330 320 ENVLDLIBS2=
331 321 ENVLDLIBS3=
332 322 ENVCPPFLAGS1=
333 323 ENVCPPFLAGS2=
334 324 ENVCPPFLAGS3=
335 325 ENVCPPFLAGS4=
336 326 PARENT_ROOT=
337 327 PARENT_TOOLS_ROOT=
338 328
339 329 if [[ "$MULTI_PROTO" != "yes" && "$MULTI_PROTO" != "no" ]]; then
340 330 printf \
341 331 'WARNING: invalid value for MULTI_PROTO (%s); setting to "no".\n' \
342 332 "$MULTI_PROTO"
343 333 export MULTI_PROTO="no"
344 334 fi
345 335
346 336 [[ "$MULTI_PROTO" == "yes" ]] && export ROOT="${ROOT}${SUFFIX}"
347 337
348 338 ENVLDLIBS1="-L$ROOT/lib -L$ROOT/usr/lib"
349 339 ENVCPPFLAGS1="-I$ROOT/usr/include"
350 340 MAKEFLAGS=e
351 341
352 342 export \
353 343 ENVLDLIBS1 \
354 344 ENVLDLIBS2 \
355 345 ENVLDLIBS3 \
356 346 ENVCPPFLAGS1 \
357 347 ENVCPPFLAGS2 \
358 348 ENVCPPFLAGS3 \
359 349 ENVCPPFLAGS4 \
360 350 MAKEFLAGS \
361 351 PARENT_ROOT \
362 352 PARENT_TOOLS_ROOT
363 353
364 354 printf 'RELEASE is %s\n' "$RELEASE"
365 355 printf 'VERSION is %s\n' "$VERSION"
366 356 printf 'RELEASE_DATE is %s\n\n' "$RELEASE_DATE"
367 357
368 358 if [[ -f "$SRC/Makefile" ]] && egrep -s '^setup:' "$SRC/Makefile" ; then
369 359 print "The top-level 'setup' target is available \c"
370 360 print "to build headers and tools."
371 361 print ""
372 362
373 363 elif "${flags.t}" ; then
374 364 printf \
375 365 'The tools can be (re)built with the install target in %s.\n\n' \
376 366 "${TOOLS}"
377 367 fi
378 368
379 369 #
380 370 # place ourselves in a new task, respecting BUILD_PROJECT if set.
381 371 #
382 372 /usr/bin/newtask -c $$ ${BUILD_PROJECT:+-p$BUILD_PROJECT}
383 373
384 374 if [[ "${flags.c}" == "false" && -x "$SHELL" && \
385 375 "$(basename -- "${SHELL}")" != "csh" ]]; then
386 376 # $SHELL is set, and it's not csh.
387 377
388 378 if "${flags.f}" ; then
389 379 print 'WARNING: -f is ignored when $SHELL is not csh'
390 380 fi
391 381
392 382 printf 'Using %s as shell.\n' "$SHELL"
393 383 exec "$SHELL" ${@:+-c "$@"}
394 384
395 385 elif "${flags.f}" ; then
396 386 print 'Using csh -f as shell.'
397 387 exec csh -f ${@:+-c "$@"}
398 388
399 389 else
400 390 print 'Using csh as shell.'
401 391 exec csh ${@:+-c "$@"}
402 392 fi
403 393
404 394 # not reached
↓ open down ↓ |
76 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX