nfs-utils: fix a number of specfile problems

The package review for RHEL7 turned up a number of problems with the
current nfs-utils specfile. This patch aims to fix most of them:

- Swap out hardcoded paths for macros that are defined for this purpose
- Move the systemd preconfig/postconfig scripts to /usr/libexec
- Fix URL for Source0
- add directives to clean out $RPM_BUILD_ROOT in %install and %clean
- add a %defattr() directive to ensure that all files are owned by root
- get rid bogus %attr() settings on symlinks

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
This commit is contained in:
Jeff Layton 2013-08-22 14:10:25 -04:00 committed by Steve Dickson
parent 67a1db49aa
commit d87e9cb3d6
3 changed files with 78 additions and 67 deletions

View File

@ -8,7 +8,7 @@ Before=remote-fs-pre.target
Type=forking Type=forking
StandardError=syslog+console StandardError=syslog+console
EnvironmentFile=-/etc/sysconfig/nfs EnvironmentFile=-/etc/sysconfig/nfs
ExecStartPre=/usr/lib/nfs-utils/scripts/nfs-lock.preconfig ExecStartPre=/usr/libexec/nfs-utils/scripts/nfs-lock.preconfig
ExecStart=/sbin/rpc.statd $STATDARG ExecStart=/sbin/rpc.statd $STATDARG
# Make sure lockd's ports are reset # Make sure lockd's ports are reset
ExecStopPost=-/sbin/sysctl -w fs.nfs.nlm_tcpport=0 fs.nfs.nlm_udpport=0 ExecStopPost=-/sbin/sysctl -w fs.nfs.nlm_tcpport=0 fs.nfs.nlm_udpport=0

View File

@ -9,10 +9,10 @@ Type=oneshot
RemainAfterExit=yes RemainAfterExit=yes
StandardError=syslog+console StandardError=syslog+console
EnvironmentFile=-/etc/sysconfig/nfs EnvironmentFile=-/etc/sysconfig/nfs
ExecStartPre=/usr/lib/nfs-utils/scripts/nfs-server.preconfig ExecStartPre=/usr/libexec/nfs-utils/scripts/nfs-server.preconfig
ExecStartPre=/usr/sbin/exportfs -r ExecStartPre=/usr/sbin/exportfs -r
ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS $RPCNFSDCOUNT ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS $RPCNFSDCOUNT
ExecStartPost=-/usr/lib/nfs-utils/scripts/nfs-server.postconfig ExecStartPost=-/usr/libexec/nfs-utils/scripts/nfs-server.postconfig
ExecStop=/usr/sbin/rpc.nfsd 0 ExecStop=/usr/sbin/rpc.nfsd 0
ExecStopPost=/usr/sbin/exportfs -f ExecStopPost=/usr/sbin/exportfs -f
ExecReload=/usr/sbin/exportfs -r ExecReload=/usr/sbin/exportfs -r

View File

@ -2,13 +2,13 @@ Summary: NFS utilities and supporting clients and daemons for the kernel NFS ser
Name: nfs-utils Name: nfs-utils
URL: http://sourceforge.net/projects/nfs URL: http://sourceforge.net/projects/nfs
Version: 1.2.8 Version: 1.2.8
Release: 4.0%{?dist} Release: 4.1%{?dist}
Epoch: 1 Epoch: 1
# group all 32bit related archs # group all 32bit related archs
%define all_32bit_archs i386 i486 i586 i686 athlon ppc sparcv9 %define all_32bit_archs i386 i486 i586 i686 athlon ppc sparcv9
Source0: http://www.kernel.org/pub/linux/utils/nfs-utils/%{name}-%{version}.tar.bz2 Source0: http://sourceforge.net/projects/nfs/files/nfs-utils/%{version}/%{name}-%{version}.tar.bz2
Source9: id_resolver.conf Source9: id_resolver.conf
Source10: nfs.sysconfig Source10: nfs.sysconfig
@ -127,62 +127,69 @@ CFLAGS="`echo $RPM_OPT_FLAGS $ARCH_OPT_FLAGS $PIE -D_FILE_OFFSET_BITS=64`"
make %{?_smp_mflags} all make %{?_smp_mflags} all
%install %install
mkdir -p $RPM_BUILD_ROOT{/sbin,/usr/sbin,/lib/systemd/system} rm -rf $RPM_BUILD_ROOT/*
mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system/nfs.target.wants
mkdir -p $RPM_BUILD_ROOT/usr/lib/%{name}/scripts mkdir -p $RPM_BUILD_ROOT%/sbin
mkdir -p $RPM_BUILD_ROOT%{_sbindir}
mkdir -p $RPM_BUILD_ROOT%{_unitdir}
mkdir -p $RPM_BUILD_ROOT%{_unitdir}/nfs.target.wants
mkdir -p $RPM_BUILD_ROOT%{_libexecdir}/%{name}/scripts
mkdir -p ${RPM_BUILD_ROOT}%{_mandir}/man8 mkdir -p ${RPM_BUILD_ROOT}%{_mandir}/man8
mkdir -p $RPM_BUILD_ROOT/etc/sysconfig mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
mkdir -p $RPM_BUILD_ROOT/etc/request-key.d mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/request-key.d
mkdir -p $RPM_BUILD_ROOT/lib/modprobe.d/ mkdir -p $RPM_BUILD_ROOT/lib/modprobe.d/
make DESTDIR=$RPM_BUILD_ROOT install make DESTDIR=$RPM_BUILD_ROOT install
install -s -m 755 tools/rpcdebug/rpcdebug $RPM_BUILD_ROOT/usr/sbin install -s -m 755 tools/rpcdebug/rpcdebug $RPM_BUILD_ROOT%{_sbindir}
install -m 644 utils/mount/nfsmount.conf $RPM_BUILD_ROOT/etc install -m 644 utils/mount/nfsmount.conf $RPM_BUILD_ROOT%{_sysconfdir}
install -m 644 %{SOURCE9} $RPM_BUILD_ROOT/etc/request-key.d install -m 644 %{SOURCE9} $RPM_BUILD_ROOT%{_sysconfdir}/request-key.d
install -m 644 %{SOURCE10} $RPM_BUILD_ROOT/etc/sysconfig/nfs install -m 644 %{SOURCE10} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/nfs
for service in %{nfs_services} ; do for service in %{nfs_services} ; do
install -m 644 $service $RPM_BUILD_ROOT/lib/systemd/system install -m 644 $service $RPM_BUILD_ROOT%{_unitdir}
done done
for service in %{nfs_automounts} ; do for service in %{nfs_automounts} ; do
install -m 644 $service $RPM_BUILD_ROOT/lib/systemd/system install -m 644 $service $RPM_BUILD_ROOT%{_unitdir}
done done
for config in %{nfs_configs} ; do for config in %{nfs_configs} ; do
install -m 755 $config $RPM_BUILD_ROOT/usr/lib/%{name}/scripts install -m 755 $config $RPM_BUILD_ROOT%{_libexecdir}/%{name}/scripts
done done
cd $RPM_BUILD_ROOT/lib/systemd/system cd $RPM_BUILD_ROOT%{_unitdir}
ln -s nfs-idmap.service rpcidmapd.service ln -s nfs-idmap.service rpcidmapd.service
ln -s nfs-lock.service nfslock.service ln -s nfs-lock.service nfslock.service
ln -s nfs-secure-server.service rpcsvcgssd.service ln -s nfs-secure-server.service rpcsvcgssd.service
ln -s nfs-secure.service rpcgssd.service ln -s nfs-secure.service rpcgssd.service
ln -s nfs-server.service nfs.service ln -s nfs-server.service nfs.service
mkdir -p $RPM_BUILD_ROOT/var/lib/nfs/rpc_pipefs mkdir -p $RPM_BUILD_ROOT%{_sharedstatedir}/nfs/rpc_pipefs
touch $RPM_BUILD_ROOT/var/lib/nfs/rmtab touch $RPM_BUILD_ROOT%{_sharedstatedir}/nfs/rmtab
mv $RPM_BUILD_ROOT/usr/sbin/rpc.statd $RPM_BUILD_ROOT/sbin mv $RPM_BUILD_ROOT%{_sbindir}/rpc.statd $RPM_BUILD_ROOT/sbin
mkdir -p $RPM_BUILD_ROOT/var/lib/nfs/statd/sm mkdir -p $RPM_BUILD_ROOT%{_sharedstatedir}/nfs/statd/sm
mkdir -p $RPM_BUILD_ROOT/var/lib/nfs/statd/sm.bak mkdir -p $RPM_BUILD_ROOT%{_sharedstatedir}/nfs/statd/sm.bak
mkdir -p $RPM_BUILD_ROOT/var/lib/nfs/v4recovery mkdir -p $RPM_BUILD_ROOT%{_sharedstatedir}/nfs/v4recovery
mkdir -p $RPM_BUILD_ROOT/etc/exports.d mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/exports.d
%clean
rm -rf $RPM_BUILD_ROOT/*
%pre %pre
# move files so the running service will have this applied as well # move files so the running service will have this applied as well
for x in gssd svcgssd idmapd ; do for x in gssd svcgssd idmapd ; do
if [ -f /var/lock/subsys/rpc.$x ]; then if [ -f /var/lock/subsys/rpc.$x ]; then
mv /var/lock/subsys/rpc.$x /var/lock/subsys/rpc$x mv /var/lock/subsys/rpc.$x /var/lock/subsys/rpc$x
fi fi
done done
/usr/sbin/useradd -l -c "RPC Service User" -r \ /usr/sbin/useradd -l -c "RPC Service User" -r \
-s /sbin/nologin -u 29 -d /var/lib/nfs rpcuser 2>/dev/null || : -s /sbin/nologin -u 29 -d /var/lib/nfs rpcuser 2>/dev/null || :
/usr/sbin/groupadd -g 29 rpcuser 2>/dev/null || : /usr/sbin/groupadd -g 29 rpcuser 2>/dev/null || :
# Using the 16-bit value of -2 for the nfsnobody uid and gid # Using the 16-bit value of -2 for the nfsnobody uid and gid
%define nfsnobody_uid 65534 %define nfsnobody_uid 65534
# Create nfsnobody gid as long as it does not already exist # Create nfsnobody gid as long as it does not already exist
cat /etc/group | cut -d':' -f 1 | grep --quiet nfsnobody 2>/dev/null cat /etc/group | cut -d':' -f 1 | grep --quiet nfsnobody 2>/dev/null
@ -196,7 +203,7 @@ fi
cat /etc/passwd | cut -d':' -f 1 | grep --quiet nfsnobody 2>/dev/null cat /etc/passwd | cut -d':' -f 1 | grep --quiet nfsnobody 2>/dev/null
if [ "$?" -eq 1 ]; then if [ "$?" -eq 1 ]; then
/usr/sbin/useradd -l -c "Anonymous NFS User" -r -g %{nfsnobody_uid} \ /usr/sbin/useradd -l -c "Anonymous NFS User" -r -g %{nfsnobody_uid} \
-s /sbin/nologin -u %{nfsnobody_uid} -d /var/lib/nfs nfsnobody 2>/dev/null || : -s /sbin/nologin -u %{nfsnobody_uid} -d /var/lib/nfs nfsnobody 2>/dev/null || :
else else
/usr/sbin/usermod -u %{nfsnobody_uid} -g %{nfsnobody_uid} nfsnobody 2>/dev/null || : /usr/sbin/usermod -u %{nfsnobody_uid} -g %{nfsnobody_uid} nfsnobody 2>/dev/null || :
@ -238,7 +245,7 @@ fi
if [ $1 -ge 1 ]; then if [ $1 -ge 1 ]; then
# Package upgrade, not uninstall # Package upgrade, not uninstall
for service in %(sed 's!\S*/!!g' <<< '%{nfs_start_services}') ; do for service in %(sed 's!\S*/!!g' <<< '%{nfs_start_services}') ; do
/bin/systemctl try-restart $service >/dev/null 2>&1 || : /bin/systemctl try-restart $service >/dev/null 2>&1 || :
done done
fi fi
/bin/systemctl --system daemon-reload >/dev/null 2>&1 || : /bin/systemctl --system daemon-reload >/dev/null 2>&1 || :
@ -256,54 +263,58 @@ if /sbin/chkconfig --level 3 rpcsvcgssd ; then
fi fi
%files %files
%defattr(-,root,root,-)
%config(noreplace) /etc/sysconfig/nfs %config(noreplace) /etc/sysconfig/nfs
%config(noreplace) /etc/nfsmount.conf %config(noreplace) /etc/nfsmount.conf
%dir /etc/exports.d %dir %{_sysconfdir}/exports.d
%dir /var/lib/nfs/v4recovery %dir %{_sharedstatedir}/nfs/v4recovery
%dir /var/lib/nfs/rpc_pipefs %dir %{_sharedstatedir}/nfs/rpc_pipefs
%dir /var/lib/nfs %dir %{_sharedstatedir}/nfs
%dir /usr/lib/%{name}/scripts %dir %{_libexecdir}/%{name}/scripts
%dir /usr/lib/%{name} %dir %{_libexecdir}/%{name}
%dir %attr(700,rpcuser,rpcuser) /var/lib/nfs/statd %dir %attr(700,rpcuser,rpcuser) %{_sharedstatedir}/nfs/statd
%dir %attr(700,rpcuser,rpcuser) /var/lib/nfs/statd/sm %dir %attr(700,rpcuser,rpcuser) %{_sharedstatedir}/nfs/statd/sm
%dir %attr(700,rpcuser,rpcuser) /var/lib/nfs/statd/sm.bak %dir %attr(700,rpcuser,rpcuser) %{_sharedstatedir}/nfs/statd/sm.bak
%config(noreplace) %attr(644,rpcuser,rpcuser) /var/lib/nfs/state %config(noreplace) %attr(644,rpcuser,rpcuser) %{_sharedstatedir}/nfs/state
%config(noreplace) /var/lib/nfs/xtab %config(noreplace) %{_sharedstatedir}/nfs/xtab
%config(noreplace) /var/lib/nfs/etab %config(noreplace) %{_sharedstatedir}/nfs/etab
%config(noreplace) /var/lib/nfs/rmtab %config(noreplace) %{_sharedstatedir}/nfs/rmtab
%config(noreplace) %{_sysconfdir}/request-key.d/id_resolver.conf %config(noreplace) %{_sysconfdir}/request-key.d/id_resolver.conf
%doc linux-nfs/ChangeLog linux-nfs/KNOWNBUGS linux-nfs/NEW linux-nfs/README %doc linux-nfs/ChangeLog linux-nfs/KNOWNBUGS linux-nfs/NEW linux-nfs/README
%doc linux-nfs/THANKS linux-nfs/TODO %doc linux-nfs/THANKS linux-nfs/TODO
/sbin/rpc.statd /sbin/rpc.statd
/sbin/osd_login /sbin/osd_login
/usr/sbin/exportfs %{_sbindir}/exportfs
/usr/sbin/nfsstat %{_sbindir}/nfsstat
/usr/sbin/rpcdebug %{_sbindir}/rpcdebug
/usr/sbin/rpc.mountd %{_sbindir}/rpc.mountd
/usr/sbin/rpc.nfsd %{_sbindir}/rpc.nfsd
/usr/sbin/showmount %{_sbindir}/showmount
/usr/sbin/rpc.idmapd %{_sbindir}/rpc.idmapd
/usr/sbin/rpc.gssd %{_sbindir}/rpc.gssd
/usr/sbin/rpc.svcgssd %{_sbindir}/rpc.svcgssd
/usr/sbin/gss_clnt_send_err %{_sbindir}/gss_clnt_send_err
/usr/sbin/gss_destroy_creds %{_sbindir}/gss_destroy_creds
/usr/sbin/sm-notify %{_sbindir}/sm-notify
/usr/sbin/start-statd %{_sbindir}/start-statd
/usr/sbin/mountstats %{_sbindir}/mountstats
/usr/sbin/nfsiostat %{_sbindir}/nfsiostat
/usr/sbin/nfsidmap %{_sbindir}/nfsidmap
/usr/sbin/blkmapd %{_sbindir}/blkmapd
/usr/sbin/nfsdcltrack %{_sbindir}/nfsdcltrack
%{_mandir}/*/* %{_mandir}/*/*
/lib/systemd/system/* %{_unitdir}/*
/usr/lib/%{name}/scripts/* %{_libexecdir}/%{name}/scripts/*
%attr(4755,root,root) /sbin/mount.nfs %attr(4755,root,root) /sbin/mount.nfs
%attr(4755,root,root) /sbin/mount.nfs4 /sbin/mount.nfs4
%attr(4755,root,root) /sbin/umount.nfs /sbin/umount.nfs
%attr(4755,root,root) /sbin/umount.nfs4 /sbin/umount.nfs4
%changelog %changelog
* Thu Aug 22 2013 Steve Dickson <steved@redhat.com> 1.2.8-4.1
- nfs-utils: fix a number of specfile problems
* Mon Aug 19 2013 Steve Dickson <steved@redhat.com> 1.2.8-4.0 * Mon Aug 19 2013 Steve Dickson <steved@redhat.com> 1.2.8-4.0
- Updated to latest upstream RC release: nfs-utils-1-2-9-rc4 - Updated to latest upstream RC release: nfs-utils-1-2-9-rc4