aboutsummaryrefslogtreecommitdiff
path: root/release/scripts/mtree-to-plist.awk
blob: 152b977f02041a3631b0a23000f63f7601bdac3c (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
#!/usr/bin/awk
/^[^#]/ {
	gsub(/^\./,"", $1)
	uname=""
	gname=""
	mode=""
	flags=""
	tags=""
	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);
		}
	}
	if (length(tags) == 0)
		next
	if (tags ~ /package=/) {
		gsub(/package=/,"",tags);
		gsub(/,/, "-", tags);
		pkg=tags
	} else {
		pkg=tags
	}
	output=pkg".plist"

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