Mockbuilder allows you to instanciate a virtual machine pre-configured with a working Mock environment.
It uses Vagrant and Chef to create and provision a virtual machine.
In a nutshell, Mock allows you to build RPM packages targetted to a different distribution than the one where your building the RPMs. It does this by jailing rpmbuild environments with chroot.
If you want to know more details on Vagrant, Chef or Mock, you may want to check these out:
You're going to need Berkshelf, so please install the Chef Development Kit
Also, you'll need to install the vagrant-berkshelf plugin:
$ vagrant plugin install vagrant-berkshelf
$ git clone https://github.com/ruizink/mockbuilder.git
$ cd mockbuilder
$ vagrant up
$ vagrant ssh
You want to make sure you have these components installed on your local machine:
I assume that you're already familiar with the rpmbuild process and you know what Mock is. (Scroll to the top in case you've missed it)
To get things going you'll need at least 2 things with you:
- a .spec file
- the sources
$ cp -rp packages/buildroot.clean packages/<mypackage>
$ cd packages/<mypackage>
$ rpmbuild -bs SPECS/<mypackage>.spec
$ mock -r <dist> SRPMS/<mypackage>-<version>-<release>.src.rpm
(Supported dist at the moment include: el5-x86_64, el6-x86_64 and el7-x86_64)
$ #### Create build environemnt
$ cp -rp packages/buildroot.clean packages/tomcat7
$ cd packages/tomcat7
$
$ #### Copy the spec file and sources
$ wget -P SPECS/ https://raw.github.com/nmilford/rpm-tomcat7/master/tomcat7.spec
$ wget -P SOURCES/ https://raw.github.com/nmilford/rpm-tomcat7/master/tomcat7.init
$ wget -P SOURCES/ https://raw.github.com/nmilford/rpm-tomcat7/master/tomcat7.sysconfig
$ wget -P SOURCES/ https://raw.github.com/nmilford/rpm-tomcat7/master/tomcat7.logrotate
$ wget -P SOURCES/ http://download.openpkg.org/components/cache/tomcat/apache-tomcat-7.0.41.tar.gz
$
$ #### Build the SRPM
$ rpmbuild -bs SPECS/tomcat7.spec
$
$ #### Build the RPMs for el5-x86_64
$ mock -r el5-x86_64 SRPMS/tomcat7-7.0.41-1.src.rpm
$
$ #### Check the results
$ ls -1 /var/lib/mock/el5-x86_64/result/tomcat7*.rpm
/var/lib/mock/el5-x86_64/result/tomcat7-7.0.41-1.noarch.rpm
/var/lib/mock/el5-x86_64/result/tomcat7-7.0.41-1.src.rpm
Mário Santos @_ruizink_