aboutsummaryrefslogtreecommitdiff
path: root/scripts/fedora-kiwi-bundle-format-generator
blob: a03d253d76e9af6e638a106636f6d2b0aba32c74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3

# Simple tool to generate bundle formats for kiwi image builds
# Author: Neal Gompa <ngompa@fedoraproject.org>
# SPDX-3.0-License-Identifier: GPL-3.0-or-later
# SPDX-2.0-License-Identifier: GPL-3.0+

from argparse import ArgumentParser
from pathlib import Path

import xml.etree.ElementTree as ET


parser = ArgumentParser(description="Generator of kiwi bundle formats for Fedora image builds")
parser.add_argument("kiwi_file", type=Path, default="Fedora.kiwi", help="kiwi description file")
parser.add_argument("image_profile", type=str, help="kiwi image profile")
parser.add_argument("--oci-variant", "-o", action="store_true", help="generate oci variant")
args = parser.parse_args()

xml_tree = ET.parse(args.kiwi_file)
image_root = xml_tree.getroot()

image_basename = image_root.attrib["name"]
image_profile = args.image_profile

image_bundle_format = f"{image_basename}-{image_profile}-%v.%I.%A"

if args.oci_variant:
	print(f"{image_bundle_format}.%T")
else:
	print(image_bundle_format)