RPM Build
References:
- https://fedoraproject.org/wiki/How_to_create_an_RPM_package
- https://fedoraproject.org/wiki/Packaging:Guidelines
Build Environment Setup
Create a dedicated build user. Never build RPMs as root.
Install the required tools:
| |
Login as the build user and set up the build tree:
| |
This creates the standard ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} directory structure.
Working with Existing Source Packages
Download an existing source RPM and install it into your build tree:
Building from a Spec File
| |
You will likely encounter missing build dependencies. Install them as needed. The dnf builddep command can handle this automatically:
| |
Adding Custom Modules
When adding third-party modules to an existing package, you need to:
- Download the module source tarballs into
~/rpmbuild/SOURCES/ - Add
Sourceentries to the spec file pointing to the tarballs - Add any new
BuildRequiresandRequiresdependencies - Add
%setuplines after the main%setup -qto extract the additional sources:- Use
-Tto prevent re-extracting the original tarball - Use
-Dto preserve existing directories - Use
-a Nwhere N is the source number - Use
-n dirnameto set the expected directory name
- Use
- Add
--add-module=./module-dirflags to the./configureinvocation in the%buildsection
Signing Packages
RPM packages can be signed with a GPG key to verify their authenticity. First set the signing key in your ~/.rpmmacros:
%_signature gpg
%_gpg_name Your Name <[email protected]>Then sign packages with:
| |