Blame README.md

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