Questo contenuto non è disponibile nella lingua selezionata.
Chapter 5. Packaging software
In the following sections, learn the basics of the packaging process with the RPM package manager.
5.1. About spec files Copia collegamentoCollegamento copiato negli appunti!
A spec file is a file with instructions that the rpmbuild utility uses to build an RPM package. This file provides necessary information to the build system by defining instructions in a series of sections. These sections are defined in the Preamble and the Body part of the spec file:
- The Preamble section contains a series of metadata items that are used in the Body section.
- The Body section represents the main part of the instructions.
5.1.1. Preamble items Copia collegamentoCollegamento copiato negli appunti!
The following are some of the directives that you can use in the Preamble section of the RPM spec file.
| Directive | Definition |
|---|---|
|
|
A base name of the package that must match the |
|
| An upstream version number of the software. |
|
| The number of times the version of the package was released.
Set the initial value to |
|
| A brief one-line summary of the package. |
|
| A license of the software being packaged.
The exact format for how to label the |
|
| A full URL for more information about the software, for example, an upstream project website for the software being packaged. |
|
| A path or URL to the compressed archive of the unpatched upstream source code. This link must point to an accessible and reliable storage of the archive, for example, the upstream page, not the packager’s local storage.
You can define multiple |
|
| A name of the first patch to apply to the source code, if necessary.
You can apply the
You can apply the patches individually by using the |
|
| An architecture that the software will be built for.
If the software is not architecture-dependent, for example, if you wrote the software entirely in an interpreted programming language, set the value to |
|
|
A comma- or whitespace-separated list of packages required to build the program written in a compiled language. There can be multiple entries of |
|
|
A comma- or whitespace-separated list of packages required by the software to run once installed. There can be multiple entries of |
|
|
If a piece of software cannot operate on a specific processor architecture, you can exclude this architecture in the |
|
|
A comma- or whitespace-separated list of packages that must not be installed on the system in order for your software to function properly when installed. There can be multiple entries of |
|
|
The
|
|
|
If you add the |
The Name, Version, and Release (NVR) directives comprise the file name of the RPM package in the name-version-release format.
You can display the NVR information for a specific package by querying RPM database by using the rpm command, for example:
rpm -q bash
# rpm -q bash
bash-4.4.19-7.el9.x86_64
Here, bash is the package name, 4.4.19 is the version, and 7.el9 is the release. The x86_64 marker is the package architecture. Unlike NVR, the architecture marker is not under direct control of the RPM packager, but is defined by the rpmbuild build environment. The exception to this is the architecture-independent noarch package.
5.1.2. Body items Copia collegamentoCollegamento copiato negli appunti!
The following are the items used in the Body section of the RPM spec file.
| Directive | Definition |
|---|---|
|
| A full description of the software packaged in the RPM. This description can span multiple lines and can be broken into paragraphs. |
|
|
A command or series of commands to prepare the software for building, for example, for unpacking the archive in the |
|
| A command or series of commands for building the software into machine code (for compiled languages) or bytecode (for some interpreted languages). |
|
|
A command or series of commands that the
The
Note that |
|
| A command or series of commands for testing the software, for example, unit tests. |
|
| A list of files, provided by the RPM package, to be installed in the user’s system and their full path location on the system.
During the build, if there are files in the
Within the |
|
|
A record of changes that happened to the package between different |
5.1.3. Advanced items Copia collegamentoCollegamento copiato negli appunti!
A spec file can contain advanced items, such as Scriptlets or Triggers.
Scriptlets and Triggers take effect at different points during the installation process on the end user’s system, not the build process.
5.2. BuildRoots Copia collegamentoCollegamento copiato negli appunti!
In the context of RPM packaging, buildroot is a chroot environment. The build artifacts are placed here by using the same file system hierarchy as the future hierarchy in the end user’s system, with buildroot acting as the root directory. The placement of build artifacts must comply with the file system hierarchy standard of the end user’s system.
The files in buildroot are later put into a cpio archive, which becomes the main part of the RPM. When RPM is installed on the end user’s system, these files are extracted in the root directory, preserving the correct hierarchy.
The rpmbuild program has its own defaults. Overriding these defaults can cause certain issues. Therefore, avoid defining your own value of the buildroot macro. Use the default %{buildroot} macro instead.
5.3. RPM macros Copia collegamentoCollegamento copiato negli appunti!
An rpm macro is a straight text substitution that can be conditionally assigned based on the optional evaluation of a statement when certain built-in functionality is used. Therefore, RPM can perform text substitutions for you.
For example, you can define Version of the packaged software only once in the %{version} macro, and use this macro throughout the spec file. Every occurrence is automatically substituted by Version that you defined in the macro.
If you see an unfamiliar macro, you can evaluate it with the following command:
rpm --eval %{MACRO}
$ rpm --eval %{MACRO}
For example, to evaluate the %{_bindir} and %{_libexecdir} macros, enter:
rpm --eval %{_bindir}
rpm --eval %{_libexecdir}
$ rpm --eval %{_bindir}
/usr/bin
$ rpm --eval %{_libexecdir}
/usr/libexec
5.4. Working with spec files Copia collegamentoCollegamento copiato negli appunti!
To package new software, you must create a spec file. You can create the spec file either of the following ways:
-
Write the new
specfile manually from scratch. -
Use the
rpmdev-newspecutility. This utility creates an unpopulatedspecfile, where you fill the necessary directives and fields.
Some programmer-focused text editors pre-populate a new spec file with their own spec template. The rpmdev-newspec utility provides a method that does not depend on a text editor..
5.4.1. Creating a new spec file for sample Bash, Python, and C programs Copia collegamentoCollegamento copiato negli appunti!
You can create a spec file for each of the three implementations of the Hello World! program by using the rpmdev-newspec utility.
Prerequisites
The following
Hello World!program implementations were placed into the~/rpmbuild/SOURCESdirectory:
Procedure
Navigate to the
~/rpmbuild/SPECSdirectory:cd ~/rpmbuild/SPECS
$ cd ~/rpmbuild/SPECSCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
specfile for each of the three implementations of theHello World!program:Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantWhen packaging a Python project into RPM, always add the
python-prefix to the original name of the project. The project name here isPelloand, therefore, the name of thespecispython-pello.The
~/rpmbuild/SPECS/directory now contains threespecfiles namedbello.spec,cello.spec, andpython-pello.spec.Examine the created files.
The directives in the files represent those described in About spec files. In the following sections, you will populate particular section in the output files of
rpmdev-newspec.
5.4.2. Modifying an original spec file Copia collegamentoCollegamento copiato negli appunti!
The original output spec file generated by the rpmdev-newspec utility represents a template that you must modify to provide necessary instructions for the rpmbuild utility. rpmbuild then uses these instructions to build an RPM package.
Prerequisites
-
The unpopulated
~/rpmbuild/SPECS/<name>.specspecfile was created by using therpmdev-newspecutility. For more information, see Creating a new spec file for sample Bash, Python, and C programs.
Procedure
-
Open the
~/rpmbuild/SPECS/<name>.specfile provided by therpmdev-newspecutility. Populate the following directives of the
specfile Preamble section:Name-
Namewas already specified as an argument torpmdev-newspec. Version-
Set
Versionto match the upstream release version of the source code. Release-
Releaseis automatically set to1%{?dist}, which is initially1. Summary- Enter a one-line explanation of the package.
License- Enter the software license associated with the source code.
URL-
Enter the URL to the upstream software website. For consistency, utilize the
%{name}RPM macro variable and use thehttps://example.com/%{name}format. SourceEnter the URL to the upstream software source code. Link directly to the software version being packaged.
NoteThe example URLs in this documentation include hard-coded values that could possibly change in the future. Similarly, the release version can change as well. To simplify these potential future changes, use the
%{name}and%{version}macros. By using these macros, you need to update only one field in thespecfile.BuildRequires- Specify build-time dependencies for the package.
Requires- Specify run-time dependencies for the package.
BuildArch- Specify the software architecture.
Populate the following directives of the
specfile Body section. You can think of these directives as section headings, because these directives can define multi-line, multi-instruction, or scripted tasks to occur.%description- Enter the full description of the software.
%prep- Enter a command or series of commands to prepare software for building.
%build- Enter a command or series of commands for building software.
%install-
Enter a command or series of commands that instruct the
rpmbuildcommand on how to install the software into theBUILDROOTdirectory. %files- Specify the list of files, provided by the RPM package, to be installed on your system.
%changelogEnter the list of datestamped entries for each
Version-Releaseof the package.Start the first line of the
%changelogsection with an asterisk (*) character followed byDay-of-Week Month Day Year Name Surname <email> - Version-Release.For the actual change entry, follow these rules:
- Each change entry can contain multiple items, one for each change.
- Each item starts on a new line.
-
Each item begins with a hyphen (
-) character.
You have now written an entire spec file for the required program.
5.4.3. An example spec file for a sample Bash program Copia collegamentoCollegamento copiato negli appunti!
You can use the following example spec file for the bello program written in bash for your reference.
An example spec file for the program written in bash
-
The
BuildRequiresdirective, which specifies build-time dependencies for the package, was deleted because there is no building step forbello. Bash is a raw interpreted programming language, and the files are just installed to their location on the system. -
The
Requiresdirective, which specifies run-time dependencies for the package, includes onlybash, because thebelloscript requires only thebashshell environment to execute. -
The
%autosetupmacro unpacks the source archive, referred to by theSource0directive, and changes to it. -
The
%buildsection, which specifies how to build the software, is blank, because thebashscript does not need to be built.
To install bello, you must create the destination directory and install the executable bash script file there. Therefore, you can use the install command in the %install section. You can use RPM macros to do this without hardcoding paths.
5.4.4. An example spec file for a program written in Python Copia collegamentoCollegamento copiato negli appunti!
You can use the following example spec file for the pello program written in the Python programming language for your reference.
An example spec file for the program written in Python
- 1
- By defining the
python3_pkgversionmacro, you set which Python version this package will be built for. To build for the default Python version 3.9, either set the macro to its default value3or remove the line entirely. - 2
- When packaging a Python project into RPM, always add the
python-prefix to the original name of the project. The original name here ispelloand, therefore, the name of the Source RPM (SRPM) ispython-pello. - 3
- The
BuildRequiresdirective specifies what packages are required to build and test this package. InBuildRequires, always include items providing tools necessary for building Python packages:python3-devel(orpython3.11-develorpython3.12-devel) and the relevant packages needed by the specific software that you package, for example,python3-setuptools(orpython3.11-setuptoolsorpython3.12-setuptools) or the runtime and testing dependencies needed to run the tests in the%checksection. - 4
- When choosing a name for the binary RPM (the package that users will be able to install), add a versioned Python prefix. Use the
python3-prefix for the default Python 3.9, thepython3.11-prefix for Python 3.11, or thepython3.12-prefix for Python 3.12. You can use the%{python3_pkgversion}macro, which evaluates to3for the default Python version 3.9 unless you set it to an explicit version, for example,3.11(see footnote 1). - 5
- The
%py3_buildand%py3_installmacros run thesetup.py buildandsetup.py installcommands, respectively, with additional arguments to specify installation locations, the interpreter to use, and other details. - 6
- The
%checksection should run the tests of the packaged project. The exact command depends on the project itself, but it is possible to use the%pytestmacro to run thepytestcommand in an RPM-friendly way.
5.4.5. An example spec file for a sample C program Copia collegamentoCollegamento copiato negli appunti!
You can use the following example spec file for the cello program that was written in the C programming language for your reference.
An example spec file for the program written in C
The
BuildRequiresdirective, which specifies build-time dependencies for the package, includes the following packages required to perform the compilation build process:-
gcc -
make
-
-
The
Requiresdirective, which specifies run-time dependencies for the package, is omitted in this example. All runtime requirements are handled byrpmbuild, and thecelloprogram does not require anything outside of the core C standard libraries. -
The
%autosetupmacro unpacks the source archive, referred to by theSource0directive, and changes to it. -
The
%buildsection reflects that in this example, theMakefilefile for the cello program was written. Therefore, you can use the GNU make command. However, you must remove the call to%configurebecause you did not provide a configure script.
You can install the cello program by using the %make_install macro. This is possible because the Makefile file for the cello program is available.
5.5. Building RPMs Copia collegamentoCollegamento copiato negli appunti!
You can build RPM packages by using the rpmbuild command. When using this command, a certain directory and file structure is expected, which is the same as the structure that was set up by the rpmdev-setuptree utility.
Different use cases and desired outcomes require different combinations of arguments to the rpmbuild command. The following are the main use cases:
- Building source RPMs.
Building binary RPMs:
- Rebuilding a binary RPM from a source RPM.
-
Building a binary RPM from the
specfile.
5.5.1. Building source RPMs Copia collegamentoCollegamento copiato negli appunti!
Building a Source RPM (SRPM) has the following advantages:
-
You can preserve the exact source of a certain
Name-Version-Releaseof an RPM file that was deployed to an environment. This includes the exactspecfile, the source code, and all relevant patches. This is useful for tracking and debugging purposes. - You can build a binary RPM on a different hardware platform or architecture.
Prerequisites
You have installed the
rpmbuildutility on your system:dnf install rpm-build
# dnf install rpm-buildCopy to Clipboard Copied! Toggle word wrap Toggle overflow The following
Hello World!implementations were placed into the~/rpmbuild/SOURCES/directory:-
A
specfile for the program that you want to package exists.
Procedure
Navigate to the
~/rpmbuild/SPECS/directive, which contains the createdspecfile:cd ~/rpmbuild/SPECS/
$ cd ~/rpmbuild/SPECS/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Build the source RPM by entering the
rpmbuildcommand with the specifiedspecfile:rpmbuild -bs <specfile>
$ rpmbuild -bs <specfile>Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
-bsoption stands for build source.For example, to build source RPMs for the
bello,pello, andcelloprograms, enter:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
-
Verify that the
rpmbuild/SRPMSdirectory includes the resulting source RPMs. The directory is a part of the structure expected byrpmbuild.
5.5.2. Rebuilding a binary RPM from a source RPM Copia collegamentoCollegamento copiato negli appunti!
To rebuild a binary RPM from a source RPM (SRPM), use the rpmbuild command with the --rebuild option.
The output generated when creating the binary RPM is verbose, which is helpful for debugging. The output varies for different examples and corresponds to their spec files.
The resulting binary RPMs are located in the ~/rpmbuild/RPMS/YOURARCH directory, where YOURARCH is your architecture, or in the ~/rpmbuild/RPMS/noarch/ directory, if the package is not architecture-specific.
Prerequisites
You have installed the
rpmbuildutility on your system:dnf install rpm-build
# dnf install rpm-buildCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Procedure
Navigate to the
~/rpmbuild/SRPMS/directive, which contains the source RPM:cd ~/rpmbuild/SRPMS/
$ cd ~/rpmbuild/SRPMS/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Rebuild the binary RPM from the source RPM:
rpmbuild --rebuild <srpm>
$ rpmbuild --rebuild <srpm>Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example, to rebuild
bello,pello, andcellofrom their SRPMs, enter:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Invoking rpmbuild --rebuild involves the following processes:
-
Installing the contents of the SRPM (the
specfile and the source code) into the~/rpmbuild/directory. - Building an RPM by using the installed contents.
-
Removing the
specfile and the source code.
You can retain the spec file and the source code after building either of the following ways:
-
When building the RPM, use the
rpmbuildcommand with the--recompileoption instead of the--rebuildoption. Install SRPMs for
bello,python-pello, andcello:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.5.3. Building a binary RPM from the spec file Copia collegamentoCollegamento copiato negli appunti!
To build a binary RPM from its spec file, use the rpmbuild command with the -bb option. The -bb option stands for build binary.
Prerequisites
You have installed the
rpmbuildutility on your system:dnf install rpm-build
# dnf install rpm-buildCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Procedure
Navigate to the
~/rpmbuild/SPECS/directive, which containsspecfiles:cd ~/rpmbuild/SPECS/
$ cd ~/rpmbuild/SPECS/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Build the binary RPM from its
spec:rpmbuild -bb <spec_file>
$ rpmbuild -bb <spec_file>Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example, to build
bello,pello, andcellobinary RPMs from theirspecfiles, enter:rpmbuild -bb bello.spec rpmbuild -bb python-pello.spec rpmbuild -bb cello.spec
$ rpmbuild -bb bello.spec $ rpmbuild -bb python-pello.spec $ rpmbuild -bb cello.specCopy to Clipboard Copied! Toggle word wrap Toggle overflow
5.6. Checking RPMs for common errors Copia collegamentoCollegamento copiato negli appunti!
After creating a package, you might want to check the quality of the package. The main tool for checking package quality is rpmlint.
With the rpmlint tool, you can perform the following actions:
- Improve RPM maintainability.
- Enable content validation by performing static analysis of the RPM.
- Enable error checking by performing static analysis of the RPM.
You can use rpmlint to check binary RPMs, source RPMs (SRPMs), and spec files. Therefore, this tool is useful for all stages of packaging.
Note that rpmlint has strict guidelines. Therefore, it is sometimes acceptable to skip some of its errors and warnings as shown in the following sections.
In the examples described in the following sections, rpmlint is run without any options, which produces a non-verbose output. For detailed explanations of each error or warning, run rpmlint -i instead.
5.6.1. Checking a sample Bash program for common errors Copia collegamentoCollegamento copiato negli appunti!
In the following sections, investigate possible warnings and errors that can occur when checking an RPM for common errors on the example of the bello spec file, bello SRPM, and bello binary RPM.
5.6.1.1. Checking the bello spec file for common errors Copia collegamentoCollegamento copiato negli appunti!
Inspect the outputs of the following examples to learn how to check a bello spec file for common errors.
Output of running the rpmlint command on the bello spec file
rpmlint bello.spec
$ rpmlint bello.spec
bello.spec: W: invalid-url Source0: https://www.example.com/bello/releases/bello-0.1.tar.gz HTTP Error 404: Not Found
0 packages and 1 specfiles checked; 0 errors, 1 warnings.
For bello.spec, there is only one invalid-url Source0 warning. This warning means that the URL listed in the Source0 directive is unreachable. This is expected, because the specified example.com URL does not exist. Assuming that this URL will be valid in the future, you can ignore this warning.
5.6.1.2. Checking the bello SRPM for common errors Copia collegamentoCollegamento copiato negli appunti!
Inspect the outputs of the following examples to learn how to check a bello source RPM (SRPM) for common errors.
Output of running the rpmlint command on the bello SRPM
rpmlint ~/rpmbuild/SRPMS/bello-0.1-1.el9.src.rpm
$ rpmlint ~/rpmbuild/SRPMS/bello-0.1-1.el9.src.rpm
bello.src: W: invalid-url URL: https://www.example.com/bello HTTP Error 404: Not Found
bello.src: W: invalid-url Source0: https://www.example.com/bello/releases/bello-0.1.tar.gz HTTP Error 404: Not Found
1 packages and 0 specfiles checked; 0 errors, 2 warnings.
For the bello SRPM, there is the invalid-url URL warning that means that the URL specified in the URL directive is unreachable. Assuming that this URL will be valid in the future, you can ignore this warning.
5.6.1.3. Checking the bello binary RPM for common errors Copia collegamentoCollegamento copiato negli appunti!
When checking binary RPMs, the rpmlint command checks the following items:
- Documentation
- Manual pages
- Consistent use of the filesystem hierarchy standard
Inspect the outputs of the following example to learn how to check a bello binary RPM for common errors.
Output of running the rpmlint command on the bello binary RPM
rpmlint ~/rpmbuild/RPMS/noarch/bello-0.1-1.el9.noarch.rpm
$ rpmlint ~/rpmbuild/RPMS/noarch/bello-0.1-1.el9.noarch.rpm
bello.noarch: W: invalid-url URL: https://www.example.com/bello HTTP Error 404: Not Found
bello.noarch: W: no-documentation
bello.noarch: W: no-manual-page-for-binary bello
1 packages and 0 specfiles checked; 0 errors, 3 warnings.
The no-documentation and no-manual-page-for-binary warnings mean that the RPM has no documentation or manual pages, because you did not provide any. Apart from the output warnings, the RPM passed rpmlint checks.
5.6.2. Checking a sample Python program for common errors Copia collegamentoCollegamento copiato negli appunti!
In the following sections, investigate possible warnings and errors that can occur when checking an RPM for common errors on the example of the pello spec file, pello SRPM, and pello binary RPM.
5.6.2.1. Checking the pello spec file for common errors Copia collegamentoCollegamento copiato negli appunti!
Inspect the outputs of the following examples to learn how to check a pello spec file for common errors.
Output of running the rpmlint command on the pello spec file
rpmlint python-pello.spec
$ rpmlint python-pello.spec
0 packages and 1 specfiles checked; 0 errors, 0 warnings.
For the python-pello spec file, the rpmlint utility detected zero errors or warnings, which means that the file was composed correctly.
For packages going into production, make sure to properly check the spec file for errors and warnings.
5.6.2.2. Checking the pello SRPM for common errors Copia collegamentoCollegamento copiato negli appunti!
Inspect the outputs of the following examples to learn how to check a pello source RPM (SRPM) for common errors.
Output of running the rpmlint command on the SRPM for pello
rpmlint ~/rpmbuild/SRPMS/python-pello-1.0.2-1.el9.src.rpm
$ rpmlint ~/rpmbuild/SRPMS/python-pello-1.0.2-1.el9.src.rpm
python-pello.src: E: description-line-too-long C Pello is an example package with an executable that prints Hello World! on the command line.
1 packages and 0 specfiles checked; 1 errors, 0 warnings.
The description-line-too-long error means that the description you provided exceeded the allowed number of characters.
Apart from the output error, the SRPM passed rpmlint checks.
5.6.2.3. Checking the pello binary RPM for common errors Copia collegamentoCollegamento copiato negli appunti!
When checking binary RPMs, the rpmlint command checks the following items:
- Documentation
- Manual pages
- Consistent use of the Filesystem Hierarchy Standard
Inspect the outputs of the following example to learn how to check a pello binary RPM for common errors.
Output of running the rpmlint command on the pello binary RPM
rpmlint ~/rpmbuild/RPMS/noarch/python3.12-pello-1.0.2-1.el9.noarch.rpm
$ rpmlint ~/rpmbuild/RPMS/noarch/python3.12-pello-1.0.2-1.el9.noarch.rpm
pello-1.0.2-1.el9.noarch.rpm
python3.12-pello.noarch: E: description-line-too-long C Pello is an example package with an executable that prints Hello World! on the command line.
python3.12-pello.noarch: W: no-manual-page-for-binary pello_greeting
1 packages and 0 specfiles checked; 2 errors, 1 warnings.
-
The
no-manual-page-for-binarywarning means that the RPM has no manual pages because you did not provide any. -
The
description-line-too-longerror means that the description you provided exceeded the allowed number of characters.
Apart from the output warnings and errors, the RPM passed rpmlint checks.
5.6.3. Checking a sample C program for common errors Copia collegamentoCollegamento copiato negli appunti!
In the following sections, investigate possible warnings and errors that can occur when checking an RPM for common errors on the example of the cello spec file, cello SRPM, and cello binary RPM.
5.6.3.1. Checking the cello spec file for common errors Copia collegamentoCollegamento copiato negli appunti!
Inspect the outputs of the following examples to learn how to check a cello spec file for common errors.
Output of running the rpmlint command on the cello spec file
rpmlint ~/rpmbuild/SPECS/cello.spec
$ rpmlint ~/rpmbuild/SPECS/cello.spec
/home/admiller/rpmbuild/SPECS/cello.spec: W: invalid-url Source0: https://www.example.com/cello/releases/cello-1.0.tar.gz HTTP Error 404: Not Found
0 packages and 1 specfiles checked; 0 errors, 1 warnings.
For cello.spec, there is only one invalid-url Source0 warning. This warning means that the URL listed in the Source0 directive is unreachable. This is expected because the specified example.com URL does not exist. Assuming that this URL will be valid in the future, you can ignore this warning.
5.6.3.2. Checking the cello SRPM for common errors Copia collegamentoCollegamento copiato negli appunti!
Inspect the outputs of the following examples to learn how to check a cello source RPM (SRPM) for common errors.
Output of running the rpmlint command on the cello SRPM
rpmlint ~/rpmbuild/SRPMS/cello-1.0-1.el9.src.rpm
$ rpmlint ~/rpmbuild/SRPMS/cello-1.0-1.el9.src.rpm
cello.src: W: invalid-url URL: https://www.example.com/cello HTTP Error 404: Not Found
cello.src: W: invalid-url Source0: https://www.example.com/cello/releases/cello-1.0.tar.gz HTTP Error 404: Not Found
1 packages and 0 specfiles checked; 0 errors, 2 warnings.
For the cello SRPM, there is the invalid-url URL warning. This warning means that the URL specified in the URL directive is unreachable. Assuming that this URL will be valid in the future, you can ignore this warning.
5.6.3.3. Checking the cello binary RPM for common errors Copia collegamentoCollegamento copiato negli appunti!
When checking binary RPMs, the rpmlint command checks the following items:
- Documentation
- Manual pages
- Consistent use of the filesystem hierarchy standard
Inspect the outputs of the following example to learn how to check a cello binary RPM for common errors.
Output of running the rpmlint command on the cello binary RPM
rpmlint ~/rpmbuild/RPMS/x86_64/cello-1.0-1.el9.x86_64.rpm
$ rpmlint ~/rpmbuild/RPMS/x86_64/cello-1.0-1.el9.x86_64.rpm
cello.x86_64: W: invalid-url URL: https://www.example.com/cello HTTP Error 404: Not Found
cello.x86_64: W: no-documentation
cello.x86_64: W: no-manual-page-for-binary cello
1 packages and 0 specfiles checked; 0 errors, 3 warnings.
The no-documentation and no-manual-page-for-binary warnings mean that the RPM has no documentation or manual pages because you did not provide any.
Apart from the output warnings, the RPM passed rpmlint checks.
5.7. Logging RPM activity to syslog Copia collegamentoCollegamento copiato negli appunti!
You can log any RPM activity or transaction by using the System Logging protocol (syslog).
Prerequisites
The
syslogplug-in is installed on the system:dnf install rpm-plugin-syslog
# dnf install rpm-plugin-syslogCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe default location for the
syslogmessages is the/var/log/messagesfile. However, you can configuresyslogto use another location to store the messages.
Procedure
Open the file that you configured to store the
syslogmessages.Alternatively, if you use the default
syslogconfiguration, open the/var/log/messagesfile.-
Search for new lines including the
[RPM]string.
5.8. Extracting RPM content Copia collegamentoCollegamento copiato negli appunti!
In some cases, for example, if a package required by RPM is damaged, you might need to extract the content of the package. In such cases, if an RPM installation is still working despite the damage, you can use the rpm2archive utility to convert an .rpm file to a tar archive to use the content of the package.
If the RPM installation is severely damaged, you can use the rpm2cpio utility to convert the RPM package file to a cpio archive.
Procedure
Convert the RPM file to the tar archive:
rpm2archive <filename>.rpm
$ rpm2archive <filename>.rpmCopy to Clipboard Copied! Toggle word wrap Toggle overflow The resulting file has the
.tgzsuffix. For example, to create an archive from thebashpackage, enter:rpm2archive bash-4.4.19-6.el9.x86_64.rpm ls bash-4.4.19-6.el9.x86_64.rpm.tgz
$ rpm2archive bash-4.4.19-6.el9.x86_64.rpm $ ls bash-4.4.19-6.el9.x86_64.rpm.tgz bash-4.4.19-6.el9.x86_64.rpm.tgzCopy to Clipboard Copied! Toggle word wrap Toggle overflow