pacutils
pacutils copied to clipboard
Allow pacini to merge sections
For a little background to this I've taken to using pacini
for generate an /etc/pacreport.conf
based on files found in /etc/pacreport.d
.
The current code for doing this looks like the following:
#!/bin/sh --
# gen-pacreport - generate /etc/pacreport.conf from files in /etc/pacreport.d
# requires pacutils
tmp=$(mktemp gen-pacreport-XXXX)
trap 'rm -f -- "$tmp"' EXIT
find /etc/pacreport.d -type f -name '*.conf' -exec cat {} + > "$tmp"
# shellcheck disable=SC2094
pacini - --section-list < "$tmp" | sort -u | while read -r section; do
printf '[%s]\n' "$section"
pacini - --section="$section" < "$tmp"
done > /etc/pacreport.conf
However, it would be more ideal if pacini
merged sections such that I wouldn't need to use sort -u
. In fact if pacini - < "$tmp"
merged sections then it would obviate much of this script. The result could only be:
find /etc/pacreport.d -type f -name '*.conf' -exec cat {} + | pacini - > /etc/pacreport.conf
Currently pacini
retains the section headers:
% cat /etc/pacreport.d/*.conf | pacini -
[Options]
IgnoreUnowned = boot/memdisk
[PkgIgnoreUnowned]
dictd = usr/share/dict/words
[PkgIgnoreUnowned]
docbook-xml = etc/xml/catalog
[PkgIgnoreUnowned]
e2fsprogs = lost+found
[PkgIgnoreUnowned]
freeradius = etc/raddb
freeradius = var/lib/radiusd
Where ideally it would return:
% cat /etc/pacreport.d/*.conf | pacini -
[Options]
IgnoreUnowned = boot/memdisk
[PkgIgnoreUnowned]
dictd = usr/share/dict/words
docbook-xml = etc/xml/catalog
e2fsprogs = lost+found
freeradius = etc/raddb
freeradius = var/lib/radiusd
PS: I'm aware that duplicate sections is likely not an issue for pacreport
but it doesn't look as beautiful.
cc @Foxboron