Difference between revisions of "RPM Packaging Process"
Chris Tyler (talk | contribs) (→Examining Existing SRPMs) |
Chris Tyler (talk | contribs) |
||
Line 1: | Line 1: | ||
+ | [[Category:SBR600]]{{Chris Tylers Draft}} | ||
RPM packages are built from the source files plus a spec file, using the ''rpmbuild'' program. | RPM packages are built from the source files plus a spec file, using the ''rpmbuild'' program. | ||
Line 48: | Line 49: | ||
rpmbuild --rebuild ''nameofpackage''*.src.rpm | rpmbuild --rebuild ''nameofpackage''*.src.rpm | ||
+ | |||
+ | This is useful when a no binary package is available for a particular platform or distribution version, but an SRPM is available. |
Revision as of 23:28, 10 January 2011
RPM packages are built from the source files plus a spec file, using the rpmbuild program.
Contents
Setting up the Packaging Environment
Needed Packages
Install with yum:
- rpm-build
- rpmdevtools
- rpmlint
- yum-utils
Setting up the RPM tree
The directories used by the rpm build tools can be defined as RPM macros. A script is provided in the rpmdevtools package to create a set of personal build directories and create the appropriate entries in the ~/.rpmmacros
file:
rpmdev-setuptree
The directories created are:
- ~/rpmbuild/SOURCES - for source code (tarballs/zip archives and patches)
- ~/rpmbuild/SPECS - for the spec file
- ~/rpmbuild/SRPMS - for the resulting source RPMs
- ~/rpmbuild/RPMS - for the resulting binary RPMs
- ~/rpmbuild/BUILD - directory used to perform the build
- ~/rpmbuild/BUILDROOT - contains a fake root directory into which the built files are "installed" prior to being packaged
Examining Existing SRPMs
A great place to start when learning to build RPMs is to examine some existing SRPMs.
- Download the source code for an existing RPM:
yumdownloader --source nameofpackage
- Install that downloaded SRPM:
rpm -i nameofpackage*.src.rpm
- Source will be in
~/rpmbuild/SOURCES
- Spec file will be in
~/rpmbuild/SPECS
- Source will be in
- Examine the specfile:
cd ~/rpmbuild/SPECS; less nameofpackage.spec
- To build from source using the specfile:
- Build all (binary RPMS plus SRPMS):
rpmbuild -ba nameofpackage.spec
- Build just the spec file:
rpmbuild -bs nameofpackage.spec
- Build all (binary RPMS plus SRPMS):
Rebuild from SRPMS
Instead of installing an SRPM and building from the spec file, it is possible to build the binary RPMs and SRPM directly from an SRPM:
rpmbuild --rebuild nameofpackage*.src.rpm
This is useful when a no binary package is available for a particular platform or distribution version, but an SRPM is available.