From 53ab6a9ec538ed0d35755879034f800739bc6655 Mon Sep 17 00:00:00 2001 From: Louis Abel Date: Tue, 11 Oct 2022 19:58:17 -0700 Subject: [PATCH] Modify repoclosure for peridot and metadata * Fix peridot repoclosure script * Modify shared utils for metadata and repositories (part 1, metadata) * Modify dnf utils to take advantage of shared utility (part 2, metadata) --- .../empanadas/scripts/peridot_repoclosure.py | 0 .../empanadas/scripts/test_module.py | 26 ++++++++++++++++ iso/empanadas/empanadas/util/dnf_utils.py | 4 ++- iso/empanadas/empanadas/util/shared.py | 10 +++++++ iso/empanadas/pyproject.toml | 1 + mangle/generators/version_metadata_parser.py | 30 +++++++++++++++++++ 6 files changed, 70 insertions(+), 1 deletion(-) mode change 100644 => 100755 iso/empanadas/empanadas/scripts/peridot_repoclosure.py create mode 100755 iso/empanadas/empanadas/scripts/test_module.py create mode 100644 mangle/generators/version_metadata_parser.py diff --git a/iso/empanadas/empanadas/scripts/peridot_repoclosure.py b/iso/empanadas/empanadas/scripts/peridot_repoclosure.py old mode 100644 new mode 100755 diff --git a/iso/empanadas/empanadas/scripts/test_module.py b/iso/empanadas/empanadas/scripts/test_module.py new file mode 100755 index 0000000..7735157 --- /dev/null +++ b/iso/empanadas/empanadas/scripts/test_module.py @@ -0,0 +1,26 @@ +# Use this to test upcoming functionality + +import argparse +import sys +#import createrepo_c as cr + +from empanadas.common import * +from empanadas.util import Checks +from empanadas.util import RepoSync + +# Start up the parser baby +parser = argparse.ArgumentParser(description="Peridot Upstream Repoclosure") + +# All of our options +parser.add_argument('--release', type=str, help="Major Release Version or major-type (eg 9-beta)", required=True) + +# Parse them +results = parser.parse_args() +rlvars = rldict[results.release] +major = rlvars['major'] + +r = Checks(rlvars, config['arch']) +r.check_valid_arch() + +def run(): + print(sys.path) diff --git a/iso/empanadas/empanadas/util/dnf_utils.py b/iso/empanadas/empanadas/util/dnf_utils.py index a706c38..379cfb3 100644 --- a/iso/empanadas/empanadas/util/dnf_utils.py +++ b/iso/empanadas/empanadas/util/dnf_utils.py @@ -912,7 +912,9 @@ class RepoSync: self.shortname, self.fullversion, 'updates', - productmd_date + productmd_date, + self.arches, + self.repos ) self.log.info(Color.INFO + 'Metadata files phase completed.') diff --git a/iso/empanadas/empanadas/util/shared.py b/iso/empanadas/empanadas/util/shared.py index 3923062..99f8c36 100644 --- a/iso/empanadas/empanadas/util/shared.py +++ b/iso/empanadas/empanadas/util/shared.py @@ -978,6 +978,16 @@ class Shared: ci.compose.date = datestamp ci.compose.respin = 0 + for repo in repos: + variant_repo = productmd.composeinfo.Variant(ci) + variant_repo.id = repo + variant_repo.uid = repo + variant_repo.name = repo + variant_repo.type = "variant" + variant_repo.arches = set(arches) + + ci.variants.add(variant_repo) + ci.dump(cijson) with open(cijson, 'r') as cidump: diff --git a/iso/empanadas/pyproject.toml b/iso/empanadas/pyproject.toml index 371fb51..a3a9e6c 100644 --- a/iso/empanadas/pyproject.toml +++ b/iso/empanadas/pyproject.toml @@ -22,6 +22,7 @@ attrs = "^21.4.0" pytest = "~5" [tool.poetry.scripts] +test_module = "empanadas.scripts.test_module:run" sync_from_peridot = "empanadas.scripts.sync_from_peridot:run" sync_from_peridot_test = "empanadas.scripts.sync_from_peridot_test:run" sync_sig = "empanadas.scripts.sync_sig:run" diff --git a/mangle/generators/version_metadata_parser.py b/mangle/generators/version_metadata_parser.py new file mode 100644 index 0000000..62777d4 --- /dev/null +++ b/mangle/generators/version_metadata_parser.py @@ -0,0 +1,30 @@ +#!/usr/bin/python3 +import os +import os.path +import json +import dnf + +# Init the dnf configuration +base = dnf.Base() +conf = base.conf +base.read_all_repos() +all_repos = base.repos.all() +all_repos.disable() +base.repos.add_new_repo('all-source', conf, baseurl=['https://yumrepofs.build.resf.org/v1/projects/55b17281-bc54-4929-8aca-a8a11d628738/repo/all/src']) +base.fill_sack() + +q = base.sack.query() +a = q.available() +pkg_list = [] + +for packages in a: + nevr = '{}-{}:{}-{}'.format( + packages.name, + packages.epoch, + packages.version, + packages.release + ) + pkg_list.append(nevr) + +pkg_list.sort() +print(pkg_list)