5630N/A# If invoked with -v FUNCTION=name, then just print $1 (s|/|---|).
5630N/A# Otherwise we expect to be invoked with TARGET=<whatever>, then if
5630N/A# s|/|---| on $1 matches TARGET, we generate a manifest.
5630N/A{
5630N/A if (substr($1, 1, 1) == "#") { # Skip comments.
5630N/A continue
5630N/A }
7034N/A if ($NF ~ /^arch=/) {
7034N/A arch=$NF;
7034N/A split(arch, a, "=")
7034N/A if (a[2] != MACH)
7034N/A continue
7034N/A NF--;
7034N/A }
5630N/A fmri=$1
5630N/A split(fmri, a, "@")
5630N/A gsub("/", "---", a[1])
5630N/A target = sprintf("%s.p5m", a[1])
5630N/A if (FUNCTION == "name") {
5630N/A printf "%s\n", target
5630N/A continue
5630N/A }
5630N/A if (target != TARGET) {
5630N/A continue
5630N/A }
5630N/A printf "set name=pkg.fmri value=pkg:/%s\n", fmri
7034N/A if ($NF ~ /^incorporate=/) {
7034N/A incorporate=$NF;
7034N/A NF--;
7034N/A }
5630N/A if (NF == 2) {
5630N/A print "set name=pkg.renamed value=true"
5630N/A printf "depend type=require fmri=%s\n", $2
5630N/A } else {
5630N/A print "set name=pkg.obsolete value=true"
5630N/A }
7034N/A if (incorporate) {
7034N/A printf "set name=org.opensolaris.consolidation %s value=$(CONSOLIDATION)\n",
7034N/A incorporate
7034N/A } else {
7034N/A print "set name=org.opensolaris.consolidation value=$(CONSOLIDATION)"
7034N/A }
5630N/A exit 0 # We're done; no point continuing.
5630N/A}