Blob Blame History Raw
Summary: glibc plugin for .local name resolution
Name: nss-mdns
Version: 0.10
Release: 2%{?dist}
License: LGPL 
URL: http://0pointer.de/lennart/projects/nss-mdns/
Group: System Environment/Libraries
Source: http://0pointer.de/lennart/projects/nss-mdns/nss-mdns-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot 
BuildRequires: glibc-devel
Requires(post): /bin/sh
Requires(preun): /bin/sh
Requires(post): perl
Requires(preun): perl
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
Requires: avahi
 
%description
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 DNS
(aka Zeroconf, aka Apple Rendezvous, aka Apple Bonjour), effectively allowing 
name resolution by common Unix/Linux programs in the ad-hoc mDNS domain .local.

nss-mdns provides client functionality only, which means that you have to
run a mDNS responder daemon separately from nss-mdns if you want to register
the local host name via mDNS (e.g. Avahi).

%prep
%setup -q

%build
%configure --libdir=/%{_lib} --enable-avahi=yes --enable-legacy=no
make %{?_smp_mflags}

%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install

%clean
rm -rf $RPM_BUILD_ROOT

%post
/sbin/ldconfig
# Perl-fu to add mdns4_minimal to the hosts line of /etc/nsswitch.conf
if [ -f /etc/nsswitch.conf ] ; then
	perl -ibak -pe '
		sub insert {
			my @bits = split(" ", shift);
		
			if (grep { $_ eq "mdns4_minimal" || $_ eq "mdns4"
				|| $_ eq "mdns6_minimal" || $_ eq "mdns6"
				|| $_ eq "mdns_minimal" || $_ eq "mdns" } @bits) {
				return join " ", @bits;
			}
			
			return join " ", map {
				$_ eq "dns" ? ("mdns4_minimal", "[NOTFOUND=return]", $_) : $_
			} @bits;
		}

		s/^(hosts:\s+)(.*)$/$1.insert($2)/e;
	' /etc/nsswitch.conf
fi

%preun
# Perl-fu to remove mdns4_minimal from the hosts line of /etc/nsswitch.conf
if [ "$1" -eq 0 -a -f /etc/nsswitch.conf ] ; then
	perl -ibak -pe '
		my @remove = (
			"mdns4_minimal [NOTFOUND=return]",
			"mdns4_minimal",
			"mdns4",
			"mdns6_minimal [NOTFOUND=return]",
			"mdns6_minimal",
			"mdns6",
			"mdns_minimal [NOTFOUND=return]",
			"mdns_minimal",
			"mdns",
		);
		sub remove {
			my $s = shift;
			foreach my $bit (@remove) {
				$s =~ s/\s+\Q$bit\E//g;
			}
			return $s;
		}
		s/^(hosts:\s+)(.*)$/$1.remove($2)/e;
	' /etc/nsswitch.conf
fi

%postun -p /sbin/ldconfig

%files
%defattr(-, root, root)
%doc README
/%{_lib}/*

%changelog
* Fri Jun 22 2007 - Lennart Poettering <lpoetter@redhat.com> - 0.10-2
- Fix up post/preun/postun dependencies, add "avahi" to the dependencies, 
  include dist tag in Release field, use _lib directory instead of literal /lib.

* Fri Jun 22 2007 - Lennart Poettering <lpoetter@redhat.com> - 0.10-1
- Update to 0.10, replace perl script by simpler and more robust versions,
  stolen from the Debian package

* Thu Jul 13 2006 - Bastien Nocera <hadess@hadess.net> - 0.8-2
- Make use of Ezio's perl scripts to enable and disable mdns4 lookups
  automatically, patch from Pancrazio `Ezio' de Mauro <pdemauro@redhat.com>

* Tue May 02 2006 - Bastien Nocera <hadess@hadess.net> - 0.8-1
- Update to 0.8, disable legacy lookups so that all lookups are made through
  the Avahi daemon

* Mon Apr 24 2006 - Bastien Nocera <hadess@hadess.net> - 0.7-2
- Fix building on 64-bit platforms

* Tue Dec 13 2005 - Bastien Nocera <hadess@hadess.net> - 0.7-1
- Update to 0.7, fix some rpmlint errors

* Thu Nov 10 2005 - Bastien Nocera <hadess@hadess.net> - 0.6-1
- Update to 0.6

* Tue Dec 07 2004 - Bastien Nocera <hadess@hadess.net> 0.1-1
- Initial package, automatically adds and remove mdns4 as a hosts service