From: Martin Jansa <martin.jansa@gmail.com>
To: Qi.Chen@windriver.com
Cc: qingtao.cao@windriver.com, openembedded-core@lists.openembedded.org
Subject: Re: [PATCH 1/1] busybox: fix the on-target upgrade problem
Date: Sat, 6 Jul 2013 12:27:28 +0200 [thread overview]
Message-ID: <20130706102728.GA30517@jama> (raw)
In-Reply-To: <61d58e6bfc00142957a77a3a1747c9848710917a.1372826827.git.Qi.Chen@windriver.com>
[-- Attachment #1: Type: text/plain, Size: 5837 bytes --]
On Wed, Jul 03, 2013 at 12:48:12PM +0800, Qi.Chen@windriver.com wrote:
> From: Chen Qi <Qi.Chen@windriver.com>
>
> We now can have a 'one-binary' version of busybox, or 'two-binary'
> version of busybox, controlled by the 'BUSYBOX_SPLIT_SUID' variable.
> This makes on-target upgrade a problem, as we have to support the
> following four upgrading paths.
>
> For convenience, in the following context, A is used to denote a
> 'two-binary' version of busybox while B is used to denote a 'one-binary'
> version of busybox.
>
> A --(upgrade)--> B
> B --(upgrade)--> A
> A --(upgrade)--> A
> B --(upgrade)--> B
>
> This patch makes effort to support the above four situations.
Thanks for looking into it (it's more complicated then I've first
expected) and it looks like there is more issues probably caused
by applet path moved in latest busybox upgrade (but ip looks weird) :/
update-alternatives: Error: cannot register alternative addgroup to
/usr/sbin/addgroup since it is already registered to /bin/addgroup
update-alternatives: Error: cannot register alternative adduser to
/usr/sbin/adduser since it is already registered to /bin/adduser
update-alternatives: Error: cannot register alternative delgroup to
/usr/sbin/delgroup since it is already registered to /bin/delgroup
update-alternatives: Error: cannot register alternative deluser to
/usr/sbin/deluser since it is already registered to /bin/deluser
update-alternatives: Error: cannot register alternative ip to /sbin/ip
since it is already registered to /bin/ip
SHR root@gjama ~ $ cat /var/lib/opkg/alternatives/ip
/bin/ip
busybox 50
/bin/busybox 50
/bin/busybox.nosuid 50
SHR root@gjama ~ $ cat /var/lib/opkg/alternatives/adduser
/bin/adduser
/bin/busybox.nosuid 50
SHR root@gjama ~ $ cat /var/lib/opkg/alternatives/addgroup
/bin/addgroup
/bin/busybox.nosuid 50
SHR root@gjama ~ $ cat /var/lib/opkg/alternatives/delgroup
/bin/delgroup
/bin/busybox.nosuid 50
SHR root@gjama ~ $ cat /var/lib/opkg/alternatives/deluser
/bin/deluser
/bin/busybox.nosuid 50
> [YOCTO #4802]
>
> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
> ---
> meta/recipes-core/busybox/busybox.inc | 48 +++++++++++++++++++++++++++++++++
> 1 file changed, 48 insertions(+)
>
> diff --git a/meta/recipes-core/busybox/busybox.inc b/meta/recipes-core/busybox/busybox.inc
> index 8567d64..acd2bfb 100644
> --- a/meta/recipes-core/busybox/busybox.inc
> +++ b/meta/recipes-core/busybox/busybox.inc
> @@ -190,6 +190,10 @@ do_install () {
> install -m 0644 ${S}/busybox.links.suid ${D}${sysconfdir}
> install -m 0644 ${S}/busybox.links.nosuid ${D}${sysconfdir}
> ln -sf busybox.nosuid ${D}${base_bindir}/sh
> + # Keep a default busybox for people who want to invoke busybox directly.
> + # This is also useful for the on device upgrade. Because we want
> + # to use the busybox command in postinst.
> + ln -sf busybox.nosuid ${D}${base_bindir}/busybox
> else
> if grep -q "CONFIG_FEATURE_SUID=y" ${B}/.config; then
> install -m 4755 ${B}/busybox ${D}${base_bindir}
> @@ -198,6 +202,12 @@ do_install () {
> fi
> install -m 0644 ${S}/busybox.links ${D}${sysconfdir}
> ln -sf busybox ${D}${base_bindir}/sh
> + # We make this symlink here to eliminate the error when upgrading together
> + # with busybox-syslog. Without this symlink, the opkg may think of the
> + # busybox.nosuid as obsolete and remove it, resulting in dead links like
> + # /bin/sed -> /bin/busybox.nosuid. This will make upgrading busybox-syslog fail.
> + # This symlink will be safely deleted in postinst, thus no negative effect.
> + ln -sf busybox ${D}${base_bindir}/busybox.nosuid
> fi
> else
> install -d ${D}${base_bindir} ${D}${base_sbindir}
> @@ -306,6 +316,44 @@ python do_package_prepend () {
> set_alternative_vars("/etc/busybox.links.suid", "/bin/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 /bin/busybox.nosuid; then
> + rm -f /bin/busybox.nosuid
> + fi
> + for suffix in "" ".nosuid" ".suid"; do
> + if test -e /etc/busybox.links$suffix; then
> + while read link; do
> + if test ! -e "$link"; then
> + case "$link" in
> + /*/*/*)
> + to="../../bin/busybox$suffix"
> + ;;
> + /bin/*)
> + to="busybox$suffix"
> + ;;
> + /*/*)
> + to="../bin/busybox$suffix"
> + ;;
> + esac
> + # 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 $to $link
> + fi
> + done < /etc/busybox.links$suffix
> + fi
> + done
> + fi
> +}
> +
> pkg_prerm_${PN} () {
> # This is so you can make busybox commit suicide - removing busybox with no other packages
> # providing its files, this will make update-alternatives work, but the update-rc.d part
> --
> 1.7.9.5
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
--
Martin 'JaMa' Jansa jabber: Martin.Jansa@gmail.com
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 205 bytes --]
next prev parent reply other threads:[~2013-07-06 10:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1372826827.git.Qi.Chen@windriver.com>
2013-07-03 4:48 ` [PATCH 1/1] busybox: fix the on-target upgrade problem Qi.Chen
2013-07-06 10:27 ` Martin Jansa [this message]
2013-07-08 8:20 ` ChenQi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130706102728.GA30517@jama \
--to=martin.jansa@gmail.com \
--cc=Qi.Chen@windriver.com \
--cc=openembedded-core@lists.openembedded.org \
--cc=qingtao.cao@windriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox