Improve mtree to plist converter
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
This commit is contained in:
parent
ef3290ce8b
commit
f4da3de647
@ -1,15 +1,39 @@
|
||||
#!/usr/bin/awk
|
||||
/^[^#]/ {
|
||||
gsub(/^\./,"", $1)
|
||||
tags=$NF
|
||||
gsub(/tags=/,"", tags)
|
||||
output=tags".plist"
|
||||
uname=$3
|
||||
gname=$4
|
||||
mode=$5
|
||||
gsub(/uname=/, "", uname);
|
||||
gsub(/gname=/, "", gname);
|
||||
gsub(/mode=/, "", mode);
|
||||
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") " $1 > output
|
||||
print "@("uname","gname","mode","flags") " $1 > output
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user