Dnf: How to get the build date for a package

Hi,

is there a way to get the Build Date for an rpm package using dnf?

Unfortunately dnf info only seems to provide a subset of what rpm -qi does.

dnf info example_package
Name         : example_package
Version      : 11.00.00
Release      : 03
Architecture : x86_64
Size         : 430 M
Source       : example_package-11.00.00-03.src.rpm
Repository   : @System
Summary      : Example Package
License      : (c) null
Description  : Example Package, SCM-Version: b96441c


rpm -qi example_package
Name        : example_package
Version     : 11.00.00
Release     : 03
Architecture: x86_64
Install Date: Fri Apr 28 17:20:06 2023
Group       : Development
Size        : 450749938
License     : (c) null
Signature   : (none)
Source RPM  : example_package-11.00.00-03.src.rpm
Build Date  : Fri Mar 17 18:41:20 2023
Build Host  : test-server
Relocations : (not relocatable)
Packager    : John Doe, Example Lc
Vendor      : DPAG
Summary     : Example Package
Description :
Example Package, SCM-Version: b96441c

How can I get the Build Date with the dnf command?

Thanks!

dnf repoquery --queryformat '%{buildtime}' <package>
dnf rq --qf '%{buildtime}' <package>

See dnf rq --querytags for tag names (different from rpm --querytags)

1 Like

Thanks, Justin. Unfortunately, it seems that repoquery does not work for my rpm. Probably because it is not associated with any repo and was installed locally. :thinking:

Try adding --installed.

Or just use rpm, any reason not to? It’s much faster than dnf for such queries.

1 Like

The –installed option does the trick. Thanks again!

It’s a client request to migrate all rpm calls to dnf, although, you are right the simple query for package information should make for an exception.

A strange request if you ask me. dnf and rpm serves different purposes and one can’t be a replacement for the other.

1 Like