Installing SRPMS
Installing SRPMS
If you have the source CDs for CentOS Linux (you can download the source CD images from one of the sites listed on http://www.redhat.com/download/mirror.html), 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:
-
Mount the CD-ROM by typing mount
/mnt/cdromor waiting for GNOME desktop to mount the CD. -
Typically source RPMs would be in the SRPMS directory. Change to that directory by typing the following command:
cd /mnt/cdrom/SRPMS
-
Install the source RPM file by using the
rpm -icommand. For example, to install the Web server (httpd) source, typerpm -ivh httpd*.src.rpm
The files would be installed in the
/usr/src/redhat/SOURCESdirectory. A spec file with a.specextension would be placed in the/usr/src/redhat/SPECSdirectory. The spec file describes the software and also contains information that is used to build and install the software. -
Use the
rpmbuildcommand 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 withrpmbuildcommand. For example, to execute the instructions in the%prepsection of the spec file, type:rpmbuild -bp packagename.spec
where
packagenameis the name of the RPM. The%prepsection should typically unpack the source files. The unpacked source files appear in a subdirectory in the/usr/src/redhat/BUILDdirectory. 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 -bpmeans just run the%prepsection of the specfile. -
rpmbuild -blperforms a list check that expands the%filessection of a spec file and checks to see if all files exist. -
rpmbuild -bcexecutes the%buildsection after the%prep. This is equivalent to amakecommand that compiles the source code. -
rpmbuild -biperforms the%prep,%build, and then%install. This is equivalent to themake installcommand. -
rpmbuild -bbbuilds a binary package after completing the%prep,%build, and%installsections of the spec file. -
rpmbuild -babuilds both binary and source packages after completing the%prep,%build, and%installsections of the spec file.