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
This commit is contained in:
parent
ad670e6734
commit
a595279334
@ -1,3 +1,11 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Mar 6 11:47:58 UTC 2019 - Dr. Werner Fink <werner@suse.de>
|
||||||
|
|
||||||
|
- 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 <werner@suse.de>
|
Mon Nov 26 11:37:32 UTC 2018 - Dr. Werner Fink <werner@suse.de>
|
||||||
|
|
||||||
|
60
man.spec
60
man.spec
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# spec file for package man
|
# 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
|
# All modifications and additions to the file contributed by third parties
|
||||||
# remain the property of their copyright owners, unless otherwise agreed
|
# remain the property of their copyright owners, unless otherwise agreed
|
||||||
@ -21,8 +21,6 @@
|
|||||||
%define _fillupdir /var/adm/fillup-templates
|
%define _fillupdir /var/adm/fillup-templates
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
%bcond_with wrapman
|
|
||||||
|
|
||||||
Name: man
|
Name: man
|
||||||
BuildRequires: automake
|
BuildRequires: automake
|
||||||
BuildRequires: flex
|
BuildRequires: flex
|
||||||
@ -37,6 +35,7 @@ BuildRequires: libzio-devel
|
|||||||
BuildRequires: man-pages
|
BuildRequires: man-pages
|
||||||
BuildRequires: pkg-config
|
BuildRequires: pkg-config
|
||||||
BuildRequires: po4a
|
BuildRequires: po4a
|
||||||
|
BuildRequires: update-alternatives
|
||||||
BuildRequires: xz-devel
|
BuildRequires: xz-devel
|
||||||
BuildRequires: zlib-devel
|
BuildRequires: zlib-devel
|
||||||
Version: 2.8.4
|
Version: 2.8.4
|
||||||
@ -58,6 +57,8 @@ Requires: groff >= 1.18
|
|||||||
Requires: less
|
Requires: less
|
||||||
Requires(pre): user(man)
|
Requires(pre): user(man)
|
||||||
Requires(pre): group(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
|
Source: http://download.savannah.gnu.org/releases/man-db/man-db-%{version}.tar.xz
|
||||||
Source1: sysconfig.cron-man
|
Source1: sysconfig.cron-man
|
||||||
Source2: cron.daily.do_mandb
|
Source2: cron.daily.do_mandb
|
||||||
@ -199,27 +200,30 @@ fi
|
|||||||
%if %suse_version <= 1030
|
%if %suse_version <= 1030
|
||||||
export MKDIR_P="mkdir -p"
|
export MKDIR_P="mkdir -p"
|
||||||
%endif
|
%endif
|
||||||
rm -rf %{buildroot}%{_localstatedir}/cache/man
|
rm -rf %{buildroot}%{_localstatedir}/cache/man
|
||||||
mkdir -p %{buildroot}%{_datadir}/doc/packages/man
|
mkdir -p %{buildroot}%{_datadir}/doc/packages/man
|
||||||
mkdir -p %{buildroot}%{_libexecdir}/man-db
|
mkdir -p %{buildroot}%{_libexecdir}/man-db
|
||||||
mkdir -p %{buildroot}%{_bindir}
|
mkdir -p %{buildroot}%{_bindir}
|
||||||
mkdir -p %{buildroot}/etc
|
mkdir -p %{buildroot}/etc
|
||||||
|
mkdir -p %{buildroot}%{_mandir}
|
||||||
|
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
|
||||||
make nls=all install DESTDIR=%{buildroot}
|
make nls=all install DESTDIR=%{buildroot}
|
||||||
rm -vf %{buildroot}%{_libdir}/*.la
|
rm -vf %{buildroot}%{_libdir}/*.la
|
||||||
mv %{buildroot}%{_datadir}/doc/man-db/man-db-manual.* \
|
mv %{buildroot}%{_datadir}/doc/man-db/man-db-manual.* \
|
||||||
%{buildroot}%{_datadir}/doc/packages/man/
|
%{buildroot}%{_datadir}/doc/packages/man/
|
||||||
# wrapper which drops roots privileges if root executes man or mandb
|
# wrapper which drops roots privileges if root executes man or mandb
|
||||||
if test -x %{buildroot}%{_bindir}/mandb ; then
|
mv -vf %{buildroot}%{_bindir}/man %{buildroot}%{_libexecdir}/man-db/
|
||||||
mv %{buildroot}%{_bindir}/mandb %{buildroot}%{_libexecdir}/man-db/
|
mv -vf %{buildroot}%{_bindir}/mandb %{buildroot}%{_libexecdir}/man-db/
|
||||||
install wrapper %{buildroot}%{_bindir}/mandb
|
mv -vf %{buildroot}%{_bindir}/apropos %{buildroot}%{_libexecdir}/man-db/
|
||||||
fi
|
mv -vf %{buildroot}%{_bindir}/whatis %{buildroot}%{_libexecdir}/man-db/
|
||||||
%if %{with wrapman}
|
install wrapper %{buildroot}%{_libexecdir}/man-db/
|
||||||
if test -x %{buildroot}%{_bindir}/man ; then
|
ln -sf %{_libexecdir}/man-db/wrapper %{buildroot}%{_sysconfdir}/alternatives/man
|
||||||
mv %{buildroot}%{_bindir}/man %{buildroot}%{_libexecdir}/man-db/
|
ln -sf %{_libexecdir}/man-db/wrapper %{buildroot}%{_bindir}/mandb
|
||||||
ln -sf mandb %{buildroot}%{_bindir}/man
|
ln -sf %{_libexecdir}/man-db/apropos %{buildroot}%{_sysconfdir}/alternatives/apropos
|
||||||
fi
|
ln -sf %{_libexecdir}/man-db/whatis %{buildroot}%{_sysconfdir}/alternatives/whatis
|
||||||
%endif
|
ln -sf %{_sysconfdir}/alternatives/man %{buildroot}%{_bindir}/man
|
||||||
mkdir -p %{buildroot}%{_mandir}
|
ln -sf %{_sysconfdir}/alternatives/apropos %{buildroot}%{_bindir}/apropos
|
||||||
|
ln -sf %{_sysconfdir}/alternatives/whatis %{buildroot}%{_bindir}/whatis
|
||||||
pushd %{buildroot}%{_mandir}/
|
pushd %{buildroot}%{_mandir}/
|
||||||
rm -rf *.ascii/
|
rm -rf *.ascii/
|
||||||
for d in *.UTF-8 ; do
|
for d in *.UTF-8 ; do
|
||||||
@ -274,12 +278,22 @@ test -d var/catman/ && rm -rf var/catman/ || true
|
|||||||
%if 0%{suse_version} >= 1500
|
%if 0%{suse_version} >= 1500
|
||||||
%service_add_post mandb.service mandb.timer
|
%service_add_post mandb.service mandb.timer
|
||||||
%endif
|
%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
|
%preun
|
||||||
%service_del_preun man-db-create.service
|
%service_del_preun man-db-create.service
|
||||||
%if 0%{suse_version} >= 1500
|
%if 0%{suse_version} >= 1500
|
||||||
%service_del_preun mandb.service mandb.timer
|
%service_del_preun mandb.service mandb.timer
|
||||||
%endif
|
%endif
|
||||||
|
if test $1 -eq 0
|
||||||
|
then
|
||||||
|
%{_sbindir}/update-alternatives --quiet --remove man %{_bindir}/man
|
||||||
|
fi
|
||||||
|
|
||||||
%postun
|
%postun
|
||||||
/sbin/ldconfig
|
/sbin/ldconfig
|
||||||
@ -300,20 +314,24 @@ test -d /var/cache/man && mandb --quiet --create ||:
|
|||||||
%if 0%{suse_version} < 1500
|
%if 0%{suse_version} < 1500
|
||||||
%attr(0744,root,root) /etc/cron.daily/suse-do_mandb
|
%attr(0744,root,root) /etc/cron.daily/suse-do_mandb
|
||||||
%endif
|
%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}/catman
|
||||||
%{_bindir}/lexgrog
|
%{_bindir}/lexgrog
|
||||||
%{_bindir}/man
|
|
||||||
%{_bindir}/mandb
|
|
||||||
%{_bindir}/manpath
|
%{_bindir}/manpath
|
||||||
%{_bindir}/whatis
|
|
||||||
%dir %attr(0755,root,root) %{_libexecdir}/man-db
|
%dir %attr(0755,root,root) %{_libexecdir}/man-db
|
||||||
%if %{with wrapman}
|
|
||||||
%attr(0755,root,root) %{_libexecdir}/man-db/man
|
%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,root,root) %{_libexecdir}/man-db/mandb
|
||||||
%attr(0755,man,man) %{_libexecdir}/man-db/manconv
|
%attr(0755,man,man) %{_libexecdir}/man-db/manconv
|
||||||
%attr(0755,man,man) %{_libexecdir}/man-db/globbing
|
%attr(0755,man,man) %{_libexecdir}/man-db/globbing
|
||||||
|
%attr(0755,root,root) %{_libexecdir}/man-db/wrapper
|
||||||
%if 0%{suse_version} >= 1500
|
%if 0%{suse_version} >= 1500
|
||||||
%attr(0744,man,man) %{_libexecdir}/man-db/do_mandb
|
%attr(0744,man,man) %{_libexecdir}/man-db/do_mandb
|
||||||
%endif
|
%endif
|
||||||
|
13
wrapper.c
13
wrapper.c
@ -67,6 +67,7 @@ char *program_name;
|
|||||||
|
|
||||||
int main (int argc, char **argv, char *envp[])
|
int main (int argc, char **argv, char *envp[])
|
||||||
{
|
{
|
||||||
|
extern char **environ;
|
||||||
uid_t ruid, euid;
|
uid_t ruid, euid;
|
||||||
gid_t rgid;
|
gid_t rgid;
|
||||||
|
|
||||||
@ -87,6 +88,11 @@ int main (int argc, char **argv, char *envp[])
|
|||||||
euid = geteuid();
|
euid = geteuid();
|
||||||
rgid = getgid ();
|
rgid = getgid ();
|
||||||
|
|
||||||
|
/* The various preprocessors should be in standard path */
|
||||||
|
environ = envp;
|
||||||
|
setenv("PATH", "/bin:/usr/bin", 1);
|
||||||
|
envp = environ;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf ("%s:\n", program_name);
|
printf ("%s:\n", program_name);
|
||||||
#endif
|
#endif
|
||||||
@ -101,6 +107,10 @@ int main (int argc, char **argv, char *envp[])
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf ("%s\n", wlp->run);
|
printf ("%s\n", wlp->run);
|
||||||
#endif
|
#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) {
|
if (ruid == 0 || euid == 0) {
|
||||||
static char *dummy_environ[] = { NULL };
|
static char *dummy_environ[] = { NULL };
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
@ -152,9 +162,10 @@ int main (int argc, char **argv, char *envp[])
|
|||||||
setenv("USER", pwd->pw_name, 1);
|
setenv("USER", pwd->pw_name, 1);
|
||||||
setenv("LOGNAME", pwd->pw_name, 1);
|
setenv("LOGNAME", pwd->pw_name, 1);
|
||||||
if (cwd)
|
if (cwd)
|
||||||
setenv("TERM", cwd, 1);
|
setenv("PWD", cwd, 1);
|
||||||
envp = environ;
|
envp = environ;
|
||||||
}
|
}
|
||||||
|
man:
|
||||||
execve (wlp->run, argv, envp);
|
execve (wlp->run, argv, envp);
|
||||||
perror ("execve");
|
perror ("execve");
|
||||||
return -errno;
|
return -errno;
|
||||||
|
Loading…
Reference in New Issue
Block a user