mirror of
https://github.com/containers/podman.git
synced 2025-10-27 03:06:22 +08:00
[CI:BUILD] Packit: show SHORT_SHA in podman --version for COPR builds
This change will allow `podman --version` from COPR rpm builds to be of the form `X.Y.Z-dev-SHORT_SHA`. Also specify a `copr_build` macro as it feels more intuitive than `copr_username` or `copr_project`. [NO NEW TESTS NEEDED] Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
This commit is contained in:
13
.packit.sh
13
.packit.sh
@ -1,7 +1,8 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# This script handles any custom processing of the spec file using the `fix-spec-file`
|
# 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
|
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
|
# Update setup macro to use the correct build dir
|
||||||
sed -i "s/^%autosetup.*/%autosetup -Sgit -n %{name}-$VERSION/" $SPEC_FILE
|
sed -i "s/^%autosetup.*/%autosetup -Sgit -n %{name}-$VERSION/" $SPEC_FILE
|
||||||
|
|
||||||
# podman --version should show short sha
|
# Update relevant sed entries in spec file with the actual VERSION and SHORT_SHA
|
||||||
sed -i "s/^const RawVersion = \"$VERSION\"/const RawVersion = \"$VERSION-$SHORT_SHA\"/" version/rawversion/version.go
|
# This allows podman --version to also show the SHORT_SHA along with the
|
||||||
|
# VERSION
|
||||||
# use ParseTolerant to allow short sha in version
|
sed -i "s/##VERSION##/$VERSION/" $SPEC_FILE
|
||||||
sed -i "s/^var Version.*/var Version, err = semver.ParseTolerant(rawversion.RawVersion)/" version/version.go
|
sed -i "s/##SHORT_SHA##/$SHORT_SHA/" $SPEC_FILE
|
||||||
|
|||||||
@ -31,6 +31,10 @@
|
|||||||
%define build_with_btrfs 1
|
%define build_with_btrfs 1
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
|
%if %{defined copr_username}
|
||||||
|
%define copr_build 1
|
||||||
|
%endif
|
||||||
|
|
||||||
%global container_base_path github.com/containers
|
%global container_base_path github.com/containers
|
||||||
%global container_base_url https://%{container_base_path}
|
%global container_base_url https://%{container_base_path}
|
||||||
|
|
||||||
@ -48,7 +52,7 @@
|
|||||||
%global import_path_plugins %{container_base_path}/%{repo_plugins}
|
%global import_path_plugins %{container_base_path}/%{repo_plugins}
|
||||||
|
|
||||||
Name: podman
|
Name: podman
|
||||||
%if %{defined copr_username}
|
%if %{defined copr_build}
|
||||||
Epoch: 102
|
Epoch: 102
|
||||||
%else
|
%else
|
||||||
Epoch: 5
|
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}
|
%autosetup -Sgit -n %{name}-%{version}
|
||||||
sed -i 's;@@PODMAN@@\;$(BINDIR);@@PODMAN@@\;%{_bindir};' Makefile
|
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
|
# untar dnsname
|
||||||
tar zxf %{SOURCE1}
|
tar zxf %{SOURCE1}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user