Open main menu

CDOT Wiki β

Changes

RPM Packaging Process

3,132 bytes added, 08:23, 13 January 2011
no edit summary
{{Admon/caution|Do Not Build as Root|Always build RPM packages as a regular, non-root user. Building as a root user is unnecessary and may cause unintended side effects, including damaging your system.}}
 
= Resources =
 
* [[:fedora:PackageMaintainers|Fedora Package Maintainers page]]
** [[:fedora:PackageMaintainers/CreatingPackageHowTo|Packaging How-To]]
* ''Fedora Linux'' chapter 5 (see Seneca Library website > eBooks > View All > Safari > Fedora Linux).
* rpmlint
** [[:fedora:Common Rpmlint issues|Fedora Common Rpmlint issues]]
= Setting up the Packaging Environment =
* ~/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
 
== Wiping out the RPM tree ==
 
{{Admon/important|Wiping the Tree Deletes Data|Be sure to save any files you need from your previous build activity before wiping the tree.}}
 
When switching to a new package, it is customary to wipe out the ''rpmbuild'' tree to avoid clutter: <code>rpmdev-wipetree</code>
= Examining Existing SRPMs =
This is useful when a no binary package is available for a particular platform or distribution version, but an SRPM is available.
 
= Creating a New Package =
 
== Writing a specfile ==
 
# Run <code>rpmdev-newspec ''packagename''</code> in ~/rpmbuild/SPECS
# Edit the skeleton specfile. Refer to the [[:fedora:PackageMaintainers/CreatingPackageHowTo|Packaging How-To]] for guidance.
 
== Building the RPM ==
 
# <code>rpmbuild -ba ''packagename''.spec</code>
#* If successful, output will be binary RPM(s) in <code>~/rpmbuild/RPMS</code> and source RPM in <code>~/rpmbuild/SRPMS</code>
#** You can install binary RPM as root using this command: <code>rpm -i ''rpmfile''</code> or <code>yum localinstall ''rpmfile''</code>
#* If unsuccessful, read the error messages carefully.
 
Note that a successful build of a compiled binary will usually produce both a binary RPM and a ''debuginfo'' RPM. The debuginfo package contains additional information which is useful for debugging a problem, but which just takes up space when the program is being used normally.
 
Some spec files may produce multiple packages -- for example, they may produce separate packages for a game, game data, and documentation; or for a base package and additional plugins for use with that package; or for a base package and multiple user interfaces (such as separate command-line, graphical, and web interfaces). This is done at the discretion of the spec file author where she decides that the user may want to install a subset of the package's features.
 
== Testing the RPM ==
 
The ''rpmlint'' tool tests spec files, source RPMs, and binary RPMs to verify that they were created in compliance with the Fedora packaging guidelines.
* Test the spec file: <code>rpmlint ~/rpmbuild/SPECS/''packagename''*</code>
* Test the source RPM: <code>rpmlint ~/rpmbuild/SRPMS/''packagename''*.src.rpm
* Test the binary RPMs: <code>rpmlint ~/rpmbuild/RPMS/*/''packagename''*.rpm
 
Notice that the checks performed vary based on the input file. For example, some errors in the spec file (such as the summary ending in a period ".") could be determined from the spec file, but only show up when the SRPM/RPM is checked. Each run will report the number of errors and warnings; errors are serious problems which should not be ignored, while warnings may be ignored depending on the context.
 
If you discover any errors, edit the specfile to correct them. If you need additional information on the error:
* add the <code>-i</code> (information) option to the ''rpmlint'' command
* see the [[:fedora:Common Rpmlint issues|Fedora Common Rpmlint issues]] page on the Fedora wiki