]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
bash: use update-alternatives for the bash binary
authorAndreas Oberritter <obi@opendreambox.org>
Sat, 15 Oct 2016 17:54:37 +0000 (19:54 +0200)
committerAndreas Oberritter <obi@opendreambox.org>
Tue, 17 Oct 2017 02:38:27 +0000 (04:38 +0200)
Busybox may offer a bash applet. If enabled, the alternatives mechanism
avoids breaking logins if bash gets deinstalled while /bin/bash is configured
as a login shell.

Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
meta/recipes-core/busybox/busybox.inc
meta/recipes-extended/bash/bash.inc

index 39c2eef082d5fa8ce9a51dd480eafa57eec53949..56cd6b9180f9c825d06545c759a192695c502bc8 100644 (file)
@@ -395,6 +395,9 @@ pkg_postinst_${PN} () {
                        fi
                done
        fi
+       if grep -q "^${base_bindir}/bash$" $D${sysconfdir}/busybox.links*; then
+               grep -q "^${base_bindir}/bash$" $D${sysconfdir}/shells || echo ${base_bindir}/bash >> $D${sysconfdir}/shells
+       fi
 }
 
 pkg_prerm_${PN} () {
@@ -419,6 +422,12 @@ pkg_prerm_${PN} () {
        export PATH=$PATH:$tmpdir
 }
 
+pkg_postrm_${PN} () {
+       if grep -q "^${base_bindir}/bash$" $D${sysconfdir}/busybox.links* && [ ! -e $D${base_bindir}/bash ]; then
+               printf "$(grep -v "^${base_bindir}/bash$" $D${sysconfdir}/shells)\n" > $D${sysconfdir}/shells
+       fi
+}
+
 pkg_prerm_${PN}-syslog () {
        # remove syslog
        if test "x$D" = "x"; then
index 1d08526c9e758bfcbdc80733567a46e17b0a523a..a05b987b87bfc47d0c21001daedb7319a37ca4fb 100644 (file)
@@ -14,9 +14,11 @@ EXTRA_OECONF = "--enable-job-control --without-bash-malloc"
 # This is what other major distros do. And this is what we wanted. See bug#5359 and bug#7137.
 CFLAGS += "-DNON_INTERACTIVE_LOGIN_SHELLS"
 
-ALTERNATIVE_${PN} = "sh"
+ALTERNATIVE_${PN} = "bash sh"
+ALTERNATIVE_LINK_NAME[bash] = "${base_bindir}/bash"
+ALTERNATIVE_TARGET[bash] = "${base_bindir}/bash"
 ALTERNATIVE_LINK_NAME[sh] = "${base_bindir}/sh"
-ALTERNATIVE_TARGET[sh] = "${base_bindir}/bash"
+ALTERNATIVE_TARGET[sh] = "${base_bindir}/bash.${BPN}"
 ALTERNATIVE_PRIORITY = "100"
 
 RDEPENDS_${PN} += "base-files"