From 818c7c211150ee192a91c995a3979762952081f8 Mon Sep 17 00:00:00 2001 From: K900 Date: Thu, 23 May 2024 14:03:50 +0300 Subject: [PATCH] scripts/kde/collect-metadata: option to use unstable version --- maintainers/scripts/kde/collect-metadata.py | 9 +++-- maintainers/scripts/kde/utils.py | 39 +++++++++++---------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/maintainers/scripts/kde/collect-metadata.py b/maintainers/scripts/kde/collect-metadata.py index eaa619647136..3a7a3e95508e 100755 --- a/maintainers/scripts/kde/collect-metadata.py +++ b/maintainers/scripts/kde/collect-metadata.py @@ -27,8 +27,13 @@ import utils ), default=pathlib.Path(__file__).parent.parent.parent.parent ) -def main(repo_metadata: pathlib.Path, nixpkgs: pathlib.Path): - metadata = utils.KDERepoMetadata.from_repo_metadata_checkout(repo_metadata) +@click.option( + "--unstable", + default=False, + is_flag=True +) +def main(repo_metadata: pathlib.Path, nixpkgs: pathlib.Path, unstable: bool): + metadata = utils.KDERepoMetadata.from_repo_metadata_checkout(repo_metadata, unstable) out_dir = nixpkgs / "pkgs/kde/generated" metadata.write_json(out_dir) diff --git a/maintainers/scripts/kde/utils.py b/maintainers/scripts/kde/utils.py index b3a00093d703..14ca61df3554 100644 --- a/maintainers/scripts/kde/utils.py +++ b/maintainers/scripts/kde/utils.py @@ -104,7 +104,7 @@ class KDERepoMetadata: return project @classmethod - def from_repo_metadata_checkout(cls, repo_metadata: pathlib.Path): + def from_repo_metadata_checkout(cls, repo_metadata: pathlib.Path, unstable=False): projects = [ Project.from_yaml(metadata_file) for metadata_file in repo_metadata.glob("projects-invent/**/metadata.yaml") @@ -122,29 +122,32 @@ class KDERepoMetadata: dep_graph={}, ) - dep_specs = ["dependency-data-stable-kf6-qt6"] dep_graph = collections.defaultdict(set) - for spec in dep_specs: - spec_path = repo_metadata / "dependencies" / spec - for line in spec_path.open(): - line = line.strip() - if line.startswith("#"): - continue - if not line: - continue + if unstable: + spec_name = "dependency-data-kf6-qt6" + else: + spec_name = "dependency-data-stable-kf6-qt6" - dependent, dependency = line.split(": ") + spec_path = repo_metadata / "dependencies" / spec_name + for line in spec_path.open(): + line = line.strip() + if line.startswith("#"): + continue + if not line: + continue - dependent = self.try_lookup_package(dependent) - if dependent is None: - continue + dependent, dependency = line.split(": ") - dependency = self.try_lookup_package(dependency) - if dependency is None: - continue + dependent = self.try_lookup_package(dependent) + if dependent is None: + continue - dep_graph[dependent].add(dependency) + dependency = self.try_lookup_package(dependency) + if dependency is None: + continue + + dep_graph[dependent].add(dependency) self.dep_graph = dep_graph