From 2f0cf575ec2323f94fa2704c4e72ca48e1f963e3 Mon Sep 17 00:00:00 2001 From: Anton Midyukov Date: Mon, 27 Mar 2023 15:59:14 +0700 Subject: [PATCH] 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 --- doc/mkimage-profiles.asciidoc | 2 ++ features.in/alternatives/README | 13 +++++++++++++ features.in/alternatives/config.mk | 6 ++++++ .../rootfs/image-scripts.d/99-alternatives | 10 ++++++++++ 4 files changed, 31 insertions(+) create mode 100644 features.in/alternatives/README create mode 100644 features.in/alternatives/config.mk create mode 100755 features.in/alternatives/rootfs/image-scripts.d/99-alternatives diff --git a/doc/mkimage-profiles.asciidoc b/doc/mkimage-profiles.asciidoc index 43b622a1..12f65d85 100644 --- a/doc/mkimage-profiles.asciidoc +++ b/doc/mkimage-profiles.asciidoc @@ -54,6 +54,8 @@ include::../features.in/README[] include::../features.in/00example/README[] +include::../features.in/alternatives/README[] + include::../features.in/apt-conf/README[] include::../features.in/armh-mcom02/README[] diff --git a/features.in/alternatives/README b/features.in/alternatives/README new file mode 100644 index 00000000..c0ce72b9 --- /dev/null +++ b/features.in/alternatives/README @@ -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 diff --git a/features.in/alternatives/config.mk b/features.in/alternatives/config.mk new file mode 100644 index 00000000..e65456b7 --- /dev/null +++ b/features.in/alternatives/config.mk @@ -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/$*) diff --git a/features.in/alternatives/rootfs/image-scripts.d/99-alternatives b/features.in/alternatives/rootfs/image-scripts.d/99-alternatives new file mode 100755 index 00000000..c8747aaf --- /dev/null +++ b/features.in/alternatives/rootfs/image-scripts.d/99-alternatives @@ -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