|
|
84c41e |
# Makefile for constructing RPMs.
|
|
|
84c41e |
|
|
|
84c41e |
SHELL := bash
|
|
|
84c41e |
.SHELLFLAGS := -eu -o pipefail -c
|
|
|
84c41e |
NAME = cephadm
|
|
|
84c41e |
DIST ?= el8
|
|
|
84c41e |
BASE := "https://github.com/ceph/ceph"
|
|
|
abf846 |
BRANCH := $(shell git rev-parse --abbrev-ref HEAD | cut -d'-' -f5)
|
|
|
e26092 |
LAST_VERSION ?= $(shell cat SPECS/cephadm.spec.in | awk '/Version/ { print $$2}')
|
|
|
55029f |
LAST_RELEASE ?= $(shell cat SPECS/cephadm.spec.in | awk '/Release/ {print $$2}' | cut -d'%' -f1)
|
|
|
84c41e |
LOCALHASH := $(shell cat SPECS/cephadm.spec.in | awk '/Source0/ { print $$2}' | cut -d'/' -f7)
|
|
|
84c41e |
SPECTOOL :=$(shell which spectool)
|
|
|
84c41e |
RPMBUILD :=$(shell which rpmbuild)
|
|
|
55029f |
RELEASE := $(if $(RELEASE),$(RELEASE),$(LAST_RELEASE))
|
|
|
55029f |
VERSION := $(if $(VERSION),$(VERSION),$(LAST_VERSION))
|
|
|
84c41e |
|
|
|
84c41e |
|
|
|
84c41e |
all: spec src srpm
|
|
|
84c41e |
|
|
|
69bde1 |
pre: ## Get the last remote hash for the specified branch
|
|
|
69bde1 |
$(eval REMOTEHASH := $(shell git ls-remote $(BASE) $(BRANCH) | awk '{print $$1}'))
|
|
|
e26092 |
$(eval RELEASE=$(shell echo $$(($(RELEASE)+1))))
|
|
|
89c139 |
$(eval NVR=$(shell echo $(NAME)-$(VERSION)-$(RELEASE).$(DIST)))
|
|
|
84c41e |
|
|
|
69bde1 |
echo: pre ## Print the passed (or computed) parameters
|
|
|
69bde1 |
@echo PWD $(PWD)/SOURCES
|
|
|
69bde1 |
@echo BASE $(BASE)
|
|
|
69bde1 |
@echo BRANCH $(BRANCH)
|
|
|
e26092 |
@echo CURRENT VERSION $(LAST_VERSION)
|
|
|
55029f |
@echo NEXT VERSION $(VERSION)
|
|
|
69bde1 |
@echo REMOTE HASH $(REMOTEHASH)
|
|
|
69bde1 |
@echo LOCAL HASH $(LOCALHASH)
|
|
|
69bde1 |
@echo RELEASE $(RELEASE)
|
|
|
84c41e |
|
|
|
69bde1 |
spec: pre ## Patch and build the cephadm spec file
|
|
|
84c41e |
sed SPECS/cephadm.spec.in \
|
|
|
84c41e |
-e "s/$(LOCALHASH)/$(REMOTEHASH)/" \
|
|
|
e26092 |
-e 's/Version: $(LAST_VERSION)/Version: $(VERSION)/' \
|
|
|
e26092 |
-e 's/Release: $(LAST_RELEASE)/Release: $(RELEASE)/' \
|
|
|
84c41e |
> SPECS/cephadm.spec
|
|
|
84c41e |
cp SPECS/cephadm.spec SPECS/cephadm.spec.in
|
|
|
84c41e |
|
|
|
69bde1 |
src: ## Download the cephadm sources according to the last hash
|
|
|
84c41e |
$(SPECTOOL) -g SPECS/cephadm.spec -C SOURCES -f
|
|
|
84c41e |
|
|
|
84c41e |
srpm: ## Build the srpm
|
|
|
484e3e |
$(RPMBUILD) -bs $(PWD)/SPECS/cephadm.spec \
|
|
|
84c41e |
--define "_sourcedir $(PWD)/SOURCES" \
|
|
|
84c41e |
--define "_srcrpmdir $(PWD)" \
|
|
|
84c41e |
--define "dist .$(DIST)"
|
|
|
89c139 |
mv $(NVR).src.rpm $(PWD)/SRPMS/
|
|
|
84c41e |
|
|
|
84c41e |
clean: ## Clean the workdir
|
|
|
55029f |
rm -f *.src.rpm
|
|
|
89c139 |
rm -f SRPMS/*.src.rpm
|
|
|
84c41e |
rm -f SPECS/cephadm.spec
|
|
|
84c41e |
|
|
|
84c41e |
help: ## Print the Help
|
|
|
84c41e |
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
|
|
84c41e |
|
|
|
84c41e |
.PHONY: all
|