From ArchWiki
Jump to navigation Jump to search

The Idea

Provide an alternatives system to allow users to select which package provides a file.

Current Situation

'/usr/bin/sh' is a symlink to 'bash'. People may want to use a different shell interpreter for 'sh', e.g. 'dash', but this is currently not possible without rebuilding the bash package to remove the symlink first.



An alternative would be specified in a PKGBUILD as:


Makepkg would add this information to the .PKGINFO file:

 alternative = python


On installation of a package with a specified alternative, there are two options. Check if the alternative symlink is there and

1) if not present, create the symlink


2) if present, do "nothing".

  • Should also issue a warning if the alternative symlink is not pointing to another file with the same alternative.
  • output notification like optdepends?

New pacman option examples

List all alternatives from installed packages

 pacman -A
   python ->
      usr/bin/python3  (python3 3.7.2-3)
      usr/bin/python3.6  (python3 3.6.7-1)
   sh ->
      usr/bin/bash  (bash 5.0.002-1)
      usr/bin/dash  (dash

List installed alternatives for a given command

 pacman -A sh
   usr/bin/bash  (bash 5.0.002-1)
   usr/bin/dash  (dash

Update alternative by package (print error if mismatch):

 pacman -Au sh dash
   sh -> /usr/bin/dash

Update alternative by path (print error if mismatch):

 pacman -Au sh /usr/bin/dash
   sh -> /usr/bin/dash

Other options requiring behaviour changes

pacman -Si <pkg>
pacman -Qi <pkg>    - also note whether alternative is active
pacman -Qo <alternative>
pacman -Ql <pkg>


pacman -F...