I haven't been very happy with my way to build packages. I've been looking for a better system for managing it.
Through conversation in #lopsa
, I found my way to Mock, a tool that builds packages in chroot environments.
I've been testing it on a VM. So far, it looks promising.
To use Mock, you first need to add your user to the mock
group:
sudo /usr/sbin/usermod -a -G mock $user
After that, Mock is simple to use. If you have a source RPM, building a package is as easy as:
mock -r $configuration rebuild $srpm
So, for example, to build my patched kernel RPM:
mock -r epel-6-x86_64 rebuild kernel-2.6.32.46-1.el6.oberon.src.rpm
Build environment configurations are defined in /etc/mock
. If you're building RPMs for use with RHEL or CentOS, one of the preexisting epel configurations should suffice. There are configurations for Fedora as well. You can configure your own configurations as well.
On 64-bit systems, you can use the 32-bit configurations to build 32-bit packages. If you want to use specify a different architecture, you can use the --arch
argument. For example, to build all binary RPMs for my patched kernel:
mock -r epel-6-x86_64 rebuild kernel-2.6.32.46-1.el6.oberon.src.rpm mock -r epel-6-i386 rebuild kernel-2.6.32.46-1.el6.oberon.src.rpm mock -r epel-6-x86_64 rebuild kernel-2.6.32.46-1.el6.oberon.src.rpm --arch=noarch --no-clean
The first command builds the 64-bit packages. The second command builds the 32-bit packages. The third command builds the additional packages that don't have an architecture, e.g. kernel-doc-2.6.32.46-1.el6.oberon.noarch.rpm
. The --no-clean
argument tells mock not to clean the build environment first. Without this, the third command will remove the packages generated by the first command.
When the commands are done running, the 64-bit and noarch RPMs can be found in the directory /var/lib/mock/epel-6-x86_64/result/
and the 32-bit RPMs can be found in the directory /var/lib/mock/epel-6-i386/result/
.
I haven't tried using Mock in my Makefile but that's next on the list. I also need to simplify my builds so they don't rebuild all RPMs. Since the kernel RPMs take about six hours to build (for both 32-bit and 64-bit) on my VM, this makes builds almost prohibitively long.
I have also thought about building a system that uses Mock, some message queueing system, and some cloud interface to spin up EC2 instances (or the like) for builds. However, that seems pretty close to Koji so I should probably look into that further first.
Add new comment