Skip to content

Commit 61e88e4

Browse files
Merge pull request #25360 from lsm5/packit-copr-rpm-changes
[skip-ci] Packit/Copr: Fix `podman version` in rpm
2 parents 3ab0d82 + 7536620 commit 61e88e4

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

.packit.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ PACKAGE=podman
1212
SPEC_FILE=rpm/$PACKAGE.spec
1313

1414
# Get short sha
15-
SHORT_SHA=$(git rev-parse --short HEAD)
15+
GIT_COMMIT=$(git rev-parse HEAD)
1616

1717
# Get Version from HEAD
1818
VERSION=$(grep '^const RawVersion' version/rawversion/version.go | cut -d\" -f2)
@@ -41,8 +41,5 @@ sed -i "s/^Source0:.*.tar.gz/Source0: $PACKAGE-$VERSION.tar.gz/" $SPEC_FILE
4141
# Update setup macro to use the correct build dir
4242
sed -i "s/^%autosetup.*/%autosetup -Sgit -n %{name}-$VERSION/" $SPEC_FILE
4343

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
44+
# Update LDFLAGS to show commit id for Copr builds
45+
sed -i "s/##GIT_COMMIT##/$GIT_COMMIT/" $SPEC_FILE

rpm/podman.spec

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,6 @@ sed -i 's;@@PODMAN@@\;$(BINDIR);@@PODMAN@@\;%{_bindir};' Makefile
216216
sed -i '/DELETE ON RHEL9/,/DELETE ON RHEL9/d' libpod/runtime.go
217217
%endif
218218

219-
# These changes are only meant for copr builds
220-
%if %{defined copr_build}
221-
# podman --version should show short sha
222-
sed -i "s/^const RawVersion = .*/const RawVersion = \"##VERSION##-##SHORT_SHA##\"/" version/rawversion/version.go
223-
# use ParseTolerant to allow short sha in version
224-
sed -i "s/^var Version.*/var Version, err = semver.ParseTolerant(rawversion.RawVersion)/" version/version.go
225-
%endif
226-
227219
%build
228220
%set_build_flags
229221
export CGO_CFLAGS=$CFLAGS
@@ -245,6 +237,13 @@ LDFLAGS="-X %{ld_libpod}/define.buildInfo=${SOURCE_DATE_EPOCH:-$(date +%s)} \
245237
-X %{ld_libpod}/config._etcDir=%{_sysconfdir} \
246238
-X %{ld_project}/pkg/systemd/quadlet._binDir=%{_bindir}"
247239

240+
%if %{defined copr_build}
241+
# ##GIT_COMMIT## is set by `.packit.sh` in Packit's Copr RPM build jobs.
242+
# Has no effect on Koji builds.
243+
GIT_COMMIT="##GIT_COMMIT##"
244+
LDFLAGS="$LDFLAGS -X %{ld_libpod}/define.gitCommit=$GIT_COMMIT"
245+
%endif
246+
248247
# build rootlessport first
249248
%gobuild -o bin/rootlessport ./cmd/rootlessport
250249

0 commit comments

Comments
 (0)