build

Charles R. Anderson cra at WPI.EDU
Fri Dec 5 17:09:49 UTC 2003


On Fri, Dec 05, 2003 at 10:38:07AM -0600, Wade Maxfield wrote:
>   However, I've never understood the RedHat build model.  I get the kernel 
> source and there are dozens of patch files.  HUH?  Do I need them?

Only if you want the bug and security fixes, feature enhancements,
backports, and additional drivers they provide.  RPM source packages
were designed to ship the original, unmodified source code, along with
patches needed or desired for the local build.

>   I gave up and downloaded the kernel from kernel.org and built. No 
> problems with the build, but the RedHat Tweaks were Gone.  I eventually 
> got something I could use, but this is not my day job.

The kernel is one of the hardest RPM packages to learn to modify.  I
suggest starting out with easier fish.  Red Hat provides a binary
package containing the fully Red Hat-patched kernel source code that
can be built in the normal way, outside of RPM packaging.  It is
called kernel-source-x.x.x.i386.rpm, and installs a kernel source tree
in /usr/src/linux-2.4.  There are steps that need to be followed,
however, to be sure this tree builds correctly:

http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/custom-guide/ch-custom-kernel.html

>   Is there a HOWTO anywhere that is RedHat specific that says if you do 
> (1), (2), (3), etc. you will get the original binary?

www.rpm.org would be a good start to look for documentation.

Reproducing a build from a src.rpm to get the original binaries is
usually as simple as:

rpmbuild --rebuild file.src.rpm

>   I need this to be for a dummy.  I've applied one source code patch about 
> two years ago and it was black magic at that time and appeared to work.  I 
> was able to look at the source code files and prove the patch made it in, 
> but I can't remember what I did to this day.

Patching, building, and packaging requires some knowledge of
programming, unfortunately.

>   Some of the things a dummy has a problem with are (1) where do the files 
> go, (2) how do I get the files out of the source code RPM once the source 
> code RPM has installed the files?  Let me explain.

When you do "rpm -i file.src.rpm" this is where things end up by 
default:

/usr/src/redhat/SOURCES - the source code tar files, patches, etc.

/usr/src/redhat/SPECS - the spec file (control script) that gives the 
steps for how to unpack, patch, build, and package the built files 
into an rpm package.

You can list the contents of a src.rpm to see what these tar, patch, 
and spec files are named:

rpm -qpvl file.src.rpm

>    I've seen source RPM's for RedHat which dump other files in a 
> directory, and they had to be untar'd to get the  source code files out.  
> At that point, I was unsure what directory Redhat built in, and could not 
> get a clean RedHat specific build from it. I may have, but I could not 
> prove it at that time.

If you instead "rpm -i file.src.rpm", you can rebuild the binaries by
doing:

rpmbuild -bb file.spec

or build BOTH the binary and source rpm packages by doing:

rpmbuild -ba file.spec

from the SPECS directory.  This executes the steps in the spec file,
which unpack (%prep), build (%build), install to a temporary directory
called a buildroot (%install), and package the files (%files) into the
final binary rpm package(s).  The sections of a spec file are simply
shell script fragments, optionally using RPM macros.

In either case, the build happens in /usr/src/redhat/BUILD, and the
resulting packaged files end up in /usr/src/redhat/RPMS.

There are ways, BTW, to change these default locations so you can
build as non-root in your home directory, for example.





More information about the fedora-legacy-list mailing list