From 61838924c6e372e01e0a3a2342741454f49285d0 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Fri, 27 Sep 2024 07:53:52 +0200 Subject: [PATCH] New config option `buildconfig.test_version_suffix` If configured like $ cat .tito/tito.props [buildconfig] test_version_suffix = .tito.git The `tito build --test ...` NEVRA is always higher than the NEVRA of released RPMs. Fixes: #460 --- src/tito/builder/main.py | 4 ++++ src/tito/common.py | 9 ++++++++- tito.props.5.asciidoc | 7 +++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/tito/builder/main.py b/src/tito/builder/main.py index b16dbf66..08113419 100644 --- a/src/tito/builder/main.py +++ b/src/tito/builder/main.py @@ -86,6 +86,9 @@ def __init__(self, name=None, build_dir=None, config_fetch_default = self.config.get(BUILDCONFIG_SECTION, "fetch_sources") self.fetch_sources = self._get_optional_arg(kwargs, 'fetch_sources', config_fetch_default) + self.test_version_suffix = self.config.get( + BUILDCONFIG_SECTION, "test_version_suffix", fallback="") + rpmbuildopts = self._get_optional_arg(args, 'rpmbuild_options', None) if rpmbuildopts: self.rpmbuild_options = ' '.join(rpmbuildopts) @@ -642,6 +645,7 @@ def _setup_test_specfile(self): self.commit_count, fullname, self.tgz_filename, + self.test_version_suffix, ) self.build_version += ".git." + str(self.commit_count) + "." + str(sha) diff --git a/src/tito/common.py b/src/tito/common.py index 63e61814..ac15e6aa 100644 --- a/src/tito/common.py +++ b/src/tito/common.py @@ -585,7 +585,8 @@ def replace_spec_release(file_name, release): print(line.rstrip('\n')) -def munge_specfile(spec_file, commit_id, commit_count, fullname=None, tgz_filename=None): +def munge_specfile(spec_file, commit_id, commit_count, fullname=None, + tgz_filename=None, version_suffix=None): # If making a test rpm we need to get a little crazy with the spec # file we're building off. (Note we are modifying a temp copy of the # spec) Swap out the actual release for one that includes the git @@ -604,6 +605,12 @@ def munge_specfile(spec_file, commit_id, commit_count, fullname=None, tgz_filena )) continue + if version_suffix: + m = re.match(r'^(\s*Version:\s*)(.+?)\s*$', line) + if m: + print(m.group(1) + m.group(2) + version_suffix) + continue + m = re.match(r'^(\s*Source0?):\s*(.+?)$', line) if tgz_filename and m: print('%s: %s' % (m.group(1), tgz_filename)) diff --git a/tito.props.5.asciidoc b/tito.props.5.asciidoc index e5c86255..c6226dd6 100644 --- a/tito.props.5.asciidoc +++ b/tito.props.5.asciidoc @@ -98,6 +98,13 @@ fetch_sources:: If true, download sources from predefined Source addresses to the SOURCE folder. +test_version_suffix:: +Append a given suffix (string, e.g., `.post`) to the `Version:` tag in the +generated spec file when building with `--test`. This ensures that any `--test` +NEVRA is higher than the NEVRA of the previous release. Simply modifying the +`Release:` tag doesn't guarantee this, as downstream `Release:` numbers are +often incremented, which would take precedence (e.g., `foo-1.0-1.git.3.60fe05a` +< `foo-1.0-2`). KOJI and COPR -------------