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.
This commit is contained in:
Íñigo Huguet
2024-08-30 08:32:18 +02:00
committed by Íñigo Huguet
parent 8be5aae5b9
commit 1b614540b8

View File

@@ -44,11 +44,20 @@ def _nm_version_is_newer(nm_ver, nm_ver_from):
return False return False
if len(sys.argv) != 2: def _print_usage():
print(f"Usage: {sys.argv[0]} <nm_version>") print("Usage: distros_support.py [-a|--all] | <nm_version>")
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) quit(code=1)
nm_version = sys.argv[1]
today = datetime.date.today() today = datetime.date.today()
with open(os.path.dirname(__file__) + "/distros-info.yml") as f: with open(os.path.dirname(__file__) + "/distros-info.yml") as f:
distros_info = yaml.load(f, Loader=yaml.BaseLoader) distros_info = yaml.load(f, Loader=yaml.BaseLoader)
@@ -67,6 +76,24 @@ for distro, versions in distros_info.items():
file=sys.stderr, 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 distros that uses this nm_version
print(f"# List of distros using NM {nm_version}") print(f"# List of distros using NM {nm_version}")
print("---") print("---")