From 55029fd0dcdbc5c594ca28a611b8304ac9a3bf24 Mon Sep 17 00:00:00 2001 From: Francesco Pantano Date: Mar 24 2021 20:03:48 +0000 Subject: Properly compute Release and Version When Release is not specified, we should increase the current value by 1. However, if that value is provided, we should get rid of what is found in the current spec. Same thing can be applied to the version field, except for the fact we don't increase that value (or at least, the logic of increasing it is unknown for now). Signed-off-by: Francesco Pantano --- diff --git a/Makefile b/Makefile index a4ed1a5..53e01eb 100644 --- a/Makefile +++ b/Makefile @@ -7,10 +7,12 @@ DIST ?= el8 BASE := "https://github.com/ceph/ceph" BRANCH := $(shell git rev-parse --abbrev-ref HEAD | cut -d'-' -f5) LAST_VERSION ?= $(shell cat SPECS/cephadm.spec.in | awk '/Version/ { print $$2}') +LAST_RELEASE ?= $(shell cat SPECS/cephadm.spec.in | awk '/Release/ {print $$2}' | cut -d'%' -f1) LOCALHASH := $(shell cat SPECS/cephadm.spec.in | awk '/Source0/ { print $$2}' | cut -d'/' -f7) -RELEASE ?= $(shell cat SPECS/cephadm.spec.in | awk '/Release/ {print $$2}' | cut -d'%' -f1) SPECTOOL :=$(shell which spectool) RPMBUILD :=$(shell which rpmbuild) +RELEASE := $(if $(RELEASE),$(RELEASE),$(LAST_RELEASE)) +VERSION := $(if $(VERSION),$(VERSION),$(LAST_VERSION)) NVR := $(NAME)-$(VERSION)-$(RELEASE).$(DIST) @@ -18,7 +20,6 @@ all: spec src srpm pre: ## Get the last remote hash for the specified branch $(eval REMOTEHASH := $(shell git ls-remote $(BASE) $(BRANCH) | awk '{print $$1}')) - $(eval LAST_RELEASE ?= $(shell cat SPECS/cephadm.spec.in | awk '/Release/ {print $$2}' | cut -d'%' -f1)) $(eval RELEASE=$(shell echo $$(($(RELEASE)+1)))) echo: pre ## Print the passed (or computed) parameters @@ -26,9 +27,9 @@ echo: pre ## Print the passed (or computed) parameters @echo BASE $(BASE) @echo BRANCH $(BRANCH) @echo CURRENT VERSION $(LAST_VERSION) + @echo NEXT VERSION $(VERSION) @echo REMOTE HASH $(REMOTEHASH) @echo LOCAL HASH $(LOCALHASH) - $(eval RELEASE=$(shell echo $$(($(RELEASE)+1)))) @echo RELEASE $(RELEASE) spec: pre ## Patch and build the cephadm spec file @@ -49,7 +50,7 @@ srpm: ## Build the srpm --define "dist .$(DIST)" clean: ## Clean the workdir - rm -f $(NVR).src.rpm + rm -f *.src.rpm rm -f SPECS/cephadm.spec help: ## Print the Help