def _run_action(args): defaulted_components = False components = utils.parse_components(args.pop("components")) if not components: defaulted_components = True components = common.get_default_components() action = _clean_action(args.pop("action")) if not action: print(utils.color_text("No valid action specified!", "red")) return False rootdir = args.pop("dir") if rootdir is None: print(utils.color_text("No root directory specified!", "red")) return False #ensure os/distro is known (distro, platform) = utils.determine_distro() if distro is None: print("Unsupported platform " + utils.color_text(platform, "red") + "!") return False #start it (rep, maxlen) = utils.welcome(_WELCOME_MAP.get(action)) header = utils.center_text("Action Runner", rep, maxlen) print(header) #here on out should be using the logger if not defaulted_components: LOG.info("Activating components [%s]" % (", ".join(sorted(components.keys())))) else: LOG.info("Activating default components [%s]" % (", ".join(sorted(components.keys())))) #need to figure out dependencies for components (if any) ignore_deps = args.pop('ignore_deps', False) component_order = None if not ignore_deps: all_components_deps = common.get_components_deps(action, components) component_diff = set(all_components_deps.keys()).difference(components.keys()) if component_diff: LOG.info("Having to activate dependent components: [%s]" \ % (", ".join(sorted(component_diff)))) for new_component in component_diff: components[new_component] = list() component_order = utils.get_components_order(all_components_deps) else: component_order = components.keys() #reverse them so that we stop in the reverse order #and that we uninstall in the reverse order which seems to make sense if action in _REVERSE_ACTIONS: component_order.reverse() #add in any that will just be referenced but which will not actually do anything (ie the action will not be applied to these) ref_components = utils.parse_components(args.pop("ref_components")) for c in ref_components.keys(): if c not in components: components[c] = ref_components.get(c) #now do it! LOG.info("Starting action [%s] on %s for distro [%s]" % (action, date.rcf8222date(), distro)) _run_components(action, component_order, components, distro, rootdir, args) LOG.info("Finished action [%s] on %s" % (action, date.rcf8222date())) return True
root=dummy_root, opts=list(), keep_old=False) if not isinstance(instance, component.PkgInstallComponent): return None else: pkgs = instance._get_pkgs_expanded() epel_pkgs = dict() for (name, info) in pkgs.items(): meta = info.get("meta") or dict() if meta and meta.get("epel"): epel_pkgs[name] = info return epel_pkgs if __name__ == "__main__": me = os.path.basename(sys.argv[0]) distro = EPEL_DISTRO for c in sorted(settings.COMPONENT_NAMES): print("Packages for %s:" % (utils.color_text(c, 'green', bold=True, underline=True))) pkgs = get_epels(c, distro) if not pkgs: print("\t- %s" % (utils.color_text('N/A', 'red'))) else: names = sorted(pkgs.keys()) for name in names: real_name = name info = pkgs.get(name) or dict() if 'version' in info: real_name = "%s (%s)" % (name, utils.color_text(str(info.get('version')), 'blue', bold=True)) print("\t- %s" % real_name)