- use sed instead of perl in scriptlets (#462996)

- consequently, removed the Requires(..): perl
- removed the reqires for things that are granted
- a better BuildRoot
epel8
Štěpán Kasal 17 years ago
parent 017e453c13
commit 9e946e1fbd

@ -1,19 +1,12 @@
Summary: glibc plugin for .local name resolution
Name: nss-mdns
Version: 0.10
Release: 5%{?dist}
Release: 6%{?dist}
License: LGPLv2+
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
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
Requires: avahi
%description
@ -44,48 +37,19 @@ rm -rf $RPM_BUILD_ROOT
/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
sed -i.bak '
/^hosts:/ !b
/\<mdns\(4\|6\)\?\(_minimal\)\?\>/ b
s/\([[:blank:]]\+\)dns\>/\1mdns4_minimal [NOTFOUND=return] dns/g
' /etc/nsswitch.conf
fi
%preun
# Perl-fu to remove mdns4_minimal from the hosts line of /etc/nsswitch.conf
# sed-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;
sed -i.bak '
/^hosts:/ !b
s/[[:blank:]]\+mdns\(4\|6\)\?\(_minimal\( \[NOTFOUND=return\]\)\?\)\?//g
' /etc/nsswitch.conf
fi
@ -97,6 +61,15 @@ fi
/%{_lib}/*
%changelog
* Tue Sep 30 2008 Stepan Kasal <skasal@redhat.com> - 0.10-6
- use sed instead of perl in %%post and %%preun (#462996),
fixing two bugs in the scriptlets:
1) the backup file shall be nsswitch.conf.bak, not nsswitch.confbak
2) the first element after host: shall be subject to removal, too
- consequently, removed the Requires(..): perl
- removed the reqires for things that are granted
- a better BuildRoot
* Mon Aug 11 2008 Tom "spot" Callaway <tcallawa@redhat.com> - 0.10-5
- fix license tag

Loading…
Cancel
Save