diff options
author | Mariano Lopez <just.another.mariano@gmail.com> | 2019-04-09 00:44:12 -0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-04-11 21:12:48 +0100 |
commit | 5feccb430bfc56e278f2e3bab87b87ea9973e08f (patch) | |
tree | d10e90ac4aa13af816eec4ba8bbc379e0340be2c | |
parent | 4e511f0abc2c9cdd0d1592e50ade0d4da0c6dbb8 (diff) | |
download | poky-5feccb430bfc56e278f2e3bab87b87ea9973e08f.tar.gz |
update-alternatives.bbclass: Add function to get metadata
This adds update_alternatives_alt_targets function to get the metadata
for a package. This is for code reuse because the metadata would help
other classes that needs to be aware of how update-alternatives modify
the final package.
[YOCTO #12597]
[YOCTO #13238]
(From OE-Core rev: 04d966c0a91c5e16555bba827969a0a2fd96bb96)
Signed-off-by: Mariano Lopez <just.another.mariano@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes/update-alternatives.bbclass | 70 |
1 files changed, 45 insertions, 25 deletions
diff --git a/meta/classes/update-alternatives.bbclass b/meta/classes/update-alternatives.bbclass index 537e85d9a3..b702e77ee5 100644 --- a/meta/classes/update-alternatives.bbclass +++ b/meta/classes/update-alternatives.bbclass | |||
@@ -216,42 +216,62 @@ python apply_update_alternative_renames () { | |||
216 | update_files(alt_target, alt_target_rename, pkg, d) | 216 | update_files(alt_target, alt_target_rename, pkg, d) |
217 | } | 217 | } |
218 | 218 | ||
219 | def update_alternatives_alt_targets(d, pkg): | ||
220 | """ | ||
221 | Returns the update-alternatives metadata for a package. | ||
222 | |||
223 | The returned format is a list of tuples where the tuple contains: | ||
224 | alt_name: The binary name | ||
225 | alt_link: The path for the binary (Shared by different packages) | ||
226 | alt_target: The path for the renamed binary (Unique per package) | ||
227 | alt_priority: The priority of the alt_target | ||
228 | |||
229 | All the alt_targets will be installed into the sysroot. The alt_link is | ||
230 | a symlink pointing to the alt_target with the highest priority. | ||
231 | """ | ||
232 | |||
233 | pn = d.getVar('BPN') | ||
234 | pkgdest = d.getVar('PKGD') | ||
235 | updates = list() | ||
236 | for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg) or "").split(): | ||
237 | alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name) | ||
238 | alt_target = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name) or \ | ||
239 | d.getVarFlag('ALTERNATIVE_TARGET', alt_name) or \ | ||
240 | d.getVar('ALTERNATIVE_TARGET_%s' % pkg) or \ | ||
241 | d.getVar('ALTERNATIVE_TARGET') or \ | ||
242 | alt_link | ||
243 | alt_priority = d.getVarFlag('ALTERNATIVE_PRIORITY_%s' % pkg, alt_name) or \ | ||
244 | d.getVarFlag('ALTERNATIVE_PRIORITY', alt_name) or \ | ||
245 | d.getVar('ALTERNATIVE_PRIORITY_%s' % pkg) or \ | ||
246 | d.getVar('ALTERNATIVE_PRIORITY') | ||
247 | |||
248 | # This shouldn't trigger, as it should have been resolved earlier! | ||
249 | if alt_link == alt_target: | ||
250 | bb.note('alt_link == alt_target: %s == %s -- correcting, this should not happen!' % (alt_link, alt_target)) | ||
251 | alt_target = '%s.%s' % (alt_target, pn) | ||
252 | |||
253 | if not os.path.lexists('%s/%s' % (pkgdest, alt_target)): | ||
254 | bb.warn('%s: NOT adding alternative provide %s: %s does not exist' % (pn, alt_link, alt_target)) | ||
255 | continue | ||
256 | |||
257 | alt_target = os.path.normpath(alt_target) | ||
258 | updates.append( (alt_name, alt_link, alt_target, alt_priority) ) | ||
259 | |||
260 | return updates | ||
261 | |||
219 | PACKAGESPLITFUNCS_prepend = "populate_packages_updatealternatives " | 262 | PACKAGESPLITFUNCS_prepend = "populate_packages_updatealternatives " |
220 | 263 | ||
221 | python populate_packages_updatealternatives () { | 264 | python populate_packages_updatealternatives () { |
222 | if not update_alternatives_enabled(d): | 265 | if not update_alternatives_enabled(d): |
223 | return | 266 | return |
224 | 267 | ||
225 | pn = d.getVar('BPN') | ||
226 | |||
227 | # Do actual update alternatives processing | 268 | # Do actual update alternatives processing |
228 | pkgdest = d.getVar('PKGD') | ||
229 | for pkg in (d.getVar('PACKAGES') or "").split(): | 269 | for pkg in (d.getVar('PACKAGES') or "").split(): |
230 | # Create post install/removal scripts | 270 | # Create post install/removal scripts |
231 | alt_setup_links = "" | 271 | alt_setup_links = "" |
232 | alt_remove_links = "" | 272 | alt_remove_links = "" |
233 | for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg) or "").split(): | 273 | updates = update_alternatives_alt_targets(d, pkg) |
234 | alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name) | 274 | for alt_name, alt_link, alt_target, alt_priority in updates: |
235 | alt_target = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name) or d.getVarFlag('ALTERNATIVE_TARGET', alt_name) | ||
236 | alt_target = alt_target or d.getVar('ALTERNATIVE_TARGET_%s' % pkg) or d.getVar('ALTERNATIVE_TARGET') or alt_link | ||
237 | # Sometimes alt_target is specified as relative to the link name. | ||
238 | alt_target = os.path.join(os.path.dirname(alt_link), alt_target) | ||
239 | |||
240 | alt_priority = d.getVarFlag('ALTERNATIVE_PRIORITY_%s' % pkg, alt_name) or d.getVarFlag('ALTERNATIVE_PRIORITY', alt_name) | ||
241 | alt_priority = alt_priority or d.getVar('ALTERNATIVE_PRIORITY_%s' % pkg) or d.getVar('ALTERNATIVE_PRIORITY') | ||
242 | |||
243 | # This shouldn't trigger, as it should have been resolved earlier! | ||
244 | if alt_link == alt_target: | ||
245 | bb.note('alt_link == alt_target: %s == %s -- correcting, this should not happen!' % (alt_link, alt_target)) | ||
246 | alt_target = '%s.%s' % (alt_target, pn) | ||
247 | |||
248 | if not os.path.lexists('%s/%s' % (pkgdest, alt_target)): | ||
249 | bb.warn('%s: NOT adding alternative provide %s: %s does not exist' % (pn, alt_link, alt_target)) | ||
250 | continue | ||
251 | |||
252 | # Default to generate shell script.. eventually we may want to change this... | ||
253 | alt_target = os.path.normpath(alt_target) | ||
254 | |||
255 | alt_setup_links += '\tupdate-alternatives --install %s %s %s %s\n' % (alt_link, alt_name, alt_target, alt_priority) | 275 | alt_setup_links += '\tupdate-alternatives --install %s %s %s %s\n' % (alt_link, alt_name, alt_target, alt_priority) |
256 | alt_remove_links += '\tupdate-alternatives --remove %s %s\n' % (alt_name, alt_target) | 276 | alt_remove_links += '\tupdate-alternatives --remove %s %s\n' % (alt_name, alt_target) |
257 | 277 | ||