busybox: make postinst run firstly before update-alternatives

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.

(From OE-Core rev: 3a035bd0a06a6ded4d0ce7e35a3bce42245727d2)

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Robert Yang
2019-06-26 15:40:22 +08:00
committed by Richard Purdie
parent 8d22a45cdd
commit cebda73b3f

View 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} () {