diff options
authorClemens Lang <clemens.lang@bmw-carit.de>2019-01-03 16:55:29 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-01-07 10:54:01 +0000
commit326220267ffc43ec1f507ad0cc47ac59caafd5b7 (patch)
parent11278e3b2c75be80645b9841763a97dbb35daadc (diff)
update-alternatives.bbclass: Stabilize iteration order
The use of a dictionary for link_rename causes problems for higher-order alternatives, i.e. when an alternative link points to another alternative link, since these links must be processed in the order in which they were originally added for symlink correction to work. Switch from a dict to a list of tuples to ensure processing happens in the original order. Signed-off-by: Clemens Lang <clemens.lang@bmw-carit.de> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
1 files changed, 6 insertions, 7 deletions
diff --git a/meta/classes/update-alternatives.bbclass b/meta/classes/update-alternatives.bbclass
index ee66379933..1362274d4d 100644
--- a/meta/classes/update-alternatives.bbclass
+++ b/meta/classes/update-alternatives.bbclass
@@ -148,7 +148,7 @@ def apply_update_alternative_renames(d):
pkgdest = d.getVar('PKGD')
for pkg in (d.getVar('PACKAGES') or "").split():
# If the src == dest, we know we need to rename the dest by appending ${BPN}
- link_rename = {}
+ link_rename = []
for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg) or "").split():
alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name)
if not alt_link:
@@ -174,7 +174,7 @@ def apply_update_alternative_renames(d):
elif os.path.lexists(src):
if os.path.islink(src):
# Delay rename of links
- link_rename[alt_target] = alt_target_rename
+ link_rename.append((alt_target, alt_target_rename))
bb.note('%s: Rename %s -> %s' % (pn, alt_target, alt_target_rename))
os.rename(src, dest)
@@ -185,22 +185,21 @@ def apply_update_alternative_renames(d):
# Process delayed link names
# Do these after other renames so we can correct broken links
- for alt_target in link_rename:
+ for (alt_target, alt_target_rename) in link_rename:
src = '%s/%s' % (pkgdest, alt_target)
- dest = '%s/%s' % (pkgdest, link_rename[alt_target])
- link = os.readlink(src)
+ dest = '%s/%s' % (pkgdest, alt_target_rename)
link_target = oe.path.realpath(src, pkgdest, True)
if os.path.lexists(link_target):
# Ok, the link_target exists, we can rename
- bb.note('%s: Rename (link) %s -> %s' % (pn, alt_target, link_rename[alt_target]))
+ bb.note('%s: Rename (link) %s -> %s' % (pn, alt_target, alt_target_rename))
os.rename(src, dest)
# Try to resolve the broken link to link.${BPN}
link_maybe = '%s.%s' % (os.readlink(src), pn)
if os.path.lexists(os.path.join(os.path.dirname(src), link_maybe)):
# Ok, the renamed link target exists.. create a new link, and remove the original
- bb.note('%s: Creating new link %s -> %s' % (pn, link_rename[alt_target], link_maybe))
+ bb.note('%s: Creating new link %s -> %s' % (pn, alt_target_rename, link_maybe))
os.symlink(link_maybe, dest)