Package: libnss-mdns
Version: 0.8-4.1
Severity: important
Tags: patch

As requested in the README.Debian, here's a patch that mangles
nsswitch.conf. It takes care to only touch it on fresh install, upgrade
from <= 0.8.4.1, or purge, so if an admin wants to modify or remove the
mdns entries, their wishes will be followed.  It will also deal with the
case where an admin has already customised /etc/nsswitch.conf (adding
some mdns entry to it), and avoid overriding their changes in this case.

I've tested this as extensively as I can with all kinds of installation,
upgrade, removal, purging, etc scenarios. Note that one of these
scenarios (reinstalling after removal) is why it only removes the
entries when purged, rather than when it's removed. Otherwise, when it's
reinstalled, it wouldn't put them back since there's no way to detect this
particular case in the postinst or preinst.

Sorry about the embedded perl but it seemed the most robust way to
modify the line.

I'm flagging this as important since without it, tasksel can't offer
debian systems that support zeroconf stuff out of the box, which I
really want to see happen, one way or another.

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.17-2-686
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)

Versions of packages libnss-mdns depends on:
ii  libc6                        2.3.6.ds1-4 GNU C Library: Shared libraries

Versions of packages libnss-mdns recommends:
pn  zeroconf                      <none>     (no description available)

-- no debconf information

-- 
see shy jo
diff --new-file -ur old/nss-mdns-0.8/debian/README.Debian 
nss-mdns-0.8/debian/README.Debian
--- old/nss-mdns-0.8/debian/README.Debian       2006-09-22 21:25:56.000000000 
-0400
+++ nss-mdns-0.8/debian/README.Debian   2006-09-22 21:48:21.000000000 -0400
@@ -2,19 +2,15 @@
 MODIFYING /etc/nsswitch.conf
 ----------------------------
 
-Previously the base-files package shipped /etc/nsswitch.conf and specified:
-
-hosts:          files dns mdns
-
-However, due to bug#351990, this is no longer the case. /etc/nsswitch.conf
-is now generated post-installation. At this time this package does not
-modify /etc/nsswitch.conf (it will in future -- patches welcome).
-
-This means that, for now, you should modify /etc/nsswitch.conf yourself
-and set the hosts: line to be:
+/etc/nsswitch.conf is modified when this package is installed, to make mdns
+be used. The hosts line is changed to look like this:
 
 hosts: files mdns_minimal dns mdns
 
+If you prefer a different setup, you can modify this line, and your changes
+will be preserved. If this package is purged, the mdns items will be
+removed from the hosts line.
+
 WHAT ABOUT UPSTREAM?
 --------------------
 
diff --new-file -ur old/nss-mdns-0.8/debian/changelog 
nss-mdns-0.8/debian/changelog
--- old/nss-mdns-0.8/debian/changelog   2006-09-22 21:25:56.000000000 -0400
+++ nss-mdns-0.8/debian/changelog       2006-09-22 21:37:17.000000000 -0400
@@ -1,3 +1,15 @@
+nss-mdns (0.8-4.2) UNRELEASED; urgency=low
+
+  * Add postinst that will add mdns entries to /etc/nsswitch.conf on new
+    installs and on upgrades from the previous version.
+  * Add postrm to remove mdns entries from /etc/nsswitch.conf when the package
+    is removed.
+  * Local modifications to the file will be preserved accross upgrades.
+  * Depend on base-files 3.1.10 or higher to get a nsswitch.conf that is not a
+    conffile and that doesn't have mdns entries from base-files in it.
+
+ -- Joey Hess <[EMAIL PROTECTED]>  Fri, 22 Sep 2006 21:10:25 -0400
+
 nss-mdns (0.8-4.1) unstable; urgency=low
 
   * NMU
diff --new-file -ur old/nss-mdns-0.8/debian/control nss-mdns-0.8/debian/control
--- old/nss-mdns-0.8/debian/control     2006-09-22 21:25:56.000000000 -0400
+++ nss-mdns-0.8/debian/control 2006-09-22 21:36:37.000000000 -0400
@@ -10,7 +10,7 @@
 Recommends: zeroconf
 Suggests: avahi-daemon
 Architecture: any
-Depends: ${shlibs:Depends}
+Depends: ${shlibs:Depends}, base-files (>= 3.1.10)
 Description: NSS module for Multicast DNS name resolution
  nss-mdns is a plugin for the GNU Name Service Switch (NSS) functionality
  of the GNU C Library (glibc) providing host name resolution via Multicast
diff --new-file -ur old/nss-mdns-0.8/debian/postinst 
nss-mdns-0.8/debian/postinst
--- old/nss-mdns-0.8/debian/postinst    1969-12-31 19:00:00.000000000 -0500
+++ nss-mdns-0.8/debian/postinst        2006-09-22 21:51:53.000000000 -0400
@@ -0,0 +1,22 @@
+#!/bin/sh
+set -e
+#DEBHELPER#
+
+if [ "$1" = configure ] && [ -e /etc/nsswitch.conf ]; then
+       if [ -z "$2" ] || dpkg --compare-versions "$2" le 0.8-4.1; then
+               perl -i -pe '
+                       sub insert {
+                               my @bits=split(" ", shift);
+                               if (grep { $_ eq "mdns_minimal" || $_ eq "mdns" 
} @bits) {
+                                       return join " ", @bits;
+                               }
+                               @bits = map {
+                                       $_ eq "files" ? ($_,"mdns_minimal") : $_
+                               } @bits;
+                               push @bits, "mdns";
+                               return join " ", @bits;
+                       }
+                       s/^(hosts:\s+)(.*)/$1.insert($2)/e;
+               ' /etc/nsswitch.conf
+       fi
+fi
diff --new-file -ur old/nss-mdns-0.8/debian/postrm nss-mdns-0.8/debian/postrm
--- old/nss-mdns-0.8/debian/postrm      1969-12-31 19:00:00.000000000 -0500
+++ nss-mdns-0.8/debian/postrm  2006-09-22 21:48:08.000000000 -0400
@@ -0,0 +1,14 @@
+#!/bin/sh
+set -e
+#DEBHELPER#
+
+if [ "$1" = purge ] && [ -e /etc/nsswitch.conf ]; then
+       perl -i -pe '
+               sub remove {
+                       my @bits=grep { $_ ne "mdns_minimal" && $_ ne "mdns" }
+                               split(" ", shift);
+                       return join " ", @bits;
+               }
+               s/^(hosts:\s+)(.*)/$1.remove($2)/e;
+       ' /etc/nsswitch.conf
+fi

Attachment: signature.asc
Description: Digital signature

Reply via email to