5 # This script is aimed at producing Apollo product tree but
6 # it should work as well on hp-ux systems. There is at least
7 # one special rule "-n" which should not be generated on hp-ux systems
8 # where it is not necessary to run nroff on the man page sources.
11 # Put "/etc" in the path
12 # because this is where "chown" appears on bsd4.3 systems (i.e. apollo).
13 # Put "/usr/apollo/bin" on the path to access "chacl" on apollo systems.
15 export PATH=":/etc:$PATH:/usr/apollo/bin:"
19 # this alias makes for more "beautiful" output.
23 # Shell script to read a file full of destination/perm/source triples and
24 # create data base entries in a format suitable for 8.0 release. All other
25 # information defaults to the default values for now -- this should be correct
26 # in most cases but may require editing of the result for those cases
27 # needing special handling.
30 # [<install-flags>] <destination_path> <perm> <src> [ <type> <owner> <group> <status> <processor> <resp_proj> ]
32 # <install-rule> ==> [optional] 2 character field encoding special actions to be invoked when
33 # creating the product tree. In the absence of this field the file is subject
34 # to defaults based on its name,destination directory and permissions.
36 # -- Do nothing special
37 # c- compress the file
38 # -n run it through an nroff pipeline
39 # -s strip the file (should be a binary executable)
41 # <destination_path> ===> full path name on target system
42 # <perm> ===> numeric permission (with leading 0)
43 # <src> ===> build tree path name (relative to build tree root)
44 # | full path name of link source
45 # | "-" to ignore this field (source for directory not required)
46 # <type> ===> "file" | "empty_dir" | "directory" | "hard_link" | NULL
47 # <owner> ===> file owner name -- defaults to bin
48 # <group> ===> file group ownership --- defaults to bin
49 # <status> ===> "di----" default
50 # <processor> ===> valid processor "3-" | "-8" | "38" -- defaults to "38"
51 # <resp_proj> ===> responsible project --- defaults to "xwindows"
54 Usage="Usage: $0 [-f filesetName] -D <desttree> -S <srctree> <file> ...\n
55 \tfilesetName \t==> (optional) used to create subdirectory in desttree\n
56 \tdesttree \t==> destination directory\n
57 \tsrctree \t==> usually a build tree containing the source\n
58 \tfile \t\t==> data base file in \".lst\" format"
65 if [ -f /com/ctnode ]; then
69 # set flag used to test for soft links
72 # hp-ux systems (and all other systems)
75 # set flag used to test for soft links
85 # Set which system we are on
89 if [ $BUILDSYSTEM = "AIX" ];
92 elif [ $BUILDSYSTEM = "SunOS" ];
95 elif [ $BUILDSYSTEM = "UNIX_SV" ];
98 elif [ $BUILDSYSTEM = "UNIX_System_V" ];
101 elif [ $BUILDSYSTEM = "OSF1" ];
104 else # Build system = HP
108 if [ $PLATFORM = "aix" ];
111 elif [ $PLATFORM = "sun" -o $PLATFORM = "usl" -o $PLATFORM = "uxp" ];
113 USER=`/usr/ucb/whoami`
115 USER=`/usr/bin/whoami`
122 print "# TYPE RULE SRC DEST MODE OWNER GROUP LINKSRC"
128 # initialize install_rule to NULL
134 # do a little syntax checking
137 # check for special install_rule values
138 if ( $1 ~ /[-c][-ns]/ ) {
139 # set the special install rule
142 # shift the rest of the fields left
143 for ( i = 1; i < NF; i++) {
149 print "Syntax Error (line " NR ") destination path: " $1
156 print "Syntax Error (line " NR ") number of fields"
161 if ( $2 !~ /0[0-7][0-7]*/ ) {
162 print "Syntax Error (line " NR ") perm : " $2
166 # if ( $4 ~ /link/ && $3 !~ /^\// && $3 !~ /`node_data/) {
167 # changed to allow local link (using ./file syntax) -- Should this be
170 if ( $4 ~ /link/ && $3 !~ /^\// && $3 !~ /`node_data/ && \
171 $3 !~ /^\.\// && $3 !~ /^\.\.\// ) {
172 print "Syntax Error (line " NR ") source: " $3
177 # Check for special install rules
178 # man pages are compressed use rule "c-"
179 # font files are compressed use rule "c-"
180 # directories have no source i.e. src = "-"
187 status = "'$STATUS'";
188 processor = "'$PROCESSOR'";
189 resp_proj = "'$RESP_PROJ'";
195 if ( $3 ~ /^\// || $3 ~ /`node_data/ || \
196 $3 ~ /^\.\// || $3 ~ /^\.\.\// )
199 print "Syntax Error (line " NR ") link_src: " $3
204 else if ( $4 == "directory" )
207 print "Syntax Error (line " NR ") directory: " $3;
213 else if ( $4 == "empty_dir" )
215 resp_proj = "common";
219 print "Syntax Error (line " NR ") empty_dir: " $3;
226 else if ( $4 == "file" && $3 == "-" )
231 # If owner an/or group are specified all previous fields (including
232 # type) must be specified.
249 if ( install_rule != "" ) {
250 ; # install rule has been explicitly set -- do nothing
252 else if ( $1 ~ /\/usr\/man\/man.*\.Z\// )
256 else if ( $1 ~ /\/usr\/X11\/man\/cat[1-9]\/.*[1-9]/ )
260 else if ( $1 ~ /\/bsd4.3\/usr\/man\/cat[1-9]\/.*[1-9]/ )
264 else if ( $1 ~ /\/sys5.3\/usr\/catman\/.*man[1-9]\/.*[1-9]/ )
268 else if ( $1 ~ /.*\/fonts\/.*.scf$/ && $3 ~ /.*.snf$/ )
272 else if ( $1 ~ /.*\/fonts\/.*.snf\.Z$/ && $3 ~ /.*.snf$/ )
276 else if ( $1 ~ /^\/integration\// && $3 ~ /^doc\/upinfo\// )
280 else if ( $2 ~ /[1357]/ && $4 == "file" )
281 { # executable files may be stripped
285 install_rule = "'$INSTALL_RULE'";
288 # print "install_target : " $1
289 # print "fileset : " "'$FILESET'"
290 # print "type : " type
291 # print "status : " status
292 # print "processor : " processor
294 # print "owner : " owner
295 # print "group : " group
296 # print "link_source : " link_src
297 # print "build_target : " "'$BUILD_TARGET'"
298 # print "install_rule_name : " install_rule
299 # print "install_flags : " "'$INSTALL_FLAGS'"
300 # print "a_out_location : " src
301 # print "order : " "'$ORDER'"
302 # print "responsible_project : " resp_proj
305 if ( type ~ /.*link/ )
307 else if ( type ~ /.*directory/ )
310 print type, install_rule, src, $1, $2, owner ,group
318 # function to create a directory path. (mkdir -p replacement on bsd4.3)
322 if [ $# -ne 1 ]; then
323 echo "ERROR: \"$0\" invalid argument count" >&2
328 # Since we are SYSTYPE bsd4.3 "-x" won't work.
329 if [ -r /sys5.3/bin/mkdir ]; then
330 /sys5.3/bin/mkdir -p $1
333 if hp9000s300 > /dev/null 2>&1 || hp9000s800 > /dev/null 2>&1; then
339 # We can't use mkdir -p so do the hard way.
340 # starting at the root check/create all the directories
348 # provide extra slash for apollo systems (//hp* syntax)?
350 if [ "$1" = "${1##/}" ]; then
351 # not a full path name so attach path to current directory
352 fulldirs=`/bin/pwd`/$1
353 xdirs="/" # added to support apollo "//host" syntax
354 elif [ "$1" != "${1##//}" ]; then
355 # using "//host" syntax
363 echo creating path: $1
365 while nextdir=`expr /$fulldirs/ : '/*\([^/]*\)/.*'`; do
366 xdirs=$xdirs/$nextdir
367 if [ ! -d $xdirs ]; then
371 fulldirs=`expr $fulldirs : '/*[^/]*/\(.*\)'`
377 # function to put the source file into the product tree. This function
378 # reads its stdin for file movement rules.
382 if [ $# -ne 0 ]; then
383 echo "ERROR: \"$0\" incorrect arg count" >&2
395 while read TYPE RULE SRC DEST MODE OWNER GROUP; do
397 if [ -z "$TYPE" ]; then
400 # ignore comment lines (match longest string starting with '#')
401 if [ "${TYPE###}" != "$TYPE" ]; then
405 DEST=$DESTTREE/$FILESET${DEST}
410 if [ ! -d "$DEST" ]; then
411 CMD="createPath $DEST"
416 if [ "$CHECK_BEFORE" = "yes" ]
421 echo "Missing: $SRC" >>/tmp/mkprod.missing
425 if [ ! -f $SRC ]; then
426 echo "ERROR: Cannot read \"$SRC\"." >&2
427 echo " LINE=$TYPE $RULE $SRC $DEST $MODE $OWNER $GROUP " >&2
432 CMD="compress -c $SRC > $DEST"
434 -n) # nroff rule (for apollo man pages)
435 if egrep -c '^\.TH[ ]|^\.ds[ ]' $SRC > /dev/null ; then
436 CMD="tbl $SRC|eqn|nroff -man|col -b> $DEST"
443 # if [ "$(find $SRC -typeuid coff -print)" = "$SRC" ]; then
445 if [ -z "$STRIP" ]; then
447 else if file $SRC | grep -q "not stripped"; then
448 CMD="cp $SRC $DEST; strip $DEST"
454 --) # default (no special processing)
458 echo "ERROR: Unrecognized rule: \"$RULE\"" >&2
459 echo " LINE=$TYPE $RULE $SRC $DEST $MODE $OWNER $GROUP " >&2
465 if [ -z "$SRC" ]; then
466 echo "ERROR: No link source for \"$DEST\"" >&2
467 echo " LINE=$TYPE $RULE $SRC $DEST $MODE $OWNER $GROUP " >&2
470 if [ "${SRC#\`node_data}" != "$SRC" ]; then
471 # apollo-style special link
472 echo "WARNING: encountered special link: $SRC" >&2
473 # try to make link to this SRC by adding a
474 # backslash to protect the tic mark.
476 elif [ "${SRC#/}" = "$SRC" ]; then
477 # echo "ERROR: Relative link \"$SRC\"" >&2
478 # echo "WARNING: Relative link \"$SRC\"" >&2
479 # echo " LINE=$TYPE $RULE $SRC $DEST $MODE $OWNER $GROUP " >&2
480 # Protect the potential variant link variable
485 CMD="ln -s $SRC $DEST"
486 # Remove existing link if one already exists
487 [ -${LNKTST} "$DEST" ] && rm $DEST
490 # Hard links are assumed to be made only to other
491 # files in the submittal -- not to existing system
493 SRC="$DESTTREE/$FILESET${SRC}"
494 if [ -z "$SRC" ]; then
495 echo "ERROR: No link source for \"$DEST\"" >&2
496 echo " LINE=$TYPE $RULE $SRC $DEST $MODE $OWNER $GROUP" >&2
501 *) echo "ERROR: Unrecognized type: \"$TYPE\"" >&2
502 echo " LINE=$TYPE $RULE $SRC $DEST $MODE $OWNER $GROUP" >&2
507 # createPath issues its own error messages
508 if [ ! -d ${DEST%/*} ]; then
509 createPath ${DEST%/*} || continue
511 [ -z "$CMD" ] && continue
513 echo "ERROR: \"$CMD\" failed" >&2
514 echo " LINE=$TYPE $RULE $SRC $DEST $MODE $OWNER $GROUP" >&2;
517 # set permissions for non-links
518 if [ "${TYPE%link}" = "$TYPE" ]; then
519 if [ "$USER" = "root" ]; then
521 echo "ERROR: \"chmod $MODE $DEST\" failed" >&2
522 chgrp $GROUP $DEST ||
523 echo "ERROR: \"chgrp $GROUP $DEST\" failed" >&2
524 chown $OWNER $DEST ||
525 echo "ERROR: \"chown $OWNER $DEST\" failed" >&2
529 echo $TYPE $RULE $SRC $DEST $MODE $OWNER $GROUP
534 ###################################################
536 ###################################################
539 # Check Path for chmod, chown, and chgrp
541 whence chmod > /dev/null || {
542 echo "ERROR: \"chmod\" not in PATH." >&2
545 whence chown > /dev/null || {
546 echo "ERROR: \"chown\" not in PATH." >&2
549 whence chgrp > /dev/null || {
550 echo "ERROR: \"chgrp\" not in PATH." >&2
556 while [ $# -ne 0 ] ; do
560 if [ -z "$FILESET" ]; then
561 if [ $# -ge 1 ]; then
570 if [ -z "$SRCTREE" ]; then
571 if [ $# -ge 1 ]; then
580 -D*) DESTTREE=${1#-D}
581 if [ -z "$DESTTREE" ]; then
582 if [ $# -ge 1 ]; then
592 -P*) CHECK_BEFORE="yes"
595 *) files="$files $1";;
597 if [ $# -ge 1 ]; then
602 if [ -z "$files" -o -z "$SRCTREE" ]; then
607 if [ ! -d "$SRCTREE" ]; then
608 echo "ERROR: Cannot access \"$SRCTREE\"." >&2
611 if [ ! -d "$DESTTREE" ]; then
612 echo "ERROR: Cannot access \"$DESTTREE\"." >&2
617 if [ -f /com/ctnode ]; then
619 # Make sure berkely style permissions are applied to the product tree
620 # This should cause directories to be created with permissions based
621 # on the umask (which is otherwise ignored on "open security model"
628 echo FILESET=$FILESET
630 echo SRCTREE=$SRCTREE
631 echo DESTTREE=$DESTTREE
632 echo "#-------------- $(date) --------------"
635 TOOL_DIR=$SRCTREE/admin/IntegTools/dbTools
638 # Avoid making duplicate entries
639 # make sure links are referred to AFTER the files to which they point.
641 if [ $PLATFORM = "uxp" ]; then
642 $TOOL_DIR/uncomment $files | sort | uniq | $TOOL_DIR/linksLast - > /tmp/awk.in
643 cat /tmp/awk.in | awkit > /tmp/awk.out
644 cat /tmp/awk.out | doit
646 $TOOL_DIR/uncomment $files | sort | uniq | $TOOL_DIR/linksLast - | awkit | doit
650 echo "#-------------- $(date) --------------"