diff --git a/Makefile b/Makefile index 793954d..a4ed1a5 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ NAME = cephadm DIST ?= el8 BASE := "https://github.com/ceph/ceph" BRANCH := $(shell git rev-parse --abbrev-ref HEAD | cut -d'-' -f5) -VERSION ?= $(shell cat SPECS/cephadm.spec.in | awk '/Version/ { print $$2}') +LAST_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) SPECTOOL :=$(shell which spectool) @@ -18,12 +18,14 @@ 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 @echo PWD $(PWD)/SOURCES @echo BASE $(BASE) @echo BRANCH $(BRANCH) - @echo CURRENT VERSION $(VERSION) + @echo CURRENT VERSION $(LAST_VERSION) @echo REMOTE HASH $(REMOTEHASH) @echo LOCAL HASH $(LOCALHASH) $(eval RELEASE=$(shell echo $$(($(RELEASE)+1)))) @@ -32,8 +34,8 @@ echo: pre ## Print the passed (or computed) parameters spec: pre ## Patch and build the cephadm spec file sed SPECS/cephadm.spec.in \ -e "s/$(LOCALHASH)/$(REMOTEHASH)/" \ - -e 's/@VERSION@/$(VERSION)/' \ - -e 's/@RELEASE@/$(RELEASE)/' \ + -e 's/Version: $(LAST_VERSION)/Version: $(VERSION)/' \ + -e 's/Release: $(LAST_RELEASE)/Release: $(RELEASE)/' \ > SPECS/cephadm.spec cp SPECS/cephadm.spec SPECS/cephadm.spec.in diff --git a/README.md b/README.md index 014b241..ddb541d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +# About building cephadm + This is a dist-git like repo for cephadm The master brach is unused: use an existing branch instead. @@ -49,3 +51,86 @@ and finally we can build it running: $ cbs build [--scratch] storage8-ceph-octopus-el8 cephadm.el8.src.rpm ``` +## Build cephadm using the Makefile + +A Makefile is provided with the purpose of automating the steps described before. +It provides an helper function and can be used to build the srpm, as well as obtaining +additional information on the current build. +The act of running the 'cbs build' command is not automated on the Makefile since it's out +of scope: feel free to refer to the last step of the previous section to run the cbs build +after the Makefile execution ends. + +### Executing the Makefile without parameters + +If no parameters are provided, the Makefile computes the branch name, the version +and the release from the current spec file. +The Release field is increased by 1 but the version remains the same: this is because +we're building the package against a newer hash instead of bumping the cephadm version +according to the provided tags (the ceph-ansible approach). + +If you want to produce a new srpm for an existing cephadm version, just run: + +``` +make +``` + +and you will see an output like this: + +``` +[fmount@buildbot cephadm]$ make +sed SPECS/cephadm.spec.in \ + -e "s/89ceb19fd8609fd4c99d10dd63f42e6786e37c86/dcf77bd9ff89dfef682c4a2dda05ac5c8651dbe5/" \ + -e 's/@VERSION@/15.2.10/' \ + -e 's/@RELEASE@/2/' \ + > SPECS/cephadm.spec +cp SPECS/cephadm.spec SPECS/cephadm.spec.in +/usr/bin/spectool -g SPECS/cephadm.spec -C SOURCES -f +Getting https://github.com/ceph/ceph/raw/dcf77bd9ff89dfef682c4a2dda05ac5c8651dbe5/src/cephadm/cephadm to SOURCES/cephadm + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed +100 170 100 170 0 0 32 0 0:00:05 0:00:05 --:--:-- 40 +100 214k 100 214k 0 0 20886 0 0:00:10 0:00:10 --:--:-- 47630 +rpmbuild -bs /home/fmount/cephadm/SPECS/cephadm.spec \ + --define "_sourcedir /home/fmount/cephadm/SOURCES" \ + --define "_srcrpmdir /home/fmount/cephadm" \ + --define "dist .el8" +Wrote: /home/fmount/cephadm/cephadm-15.2.10-2.el8.src.rpm +``` + +In addition, a cephadm.spec file is generated from the input `SPECS/cephadm.spec.in` and it can be +found under the SPECS directory. + +At the end of this process, as described in the previous section, you can run the cbs build: + +``` + $ cbs build [--scratch] storage8-ceph-octopus-el8 cephadm-15.2.10-2.el8.src.rpm +``` + + +### Executing the Makefile overriding some input parameters + +If you want to bump to a newer released version, the hash computation remains unchanged, +but you might want to patch the spec input file properly. +For this reason a few parameters, exposed via the `cephadm.spec.in` file can be overrided: + +* RELEASE +* DIST = el8 by default +* VERSION + +For instance, assuming we have the following data in the current spec: + +[fmount@buildbot cephadm]$ cat SPECS/cephadm.spec | grep -iE "(Release|Version)" +Version: 15.2.10 +Release: 2%{?dist} + +you can patch (and bump to a newer NVR) the current (existing) spec file by running: + +``` +DIST=el8 RELEASE=1 VERSION=15.2.11 make +``` + +Then, running the regular cbs build command a new cephadm rpm can be built: + +``` + $ cbs build [--scratch] storage8-ceph-octopus-el8 cephadm-15.2.10-2.el8.src.rpm +```