Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH 0/1] busybox: fix the alternatives logic
@ 2018-08-30  9:45 Chen Qi
  2018-08-30  9:45 ` [PATCH 1/1] " Chen Qi
  0 siblings, 1 reply; 2+ messages in thread
From: Chen Qi @ 2018-08-30  9:45 UTC (permalink / raw)
  To: openembedded-core

*** BLURB HERE ***
The following changes since commit 4434777705cf49300a7d2c9ca8fa3080d551d795:

  bitbake: tests/fetch: Update gnome.org urls after upstream changes (2018-08-29 10:43:23 +0100)

are available in the git repository at:

  git://git.pokylinux.org/poky-contrib ChenQi/busybox-alternatives
  http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=ChenQi/busybox-alternatives

Chen Qi (1):
  busybox: fix the alternatives logic

 meta/recipes-core/busybox/busybox.inc | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

-- 
1.9.1



^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 1/1] busybox: fix the alternatives logic
  2018-08-30  9:45 [PATCH 0/1] busybox: fix the alternatives logic Chen Qi
@ 2018-08-30  9:45 ` Chen Qi
  0 siblings, 0 replies; 2+ messages in thread
From: Chen Qi @ 2018-08-30  9:45 UTC (permalink / raw)
  To: openembedded-core

The current alternatives setting logic in busybox is not ideal.
For example, the 'syslogd' alternative should be handled by
busybox-syslog package, but it is now handled by the busybox package.

In other words, despite the fact that busybox recipe has multiple
packages, the alternatives settings are all done for the main busybox
package.

This will cause problems. For example, if we have an image with sysklogd
and busybox installed, there will be do_rootfs failure if busybox is
installed after sysklogd.

Note that in the above situation, the image does not have busybox-syslog.
The 'syslogd' entry should really be handled by busybox-syslog instead of
busybox.

And the same logic applies to other packages in the busybox recipe.

So change the alternatives handling codes in busybox to fix this problem.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/recipes-core/busybox/busybox.inc | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/meta/recipes-core/busybox/busybox.inc b/meta/recipes-core/busybox/busybox.inc
index 8c6dbba..5ca1bab 100644
--- a/meta/recipes-core/busybox/busybox.inc
+++ b/meta/recipes-core/busybox/busybox.inc
@@ -29,6 +29,13 @@ FILES_${PN}-udhcpd = "${sysconfdir}/init.d/busybox-udhcpd"
 FILES_${PN}-udhcpc = "${sysconfdir}/udhcpc.d ${datadir}/udhcpc"
 FILES_${PN}-hwclock = "${sysconfdir}/init.d/hwclock.sh"
 
+ALTERNATIVE_${PN}-httpd = "httpd"
+ALTERNATIVE_${PN}-syslog = "syslogd klogd"
+ALTERNATIVE_${PN}-mdev = "mdev"
+ALTERNATIVE_${PN}-udhcpd = "udhcpd"
+ALTERNATIVE_${PN}-udhcpc = "udhcpc"
+ALTERNATIVE_${PN}-hwclock = "hwclock"
+
 INITSCRIPT_PACKAGES = "${PN}-httpd ${PN}-syslog ${PN}-udhcpd ${PN}-mdev ${PN}-hwclock"
 
 INITSCRIPT_NAME_${PN}-httpd = "busybox-httpd"
@@ -357,21 +364,46 @@ python do_package_prepend () {
 
     dvar = d.getVar('D')
     pn = d.getVar('PN')
+    pkgs = d.getVar('PACKAGES').split()
     def set_alternative_vars(links, target):
         links = d.expand(links)
         target = d.expand(target)
         f = open('%s%s' % (dvar, links), 'r')
+        valid_names = []
         for alt_link_name in f:
             alt_link_name = alt_link_name.strip()
             alt_name = os.path.basename(alt_link_name)
             # Match coreutils
             if alt_name == '[':
                 alt_name = 'lbracket'
-            d.appendVar('ALTERNATIVE_%s' % (pn), ' ' + alt_name)
+            valid_names.append(alt_name)
+            # if not already specified by ALTERNATIVE_pkg, default to put it in ALTERNATIVE_${PN}
+            flag_default = True
+            for pkg in pkgs:
+                if pkg == pn:
+                    continue
+                if alt_name in (d.getVar('ALTERNATIVE_%s' % pkg) or '').split():
+                    flag_default = False
+                    break
+            if flag_default:
+                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)):
                 d.setVarFlag('ALTERNATIVE_TARGET', alt_name, target)
         f.close()
+        # iterate over pkgs to remove invalid entries for ALTERNATIVE_pkg
+        for pkg in pkgs:
+            if pkg == pn:
+                continue
+            final_names = []
+            names = (d.getVar('ALTERNATIVE_%s' % pkg) or '').split()
+            for name in names:
+                if name in valid_names:
+                    final_names.append(name)
+            if final_names:
+                d.setVar('ALTERNATIVE_%s' % pkg, ' '.join(final_names))
+            else:
+                d.delVar('ALTERNATIVE_%s' % pkg)
         return
 
     if os.path.exists('%s/etc/busybox.links' % (dvar)):
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-08-30  9:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-30  9:45 [PATCH 0/1] busybox: fix the alternatives logic Chen Qi
2018-08-30  9:45 ` [PATCH 1/1] " Chen Qi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox