From ab6d8480912227c9b5c2ee0dfa1dc2a0b5fcc13a068cc81c07cd3d1ea3dc0a59 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Thu, 9 Jan 2020 21:12:44 +0000 Subject: [PATCH] Accepting request 762248 from home:lnussel:branches:Documentation - update-alternatives --remove must be in %postun - own mandoc.db - add file triggers to update mandoc.db OBS-URL: https://build.opensuse.org/request/show/762248 OBS-URL: https://build.opensuse.org/package/show/Documentation/mandoc?expand=0&rev=3 --- mandoc.changes | 7 +++++ mandoc.spec | 69 ++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 71 insertions(+), 5 deletions(-) diff --git a/mandoc.changes b/mandoc.changes index 2989ebf..f2500de 100644 --- a/mandoc.changes +++ b/mandoc.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Thu Jan 9 10:13:07 UTC 2020 - Ludwig Nussel + +- update-alternatives --remove must be in %postun +- own mandoc.db +- add file triggers to update mandoc.db + ------------------------------------------------------------------- Mon Dec 16 14:43:39 CET 2019 - Matej Cepl diff --git a/mandoc.spec b/mandoc.spec index 0a90b30..b15c95c 100644 --- a/mandoc.spec +++ b/mandoc.spec @@ -82,6 +82,9 @@ for man in eqn man mdoc roff tbl ; do ln -s -f %{_sysconfdir}/alternatives/$man.7 "$from" done +# ghost +: > %{buildroot}%{_mandir}/mandoc.db + %post update-alternatives --install \ %{_bindir}/man man %{_bindir}/man.mandoc 1000 \ @@ -97,13 +100,68 @@ update-alternatives --install \ --slave %{_mandir}/man7/mdoc.7%{?ext_man} mdoc.7%{?ext_man} %{_mandir}/man7/mdoc-mandoc.7%{?ext_man} \ --slave %{_mandir}/man7/roff.7%{?ext_man} roff.7%{?ext_man} %{_mandir}/man7/roff-mandoc.7%{?ext_man} \ --slave %{_mandir}/man7/tbl.7%{?ext_man} tbl.7%{?ext_man} %{_mandir}/man7/tbl-mandoc.7%{?ext_man} - - -%preun -if [ $1 -eq 0 ] ; then - update-alternatives --remove man %{_bindir}/man.mandoc +if [ -x %{_sbindir}/makewhatis ]; then + %{_sbindir}/makewhatis fi +%postun +if [ $1 -eq 0 ] ; then + update-alternatives --remove man %{_bindir}/man.mandoc +fi + +%filetriggerin -p -- %{_mandir} +-- TODO: replace with rpm.execute after rpm 4.15 +function execute(path, ...) + local pid = posix.fork() + if pid == 0 then + posix.exec(path, ...) + io.write(path, ": exec failed: ", posix.errno(), "\n") + os.exit(1) + end + if not pid then + error(path .. ": fork failed: " .. posix.errno() .. "\n") + end + posix.wait(pid) +end +-- +-- makewhatis may not exist if update-alternatives did not create it +-- yet. Also, no point registering individual files if we can call +-- makewhatis in %%post to catch all +if posix.access("%{_sbindir}/makewhatis") and posix.access("%{_mandir}/mandoc.db") then + file = rpm.next_file() + while file do + if string.match(file, "%{_mandir}/man[^/]+/[^/]+%{?ext_man}$") then + execute("%{_sbindir}/makewhatis", "-d", "%{_mandir}", file) + end + file = rpm.next_file() + end +end + +%filetriggerun -p -- %{_mandir} +-- TODO: replace with rpm.execute after rpm 4.15 +function execute(path, ...) + local pid = posix.fork() + if pid == 0 then + posix.exec(path, ...) + io.write(path, ": exec failed: ", posix.errno(), "\n") + os.exit(1) + end + if not pid then + error(path .. ": fork failed: " .. posix.errno() .. "\n") + end + posix.wait(pid) +end +-- +if posix.access("%{_sbindir}/makewhatis") and posix.access("%{_mandir}/mandoc.db") then + file = rpm.next_file() + while file do + if string.match(file, "%{_mandir}/man[^/]+/[^/]+%{?ext_man}$") then + execute("%{_sbindir}/makewhatis", "-u", "%{_mandir}", file) + end + file = rpm.next_file() + end +end + %files %license LICENSE %doc NEWS TODO @@ -117,6 +175,7 @@ fi %{_mandir}/man5/*.5%{?ext_man} %{_mandir}/man7/*.7%{?ext_man} %{_mandir}/man8/*.8%{?ext_man} +%ghost %{_mandir}/mandoc.db %ghost %{_sysconfdir}/alternatives/man %ghost %{_sysconfdir}/alternatives/apropos %ghost %{_sysconfdir}/alternatives/soelim