We keep screwing this up, so let's not do that any more. Signed-off-by: Adam Williamson <awilliam@redhat.com>
68 lines
2.3 KiB
Python
Executable file
68 lines
2.3 KiB
Python
Executable file
#!/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")
|