1/ Analyse the fields from mtree lines to extract: - owner, - group, - mode, - flags, - tags, 2/ Ignore non tagged entries 3/ For now concat tags to form a futur package name
40 lines
697 B
Awk
40 lines
697 B
Awk
#!/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
|
|
}
|