Skip to content

Commit e658749

Browse files
committed
[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 <[email protected]>
1 parent 5a3a9ce commit e658749

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

.packit.sh

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/usr/bin/env bash
22

33
# This script handles any custom processing of the spec file using the `fix-spec-file`
4-
# action in .packit.yaml.
4+
# action in .packit.yaml. These steps only work on copr builds, not on official
5+
# Fedora builds.
56

67
set -eox pipefail
78

@@ -40,8 +41,8 @@ sed -i "s/^Source0:.*.tar.gz/Source0: $PACKAGE-$VERSION.tar.gz/" $SPEC_FILE
4041
# Update setup macro to use the correct build dir
4142
sed -i "s/^%autosetup.*/%autosetup -Sgit -n %{name}-$VERSION/" $SPEC_FILE
4243

43-
# podman --version should show short sha
44-
sed -i "s/^const RawVersion = \"$VERSION\"/const RawVersion = \"$VERSION-$SHORT_SHA\"/" version/rawversion/version.go
45-
46-
# use ParseTolerant to allow short sha in version
47-
sed -i "s/^var Version.*/var Version, err = semver.ParseTolerant(rawversion.RawVersion)/" version/version.go
44+
# Update relevant sed entries in spec file with the actual VERSION and SHORT_SHA
45+
# This allows podman --version to also show the SHORT_SHA along with the
46+
# VERSION
47+
sed -i "s/##VERSION##/$VERSION/" $SPEC_FILE
48+
sed -i "s/##SHORT_SHA##/$SHORT_SHA/" $SPEC_FILE

rpm/podman.spec

+13-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
%define build_with_btrfs 1
3232
%endif
3333

34+
%if %{defined copr_username}
35+
%define copr_build 1
36+
%endif
37+
3438
%global container_base_path github.com/containers
3539
%global container_base_url https://%{container_base_path}
3640

@@ -48,7 +52,7 @@
4852
%global import_path_plugins %{container_base_path}/%{repo_plugins}
4953

5054
Name: podman
51-
%if %{defined copr_username}
55+
%if %{defined copr_build}
5256
Epoch: 102
5357
%else
5458
Epoch: 5
@@ -203,6 +207,14 @@ when `%{_bindir}/%{name}sh` is set as a login shell or set as os.Args[0].
203207
%autosetup -Sgit -n %{name}-%{version}
204208
sed -i 's;@@PODMAN@@\;$(BINDIR);@@PODMAN@@\;%{_bindir};' Makefile
205209

210+
# These changes are only meant for copr builds
211+
%if %{defined copr_build}
212+
# podman --version should show short sha
213+
sed -i "s/^const RawVersion = .*/const RawVersion = \"##VERSION##-##SHORT_SHA##\"/" version/rawversion/version.go
214+
# use ParseTolerant to allow short sha in version
215+
sed -i "s/^var Version.*/var Version, err = semver.ParseTolerant(rawversion.RawVersion)/" version/version.go
216+
%endif
217+
206218
# untar dnsname
207219
tar zxf %{SOURCE1}
208220

0 commit comments

Comments
 (0)