From 69bde15591a847b3fe846daea5a15aaaa1a80488 Mon Sep 17 00:00:00 2001 From: Francesco Pantano Date: Mar 24 2021 14:52:14 +0000 Subject: Make the Makefile faster on common operations Add pre target that is going to be executed when the remote git repo interaction is needed. Signed-off-by: Francesco Pantano --- diff --git a/Makefile b/Makefile index a1034ac..fff4f05 100644 --- a/Makefile +++ b/Makefile @@ -9,8 +9,6 @@ BRANCH := "octopus" VERSION ?= $(shell cat SPECS/cephadm.spec.in | awk '/Version/ { print $$2}') 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) -# TODO: Make remote hash parametric -REMOTEHASH := $(shell git ls-remote "https://github.com/ceph/ceph" "octopus" | awk '{print $$1}') SPECTOOL :=$(shell which spectool) RPMBUILD :=$(shell which rpmbuild) @@ -18,19 +16,20 @@ NVR := $(NAME)-$(VERSION)-$(RELEASE).$(DIST) all: spec src srpm -pre: +pre: ## Get the last remote hash for the specified branch + $(eval REMOTEHASH := $(shell git ls-remote $(BASE) $(BRANCH) | awk '{print $$1}')) -echo: ## Print the passed (or computed) parameters - echo PWD $(PWD)/SOURCES - echo BASE $(BASE) - echo BRANCH $(BRANCH) - echo CURRENT VERSION $(VERSION) - echo REMOTE HASH $(REMOTEHASH) - echo LOCAL HASH $(LOCALHASH) +echo: pre ## Print the passed (or computed) parameters + @echo PWD $(PWD)/SOURCES + @echo BASE $(BASE) + @echo BRANCH $(BRANCH) + @echo CURRENT VERSION $(VERSION) + @echo REMOTE HASH $(REMOTEHASH) + @echo LOCAL HASH $(LOCALHASH) $(eval RELEASE=$(shell echo $$(($(RELEASE)+1)))) - echo RELEASE $(RELEASE) + @echo RELEASE $(RELEASE) -spec: ## Patch and build the cephadm spec file +spec: pre ## Patch and build the cephadm spec file sed SPECS/cephadm.spec.in \ -e "s/$(LOCALHASH)/$(REMOTEHASH)/" \ -e 's/@VERSION@/$(VERSION)/' \ @@ -38,7 +37,7 @@ spec: ## Patch and build the cephadm spec file > SPECS/cephadm.spec cp SPECS/cephadm.spec SPECS/cephadm.spec.in -src: ## Download the cephadm sources according to the last hash +src: ## Download the cephadm sources according to the last hash $(SPECTOOL) -g SPECS/cephadm.spec -C SOURCES -f srpm: ## Build the srpm