5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
27 # Generates the list of source files that would get brought over with the
28 # specified subtree as a result of inc.flg and req.flg files. If no subtree
29 # is named, then the current directory is assumed.
31 # Based loosely on ON's version of Teamware's def.dir.flp.
34 ONBLDDIR
=$
(dirname $
(whence
$0))
36 PATH
=/usr
/bin
:${BUILD_TOOLS:-/opt}/teamware
/bin
:$ONBLDDIR
41 # The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout
42 # under certain circumstances, which will screw up consumers of incflg()
43 # (and perhaps other things as well); unset it.
48 # Print the usage message and exit with an error.
52 echo "usage: $PROG [-r] [<dir>]" > /dev
/stderr
57 # Print the provided failure message and exit with an error.
61 echo $PROG: $@
> /dev
/stderr
65 # Find the files matching the pattern specified by the first argument in the
66 # directories named by the remaining arguments. Unlike def.dir.flp, print
67 # the name of the source file since we want to make a list of source files,
75 if [[ "$SCM_MODE" = "teamware" ]]; then
77 if [[ -d $CODEMGR_WS/$dir ]]; then
79 find $dir -name "$pat" | \
80 sed -n s
:/SCCS
/s.
:/:p | prpath
84 elif [[ "$SCM_MODE" = "mercurial" ||
"$SCM_MODE" == "git" ]]; then
87 if [[ -d $CODEMGR_WS/$dir ]]; then
92 # Remove leading pipe before it can confuse egrep
94 echo "$FILELIST" |
egrep "^($dirs)/.*/${pat#s.}\$" | prpath
99 # Echo the filename if it exists in the workspace.
103 [ -f $CODEMGR_WS/$1 ] && echo $1 | prpath
107 # Source the named script, specified as either a full path or a path relative
108 # to $CODEMGR_WS. Although def.dir.flp allows for situations in which the
109 # script is actually executed (rather than sourced), this feature has never
110 # been used in ON, since it precludes use of echo_file() and find_files().
114 if [[ "${1##/}" = "$1" ]]; then
122 # Iterate up through all directories below the named directory, and
123 # execute any inc.flg's that may exist.
136 if [[ -d $i && ! -h $i ]]; then
146 # Convert the absolute pathnames named on input to relative pathnames (if
147 # necessary) and print them.
152 # $CURTREE may be a subdirectory of $CODEMGR_WS, or it
153 # may be the root of $CODEMGR_WS. We want to strip it
154 # and end up with a relative path in either case, so the
155 # ?(/) pattern is important. If we don't do that, the
156 # dots/tree loop will go on forever.
158 reltree
=${CURTREE##$CODEMGR_WS?(/)}
160 while read srcfile
; do
161 if [[ "$RELPATHS" != y
]]; then
168 while [[ "${srcfile##$tree}" = "$srcfile" ]]; do
171 [ "$tree" = "." ] && break
173 echo ${dots}${srcfile##$tree/}
177 which_scm |
read SCM_MODE CODEMGR_WS ||
exit 1
179 if [[ $SCM_MODE == "unknown" ]]; then
180 fail
"Unable to determine SCM type currently in use."
181 elif [[ $SCM_MODE == "mercurial" ]]; then
182 FILELIST
=$
(hg manifest
)
183 elif [[ $SCM_MODE == "git" ]]; then
184 FILELIST
=$
(cd $
(dirname $
(git rev-parse
--git-dir)) && git ls-files
)
185 elif [[ $SCM_MODE != "teamware" ]]; then
186 fail
"Unsupported SCM in use: $SCM_MODE"
189 while getopts r flag
; do
200 shift $
((OPTIND
- 1))
202 [ $# -gt 1 ] && usage
207 # Determine the subtree being examined.
209 if [[ $# -eq 0 ]]; then
211 elif [[ -d $1 ]]; then
213 elif [[ -d $CODEMGR_WS/$1 ]]; then
214 SUBTREE
=$CODEMGR_WS/$1
216 fail
"neither \$CODEMGR_WS/$1 nor $1 exists as a directory"
220 # Get the canonical path to the subtree.
226 # Get the canonical path to the current directory.
232 # Get the canonical path to the workspace.
235 CODEMGR_WS
=`/bin/pwd`
237 if [[ "${SUBTREE##$CODEMGR_WS}" = "$SUBTREE" ]]; then
238 fail
"$SUBTREE is not a subtree of \$CODEMGR_WS"
241 if [[ "${CURTREE##$CODEMGR_WS}" = "$CURTREE" ]]; then
242 fail
"$CURTREE is not a subtree of \$CODEMGR_WS"
246 # Find and execute all inc.flg's below our subtree.
251 # Find and execute all req.flg's at or above our subtree.
254 while [[ $TREE != $CODEMGR_WS ]]; do
255 [[ -f $TREE/req.flg
]] && exec_file
$TREE/req.flg