From 8b062e7a4c4bd3f99919f4729faaf7ada6647696 Mon Sep 17 00:00:00 2001 From: Jayden Grubb Date: Sun, 13 Oct 2024 17:28:45 +1000 Subject: [PATCH 1/8] Add new migration tool to vinca (vinca-mg) --- setup.cfg | 1 + vinca/migration.py | 92 ++++++++++++++++++++++++++++++++++++++++++++++ vinca/utils.py | 13 +++++++ 3 files changed, 106 insertions(+) create mode 100644 vinca/migration.py diff --git a/setup.cfg b/setup.cfg index 237cb80..cb07742 100644 --- a/setup.cfg +++ b/setup.cfg @@ -42,6 +42,7 @@ console_scripts = vinca-gha = vinca.generate_gha:main vinca-azure = vinca.generate_azure:main vinca-migrate = vinca.migrate:main + vinca-mg = vinca.migration:main [flake8] import-order-style = google diff --git a/vinca/migration.py b/vinca/migration.py new file mode 100644 index 0000000..340deff --- /dev/null +++ b/vinca/migration.py @@ -0,0 +1,92 @@ +import argparse +from ruamel.yaml import YAML +from .utils import get_repodata, get_pinnings + + +def main(): + parser = argparse.ArgumentParser( + description="Dependency migration tool for ROS packages" + ) + parser.add_argument( + type=str, + dest="pinnings", + help="Path to the local pinnings file", + metavar="PINNINGS", + ) + parser.add_argument( + "-a", + "--all", + action="store_true", + dest="all", + help="Show all dependencies", + required=False, + ) + parser.add_argument( + "-p", + "--platform", + type=str, + dest="platform", + choices=["win-64", "linux-64", "linux-aarch64", "osx-64", "osx-arm64"], + default="linux-64", + help="Platform to target (default: linux-64)", + required=False, + ) + parser.add_argument( + "--repodata", + type=str, + dest="repodata", + default="https://conda.anaconda.org/robostack-staging/", + help="URL to the repodata file", + required=False, + ) + parser.add_argument( + "--upstream", + type=str, + dest="upstream", + default="https://raw.githubusercontent.com/conda-forge/conda-forge-pinning-feedstock/refs/heads/main/recipe/conda_build_config.yaml", + help="URL to the upstream pinnings file", + required=False, + ) + args = parser.parse_args() + + repodata = get_repodata(args.repodata, args.platform) + packages = repodata["packages"] + + deps = set() + for pkg in packages: + for dep in packages[pkg].get("depends", []): + deps.add(dep.split()[0]) + + local = get_pinnings(args.pinnings) + upstream = get_pinnings(args.upstream) + + common = sorted(deps.intersection(local.keys())) + max_len = max(len(name) for name in common) + print("\033[1m{0:{2}} {1}\033[0m".format("Package", "Versions", max_len)) + + changed = [] + + for name in common: + current = local[name] + latest = upstream[name] + + if current == latest: + if args.all: + print("{0:{2}} {1}".format(name, current, max_len)) + continue + + print("{0:{3}} {1} -> {2}".format(name, current, latest, max_len)) + + local[name] = latest + changed.append(name) + + if not changed: + print("No packages to migrate") + return + + with open(args.pinnings, "w") as f: + yaml = YAML() + yaml.indent(mapping=2, sequence=4, offset=2) + yaml.compact_seq_seq = False + # TODO: check output formatting + yaml.dump(local, f) diff --git a/vinca/utils.py b/vinca/utils.py index a516720..0d9e2ea 100644 --- a/vinca/utils.py +++ b/vinca/utils.py @@ -4,6 +4,7 @@ import time import json import requests +import ruamel.yaml class folded_unicode(str): @@ -64,3 +65,15 @@ def get_repodata(url_or_path, platform=None): with open(fn, "w") as fcache: fcache.write(content.decode("utf-8")) return json.loads(content) + + +def get_pinnings(url_or_path): + yaml = ruamel.yaml.YAML() + yaml.allow_duplicate_keys = True + + if "://" not in url_or_path: + with open(url_or_path) as fi: + return yaml.load(fi) + + response = requests.get(url_or_path) + return yaml.load(response.content) From ead7df69707933142ff905b4238178fdb26ef7a5 Mon Sep 17 00:00:00 2001 From: Jayden Grubb Date: Sun, 13 Oct 2024 19:12:25 +1000 Subject: [PATCH 2/8] Find packages to rebuild --- vinca/migration.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/vinca/migration.py b/vinca/migration.py index 340deff..146ee76 100644 --- a/vinca/migration.py +++ b/vinca/migration.py @@ -1,4 +1,5 @@ import argparse +import networkx as nx from ruamel.yaml import YAML from .utils import get_repodata, get_pinnings @@ -90,3 +91,26 @@ def main(): yaml.compact_seq_seq = False # TODO: check output formatting yaml.dump(local, f) + + graph = nx.DiGraph() + for pkg in packages: + pkg_name = packages[pkg].get("name") + if not pkg_name.startswith("ros-humble"): # TODO: add parameter for prefix + continue + graph.add_node(pkg_name) + for dep in packages[pkg].get("depends", []): + req = dep.split()[0] + graph.add_edge(pkg_name, req) + + graph = graph.reverse() + + rebuild = set() + for pkg in changed: + if pkg not in graph: + continue + for node in nx.dfs_predecessors(graph, pkg): + rebuild.add(node) + + print("\n\033[1mPackages to rebuild:\033[0m") + for pkg in rebuild: + print(pkg) From aa361a73f21ce86d3e373c13dbb30ec65219a583 Mon Sep 17 00:00:00 2001 From: Jayden Grubb Date: Sun, 13 Oct 2024 22:27:01 +1000 Subject: [PATCH 3/8] Find repo name of package to rebuild --- vinca/distro.py | 3 +++ vinca/migration.py | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/vinca/distro.py b/vinca/distro.py index 666e420..1599c40 100644 --- a/vinca/distro.py +++ b/vinca/distro.py @@ -65,6 +65,9 @@ def get_released_repo(self, pkg_name): release_tag = get_release_tag(repo, pkg_name) return repo.url, release_tag + def get_released_repo_name(self, package_name): + return self._distro.release_packages[package_name].repository_name + def check_package(self, pkg_name): if pkg_name in self._distro.release_packages: return True diff --git a/vinca/migration.py b/vinca/migration.py index 146ee76..b6f38e1 100644 --- a/vinca/migration.py +++ b/vinca/migration.py @@ -1,6 +1,7 @@ import argparse import networkx as nx from ruamel.yaml import YAML +from .distro import Distro from .utils import get_repodata, get_pinnings @@ -95,7 +96,7 @@ def main(): graph = nx.DiGraph() for pkg in packages: pkg_name = packages[pkg].get("name") - if not pkg_name.startswith("ros-humble"): # TODO: add parameter for prefix + if not pkg_name.startswith("ros-humble"): # TODO: add parameter for distro continue graph.add_node(pkg_name) for dep in packages[pkg].get("depends", []): @@ -103,13 +104,16 @@ def main(): graph.add_edge(pkg_name, req) graph = graph.reverse() + distro = Distro("humble") # TODO: add parameter for distro rebuild = set() for pkg in changed: if pkg not in graph: continue for node in nx.dfs_predecessors(graph, pkg): - rebuild.add(node) + ros_name = node.replace("ros-humble-", "").replace("-", "_") + repo_name = distro.get_released_repo_name(ros_name) + rebuild.add(repo_name) print("\n\033[1mPackages to rebuild:\033[0m") for pkg in rebuild: From 5f6760eb643228af94651b2ced27e044ac58143a Mon Sep 17 00:00:00 2001 From: Jayden Grubb Date: Mon, 14 Oct 2024 22:44:16 +1000 Subject: [PATCH 4/8] Update vinca.yaml with migration list --- vinca/migration.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/vinca/migration.py b/vinca/migration.py index b6f38e1..ef3a0f0 100644 --- a/vinca/migration.py +++ b/vinca/migration.py @@ -33,6 +33,15 @@ def main(): help="Platform to target (default: linux-64)", required=False, ) + parser.add_argument( + "-v", + "--vinca", + type=str, + dest="vinca", + default="vinca.yaml", + help="Path to the vinca configuration file", + required=False, + ) parser.add_argument( "--repodata", type=str, @@ -51,6 +60,11 @@ def main(): ) args = parser.parse_args() + with open(args.vinca, "r") as f: + vinca = YAML().load(f) + + ros_distro = vinca["ros_distro"] + repodata = get_repodata(args.repodata, args.platform) packages = repodata["packages"] @@ -96,7 +110,7 @@ def main(): graph = nx.DiGraph() for pkg in packages: pkg_name = packages[pkg].get("name") - if not pkg_name.startswith("ros-humble"): # TODO: add parameter for distro + if not pkg_name.startswith("ros-" + ros_distro): continue graph.add_node(pkg_name) for dep in packages[pkg].get("depends", []): @@ -104,17 +118,25 @@ def main(): graph.add_edge(pkg_name, req) graph = graph.reverse() - distro = Distro("humble") # TODO: add parameter for distro + distro = Distro(ros_distro) rebuild = set() for pkg in changed: if pkg not in graph: continue for node in nx.dfs_predecessors(graph, pkg): - ros_name = node.replace("ros-humble-", "").replace("-", "_") + ros_name = node.removeprefix("ros-" + ros_distro + "-").replace("-", "_") repo_name = distro.get_released_repo_name(ros_name) rebuild.add(repo_name) + vinca["build_number"] += 1 + vinca["full_rebuild"] = False + vinca["packages_select_by_deps"] = list(rebuild) + # TODO: comment/uncomment/add packages to existing list instead of overwriting + + with open(args.vinca, "w") as f: + yaml.dump(vinca, f) + print("\n\033[1mPackages to rebuild:\033[0m") for pkg in rebuild: print(pkg) From faa58dca269817b9d413725fe252130538521c5a Mon Sep 17 00:00:00 2001 From: Jayden Grubb Date: Tue, 15 Oct 2024 10:55:23 +1000 Subject: [PATCH 5/8] Replace old migration tool --- setup.cfg | 1 - vinca/migrate.py | 303 ++++++++++++++++++--------------------------- vinca/migration.py | 142 --------------------- 3 files changed, 121 insertions(+), 325 deletions(-) delete mode 100644 vinca/migration.py diff --git a/setup.cfg b/setup.cfg index cb07742..237cb80 100644 --- a/setup.cfg +++ b/setup.cfg @@ -42,7 +42,6 @@ console_scripts = vinca-gha = vinca.generate_gha:main vinca-azure = vinca.generate_azure:main vinca-migrate = vinca.migrate:main - vinca-mg = vinca.migration:main [flake8] import-order-style = google diff --git a/vinca/migrate.py b/vinca/migrate.py index 69aff1b..ef3a0f0 100644 --- a/vinca/migrate.py +++ b/vinca/migrate.py @@ -1,203 +1,142 @@ -import yaml -import sys -import os import argparse -import re import networkx as nx -import subprocess -import shutil -import ruamel.yaml -from .utils import get_repodata -from vinca import config -from vinca.distro import Distro -from distutils.dir_util import copy_tree - -distro_version = None -ros_prefix = None - -# arches = ["linux-64", "linux-aarch64", "win-64", "osx-64", "osx-arm64"] -# arch_to_fname = { -# "linux-64": "linux", -# "linux-aarch64": "linux_aarch_64", -# "win-64": "win", -# "osx-64": "osx", -# "osx-arm64": "osx_arm64" -# } - - -def to_ros_name(distro, pkg_name): - shortname = pkg_name[len(ros_prefix) + 1 :] - if distro.check_package(shortname): - return shortname - elif distro.check_package(shortname.replace("-", "_")): - return shortname.replace("-", "_") - else: - raise RuntimeError(f"Couldnt convert {pkg_name} to ROS pkg name") - - -def create_migration_instructions(arch, packages_to_migrate, trigger_branch): - url = "https://conda.anaconda.org/robostack/" - - yaml = ruamel.yaml.YAML() - with open("vinca.yaml", "r") as fi: - vinca_conf = yaml.load(fi) - - global distro_version, ros_prefix - distro_version = vinca_conf["ros_distro"] - ros_prefix = f"ros-{distro_version}" - - repodata = get_repodata(url, arch) +from ruamel.yaml import YAML +from .distro import Distro +from .utils import get_repodata, get_pinnings - packages = repodata["packages"] - to_migrate = set() - ros_pkgs = set() - for pkey in packages: - if not pkey.startswith(ros_prefix): - continue - - pname = pkey.rsplit("-", 2)[0] - ros_pkgs.add(pname) - - p = packages[pkey] - - for d in p.get("depends", []): - if d.split()[0] in packages_to_migrate: - # print(f"need to migrate {pkey}") - to_migrate.add(pname) - - latest = {} - for pkg in ros_pkgs: - current = current_version = None - for pkey in packages: - if packages[pkey]["name"] == pkg: - tmp = packages[pkey]["version"].split(".") - version = [] - for el in tmp: - if el.isdecimal(): - version.append(int(el)) - else: - x = re.search(r"[^0-9]", version).start() - version.append(int(el[:x])) - - version = tuple(version) - - if not current or version > current_version: - current_version = version - current = pkey - latest[pkg] = current - - # now we can build the graph ... - - G = nx.DiGraph() - for pkg, pkgkey in latest.items(): - full_pkg = packages[pkgkey] - for dep in full_pkg.get("depends", []): - req = dep.split(" ")[0] - G.add_node(pkg) - if req.startswith(ros_prefix): - G.add_edge(pkg, req) - - gsorted = nx.topological_sort(G) - gsorted = list(reversed([g for g in gsorted])) - - to_migrate = sorted(to_migrate, key=lambda x: gsorted.index(x)) - - print("Sorted to migrate: ", to_migrate) - - distro = Distro(distro_version) - # import IPython; IPython.embed() - ros_names = [] - for pkg in to_migrate: - ros_names.append(to_ros_name(distro, pkg)) - print("Final names: ", ros_names) - - vinca_conf["packages_select_by_deps"] = ros_names - vinca_conf["skip_all_deps"] = True - vinca_conf["is_migration"] = True - vinca_conf["skip_existing"] = [] - - with open("vinca.yaml", "w") as fo: - yaml.dump(vinca_conf, fo) - - if os.path.exists("recipes"): - shutil.rmtree("recipes") - - mutex_path = os.path.join( - config.parsed_args.dir, "additional_recipes/ros-distro-mutex" - ) - if os.path.exists(mutex_path): - goal_folder = os.path.join( - config.parsed_args.dir, "recipes", "ros-distro-mutex" - ) - os.makedirs(goal_folder, exist_ok=True) - copy_tree(mutex_path, goal_folder) - - subprocess.check_call( - ["vinca", "-d", config.parsed_args.dir, "--multiple", "--platform", arch] - ) - - # TODO remove hard coded build branch here! - recipe_dir = os.path.join(config.parsed_args.dir, "recipes") - subprocess.check_call( - [ - "vinca-azure", - "--platform", - arch, - "--trigger-branch", - "buildbranch_linux", - "-d", - recipe_dir, - "--additional-recipes", - ] - ) - - -def parse_command_line(argv): +def main(): parser = argparse.ArgumentParser( - description="Conda recipe Azure pipeline generator for ROS packages" + description="Dependency migration tool for ROS packages" ) - - default_dir = "./recipes" parser.add_argument( - "-d", - "--dir", - dest="dir", - default=default_dir, - help="The recipes directory to process (default: {}).".format(default_dir), + type=str, + dest="pinnings", + help="Path to the local pinnings file", + metavar="PINNINGS", ) - parser.add_argument( - "-t", "--trigger-branch", dest="trigger_branch", help="Trigger branch for Azure" + "-a", + "--all", + action="store_true", + dest="all", + help="Show all dependencies", + required=False, ) - parser.add_argument( "-p", "--platform", + type=str, dest="platform", + choices=["win-64", "linux-64", "linux-aarch64", "osx-64", "osx-arm64"], default="linux-64", - help="Platform to emit build pipeline for", + help="Platform to target (default: linux-64)", + required=False, ) - parser.add_argument( - "-a", - "--additional-recipes", - action="store_true", - help="search for additional_recipes folder?", + "-v", + "--vinca", + type=str, + dest="vinca", + default="vinca.yaml", + help="Path to the vinca configuration file", + required=False, + ) + parser.add_argument( + "--repodata", + type=str, + dest="repodata", + default="https://conda.anaconda.org/robostack-staging/", + help="URL to the repodata file", + required=False, ) + parser.add_argument( + "--upstream", + type=str, + dest="upstream", + default="https://raw.githubusercontent.com/conda-forge/conda-forge-pinning-feedstock/refs/heads/main/recipe/conda_build_config.yaml", + help="URL to the upstream pinnings file", + required=False, + ) + args = parser.parse_args() - arguments = parser.parse_args(argv[1:]) - config.parsed_args = arguments - return arguments + with open(args.vinca, "r") as f: + vinca = YAML().load(f) + ros_distro = vinca["ros_distro"] -def main(): - args = parse_command_line(sys.argv) - - mfile = os.path.join(args.dir + "/migration.yaml") - with open(mfile, "r") as fi: - migration = yaml.safe_load(fi) - print(migration) - create_migration_instructions( - args.platform, migration.get("packages", []), args.trigger_branch - ) + repodata = get_repodata(args.repodata, args.platform) + packages = repodata["packages"] + + deps = set() + for pkg in packages: + for dep in packages[pkg].get("depends", []): + deps.add(dep.split()[0]) + + local = get_pinnings(args.pinnings) + upstream = get_pinnings(args.upstream) + + common = sorted(deps.intersection(local.keys())) + max_len = max(len(name) for name in common) + print("\033[1m{0:{2}} {1}\033[0m".format("Package", "Versions", max_len)) + + changed = [] + + for name in common: + current = local[name] + latest = upstream[name] + + if current == latest: + if args.all: + print("{0:{2}} {1}".format(name, current, max_len)) + continue + + print("{0:{3}} {1} -> {2}".format(name, current, latest, max_len)) + + local[name] = latest + changed.append(name) + + if not changed: + print("No packages to migrate") + return + + with open(args.pinnings, "w") as f: + yaml = YAML() + yaml.indent(mapping=2, sequence=4, offset=2) + yaml.compact_seq_seq = False + # TODO: check output formatting + yaml.dump(local, f) + + graph = nx.DiGraph() + for pkg in packages: + pkg_name = packages[pkg].get("name") + if not pkg_name.startswith("ros-" + ros_distro): + continue + graph.add_node(pkg_name) + for dep in packages[pkg].get("depends", []): + req = dep.split()[0] + graph.add_edge(pkg_name, req) + + graph = graph.reverse() + distro = Distro(ros_distro) + + rebuild = set() + for pkg in changed: + if pkg not in graph: + continue + for node in nx.dfs_predecessors(graph, pkg): + ros_name = node.removeprefix("ros-" + ros_distro + "-").replace("-", "_") + repo_name = distro.get_released_repo_name(ros_name) + rebuild.add(repo_name) + + vinca["build_number"] += 1 + vinca["full_rebuild"] = False + vinca["packages_select_by_deps"] = list(rebuild) + # TODO: comment/uncomment/add packages to existing list instead of overwriting + + with open(args.vinca, "w") as f: + yaml.dump(vinca, f) + + print("\n\033[1mPackages to rebuild:\033[0m") + for pkg in rebuild: + print(pkg) diff --git a/vinca/migration.py b/vinca/migration.py deleted file mode 100644 index ef3a0f0..0000000 --- a/vinca/migration.py +++ /dev/null @@ -1,142 +0,0 @@ -import argparse -import networkx as nx -from ruamel.yaml import YAML -from .distro import Distro -from .utils import get_repodata, get_pinnings - - -def main(): - parser = argparse.ArgumentParser( - description="Dependency migration tool for ROS packages" - ) - parser.add_argument( - type=str, - dest="pinnings", - help="Path to the local pinnings file", - metavar="PINNINGS", - ) - parser.add_argument( - "-a", - "--all", - action="store_true", - dest="all", - help="Show all dependencies", - required=False, - ) - parser.add_argument( - "-p", - "--platform", - type=str, - dest="platform", - choices=["win-64", "linux-64", "linux-aarch64", "osx-64", "osx-arm64"], - default="linux-64", - help="Platform to target (default: linux-64)", - required=False, - ) - parser.add_argument( - "-v", - "--vinca", - type=str, - dest="vinca", - default="vinca.yaml", - help="Path to the vinca configuration file", - required=False, - ) - parser.add_argument( - "--repodata", - type=str, - dest="repodata", - default="https://conda.anaconda.org/robostack-staging/", - help="URL to the repodata file", - required=False, - ) - parser.add_argument( - "--upstream", - type=str, - dest="upstream", - default="https://raw.githubusercontent.com/conda-forge/conda-forge-pinning-feedstock/refs/heads/main/recipe/conda_build_config.yaml", - help="URL to the upstream pinnings file", - required=False, - ) - args = parser.parse_args() - - with open(args.vinca, "r") as f: - vinca = YAML().load(f) - - ros_distro = vinca["ros_distro"] - - repodata = get_repodata(args.repodata, args.platform) - packages = repodata["packages"] - - deps = set() - for pkg in packages: - for dep in packages[pkg].get("depends", []): - deps.add(dep.split()[0]) - - local = get_pinnings(args.pinnings) - upstream = get_pinnings(args.upstream) - - common = sorted(deps.intersection(local.keys())) - max_len = max(len(name) for name in common) - print("\033[1m{0:{2}} {1}\033[0m".format("Package", "Versions", max_len)) - - changed = [] - - for name in common: - current = local[name] - latest = upstream[name] - - if current == latest: - if args.all: - print("{0:{2}} {1}".format(name, current, max_len)) - continue - - print("{0:{3}} {1} -> {2}".format(name, current, latest, max_len)) - - local[name] = latest - changed.append(name) - - if not changed: - print("No packages to migrate") - return - - with open(args.pinnings, "w") as f: - yaml = YAML() - yaml.indent(mapping=2, sequence=4, offset=2) - yaml.compact_seq_seq = False - # TODO: check output formatting - yaml.dump(local, f) - - graph = nx.DiGraph() - for pkg in packages: - pkg_name = packages[pkg].get("name") - if not pkg_name.startswith("ros-" + ros_distro): - continue - graph.add_node(pkg_name) - for dep in packages[pkg].get("depends", []): - req = dep.split()[0] - graph.add_edge(pkg_name, req) - - graph = graph.reverse() - distro = Distro(ros_distro) - - rebuild = set() - for pkg in changed: - if pkg not in graph: - continue - for node in nx.dfs_predecessors(graph, pkg): - ros_name = node.removeprefix("ros-" + ros_distro + "-").replace("-", "_") - repo_name = distro.get_released_repo_name(ros_name) - rebuild.add(repo_name) - - vinca["build_number"] += 1 - vinca["full_rebuild"] = False - vinca["packages_select_by_deps"] = list(rebuild) - # TODO: comment/uncomment/add packages to existing list instead of overwriting - - with open(args.vinca, "w") as f: - yaml.dump(vinca, f) - - print("\n\033[1mPackages to rebuild:\033[0m") - for pkg in rebuild: - print(pkg) From 8be026a70950fdb9827e9de86e283931790e2d6a Mon Sep 17 00:00:00 2001 From: Jayden Grubb Date: Thu, 17 Oct 2024 17:54:09 +1000 Subject: [PATCH 6/8] Add --dry-run CLI option --- vinca/migrate.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/vinca/migrate.py b/vinca/migrate.py index ef3a0f0..47993f0 100644 --- a/vinca/migrate.py +++ b/vinca/migrate.py @@ -42,6 +42,13 @@ def main(): help="Path to the vinca configuration file", required=False, ) + parser.add_argument( + "--dry-run", + action="store_true", + dest="dry_run", + help="Show changes without modifying files", + required=False, + ) parser.add_argument( "--repodata", type=str, @@ -100,12 +107,13 @@ def main(): print("No packages to migrate") return - with open(args.pinnings, "w") as f: - yaml = YAML() - yaml.indent(mapping=2, sequence=4, offset=2) - yaml.compact_seq_seq = False - # TODO: check output formatting - yaml.dump(local, f) + if not args.dry_run: + with open(args.pinnings, "w") as f: + yaml = YAML() + yaml.indent(mapping=2, sequence=4, offset=2) + yaml.compact_seq_seq = False + # TODO: check output formatting + yaml.dump(local, f) graph = nx.DiGraph() for pkg in packages: @@ -134,8 +142,9 @@ def main(): vinca["packages_select_by_deps"] = list(rebuild) # TODO: comment/uncomment/add packages to existing list instead of overwriting - with open(args.vinca, "w") as f: - yaml.dump(vinca, f) + if not args.dry_run: + with open(args.vinca, "w") as f: + yaml.dump(vinca, f) print("\n\033[1mPackages to rebuild:\033[0m") for pkg in rebuild: From def6a73264bf64dc543ab365a56229defab58ab7 Mon Sep 17 00:00:00 2001 From: Jayden Grubb Date: Fri, 18 Oct 2024 12:40:36 +1000 Subject: [PATCH 7/8] Add --pinnings-only CLI option --- vinca/migrate.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vinca/migrate.py b/vinca/migrate.py index 47993f0..782c76e 100644 --- a/vinca/migrate.py +++ b/vinca/migrate.py @@ -49,6 +49,13 @@ def main(): help="Show changes without modifying files", required=False, ) + parser.add_argument( + "--pinnings-only", + action="store_true", + dest="pinnings_only", + help="Only update the pinnings file", + required=False, + ) parser.add_argument( "--repodata", type=str, @@ -115,6 +122,9 @@ def main(): # TODO: check output formatting yaml.dump(local, f) + if args.pinnings_only: + return + graph = nx.DiGraph() for pkg in packages: pkg_name = packages[pkg].get("name") From 59e9e712e7917dc381e42b38486fd3a60054a9cd Mon Sep 17 00:00:00 2001 From: Tobias Fischer Date: Wed, 15 Jan 2025 12:02:44 +1000 Subject: [PATCH 8/8] Output into pkg_additional_info.yaml --- vinca/migrate.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/vinca/migrate.py b/vinca/migrate.py index 782c76e..4b7a2f4 100644 --- a/vinca/migrate.py +++ b/vinca/migrate.py @@ -147,14 +147,12 @@ def main(): repo_name = distro.get_released_repo_name(ros_name) rebuild.add(repo_name) - vinca["build_number"] += 1 - vinca["full_rebuild"] = False - vinca["packages_select_by_deps"] = list(rebuild) - # TODO: comment/uncomment/add packages to existing list instead of overwriting + new_build_number = vinca["build_number"] + 1 + yaml_data = {package: {"build_number": new_build_number} for package in list(rebuild)} if not args.dry_run: - with open(args.vinca, "w") as f: - yaml.dump(vinca, f) + with open("pkg_additional_info.yaml", "w") as f: + yaml.dump(yaml_data, f) print("\n\033[1mPackages to rebuild:\033[0m") for pkg in rebuild: