Changes

Jump to: navigation, search

RPM Packaging Process

1,373 bytes added, 13:18, 17 July 2017
Setting up the Packaging Environment
[[Category:SBR600]][[Category:DPI908]][[Category:RPM]][[Category:SPO600]]
RPM packages are built from the source files plus a spec file, using the ''rpmbuild'' program.
== Needed Packages ==
Install with ''dnf'' (or ''yum''on older versions of Fedora):* rpm"Fedora Packager" (this is a group of packages -builduse "dnf groupinstall" or put an @ sign in front of the group name)
* rpmdevtools
* rpmlint
* yum-utils
 
{{Admon/tip|"Fedora Packager" group|Many of these tools can be installed at once by installing the "Fedora Packager" group: <code>yum groupinstall "Fedora Packager"</code>}}
== Setting up the RPM tree ==
# Download the source code for an existing RPM: <code>yumdownloader --source ''nameofpackage''</code>
# Install that downloaded SRPM(this does not require root access): <code>rpm -i ''nameofpackage''*.src.rpm</code>
#* Source will be in <code>~/rpmbuild/SOURCES</code>
#* Spec file will be in <code>~/rpmbuild/SPECS</code>
 
After installing the SRPM you can:
 
* Examine the specfile: <code>cd ~/rpmbuild/SPECS; less ''nameofpackage''.spec</code>
* To build Prep the sources (unpack tarballs, apply patches) to see the source code as it will be built: <code>rpmbuild -bp ''nameofpackage''.spec</code> # Results will be in <code>~/rpmbuild/BUILD/</code> (usually in a subdirectory named <code>''nameofpackage''-''version''</code>).* Build from source using the specfile:
*# Build all (binary RPMS plus SRPMS): <code>rpmbuild -ba ''nameofpackage''.spec</code>
*# Build just the spec file: <code>rpmbuild -bs ''nameofpackage''.spec</code>
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.
 
{{Admon/note|Building to Different Points|The <code>-ba</code> argument means "build all". You can substitute different values to build to different points in the process: <code>-bp</code> to build to the prep stage, <code>-bs</code> to build only a SRPM, and so forth. See the manpage for <rpmbuild" for details.}}
== 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</code>* Test the binary RPMs: <code>rpmlint ~/rpmbuild/RPMS/*/''packagename''*.rpm</code>
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.
* add the -i (information) option to the ''rpmlint'' command
* see the [[:fedora:Common Rpmlint issues|Fedora Common Rpmlint issues]] page on the Fedora wiki
 
= Common Challenges =
 
Refer to these documents on the Fedora wiki for help on specific packaging challenges:
* [[:fedora:Packaging:Guidelines|Packaging Guidelines]] - General packaging guidelines for Fedora, including instructions for specific languages and packaging cases
* [[:fedora:Packaging:ScriptletSnippets|Scriptlet Snippets]] - Script(lets) that can be used in RPM packages to solve specific problems
 
In particular, these sections are useful for GNU software:
* [[:fedora:Packaging:ScriptletSnippets#Texinfo|Packaging .info (texinfo) documentation files]]
* [[:fedora:Packaging:Guidelines#Handling_Locale_Files|Handling locale files (message translations)]]

Navigation menu