summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorJeremy Puhlman <jpuhlman@mvista.com>2020-04-02 15:58:20 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-04-05 11:46:38 +0100
commitac39c11d4988ced28a8d549068e2e870b4ad90d6 (patch)
tree1ddf6f772f473af327c565591b8f3e0e5ff5c267 /meta
parent1b15cc6e65c18cda7888a2eef1f55bf0a660ae7e (diff)
downloadpoky-ac39c11d4988ced28a8d549068e2e870b4ad90d6.tar.gz
busybox: on upgrade save busybox if it is the last shell
During a busybox upgrade on a ipk based system, it is possible that busybox is the only shell in the system. During the uninstall the alternative for /bin/sh is removed and everything after that goes down hill. * Add a check to verify if busybox is the shell, and save it to the busyboxrm directory created in tmp. Then add an alternative for /bin/sh that points to that busybox at the lowest priority. * Add PATH to the busyboxrm directory using shell(as during an upgrade busybox and its links are missing). * When install over remove extra busybox if present. deb and rpm are uneffected by the bug because they both drag in bash, however neither upgrade seemed to have issue with the changes. [YOCTO 13850] (From OE-Core rev: a9d2af8f5b3da8239cf00a52883ca596a19ea23a) Signed-off-by: Jeremy A. Puhlman <jpuhlman@mvista.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-core/busybox/busybox.inc43
1 files changed, 43 insertions, 0 deletions
diff --git a/meta/recipes-core/busybox/busybox.inc b/meta/recipes-core/busybox/busybox.inc
index 1a82f23b0f..344e891f7a 100644
--- a/meta/recipes-core/busybox/busybox.inc
+++ b/meta/recipes-core/busybox/busybox.inc
@@ -433,6 +433,32 @@ fi
433 d.prependVar('pkg_postinst_%s' % pkg, postinst) 433 d.prependVar('pkg_postinst_%s' % pkg, postinst)
434} 434}
435 435
436pkg_postinst_${PN}_prepend () {
437 # Need path to saved utils, but they may have be removed on upgrade of busybox
438 # Only use shell to get paths. Also capture if busybox was saved.
439 BUSYBOX=""
440 if [ "x$D" = "x" ] ; then
441 for busybox_rmdir in /tmp/busyboxrm-*; do
442 if [ "$busybox_rmdir" != '/tmp/busyboxrm-*' ] ; then
443 export PATH=$busybox_rmdir:$PATH
444 if [ -e $busybox_rmdir/busybox* ] ; then
445 BUSYBOX="$busybox_rmdir/busybox*"
446 fi
447 fi
448 done
449 fi
450}
451
452pkg_postinst_${PN}_append () {
453 # If busybox exists in the remove directory it is because it was the only shell left.
454 if [ "x$D" = "x" ] ; then
455 if [ "x$BUSYBOX" != "x" ] ; then
456 update-alternatives --remove sh $BUSYBOX
457 rm -f $BUSYBOX
458 fi
459 fi
460}
461
436pkg_prerm_${PN} () { 462pkg_prerm_${PN} () {
437 # This is so you can make busybox commit suicide - removing busybox with no other packages 463 # This is so you can make busybox commit suicide - removing busybox with no other packages
438 # providing its files, this will make update-alternatives work, but the update-rc.d part 464 # providing its files, this will make update-alternatives work, but the update-rc.d part
@@ -453,9 +479,26 @@ pkg_prerm_${PN} () {
453 ln -s ${base_bindir}/busybox $tmpdir/grep 479 ln -s ${base_bindir}/busybox $tmpdir/grep
454 ln -s ${base_bindir}/busybox $tmpdir/tail 480 ln -s ${base_bindir}/busybox $tmpdir/tail
455 export PATH=$PATH:$tmpdir 481 export PATH=$PATH:$tmpdir
482
483 # If busybox is the shell, we need to save it since its the lowest priority shell
484 # Register saved bitbake as the lowest priority shell possible as back up.
485 if [ -n "$(readlink -f /bin/sh | grep busybox)" ] ; then
486 BUSYBOX=$(readlink -f /bin/sh)
487 cp $BUSYBOX $tmpdir/$(basename $BUSYBOX)
488 update-alternatives --install /bin/sh sh $tmpdir/$(basename $BUSYBOX) 1
489 fi
456} 490}
457 491
458pkg_postrm_${PN} () { 492pkg_postrm_${PN} () {
493 # Add path to remove dir in case we removed our only grep
494 if [ "x$D" = "x" ] ; then
495 for busybox_rmdir in /tmp/busyboxrm-*; do
496 if [ "$busybox_rmdir" != '/tmp/busyboxrm-*' ] ; then
497 export PATH=$busybox_rmdir:$PATH
498 fi
499 done
500 fi
501
459 if grep -q "^${base_bindir}/bash$" $D${sysconfdir}/busybox.links* && [ ! -e $D${base_bindir}/bash ]; then 502 if grep -q "^${base_bindir}/bash$" $D${sysconfdir}/busybox.links* && [ ! -e $D${base_bindir}/bash ]; then
460 printf "$(grep -v "^${base_bindir}/bash$" $D${sysconfdir}/shells)\n" > $D${sysconfdir}/shells 503 printf "$(grep -v "^${base_bindir}/bash$" $D${sysconfdir}/shells)\n" > $D${sysconfdir}/shells
461 fi 504 fi