ostree/container: Set version in treefile 'automatic-version-prefix'

In the non container path, we're setting the version for the build using
the `--add-metadata-string=version=XYZ` argument passed to `rpm-ostree
compose tree ...`.

The `rpm-ostree compose image` path does not expose this option yet so
modify the treefile directly as we are already doing it to set the
repos used for the compose.

See: https://github.com/coreos/rpm-ostree/issues/4829
See: https://pagure.io/workstation-ostree-config/pull-request/472
Merges: https://pagure.io/pungi/pull-request/1726
Signed-off-by: Timothée Ravier <tim@siosm.fr>
This commit is contained in:
Timothée Ravier 2024-02-15 18:58:07 +01:00 committed by Lubomír Sedlář
parent 42befba0b1
commit 8412890640
2 changed files with 4 additions and 2 deletions

View File

@ -74,7 +74,7 @@ class Container(OSTree):
repos = [] repos = []
keep_original_sources = True keep_original_sources = True
update_dict = {} update_dict = {"automatic-version-prefix": self.args.version}
self.treefile = tweak_treeconf( self.treefile = tweak_treeconf(
self.treefile, self.treefile,

View File

@ -121,10 +121,11 @@ class OSTreeContainerThread(WorkerThread):
): ):
target_dir = compose.paths.compose.image_dir(variant) % {"arch": arch} target_dir = compose.paths.compose.image_dir(variant) % {"arch": arch}
util.makedirs(target_dir) util.makedirs(target_dir)
version = util.version_generator(compose, config.get("version"))
archive_name = "%s-%s-%s" % ( archive_name = "%s-%s-%s" % (
compose.conf["release_short"], compose.conf["release_short"],
variant.uid, variant.uid,
util.version_generator(compose, config.get("version")), version,
) )
# Run the pungi-make-ostree command locally to create a script to # Run the pungi-make-ostree command locally to create a script to
@ -137,6 +138,7 @@ class OSTreeContainerThread(WorkerThread):
"--path=%s" % target_dir, "--path=%s" % target_dir,
"--treefile=%s" % os.path.join(config_repo, config["treefile"]), "--treefile=%s" % os.path.join(config_repo, config["treefile"]),
"--extra-config=%s" % extra_config_file, "--extra-config=%s" % extra_config_file,
"--version=%s" % version,
] ]
_, runroot_script = shortcuts.run(cmd, universal_newlines=True) _, runroot_script = shortcuts.run(cmd, universal_newlines=True)