#1 Better implementation of alternatives
Merged 4 years ago by dcantrel. Opened 4 years ago by nforro.
rpms/ nforro/mandoc master  into  master

file modified
+63 -41
@@ -24,6 +24,7 @@ 

  Requires:         libmandoc%{?_isa} = %{version}-%{release}

  Requires(post):   %{_sbindir}/update-alternatives

  Requires(postun): %{_sbindir}/update-alternatives

+ Requires(preun):  %{_sbindir}/update-alternatives

  

  %description

  mandoc is a suite of tools compiling mdoc, the roff macro language of choice
@@ -66,19 +67,7 @@ 

  # with default settings rpmlint complains about cross-directory hardlinks

  echo 'LN="ln -sf"' >> configure.local

  

- # change the names of binaries, conf files, and section 7 man pages

- # to avoid conflicts with man-db and groff

  echo 'MANM_MANCONF=mandoc.conf'          >> configure.local

- echo 'BINM_MAN=man.mandoc'               >> configure.local

- echo 'BINM_APROPOS=apropos.mandoc'       >> configure.local

- echo 'BINM_WHATIS=whatis.mandoc'         >> configure.local

- echo 'BINM_MAKEWHATIS=makewhatis.mandoc' >> configure.local

- echo 'BINM_SOELIM=soelim.mandoc'         >> configure.local

- echo 'MANM_MAN=man.mandoc'               >> configure.local

- echo 'MANM_MDOC=mdoc.mandoc'             >> configure.local

- echo 'MANM_ROFF=roff.mandoc'             >> configure.local

- echo 'MANM_EQN=eqn.mandoc'               >> configure.local

- echo 'MANM_TBL=tbl.mandoc'               >> configure.local

  

  # override the install permissions so that owner-write bits are set,

  # so rpmbuild can do whatever modifications it does post-%%install
@@ -97,8 +86,22 @@ 

  %install

  %make_install

  

- # Compress all the man pages

- find %{buildroot}/%{_mandir}/ -type f | xargs gzip -9

+ # Rename files for alternative usage

+ mv %{buildroot}%{_bindir}/man %{buildroot}%{_bindir}/man.mandoc

+ mv %{buildroot}%{_bindir}/apropos %{buildroot}%{_bindir}/apropos.mandoc

+ mv %{buildroot}%{_bindir}/whatis %{buildroot}%{_bindir}/whatis.mandoc

+ mv %{buildroot}%{_bindir}/soelim %{buildroot}%{_bindir}/soelim.mandoc

+ mv %{buildroot}%{_sbindir}/makewhatis %{buildroot}%{_sbindir}/makewhatis.mandoc

+ mv %{buildroot}%{_mandir}/man1/apropos.1 %{buildroot}%{_mandir}/man1/apropos.mandoc.1

+ mv %{buildroot}%{_mandir}/man1/man.1 %{buildroot}%{_mandir}/man1/man.mandoc.1

+ mv %{buildroot}%{_mandir}/man1/soelim.1 %{buildroot}%{_mandir}/man1/soelim.mandoc.1

+ mv %{buildroot}%{_mandir}/man1/whatis.1 %{buildroot}%{_mandir}/man1/whatis.mandoc.1

+ mv %{buildroot}%{_mandir}/man7/man.7 %{buildroot}%{_mandir}/man7/man.mandoc.7

+ mv %{buildroot}%{_mandir}/man7/mdoc.7 %{buildroot}%{_mandir}/man7/mdoc.mandoc.7

+ mv %{buildroot}%{_mandir}/man7/roff.7 %{buildroot}%{_mandir}/man7/roff.mandoc.7

+ mv %{buildroot}%{_mandir}/man7/eqn.7 %{buildroot}%{_mandir}/man7/eqn.mandoc.7

+ mv %{buildroot}%{_mandir}/man7/tbl.7 %{buildroot}%{_mandir}/man7/tbl.mandoc.7

+ mv %{buildroot}%{_mandir}/man8/makewhatis.8 %{buildroot}%{_mandir}/man8/makewhatis.mandoc.8

  

  # Touch all the locations that update-alternatives will use

  touch %{buildroot}%{_bindir}/man
@@ -106,16 +109,16 @@ 

  touch %{buildroot}%{_bindir}/whatis

  touch %{buildroot}%{_bindir}/soelim

  touch %{buildroot}%{_sbindir}/makewhatis

- touch %{buildroot}%{_mandir}/man1/apropos.1.gz

- touch %{buildroot}%{_mandir}/man1/man.1.gz

- touch %{buildroot}%{_mandir}/man1/soelim.1.gz

- touch %{buildroot}%{_mandir}/man1/whatis.1.gz

- touch %{buildroot}%{_mandir}/man7/man.7.gz

- touch %{buildroot}%{_mandir}/man7/mdoc.7.gz

- touch %{buildroot}%{_mandir}/man7/roff.7.gz

- touch %{buildroot}%{_mandir}/man7/eqn.7.gz

- touch %{buildroot}%{_mandir}/man7/tbl.7.gz

- touch %{buildroot}%{_mandir}/man8/makewhatis.8.gz

+ touch %{buildroot}%{_mandir}/man1/apropos.1

+ touch %{buildroot}%{_mandir}/man1/man.1

+ touch %{buildroot}%{_mandir}/man1/soelim.1

+ touch %{buildroot}%{_mandir}/man1/whatis.1

+ touch %{buildroot}%{_mandir}/man7/man.7

+ touch %{buildroot}%{_mandir}/man7/mdoc.7

+ touch %{buildroot}%{_mandir}/man7/roff.7

+ touch %{buildroot}%{_mandir}/man7/eqn.7

+ touch %{buildroot}%{_mandir}/man7/tbl.7

+ touch %{buildroot}%{_mandir}/man8/makewhatis.8

  

  %check

  env LD_LIBRARY_PATH="$PWD" make regress
@@ -124,30 +127,49 @@ 

  

  %postun

  if [ $1 -ge 1 ]; then

-     if [ "$(readlink %{_sysconfdir}/alternatives/mandoc)" = "%{_bindir}/man.mandoc" ]; then

-         %{_sbindir}/alternatives --set mandoc %{_bindir}/man.mandoc

+     if [ "$(readlink %{_sysconfdir}/alternatives/man)" = "%{_bindir}/man.mandoc" ]; then

+         %{_sbindir}/alternatives --set man %{_bindir}/man.mandoc

+     fi

+ 

+     if [ "$(readlink %{_sysconfdir}/alternatives/soelim)" = "%{_bindir}/soelim.mandoc" ]; then

+         %{_sbindir}/alternatives --set soelim %{_bindir}/soelim.mandoc

+     fi

+ 

+     if [ "$(readlink %{_sysconfdir}/alternatives/roff.7.gz)" = "%{_mandir}/man7/roff.mandoc.7.gz" ]; then

+         %{_sbindir}/alternatives --set roff.7.gz %{_mandir}/man7/roff.mandoc.7.gz

+     fi

+ 

+     if [ "$(readlink %{_sysconfdir}/alternatives/man.7.gz)" = "%{_mandir}/man7/man.mandoc.7.gz" ]; then

+         %{_sbindir}/alternatives --set man.7.gz %{_mandir}/man7/man.mandoc.7.gz

      fi

  fi

  

  %post

- %{_sbindir}/update-alternatives --install %{_bindir}/man mandoc %{_bindir}/man.mandoc 200 \

-     --slave %{_bindir}/soelim mandoc-soelim %{_bindir}/soelim.mandoc \

-     --slave %{_bindir}/whatis mandoc-whatis %{_bindir}/whatis.mandoc \

-     --slave %{_sbindir}/makewhatis mandoc-makewhatis %{_sbindir}/makewhatis.mandoc \

-     --slave %{_mandir}/man1/apropos.1.gz mandoc-aproposman %{_mandir}/man1/apropos.mandoc.1.gz \

-     --slave %{_mandir}/man1/man.1.gz mandoc-man1man %{_mandir}/man1/man.mandoc.1.gz \

-     --slave %{_mandir}/man1/soelim.1.gz mandoc-soelimman %{_mandir}/man1/soelim.mandoc.1.gz \

-     --slave %{_mandir}/man1/whatis.1.gz mandoc-whatisman %{_mandir}/man1/whatis.mandoc.1.gz \

-     --slave %{_mandir}/man7/man.7.gz mandoc-man7man %{_mandir}/man7/man.mandoc.7.gz \

-     --slave %{_mandir}/man7/mdoc.7.gz mandoc-mdocman %{_mandir}/man7/mdoc.mandoc.7.gz \

-     --slave %{_mandir}/man7/roff.7.gz mandoc-roffman %{_mandir}/man7/roff.mandoc.7.gz \

-     --slave %{_mandir}/man7/eqn.7.gz mandoc-eqnman %{_mandir}/man7/eqn.mandoc.7.gz \

-     --slave %{_mandir}/man7/tbl.7.gz mandoc-tblman %{_mandir}/man7/tbl.mandoc.7.gz

-     --slave %{_mandir}/man8/makewhatis.8.gz mandoc-makewhatisman %{_mandir}/man8/makewhatis.mandoc.8.gz

+ %{_sbindir}/update-alternatives --install %{_bindir}/man man %{_bindir}/man.mandoc 200 \

+     --slave %{_bindir}/apropos apropos %{_bindir}/apropos.mandoc \

+     --slave %{_bindir}/whatis whatis %{_bindir}/whatis.mandoc \

+     --slave %{_sbindir}/makewhatis makewhatis %{_sbindir}/makewhatis.mandoc \

+     --slave %{_mandir}/man1/apropos.1.gz apropos.1.gz %{_mandir}/man1/apropos.mandoc.1.gz \

+     --slave %{_mandir}/man1/man.1.gz man.1.gz %{_mandir}/man1/man.mandoc.1.gz \

+     --slave %{_mandir}/man1/whatis.1.gz whatis.1.gz %{_mandir}/man1/whatis.mandoc.1.gz \

+     --slave %{_mandir}/man8/makewhatis.8.gz makewhatis.8.gz %{_mandir}/man8/makewhatis.mandoc.8.gz

+ 

+ %{_sbindir}/update-alternatives --install %{_bindir}/soelim soelim %{_bindir}/soelim.mandoc 200 \

+     --slave %{_mandir}/man1/soelim.1.gz soelim.1.gz %{_mandir}/man1/soelim.mandoc.1.gz

+ 

+ %{_sbindir}/update-alternatives --install %{_mandir}/man7/roff.7.gz roff.7.gz %{_mandir}/man7/roff.mandoc.7.gz 200 \

+     --slave %{_mandir}/man7/eqn.7.gz eqn.7.gz %{_mandir}/man7/eqn.mandoc.7.gz \

+     --slave %{_mandir}/man7/tbl.7.gz tbl.7.gz %{_mandir}/man7/tbl.mandoc.7.gz

+ 

+ %{_sbindir}/update-alternatives --install %{_mandir}/man7/man.7.gz man.7.gz %{_mandir}/man7/man.mandoc.7.gz 200 \

+     --slave %{_mandir}/man7/mdoc.7.gz mdoc.7.gz %{_mandir}/man7/mdoc.mandoc.7.gz

  

  %preun

  if [ $1 -eq 0 ]; then

-     %{_sbindir}/update-alternatives --remove mandoc %{_bindir}/man.mandoc

+     %{_sbindir}/update-alternatives --remove man %{_bindir}/man.mandoc

+     %{_sbindir}/update-alternatives --remove soelim %{_bindir}/soelim.mandoc

+     %{_sbindir}/update-alternatives --remove roff.7.gz %{_mandir}/man7/roff.mandoc.7.gz

+     %{_sbindir}/update-alternatives --remove man.7.gz %{_mandir}/man7/man.mandoc.7.gz

  fi

  

  %files

no initial comment

I didn't change the priority, but 200 seems rather high to me.
I suppose I should use higher priority for man-db, groff-base, groff and man-pages.

This is much nicer, thank you. I did a 2 second survey and felt 200 was reasonable since most people probably want to favor the groff and man-db tools over mandoc.

Pull-Request has been merged by dcantrel

4 years ago