A utility for managing symbolic links (alternatives) of pacman packages.
git clone https://github.com/termux-pacman/pacman-alternatives.git
cd pacman-alternatives
# on pacman-based Termux
make
# on pacman-based Linux distributions
sudo makeVariables for installation configuration:
| Variable | Type | Description | Default |
|---|---|---|---|
DEF_OS |
android/linux |
host operating system | automatically detects host OS |
PREFIX |
absolute path | main path for installing and routing system files | on Linux - /usr, on Android (Termux) - /data/data/com.termux/files/usr |
DESTDIR |
empty/path | path to installing temporary directory | empty |
SYSDIR |
absolute path | main path for routing alternative (links and root files) paths | on Linux - /, on Android (Termux) - /data/data/com.termux/files/usr/ |
LINKDIR |
empty/absolute path | path for routing links of alternatives | empty |
ROOTDIR |
empty/absolute path | path for routing root files of alternatives | empty |
ALTER_FILES_PATH |
relative path/absolute path | path to directory for alternative files | share/pacman-alternatives |
ENABLED_ALTERS_PATH |
relative path/absolute path | path to directory for active alternatives | var/lib/pacman/alternatives |
READER_USER |
username/empty | user for reading alternative files | on Linux - pacman-alternatives, on Android (Termux) - empty (disabling use of reader user) |
BINDIR |
absolute path | path to bin/ |
$(PREFIX)/bin |
BASHPATH |
absolute path | path to bash | $(BINDIR)/bash |
ALPMDIR |
absolute path | path to ALPM directory | $(PREFIX)/share/libalpm |
ALPM_HOOK_DIR |
absolute path | path to hooks directory of ALPM | $(ALPMDIR)/hooks |
ALPM_SCRIPT_DIR |
absolute path | path to scripts directory of ALPM | $(ALPMDIR)/scripts |
| Name | Flag | Description |
|---|---|---|
| Disable | -D/--disable |
Disable enabled alternative(s) |
| Enable | -E/--enable |
Enable available (disabled) alternative(s) |
| Install | -I/--install |
Install alternative file(s) into system |
| Query | -Q/--query |
Output of information about alternative(s), checking alternative(s) |
| Reject | -R/--reject |
Reject selected alternative(s) |
| Select | -S/--select |
Select enabled alternative(s) |
| Uninstall | -U/--uninstall |
Uninstall alternative file(s) from system |
Installing nano (editor:nano) alternative file:
pacman-alternatives -I ./nano.altEnabling editor:nano alternative and selecting it in auto mode:
pacman-alternatives -Ea nanoSummary of enabled alternatives by editor alternative group:
pacman-alternatives -Q editor:Selecting alternative by editor alternative group in manual mode:
pacman-alternatives -S editor:Rejecting selected alternative in editor alternative group and replacing it:
pacman-alternatives -Rr editor:Disabling and rejecting editor:nano alternative without confirmation:
pacman-alternatives -Dr :nano --noconfirmUninstalling nano (editor:nano) alternative from system without confirmation:
pacman-alternatives -U nano --noconfirmChecking all enabled alternatives:
pacman-alternatives -Qc| Variable | Type | Description |
|---|---|---|
PA_RUN_IN_ALPM_HOOKS |
bool | configure output and processing for the ALPM environment |
PA_VERBOSE |
bool | enable verbose mode |
PA_SYSDIR |
absolute path | set path for routing alternative (links and root files) paths (must begin and end with /) |
PA_ROOTDIR |
empty/absolute path | set path for routing root files of alternatives (must begin and end with /) |
PA_LINKDIR |
empty/absolute path | set path for routing links of alternatives (must begin and end with /) |
PA_PREFIX |
absolute path | set path for routing system files |
PA_ALTER_FILES_PATH |
relative path/absolute path | set path to directory for alternative files (if relative path is specified, absolute path is formed using _pa_prefix: "${_pa_prefix}/${PA_ALTER_FILES_PATH}") |
PA_ENABLED_ALTERS_PATH |
relative path/absolute path | set path to directory for active alternatives (if relative path is specified, absolute path is formed using _pa_prefix: "${_pa_prefix}/${PA_ENABLED_ALTERS_PATH}") |
PA_READER_USER |
username/empty | set reader username (if empty, the use of reader user is disabled) |
File alternative is a shell script in the .alt format, which stores alter_group_* functions that allow flexibly configuring alternatives and easily collecting alternative metadata from them (group:name:priority:link:root).
Syntax rules:
- Alternative name and alternative group name can consist of letters, numbers and the special characters
-/_. - Paths in the
sysdir,linkdirandrootdirvariables must begin and end with the/character. - Value of
priorityvariable must be integer. - Paths specified in the
associationsvariable must be relative.
# example file alternative `example.alt`
priority=10
sysdir="/usr/local/"
alter_group_group1() {
associations=(
bin/link1_1:bin/root1_1
bin/link1_2:bin/root1_2
)
# final metadata:
# - group1:example:10:/usr/local/bin/link1_1:/usr/local/bin/root1_1
# - group1:example:10:/usr/local/bin/link1_2:/usr/local/bin/root1_2
}
alter_group_group2() {
sysdir+="bin/"
associations=(link2:root2)
# final metadata:
# - group2:example:10:/usr/local/bin/link2:/usr/local/bin/root2
}
function alter_group_group3 {
priority=20
linkdir="/usr/"
rootdir="/usr/local/"
associations=(bin/link3:sbin/root3)
# final metadata:
# - group3:example:20:/usr/bin/link3:/usr/local/sbin/root3
}