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