From 23b01e58a769cb4fc0d255c5ff924b5cefe00ca4 Mon Sep 17 00:00:00 2001 From: Francesco Pantano Date: Mar 25 2021 08:30:49 +0000 Subject: Moving the Makefile, Readme and cephadm.spec.in to the -pacific branch This is a first import of the octopus branch to the pacific one, except for the cephadm.spec.in which contains the pacific snapshot. Signed-off-by: Francesco Pantano --- diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2230376 --- /dev/null +++ b/Makefile @@ -0,0 +1,59 @@ +# Makefile for constructing RPMs. + +SHELL := bash +.SHELLFLAGS := -eu -o pipefail -c +NAME = cephadm +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) +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) + +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 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 $(LAST_VERSION) + @echo NEXT VERSION $(VERSION) + @echo REMOTE HASH $(REMOTEHASH) + @echo LOCAL HASH $(LOCALHASH) + @echo RELEASE $(RELEASE) + +spec: pre ## Patch and build the cephadm spec file + sed SPECS/cephadm.spec.in \ + -e "s/$(LOCALHASH)/$(REMOTEHASH)/" \ + -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 + +src: ## Download the cephadm sources according to the last hash + $(SPECTOOL) -g SPECS/cephadm.spec -C SOURCES -f + +srpm: ## Build the srpm + $(RPMBUILD) -bs $(PWD)/SPECS/cephadm.spec \ + --define "_sourcedir $(PWD)/SOURCES" \ + --define "_srcrpmdir $(PWD)" \ + --define "dist .$(DIST)" + +clean: ## Clean the workdir + rm -f *.src.rpm + rm -f SPECS/cephadm.spec + +help: ## Print the Help + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +.PHONY: all diff --git a/README.md b/README.md index 2bca2f6..fa49c37 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. @@ -7,9 +9,9 @@ Branch names follow convention like c-sig-storage-ceph-VERSION> as desc on [Naming and Patterns for Mapping Git Branches to Koji Tags](https://wiki.centos.org/BrianStinson/GitBranchesandKojiTags) ``` - c8-sig-storage-ceph-octopus: CentOS-8 - c8-sig-storage-ceph-pacific: CentOS-8 - ... +c8-sig-storage-ceph-octopus: CentOS-8 +c8-sig-storage-ceph-pacific: CentOS-8 +... ``` Instructions for building the ceph package for the CentOS Storage SIG can be found in the following places: @@ -20,33 +22,117 @@ Instructions for building the ceph package for the CentOS Storage SIG can be fou Before starting, choose the branch containing the maintained spec for the cephadm package: ``` - git checkout -t origin/c8-sig-storage-ceph- +git checkout -t origin/c8-sig-storage-ceph- ``` You can find the sha1 for the "patches_base" comment and "Source0" with "git ls-remote", e.g. ``` - $ git ls-remote https://github.com/ceph/ceph pacific - ca0faa0a628c041f5b5313060344006830812e25 refs/heads/pacific +$ git ls-remote https://github.com/ceph/ceph pacific +ca0faa0a628c041f5b5313060344006830812e25 refs/heads/pacific ``` The source code can be downloaded using the 'spectool' tool , which uses the Source0 entry in the SPEC: ``` - $ spectool -g SPECS/cephadm.spec - $ mv cephadm SOURCES/cephadm +$ spectool -g SPECS/cephadm.spec +$ mv cephadm SOURCES/cephadm ``` Create a src.rpm with: ``` - $ rpmbuild -bs \ --define "_sourcedir $PWD/SOURCES" --define "_srcrpmdir $PWD" \ --define "dist .el8" SPECS/cephadm.spec +$ rpmbuild -bs \ --define "_sourcedir $PWD/SOURCES" --define "_srcrpmdir $PWD" \ --define "dist .el8" SPECS/cephadm.spec ``` and finally we can build it running: ``` - $ cbs build [--scratch] storage8-ceph-pacific-el8 cephadm.el8.src.rpm +$ cbs build [--scratch] storage8-ceph-pacific-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 you 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.11-1.el8.src.rpm +``` diff --git a/SPECS/cephadm.spec b/SPECS/cephadm.spec deleted file mode 100644 index 29b92a5..0000000 --- a/SPECS/cephadm.spec +++ /dev/null @@ -1,55 +0,0 @@ -# Upstream ceph commit upon which this package is based: -# patches_base=ca0faa0a628c041f5b5313060344006830812e25 - -Name: cephadm -Epoch: 2 -Version: 16.1.0 -Release: 568%{?dist} -Summary: Utility to bootstrap Ceph clusters -License: LGPL-2.1 -URL: https://ceph.io -Source0: https://github.com/ceph/ceph/raw/ca0faa0a628c041f5b5313060344006830812e25/src/cephadm/cephadm -Source1: COPYING-LGPL2.1 - -BuildArch: noarch - -Requires: lvm2 -Requires: python3 -Recommends: podman -%description -Utility to bootstrap a Ceph cluster and manage Ceph daemons deployed -with systemd and podman. - -%prep -cp %{SOURCE0} . -cp %{SOURCE1} . - -%build - -%install -mkdir -p %{buildroot}%{_sbindir} -install -m 0755 cephadm %{buildroot}%{_sbindir}/cephadm -mkdir -p %{buildroot}%{_sharedstatedir}/cephadm -chmod 0700 %{buildroot}%{_sharedstatedir}/cephadm -mkdir -p %{buildroot}%{_sharedstatedir}/cephadm/.ssh -chmod 0700 %{buildroot}%{_sharedstatedir}/cephadm/.ssh -touch %{buildroot}%{_sharedstatedir}/cephadm/.ssh/authorized_keys -chmod 0600 %{buildroot}%{_sharedstatedir}/cephadm/.ssh/authorized_keys - -%pre -getent group cephadm >/dev/null || groupadd -r cephadm -getent passwd cephadm >/dev/null || useradd -r -g cephadm -s /bin/bash -c "cephadm user for mgr/cephadm" -d %{_sharedstatedir}/cephadm cephadm -exit 0 - -%postun -userdel -r cephadm || true -exit 0 - -%files -%license COPYING-LGPL2.1 -%{_sbindir}/cephadm -%attr(0700,cephadm,cephadm) %dir %{_sharedstatedir}/cephadm -%attr(0700,cephadm,cephadm) %dir %{_sharedstatedir}/cephadm/.ssh -%attr(0600,cephadm,cephadm) %{_sharedstatedir}/cephadm/.ssh/authorized_keys - -%changelog diff --git a/SPECS/cephadm.spec.in b/SPECS/cephadm.spec.in new file mode 100644 index 0000000..29b92a5 --- /dev/null +++ b/SPECS/cephadm.spec.in @@ -0,0 +1,55 @@ +# Upstream ceph commit upon which this package is based: +# patches_base=ca0faa0a628c041f5b5313060344006830812e25 + +Name: cephadm +Epoch: 2 +Version: 16.1.0 +Release: 568%{?dist} +Summary: Utility to bootstrap Ceph clusters +License: LGPL-2.1 +URL: https://ceph.io +Source0: https://github.com/ceph/ceph/raw/ca0faa0a628c041f5b5313060344006830812e25/src/cephadm/cephadm +Source1: COPYING-LGPL2.1 + +BuildArch: noarch + +Requires: lvm2 +Requires: python3 +Recommends: podman +%description +Utility to bootstrap a Ceph cluster and manage Ceph daemons deployed +with systemd and podman. + +%prep +cp %{SOURCE0} . +cp %{SOURCE1} . + +%build + +%install +mkdir -p %{buildroot}%{_sbindir} +install -m 0755 cephadm %{buildroot}%{_sbindir}/cephadm +mkdir -p %{buildroot}%{_sharedstatedir}/cephadm +chmod 0700 %{buildroot}%{_sharedstatedir}/cephadm +mkdir -p %{buildroot}%{_sharedstatedir}/cephadm/.ssh +chmod 0700 %{buildroot}%{_sharedstatedir}/cephadm/.ssh +touch %{buildroot}%{_sharedstatedir}/cephadm/.ssh/authorized_keys +chmod 0600 %{buildroot}%{_sharedstatedir}/cephadm/.ssh/authorized_keys + +%pre +getent group cephadm >/dev/null || groupadd -r cephadm +getent passwd cephadm >/dev/null || useradd -r -g cephadm -s /bin/bash -c "cephadm user for mgr/cephadm" -d %{_sharedstatedir}/cephadm cephadm +exit 0 + +%postun +userdel -r cephadm || true +exit 0 + +%files +%license COPYING-LGPL2.1 +%{_sbindir}/cephadm +%attr(0700,cephadm,cephadm) %dir %{_sharedstatedir}/cephadm +%attr(0700,cephadm,cephadm) %dir %{_sharedstatedir}/cephadm/.ssh +%attr(0600,cephadm,cephadm) %{_sharedstatedir}/cephadm/.ssh/authorized_keys + +%changelog