Overview

Request 831020 accepted

- Fix usage of update-alternatives (boo#1175919).

Loading...

Antoine Belvire's avatar

Rebased request since other changes were pushed in Base:System / man.


Dr. Werner Fink's avatar

How does your approach remove an already exising entry for group man with path /usr/lib/man-db/wrapper? Also, regardless what https://en.opensuse.org/openSUSE:Packaging_Multiple_Version_guidelines#update-alternatives_mechanism says, I wnatto use %preun as at this point the path is installed and not removed in case of a real deintallation.


Antoine Belvire's avatar

@WernerFink

How does your approach remove an already exising entry for group man with path /usr/lib/man-db/wrapper?

Both your approach and mine will remove the existing entry /usr/lib/man-db/wrapper when updating from current package. Because update-alternatives --install /usr/bin/man man /usr/libexec/man-db/wrapper will remove the old path /usr/lib/man-db/wrapper for group because path doesn't exist anymore.

But if in future the path changes again e.g. to /usr/libexec2/man-db/wrapper the %post of updated package will call update-alternatives --install /usr/bin/man man /usr/libexec2/man-db/wrapper which won't remove /usr/libexec/man-db/wrapper because path will exist (because %post of updated package is executed before old package deinstallation).

I wnatto use %preun as at this point the path is installed and not removed in case of a real deinstallation.

I don't get it: The guidelines' approach equally works for package upgrade and removal. update-alternatives --remove... in %postun will clean things if path doesn't exist anymore - in case of path update like the bug and in case of package removal as well.


Dr. Werner Fink's avatar

The quidline is missing --quiet together with --remove as without --quiet there is a message which will reported by rpm and therefore with zypper and yast


Dr. Werner Fink's avatar

As package mandoc simply conflicts nowadays:

Fri Jan 10 10:36:08 UTC 2020 - Ludwig Nussel lnussel@suse.de - get rid of alternatives altogether, just conflict (boo#1160568)

maybe it is better to skip the whole u-a stuff at all


Dr. Werner Fink's avatar

Beside the test and usage of %{_libexecdir}/man-db/wrapper ... do you have tested this in %preun scriptlet as well? This because IMHO this is the correct location for disabling a symbolic link at deinstalling a package as in the %postun scriptlet the file below %{_libexecdir}/man-db/ are removed in this case.


Antoine Belvire's avatar

Hi @WernerFink, I've only tested the update with the scriptlet in %postun.

update-alternatives handles well the removal when the path %{_libexecdir}/man-db/wrapper doesn't exist anymore in %postun.

I see nothing wrong with calling it in %preun but I preferred to follow the guidelines at https://en.opensuse.org/openSUSE:Packaging_Multiple_Version_guidelines#update-alternatives_mechanism.


Antoine Belvire's avatar

However, I assume that calling update-alternatives --remove... in %preun would be more complex because it would require to test both $1 -eq 0 (package removal: %{_libexecdir}/man-db/wrapper still exists but we have to clean the alternative because it's going to be removed) and another condition to check the case of an update changing the alternative path (the bug case).

I suppose that's why simply using the file presence condition in %postun has been chosen in guidelines.


Dr. Werner Fink's avatar

https://bugzilla.opensuse.org/show_bug.cgi?id=1175919#c5


Dr. Werner Fink's avatar

Means to increase the priority will help ... and using %preun avoid other messages


Antoine Belvire's avatar

@WernerFink: I think increasing priority is not desirable for this case. Path has changed: Adding new path with higher priority may work but keeping the old path just looks awkward.

update-alternatives --remove in %postun seems the standard way, playing with priority/%preun/crafting a specific solution for the man package is unnecessary and less maintainable imho.


Dr. Werner Fink's avatar

Just tested the value 1020 instead of 1010 and it works on update

noether:~ # update-alternatives --query man
Name: man
Link: /usr/bin/man
Slaves:
 apropos /usr/bin/apropos
 apropos.1.gz /usr/share/man/man1/apropos.1.gz
 man.1.gz /usr/share/man/man1/man.1.gz
 whatis /usr/bin/whatis
 whatis.1.gz /usr/share/man/man1/whatis.1.gz
Status: auto
Best: /usr/lib/man-db/wrapper
Value: /usr/lib/man-db/wrapper

Alternative: /usr/lib/man-db/wrapper
Priority: 1010
Slaves:
 apropos /usr/lib/man-db/whatis
 apropos.1.gz /usr/share/man/man1/apropos-db.1.gz
 man.1.gz /usr/share/man/man1/man-db.1.gz
 whatis /usr/lib/man-db/whatis
 whatis.1.gz /usr/share/man/man1/whatis-db.1.gz
noether:~ # rpm -Uhv /abuild/oscbuild/openSUSE_Factory/home/abuild/rpmbuild/RPMS/x86_64/man-2.8.4-0.x86_64.rpm --force
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:man-2.8.4-0                      ################################# [ 50%]
Updating /etc/sysconfig/cron ...
Cleaning up / removing...
   2:man-2.8.4-10.1                   ################################# [100%]
noether:~ # update-alternatives --query man
update-alternatives: warning: alternative /usr/lib/man-db/wrapper (part of link group man) doesn't exist; removing from list of alternatives
Name: man
Link: /usr/bin/man
Slaves:
 apropos /usr/bin/apropos
 apropos.1.gz /usr/share/man/man1/apropos.1.gz
 man.1.gz /usr/share/man/man1/man.1.gz
 whatis /usr/bin/whatis
 whatis.1.gz /usr/share/man/man1/whatis.1.gz
Status: auto
Best: /usr/libexec/man-db/wrapper
Value: /usr/libexec/man-db/wrapper

Alternative: /usr/libexec/man-db/wrapper
Priority: 1020
Slaves:
 apropos /usr/libexec/man-db/whatis
 apropos.1.gz /usr/share/man/man1/apropos-db.1.gz
 man.1.gz /usr/share/man/man1/man-db.1.gz
 whatis /usr/libexec/man-db/whatis
 whatis.1.gz /usr/share/man/man1/whatis-db.1.gz

and no dangling symlinks

noether:~ # find  /usr/bin/man /usr/bin/apropos /usr/share/man/man1/apropos.1.gz /usr/share/man/man1/man.1.gz /usr/bin/whatis /usr/share/man/man1/whatis.1.gz  -ls
  1461710      0 lrwxrwxrwx   1 root     root           21 Sep  1 09:28 /usr/bin/man -> /etc/alternatives/man
  1461711      0 lrwxrwxrwx   1 root     root           25 Sep  1 09:28 /usr/bin/apropos -> /etc/alternatives/apropos
202661319      0 lrwxrwxrwx   1 root     root           30 Sep  1 09:28 /usr/share/man/man1/apropos.1.gz -> /etc/alternatives/apropos.1.gz
202661338      0 lrwxrwxrwx   1 root     root           26 Sep  1 09:28 /usr/share/man/man1/man.1.gz -> /etc/alternatives/man.1.gz
  1461712      0 lrwxrwxrwx   1 root     root           24 Sep  1 09:28 /usr/bin/whatis -> /etc/alternatives/whatis
202661345      0 lrwxrwxrwx   1 root     root           29 Sep  1 09:28 /usr/share/man/man1/whatis.1.gz -> /etc/alternatives/whatis.1.gz
noether:~ # find  /usr/bin/man /usr/bin/apropos /usr/share/man/man1/apropos.1.gz /usr/share/man/man1/man.1.gz /usr/bin/whatis /usr/share/man/man1/whatis.1.gz -follow -ls
137535230     16 -rwxr-xr-x   1 root     root        14800 Sep  1 09:25 /usr/bin/man
137535229     48 -rwxr-xr-x   1 root     root        49024 Sep  1 09:25 /usr/bin/apropos
201572731      4 -rw-r--r--   1 root     root         2859 Sep  1 09:25 /usr/share/man/man1/apropos.1.gz
201736602     16 -rw-r--r--   1 root     root        12922 Sep  1 09:25 /usr/share/man/man1/man.1.gz
137535229     48 -rwxr-xr-x   1 root     root        49024 Sep  1 09:25 /usr/bin/whatis
201769841      4 -rw-r--r--   1 root     root         2710 Sep  1 09:25 /usr/share/man/man1/whatis.1.gz

Antoine Belvire's avatar

Sure... there is no dangling symlink with the solution of this request either but whatever!


Antoine Belvire's avatar

@WernerFink: Plus with your solution the old path will not be cleaned properly from alternative list.

See the message update-alternatives: warning: alternative /usr/lib/man-db/wrapper (part of link group man) doesn't exist; removing from list of alternatives which will be displayed on every calls to update-alternatives --list man or update-alternatives --query man.


Dr. Werner Fink's avatar

Hmmm ... and with your approach the old already installed package provides the same problem as /usr/lib/man-db/wrapper is not equal to /usr/libexec/man-db/wrapper

The only approach would be hardcoded

update-alternatives --remove man /usr/lib/man-db/wrapper


Antoine Belvire's avatar

@WernerFink: No because %post of new package will call again update-alternatives --install /usr/bin/man man /usr/libexec/man-db/wrapper which will have the "side" effect to clean old path /usr/lib/man-db/wrapper since it doesn't exist anymore this time.

This is the same reason why re-installing man with zypper in -f man fixes the issue.

And when the path changes again, this solution will avoid this kind of problem.

Request History
Antoine Belvire's avatar

1Antoine1 created request

- Fix usage of update-alternatives (boo#1175919).


Dr. Werner Fink's avatar

WernerFink accepted request

It work only as `--quiet` is used, indeed ... the guideline `https://en.opensuse.org/openSUSE:Packaging_Multiple_Version_guidelines#update-alternatives_mechanism` should be completed at this point as

openSUSE Build Service is sponsored by