Patchwork [2/8] busybox: add support for CONFIG_FEATURE_INDIVIDUAL

login
register
mail settings
Submitter Qi.Chen@windriver.com
Date June 7, 2013, 6:13 a.m.
Message ID <b5688fe465a6f4fd3e21ce9eae41ce5fc8eb84db.1370585547.git.Qi.Chen@windriver.com>
Download mbox | patch
Permalink /patch/51277/
State Accepted
Commit 726483741a69861a2b4adc3186a39de227a353a1
Headers show

Comments

Qi.Chen@windriver.com - June 7, 2013, 6:13 a.m.
From: Chen Qi <Qi.Chen@windriver.com>

Previously, if CONFIG_FEATURE_INDIVIDUAL was enabled for busybox,
yocto-based systems could start correctly.

This is because if busybox is built as individual apps, '/bin/busybox'
may not be present, so setting the default ALTERNATIVE_TARGET to
'/bin/busybox' is not appropriate and could lead to errors.

This patch fixes this problem by checking the existence of '/bin/busybox'
before setting the ALTERNATIVE_TARGET to '/bin/busybox'.

After this change, if busybox is built as individual apps, we'll have
links like '/bin/ls -> /bin/ls.busybox', otherwise, we'll have links
like '/bin/ls -> /bin/busybox'.

Note there's a grep expression change in this patch. The old expression
doesn't work well, it has an unwanted underscore, so I changed it to make
it work.

[YOCTO #4570]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/recipes-core/busybox/busybox.inc |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
Otavio Salvador - June 7, 2013, 12:33 p.m.
On Fri, Jun 7, 2013 at 3:13 AM, <Qi.Chen@windriver.com> wrote:

> From: Chen Qi <Qi.Chen@windriver.com>
>
> Previously, if CONFIG_FEATURE_INDIVIDUAL was enabled for busybox,
> yocto-based systems could start correctly.
>
> This is because if busybox is built as individual apps, '/bin/busybox'
> may not be present, so setting the default ALTERNATIVE_TARGET to
> '/bin/busybox' is not appropriate and could lead to errors.
>
> This patch fixes this problem by checking the existence of '/bin/busybox'
> before setting the ALTERNATIVE_TARGET to '/bin/busybox'.
>
> After this change, if busybox is built as individual apps, we'll have
> links like '/bin/ls -> /bin/ls.busybox', otherwise, we'll have links
> like '/bin/ls -> /bin/busybox'.
>
> Note there's a grep expression change in this patch. The old expression
> doesn't work well, it has an unwanted underscore, so I changed it to make
> it work.
>
> [YOCTO #4570]
>
> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
>

Please rework 1/8 and reduce the changes here. This will be easier to test
and review this way.

Patch

diff --git a/meta/recipes-core/busybox/busybox.inc b/meta/recipes-core/busybox/busybox.inc
index f4efeb8..99d4e99 100644
--- a/meta/recipes-core/busybox/busybox.inc
+++ b/meta/recipes-core/busybox/busybox.inc
@@ -171,7 +171,7 @@  do_install () {
 			install -m 0755 "0_lib/$NAME" "${D}$FILE.${BPN}"
 		done
 		# add suid bit where needed
-		for i in `grep -E "APPLET.*_BB_SUID_((MAYBE|REQUIRE))" include/applets.h | grep -v _BB_SUID_DROP | cut -f 3 -d '(' | cut -f 1 -d ','`; do
+		for i in `grep -E "APPLET.*BB_SUID_((MAYBE|REQUIRE))" include/applets.h | grep -v _BB_SUID_DROP | cut -f 3 -d '(' | cut -f 1 -d ','`; do
 			find ${D} -name $i.${BPN} -exec chmod a+s {} \;
 		done
 		install -m 0755 0_lib/libbusybox.so.${PV} ${D}${libdir}/libbusybox.so.${PV}
@@ -242,8 +242,6 @@  ALTERNATIVE_TARGET[syslog-init] = "${sysconfdir}/init.d/syslog.${BPN}"
 ALTERNATIVE_LINK_NAME[syslog-startup-conf] = "${sysconfdir}/syslog-startup.conf"
 ALTERNATIVE_TARGET[syslog-startup-conf] = "${sysconfdir}/syslog-startup.conf.${BPN}"
 
-ALTERNATIVE_TARGET = "/bin/busybox"
-
 python do_package_prepend () {
     # We need to load the full set of busybox provides from the /etc/busybox.links
     # Use this to see the update-alternatives with the right information
@@ -252,6 +250,9 @@  python do_package_prepend () {
     pn = d.getVar('PN', True)
     f = open('%s/etc/busybox.links' % (dvar), 'r')
 
+    if os.path.exists('%s/bin/busybox' % (dvar)):
+        d.setVar('ALTERNATIVE_TARGET', "/bin/busybox")
+
     for alt_link_name in f:
         alt_link_name = alt_link_name.strip()
         alt_name = os.path.basename(alt_link_name)