#1276 Add a dumb script to create Beta and Final config files
Opened a month ago by adamwill. Modified 13 days ago
adamwill/pungi-fedora script-candidate-config-creation  into  main

@@ -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")

We keep screwing this up, so let's not do that any more.

Signed-off-by: Adam Williamson awilliam@redhat.com

rebased onto 4d848a05193f952d6598692e03f6506d16ca081f

a month ago

obviously this unconditionally regenerates both files when run, and fudges the respin number a bit. I can add more sophisticated choices there if it'd be helpful.

rebased onto b2512ead8358f1c09ed871966b287ba70bf81a4f

a month ago

rebased onto e455ecc

a month ago

eh, okay, I just did it: added a mandatory arg to specify the milestone to generate (beta or final) and optional args for the major and minor versions for the label. you can run e.g. ./create-candidate-configs.py --minor=13 final

I'm good to merge this.

We should also update the docs to use it.

Metadata