From a5952793340a4f85db8c7ad83e67b3aec9453ad47af6fbdf2025ca597cbaca7f Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Wed, 6 Mar 2019 11:57:50 +0000 Subject: [PATCH 1/5] Use update-alternatives for man(1), apropos(1), whatis(1) OBS-URL: https://build.opensuse.org/package/show/Base:System/man?expand=0&rev=94 --- man.changes | 8 +++++++ man.spec | 60 ++++++++++++++++++++++++++++++++++------------------- wrapper.c | 13 +++++++++++- 3 files changed, 59 insertions(+), 22 deletions(-) diff --git a/man.changes b/man.changes index c3a1c0d..86a56a6 100644 --- a/man.changes +++ b/man.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Wed Mar 6 11:47:58 UTC 2019 - Dr. Werner Fink + +- Use update-alternatives to allow that man(1), apropos(1), whatis(1) + can be overwritten by an other package like mandoc +- Reintroduce wrapper for man(1) but without mapping to user man to + be able to reset the PATH to the standard for any preprocessor + ------------------------------------------------------------------- Mon Nov 26 11:37:32 UTC 2018 - Dr. Werner Fink diff --git a/man.spec b/man.spec index 1a8b30e..966e62d 100644 --- a/man.spec +++ b/man.spec @@ -1,7 +1,7 @@ # # spec file for package man # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -21,8 +21,6 @@ %define _fillupdir /var/adm/fillup-templates %endif -%bcond_with wrapman - Name: man BuildRequires: automake BuildRequires: flex @@ -37,6 +35,7 @@ BuildRequires: libzio-devel BuildRequires: man-pages BuildRequires: pkg-config BuildRequires: po4a +BuildRequires: update-alternatives BuildRequires: xz-devel BuildRequires: zlib-devel Version: 2.8.4 @@ -58,6 +57,8 @@ Requires: groff >= 1.18 Requires: less Requires(pre): user(man) Requires(pre): group(man) +Requires(post): update-alternatives +Requires(preun): update-alternatives Source: http://download.savannah.gnu.org/releases/man-db/man-db-%{version}.tar.xz Source1: sysconfig.cron-man Source2: cron.daily.do_mandb @@ -199,27 +200,30 @@ fi %if %suse_version <= 1030 export MKDIR_P="mkdir -p" %endif - rm -rf %{buildroot}%{_localstatedir}/cache/man + rm -rf %{buildroot}%{_localstatedir}/cache/man mkdir -p %{buildroot}%{_datadir}/doc/packages/man mkdir -p %{buildroot}%{_libexecdir}/man-db mkdir -p %{buildroot}%{_bindir} mkdir -p %{buildroot}/etc + mkdir -p %{buildroot}%{_mandir} + mkdir -p %{buildroot}%{_sysconfdir}/alternatives make nls=all install DESTDIR=%{buildroot} rm -vf %{buildroot}%{_libdir}/*.la mv %{buildroot}%{_datadir}/doc/man-db/man-db-manual.* \ %{buildroot}%{_datadir}/doc/packages/man/ # wrapper which drops roots privileges if root executes man or mandb - if test -x %{buildroot}%{_bindir}/mandb ; then - mv %{buildroot}%{_bindir}/mandb %{buildroot}%{_libexecdir}/man-db/ - install wrapper %{buildroot}%{_bindir}/mandb - fi -%if %{with wrapman} - if test -x %{buildroot}%{_bindir}/man ; then - mv %{buildroot}%{_bindir}/man %{buildroot}%{_libexecdir}/man-db/ - ln -sf mandb %{buildroot}%{_bindir}/man - fi -%endif - mkdir -p %{buildroot}%{_mandir} + mv -vf %{buildroot}%{_bindir}/man %{buildroot}%{_libexecdir}/man-db/ + mv -vf %{buildroot}%{_bindir}/mandb %{buildroot}%{_libexecdir}/man-db/ + mv -vf %{buildroot}%{_bindir}/apropos %{buildroot}%{_libexecdir}/man-db/ + mv -vf %{buildroot}%{_bindir}/whatis %{buildroot}%{_libexecdir}/man-db/ + install wrapper %{buildroot}%{_libexecdir}/man-db/ + ln -sf %{_libexecdir}/man-db/wrapper %{buildroot}%{_sysconfdir}/alternatives/man + ln -sf %{_libexecdir}/man-db/wrapper %{buildroot}%{_bindir}/mandb + ln -sf %{_libexecdir}/man-db/apropos %{buildroot}%{_sysconfdir}/alternatives/apropos + ln -sf %{_libexecdir}/man-db/whatis %{buildroot}%{_sysconfdir}/alternatives/whatis + ln -sf %{_sysconfdir}/alternatives/man %{buildroot}%{_bindir}/man + ln -sf %{_sysconfdir}/alternatives/apropos %{buildroot}%{_bindir}/apropos + ln -sf %{_sysconfdir}/alternatives/whatis %{buildroot}%{_bindir}/whatis pushd %{buildroot}%{_mandir}/ rm -rf *.ascii/ for d in *.UTF-8 ; do @@ -274,12 +278,22 @@ test -d var/catman/ && rm -rf var/catman/ || true %if 0%{suse_version} >= 1500 %service_add_post mandb.service mandb.timer %endif +# Remark: soelim(1) is part of package groff or mandoc and +# makewhatis(8) is part of package makewaht or mandoc +%{_sbindir}/update-alternatives --quiet --force \ + --install %{_bindir}/man man %{_libexecdir}/man-db/wrapper 1010 \ + --slave %{_bindir}/apropos apropos %{_libexecdir}/man-db/apropos \ + --slave %{_bindir}/whatis whatis %{_libexecdir}/man-db/whatis %preun %service_del_preun man-db-create.service %if 0%{suse_version} >= 1500 %service_del_preun mandb.service mandb.timer %endif +if test $1 -eq 0 +then + %{_sbindir}/update-alternatives --quiet --remove man %{_bindir}/man +fi %postun /sbin/ldconfig @@ -300,20 +314,24 @@ test -d /var/cache/man && mandb --quiet --create ||: %if 0%{suse_version} < 1500 %attr(0744,root,root) /etc/cron.daily/suse-do_mandb %endif -%{_bindir}/apropos +%ghost %config %{_sysconfdir}/alternatives/man +%ghost %config %{_sysconfdir}/alternatives/apropos +%ghost %config %{_sysconfdir}/alternatives/whatis +%verify(not link mtime)%{_bindir}/man +%verify(not link mtime)%{_bindir}/apropos +%verify(not link mtime)%{_bindir}/whatis +%{_bindir}/mandb %{_bindir}/catman %{_bindir}/lexgrog -%{_bindir}/man -%{_bindir}/mandb %{_bindir}/manpath -%{_bindir}/whatis %dir %attr(0755,root,root) %{_libexecdir}/man-db -%if %{with wrapman} %attr(0755,root,root) %{_libexecdir}/man-db/man -%endif +%attr(0755,root,root) %{_libexecdir}/man-db/apropos +%attr(0755,root,root) %{_libexecdir}/man-db/whatis %attr(0755,root,root) %{_libexecdir}/man-db/mandb %attr(0755,man,man) %{_libexecdir}/man-db/manconv %attr(0755,man,man) %{_libexecdir}/man-db/globbing +%attr(0755,root,root) %{_libexecdir}/man-db/wrapper %if 0%{suse_version} >= 1500 %attr(0744,man,man) %{_libexecdir}/man-db/do_mandb %endif diff --git a/wrapper.c b/wrapper.c index d964424..a617ae4 100644 --- a/wrapper.c +++ b/wrapper.c @@ -67,6 +67,7 @@ char *program_name; int main (int argc, char **argv, char *envp[]) { + extern char **environ; uid_t ruid, euid; gid_t rgid; @@ -87,6 +88,11 @@ int main (int argc, char **argv, char *envp[]) euid = geteuid(); rgid = getgid (); + /* The various preprocessors should be in standard path */ + environ = envp; + setenv("PATH", "/bin:/usr/bin", 1); + envp = environ; + #ifdef DEBUG printf ("%s:\n", program_name); #endif @@ -101,6 +107,10 @@ int main (int argc, char **argv, char *envp[]) #ifdef DEBUG printf ("%s\n", wlp->run); #endif + if (strcmp("man", wlp->prog) == 0) + /* Short cut: do not map man command to an other user */ + goto man; + if (ruid == 0 || euid == 0) { static char *dummy_environ[] = { NULL }; extern char **environ; @@ -152,9 +162,10 @@ int main (int argc, char **argv, char *envp[]) setenv("USER", pwd->pw_name, 1); setenv("LOGNAME", pwd->pw_name, 1); if (cwd) - setenv("TERM", cwd, 1); + setenv("PWD", cwd, 1); envp = environ; } +man: execve (wlp->run, argv, envp); perror ("execve"); return -errno; From 7212e7a225e308b163c56cc252e2884b62ad9cf485357de1bc91cba6d410fcad Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Wed, 6 Mar 2019 13:17:17 +0000 Subject: [PATCH 2/5] . OBS-URL: https://build.opensuse.org/package/show/Base:System/man?expand=0&rev=95 --- man.changes | 5 +++++ man.spec | 21 ++++++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/man.changes b/man.changes index 86a56a6..2dd4ba6 100644 --- a/man.changes +++ b/man.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Wed Mar 6 13:15:43 UTC 2019 - Dr. Werner Fink + +- Minor corrections on %ghost /var/cache/man and link to apropos + ------------------------------------------------------------------- Wed Mar 6 11:47:58 UTC 2019 - Dr. Werner Fink diff --git a/man.spec b/man.spec index 966e62d..3d8919c 100644 --- a/man.spec +++ b/man.spec @@ -12,7 +12,7 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # @@ -214,12 +214,12 @@ fi # wrapper which drops roots privileges if root executes man or mandb mv -vf %{buildroot}%{_bindir}/man %{buildroot}%{_libexecdir}/man-db/ mv -vf %{buildroot}%{_bindir}/mandb %{buildroot}%{_libexecdir}/man-db/ - mv -vf %{buildroot}%{_bindir}/apropos %{buildroot}%{_libexecdir}/man-db/ + rm -vf %{buildroot}%{_bindir}/apropos mv -vf %{buildroot}%{_bindir}/whatis %{buildroot}%{_libexecdir}/man-db/ install wrapper %{buildroot}%{_libexecdir}/man-db/ ln -sf %{_libexecdir}/man-db/wrapper %{buildroot}%{_sysconfdir}/alternatives/man ln -sf %{_libexecdir}/man-db/wrapper %{buildroot}%{_bindir}/mandb - ln -sf %{_libexecdir}/man-db/apropos %{buildroot}%{_sysconfdir}/alternatives/apropos + ln -sf %{_libexecdir}/man-db/whatis %{buildroot}%{_sysconfdir}/alternatives/apropos ln -sf %{_libexecdir}/man-db/whatis %{buildroot}%{_sysconfdir}/alternatives/whatis ln -sf %{_sysconfdir}/alternatives/man %{buildroot}%{_bindir}/man ln -sf %{_sysconfdir}/alternatives/apropos %{buildroot}%{_bindir}/apropos @@ -229,8 +229,8 @@ fi for d in *.UTF-8 ; do find -name '*.[1-9nlop]' | xargs gzip -9f done - for d in `find -name manpath.5.gz -printf '%%h '` ; do - ln -sf manpath.5.gz $d/manpath.config.5.gz + for d in `find -name manpath.5%{?ext_man} -printf '%%h '` ; do + ln -sf manpath.5%{?ext_man} $d/manpath.config.5%{?ext_man} done # remove japanese pages, as they are in man-pages-ja @@ -282,7 +282,7 @@ test -d var/catman/ && rm -rf var/catman/ || true # makewhatis(8) is part of package makewaht or mandoc %{_sbindir}/update-alternatives --quiet --force \ --install %{_bindir}/man man %{_libexecdir}/man-db/wrapper 1010 \ - --slave %{_bindir}/apropos apropos %{_libexecdir}/man-db/apropos \ + --slave %{_bindir}/apropos apropos %{_libexecdir}/man-db/whatis \ --slave %{_bindir}/whatis whatis %{_libexecdir}/man-db/whatis %preun @@ -326,7 +326,6 @@ test -d /var/cache/man && mandb --quiet --create ||: %{_bindir}/manpath %dir %attr(0755,root,root) %{_libexecdir}/man-db %attr(0755,root,root) %{_libexecdir}/man-db/man -%attr(0755,root,root) %{_libexecdir}/man-db/apropos %attr(0755,root,root) %{_libexecdir}/man-db/whatis %attr(0755,root,root) %{_libexecdir}/man-db/mandb %attr(0755,man,man) %{_libexecdir}/man-db/manconv @@ -350,14 +349,14 @@ test -d /var/cache/man && mandb --quiet --create ||: %dir %{_datadir}/groff/site-tmac %{_datadir}/groff/site-tmac/tmac.andb %{_datadir}/groff/site-tmac/tmac.andocdb -%doc %{_mandir}/man1/*.1.gz -%doc %{_mandir}/man5/*.5.gz -%doc %{_mandir}/man8/*.8.gz +%doc %{_mandir}/man1/*.1%{?ext_man} +%doc %{_mandir}/man5/*.5%{?ext_man} +%doc %{_mandir}/man8/*.8%{?ext_man} %dir %{_mandir}/id %dir %{_mandir}/sr %dir %{_mandir}/tr %{_fillupdir}/sysconfig.cron-man %defattr(-,man,man) -%ghost %{_localstatedir}/cache/man +%ghost %verify(not group) %{_localstatedir}/cache/man %changelog From 94f1be2a18936e8ce0a04867bd6f0bbb72655835b0381eea71cf7ba9076b9895 Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Thu, 7 Mar 2019 08:02:01 +0000 Subject: [PATCH 3/5] . OBS-URL: https://build.opensuse.org/package/show/Base:System/man?expand=0&rev=96 --- man.changes | 6 ++++++ man.spec | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/man.changes b/man.changes index 2dd4ba6..40cef81 100644 --- a/man.changes +++ b/man.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Mar 7 07:59:37 UTC 2019 - Dr. Werner Fink + +- Skip %verify(not link mtime) from symbolic links i %_bindir + even if those should not hurt + ------------------------------------------------------------------- Wed Mar 6 13:15:43 UTC 2019 - Dr. Werner Fink diff --git a/man.spec b/man.spec index 3d8919c..e0a1ba1 100644 --- a/man.spec +++ b/man.spec @@ -317,9 +317,9 @@ test -d /var/cache/man && mandb --quiet --create ||: %ghost %config %{_sysconfdir}/alternatives/man %ghost %config %{_sysconfdir}/alternatives/apropos %ghost %config %{_sysconfdir}/alternatives/whatis -%verify(not link mtime)%{_bindir}/man -%verify(not link mtime)%{_bindir}/apropos -%verify(not link mtime)%{_bindir}/whatis +%{_bindir}/man +%{_bindir}/apropos +%{_bindir}/whatis %{_bindir}/mandb %{_bindir}/catman %{_bindir}/lexgrog From 1d5ffd2bc23ae01c47778cf551af3dfb874c7055fcb54ad6fa04e0282ff6da77 Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Thu, 7 Mar 2019 08:05:02 +0000 Subject: [PATCH 4/5] . OBS-URL: https://build.opensuse.org/package/show/Base:System/man?expand=0&rev=97 --- man.changes | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/man.changes b/man.changes index 40cef81..53351ed 100644 --- a/man.changes +++ b/man.changes @@ -1,8 +1,8 @@ ------------------------------------------------------------------- Thu Mar 7 07:59:37 UTC 2019 - Dr. Werner Fink -- Skip %verify(not link mtime) from symbolic links i %_bindir - even if those should not hurt +- Skip %verify(not link mtime) from symbolic links %_bindir even if + those should not hurt but avoid superfluous verify messages ------------------------------------------------------------------- Wed Mar 6 13:15:43 UTC 2019 - Dr. Werner Fink From 39fce819e74c648084eb007bb0b071f3c2a2f087485f4b5b7d7a4dd0fc99812b Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Fri, 8 Mar 2019 13:14:55 +0000 Subject: [PATCH 5/5] Manual pages also should have alternatives OBS-URL: https://build.opensuse.org/package/show/Base:System/man?expand=0&rev=98 --- man.changes | 5 +++++ man.spec | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/man.changes b/man.changes index 53351ed..757720c 100644 --- a/man.changes +++ b/man.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri Mar 8 13:12:07 UTC 2019 - Dr. Werner Fink + +- Ah ... yes, manual pages are also provides by e.g. mandoc + ------------------------------------------------------------------- Thu Mar 7 07:59:37 UTC 2019 - Dr. Werner Fink diff --git a/man.spec b/man.spec index e0a1ba1..efc4e07 100644 --- a/man.spec +++ b/man.spec @@ -12,7 +12,7 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# Please submit bugfixes or comments via http://bugs.opensuse.org/ # @@ -233,6 +233,13 @@ fi ln -sf manpath.5%{?ext_man} $d/manpath.config.5%{?ext_man} done + for man in apropos man whatis + do + mv man1/${man}.1%{?ext_man} man1/${man}-db.1%{?ext_man} + ln -sf %{_sysconfdir}/alternatives/${man}.1%{?ext_man} man1/${man}.1%{?ext_man} + ln -sf %{_mandir}/man1/${man}-db.1%{?ext_man} %{buildroot}%{_sysconfdir}/alternatives/${man}.1%{?ext_man} + done + # remove japanese pages, as they are in man-pages-ja # (need to cross verify at some point that they are up to date there) rm -rf ja @@ -283,7 +290,10 @@ test -d var/catman/ && rm -rf var/catman/ || true %{_sbindir}/update-alternatives --quiet --force \ --install %{_bindir}/man man %{_libexecdir}/man-db/wrapper 1010 \ --slave %{_bindir}/apropos apropos %{_libexecdir}/man-db/whatis \ - --slave %{_bindir}/whatis whatis %{_libexecdir}/man-db/whatis + --slave %{_bindir}/whatis whatis %{_libexecdir}/man-db/whatis \ + --slave %{_mandir}/man1/man.1%{?ext_man} man.1%{?ext_man} %{_mandir}/man1/man-db.1%{?ext_man} \ + --slave %{_mandir}/man1/apropos.1%{?ext_man} apropos.1%{?ext_man} %{_mandir}/man1/apropos-db.1%{?ext_man} \ + --slave %{_mandir}/man1/whatis.1%{?ext_man} whatis.1%{?ext_man} %{_mandir}/man1/whatis-db.1%{?ext_man} %preun %service_del_preun man-db-create.service @@ -317,6 +327,9 @@ test -d /var/cache/man && mandb --quiet --create ||: %ghost %config %{_sysconfdir}/alternatives/man %ghost %config %{_sysconfdir}/alternatives/apropos %ghost %config %{_sysconfdir}/alternatives/whatis +%ghost %config %{_sysconfdir}/alternatives/man.1%{ext_man} +%ghost %config %{_sysconfdir}/alternatives/apropos.1%{ext_man} +%ghost %config %{_sysconfdir}/alternatives/whatis.1%{ext_man} %{_bindir}/man %{_bindir}/apropos %{_bindir}/whatis