summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core
diff options
context:
space:
mode:
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