From 9b737c19496ae8c1f380bdd1476861eb9f61064c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Thu, 19 Dec 2024 12:11:22 +0100 Subject: [PATCH] Makefile: use version instead of commit for archive filename MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RPM tooling expects the source tarball to match the name of the package, suffixed with the version in the SPEC file. Modify the Makefile to comply with this expectation. Signed-off-by: Tomáš Hozza --- Makefile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index d3e85ca..b9fb528 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ GOLANGCI_COMPOSER_IMAGE=composer_golangci # VERSION: # This evaluates the `Version` field of the specfile. Therefore, it will # be set to the latest version number of this repository without any -# prefix (just a plain number). +# prefix (just a plan number or a version with dots). # # COMMIT: # This evaluates to the latest git commit sha. This will not work if @@ -47,7 +47,7 @@ GOLANGCI_COMPOSER_IMAGE=composer_golangci # pre-fetched but evaluated at time of use. # -VERSION := $(shell (cd "$(SRCDIR)" && grep "^Version:" image-builder-cli.spec | sed 's/[^[:digit:]]*\([[:digit:]]\+\).*/\1/')) +VERSION := $(shell (cd "$(SRCDIR)" && grep "^Version:" image-builder-cli.spec | sed -n 's/^[^0-9]*\([1-9][0-9]*\(\.[1-9][0-9]*\)*\)/\1/p')) COMMIT = $(shell (cd "$(SRCDIR)" && git rev-parse HEAD)) # @@ -121,7 +121,7 @@ clean: # RPM_SPECFILE=rpmbuild/SPECS/image-builder-cli.spec -RPM_TARBALL=rpmbuild/SOURCES/image-builder-cli-$(COMMIT).tar.gz +RPM_TARBALL=rpmbuild/SOURCES/image-builder-cli-$(VERSION).tar.gz .PHONY: $(RPM_SPECFILE) $(RPM_SPECFILE): @@ -134,11 +134,11 @@ RPM_TARBALL_UNCOMPRESSED=$(RPM_TARBALL:.tar.gz=.tar) $(RPM_TARBALL): $(RPM_SPECFILE) mkdir -p $(CURDIR)/rpmbuild/SOURCES - git archive --prefix=image-builder-cli-$(COMMIT)/ --format=tar.gz HEAD > $(RPM_TARBALL) + git archive --prefix=image-builder-cli-$(VERSION)/ --format=tar.gz HEAD > $(RPM_TARBALL) gunzip -f $(RPM_TARBALL) - tar --delete --owner=0 --group=0 --file $(RPM_TARBALL_UNCOMPRESSED) image-builder-cli-$(COMMIT)/$(notdir $(RPM_SPECFILE)) - tar --append --owner=0 --group=0 --transform "s;^;image-builder-cli-$(COMMIT)/;" --file $(RPM_TARBALL_UNCOMPRESSED) $(RPM_SPECFILE) vendor/ - tar --append --owner=0 --group=0 --transform "s;$(dir $(RPM_SPECFILE));image-builder-cli-$(COMMIT)/;" --file $(RPM_TARBALL_UNCOMPRESSED) $(RPM_SPECFILE) + tar --delete --owner=0 --group=0 --file $(RPM_TARBALL_UNCOMPRESSED) image-builder-cli-$(VERSION)/$(notdir $(RPM_SPECFILE)) + tar --append --owner=0 --group=0 --transform "s;^;image-builder-cli-$(VERSION)/;" --file $(RPM_TARBALL_UNCOMPRESSED) $(RPM_SPECFILE) vendor/ + tar --append --owner=0 --group=0 --transform "s;$(dir $(RPM_SPECFILE));image-builder-cli-$(VERSION)/;" --file $(RPM_TARBALL_UNCOMPRESSED) $(RPM_SPECFILE) gzip $(RPM_TARBALL_UNCOMPRESSED) .PHONY: srpm