From f9ae5eb7605f418fd525a8430a2fa2c6735c08fd Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Tue, 19 Jul 2022 16:26:45 +0200 Subject: [PATCH] spec: Substitute git revision when generating When doing a build from the spec file, 'git rev-parse HEAD' is unlikely to correspond to a hash from github.com/code-ready/crc. It will most likely be a hash from dist-git, or from a git repository created at build time by `%autosetup -S git` This commit allows to use 'make COMMIT_SHA=xxxx' to override the one used at build time, to ensure the sha we use in release-info.json or in "crc version" is something useful. --- Makefile | 3 ++- packaging/rpm/crc.spec.in | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 004675eb19..d02bbd2162 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ OKD_VERSION ?= 4.12.0-0.okd-2023-02-18-033438 MICROSHIFT_VERSION ?= 4.12.5 BUNDLE_EXTENSION = crcbundle CRC_VERSION = 2.15.0 -COMMIT_SHA=$(shell git rev-parse --short HEAD) +COMMIT_SHA?=$(shell git rev-parse --short HEAD) MACOS_INSTALL_PATH = /usr/local/crc CONTAINER_RUNTIME ?= podman @@ -359,6 +359,7 @@ $(BUILD_DIR)/macos-universal/crc-macos-installer.tar: packagedir -e '/__BUNDLED_PROVIDES__/d' \ -e 's/__VERSION__/'$(CRC_VERSION)'/g' \ -e 's/__OPENSHIFT_VERSION__/'$(OPENSHIFT_VERSION)'/g' \ + -e 's/__COMMIT_SHA__/'$(COMMIT_SHA)'/g' \ $< >$@ %: %.in diff --git a/packaging/rpm/crc.spec.in b/packaging/rpm/crc.spec.in index 0c990721b2..dfc41bd805 100644 --- a/packaging/rpm/crc.spec.in +++ b/packaging/rpm/crc.spec.in @@ -60,7 +60,7 @@ export GOFLAGS="-mod=vendor" mkdir embed-files cp /usr/bin/crc-driver-libvirt embed-files cp /usr/bin/crc-admin-helper embed-files/crc-admin-helper-linux -make GO_EXTRA_LDFLAGS="-B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n')" GO_EXTRA_BUILDFLAGS="" CUSTOM_EMBED=true EMBED_DOWNLOAD_DIR=embed-files/ release +make COMMIT_SHA=__COMMIT_SHA__ GO_EXTRA_LDFLAGS="-B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n')" GO_EXTRA_BUILDFLAGS="" CUSTOM_EMBED=true EMBED_DOWNLOAD_DIR=embed-files/ release %install # with fedora macros: gopkginstall