summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMariano Lopez <just.another.mariano@gmail.com>2019-04-09 00:44:12 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-04-11 15:22:43 +0100
commit04d966c0a91c5e16555bba827969a0a2fd96bb96 (patch)
tree3b7f035cd01b961308c0f1c3d429ef44921adc74
parent5f48939e26402b77fc3343f326765137f9570f40 (diff)
downloadopenembedded-core-04d966c0a91c5e16555bba827969a0a2fd96bb96.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] 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.bbclass70
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 () {
update_files(alt_target, alt_target_rename, pkg, d)
}
+def update_alternatives_alt_targets(d, pkg):
+ """
+ Returns the update-alternatives metadata for a package.
+
+ The returned format is a list of tuples where the tuple contains:
+ alt_name: The binary name
+ alt_link: The path for the binary (Shared by different packages)
+ alt_target: The path for the renamed binary (Unique per package)
+ alt_priority: The priority of the alt_target
+
+ All the alt_targets will be installed into the sysroot. The alt_link is
+ a symlink pointing to the alt_target with the highest priority.
+ """
+
+ pn = d.getVar('BPN')
+ pkgdest = d.getVar('PKGD')
+ updates = list()
+ for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg) or "").split():
+ alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name)
+ alt_target = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name) or \
+ d.getVarFlag('ALTERNATIVE_TARGET', alt_name) or \
+ d.getVar('ALTERNATIVE_TARGET_%s' % pkg) or \
+ d.getVar('ALTERNATIVE_TARGET') or \
+ alt_link
+ alt_priority = d.getVarFlag('ALTERNATIVE_PRIORITY_%s' % pkg, alt_name) or \
+ d.getVarFlag('ALTERNATIVE_PRIORITY', alt_name) or \
+ d.getVar('ALTERNATIVE_PRIORITY_%s' % pkg) or \
+ d.getVar('ALTERNATIVE_PRIORITY')
+
+ # This shouldn't trigger, as it should have been resolved earlier!
+ if alt_link == alt_target:
+ bb.note('alt_link == alt_target: %s == %s -- correcting, this should not happen!' % (alt_link, alt_target))
+ alt_target = '%s.%s' % (alt_target, pn)
+
+ if not os.path.lexists('%s/%s' % (pkgdest, alt_target)):
+ bb.warn('%s: NOT adding alternative provide %s: %s does not exist' % (pn, alt_link, alt_target))
+ continue
+
+ alt_target = os.path.normpath(alt_target)
+ updates.append( (alt_name, alt_link, alt_target, alt_priority) )
+
+ return updates
+
PACKAGESPLITFUNCS_prepend = "populate_packages_updatealternatives "
python populate_packages_updatealternatives () {
if not update_alternatives_enabled(d):
return
- pn = d.getVar('BPN')
-
# Do actual update alternatives processing
- pkgdest = d.getVar('PKGD')
for pkg in (d.getVar('PACKAGES') or "").split():
# Create post install/removal scripts
alt_setup_links = ""
alt_remove_links = ""
- for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg) or "").split():
- alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name)
- alt_target = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name) or d.getVarFlag('ALTERNATIVE_TARGET', alt_name)
- alt_target = alt_target or d.getVar('ALTERNATIVE_TARGET_%s' % pkg) or d.getVar('ALTERNATIVE_TARGET') or alt_link
- # Sometimes alt_target is specified as relative to the link name.
- alt_target = os.path.join(os.path.dirname(alt_link), alt_target)
-
- alt_priority = d.getVarFlag('ALTERNATIVE_PRIORITY_%s' % pkg, alt_name) or d.getVarFlag('ALTERNATIVE_PRIORITY', alt_name)
- alt_priority = alt_priority or d.getVar('ALTERNATIVE_PRIORITY_%s' % pkg) or d.getVar('ALTERNATIVE_PRIORITY')
-
- # This shouldn't trigger, as it should have been resolved earlier!
- if alt_link == alt_target:
- bb.note('alt_link == alt_target: %s == %s -- correcting, this should not happen!' % (alt_link, alt_target))
- alt_target = '%s.%s' % (alt_target, pn)
-
- if not os.path.lexists('%s/%s' % (pkgdest, alt_target)):
- bb.warn('%s: NOT adding alternative provide %s: %s does not exist' % (pn, alt_link, alt_target))
- continue
-
- # Default to generate shell script.. eventually we may want to change this...
- alt_target = os.path.normpath(alt_target)
-
+ updates = update_alternatives_alt_targets(d, pkg)
+ for alt_name, alt_link, alt_target, alt_priority in updates:
alt_setup_links += '\tupdate-alternatives --install %s %s %s %s\n' % (alt_link, alt_name, alt_target, alt_priority)
alt_remove_links += '\tupdate-alternatives --remove %s %s\n' % (alt_name, alt_target)