Skip to content

Commit

Permalink
spec: Substitute git revision when generating
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cfergeau authored and praveenkumar committed Mar 23, 2023
1 parent 352872e commit f9ae5eb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packaging/rpm/crc.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f9ae5eb

Please sign in to comment.