diff options
Diffstat (limited to 'meta/classes/update-alternatives.bbclass')
-rw-r--r-- | meta/classes/update-alternatives.bbclass | 286 |
1 files changed, 143 insertions, 143 deletions
diff --git a/meta/classes/update-alternatives.bbclass b/meta/classes/update-alternatives.bbclass index 9f2e59f584..47215add1e 100644 --- a/meta/classes/update-alternatives.bbclass +++ b/meta/classes/update-alternatives.bbclass @@ -113,13 +113,13 @@ def update_alternatives_after_parse(d): # Convert old format to new format... alt_links = d.getVar('ALTERNATIVE_LINKS', True) or "" for alt_link in alt_links.split(): - alt_name = os.path.basename(alt_link) + alt_name = os.path.basename(alt_link) - alternative = d.getVar('ALTERNATIVE_%s' % pn, True) or "" - alternative += " " + alt_name - d.setVar('ALTERNATIVE_%s' % pn, alternative) - d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link) - d.setVarFlag('ALTERNATIVE_TARGET', alt_name, alt_link) + alternative = d.getVar('ALTERNATIVE_%s' % pn, True) or "" + alternative += " " + alt_name + d.setVar('ALTERNATIVE_%s' % pn, alternative) + d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link) + d.setVarFlag('ALTERNATIVE_TARGET', alt_name, alt_link) return if d.getVar('ALTERNATIVE_NAME') != None or d.getVar('ALTERNATIVE_PATH') != None: @@ -128,15 +128,15 @@ def update_alternatives_after_parse(d): alt_path = d.getVar('ALTERNATIVE_PATH', True) alt_link = d.getVar('ALTERNATIVE_LINK', True) or ("%s/%s" % (d.getVar('bindir', True), alt_name)) if alt_name == None: - raise bb.build.build.FuncFailed, "%s inherits update-alternatives but doesn't set ALTERNATIVE_NAME" % d.getVar('FILE') + raise bb.build.build.FuncFailed, "%s inherits update-alternatives but doesn't set ALTERNATIVE_NAME" % d.getVar('FILE') if alt_path == None: - raise bb.build.build.FuncFailed, "%s inherits update-alternatives but doesn't set ALTERNATIVE_PATH" % d.getVar('FILE') + raise bb.build.build.FuncFailed, "%s inherits update-alternatives but doesn't set ALTERNATIVE_PATH" % d.getVar('FILE') alternative = d.getVar('ALTERNATIVE_%s' % pn, True) or "" alternative += " " + alt_name - # Fix the alt_path if it's relative - alt_path = os.path.join(os.path.dirname(alt_link), alt_path) + # Fix the alt_path if it's relative + alt_path = os.path.join(os.path.dirname(alt_link), alt_path) d.setVar('ALTERNATIVE_%s' % pn, alternative) d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link) @@ -199,144 +199,144 @@ populate_packages[vardeps] += "${UPDALTVARS} ${@gen_updatealternativesvars(d)}" # the split and strip steps.. packagecopy seems to be the earliest reasonable # place. python perform_packagecopy_append () { - # Check for deprecated usage... - pn = d.getVar('BPN', True) - if d.getVar('ALTERNATIVE_LINKS', True) != None: - bb.warn('%s: Use of ALTERNATIVE_LINKS is deprecated, see update-alternatives.bbclass for more info.' % pn) - - if d.getVar('ALTERNATIVE_NAME', True) != None or d.getVar('ALTERNATIVE_PATH', True) != None: - bb.warn('%s: Use of ALTERNATIVE_NAME is deprecated, see update-alternatives.bbclass for more info.' % pn) - - # Do actual update alternatives processing - pkgdest = d.getVar('PKGD', True) - for pkg in (d.getVar('PACKAGES', True) or "").split(): - # If the src == dest, we know we need to rename the dest by appending ${BPN} - link_rename = {} - for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg, True) or "").split(): - alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name, True) - if not alt_link: - alt_link = "%s/%s" % (d.getVar('bindir', True), alt_name) - d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link) - - alt_target = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name, True) or d.getVarFlag('ALTERNATIVE_TARGET', alt_name, True) - alt_target = alt_target or d.getVar('ALTERNATIVE_TARGET_%s' % pkg, True) or d.getVar('ALTERNATIVE_TARGET', True) 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) - - # If the link and target are the same name, we need to rename the target. - if alt_link == alt_target: - src = '%s/%s' % (pkgdest, alt_target) - alt_target_rename = '%s.%s' % (alt_target, pn) - dest = '%s/%s' % (pkgdest, alt_target_rename) - if os.path.lexists(dest): - bb.note('%s: Already renamed: %s' % (pn, alt_target_rename)) - elif os.path.lexists(src): - if os.path.islink(src): - # Delay rename of links - link_rename[alt_target] = alt_target_rename - else: - bb.note('%s: Rename %s -> %s' % (pn, alt_target, alt_target_rename)) - os.rename(src, dest) - else: - bb.warn("%s: alternative target (%s or %s) does not exist, skipping..." % (pn, alt_target, alt_target_rename)) - continue - d.setVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name, alt_target_rename) - - # Process delayed link names - # Do these after other renames so we can correct broken links - for alt_target in link_rename: - src = '%s/%s' % (pkgdest, alt_target) - dest = '%s/%s' % (pkgdest, link_rename[alt_target]) - link = os.readlink(src) - if os.path.isabs(link): - link_target = pkgdest + os.readlink(src) - else: - link_target = os.path.join(os.path.dirname(src), link) - - 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])) - os.rename(src, dest) - else: - # 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)) - os.symlink(link_maybe, dest) - os.unlink(src) - else: - bb.warn('%s: Unable to resolve dangling symlink: %s' % (pn, alt_target)) + # Check for deprecated usage... + pn = d.getVar('BPN', True) + if d.getVar('ALTERNATIVE_LINKS', True) != None: + bb.warn('%s: Use of ALTERNATIVE_LINKS is deprecated, see update-alternatives.bbclass for more info.' % pn) + + if d.getVar('ALTERNATIVE_NAME', True) != None or d.getVar('ALTERNATIVE_PATH', True) != None: + bb.warn('%s: Use of ALTERNATIVE_NAME is deprecated, see update-alternatives.bbclass for more info.' % pn) + + # Do actual update alternatives processing + pkgdest = d.getVar('PKGD', True) + for pkg in (d.getVar('PACKAGES', True) or "").split(): + # If the src == dest, we know we need to rename the dest by appending ${BPN} + link_rename = {} + for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg, True) or "").split(): + alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name, True) + if not alt_link: + alt_link = "%s/%s" % (d.getVar('bindir', True), alt_name) + d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link) + + alt_target = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name, True) or d.getVarFlag('ALTERNATIVE_TARGET', alt_name, True) + alt_target = alt_target or d.getVar('ALTERNATIVE_TARGET_%s' % pkg, True) or d.getVar('ALTERNATIVE_TARGET', True) 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) + + # If the link and target are the same name, we need to rename the target. + if alt_link == alt_target: + src = '%s/%s' % (pkgdest, alt_target) + alt_target_rename = '%s.%s' % (alt_target, pn) + dest = '%s/%s' % (pkgdest, alt_target_rename) + if os.path.lexists(dest): + bb.note('%s: Already renamed: %s' % (pn, alt_target_rename)) + elif os.path.lexists(src): + if os.path.islink(src): + # Delay rename of links + link_rename[alt_target] = alt_target_rename + else: + bb.note('%s: Rename %s -> %s' % (pn, alt_target, alt_target_rename)) + os.rename(src, dest) + else: + bb.warn("%s: alternative target (%s or %s) does not exist, skipping..." % (pn, alt_target, alt_target_rename)) + continue + d.setVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name, alt_target_rename) + + # Process delayed link names + # Do these after other renames so we can correct broken links + for alt_target in link_rename: + src = '%s/%s' % (pkgdest, alt_target) + dest = '%s/%s' % (pkgdest, link_rename[alt_target]) + link = os.readlink(src) + if os.path.isabs(link): + link_target = pkgdest + os.readlink(src) + else: + link_target = os.path.join(os.path.dirname(src), link) + + 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])) + os.rename(src, dest) + else: + # 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)) + os.symlink(link_maybe, dest) + os.unlink(src) + else: + bb.warn('%s: Unable to resolve dangling symlink: %s' % (pn, alt_target)) } python populate_packages_prepend () { - pn = d.getVar('BPN', True) - - # Do actual update alternatives processing - pkgdest = d.getVar('PKGD', True) - for pkg in (d.getVar('PACKAGES', True) or "").split(): - # Create post install/removal scripts - alt_setup_links = "" - alt_remove_links = "" - for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg, True) or "").split(): - alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name, True) - alt_target = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name, True) or d.getVarFlag('ALTERNATIVE_TARGET', alt_name, True) - alt_target = alt_target or d.getVar('ALTERNATIVE_TARGET_%s' % pkg, True) or d.getVar('ALTERNATIVE_TARGET', True) 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, True) or d.getVarFlag('ALTERNATIVE_PRIORITY', alt_name, True) - alt_priority = alt_priority or d.getVar('ALTERNATIVE_PRIORITY_%s' % pkg, True) or d.getVar('ALTERNATIVE_PRIORITY', True) - - # 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.relpath(alt_target, os.path.dirname(alt_link)) - - alt_setup_links += ' update-alternatives --install %s %s %s %s\n' % (alt_link, alt_name, alt_target, alt_priority) - alt_remove_links += ' update-alternatives --remove %s %s\n' % (alt_name, alt_target) - - if alt_setup_links: - bb.note('adding update-alternatives calls to postinst/postrm for %s' % pkg) - bb.note('%s' % alt_setup_links) - postinst = (d.getVar('pkg_postinst_%s' % pkg, True) or d.getVar('pkg_postinst', True)) or '#!/bin/sh\n' - postinst += alt_setup_links - d.setVar('pkg_postinst_%s' % pkg, postinst) - - bb.note('%s' % alt_remove_links) - postrm = (d.getVar('pkg_postrm_%s' % pkg, True) or d.getVar('pkg_postrm', True)) or '#!/bin/sh\n' - postrm += alt_remove_links - d.setVar('pkg_postrm_%s' % pkg, postrm) + pn = d.getVar('BPN', True) + + # Do actual update alternatives processing + pkgdest = d.getVar('PKGD', True) + for pkg in (d.getVar('PACKAGES', True) or "").split(): + # Create post install/removal scripts + alt_setup_links = "" + alt_remove_links = "" + for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg, True) or "").split(): + alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name, True) + alt_target = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name, True) or d.getVarFlag('ALTERNATIVE_TARGET', alt_name, True) + alt_target = alt_target or d.getVar('ALTERNATIVE_TARGET_%s' % pkg, True) or d.getVar('ALTERNATIVE_TARGET', True) 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, True) or d.getVarFlag('ALTERNATIVE_PRIORITY', alt_name, True) + alt_priority = alt_priority or d.getVar('ALTERNATIVE_PRIORITY_%s' % pkg, True) or d.getVar('ALTERNATIVE_PRIORITY', True) + + # 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.relpath(alt_target, os.path.dirname(alt_link)) + + 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) + + if alt_setup_links: + bb.note('adding update-alternatives calls to postinst/postrm for %s' % pkg) + bb.note('%s' % alt_setup_links) + postinst = (d.getVar('pkg_postinst_%s' % pkg, True) or d.getVar('pkg_postinst', True)) or '#!/bin/sh\n' + postinst += alt_setup_links + d.setVar('pkg_postinst_%s' % pkg, postinst) + + bb.note('%s' % alt_remove_links) + postrm = (d.getVar('pkg_postrm_%s' % pkg, True) or d.getVar('pkg_postrm', True)) or '#!/bin/sh\n' + postrm += alt_remove_links + d.setVar('pkg_postrm_%s' % pkg, postrm) } python package_do_filedeps_append () { - pn = d.getVar('BPN', True) - pkgdest = d.getVar('PKGDEST', True) - - for pkg in packages.split(): - for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg, True) or "").split(): - alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name, True) - alt_target = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name, True) or d.getVarFlag('ALTERNATIVE_TARGET', alt_name, True) - alt_target = alt_target or d.getVar('ALTERNATIVE_TARGET_%s' % pkg, True) or d.getVar('ALTERNATIVE_TARGET', True) or alt_link - - if alt_link == alt_target: - bb.warn('alt_link == alt_target: %s == %s' % (alt_link, alt_target)) - alt_target = '%s.%s' % (alt_target, pn) - - if not os.path.lexists('%s/%s/%s' % (pkgdest, pkg, alt_target)): - continue - - # Add file provide - trans_target = file_translate(alt_target) - d.appendVar('FILERPROVIDES_%s_%s' % (trans_target, pkg), " " + alt_link) - if not trans_target in (d.getVar('FILERPROVIDESFLIST_%s' % pkg, True) or ""): - d.appendVar('FILERPROVIDESFLIST_%s' % pkg, " " + trans_target) + pn = d.getVar('BPN', True) + pkgdest = d.getVar('PKGDEST', True) + + for pkg in packages.split(): + for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg, True) or "").split(): + alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name, True) + alt_target = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name, True) or d.getVarFlag('ALTERNATIVE_TARGET', alt_name, True) + alt_target = alt_target or d.getVar('ALTERNATIVE_TARGET_%s' % pkg, True) or d.getVar('ALTERNATIVE_TARGET', True) or alt_link + + if alt_link == alt_target: + bb.warn('alt_link == alt_target: %s == %s' % (alt_link, alt_target)) + alt_target = '%s.%s' % (alt_target, pn) + + if not os.path.lexists('%s/%s/%s' % (pkgdest, pkg, alt_target)): + continue + + # Add file provide + trans_target = file_translate(alt_target) + d.appendVar('FILERPROVIDES_%s_%s' % (trans_target, pkg), " " + alt_link) + if not trans_target in (d.getVar('FILERPROVIDESFLIST_%s' % pkg, True) or ""): + d.appendVar('FILERPROVIDESFLIST_%s' % pkg, " " + trans_target) } |