Changes

Jump to: navigation, search

ReleaseEngineering/PuppetAgain/HowTo/Build RPMs

2,591 bytes removed, 21:09, 10 December 2013
no edit summary
=How to Build RPMs=
 
==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:
 
<pre>
$ 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
</pre>
 
Then edit these .spec file lines to update the Python version and package release number:
 
<pre>
%define pyrel 3
Release: 0%{?dist}
</pre>
==Build a .src.rpm==
There are two ways Use a machine configured to build a source RPM described belowRPMs, with the toplevel::server::pkgbuilder class.
===Build a .src.rpm Using Mach=== Mach automatically downloads required If you're upgrading or modifying an existing package, download the source tarballs and patches and can handle multi-package builds with inter-dependencies. ====Install/Configure Mach==== Start with a minimal install RPM of CentOS 6.2. <pre>$ yum install wget createrepo gcc make$ wget http://thomas.apestaart.org/download/mach/mach-1.0.2.tar.gz$ tar xzf ./mach-1.0.2.tar.gz$ cd mach-1.0.2$ ./configure --disable-selinux$ make$ make install$ chmod u+s /usr/local/sbin/mach-helper$ groupadd mach$ useradd -g mach -m mach$ passwd mach</pre> Due to a permissions bug I hit with mach (during a file copy), we'll continue as root. Create /root/.machrc: <pre>config['centos-6-x86_64-os']['macros']['dist'] = '.el6'config['centos-6-i386-os']['macros']['dist'] = '.el6'</pre> ====Build the .src.rpm====  $ mach build /path/to/spec ===Build a .src.rpm Using Mock=== ====Install/Configure Mock==== * Install mock* Copy old version of the [http://hg.mozilla.org/users/john.hopkins_mozillamessaging.com/misc/file/default/mock mock-config] folder to your home directory (this example uses /home/cltbld/mock-config). Find a suitable machine with package you'mock' installed. It's best d like to do this on a target machine, since its /etc/mock/default.cfg will already be set up correctly. Download the srpm build from puppetagain.pub.build.mozilla.org/data/repos/yum/releng/public and unpack it:
$ mkdir foopkg && cd foopkg
You should see a .spec file appear. Check that it is identical to the one in http://hg.mozilla.org/build/puppet under modules/packages/manifests/mozilla e.g., with an md5 hash. If not, figure out what the differences are, and which corresponds to the running version of the package.
Edit the If you're starting a fresh package, make yourself a new .spec file and download any Source files to your heart's contentthe current directory.
====Build Edit the spec file to your heart's content. To actually build the .src.rpm====:
$ mock --buildsrpm --spec /path/to/spec --sources $PWD
The script output will tell you where the SRPM is. Copy it somewhere else, or mock will delete itin the next step.
==Build the Package==
Now we want to rebuild the package using our .src.rpm created above.
===Build using Mach=== Included here for reference, but it is preferable to use Mock to build the final binary package (see "Build Using Mock"* If necessary, below) as fetch the steps have been tweaked to use only our internal Yum repos. This is desirable to get exactly the right binary package outputsrc.rpm you built earlier.* Execute these steps to build:
<pre>
$ rm mock -rf /usr/local/var/tmp/mach/*$ mach='mach --debug rebuild -r centospuppetagain-6centos6-x86_64-os'$ $mach clean$ $mach build 64 mozilla-python27/python27-2.7.3-0.el6.src.specrpm
</pre>
The script will tell you where the results are available.
Note: adjust the target to Use 'centos-6r puppetagain-i386centos6-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. ===Build Using Mock=== * Fetch the .src.rpm you built earlier.* Execute these steps to build:<pre>$ mock='mock --configdir=/home/cltbld/mock-config -r epel-6-x86_64 -v'$ $mock --clean$ $mock --rebuild mozilla-python27-2.7.3-0.el6.src.rpm</pre>* The script will tell you where the results are available.* Use 'epel-6-i386' instead to build a 32-bit package.
== Other Dependencies ==
If your package depends on other mozilla-specific packages, Iit'm not sure what the s best way to build isand land those first. The less-than-awesome technique I used was to hack /etc/mock/epel-6-x86_64.cfg to include pointers configs point to the public mirrors of local puppetagain repositories, so once the puppetagain reposdependency is landed, it will be available in your mock build environment.
= Testing =
For testing purposes, it's best to install the RPM locallyon a test host (NOT on the pkgbuilder host!), rather than dropping it into the puppetagain data directory and risking affecting production. You can do that too, if you're confident it won't affect anything.
= Review =
Canmove, confirm
1,394
edits

Navigation menu