aboutsummaryrefslogtreecommitdiff
path: root/release/scripts/mtree-to-plist.awk
blob: e61805f2cd0112b7fc0f737eb77fabc612b67afa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/awk
/^[^#]/ {
	gsub(/^\./,"", $1)
	uname = gname = mode = flags = tags = type = ""
	for (i=2; i<=NF; i++) {
		if ($i ~ /^uname=/) {
			uname=$i
			gsub(/uname=/, "", uname)
		} else if ($i ~ /^gname=/) {
			gname=$i
			gsub(/gname=/, "", gname)
		} else if ($i ~ /^mode=/) {
			mode=$i
			gsub(/mode=/,"", mode)
		} else if ($i ~ /^flags=/) {
			flags=$i
			gsub(/flags=/, "", flags)
		} else if ($i ~ /^tags=/) {
			tags=$i
			gsub(/tags=/, "", tags)
		} else if ($i ~ /^type=dir/) {
			type="dir"
		}
	}
	if (length(tags) == 0)
		next
	if (tags ~ /package=/) {
		ext = pkgname = ""
		split(tags, a, ",");
		for (i in a) {
			if (a[i] ~ /^package=/) {
				pkgname=a[i]
				gsub(/package=/, "", pkgname)
			} else if (a[i] == "config") {
				type="config"
			} else {
				ext=a[i]
			}
		}
		if (length(ext) > 0) {
			if (pkgname == "runtime") {
				pkgname=ext
			} else {
				pkgname=pkgname"-"ext
			}
		}
	} else {
		print "No packages specified in line: $0" > 2
		next
	}
	output=pkgname".plist"

	print "@"type"("uname","gname","mode","flags") " $1 > output
}