Tuesday, February 1, 2011

Using Mock and Koji




Hello Readers,


The purpose of this post is to demonstrate a step-by-step procedure on how to use the mock and koji tools.

Mock is used to test that the BuildRequires for a package are accurate; creating a bare-bone chroot environment that only contains the basic build packages plus any packages that were indicated by the BuildRequires line in the spec file.

Koji is a client-server system that allows you to queue build with the Fedora build farm. This will allow you to test your packages by building them for different architectures.

Mock

Before we being we must install mock by using the yum install mock command.
Add yourself to the mock group giving you the ability to properly use the command: usermod –G mock <username>.

In order to use mock to test your package’s  BuildRequires you will need to use SRPMs that you have built in the past. The command syntax for using mock is, mock –r <architecture> <path-to-SRPM>.


NOTE: A list of architectures that mock is able to test can be found in the /etc/mock/ directory, and your systems default architecture for mock can be found in the /etc/mock/default.cfg file.


I will be using my SRPMs that I created in my previous post in order to demonstrate how the mock command is used. (gnupg-1.4.11-1.fc14.src.rpm and wdiff-0.6.5-1.fc14.src.rpm)

[gcasella@Fedora14  SRPMS]$ mock -r default wdiff-0.6.5-1.fc14.src.rpm
INFO: mock.py version 1.1.8 starting...
...
INFO: Start(wdiff-0.6.5-1.fc14.src.rpm)  Config(fedora-14-x86_64)
State Changed: lock buildroot
...
State Changed: running yum
State Changed: creating cache
State Changed: unlock buildroot
State Changed: setup
State Changed: build
INFO: Done(wdiff-0.6.5-1.fc14.src.rpm) Config(default) 3 minutes 43 seconds
INFO: Results and/or logs in: /var/lib/mock/fedora-14-x86_64/result

As you can see from the output above it took 3 minutes and 43 seconds for the mock command to complete its tests. Any errors that may arise can be found in the log files in your /var/lib/mock/<architecture>/results/ directory.

NOTE: It may seem that the mock command times out while it’s running yum. It is crucial to remember that each SRPM that is being tested for the first time will take a long time.

KOJ I

In order to use koji we must install the client software that will upload your package to the Fedora farm build. Koji requires you to have a Fedora Account System (FAS2) account, this is where you will be able to watch the status of your uploaded packages.

To install Koji use the command: yum install fedora-packager

Before using the Koji command line interface you need to perform an initial setup, luckily the Koji package includes a script which will automatically set up your Koji client. To perform the initial setup you must run the command as a non-super user: /usr/bin/fedora-packager-setup – Follow the on screen instructions and import the created certificate into your Firefox web browser. (Additional information can be found here)

The command koji build dist-f14 –scratch SRPM will allow you to queue a build request on the main koji server. The target (dist-f14) instructs koji to build the package using packages available in the Fedora 14 distribution and the –scratch option causes koji to build the package but not take it for the specific target (i.e. not include it in Fedora 14). Below is an example of the Koji command using my gnupg-1.4.11-1.fc14.src.rpm package;

[gcasella@Fedora14  SRPMS]$ koji build dist-f14 --scratch gnupg-1.4.11-1.fc14.src.rpm
Uploading srpm: gnupg-1.4.11-1.fc14.src.rpm
[====================================] 100% 00:00:44   4.50 MiB 102.81 KiB/sec
Created task: 2748409
Task info: http://koji.fedoraproject.org/koji/taskinfo?taskID=2748409
Watching tasks (this may be safely interrupted)...
...
2748409 build (dist-f14, gnupg-1.4.11-1.fc14.src.rpm): free -> open (x86-02.phx2.fedoraproject.org)
...
2748411 buildArch (gnupg-1.4.11-1.fc14.src.rpm, i686): free -> open (x86-14.phx2.fedoraproject.org)

You will notice in the output above that a Task ID will be given, with this task ID you can use the following command: koji watch-task <task ID>, alternatively you can monitor your tasks through the https://koji.fedoraproject.org website. An example of the koji watch-task <task ID> command is displayed below;

 [gcasella@Fedora14  SRPMS]$ koji watch-task 2748409
Watching tasks (this may be safely interrupted)...
2748409 build (dist-f14, gnupg-1.4.11-1.fc14.src.rpm): open (x86-02.phx2.fedoraproject.org)
  2748411 buildArch (gnupg-1.4.11-1.fc14.src.rpm, i686): open (x86-14.phx2.fedoraproject.org)
   ...
   ...
  0 free  2 open  1 done  0 failed
  2748411 buildArch (gnupg-1.4.11-1.fc14.src.rpm, i686): open (x86-14.phx2.fedoraproject.org) -> closed
  0 free  1 open  2 done  0 failed
2748409 build (dist-f14, gnupg-1.4.11-1.fc14.src.rpm): open (x86-02.phx2.fedoraproject.org) -> closed
  0 free  0 open  3 done  0 failed

2748409 build (dist-f14, gnupg-1.4.11-1.fc14.src.rpm) completed successfully



Where To Find My Files! 

I have provided links to my SRPMs from my previous posts along with a screen shot of my successful tasks performed on the Fedora build farm;


    Koji Server Screen Shot 

gnupg-1.4.11 Files
wdiff-0.6.5 Files



Gian-Luca Casella -- Last Updated on Tuesday, February 01, 2011



1 comment:

  1. So what about running a dedicated (non-hosted) Koji/mock build system?

    Tweeks

    ReplyDelete