Contents
Building OpenShift Origin and OpenShiftAnsible Manually
There are many times that you want to build Origin or OpenShiftAnsible manually. This is usually for testing, or when automation has broken down, but there can be other reasons.
1. Setup
Although tito or cbs are not required, they are helpful.
1.1. Tito
tito helps you build rpm's and srpm's from git repos.
- Fedora
- dnf install tito
- RHEL7 / Scientific Linux 7 / CentOS 7
- yum --enablerepo=epel install tito
1.2. CBS
cbs allows you to build packages on the CentOS Build System. More information, including getting permissions
- Fedora
- dnf copr enable bstinson/centos-packager
- dnf install centos-packager
- CentOS 7
- yum install centos-packager
2. Manually Build Origin
2.1. Setup Variables
Although you don't have to use variables, it makes it easier for showing what to do. I also find that when I set the variables I don't miss steps. I will be using 3.9.0 as our example.
- VERSION - Just the number, not with the v, and not with the alpha/rc stuff
- export VERSION=3.9.0
- RELEASE - If not a release, start with a 0, if it is a release, start with a 1, or if you needed to rebuild, go up in intergers
- export RELEASE=0.alpha.1
- export RELEASE=1
- export RELEASE=2
- GIT_TAG - The full git tag of the version you want to build. Get these values by doing "git tag" in the origin git repo.
- export GIT_TAG=v3.9.0-alpha.1
- export GIT_TAG=v3.9.0
2.2. Do The Work
I like to always do a build with a clean git checkout.
- mkdir -p /tmp/merge
- cd /tmp/merge
- rm -rf origin
git clone https://github.com/openshift/origin.git
- cd origin
- git checkout ${GIT_TAG}
- git tag -d ${GIT_TAG}
- sed -i "s|^Version: .*$|Version: ${VERSION}|" origin.spec
- sed -i "s|^Release: .*$|Release: ${RELEASE}|" origin.spec
- (If you are not using tito, do the following)
- # edit ""%global os_git_vars" line in origin.spec
- ## This will be different, depending on your release
- ## This is the hard part, and the reason most people use tito
- git commit -m "Fixup spec file" origin.spec
- (If using tito, do the following)
- tito tag --keep-version --no-auto-changelog
- tito build --offline --srpm
- (If you are not using tito, do the following)
git archive --format=tar --prefix=origin-${VERSION}/ --output=/tmp/origin-${VERSION}.tar.gz <git hash from last step>
- cp origin.spec ~/rpmbuild/SPECS/
- cp /tmp/origin-${VERSION}.tar.gz ~/rpmbuild/SOURCES/
- cd ~/rpmbuild/SPECS/
- rpmbuild -bs --nodeps origin.spec
- (If you are using CBS, do the following)
cbs build --scratch paas7-openshift-origin39-el7 <full path to srpm>
- (If you are building locally, do the following)
rpmbuild --rebuild <full path to srpm>
3. Manually Build OpenShift Ansible
3.1. Setup Variables
Although you don't have to use variables, it makes it easier for showing what to do. I also find that when I set the variables I don't miss steps. I will be using 3.9.0 as our example.
- VERSION - Just the number, not with the v, and not with the alpha/rc stuff
- export VERSION="3.9"
3.2. Do The Work
I like to always do a build with a clean git checkout.
- mkdir -p /tmp/merge
- cd /tmp/merge
- rm -rf openshift-ansible
git clone https://github.com/openshift/openshift-ansible.git
- cd openshift-ansible
LATEST_TAG=git tag | grep openshift-ansible-${VERSION} | cut -d'.' -f3 | sort -n | tail -n1
- echo $LATEST_TAG
- git checkout openshift-ansible-${VERSION}.${LATEST_TAG}
- (If using tito, do the following)
- tito build --test --srpm --rpmbuild-options="--define 'dist .el7'"
- (If you are not using tito, do the following)
git archive --format=tar --prefix=openshift-ansible-${VERSION}/ --output=/tmp/openshift-ansible-${VERSION}.tar.gz <git hash from last step>
- cp openshift-ansible.spec ~/rpmbuild/SPECS/
- cp /tmp/openshift-ansible-${VERSION}.tar.gz ~/rpmbuild/SOURCES/
- cd ~/rpmbuild/SPECS/
- rpmbuild -bs --nodeps openshift-ansible.spec
- (If you are using CBS, do the following)
cbs build --scratch paas7-openshift-origin39-el7 <full path to srpm>
- (If you are building locally, do the following)
rpmbuild --rebuild <full path to srpm>