This page does not cover Terra-specific (Anda SRPM) macros. For documentation on these macros, see here. For documentation on our AppStream MetaInfo macros, see here.
‼️
Macro Argument Syntax
All macro flags followed by <…> REQUIRE an argument passed to them.
All macro flags followed by […] MAY have an argument passed to them.
All macro flags with <#> or [#] take only numbers as arguments.
Additionally, if there is no space between the flag <…>/<#> or […]/[#], you MUST NOT have a space between the flag and the argument passed to it.
Conversely, if there is a space you SHOULD assume the flag needs a space between them.
If you are new to RPM packaging, you should first check out the macros with the 🔰 icon.
On a computer, the right hand side of this page shows you the list of macros.
If you would like to learn more about the RPM macro syntax, check out Macro syntax.
Macros defined with %define will not last to another RPM section.
For example, if used in preamble section, the macro will be automatically undefined in %prep.
To make sure a macro lasts for the entire spec file, use %global instead.
Similar to # …, this can comment out anything in %{dnl:…} or after %dnl ….
The difference with # … is that %dnl prevents macro expansions,
while macros in # … are actually expanded.
%global my_macro Hello%{lua: -- this lua block expands to the input -- to all `print()` statements print("%prep\necho " .. rpm.expand("%my_macro from lua!") .. "\n")}
Wrap the input with single quotes and also escape preexisting single-quotes correctly,
so that the input can be safely passed as arguments to shell commands.
$ rpm -E "echo %{shescape:this is some 'text'}"echo 'this is some '\''text'\'''$ rpm -E "%(echo %{shescape:this is some 'text'})"this is some 'text'
When used as %{getncpus} with no arguments, expand to the number of available CPU cores.
Also accept extra arguments:
accepts arguments total, proc and thread, additionally accounting for available memory (e.g. address space limitations for threads)
However, %getncpus total, %getncpus proc and %getncpus thread produce the same results as far as
concerned. It is suspected that the arguments in most cases have no effect to the output.
Produce an RPM warning, which is immediately shown in console stderr,
and displayed again at the end of the rpmbuild execution (after Executing(rmbuild)).
The printing happens when the macro is evaluated and expanded, not at the
section/position it is written.
Produce an RPM warning, which is immediately shown in console stderr, then immediately
perform Executing(rmbuild) and exit with a summary of all warnings and errors.
The printing happens when the macro is evaluated and expanded, not at the
section/position it is written.
When you see problems with /usr/lib/.build-id, try setting this to none.
In /usr/lib/rpm/macros:
## Defines how and if build_id links are generated for ELF files.# The following settings are supported:## - none# No build_id links are generated.## - alldebug# build_id links are generated only when the __debug_package global is# defined. This will generate build_id links in the -debuginfo package# for both the main file as /usr/lib/debug/.build-id/xx/yyy and for# the .debug file as /usr/lib/debug/.build-id/xx/yyy.debug.# This is the old style build_id links as generated by the original# find-debuginfo.sh script.## - separate# build_id links are generate for all binary packages. If this is a# main package (the __debug_package global isn't set) then the# build_id link is generated as /usr/lib/.build-id/xx/yyy. If this is# a -debuginfo package (the __debug_package global is set) then the# build_id link is generated as /usr/lib/debug/.build-id/xx/yyy.## - compat# Same as for "separate" but if the __debug_package global is set then# the -debuginfo package will have a compatibility link for the main# ELF /usr/lib/debug/.build-id/xx/yyy -> /usr/lib/.build-id/xx/yyy%_build_id_links compat
Still having problems with /usr/lib/.build-id? Try setting this to 0.
In /usr/lib/rpm/macros:
## Should an ELF file processed by find-debuginfo.sh having no build ID# terminate a build? This is left undefined to disable it and defined to# enable.#%_missing_build_ids_terminate_build 1
Since rpmbuild automatically generates Requires: by looking at
what things the binaries are linked to, you may disable that by adding a regex to this macro:
# https://github.com/terrapkg/packages/blob/7f0fd6b6a8993d17832403960d4343899cfb0474/anda/apps/youtube-music/youtube-music.spec#L5%define debug_package %nil# Exclude private libraries since this is bundled with electron%global __provides_exclude ^((libffmpeg[.]so.*)|(lib.*\\.so.*))$%global __requires_exclude ^((libffmpeg[.]so.*)|(lib.*\\.so.*))$
If you want to disable all automatic Requires:, set AutoReq: 0.
Similarly, since rpmbuild automatically generates Provides:, you may disable that:
# https://github.com/terrapkg/packages/blob/7f0fd6b6a8993d17832403960d4343899cfb0474/anda/apps/youtube-music/youtube-music.spec#L4%define debug_package %nil# Exclude private libraries since this is bundled with electron%global __provides_exclude ^((libffmpeg[.]so.*)|(lib.*\\.so.*))$%global __requires_exclude ^((libffmpeg[.]so.*)|(lib.*\\.so.*))$
If you want to disable all automatic Provides:, set AutoProv: 0.
RPM tries to mangle shebangs (#!) by default (see
%__brp_mangle_shebangs).
If this breaks, you can ask it to exclude the files that matches a given regex.
As a last resort to fixing bugs related to shebangs mangling shenanigans,
undefine this macro. You really should try using
%__brp_mangle_shebangs_exclude_from first though.
-c: create directory, cd into it, then unpack the source (useful if archive lacks top-level directory)
-C: I've no idea what this does! — Mado
-D: do not delete folder before unpacking sources
-T: disable unpacking %SOURCE0
-v: verbose. If specified, %autosetup will omit the -q argument to %setup
-S <…>: specify the SCM, equivalent to %global __scm … then %__scm_setup_git (replace git with the argument). With this argument, the specified SCM will be set up in the uncompressed directory
Wrapper around %__apply_patch. No, this does not wrap around %patch!
Parameterized as %autopatch(vqp:m:M:):
-v: verbose
-q: don’t warn if there are no matching patches
-p<#>: number of top-level path components to strip (default 0)
For example, if the patch uses the path a/b/hello.txt,
passing in -p1 will strip it to b/hello.txt,
and passing in -p2 will strip it to just hello.txt.
-m<#>: apply patches starting from n (default 0)
-M<#>: apply patches up to n (default to the last patch number for Patch:)
Examples:
%autopatch -m 100: apply patches with number >= 100
%autopatch -M 400: apply patches with number <= 400
This list is NOT exhaustive. Some macros are not built-in. If your
machine does not come with them, try dnf install 'rpm_macro(macro_name)'.
Macros with the '(Terra only)' warning are part of the anda-srpm-macros package in Terra, documentation for these can be found on the Terra SRPM devdocs page.
automagically generate list of language specific filesfor inclusion in an rpm spec file.This does assume that the *.mo files are under .../locale/...
Expand to exactly /usr/lib/rpm/find-lang.sh %{buildroot}.
Used with the -f flag for %files.
Useful for packaging /usr/share/locale/*/LC_MESSAGES/%{app_id}.mo files.
$ /usr/lib/rpm/find-lang.shUsage: /usr/lib/rpm/find-lang.sh TOP_DIR PACKAGE_NAME [prefix]where TOP_DIR isthe top of the tree containing the files to be processed--should be$RPM_BUILD_ROOT usually. TOP_DIR gets sed'd out of the output list.PACKAGE_NAME is the %{name} of the package. This should also bethe basename of the .mo files. the output is written toPACKAGE_NAME.lang unless $3 is given in which case output is writtento $3.Additional options: --with-gnome find GNOME help files --with-mate find MATE help files --with-kde find KDE help files --with-qt find Qt translation files --with-html find HTML files --with-man find localized man pages --all-name match all package/domain names --without-mo do not find locale files --generate-subpackages move language files in one sub package per language