def get_pips(c, distro): cls = common.get_action_cls(settings.INSTALL, c) dummy_config = common.get_config() dummy_root = tempfile.gettempdir() instance = cls(instances=set(), distro=distro, packager=None, config=dummy_config, root=dummy_root, opts=list(), keep_old=False) if not isinstance(instance, component.PkgInstallComponent): return None else: return instance._get_pkgs_expanded()
def get_epels(c, distro): cls = common.get_action_cls(settings.INSTALL, c) dummy_config = common.get_config() dummy_root = tempfile.gettempdir() instance = cls(instances=set(), distro=distro, packager=None, config=dummy_config, 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
def _run_components(action_name, component_order, components, distro, root_dir, program_args): LOG.info("Will run action [%s] using root directory \"%s\"" % (action_name, root_dir)) LOG.info("In the following order: %s" % ("->".join(component_order))) non_components = set(components.keys()).difference(set(component_order)) if non_components: LOG.info("Using reference components (%s)" % (", ".join(sorted(non_components)))) #get the package manager + config pkg_manager = _get_pkg_manager(distro, program_args.get('keep_packages', True)) config = common.get_config() #form the active instances (this includes ones we won't use) (all_instances, prerequisite_instances) = _instanciate_components(action_name, components, distro, pkg_manager, config, root_dir) #run anything before it gets going... _pre_run(action_name, root_dir=root_dir, pkg_manager=pkg_manager, config=config, component_order=component_order, instances=(all_instances, prerequisite_instances)) LOG.info("Activating components required to complete action %s." % (action_name)) start_time = time.time() results = list() force = program_args.get('force', False) for component in component_order: instance = all_instances[component] #activate the correct function for the given action if action_name == settings.INSTALL: install_result = _install(component, instance) if install_result: #TODO clean this up. if type(install_result) == list: results += install_result else: results.append(str(install_result)) elif action_name == settings.STOP: _stop(component, instance, force) elif action_name == settings.START: #do we need to activate an install prerequisite first??? if component in prerequisite_instances: install_instance = prerequisite_instances[component] _install(component, install_instance) #now start it start_result = _start(component, instance) if start_result: #TODO clean this up. if type(start_result) == list: results += start_result else: results.append(str(start_result)) elif action_name == settings.UNINSTALL: #do we need to activate an uninstall prerequisite first??? if component in prerequisite_instances: stop_instance = prerequisite_instances[component] _stop(component, stop_instance, force) _uninstall(component, instance, force) end_time = time.time() #any post run actions go now _post_run(action_name, root_dir=root_dir, config=config, components=components.keys(), time_taken=(end_time - start_time), results=results)