Mock Rocks!

I’ve been working through the process of getting a libcmpiutil package built for Fedora 9.  I’ve never packaged something for a distro before, so some of the things are a bit new to me.  Luckily, Daniel Veillard did a good chunk of the up-front work of writing the spec files; only minor tweakage was needed.

I’ve been using Fedora 8 for a development machine, because the Pegasus package is fine for what we need (aside from the schema changes).  However, during the review process, an issue came up which was no doubt related to a newer compiler version in the -development head of Fedora (what will become Fedora 9).  I, of course, did not see these issues on my Fedora 8 machine, and needed a way to test my fixes before posting for review again.

I considered installing a Fedora 8 VM, enabling the fedora-development repository and upgrading everything.  However, our lab was being really slow today, and accessing my KVM-capable machines was just not going to happen.  Knowing that Mock is supposed to help this sort of thing, I decided to give it a shot.

After setting up a build user (per the MockTricks page), I can do this:

% sudo su – build
% mock -r fedora-devel-x86_64 rebuild libcmpiutil-0.1-4.src.rpm

Not only do I get a Fedora 9 build environment, but I get my build dependencies checked and a .fc9 SRPM out of the whole deal!  It’s really cool to be able to get an automated build environment without needing to hose a machine with a test installation.  You can even test 32-bit builds on a 64-bit machine with minimal effort.  Finally, if you need to do something other than build an SRPM in the sandbox, you can get a chroot to any of the environments you need like this:

[build@guaranine ~]$ mock -r fedora-devel-x86_64 shell
INFO: mock.py version 0.8.7 starting…
State Changed: init plugins
State Changed: start
State Changed: lock buildroot
State Changed: clean
State Changed: init
State Changed: lock buildroot
State Changed: enabled yum cache, cleaning yum metadata
State Changed: enabling root cache
State Changed: unpacking cache
mock-chroot> cat /etc/fedora-release
Fedora release 8.90 (Rawhide)
mock-chroot>

The one thing I haven’t figured out how to do yet is test build a dependent set of RPMs (such as libcmpiutil and libvirt-cim), but I feel there must be a way.

Category(s): Codemonkeying, Linux
Tags: ,

Comments are closed.