1278391Sbapt#!/usr/bin/awk
2278391Sbapt/^[^#]/ {
3278391Sbapt	gsub(/^\./,"", $1)
4279653Sbapt	uname = gname = mode = flags = tags = type = ""
5279605Sbapt	for (i=2; i<=NF; i++) {
6279605Sbapt		if ($i ~ /^uname=/) {
7279605Sbapt			uname=$i
8279608Sbapt			gsub(/uname=/, "", uname)
9279605Sbapt		} else if ($i ~ /^gname=/) {
10279605Sbapt			gname=$i
11279608Sbapt			gsub(/gname=/, "", gname)
12279605Sbapt		} else if ($i ~ /^mode=/) {
13279605Sbapt			mode=$i
14279608Sbapt			gsub(/mode=/,"", mode)
15279605Sbapt		} else if ($i ~ /^flags=/) {
16279605Sbapt			flags=$i
17279608Sbapt			gsub(/flags=/, "", flags)
18279605Sbapt		} else if ($i ~ /^tags=/) {
19279605Sbapt			tags=$i
20279608Sbapt			gsub(/tags=/, "", tags)
21279653Sbapt		} else if ($i ~ /^type=dir/) {
22279653Sbapt			type="dir"
23279605Sbapt		}
24279605Sbapt	}
25294942Sgjb	if (kernel != "") {
26294942Sgjb		tags="package=kernel"
27294942Sgjb		if (_kernconf != "") {
28294942Sgjb			tags=tags""_kernconf
29294942Sgjb		}
30294942Sgjb	}
31279605Sbapt	if (length(tags) == 0)
32279605Sbapt		next
33279605Sbapt	if (tags ~ /package=/) {
34280215Sbapt		ext = pkgname = pkgend = ""
35279660Sbapt		split(tags, a, ",");
36279660Sbapt		for (i in a) {
37279660Sbapt			if (a[i] ~ /^package=/) {
38279660Sbapt				pkgname=a[i]
39279660Sbapt				gsub(/package=/, "", pkgname)
40279660Sbapt			} else if (a[i] == "config") {
41279660Sbapt				type="config"
42296531Sgjb			} else if (a[i] == "development" || a[i] == "profile" || a[i] == "debug" || a[i] == "docs") {
43280215Sbapt				pkgend=a[i]
44279660Sbapt			} else {
45280215Sbapt				if (ext != "")
46280215Sbapt					ext=ext"-"a[i]
47280215Sbapt				else
48280215Sbapt					ext=a[i]
49279660Sbapt			}
50279660Sbapt		}
51280215Sbapt		if (ext != "") {
52296531Sgjb			pkgname=pkgname"-"ext
53279660Sbapt		}
54280215Sbapt		if (pkgend != "") {
55296531Sgjb			if (pkgend == "docs") {
56280215Sbapt				pkgname=pkgend
57280215Sbapt			} else {
58280215Sbapt				pkgname=pkgname"-"pkgend
59280215Sbapt			}
60280215Sbapt		}
61279605Sbapt	} else {
62294942Sgjb		print "No packages specified in line: $0"
63279660Sbapt		next
64279605Sbapt	}
65294942Sgjb	if (kernel != "") {
66294942Sgjb		output="kernel"
67294942Sgjb		if (_kernconf != "") {
68294942Sgjb			output=output"."_kernconf
69294942Sgjb		}
70294942Sgjb		if ($1 ~ /^\/usr\/lib\/debug\/boot/) {
71294942Sgjb			output=output"-debug.plist"
72294942Sgjb		} else {
73296545Sgjb			output=output".plist"
74294942Sgjb		}
75294942Sgjb	} else {
76294942Sgjb		output=pkgname".plist"
77294942Sgjb	}
78278391Sbapt
79279653Sbapt	print "@"type"("uname","gname","mode","flags") " $1 > output
80278391Sbapt}
81