Chapter 5. New features in RHEL 9
This section documents the most notable changes in RPM packaging between Red Hat Enterprise Linux 8 and 9.
5.1. Dynamic build dependencies
Red Hat Enterprise Linux 9 introduces the
%generate_buildrequires section that enables generating dynamic build dependencies.
Additional build dependencies can now be generated programmatically at RPM build time, using the newly available
%generate_buildrequires script. This is useful when packaging software written in a language in which a specialized utility is commonly used to determine run-time or build-time dependencies, such as Rust, Golang, Node.js, Ruby, Python, or Haskell.
You can use the
%generate_buildrequires script to dynamically determine which
BuildRequires directives are added to a SPEC file at build-time. If present,
%generate_buildrequires is executed after the
%prep section and can access the unpacked and patched source files. The script must print the found build dependencies to standard output using the same syntax as a regular
rpmbuild utility then checks if the dependencies are met before continuing the build.
If some dependencies are missing, a package with the
.buildreqs.nosrc.rpm suffix is created, which contains the found
BuildRequires and no source files. You can use this package to install the missing build dependencies with the
dnf builddep command before restarting the build.
For more information, see the
DYNAMIC BUILD DEPENDENCIES section in the
rpmbuild(8) man page.
5.2. Improved patch declaration
5.2.1. Optional automatic patch and source numbering
Source: tags without a number are now automatically numbered based on the order in which they are listed.
The numbering is run internally by the
rpmbuild utility starting from the last manually numbered entry, or
0 if there is no such entry.
Patch: one.patch Patch: another.patch Patch: yet-another.patch
It is now possible to list patch and source files without preceding each item with the respective
Source: tags by using the newly added
For example, the following entries:
Patch0: one.patch Patch1: another.patch Patch2: yet-another.patch
can now be replaced with:
%patchlist one.patch another.patch yet-another.patch
%autopatch now accepts patch ranges
%autopatch macro now accepts the
-M parameters to limit the minimum and maximum patch number to apply, respectively:
-mparameter specifies the patch number (inclusive) to start at when applying patches.
-Mparameter specifies the patch number (inclusive) to stop at when applying patches.
This feature can be useful when an action needs to be performed in between certain patch sets.
5.3. Other features
Other new features related to RPM packaging in Red Hat Enterprise Linux 9 include:
- Fast macro-based dependency generators
Powerful macro and
%ifexpressions, including ternary operator and native version comparison
- Meta (unordered) dependencies
Caret version operator (
^), which can be used to express a version that is higher than the base version. This operator complements the tilde (
~) operator, which has the opposite semantics.