#
#  update method awk script
#

/^var target / {
         target = $3
        }

/^var srcdir / {
         srcdir = $3
        }

/^var cmddir / {
         cmddir = $3
        }

/^var mandir / {
         mandir = $3
}

/^var mancp / {
         mancp = $3
}

/^var instarch / {
         instarch = $3
}

/^systemid / {
         sysid = $2
}

/^dir / { 
         rawdir = sprintf($2, instarch)
         destdir = target "/" rawdir
         printm "printm InstallingDir " rawdir
         print "if [ ! -d " destdir " ]; then\nmkdir " destdir "\nfi"
       }

/^source / {
        rawsource = srcdir "/" $2
        source = sprintf(rawsource, instarch)
       }

/^file / {
        srcfile = source "/" $2
        print "if [ ! -f " destdir "/" $2 " ]; then\ncp " srcfile " " destdir "\nfi"
       }

/^command / {
        if (instarch != ""){
        print $3 " " instarch " " $2}
        else {print $3 " " sysid " " $2}
        cfile="$sysid/$2"
        ccfile=cmddir "/" $2
        if (cmddir != "") {
           print "cp " destdir "/" $2 " " ccfile
           print "printm CommandFile " ccfile
        }
       }

#  Scripts are called for both update and copy methods.

/^script / {
        print $2 " " destdir
       }

/^manpage / {
        if ( mancp == "" ) {
            print "cp " destdir "/" $2 " " mandir
        } else {
            print mancp " " destdir "/" $2 " " mandir
        }
}

#  Obsolete files and directories are handled for both update and copy methods.

/^obsoletefile / {
	print "rm -f " destdir "/" $2
       }

# Use rmdir for obsolete directories; use obsolete file to list everything
# in it first. This provides at least a tiny amount of safety.

/^obsoletedir / {
	print "rmdir " $2
       }

