summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2022-12-28 20:04:57 +0000
committerSam James <sam@gentoo.org>2022-12-28 20:07:06 +0000
commit689f36370d85a43fba6d7329290b5d2086b61fb4 (patch)
tree2e7da2365c98b9f5bb867f553375165520fee931 /app-alternatives/sh
parentsys-devel/crossdev: add 20221228 (diff)
downloadgentoo-689f36370d85a43fba6d7329290b5d2086b61fb4.tar.gz
gentoo-689f36370d85a43fba6d7329290b5d2086b61fb4.tar.bz2
gentoo-689f36370d85a43fba6d7329290b5d2086b61fb4.zip
app-alternatives/sh: support sys-apps/busybox
Note that we have to check for CONFIG_FEATURE_SH_STANDALONE=y to avoid busybox preferring internal applets over commands in PATH. See https://web.archive.org/web/20221206223848/https://busybox.net/FAQ.html#standalone_shell. Closes: https://bugs.gentoo.org/888781 Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'app-alternatives/sh')
-rw-r--r--app-alternatives/sh/sh-0.ebuild14
1 files changed, 14 insertions, 0 deletions
diff --git a/app-alternatives/sh/sh-0.ebuild b/app-alternatives/sh/sh-0.ebuild
index 4cd530a89d9c..682533efb3bf 100644
--- a/app-alternatives/sh/sh-0.ebuild
+++ b/app-alternatives/sh/sh-0.ebuild
@@ -5,6 +5,7 @@ EAPI=8
ALTERNATIVES=(
bash:app-shells/bash
+ busybox:sys-apps/busybox
dash:app-shells/dash
ksh:app-shells/ksh
"lksh:app-shells/mksh[lksh]"
@@ -20,6 +21,19 @@ RDEPEND="
!!app-eselect/eselect-sh
"
+pkg_setup() {
+ if [[ -z ${ROOT} ]] && use busybox ; then
+ # Needed to avoid busybox preferring internal applets over PATH lookups.
+ # https://web.archive.org/web/20221206223848/https://busybox.net/FAQ.html#standalone_shell.
+ if busybox bbconfig | grep -q "CONFIG_FEATURE_SH_STANDALONE=y" ; then
+ ewarn "busybox is configured with CONFIG_FEATURE_SH_STANDALONE=y!"
+ ewarn "This is not a safe configuration for busybox as /bin/sh."
+ ewarn "Please use savedconfig to disable CONFIG_FEATURE_SH_STANDALONE on busybox."
+ die "Aborting due to unsafe Busybox configuration (CONFIG_FEATURE_SH_STANDALONE=y)!"
+ fi
+ fi
+}
+
src_install() {
dosym "$(get_alternative)" /bin/sh || die
}