Tuesday, 30 October 2012

Mock and Koji

Today I'm going to build my packages with mock and koji. Mock is a toll to test that the BuildRequires for the package are complete and accurate. While koji is a client-server system that builds the package on multiple different architectures within the Fedora build farm. It is useful when you don't have access to the machines of each architecture.
Let's start with mock.


Mock takes a srpm and builds it in a chroot. It will tests your BuildRequries lines are correct and no missing dependencies.

Install mock on Fedora, and add current user into mock group.

| yum install mock
| usermod -aG mock wendy

Then I tested to build my SRPM package for Fedora 17 on 64-bit architecture by using mock

| mock -r fedora-17-x86_64 rpmbuild/SRPMS/which-2.20-1.fc17.src.rpm
| mock -r fedora-17-x86_64 rpmbuild/SRPMS/hello-2.80-1.fc17.src.rpm
( * Note: the distribution-release-arch value must correspond to a config file in /etc/mock)

The mock build took longer than the rpmbuild time.

real    5m41.030s
user    0m6.307s
sys    0m11.108s


real    1m38.404s
user    0m11.832s
sys    0m20.338s

To check the result and any error during the testing process. I checked the following file, and both of them were good.

| vi /var/lib/mock/fedora-17-x86_64/result/build.log

There was no error so my mock build was successful.

Mock is easy to use since it's only one command, but I like rpmbuild better. For rpmbuild, I can see the source code file and spec file located in separate directories and it is clear and well structured when building the RPM files.


Koji setup

| yum install fedora-packager

then run this script to setup my certificate that authenticate the package.

| /usr/bin/fedora-packager-setup

This links my FAS account to my Fedora system by making certificate on it. Also it makes a SSL certificate so I can login to the web interface of each Fedora testing farm. After the setup, I imported my certificate into Firefox browser in order to manage the koji web interfaces.

Below are my testing in different architechtures.

Primary i386 and x86_64 

| koji build f17 --scratch SRPMS/which2.20-1.fc17.src.rpm


ARM armv5tel and armv7hl

| arm-koji build f18 --scratch SRPMS/which2.20-1.fc17.src.rpm


| arm-koji build f18 --scratch SRPMS/hello-2.8-1.fc17.src.rpm


s390 mainframe

| s390-koji build f18 --scratch SRPMS/which2.20-1.fc17.src.rpm



| ppc-koji build f18 --scratch SRPMS/which2.20-1.fc17.src.rpm


| ppc-koji build f18 --scratch SRPMS/hello-2.8-1.fc17.src.rpm


All of my testing builds are passed without any error. The job was sent to each building machine and sent in the queue. It took around 10 to 20 minutes to finish each building depended on the size of package and how busy the queue was.

Overall I think mock and koji are great tools to build RPM packages. It's bacially automated process. They are simply and user friendly to use and especially for beginner packagers. I like the fact that mock allows us to test packages in a chroot environment so we don't need to worry about messing up our own OS. Koji is also a great tool to test all kinds of architectures without accessing the physical hardware of each architecture.

No comments:

Post a Comment