Right now, do_package_prepend() supports putting all applets into one
binary or the suid/nosuid binaries.

It may also be useful to split busybox differently and then use more
fine-grained file capabilities instead of suid to control what each
applet is allowed to do, or use hardlinks and different file
capabilities on each copy.

This change supports this by replacing the hard-coded links file names
with something that operates on all files matching the busybox.links*
shell pattern. For each /etc/busybox.links<foobar> link file there has
to be a corresponding /bin/busybox<foobar>.

set_alternative_vars() now always gets called with full path of the
link file in the host file system (because that is what the caller
has) and, while at it, only checks for existance of the target once.

Signed-off-by: Patrick Ohly <[email protected]>
---
 meta/recipes-core/busybox/busybox.inc | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/meta/recipes-core/busybox/busybox.inc 
b/meta/recipes-core/busybox/busybox.inc
index fba956e..65a17ee 100644
--- a/meta/recipes-core/busybox/busybox.inc
+++ b/meta/recipes-core/busybox/busybox.inc
@@ -331,7 +331,8 @@ python do_package_prepend () {
     dvar = d.getVar('D', True)
     pn = d.getVar('PN', True)
     def set_alternative_vars(links, target):
-        f = open('%s%s' % (dvar, links), 'r')
+        target_exists = os.path.exists('%s%s' % (dvar, target))
+        f = open(links, 'r')
         for alt_link_name in f:
             alt_link_name = alt_link_name.strip()
             alt_name = os.path.basename(alt_link_name)
@@ -340,16 +341,17 @@ python do_package_prepend () {
                 alt_name = 'lbracket'
             d.appendVar('ALTERNATIVE_%s' % (pn), ' ' + alt_name)
             d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link_name)
-            if os.path.exists('%s%s' % (dvar, target)):
+            if target_exists:
                 d.setVarFlag('ALTERNATIVE_TARGET', alt_name, target)
         f.close()
         return
 
-    if os.path.exists('%s/etc/busybox.links' % (dvar)):
-        set_alternative_vars("${sysconfdir}/busybox.links", 
"${base_bindir}/busybox")
-    else:
-        set_alternative_vars("${sysconfdir}/busybox.links.nosuid", 
"${base_bindir}/busybox.nosuid")
-        set_alternative_vars("${sysconfdir}/busybox.links.suid", 
"${base_bindir}/busybox.suid")
+    import glob
+    base = dvar + "${sysconfdir}/busybox.links"
+    for links in glob.glob(base + "*"):
+        # Suffix might be empty when there is no split between busybox.suid 
and busybox.nosuid.
+        suffix = links[len(base):]
+        set_alternative_vars(links, "${base_bindir}/busybox" + suffix)
 }
 
 pkg_postinst_${PN} () {
-- 
2.1.4

-- 
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Reply via email to