Skip to content

Commit

Permalink
Merge pull request #25360 from lsm5/packit-copr-rpm-changes
Browse files Browse the repository at this point in the history
[skip-ci] Packit/Copr: Fix `podman version` in rpm
  • Loading branch information
openshift-merge-bot[bot] authored Feb 19, 2025
2 parents 3ab0d82 + 7536620 commit 61e88e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
9 changes: 3 additions & 6 deletions .packit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ PACKAGE=podman
SPEC_FILE=rpm/$PACKAGE.spec

# Get short sha
SHORT_SHA=$(git rev-parse --short HEAD)
GIT_COMMIT=$(git rev-parse HEAD)

# Get Version from HEAD
VERSION=$(grep '^const RawVersion' version/rawversion/version.go | cut -d\" -f2)
Expand Down Expand Up @@ -41,8 +41,5 @@ 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

# 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
# Update LDFLAGS to show commit id for Copr builds
sed -i "s/##GIT_COMMIT##/$GIT_COMMIT/" $SPEC_FILE
15 changes: 7 additions & 8 deletions rpm/podman.spec
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,6 @@ sed -i 's;@@PODMAN@@\;$(BINDIR);@@PODMAN@@\;%{_bindir};' Makefile
sed -i '/DELETE ON RHEL9/,/DELETE ON RHEL9/d' libpod/runtime.go
%endif

# These changes are only meant for copr builds
%if %{defined copr_build}
# podman --version should show short sha
sed -i "s/^const RawVersion = .*/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
%endif

%build
%set_build_flags
export CGO_CFLAGS=$CFLAGS
Expand All @@ -245,6 +237,13 @@ LDFLAGS="-X %{ld_libpod}/define.buildInfo=${SOURCE_DATE_EPOCH:-$(date +%s)} \
-X %{ld_libpod}/config._etcDir=%{_sysconfdir} \
-X %{ld_project}/pkg/systemd/quadlet._binDir=%{_bindir}"

%if %{defined copr_build}
# ##GIT_COMMIT## is set by `.packit.sh` in Packit's Copr RPM build jobs.
# Has no effect on Koji builds.
GIT_COMMIT="##GIT_COMMIT##"
LDFLAGS="$LDFLAGS -X %{ld_libpod}/define.gitCommit=$GIT_COMMIT"
%endif

# build rootlessport first
%gobuild -o bin/rootlessport ./cmd/rootlessport

Expand Down

0 comments on commit 61e88e4

Please sign in to comment.