Rev 1530 | Blame | Compare with Previous | Last modification | View Log | RSS feed
##################################################################################################### This is a class action script for the replace class# For each file in this class it will replace any replace tags in that file as it copies it to dest.# It searches the src file for <REPLACETAG-XXX> and for each one it# Looks for Environment var XXX and if it exists it is used to replace the tag in the file# otherwise it prints a warning if the Var does not exist.# If no tags are found in the file it is simply copied to dest# These environment vars are setup by pkginfo or request script# Just need to make sure that these vars match the XXX portion of the REPLACETAG####################################################################################################getList(){sed -n ':start/<REPLACETAG/{:leading/^<REPLACETAG/!{# while replace tag not at beginning of line remove leading charss/^<\{0,1\}[^<]*//b leading}# we now should have replace tag at start of line# save lineh# print 1st REPLACETAG, ie remove all after tag and print lines/^<\(REPLACETAG[^>]*\)>.*$/\1/p#restore orignial line & remove printed replace & jump to start to see if any more on same linexs/^<REPLACETAG[^>]*>\(.*\)$/\1/b start}' $1 | sort | uniq | awk 'BEGIN { ORS=" " } { print $0 }'}Warn=while read src destdoif [ "$src" != "/dev/null" ]; then# Get list of REPLACETAG- in current fileLIST=`getList $src`Msg=sedArgs=for tag in $LISTdo# Remove REPLACETAG- from front of tag to get the enviroment var namevar=`echo $tag | sed 's|^REPLACETAG-||'`# now eval the name and expand the var to get contents into replrepl=`eval echo \\$$var`if [ -n "$repl" ]; thenMsg="$Msg [$tag=$repl]\n"sedArgs="$sedArgs -e 's|<$tag>|$repl|g'"elseWarn="$Warn===>WARNING: Install Environment Var [$var] does not exist for replacement in [$dest]\n"fidoneinstallf -c replace $PKGINST $dest fif [ -n "$sedArgs" ]; thenprintf "$dest <Replacements as follows>\n$Msg"eval sed $sedArgs $src > $destelseprintf "$dest <No Replacements Found>\n$Msg"cp $src $destfifidoneif [ "$1" = "ENDOFCLASS" ]; theninstallf -f -c replace $PKGINSTecho "Replacements Completed"if [ -n "$Warn" ]; thenprintf "$Warn"fifi