Koji RPM Build System Configuration and Usage
In the previous short article series I’ve shown you how to install Koji and all its components like Kojid, Kojira, Koji-Hub. However to fully use it we need to do some initial configuration that can only be persisted for a fresh install by a early DB Backup, I’ll remind you of that later.
To understand what we are doing here you need to know a bit more about Kojis philosophy:
Koji uses Tags to identify and mark various stages in the RPM building workflow. Some tags are logically linked together to the same flow, like building for a certain target distribution, e.g. CentOS6. We will call this target tag dist-centos6. But you can maintain multiple distribution-builds on the same Koji instance, just add more tags then according to this article.
We also need a tag that is used for builds and inherits the build target. We call this tag dist-centos6-build
Koji is building RPMs in a chroot with the mock tool. It also installs basic packages to those buildroots from the virtual yum package groups named build and srpm-build. So we need to tell Koji which packages we need. You can extend that list to your needs but choose wise: These packages are pulled in for every build then.
Also, Koji needs to know where to find/pull packages from, therefore we add external repositories, the base repo as the very first !!
When doing this, stick to the tag name pattern dist-SOME_NAME, dist-SOME_NAME-build
koji add-tag --parent dist-centos6 --arches "x86_64" dist-centos6-build
# external repos
koji add-external-repo -t dist-centos6-build dist-centos6-repo http://centos.bio.lmu.de/6/os/\$arch/
koji add-external-repo -t dist-centos6-build dist-epel6-repo http://ftp-stud.hs-esslingen.de/pub/epel/6/\$arch/
koji add-target dist-centos6 dist-centos6-build
# virtual build yum groups
koji add-group dist-centos6-build build
koji add-group dist-centos6-build srpm-build
koji add-group-pkg dist-centos6-build build bash bzip2 coreutils cpio diffutils findutils gawk gcc grep sed gcc-c++ gzip info patch redhat-rpm-config rpm-build shadow-utils tar unzip util-linux-ng which make
koji add-group-pkg dist-centos6-build srpm-build bash cvs gnupg make redhat-rpm-config rpm-build shadow-utils wget rpmdevtools
koji regen-repo dist-centos6-build
This last command is always a good shot to fix errors you might run into, especially after altering the external repos or adding packages to the build groups.
Now we are ready to go and build our first package
koji build --scratch dist-centos6 nginx-1.2.7-1.el6.ngx.src.rpm
This uses a local source rpm and builds it “scratch”, meaning that its like sandboxed and not going into the usual Koji workflow. This is useful for quick tests or building packages that you dont want to archive/maintain with Koji permanently.
If that worked out you know that Koji is running fine. Now go ahead and add the packages you want to permanently maintain with Koji
# and build them
koji build dist-centos6 nginx-1.2.7-1.el6.ngx.src.rpm
Note that you can only successfully build an NVRA (Name-Version-Release-Architecture) once ! So you need to bump the release number or version up if you change sth within the srpm.
In the next article, I will show you how to maintain your packages in a Git (or SVN) repository and letting Koji build SRPM and RPM from there , because supplying SRPM locally is not that convenient.