Using mock to build RHEL packages

19 September 2006

Mock, the Fedora tool for maintaining standard buildroots and building rpm’s in them, can also be used to build packages for Red Hat Enterprise Linux (RHEL).

As an example, to create a mock buildroot for RHEL4, you need to:

  • Create a yum repository with the RPM's for RHEL4 in them. One way to do that is to download the ISO files for RHEL4 from [RHN]( and copy the RPM's from them into a new directory and run `createrepo` on that directory. There are also tools out there to help with that, e.g. [Yam](
  • Create a second yum repository for the mock-specific RPM's for a buildroot. These are [buildsys-build]( , which defines what RPM's make up the initial or 'minimal' build root, and [buildsys-macros](, which defines the `%dist` and `%rhel` macros, similar to the same package for Fedora. (An unmaintained example for such a repo can be found [here](
  • Download the [mock config file]( and adapt it to your local needs, in particular adjust the URL's for the yum repos in it.

If you want to rebuild buildsys-build and buildsys-macros from their specfiles, note that you need to define the %rhel macro on the command line like %% rpmbuild –define ‘rhel 4’ buildsys-build.spec %%

Creative Commons License Watzmann.Blog by David Lutterkort is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.

Generated with Jekyll