From 1b614540b80ad562c42b9ed86c3eac1900659fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8D=C3=B1igo=20Huguet?= Date: Fri, 30 Aug 2024 08:32:18 +0200 Subject: [PATCH] distros-info: add option to print all active NM branches Add option --all to distros_support.py to show all the NM versions that are being actively used by any active distro. This will be useful to decide what stable branches are we interested into actively backporting fixes and which ones we're not. --- .gitlab-ci/distros_support.py | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci/distros_support.py b/.gitlab-ci/distros_support.py index 7963440a66..c979acfe10 100755 --- a/.gitlab-ci/distros_support.py +++ b/.gitlab-ci/distros_support.py @@ -44,11 +44,20 @@ def _nm_version_is_newer(nm_ver, nm_ver_from): return False -if len(sys.argv) != 2: - print(f"Usage: {sys.argv[0]} ") +def _print_usage(): + print("Usage: distros_support.py [-a|--all] | ") + print(" -a|--all: print NM versions still active in any distro") + print(" nm_version: print all info and config.yml file of the specified NM version") + + +if len(sys.argv) == 2 and sys.argv[1] in ("-h", "--help", "help"): + _print_usage() + quit() +elif len(sys.argv) > 2: + print("Error: wrong arguments.", file=sys.stderr) + _print_usage() quit(code=1) -nm_version = sys.argv[1] today = datetime.date.today() with open(os.path.dirname(__file__) + "/distros-info.yml") as f: distros_info = yaml.load(f, Loader=yaml.BaseLoader) @@ -67,6 +76,24 @@ for distro, versions in distros_info.items(): file=sys.stderr, ) +# If --all is selected, print all active NM versions and return +if len(sys.argv) < 2 or sys.argv[1] in ("-a", "--all"): + nm_versions = {} + + for distro, versions in distros_info.items(): + for info in versions: + if not _is_supported(info["support"], today): + continue + nm_versions.setdefault(info["nm"], []).append(f"{distro} {info['version']}") + + for nm_ver, distros in sorted(nm_versions.items(), reverse=True): + print("- NM {}: {}".format(nm_ver, ", ".join(distros))) + + quit() + +# Otherwise, print all the info related to the specified NM version +nm_version = sys.argv[1] + # Print distros that uses this nm_version print(f"# List of distros using NM {nm_version}") print("---")