summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core
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-17 08:29:02 +0100
commit3e311128b2514f4303422cfd9d455ff5965ea55a (patch)
treea98117fc0f155665f44326e48d5ef518786c14f3 /meta/recipes-core
parenta41085d1a63cc629cfb9b4fb1fc30ec43d8e56a7 (diff)
downloadpoky-3e311128b2514f4303422cfd9d455ff5965ea55a.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: 443d1c8c7fb5a69c03c813f3e90758e0add7df4b) Signed-off-by: Jeremy A. Puhlman <jpuhlman@mvista.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit a9d2af8f5b3da8239cf00a52883ca596a19ea23a) Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core')
-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 bf6ddae7d1..33c84bc2c1 100644
--- a/meta/recipes-core/busybox/busybox.inc
+++ b/meta/recipes-core/busybox/busybox.inc
@@ -431,6 +431,32 @@ fi
431 d.prependVar('pkg_postinst_%s' % pkg, postinst) 431 d.prependVar('pkg_postinst_%s' % pkg, postinst)
432} 432}
433 433
434pkg_postinst_${PN}_prepend () {
435 # Need path to saved utils, but they may have be removed on upgrade of busybox
436 # Only use shell to get paths. Also capture if busybox was saved.
437 BUSYBOX=""
438 if [ "x$D" = "x" ] ; then
439 for busybox_rmdir in /tmp/busyboxrm-*; do
440 if [ "$busybox_rmdir" != '/tmp/busyboxrm-*' ] ; then
441 export PATH=$busybox_rmdir:$PATH
442 if [ -e $busybox_rmdir/busybox* ] ; then
443 BUSYBOX="$busybox_rmdir/busybox*"
444 fi
445 fi
446 done
447 fi
448}
449
450pkg_postinst_${PN}_append () {
451 # If busybox exists in the remove directory it is because it was the only shell left.
452 if [ "x$D" = "x" ] ; then
453 if [ "x$BUSYBOX" != "x" ] ; then
454 update-alternatives --remove sh $BUSYBOX
455 rm -f $BUSYBOX
456 fi
457 fi
458}
459
434pkg_prerm_${PN} () { 460pkg_prerm_${PN} () {
435 # This is so you can make busybox commit suicide - removing busybox with no other packages 461 # This is so you can make busybox commit suicide - removing busybox with no other packages
436 # providing its files, this will make update-alternatives work, but the update-rc.d part 462 # providing its files, this will make update-alternatives work, but the update-rc.d part
@@ -451,9 +477,26 @@ pkg_prerm_${PN} () {
451 ln -s ${base_bindir}/busybox $tmpdir/grep 477 ln -s ${base_bindir}/busybox $tmpdir/grep
452 ln -s ${base_bindir}/busybox $tmpdir/tail 478 ln -s ${base_bindir}/busybox $tmpdir/tail
453 export PATH=$PATH:$tmpdir 479 export PATH=$PATH:$tmpdir
480
481 # If busybox is the shell, we need to save it since its the lowest priority shell
482 # Register saved bitbake as the lowest priority shell possible as back up.
483 if [ -n "$(readlink -f /bin/sh | grep busybox)" ] ; then
484 BUSYBOX=$(readlink -f /bin/sh)
485 cp $BUSYBOX $tmpdir/$(basename $BUSYBOX)
486 update-alternatives --install /bin/sh sh $tmpdir/$(basename $BUSYBOX) 1
487 fi
454} 488}
455 489
456pkg_postrm_${PN} () { 490pkg_postrm_${PN} () {
491 # Add path to remove dir in case we removed our only grep
492 if [ "x$D" = "x" ] ; then
493 for busybox_rmdir in /tmp/busyboxrm-*; do
494 if [ "$busybox_rmdir" != '/tmp/busyboxrm-*' ] ; then
495 export PATH=$busybox_rmdir:$PATH
496 fi
497 done
498 fi
499
457 if grep -q "^${base_bindir}/bash$" $D${sysconfdir}/busybox.links* && [ ! -e $D${base_bindir}/bash ]; then 500 if grep -q "^${base_bindir}/bash$" $D${sysconfdir}/busybox.links* && [ ! -e $D${base_bindir}/bash ]; then
458 printf "$(grep -v "^${base_bindir}/bash$" $D${sysconfdir}/shells)\n" > $D${sysconfdir}/shells 501 printf "$(grep -v "^${base_bindir}/bash$" $D${sysconfdir}/shells)\n" > $D${sysconfdir}/shells
459 fi 502 fi