Installing SRPMS

Installing SRPMS

If you have the source CDs for Red Hat Linux (you can download the source CD images from one of the sites listed on, you can install the source files and build various applications directly from the source files. Red Hat provides the sources files in RPMs and these RPMs are generally known as SRPMS (for source RPMs).

To install a specific source RPM and build the application, follow these steps:

  1. Mount the CD-ROM by typing mount /mnt/cdrom or waiting for GNOME desktop to mount the CD.

  2. Typically source RPMs would be in the SRPMS directory. Change to that directory by typing the following command:

    cd /mnt/cdrom/SRPMS
  3. Install the source RPM file by using the rpm -i command. For example, to install the Web server (httpd) source, type

    rpm -ivh httpd*.src.rpm

    The files would be installed in the /usr/src/redhat/SOURCES directory. A spec file with a .spec extension would be placed in the /usr/src/redhat/SPECS directory. The spec file describes the software and also contains information that is used to build and install the software.

  4. Use the rpmbuild command with the spec file to build the software. You perform different tasks from unpacking the source files to building and installing the binaries by using different options with rpmbuild command. For example, to execute the instructions in the %prep section of the spec file, type:

    rpmbuild -bp packagename.spec

    where packagename is the name of the RPM. The %prep section should typically unpack the source files. The unpacked source files appear in a subdirectory in the /usr/src/redhat/BUILD directory. The subdirectory usually has the name of the software package, including a version number.

    If you want to run the whole spec file, type:

    rpmbuild -ba packagename.spec

    This command should typically build the software and install the binary files,

A number of single-letter options that go with -b are very useful. Here is a summary of these rpmbuild -b options:

  • rpmbuild -bp means just run the %prep section of the specfile.

  • rpmbuild -bl performs a list check that expands the %files section of a spec file and checks to see if all files exist.

  • rpmbuild -bc executes the %build section after the %prep. This is equivalent to a make command that compiles the source code.

  • rpmbuild -bi performs the %prep, %build, and then %install. This is equivalent to the make install command.

  • rpmbuild -bb builds a binary package after completing the %prep, %build, and %install sections of the spec file.

  • rpmbuild -ba builds both binary and source packages after completing the %prep, %build, and %install sections of the spec file.