LinuxCommandLibrary

dnf-builddep

Install RPM build dependencies

TLDR

Install dependencies for a given package

$ dnf builddep [path/to/specification.spec]
copy

Install dependencies for a given package but ignore unavailable
$ dnf builddep --skip-unavailable [path/to/specification.spec]
copy

Define the RPM macro to a given expression
$ dnf builddep [[-D|--define]] '[expression]'
copy

Define an argument for a .spec file path
$ dnf builddep --spec [argument]
copy

Define an argument for a .rpm file path
$ dnf builddep --srpm [argument]
copy

Display help
$ dnf builddep --help-cmd
copy

SYNOPSIS

dnf builddep [options] <package-file|package-spec>...

PARAMETERS

<package-file|package-spec>
    Specifies the target package. This can be the path to an SRPM file (e.g., mypackage-1.0-1.src.rpm), the path to a spec file (e.g., mypackage.spec), or the name of a source package available in enabled repositories (e.g., mypackage).

-s, --specfile <specfile>
    Explicitly specifies the path to an RPM spec file from which to read build dependencies. This is useful when the spec file is not part of an SRPM or is located elsewhere.

--installroot=<path>
    Specifies an alternative root directory into which dependencies will be installed. This is useful for chroot environments or when preparing a custom build environment without affecting the host system.

--buildroot=<path>
    Specifies an alternative build root for installing build dependencies. This is often used in conjunction with --installroot for more granular control over the build environment setup.

--enable-source
    Enables the resolution of build dependencies that are themselves source packages (SRPMs) from enabled DNF repositories. This is crucial when a package's build dependencies are not just development libraries but other SRPMs.

[options]
    Represents general DNF options that can be used with dnf-builddep, such as --assumeyes (-y) for automatic confirmation, --nogpgcheck to disable GPG signature checking, or --enablerepo/--disablerepo to manage repositories during dependency resolution.

DESCRIPTION

The dnf-builddep command is a powerful DNF plugin designed to simplify the process of installing all necessary build dependencies for a specified RPM package. It parses the BuildRequires and Requires(pre) fields from an SRPM (Source RPM) file, a local spec file, or a package name available in configured DNF repositories. After identifying these dependencies, it leverages DNF's robust dependency resolution engine to automatically download and install them.

This utility is indispensable for package developers, maintainers, and users who need to compile software from source on RPM-based Linux distributions like Fedora, RHEL, CentOS, Rocky Linux, or AlmaLinux. Instead of manually figuring out and installing each required development package, dnf-builddep automates this often complex and error-prone task, ensuring that the build environment is correctly set up before compilation. It significantly streamlines the workflow for rebuilding existing packages or developing new ones.

CAVEATS

Requires the dnf-plugins-core package to be installed.
The command needs access to configured DNF repositories that contain the necessary build dependencies.
It typically requires root privileges to install packages on the system.
Be aware that installing build dependencies can pull in a large number of packages, potentially consuming significant disk space.

USAGE EXAMPLES

To install build dependencies for an SRPM file:
sudo dnf builddep mypackage-1.0-1.src.rpm

To install build dependencies for a local spec file:
sudo dnf builddep -s mypackage.spec

To install build dependencies for a source package named 'mypackage' available in repositories:
sudo dnf builddep mypackage

REQUIRED PACKAGE

The dnf-builddep command is part of the dnf-plugins-core package. Ensure this package is installed on your system to use the command.

HISTORY

The dnf-builddep command is the modern successor to the yum-builddep command, which served a similar purpose in the older YUM package manager. With the transition to DNF as the default package manager for Fedora and later for RHEL/CentOS, this essential functionality was migrated and enhanced as a DNF plugin. Its development is intertwined with the evolution of DNF itself, aiming to provide a more robust and performant dependency resolution engine for RPM-based systems, thereby streamlining the software development and packaging workflow within these ecosystems.

SEE ALSO

dnf(8), rpm(8), mock(1), rpmspec(8)

Copied to clipboard