[CI:BUILD] Packit: show SHORT_SHA in podman --version for COPR builds

This change will allow `podman --version` from COPR rpm builds to be of
the form `X.Y.Z-dev-SHORT_SHA`.

Also specify a `copr_build` macro as it feels more intuitive
than `copr_username` or `copr_project`.

[NO NEW TESTS NEEDED]

Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
This commit is contained in:
Lokesh Mandvekar
2023-09-21 14:27:35 -04:00
parent 5a3a9ce9c7
commit e65874903c
2 changed files with 20 additions and 7 deletions

View File

@ -1,7 +1,8 @@
#!/usr/bin/env bash
# This script handles any custom processing of the spec file using the `fix-spec-file`
# action in .packit.yaml.
# action in .packit.yaml. These steps only work on copr builds, not on official
# Fedora builds.
set -eox pipefail
@ -40,8 +41,8 @@ sed -i "s/^Source0:.*.tar.gz/Source0: $PACKAGE-$VERSION.tar.gz/" $SPEC_FILE
# Update setup macro to use the correct build dir
sed -i "s/^%autosetup.*/%autosetup -Sgit -n %{name}-$VERSION/" $SPEC_FILE
# podman --version should show short sha
sed -i "s/^const RawVersion = \"$VERSION\"/const RawVersion = \"$VERSION-$SHORT_SHA\"/" version/rawversion/version.go
# use ParseTolerant to allow short sha in version
sed -i "s/^var Version.*/var Version, err = semver.ParseTolerant(rawversion.RawVersion)/" version/version.go
# Update relevant sed entries in spec file with the actual VERSION and SHORT_SHA
# This allows podman --version to also show the SHORT_SHA along with the
# VERSION
sed -i "s/##VERSION##/$VERSION/" $SPEC_FILE
sed -i "s/##SHORT_SHA##/$SHORT_SHA/" $SPEC_FILE