Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[skip-ci] Packit/RPM: Display upstream commit SHA in all rpm builds #25445

Merged
merged 1 commit into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions .packit.sh → .packit-copr-rpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@
# action in .packit.yaml. These steps only work on copr builds, not on official
# Fedora builds.

set -eox pipefail
set -exo pipefail

PACKAGE=podman

# Set path to rpm spec file
SPEC_FILE=rpm/$PACKAGE.spec

# Get short sha
GIT_COMMIT=$(git rev-parse HEAD)
. .packit-rpm-git-commit.sh

# Get Version from HEAD
VERSION=$(grep '^const RawVersion' version/rawversion/version.go | cut -d\" -f2)
Expand Down Expand Up @@ -40,6 +34,3 @@ 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 LDFLAGS to show commit id for Copr builds
sed -i "s/##GIT_COMMIT##/$GIT_COMMIT/" $SPEC_FILE
17 changes: 17 additions & 0 deletions .packit-rpm-git-commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

# Updates the rpm spec with the upstream git SHA. Works for both copr and koji
# builds via Packit actions. See .packit.yaml for usage.

set -exo pipefail

PACKAGE=podman

# Set path to rpm spec file
SPEC_FILE=rpm/$PACKAGE.spec

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

# Update LDFLAGS to show commit id for Copr builds
sed -i "s/^GIT_COMMIT=*/GIT_COMMIT=\"$GIT_COMMIT\"/" $SPEC_FILE
4 changes: 2 additions & 2 deletions .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ srpm_build_deps:
- make

actions:
fix-spec-file:
- "bash .packit.sh"
fix-spec-file: "bash .packit-copr-rpm.sh"
pre-sync: "bash .packit-rpm-git-commit.sh"

jobs:
- job: copr_build
Expand Down
8 changes: 3 additions & 5 deletions rpm/podman.spec
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,10 @@ 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##"
# This variable will be set by Packit actions. See .packit.yaml in the root dir
# of the repo (upstream as well as Fedora dist-git).
GIT_COMMIT=""
LDFLAGS="$LDFLAGS -X %{ld_libpod}/define.gitCommit=$GIT_COMMIT"
%endif

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