This is an introduction and basic usage for RPM packaging, reading upstream docs if you want more.
RPM is an packaging system for Linux distros. besides Red Hat’ Fedora, RHEL, CentOS, many other important distros also using RPM package system, include but not limited: openSuSE, Turbo Linux, openEuler, etc.
RPM using spec file to describe a package’s preparation, compilation, and packaging process.
Each section indicates a step to compile source code to an RPM package, below is an example:
|%prep||%_sourcedir||%_builddir||prepare source in for compiling in %_builddir with tarball, patch stored in %_sourcedir|
|%build||%_builddir||%_builddir||compile in %_builddir with configure, make or other similar operation to generate binaries|
|%install||%_builddir||%_buildrootdir||install binaries to %_buildrootdir|
|%check||%_builddir||%_builddir||check binaries with test program in source, can be skipped|
|%files||%_buildrootdir||%_rpmdir or %_srpmdir||files in %_builddir will be packaged to RPM or SRPM pacakge|
RPM package tools:
Using rpmdevtools command
rpmdev-setuptree to generate a standard RPM packaging tree.
default location is ~/rpmbuild and structure as below:
rpmbuild ├── BUILD ├── RPMS ├── SOURCES ├── SPECS └── SRPMS
Install a SRPM package with command
rpm, will create this tree, too.
spec file default in SPECS sub directory
Source code tarball and patches or other files used in building process, will be put in SOURCES, all files should be declared in SPEC file.
After prepared all files and spec file, using
rpmbuild to run package process
rpmbuild -bs ~/rpmbuild/SPECS/my.spec
rpmbuild -bb ~/rpmbuild/SPECS/my.spec
rpmbuild -ba ~/rpmbuild/SPECS/my.spec
rpmbuild will generate directories and packages under
~/rpmbuild/RPMS when everything is okay.
The dependency requirement may be different in deferent root file system, so a ‘clean’ root filessystem for package is necessary. mock is the tool to create the ‘clean filesystem’. mock is used in many distros.
Using mock to create package, is similar to rpmbuild as below:
mock -r distro-config-file --rebuild --spec=spec-file --sources=source-dir
Read mock documentation to get more of mock.
Distributions or third party communities such as oepkgs.net will provide computing resources to create RPM packages for distributes.
Copyright © oepkgs.net All rights reserved.
版权所有 © oepkgs.net 保留所有权利