예제 #1
0
def regenerate_repodata(repository_path, marked_repository_path):
    """
    Re-generates the repodata for the given repository.

    @param repository_path  The path to the repository.

    Uses group.xml and patterns.xml from any path inside repository, if these
    files don't exist they're unpacked from package-groups.rpm
    """
    repository = Repository(repository_path)
    repodata = repository.get_data()
    if repodata.groups_data is None:
        logging.warning("There is no groups data in "
                        "{0}".format(repository_path))
    if repodata.patterns_data is None:
        logging.warning("There is no patterns data in "
                        "{0}".format(repository_path))
    repository.generate_derived_data()

    marked_repository = Repository(marked_repository_path)
    marked_repository.set_data(repodata)
    marked_repository.generate_derived_data()
예제 #2
0
def construct_combined_repositories(parameters, packages):
    """
    Constructs combined repositories based on arguments.

    @param parameters       The parameters of the repository combiner.
    @param packages         The list of package names that should be installed
                            to the image with all their dependencies.

    @return                 The list of combined repositories' paths.
    """
    dependency_builder = DependencyGraphBuilder(check_rpm_name, packages)

    graphs = {}
    for repository_pair in parameters.repository_pairs:
        graphs[repository_pair.name] = build_graphs(repository_pair,
                                                    dependency_builder,
                                                    parameters)
    specified_packages = check_package_names(graphs, parameters.package_names)

    # Prepare RPM patching root based on original dependency graphs:
    original_repositories = [
        repository_pair.url for repository_pair in parameters.repository_pairs
    ]
    names = [
        repository_pair.name for repository_pair in parameters.repository_pairs
    ]
    patcher = rpm_patcher.RpmPatcher(names, original_repositories,
                                     parameters.architecture,
                                     parameters.kickstart_file_path,
                                     [graphs[key][0] for key in graphs.keys()])

    combined_repository_paths = {}
    marked_packages_total = Set()
    for repository_pair in parameters.repository_pairs:
        logging.debug(parameters.package_names)
        path, marked_packages = process_repository_pair(
            repository_pair, graphs[repository_pair.name], parameters, patcher)
        marked_packages_total = marked_packages_total | marked_packages
        combined_repository_paths[repository_pair.name] = path

    excluded_packages = parameters.package_names.get("excluded")
    if excluded_packages is None:
        excluded_packages = []
    for package in specified_packages:
        if (package not in marked_packages_total
                and package not in excluded_packages):
            raise Exception("Failed to find package with name \"{0}\" in any"
                            " of non-marked repositories".format(package))
    patcher.do_tasks()
    for repository_pair in parameters.repository_pairs:
        repository = Repository(repository_pair.url)
        repository.prepare_data()
        repodata = repository.data
        combined_repository = Repository(
            combined_repository_paths[repository_pair.name])
        combined_repository.set_data(repodata)
        combined_repository.generate_derived_data()
    return [
        combined_repository_paths[key]
        for key in combined_repository_paths.keys()
    ]