Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-alternatives/sh/
Date: Wed, 28 Dec 2022 20:25:36
Message-Id: 1672258026.689f36370d85a43fba6d7329290b5d2086b61fb4.sam@gentoo
1 commit: 689f36370d85a43fba6d7329290b5d2086b61fb4
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Wed Dec 28 20:04:57 2022 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Wed Dec 28 20:07:06 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=689f3637
7
8 app-alternatives/sh: support sys-apps/busybox
9
10 Note that we have to check for CONFIG_FEATURE_SH_STANDALONE=y to avoid
11 busybox preferring internal applets over commands in PATH.
12
13 See https://web.archive.org/web/20221206223848/https://busybox.net/FAQ.html#standalone_shell.
14
15 Closes: https://bugs.gentoo.org/888781
16 Signed-off-by: Sam James <sam <AT> gentoo.org>
17
18 app-alternatives/sh/sh-0.ebuild | 14 ++++++++++++++
19 1 file changed, 14 insertions(+)
20
21 diff --git a/app-alternatives/sh/sh-0.ebuild b/app-alternatives/sh/sh-0.ebuild
22 index 4cd530a89d9c..682533efb3bf 100644
23 --- a/app-alternatives/sh/sh-0.ebuild
24 +++ b/app-alternatives/sh/sh-0.ebuild
25 @@ -5,6 +5,7 @@ EAPI=8
26
27 ALTERNATIVES=(
28 bash:app-shells/bash
29 + busybox:sys-apps/busybox
30 dash:app-shells/dash
31 ksh:app-shells/ksh
32 "lksh:app-shells/mksh[lksh]"
33 @@ -20,6 +21,19 @@ RDEPEND="
34 !!app-eselect/eselect-sh
35 "
36
37 +pkg_setup() {
38 + if [[ -z ${ROOT} ]] && use busybox ; then
39 + # Needed to avoid busybox preferring internal applets over PATH lookups.
40 + # https://web.archive.org/web/20221206223848/https://busybox.net/FAQ.html#standalone_shell.
41 + if busybox bbconfig | grep -q "CONFIG_FEATURE_SH_STANDALONE=y" ; then
42 + ewarn "busybox is configured with CONFIG_FEATURE_SH_STANDALONE=y!"
43 + ewarn "This is not a safe configuration for busybox as /bin/sh."
44 + ewarn "Please use savedconfig to disable CONFIG_FEATURE_SH_STANDALONE on busybox."
45 + die "Aborting due to unsafe Busybox configuration (CONFIG_FEATURE_SH_STANDALONE=y)!"
46 + fi
47 + fi
48 +}
49 +
50 src_install() {
51 dosym "$(get_alternative)" /bin/sh || die
52 }