From b7367e2519b87a6a10d655a187eff1dfb4599c9e Mon Sep 17 00:00:00 2001 From: Lars Karlitski Date: Mon, 16 Nov 2020 13:35:36 +0100 Subject: [PATCH] Makefile: define `commit` on make (s)rpm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prepending the definition to the spec file feels brittle. Stop doing that – pass --define to rpmbuild instead. Keep copying the spec file from git though, so that it's always using the one from the last commit, and not the current checkout. --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b398cdba5..7ad50fcea 100644 --- a/Makefile +++ b/Makefile @@ -206,7 +206,7 @@ RPM_TARBALL=rpmbuild/SOURCES/osbuild-composer-$(COMMIT).tar.gz $(RPM_SPECFILE): mkdir -p $(CURDIR)/rpmbuild/SPECS - (echo "%global commit $(COMMIT)"; git show HEAD:osbuild-composer.spec) > $(RPM_SPECFILE) + git show HEAD:osbuild-composer.spec > $(RPM_SPECFILE) $(RPM_TARBALL): mkdir -p $(CURDIR)/rpmbuild/SOURCES @@ -216,6 +216,7 @@ $(RPM_TARBALL): srpm: $(RPM_SPECFILE) $(RPM_TARBALL) rpmbuild -bs \ --define "_topdir $(CURDIR)/rpmbuild" \ + --define "commit $(COMMIT)" \ --with tests \ $(RPM_SPECFILE) @@ -223,6 +224,7 @@ srpm: $(RPM_SPECFILE) $(RPM_TARBALL) rpm: $(RPM_SPECFILE) $(RPM_TARBALL) rpmbuild -bb \ --define "_topdir $(CURDIR)/rpmbuild" \ + --define "commit $(COMMIT)" \ --with tests \ $(RPM_SPECFILE)