[NBLUG/talk] Recompiling a RPM
Eric Eisenhart
eric at nblug.org
Mon Jan 8 09:20:58 PST 2007
On Mon, Jan 08, 2007 at 08:58:03AM -0800, Todd Cary wrote:
> I need to recompile my version of Red Hat's PHP using the
> --with-interbase=shared,/opt/firebird. I have downloaded the .src.rpm
> version, however I have forgotten how to recompile the src and how to
> replace the current version. In fact, can that even be done?
>
> I cannot run RPM -e php due to the dependencies..
I usually do this in a user-environment instead of as root, but here's the
basic steps:
1) rpm -ihv blah.src.rpm
2) rpmbuild -ba /usr/src/redhat/SPECS/blah.spec
The rpmbuild command-line can take some arguments to define things that are
passed to the stuff in the .spec file. Or you can modify the .spec file
first.
I highly recommend doing the following, though:
As a non-root user:
1) mkdir ~/rpmbuild/ ; mkdir ~/rpmbuild/tmp ; mkdir ~/rpmbuild/RPMS
2) cat > ~/.rpmmacros <<EOT
%_topdir %(echo $HOME)/rpmbuild
%_tmppath %{_topdir}/tmp
%_builddir %{_tmppath}
%_rpmtopdir %{_topdir}/%{name}
%_sourcedir %{_rpmtopdir}
%_specdir %{_rpmtopdir}
%_rpmdir %{_topdir}/RPMS
%_srcrpmdir %{_topdir}/RPMS
%_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm
EOT
3) as same non-root user, "rpm -ihv somepackage.src.rpm" -- it'll install
the spec file and all its source stuff into ~/rpmbuild/packagename/. You
can do the same "rpmbuild" command-line stuff as a non-root user from inside
that directory now.
The biggest advantage to doing the non-root thing is that some software
tries really hard to install itself into the system proper when you run some
of the build/install scripts, and when you build as a non-root user that
generates an error that you can then fix, instead of putting files on the
system that RPM doesn't know about that will cause you trouble later.
--
Eric Eisenhart
NBLUG Co-Founder
The North Bay Linux Users Group -- http://nblug.org/
eric at nblug.org, IRC: Freiheit at fn AIM: falschfreiheit
Jabber/XMPP/GTalk: freiheit at gmail.com
More information about the talk
mailing list