Create RPMs for yourself

create

~/.rpmmacros:

[pauljohn@pols12 ~]$ cat .rpmmacros
%_topdir /home/pauljohn/LinuxDownloads/redhat

%_signature gpg
%_gpg_name Paul Johnson

%_unpackaged_files_terminate_build 0

2. Make the directory

mkdir -p ~/LinuxDownloads/redhat

3. Install rpmbuild program

$ yum install rpm-build

4. Download the SRPM file of something you want to build. I used firefox to browse,
found something on epel, then downloaded from cli:

$ wget http://download.fedora.redhat.com/pub/epel/6/SRPMS/R-2.12.1-1.el6.src.rpm

5. Install that src.rpm. Unlike other RPM installs, this IS NOT run as root, and it will drop the files into the topdir defined above in .rpmmacros.

$ rpm -ivh R-2.12.1-1.el6.src.rpm

Warnings will say “user mockbuild does not exist”. Just ignore it.

6. Note that creates the directories SPECS and SOURCES under LinuxDownloads/redhat.

Create the others you will need in there

$ mkdir BUILD
$ mkdir RPMS
$ mkdir SRPMS

6. cd to LinuxDownloads/redhat/SPECS.

Read the “spec” file, it controls how the build works. When I have
trouble compiling programs, I almost always download an SRPM file
from that project and study how the packager built it.

If you just want to rebuild R as Tom had done it for EPEL, go ahead.

$ rpmbuild -ba R.spec

If you don’t want to build everything, well, then don’t.

Read the rpmbuild manual page.

$ rpmbuild -bp R.spec

Or

$ rpmbuild -bb R.spec

7. The usual scenario is that I study the spec file, then
figure out what changes I want to make.

Now my purpose is to make an RPM for R-2.12.2, which I’m sure
EPEL will offer on its own, but I’m eager.

So I get the source code for that version of R, put it in the
LinuxDownloads/redhat/SOURCES folder. Hopefully, that follows
the same naming convention as the previous R packaging. If
it doesn’t, there will be more work to do.

Then go back to spec file, and change the VERSION number so
it matches the new R source just downloaded.

If everything is “just right”, then the new rpm can be built
without further trouble. Usually, things don’t go just
right. Perhaps the packaging for the previous version
applied a patch that is no longer needed (or has already
been applied in R itself), so you have to remove that from the
spec file.

Or you want to change the build options in the spec.

There is some controversy about how R ought to be built, and
you see the results in the difference of Debian and Epel packaging
of R. Look at the configure statements, you’ll see what I mean.

Posted from GScribble.