Blame README.md

e26092
# About building cephadm
e26092
09ccae
This is a dist-git like repo for cephadm
09ccae
3fd926
The master brach is unused: use an existing branch instead.
09ccae
3fd926
Branch names follow convention like c<VERSION>-sig-storage-ceph-VERSION> as described
3fd926
3fd926
on [Naming and Patterns for Mapping Git Branches to Koji Tags](https://wiki.centos.org/BrianStinson/GitBranchesandKojiTags)
3fd926
3fd926
```
484e3e
c8-sig-storage-ceph-octopus: CentOS-8
484e3e
c8-sig-storage-ceph-pacific: CentOS-8
484e3e
...
3fd926
```
09ccae
09ccae
Instructions for building the ceph package for the CentOS Storage SIG can be found in the following places:
09ccae
3fd926
[Comunity Build System](https://wiki.centos.org/HowTos/CommunityBuildSystem)
3fd926
[Storage SIG landing page](https://wiki.centos.org/SpecialInterestGroup/Storage)
3fd926
3fd926
Before starting, choose the branch containing the maintained spec for the cephadm package:
3fd926
3fd926
```
484e3e
git checkout -t origin/c8-sig-storage-ceph-<VERSION>
3fd926
```
3fd926
3fd926
You can find the sha1 for the "patches_base" comment and "Source0" with "git ls-remote", e.g.
3fd926
3fd926
```
484e3e
$ git ls-remote https://github.com/ceph/ceph octopus
484e3e
ca0faa0a628c041f5b5313060344006830812e25 refs/heads/octopus
3fd926
```
3fd926
3fd926
The source code can be downloaded using the 'spectool' tool , which uses the Source0 entry in the SPEC:
3fd926
3fd926
```
484e3e
$ spectool -g SPECS/cephadm.spec
484e3e
$ mv cephadm SOURCES/cephadm
3fd926
```
09ccae
3fd926
Create a src.rpm with:
09ccae
3fd926
```
484e3e
$ rpmbuild -bs \ --define "_sourcedir $PWD/SOURCES" --define "_srcrpmdir $PWD" \ --define "dist .el8" SPECS/cephadm.spec
3fd926
```
09ccae
3fd926
and finally we can build it running:
09ccae
3fd926
```
484e3e
$ cbs build [--scratch] storage8-ceph-octopus-el8 cephadm.el8.src.rpm
3fd926
```
09ccae
e26092
## Build cephadm using the Makefile
e26092
e26092
A Makefile is provided with the purpose of automating the steps described before.
e26092
It provides an helper function and can be used to build the srpm, as well as obtaining
e26092
additional information on the current build.
e26092
The act of running the 'cbs build' command is not automated on the Makefile since it's out
e26092
of scope: feel free to refer to the last step of the previous section to run the cbs build
e26092
after the Makefile execution ends.
e26092
e26092
### Executing the Makefile without parameters
e26092
e26092
If no parameters are provided, the Makefile computes the branch name, the version
e26092
and the release from the current spec file.
e26092
The Release field is increased by 1 but the version remains the same: this is because
e26092
we're building the package against a newer hash instead of bumping the cephadm version
e26092
according to the provided tags (the ceph-ansible approach).
e26092
e26092
If you want to produce a new srpm for an existing cephadm version, just run:
e26092
e26092
```
e26092
make
e26092
```
e26092
e26092
and you will see an output like this:
e26092
e26092
```
e26092
[fmount@buildbot cephadm]$ make
e26092
sed SPECS/cephadm.spec.in \
e26092
  -e "s/89ceb19fd8609fd4c99d10dd63f42e6786e37c86/dcf77bd9ff89dfef682c4a2dda05ac5c8651dbe5/" \
e26092
  -e 's/@VERSION@/15.2.10/' \
e26092
  -e 's/@RELEASE@/2/' \
e26092
 > SPECS/cephadm.spec
e26092
cp SPECS/cephadm.spec SPECS/cephadm.spec.in
e26092
/usr/bin/spectool -g SPECS/cephadm.spec -C SOURCES -f
e26092
Getting https://github.com/ceph/ceph/raw/dcf77bd9ff89dfef682c4a2dda05ac5c8651dbe5/src/cephadm/cephadm to SOURCES/cephadm
e26092
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
e26092
                                 Dload  Upload   Total   Spent    Left  Speed
e26092
100   170  100   170    0     0     32      0  0:00:05  0:00:05 --:--:--    40
e26092
100  214k  100  214k    0     0  20886      0  0:00:10  0:00:10 --:--:-- 47630
e26092
rpmbuild -bs /home/fmount/cephadm/SPECS/cephadm.spec \
e26092
  --define "_sourcedir /home/fmount/cephadm/SOURCES" \
e26092
  --define "_srcrpmdir /home/fmount/cephadm" \
e26092
  --define "dist .el8"
e26092
Wrote: /home/fmount/cephadm/cephadm-15.2.10-2.el8.src.rpm
e26092
```
e26092
e26092
In addition, a cephadm.spec file is generated from the input `SPECS/cephadm.spec.in` and it can be
e26092
found under the SPECS directory.
e26092
e26092
At the end of this process, as described in the previous section, you can run the cbs build:
e26092
e26092
```
484e3e
$ cbs build [--scratch] storage8-ceph-octopus-el8 cephadm-15.2.10-2.el8.src.rpm
e26092
```
e26092
e26092
e26092
### Executing the Makefile overriding some input parameters
e26092
e26092
If you want to bump to a newer released version, the hash computation remains unchanged,
e26092
but you might want to patch the spec input file properly.
e26092
For this reason a few parameters, exposed via the `cephadm.spec.in` file can be overrided:
e26092
e26092
* RELEASE
e26092
* DIST = el8 by default
e26092
* VERSION
e26092
484e3e
For instance, assuming you have the following data in the current spec:
e26092
484e3e
```
e26092
[fmount@buildbot cephadm]$ cat SPECS/cephadm.spec | grep -iE "(Release|Version)"
e26092
Version: 15.2.10
e26092
Release: 2%{?dist}
484e3e
```
e26092
e26092
you can patch (and bump to a newer NVR) the current (existing) spec file by running:
e26092
e26092
```
e26092
DIST=el8 RELEASE=1 VERSION=15.2.11 make
e26092
```
e26092
e26092
Then, running the regular cbs build command a new cephadm rpm can be built:
e26092
e26092
```
484e3e
$ cbs build [--scratch] storage8-ceph-octopus-el8 cephadm-15.2.11-1.el8.src.rpm
e26092
```