freebsd-dev/release/scripts/mtree-to-plist.awk
Emmanuel Vadot c016c89196 pkgbase: Move device.hints from the runtime to the bootloader package
Also mark it as config file so if a user changes this file pkg will attempt
to merge the new file upon an update.
device.hints is neither related to runtime or loader but it make more sense
to have it in loader in case some user delete /boot/ and wants to recreate it,
now only two packages are required FreeBSD-bootloader and the kernel package.
While here change where we override the package for files installed in /boot,
this allow us to keep other tags (such as config).

Reported by:	pizzamig
Reviewed by:	bapt pizzamig emaste
Differential Revision:	https://reviews.freebsd.org/D24159
2020-03-24 01:07:01 +00:00

83 lines
1.6 KiB
Awk

#!/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 (kernel != "") {
tags="package=kernel"
if (_kernconf != "") {
tags=tags""_kernconf
}
}
if (length(tags) == 0)
next
if (tags ~ /package=/) {
ext = pkgname = pkgend = ""
split(tags, a, ",");
for (i in a) {
if (a[i] ~ /^package=/) {
pkgname=a[i]
if ($1 ~ /^\/boot\//)
pkgname="bootloader"
gsub(/package=/, "", pkgname)
} else if (a[i] == "config") {
type="config"
} else if (a[i] == "development" || a[i] == "profile" || a[i] == "debug" || a[i] == "docs") {
pkgend=a[i]
} else {
if (ext != "")
ext=ext"-"a[i]
else
ext=a[i]
}
}
if (ext != "") {
pkgname=pkgname"-"ext
}
if (pkgend != "") {
if (pkgend == "docs") {
pkgname=pkgend
} else {
pkgname=pkgname"-"pkgend
}
}
} else {
print "No packages specified in line: $0"
next
}
if (kernel != "") {
output="kernel"
if (_kernconf != "") {
output=output"."_kernconf
}
if ($1 ~ /^\/usr\/lib\/debug\/boot/) {
output=output"-debug.plist"
} else {
output=output".plist"
}
} else {
output=pkgname".plist"
}
print "@"type"("uname","gname","mode","flags") " $1 > output
}