Print this page
4028 remove CLOSED_IS_PRESENT
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/tools/scripts/ws.sh
+++ new/usr/src/tools/scripts/ws.sh
1 1 #!/bin/ksh -p
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 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 24 # Use is subject to license terms.
25 25 #
26 26 # Copyright 2011 Nexenta Systems, Inc. All rights reserved.
27 27 #
28 28 # This script sets up the environment variables for a SunOS
29 29 # codemgr workspace and spawns a shell with the environment
30 30 # setup.
31 31 #
32 32 # The following Environment variables are set:
33 33 # CODEMGR_WS
34 34 # ONBLD_DIR
35 35 # SRC
36 36 # TSRC
37 37 # ROOT
38 38 # PARENT_ROOT
39 39 # MACH
40 40 # MAKEFLAGS
41 41 # ENVCPPFLAGS{1-4}
42 42 # ENVLDLIBS{1-3}
43 43 #
44 44 # The MAKEFLAGS environment variable is set to force make
45 45 # to read default make variables from the environment.
46 46 #
47 47 # Workspace names can be specified in two forms: pathname
48 48 # and hostname:pathname. If the hostname:pathname form is used
49 49 # the script accesses the environment through the /net automounter
50 50 # map.
51 51 #
52 52
53 53 #
54 54 # function to produce a pathname from a workspace name or subdirectory.
55 55 # The workspace name can have hostname:pathname format.
56 56 #
57 57
58 58 fmtwsname()
59 59 {
60 60 awk -F: '$1 != $0 { print "/net/"$1$2 } \
61 61 $1 == $0 { print $0 }'
62 62 }
63 63
64 64 #
65 65 # Return a valid proto area, if one exists.
66 66 #
67 67 check_proto()
68 68 {
69 69 if [[ -z $1 ]]; then
70 70 return
71 71 fi
72 72
73 73 if [[ "$SCM_MODE" = "teamware" ]]; then
74 74 # Check for problematic parent specification and adjust
75 75 proto=`echo $1|fmtwsname`
76 76 echo "${proto}/root_${MACH}"
77 77 elif [[ "$SCM_MODE" = "mercurial" ]]; then
78 78 proto=$1
79 79 #
80 80 # If the proto is a local repository then we can use it
81 81 # to point to the parents proto area. Don't bother to
82 82 # check if it exists or not, we never did for Teamware,
83 83 # since it might appear later anyway.
84 84 #
85 85 if [[ "${proto##ssh://}" == "$proto" && \
86 86 "${proto##http://}" == "$proto" && \
87 87 "${proto##https://}" == "$proto" ]]; then
88 88 echo "${proto}/root_${MACH}"
89 89 fi
90 90 elif [[ "$SCM_MODE" = "git" ]]; then
91 91 #
92 92 # For git, we make no attempt to deal with the possibility of
93 93 # remote parent workspaces because, in the protodefs file, we
94 94 # don't actually acknowledge the concept of a parent workspace
95 95 # at all, in keeping with the rest of our git support.
96 96 #
97 97 echo "${1}/root_${MACH}"
98 98 fi
99 99 }
100 100
101 101 cleanup_env()
102 102 {
103 103 # keep the env. clean when returning
104 104 unset setenv osbld_flag os_rev wsosdir protofile wsname ofs proto \
105 105 pwd parent PROTO1 PROTO2 PROTO3 tmpwsname
106 106 return 0
107 107 }
108 108
109 109 if [[ "$1" = "-e" ]]; then
110 110 setenv=true
111 111 shift
112 112 else
113 113 setenv=false
114 114 fi
115 115
116 116 WHICH_SCM=$(/bin/dirname $(whence $0))/which_scm
117 117 if [[ ! -x $WHICH_SCM ]]; then
118 118 WHICH_SCM=which_scm
119 119 fi
120 120
121 121 #
122 122 # No workspace/repository path was given, so try and detect one from our
123 123 # current directory we're in
124 124 #
125 125 if [[ $# -lt 1 ]]; then
126 126 if env CODEMGR_WS="" $WHICH_SCM | read SCM_MODE tmpwsname && \
127 127 [[ $SCM_MODE != unknown ]]; then
128 128 echo "Defaulting to $SCM_MODE repository $tmpwsname"
129 129 else
130 130 echo "usage: ws [-e] [workspace_name]" >&2
131 131 if $setenv; then
132 132 cleanup_env
133 133 return 1
134 134 else
135 135 exit 1
136 136 fi
137 137 fi
138 138 else
139 139 #
140 140 # A workspace/repository path was passed in, grab it and pop
141 141 # it off the stack
142 142 #
143 143 tmpwsname=$1
144 144 shift
145 145 fi
146 146
147 147 #
148 148 # This variable displays the nested activations of workspaces.
149 149 # This is done here to get the exact name the user entered.
150 150 #
151 151 WS_STACK="$tmpwsname $WS_STACK"; export WS_STACK
152 152
153 153 #
154 154 # Set the workspace name and unset tmpwsname (as we reuse it later)
155 155 #
156 156 wsname=`echo $tmpwsname|fmtwsname`
157 157 unset tmpwsname
158 158
159 159 #
160 160 # Checking for CODEMGR_WSPATH
161 161 #
162 162 if [[ -n ${CODEMGR_WSPATH} && ( ! -d $wsname ) && \
163 163 ( `expr "$wsname" : "\/"` = "0" ) ]]
164 164 then
165 165 ofs=$IFS
166 166 IFS=": "
167 167 for i in $CODEMGR_WSPATH
168 168 do
169 169 if [[ -d ${i}/${wsname} ]]; then
170 170 wsname=${i}/${wsname}
171 171 break
172 172 fi
173 173 done
174 174 IFS=$ofs
175 175 fi
176 176
177 177 #
178 178 # to translate it to an absolute pathname. We need an
179 179 # absolute pathname in order to set CODEMGR_WS.
180 180 #
181 181 if [[ `expr "$wsname" : "\/"` = "0" ]]
182 182 then
183 183 pwd=`pwd`
184 184 wsname="$pwd/$wsname"
185 185 fi
186 186
187 187 #
188 188 # Check to see if this is a valid workspace
189 189 #
190 190 if [[ ! -d $wsname ]]; then
191 191 echo "$wsname . . . no such directory" >&2
192 192 if $setenv; then
193 193 cleanup_env
194 194 return 1
195 195 else
196 196 exit 1
197 197 fi
198 198 fi
199 199
200 200 #
201 201 # This catches the case of a passed in workspace path
202 202 # Check which type of SCM is in use by $wsname.
203 203 #
204 204 (cd $wsname && env CODEMGR_WS="" $WHICH_SCM) | read SCM_MODE tmpwsname
205 205 if [[ $? != 0 || "$SCM_MODE" == unknown ]]; then
206 206 echo "Error: Unable to detect a supported SCM repository in $wsname"
207 207 if $setenv; then
208 208 cleanup_env
209 209 return 1
210 210 else
211 211 exit 1
212 212 fi
213 213 fi
214 214
215 215 wsname=$tmpwsname
216 216 CODEMGR_WS=$wsname ; export CODEMGR_WS
217 217 SRC=$wsname/usr/src; export SRC
218 218 TSRC=$wsname/usr/ontest; export TSRC
219 219
220 220 if [[ "$SCM_MODE" = "teamware" && -d ${wsname}/Codemgr_wsdata ]]; then
221 221 CM_DATA="Codemgr_wsdata"
222 222 wsosdir=$CODEMGR_WS/$CM_DATA/sunos
223 223 protofile=$wsosdir/protodefs
224 224 elif [[ "$SCM_MODE" = "mercurial" && -d ${wsname}/.hg ]]; then
225 225 CM_DATA=".hg"
226 226 wsosdir=$CODEMGR_WS/$CM_DATA
227 227 protofile=$wsosdir/org.opensolaris.protodefs
228 228 elif [[ "$SCM_MODE" = "git" && -d ${wsname}/.git ]]; then
229 229 CM_DATA=".git"
230 230 wsosdir=$CODEMGR_WS/$CM_DATA
231 231 protofile=$wsosdir/org.opensolaris.protodefs
232 232 else
233 233 echo "$wsname is not a supported workspace; type is $SCM_MODE" >&2
234 234 if $setenv; then
235 235 cleanup_env
236 236 return 1
237 237 else
238 238 exit 1
239 239 fi
240 240 fi
241 241
242 242 MACH=`uname -p`
243 243
244 244 if [[ ! -f $protofile ]]; then
245 245 if [[ ! -w $CODEMGR_WS/$CM_DATA ]]; then
246 246 #
247 247 # The workspace doesn't have a protodefs file and I am
248 248 # unable to create one. Tell user and use /tmp instead.
249 249 #
250 250 echo "Unable to create the proto defaults file ($protofile)."
251 251
252 252 # Just make one in /tmp
253 253 wsosdir=/tmp
254 254 protofile=$wsosdir/protodefs
255 255 fi
256 256
257 257 if [[ ! -d $wsosdir ]]; then
258 258 mkdir $wsosdir
259 259 fi
260 260
261 261 cat << PROTOFILE_EoF > $protofile
262 262 #!/bin/sh
263 263 #
264 264 # Set default proto areas for this workspace
265 265 # NOTE: This file was initially automatically generated.
266 266 #
267 267 # Feel free to edit this file. If this file is removed
268 268 # it will be rebuilt containing default values.
269 269 #
270 270 # The variable CODEMGR_WS is available to this script.
271 271 #
272 272 # PROTO1 is the first proto area searched and is typically set
273 273 # to a proto area associated with the workspace. The ROOT
274 274 # environment variable is set to the same as PROTO1. If you
275 275 # will be doing make installs this proto area needs to be writable.
276 276 #
277 277 # PROTO2 and PROTO3 are set to proto areas to search before the
278 278 # search proceeds to the local machine or the proto area specified by
279 279 # TERMPROTO.
280 280 #
281 281 # TERMPROTO (if specified) is the last place searched. If
282 282 # TERMPROTO is not specified the search will end at the local
283 283 # machine.
284 284 #
285 285
286 286 PROTO1=\$CODEMGR_WS/proto
287 287 PROTOFILE_EoF
288 288
289 289 if [[ "$SCM_MODE" = "teamware" ]]; then
290 290 cat << PROTOFILE_EoF >> $protofile
291 291 if [[ -f "\$CODEMGR_WS/Codemgr_wsdata/parent" ]]; then
292 292 #
293 293 # If this workspace has an codemgr parent then set PROTO2 to
294 294 # point to the parents proto space.
295 295 #
296 296 parent=\`workspace parent \$CODEMGR_WS\`
297 297 if [[ -n \$parent ]]; then
298 298 PROTO2=\$parent/proto
299 299 fi
300 300 fi
301 301 PROTOFILE_EoF
302 302 elif [[ "$SCM_MODE" = "mercurial" ]]; then
303 303 cat << PROTOFILE_EoF >> $protofile
304 304 parent=\`(cd \$CODEMGR_WS && hg path default 2>/dev/null)\`
305 305 if [[ \$? -eq 0 && -n \$parent ]]; then
306 306 [[ -n \$(check_proto \$parent/proto) ]] && PROTO2=\$parent/proto
307 307 fi
308 308 PROTOFILE_EoF
309 309 fi
310 310 fi
311 311
312 312 . $protofile
313 313
314 314 # This means you don't have to type make -e all of the time
315 315
316 316 MAKEFLAGS=e; export MAKEFLAGS
317 317
318 318 #
319 319 # Set up the environment variables
320 320 #
321 321 ROOT=/proto/root_${MACH} # default
322 322
323 323 ENVCPPFLAGS1=
324 324 ENVCPPFLAGS2=
325 325 ENVCPPFLAGS3=
326 326 ENVCPPFLAGS4=
327 327 ENVLDLIBS1=
328 328 ENVLDLIBS2=
329 329 ENVLDLIBS3=
330 330
331 331 PROTO1=`check_proto $PROTO1`
332 332 if [[ -n "$PROTO1" ]]; then # first proto area specifed
333 333 ROOT=$PROTO1
334 334 ENVCPPFLAGS1=-I$ROOT/usr/include
335 335 export ENVCPPFLAGS1
336 336 ENVLDLIBS1="-L$ROOT/lib -L$ROOT/usr/lib"
337 337 export ENVLDLIBS1
338 338
339 339 PROTO2=`check_proto $PROTO2`
340 340 if [[ -n "$PROTO2" ]]; then # second proto area specifed
341 341 ENVCPPFLAGS2=-I$PROTO2/usr/include
342 342 export ENVCPPFLAGS2
343 343 ENVLDLIBS2="-L$PROTO2/lib -L$PROTO2/usr/lib"
344 344 export ENVLDLIBS2
345 345
346 346 PROTO3=`check_proto $PROTO3`
347 347 if [[ -n "$PROTO3" ]]; then # third proto area specifed
348 348 ENVCPPFLAGS3=-I$PROTO3/usr/include
349 349 export ENVCPPFLAGS3
350 350 ENVLDLIBS3="-L$PROTO3/lib -L$PROTO3/usr/lib"
351 351 export ENVLDLIBS3
352 352 fi
353 353 fi
354 354 fi
355 355
356 356 export ROOT
357 357
↓ open down ↓ |
357 lines elided |
↑ open up ↑ |
358 358 if [[ -n "$TERMPROTO" ]]; then # fallback area specifed
359 359 TERMPROTO=`check_proto $TERMPROTO`
360 360 ENVCPPFLAGS4="-Y I,$TERMPROTO/usr/include"
361 361 export ENVCPPFLAGS4
362 362 ENVLDLIBS3="$ENVLDLIBS3 -Y P,$TERMPROTO/lib:$TERMPROTO/usr/lib"
363 363 export ENVLDLIBS3
364 364 fi
365 365
366 366 osbld_flag=0
367 367
368 -if [[ ! -v CLOSED_IS_PRESENT ]]; then
369 - if [[ -d $SRC/../closed ]]; then
370 - export CLOSED_IS_PRESENT="yes"
371 - else
372 - export CLOSED_IS_PRESENT="no"
373 - fi
374 -fi
375 -
376 368 if [[ -z "$ONBLD_DIR" ]]; then
377 369 ONBLD_DIR=$(/bin/dirname $(whence $0))
378 370 fi
379 371
380 372 if ! echo ":$PATH:" | grep ":${ONBLD_DIR}:" > /dev/null; then
381 373 PATH="${ONBLD_DIR}:${ONBLD_DIR}/${MACH}:${PATH}"
382 374 osbld_flag=1
383 375 fi
384 376
385 377 export PATH
386 378
387 379 if [[ -n "$PROTO2" ]]; then
388 380 # This should point to the parent's proto
389 381 PARENT_ROOT=$PROTO2
390 382 export PARENT_ROOT
391 383 else
392 384 # Clear it in case it's already in the env.
393 385 PARENT_ROOT=
394 386 fi
395 387 export ONBLD_DIR
396 388 export MACH
397 389
398 390 os_rev=`uname -r`
399 391 os_name=`uname -s`
400 392
401 393 if [[ $os_name != "SunOS" || `expr $os_rev : "5\."` != "2" ]]; then
402 394 #
403 395 # This is not a SunOS 5.x machine - something is wrong
404 396 #
405 397 echo "***WARNING: this script is meant to be run on SunOS 5.x."
406 398 echo " This machine appears to be running: $os_name $os_rev"
407 399 fi
408 400
409 401 echo ""
410 402 echo "Workspace : $wsname"
411 403 if [[ -n "$parent" ]]; then
412 404 echo "Workspace Parent : $parent"
413 405 fi
414 406 echo "Proto area (\$ROOT) : $ROOT"
415 407 if [[ -n "$PARENT_ROOT" ]]; then
416 408 echo "Parent proto area (\$PARENT_ROOT) : $PARENT_ROOT"
417 409 fi
418 410 echo "Root of source (\$SRC) : $SRC"
419 411 echo "Root of test source (\$TSRC) : $TSRC"
420 412 if [[ $osbld_flag = "1" ]]; then
421 413 echo "Prepended to PATH : $ONBLD_DIR"
422 414 fi
423 415 echo "Current directory (\$PWD) : $wsname"
424 416 echo ""
425 417
426 418 cd $wsname
427 419
428 420 if $setenv; then
429 421 cleanup_env
430 422 else
431 423 exec ${SHELL:-sh} "$@"
432 424 fi
↓ open down ↓ |
47 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX