alternatives: initial feature

This feature allows you to set alternatives [1].
For example, like this:

   @$(call add,ALTERNATIVES,/usr/bin/xvt:/usr/bin/xterm)

Also, in the config itself, targets for setting alternatives may already
be predefined. For example, use/alternatives/xvt/% allows you to specify
arbitrary alternatives for xvt:
use/alternatives/xvt/xterm, use/alternatives/xvt/mate-terminal, etc.
However, an alternative must be available.

1. https://www.altlinux.org/Alternatives
This commit is contained in:
Anton Midyukov 2023-03-27 15:59:14 +07:00
parent 388c0fbbf5
commit 2f0cf575ec
4 changed files with 31 additions and 0 deletions

View File

@ -54,6 +54,8 @@ include::../features.in/README[]
include::../features.in/00example/README[] include::../features.in/00example/README[]
include::../features.in/alternatives/README[]
include::../features.in/apt-conf/README[] include::../features.in/apt-conf/README[]
include::../features.in/armh-mcom02/README[] include::../features.in/armh-mcom02/README[]

View File

@ -0,0 +1,13 @@
=== features.in/alternatives ===
Данная фича позволяет задавать альтернативы [1].
Например, так:
@$(call add,ALTERNATIVES,/usr/bin/xvt:/usr/bin/xterm)
Также в самом конфиге могут быть уже преопределены цели для установки альтернатив.
Например, use/alternatives/xvt/% позволяет задавать произвольные альтернативы для xvt:
use/alternatives/xvt/xterm, use/alternatives/xvt/mate-terminal и т.д.
При этом альтернатива должна быть доступна.
1. https://www.altlinux.org/Alternatives

View File

@ -0,0 +1,6 @@
use/alternatives:
@$(call add_feature)
@$(call xport,ALTERNATIVES)
use/alternatives/xvt/%: use/alternatives
@$(call add,ALTERNATIVES,/usr/bin/xvt:/usr/bin/$*)

View File

@ -0,0 +1,10 @@
#!/bin/sh -efu
[ -n "$GLOBAL_ALTERNATIVES" ] || exit 0
for alternative in $GLOBAL_ALTERNATIVES; do
candidate="${alternative#*:}"
alternative="${alternative%:*}"
alternatives-manual "$alternative" "$candidate"
done
alternatives-update