busybox: fix the alternatives logic
cover busybox: fix the alternatives logic
*** 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(-)
Signature · 1 line
1.9.1
PATCH 1/1 busybox: fix the alternatives logic
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.
--- meta/recipes-core/busybox/busybox.inc | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)
meta/recipes-core/busybox/busybox.inc +33 -1
@@ -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)):
Signature · 1 line
1.9.1