From e63481e89ba9dc309019793ce43d73bd0ca642e6 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: May 14 2024 16:58:50 +0000 Subject: Add a dumb script to create Beta and Final config files We keep screwing this up, so let's not do that any more. Signed-off-by: Adam Williamson --- diff --git a/create-candidate-configs.py b/create-candidate-configs.py new file mode 100755 index 0000000..f45b069 --- /dev/null +++ b/create-candidate-configs.py @@ -0,0 +1,68 @@ +#!/usr/bin/python3 + +import argparse + +parser = argparse.ArgumentParser( + description=( + "Script for generating Fedora Beta and Final Pungi configs." + ) +) +parser.add_argument( + "milestone", + help="The milestone whose config to generate", + choices=("beta", "final"), +) + +parser.add_argument( + "--major", + help="The major release number", + type=int, + default=1 +) + +parser.add_argument( + "--minor", + help="The minor release number", + type=int, + default=1 +) + +args = parser.parse_args() + +with open("fedora.conf", "r", encoding="utf-8") as nightlyfh: + nightly = nightlyfh.read().splitlines() + +out = [] +rel = "" +for line in nightly: + if line.strip().startswith("pkgset_koji_tag"): + # this is useful to know later + rel = line.split("=")[1].strip().replace("'", "") + shortrel = rel.replace("f", "") + line = line.replace(rel, f"{rel}-compose") + if line.strip().startswith("pkgset_koji_inherit"): + line = line.replace("False", "True") + if line.strip().startswith("media_checksum_base_filename"): + if args.milestone == "beta": + line = "media_checksum_base_filename = '%(release_short)s-%(variant)s-%(dirname)s-%(version)s_%(label)s-%(arch)s'" + else: + line = f"media_checksum_base_filename = '%(release_short)s-%(variant)s-%(version)s-{args.major}.{args.minor}-%(arch)s'" + if line.strip().startswith("image_name_format"): + if args.milestone == "beta": + line = "image_name_format = '%(release_short)s-%(variant)s-%(disc_type)s-%(arch)s-%(version)s_%(label)s.iso'" + else: + line = f"image_name_format = '%(release_short)s-%(variant)s-%(disc_type)s-%(arch)s-%(version)s-{args.major}.{args.minor}.iso'" + if line.strip().startswith("global_release"): + line = f"global_release = '{args.major}.{args.minor}'" + if line.strip().startswith("global_version") and args.milestone == "beta": + if not shortrel: + sys.exit("We should've figured out shortrel by now!") + line = line.replace(shortrel, f"{shortrel}_Beta") + if line.strip().startswith("'template_branch'"): + if not rel: + sys.exit("We should've figured out rel by now!") + line = line.replace("main", rel) + out.append(line) + +with open(f"fedora-{args.milestone}.conf", "w", encoding="utf-8") as outfh: + outfh.write("\n".join(out) + "\n")