Skip to contentSkip to conversation

libnss-mdns: fix postinst and postrm

PATCH New Dan McGregor 1 participant 1 message May 16, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libnss-mdns: fix postinst and postrm

From: Dan McGregor <[email protected]>

Don't blindly add mdns_minimal, instead check for existing mdns_minimal instances. Fixes continuously appending mdns settings to nssswitch.conf when upgrading.

---
 .../libnss-mdns/libnss-mdns_0.10.bb               | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
meta/recipes-connectivity/libnss-mdns/libnss-mdns_0.10.bb +9 -6
index 8d2feec7698..5be5e4fa323 100644
@@ -28,13 +28,16 @@ DEBIANNAME_${PN} = "libnss-mdns"
 RDEPENDS_${PN} = "avahi-daemon"
 
 pkg_postinst_${PN} () {
-	sed -e '/^hosts:/s/\s*\<mdns\>//' \
-		-e 's/\(^hosts:.*\)\(\<files\>\)\(.*\)\(\<dns\>\)\(.*\)/\1\2 mdns4_minimal [NOTFOUND=return]\3\4 mdns\5/' \
-		-i $D${sysconfdir}/nsswitch.conf
+	sed '
+		/^hosts:/ !b
+		/\<mdns\(4\|6\)\?\(_minimal\)\?\>/ b
+		s/\([[:blank:]]\+\)dns\>/\1mdns4_minimal [NOTFOUND=return] dns/g
+		' -i $D${sysconfdir}/nsswitch.conf
 }
 
 pkg_prerm_${PN} () {
-	sed -e '/^hosts:/s/\s*\<mdns\>//' \
-		-e '/^hosts:/s/\s*mdns4_minimal\s\+\[NOTFOUND=return\]//' \
-		-i $D${sysconfdir}/nsswitch.conf
+	sed '
+		/^hosts:/ !b
+		s/[[:blank:]]\+mdns\(4\|6\)\?\(_minimal\( \[NOTFOUND=return\]\)\?\)\?//g
+		' -i $D${sysconfdir}/nsswitch.conf
 }
Signature · 1 line
2.18.0-dev