summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/busybox
diff options
context:
space:
mode:
authorChen Qi <Qi.Chen@windriver.com>2013-07-03 12:48:12 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-07-05 15:34:21 +0100
commitcb534214286cb59f1ac377b6f1643c923c1289b1 (patch)
tree7c7c5661429cc2261d9d8de393ebed3925e5f7b0 /meta/recipes-core/busybox
parente695d4104f04c02fdb9298ec31d1ff69d877dbc9 (diff)
downloadpoky-cb534214286cb59f1ac377b6f1643c923c1289b1.tar.gz
busybox: fix the on-target upgrade problem
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. [YOCTO #4802] (From OE-Core rev: 4e571e97750f3ac6a62cd0d2d10c08be98230630) Signed-off-by: Chen Qi <Qi.Chen@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/busybox')
-rw-r--r--meta/recipes-core/busybox/busybox.inc48
1 files changed, 48 insertions, 0 deletions
diff --git a/meta/recipes-core/busybox/busybox.inc b/meta/recipes-core/busybox/busybox.inc
index 8567d6471f..acd2bfbcff 100644
--- a/meta/recipes-core/busybox/busybox.inc
+++ b/meta/recipes-core/busybox/busybox.inc
@@ -190,6 +190,10 @@ do_install () {
190 install -m 0644 ${S}/busybox.links.suid ${D}${sysconfdir} 190 install -m 0644 ${S}/busybox.links.suid ${D}${sysconfdir}
191 install -m 0644 ${S}/busybox.links.nosuid ${D}${sysconfdir} 191 install -m 0644 ${S}/busybox.links.nosuid ${D}${sysconfdir}
192 ln -sf busybox.nosuid ${D}${base_bindir}/sh 192 ln -sf busybox.nosuid ${D}${base_bindir}/sh
193 # Keep a default busybox for people who want to invoke busybox directly.
194 # This is also useful for the on device upgrade. Because we want
195 # to use the busybox command in postinst.
196 ln -sf busybox.nosuid ${D}${base_bindir}/busybox
193 else 197 else
194 if grep -q "CONFIG_FEATURE_SUID=y" ${B}/.config; then 198 if grep -q "CONFIG_FEATURE_SUID=y" ${B}/.config; then
195 install -m 4755 ${B}/busybox ${D}${base_bindir} 199 install -m 4755 ${B}/busybox ${D}${base_bindir}
@@ -198,6 +202,12 @@ do_install () {
198 fi 202 fi
199 install -m 0644 ${S}/busybox.links ${D}${sysconfdir} 203 install -m 0644 ${S}/busybox.links ${D}${sysconfdir}
200 ln -sf busybox ${D}${base_bindir}/sh 204 ln -sf busybox ${D}${base_bindir}/sh
205 # We make this symlink here to eliminate the error when upgrading together
206 # with busybox-syslog. Without this symlink, the opkg may think of the
207 # busybox.nosuid as obsolete and remove it, resulting in dead links like
208 # /bin/sed -> /bin/busybox.nosuid. This will make upgrading busybox-syslog fail.
209 # This symlink will be safely deleted in postinst, thus no negative effect.
210 ln -sf busybox ${D}${base_bindir}/busybox.nosuid
201 fi 211 fi
202 else 212 else
203 install -d ${D}${base_bindir} ${D}${base_sbindir} 213 install -d ${D}${base_bindir} ${D}${base_sbindir}
@@ -306,6 +316,44 @@ python do_package_prepend () {
306 set_alternative_vars("/etc/busybox.links.suid", "/bin/busybox.suid") 316 set_alternative_vars("/etc/busybox.links.suid", "/bin/busybox.suid")
307} 317}
308 318
319pkg_postinst_${PN} () {
320 # This part of code is dedicated to the on target upgrade problem.
321 # It's known that if we don't make appropriate symlinks before update-alternatives calls,
322 # there will be errors indicating missing commands such as 'sed'.
323 # These symlinks will later be updated by update-alternatives calls.
324 test -n 2 > /dev/null || alias test='busybox test'
325 if test "x$D" = "x"; then
326 # Remove busybox.nosuid if it's a symlink, because this situation indicates
327 # that we're installing or upgrading to a one-binary busybox.
328 if test -h /bin/busybox.nosuid; then
329 rm -f /bin/busybox.nosuid
330 fi
331 for suffix in "" ".nosuid" ".suid"; do
332 if test -e /etc/busybox.links$suffix; then
333 while read link; do
334 if test ! -e "$link"; then
335 case "$link" in
336 /*/*/*)
337 to="../../bin/busybox$suffix"
338 ;;
339 /bin/*)
340 to="busybox$suffix"
341 ;;
342 /*/*)
343 to="../bin/busybox$suffix"
344 ;;
345 esac
346 # we can use busybox here because even if we are using splitted busybox
347 # we've made a symlink from /bin/busybox to /bin/busybox.nosuid.
348 busybox rm -f $link
349 busybox ln -s $to $link
350 fi
351 done < /etc/busybox.links$suffix
352 fi
353 done
354 fi
355}
356
309pkg_prerm_${PN} () { 357pkg_prerm_${PN} () {
310 # This is so you can make busybox commit suicide - removing busybox with no other packages 358 # This is so you can make busybox commit suicide - removing busybox with no other packages
311 # providing its files, this will make update-alternatives work, but the update-rc.d part 359 # providing its files, this will make update-alternatives work, but the update-rc.d part