mirror of
https://github.com/containers/podman.git
synced 2025-05-17 06:59:07 +08:00

Packit's `pre-sync` action allows modification of spec file prior to dist-git PR creation. This is already being done on containers-common rpm to update c/storage and c/image verions tags in spec. This commit will allow `podman version` to show `Git Commit: $SHA` for copr as well as koji builds. Ref: https://raw.githubusercontent.com/containers/common/refs/heads/main/.packit.yaml Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
37 lines
1.2 KiB
Bash
37 lines
1.2 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# This script handles any custom processing of the spec file using the `fix-spec-file`
|
|
# action in .packit.yaml. These steps only work on copr builds, not on official
|
|
# Fedora builds.
|
|
|
|
set -exo pipefail
|
|
|
|
. .packit-rpm-git-commit.sh
|
|
|
|
# Get Version from HEAD
|
|
VERSION=$(grep '^const RawVersion' version/rawversion/version.go | cut -d\" -f2)
|
|
|
|
# RPM Version can't take "-"
|
|
RPM_VERSION=$(echo $VERSION | sed -e 's/-/~/')
|
|
|
|
# Generate source tarball from HEAD
|
|
git-archive-all -C $(git rev-parse --show-toplevel) --prefix=$PACKAGE-$VERSION/ rpm/$PACKAGE-$VERSION.tar.gz
|
|
|
|
# RPM Spec modifications
|
|
|
|
# Use the Version from HEAD in rpm spec
|
|
sed -i "s/^Version:.*/Version: $RPM_VERSION/" $SPEC_FILE
|
|
|
|
# Use Packit's supplied variable in the Release field in rpm spec.
|
|
sed -i "s/^Release:.*/Release: $PACKIT_RPMSPEC_RELEASE%{?dist}/" $SPEC_FILE
|
|
|
|
# Ensure last part of the release string is the git shortcommit without a
|
|
# prepended "g"
|
|
sed -i "/^Release: $PACKIT_RPMSPEC_RELEASE%{?dist}/ s/\(.*\)g/\1/" $SPEC_FILE
|
|
|
|
# Use above generated tarball as Source in rpm spec
|
|
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
|