RPM Build Notes

From MozillaWiki
Jump to navigation Jump to search

RPM Build Notes

Install Mach

Start with a minimal install of CentOS 6.2.

$ yum install wget createrepo
$ wget http://thomas.apestaart.org/download/mach/mach-1.0.2.tar.gz
$ ./configure --disable-selinux
$ make
$ make install
$ chmod u+s /usr/local/sbin/mach-helper
$ groupadd mach
$ useradd -g mach -m mach
$ passwd mach

Due to a permissions bug I hit with mach (during a file copy), we'll continue as root.

Create /root/.machrc:

config['centos-6-x86_64-os']['macros']['dist'] = '.el6'
config['centos-6-i386-os']['macros']['dist'] = '.el6'

Prepare the Package

For this example, I want to build a new mozilla-python27 package based on 2.7.3 instead of 2.7.2. I'm going to fetch the original .src.rpm and extract it into a subdirectory:

$ wget http://repos/repos/yum/releng/public/CentOS/6/x86_64/mozilla-python27-mercurial-2.1.1-4.el6.src.rpm
$ mkdir mozilla-python27 && cd mozilla-python27
$ rpm2cpio ../mozilla-python27-mercurial-2.1.1-4.el6.src.rpm | cpio -ivd

Then edit these .spec file lines to update the Python version and package release number:

%define pyrel 3
Release:        0%{?dist}

Build the Package

Now we want to rebuild the package using our updated .spec file.

$ rm -rf /usr/local/var/tmp/mach/*
$ mach='mach --debug -r centos-6-x86_64-os'
$ $mach clean
$ $mach build mozilla-python27/python27.spec

Note: adjust the target to 'centos-6-i386-os' to generate a 32-bit package.

In this case, though, I wanted to use mock (not mach) to build the final package since my mach build machine does not have access to the Mozilla yum repos. We can use the .src.rpm generated above and feed that to mock.

Note that this is a simple example. mach has an advantage over mock in that it figures out dependencies when building multiple packages and automatically pulls in source files (normally a manual operation). This can save a lot of time and hassle.

Configure Mock

  • Install mock
  • Copy the mock-config folder to your home directory (this example uses /home/cltbld/mock-config).

Build Using Mock

  • Fetch the .src.rpm you built earlier.
  • Execute these steps to build:
$ mock='mock --configdir=/home/cltbld/mock-config -r epel-6-x86_64 -v'
$ $mock --rebuild mozilla-python27-2.7.3-0.el6.src.rpm
  • The script will tell you where the results are available.
  • Use 'epel-6-i386' to build a 32-bit package.