rpmspec
Extract information from RPM spec files
TLDR
List binary packages which would be generated from a RPM spec file
List all options for --queryformat
Get summary information for single binary packages generated from a RPM spec file
Get the source package which would be generated from a RPM spec file
Parse a RPM spec file to stdout
SYNOPSIS
rpmspec [OPTION]... SPEC_FILE...
PARAMETERS
-P, --parse
Parse the spec file and print the build tree to standard output. This shows the result of macro expansion and conditional processing.
-q, --query
Query the spec file for package information. This is the default action if no other action is specified.
-l, --list
List files included in the package as defined by the %files section of the spec file.
-i, --info
Display package information (Name, Version, Release, Summary, License, etc.) from the spec file.
--buildarch ARCH
Override the detected build architecture (e.g., x86_64, aarch64). Useful for testing cross-build scenarios.
--target PLATFORM
Override the detected build target platform (e.g., i686-linux-gnu).
--define='MACRO VALUE'
Define a macro with a specific value, overriding default or previously defined macros.
--undefine=MACRO
Undefine a macro, preventing its expansion.
--with=FEATURE
Enable a conditional build feature as specified by %bcond_with or similar constructs in the spec file.
--without=FEATURE
Disable a conditional build feature as specified by %bcond_without or similar constructs.
--queryformat='FORMAT_STRING'
Specify a custom format string for query output, similar to rpm -q --queryformat.
--rcfile=FILELIST
Read RPM configuration from the specified colon-separated FILELIST instead of the default.
--root=PATH
Specify an alternate root directory to operate on.
-D, --debug
Enable debugging output, showing more details about internal processes.
-h, --help
Print a concise help message and exit.
--version
Print the version number of rpmspec and exit.
DESCRIPTION
The rpmspec command is a utility from the RPM Package Manager suite, primarily used for analyzing .spec files. A .spec file is a blueprint used by rpmbuild to create RPM packages. rpmspec allows developers and administrators to parse these files, query their contents, and inspect the package metadata without necessarily building the package.
It's invaluable for understanding package dependencies, build requirements, included files, and general package structure before the actual build process. It can evaluate conditional sections (like %if, %else) and macro expansions, providing a final, processed view of the spec file's instructions. This helps in debugging spec file issues and ensuring correct package metadata.
CAVEATS
rpmspec evaluates the spec file in a similar way to rpmbuild, meaning it considers defined macros and conditional builds. However, it does not actually perform any build operations, download sources, or check for build environments. Its output is based purely on the parsing and evaluation of the .spec file itself, which might not reflect the actual state if external conditions (like missing build dependencies) would prevent a successful rpmbuild. It also might not catch all syntax errors that rpmbuild would, especially those related to source/patch file presence or execution of scriptlets.
MACRO EXPANSION
rpmspec is particularly useful for understanding how macros are expanded within a spec file. Using -P will show the fully expanded spec file, which is invaluable for debugging complex macro definitions and conditional logic, especially when dealing with environment-specific builds or complex dependencies.
QUERYING METADATA
Beyond just parsing, rpmspec can extract specific metadata (like Name, Version, Release, Summary, License, BuildRequires, Requires, Source files, etc.) from a spec file without needing to build the package. This is similar to querying an already built RPM package, making it a quick way to inspect a package's definition.
HISTORY
The rpmspec command is an integral part of the RPM Package Manager project, which was originally developed by Red Hat. It emerged as a dedicated utility to inspect and parse .spec files, a crucial component of RPM package creation. While rpmbuild can also parse spec files internally during a build, rpmspec provides a standalone, non-intrusive way to review the package definition, aiding developers in debugging spec file logic, verifying macros, and understanding the final package structure before committing to a full build process. Its development reflects the need for more granular control and inspection capabilities within the RPM ecosystem.