diff --git a/.packit.sh b/.packit.sh index 4791f9f272..7eb5aa002c 100644 --- a/.packit.sh +++ b/.packit.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash # This script handles any custom processing of the spec file using the `fix-spec-file` -# action in .packit.yaml. +# action in .packit.yaml. These steps only work on copr builds, not on official +# Fedora builds. set -eox pipefail @@ -40,8 +41,8 @@ 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 -# podman --version should show short sha -sed -i "s/^const RawVersion = \"$VERSION\"/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 +# 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 diff --git a/rpm/podman.spec b/rpm/podman.spec index b95e3a51cc..583aa0d55d 100644 --- a/rpm/podman.spec +++ b/rpm/podman.spec @@ -31,6 +31,10 @@ %define build_with_btrfs 1 %endif +%if %{defined copr_username} +%define copr_build 1 +%endif + %global container_base_path github.com/containers %global container_base_url https://%{container_base_path} @@ -48,7 +52,7 @@ %global import_path_plugins %{container_base_path}/%{repo_plugins} Name: podman -%if %{defined copr_username} +%if %{defined copr_build} Epoch: 102 %else Epoch: 5 @@ -203,6 +207,14 @@ when `%{_bindir}/%{name}sh` is set as a login shell or set as os.Args[0]. %autosetup -Sgit -n %{name}-%{version} sed -i 's;@@PODMAN@@\;$(BINDIR);@@PODMAN@@\;%{_bindir};' Makefile +# 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 + # untar dnsname tar zxf %{SOURCE1}