diff options
author | Clemens Lang <clemens.lang@bmw-carit.de> | 2019-01-03 16:55:29 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-01-07 10:54:13 +0000 |
commit | caf55cf9b4be08693c561824fd8d8835617c4c06 (patch) | |
tree | f80b0533b284ee345f6b76be70330640b4c8d29e /meta/classes | |
parent | 69431c3982d980da8bf0977bdae1dd3049aed8cf (diff) | |
download | poky-caf55cf9b4be08693c561824fd8d8835617c4c06.tar.gz |
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.
(From OE-Core rev: 326220267ffc43ec1f507ad0cc47ac59caafd5b7)
Signed-off-by: Clemens Lang <clemens.lang@bmw-carit.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/update-alternatives.bbclass | 13 |
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): | |||
148 | pkgdest = d.getVar('PKGD') | 148 | pkgdest = d.getVar('PKGD') |
149 | for pkg in (d.getVar('PACKAGES') or "").split(): | 149 | for pkg in (d.getVar('PACKAGES') or "").split(): |
150 | # If the src == dest, we know we need to rename the dest by appending ${BPN} | 150 | # If the src == dest, we know we need to rename the dest by appending ${BPN} |
151 | link_rename = {} | 151 | link_rename = [] |
152 | for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg) or "").split(): | 152 | for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg) or "").split(): |
153 | alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name) | 153 | alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name) |
154 | if not alt_link: | 154 | if not alt_link: |
@@ -174,7 +174,7 @@ def apply_update_alternative_renames(d): | |||
174 | elif os.path.lexists(src): | 174 | elif os.path.lexists(src): |
175 | if os.path.islink(src): | 175 | if os.path.islink(src): |
176 | # Delay rename of links | 176 | # Delay rename of links |
177 | link_rename[alt_target] = alt_target_rename | 177 | link_rename.append((alt_target, alt_target_rename)) |
178 | else: | 178 | else: |
179 | bb.note('%s: Rename %s -> %s' % (pn, alt_target, alt_target_rename)) | 179 | bb.note('%s: Rename %s -> %s' % (pn, alt_target, alt_target_rename)) |
180 | os.rename(src, dest) | 180 | os.rename(src, dest) |
@@ -185,22 +185,21 @@ def apply_update_alternative_renames(d): | |||
185 | 185 | ||
186 | # Process delayed link names | 186 | # Process delayed link names |
187 | # Do these after other renames so we can correct broken links | 187 | # Do these after other renames so we can correct broken links |
188 | for alt_target in link_rename: | 188 | for (alt_target, alt_target_rename) in link_rename: |
189 | src = '%s/%s' % (pkgdest, alt_target) | 189 | src = '%s/%s' % (pkgdest, alt_target) |
190 | dest = '%s/%s' % (pkgdest, link_rename[alt_target]) | 190 | dest = '%s/%s' % (pkgdest, alt_target_rename) |
191 | link = os.readlink(src) | ||
192 | link_target = oe.path.realpath(src, pkgdest, True) | 191 | link_target = oe.path.realpath(src, pkgdest, True) |
193 | 192 | ||
194 | if os.path.lexists(link_target): | 193 | if os.path.lexists(link_target): |
195 | # Ok, the link_target exists, we can rename | 194 | # Ok, the link_target exists, we can rename |
196 | bb.note('%s: Rename (link) %s -> %s' % (pn, alt_target, link_rename[alt_target])) | 195 | bb.note('%s: Rename (link) %s -> %s' % (pn, alt_target, alt_target_rename)) |
197 | os.rename(src, dest) | 196 | os.rename(src, dest) |
198 | else: | 197 | else: |
199 | # Try to resolve the broken link to link.${BPN} | 198 | # Try to resolve the broken link to link.${BPN} |
200 | link_maybe = '%s.%s' % (os.readlink(src), pn) | 199 | link_maybe = '%s.%s' % (os.readlink(src), pn) |
201 | if os.path.lexists(os.path.join(os.path.dirname(src), link_maybe)): | 200 | if os.path.lexists(os.path.join(os.path.dirname(src), link_maybe)): |
202 | # Ok, the renamed link target exists.. create a new link, and remove the original | 201 | # Ok, the renamed link target exists.. create a new link, and remove the original |
203 | bb.note('%s: Creating new link %s -> %s' % (pn, link_rename[alt_target], link_maybe)) | 202 | bb.note('%s: Creating new link %s -> %s' % (pn, alt_target_rename, link_maybe)) |
204 | os.symlink(link_maybe, dest) | 203 | os.symlink(link_maybe, dest) |
205 | os.unlink(src) | 204 | os.unlink(src) |
206 | else: | 205 | else: |