]> code.ossystems Code Review - openembedded-core.git/commitdiff
busybox: make postinst run firstly before update-alternatives
authorRobert Yang <liezhi.yang@windriver.com>
Wed, 26 Jun 2019 07:40:22 +0000 (15:40 +0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 27 Jun 2019 11:20:24 +0000 (12:20 +0100)
The update-alternatives.bbclass' postinst script runs firstly before other
postinst, but busybox needs set basic tools such as sed command firstly,
otherwise, update-alternatives doesn't work, so run busybox' postinst firstly
to fix the problem.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-core/busybox/busybox.inc

index 174ce5a8c0b837f9277b7113a18481ea372c5861..49165d7f51b606e3e7ea748545afde3b733d38e9 100644 (file)
@@ -392,34 +392,40 @@ python do_package_prepend () {
         set_alternative_vars("${sysconfdir}/busybox.links.suid", "${base_bindir}/busybox.suid")
 }
 
-pkg_postinst_${PN} () {
-       # This part of code is dedicated to the on target upgrade problem.
-       # It's known that if we don't make appropriate symlinks before update-alternatives calls,
-       # there will be errors indicating missing commands such as 'sed'.
-       # These symlinks will later be updated by update-alternatives calls.
-       test -n 2 > /dev/null || alias test='busybox test'
-       if test "x$D" = "x"; then
-               # Remove busybox.nosuid if it's a symlink, because this situation indicates
-               # that we're installing or upgrading to a one-binary busybox.
-               if test -h ${base_bindir}/busybox.nosuid; then
-                       rm -f ${base_bindir}/busybox.nosuid
-               fi
-               for suffix in "" ".nosuid" ".suid"; do
-                       if test -e ${sysconfdir}/busybox.links$suffix; then
-                               while read link; do
-                                       if test ! -e "$link"; then
-                                               # we can use busybox here because even if we are using splitted busybox
-                                               # we've made a symlink from /bin/busybox to /bin/busybox.nosuid.
-                                               busybox rm -f $link
-                                               busybox ln -s "${base_bindir}/busybox$suffix" $link
-                                       fi
-                               done < ${sysconfdir}/busybox.links$suffix
-                       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
+# This part of code is dedicated to the on target upgrade problem.  It's known
+# that if we don't make appropriate symlinks before update-alternatives calls,
+# there will be errors indicating missing commands such as 'sed'.
+# These symlinks will later be updated by update-alternatives calls.
+# The update-alternatives.bbclass' postinst script runs firstly before other
+# postinst, but this part of code needs run firstly, so add this funtion.
+python populate_packages_updatealternatives_append() {
+    postinst = """
+test -n 2 > /dev/null || alias test='busybox test'
+if test "x$D" = "x"; then
+    # Remove busybox.nosuid if it's a symlink, because this situation indicates
+    # that we're installing or upgrading to a one-binary busybox.
+    if test -h ${base_bindir}/busybox.nosuid; then
+        rm -f ${base_bindir}/busybox.nosuid
+    fi
+    for suffix in "" ".nosuid" ".suid"; do
+        if test -e ${sysconfdir}/busybox.links$suffix; then
+            while read link; do
+                if test ! -e "$link"; then
+                    # we can use busybox here because even if we are using splitted busybox
+                    # we've made a symlink from /bin/busybox to /bin/busybox.nosuid.
+                    busybox rm -f $link
+                    busybox ln -s "${base_bindir}/busybox$suffix" $link
+                fi
+            done < ${sysconfdir}/busybox.links$suffix
+        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
+
+"""
+    d.prependVar('pkg_postinst_%s' % pkg, postinst)
 }
 
 pkg_prerm_${PN} () {