Enable and fix nscd

Let's build this package so that those who need it could install it.
nscd.socket does not exist in upstream any more, so do not install it
(I doubt it is useful).
Lua is not needed in scriptlets, use plain shell.
Do not own files from tmpfs /run (%%_rundir), it is useless.
This commit is contained in:
Mikhail Novosyolov 2023-01-10 12:38:00 +03:00
parent 2b457fad7c
commit 5139146b49

View file

@ -91,7 +91,7 @@
%define build_biarch 1
%endif
%bcond_with nscd
%bcond_without nscd
%bcond_without i18ndata
%bcond_with timezone
%bcond_with locales
@ -1052,42 +1052,28 @@ library.
%package -n nscd
Summary: A Name Service Caching Daemon (nscd)
Group: System/Servers
Conflicts: kernel < 2.2.0
BuildRequires: rpm-helper
Requires(post): systemd
Requires(pre): shadow
%description -n nscd
Nscd caches name service lookups and can dramatically improve
performance with NIS+, and may help with DNS as well.
%pre -n nscd -p <lua>
user = os.execute("/usr/bin/getent passwd nscd >/dev/null 2>&1")
if user ~= 0 then
os.execute("/usr/sbin/useradd -r -M -U -s /sbin/nologin -d / -c 'system user for nscd' nscd >/dev/null 2>&1")
end
%post -n nscd
# nscd user pre-exists in the "setup" package,
# so not creating it here
%systemd_post nscd.service
%{_sbindir}/nscd -i passwd -i group || :
%post -n nscd -p <lua>
os.execute("/usr/sbin/nscd -i passwd -i group >/dev/null 2>&1")
os.execute("/bin/systemctl preset --now nscd.socket >/dev/null 2>&1")
os.execute("/bin/systemctl preset --now nscd.service >/dev/null 2>&1")
%preun -n nscd
%systemd_preun nscd.service
%files -n nscd
%config(noreplace) %{_sysconfdir}/nscd.conf
%dir %attr(0755,root,root) /run/nscd
%dir %attr(0755,root,root) %{_var}/db/nscd
%dir %attr(0755,root,root) %{_sysconfdir}/netgroup
%{_presetdir}/86-nscd.preset
%{_unitdir}/nscd.service
%{_unitdir}/nscd.socket
%{_sbindir}/nscd
%{_tmpfilesdir}/nscd.conf
%attr(0644,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /run/nscd/nscd.pid
%attr(0666,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /run/nscd/socket
%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /run/nscd/passwd
%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /run/nscd/group
%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /run/nscd/hosts
%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /run/nscd/services
%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) %{_var}/db/nscd/passwd
%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) %{_var}/db/nscd/group
%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) %{_var}/db/nscd/hosts
@ -1727,15 +1713,12 @@ install -m 644 %{SOURCE11} %{buildroot}%{_sysconfdir}/nsswitch.conf
touch %{buildroot}%{_sysconfdir}/sysconfig/nscd
install -m755 -d %{buildroot}%{_sysconfdir}/netgroup
mkdir -p %{buildroot}%{_unitdir}
install -m 644 nscd/nscd.service nscd/nscd.socket %{buildroot}%{_unitdir}
install -m 644 nscd/nscd.service %{buildroot}%{_unitdir}
install -m644 nscd/nscd.tmpfiles -D %{buildroot}%{_tmpfilesdir}/nscd.conf
install -m755 -d %{buildroot}%{_var}/db/nscd
touch %{buildroot}%{_var}/db/nscd/{passwd,group,hosts,services}
install -m755 -d %{buildroot}/run/nscd
touch %{buildroot}/run/nscd/{nscd.pid,socket,passwd,group,hosts,services}
install -d %{buildroot}%{_presetdir}
cat > %{buildroot}%{_presetdir}/86-nscd.preset << EOF
enable nscd.socket
enable nscd.service
EOF
%endif