resolved: use DPKG_ROOT and make postinst shellcheck-happy

This commit is contained in:
Luca Boccassi 2022-08-21 02:01:40 +01:00
parent 7129300f3c
commit 68f64dc69a

View File

@ -6,15 +6,15 @@ _adopt_conffile() {
conffile=$1
pkg=$2
[ -f ${conffile}.dpkg-bak ] || return 0
[ -f "${conffile}.dpkg-bak" ] || return 0
md5sum="$(md5sum ${conffile} | sed -e 's/ .*//')"
old_md5sum="$(dpkg-query -W -f='${Conffiles}' $pkg | \
md5sum="$(md5sum "${conffile}" | sed -e 's/ .*//')"
old_md5sum="$(dpkg-query -W -f='${Conffiles}' "$pkg" | \
sed -n -e "\' ${conffile} ' { s/ obsolete$//; s/.* //; p }")"
# On new installs, if the policy file was preserved on systemd upgrade
# by dpkg-maintscript helper, copy it back if the new file has not been modified yet
if [ "$md5sum" = "$old_md5sum" ]; then
mv ${conffile}.dpkg-bak ${conffile}
mv "${conffile}.dpkg-bak" "${conffile}"
fi
}
@ -22,7 +22,7 @@ _adopt_conffile() {
if [ "$1" = configure ] && [ -z "$2" ]; then
adduser --quiet --system --group --no-create-home --home /run/systemd \
--gecos "systemd Resolver" systemd-resolve
_adopt_conffile /etc/systemd/resolved.conf systemd-resolved
_adopt_conffile "${DPKG_ROOT}/etc/systemd/resolved.conf" systemd-resolved
fi
#DEBHELPER#