#782493 u-a: allow to override the priorities of alternatives at a system-wide level

Package:
dpkg
Source:
dpkg
Description:
Debian package management system
Submitter:
Raphaël Hertzog
Date:
2024-10-28 10:15:01 UTC
Severity:
wishlist
#782493#5
Date:
2015-04-13 07:02:26 UTC
From:
To:
In the context a Debian derivative, you might want to tweak the priorities
of alternatives because you make different choices about what should be
the default implementation of something (my immediate use case was to
change the default desktop session which is managed with x-session-manager).

Yet changing the priority of an alternative requires forking the package
because the priority is hardcoded in maintainer scripts. It would be nice
if update-alternatives could look up some system-wide override data and
use those values when they exist instead of the value provided on the
command line.

This would also make it easier to change defaults at a company-wide level
while still leaving the possibility for each user to change the
alternative to point to something else.

I imagine it could take the form of a directory
/etc/alternatives/priorities.d/ (or
/etc/dpkg/update-alternatives/priorities.d) with files containing simple
"<name> <path> <priority>" lines (where <name> is the name of the symlink
in /etc/alternatives/ and <path> is the full path of the alternative in the
master link).

Cheers,

#782493#10
Date:
2024-10-28 09:59:42 UTC
From:
To:
To give an example of where this is needed, the package

microsoft-edge-beta

available from the non-debian repo

$ cat /etc/apt/sources.list.d/microsoft-edge-beta.list
deb [arch=amd64] https://packages.microsoft.com/repos/edge/ stable main

installs an alternative:

$ update-alternatives --display x-www-browser
x-www-browser - auto mode
  link best version is /usr/bin/microsoft-edge-beta
  link currently points to /usr/bin/microsoft-edge-beta
  link x-www-browser is /usr/bin/x-www-browser
  slave x-www-browser.1.gz is /usr/share/man/man1/x-www-browser.1.gz
/usr/bin/epiphany-browser - priority 85
  slave x-www-browser.1.gz: /usr/share/man/man1/epiphany-browser.1.gz
/usr/bin/firefox - priority 70
  slave x-www-browser.1.gz: /usr/share/man/man1/firefox.1.gz
/usr/bin/microsoft-edge-beta - priority 150

and another

$ update-alternatives --display gnome-www-browser
gnome-www-browser - auto mode
  link best version is /usr/bin/microsoft-edge-beta
  link currently points to /usr/bin/microsoft-edge-beta
  link gnome-www-browser is /usr/bin/gnome-www-browser
  slave gnome-www-browser.1.gz is /usr/share/man/man1/gnome-www-browser.1.gz
/usr/bin/epiphany-browser - priority 85
  slave gnome-www-browser.1.gz: /usr/share/man/man1/epiphany-browser.1.gz
/usr/bin/firefox - priority 70
  slave gnome-www-browser.1.gz: /usr/share/man/man1/firefox.1.gz
/usr/bin/microsoft-edge-beta - priority 150

It is using priority 150 (!) while firefox/sid is using priority 70.
The epiphany-browser has priority 85, which I think is a little bit of
overreach, but whatever. And at least there's a place to discuss it:
https://bugs.debian.org/824613

I would classify this as more a deliberate attack than a bug. But the
MS Edge package is not distributed by Debian, so there's not really
anything we can do about it.

Ideally, we'd have a mechanism to override priorities from random
out-of-line packages. (And maybe pre-populate it with offenders like
this particular one. In this case, I'd override to -100 like the
update-alternatives(1) example for /bin/ed.)

(Why do I have MS Edge installed? Other obnoxious systems I need to
use require it.)