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] <packagename | specfile | srpm>

PARAMETERS

--check
    Verify build dependencies are satisfied without installing anything

--resolve
    Resolve abstract capabilities to concrete packages during installation

--spec=SPECFILE
    Read build requirements from the specified SPEC file

--srpm=SRPM
    Read build requirements from the specified source RPM file

-y, --assumeyes
    Automatically answer yes to prompts (common DNF option)

--best
    Install the best available versions of build dependencies

DESCRIPTION

The dnf builddep command installs the build-time dependencies (BuildRequires) for a given RPM source package, SPEC file, or SRPM file. It is essential for developers and packagers on Fedora, RHEL, and other RPM-based distributions who need to replicate the build environment for compiling software from source.

DNF parses the SPEC file (either from a local SRPM or remote source package metadata), resolves all declared build requirements to installable packages, and installs them. This differs from runtime dependencies managed by dnf install, as builddeps are transient, often used in isolated environments like mock or koji.

For remote packages, source repositories must be enabled (e.g., fedora-source). It supports dry-run checks, capability resolution, and assumes yes for non-interactive use. This streamlines SRPM-based workflows, ensuring reproducible builds without manual dependency hunting.

Typical use: set up a clean system, run dnf builddep package-name, then rpmbuild. Handles complex deps like development libraries, compilers, and macros.

CAVEATS

Requires enabled source repos for remote packages; installs many devel packages; use in chroots for isolation; weak dependencies (Suggests) ignored.

EXAMPLES

dnf builddep httpd (installs deps for httpd SRPM)
dnf builddep --spec /path/to/myspec.spec --check (dry-run check)
dnf builddep -y --resolve --srpm foo.src.rpm (non-interactive with resolution)

CONFIGURATION

Honors /etc/dnf/dnf.conf and repos.d; enable sources via dnf config-manager --set-enabled fedora-source

HISTORY

Introduced in DNF 1.0 (Fedora 22, 2015) as successor to yum-builddep. Enhanced in DNF 4+ with modular support and better libdnf integration for RHEL 8+. Actively maintained in Fedora and EPEL.

SEE ALSO

dnf(8), yum-builddep(1), rpmbuild(8), mock(1)

Copied to clipboard