A repository where I can work on whatever random RPM macros come to mind.
Feel free to file issues if you have macros you'd like to see in Fedora, or send pull requests. Eventually I will add useful macros to the appropriate packages so that they can be used throughout Fedora.
Macros are grouped into individual files by function. Many macros have no output or effect on the specfile; they instead add objects (generally functions) to the Lua namespace. Such functions live in the 'fedora' table, but there is generally a macro which imports them into the global namespace. Macros for general use in Fedora should never pollute the global namespace and thus should never use these import functions. Packagers can use them in their own specs, of course.
Context is important for many macros and the functions they define. Some
assume they will be evaluated or called while RPM is processing a scriptlet
(%prep
, %build
, %install
, etc.) and they may simply output code
intended to be interpreted by the shell. Outside of a scriptlet, this will be
interpreted by RPM as regular specfile directives and will likely cause an
error. Similarly, some functions or macros may output specfile directives
which will cause errors if evaluated inside of a scriptlet.
Note that macros themselves can begin scriptlets, and that once the first
scriptlet tag (or the %description
tag) is parsed by RPM, no more specfile
directives will be parsed; everything that follows is either being run by the
shell or interpreted as a file list.
Note that RPM will in some cases re-parse macro output. You must be careful when using percent signs in strings passed to macros which output text into the parse stream, because you may end up with recursive expansions.
Contains two macros:
%fedora_utility_init
fedora
table.%fedora_utlity_import
The included functions:
basename
get_numbered_patch(N), get_numbered_source(N)
Gets the full path to the patchfile or sourcefile given by N
.
fedora.get_numbered_source(7)
will produce the full path to the source
file defined earlier in the spec with Source7:
Note that Patch:
and Source:
define the zeroth patch/source file,
not the first.
If the given number does not correspond to a currently defined
patch/source file, nil
is returned.
echo(string)
Called while RPM is parsing scriptlet, will cause that scriptlet to echo the provided
string (by outputting an echo
statement into the spec).
Note that string
will be interpreted by the shell as an argument to
echo
. Leading dashes or shell metacharacters will not print literally.
Will almost certainly cause errors if called while RPM is not parsing a scriptlet.
exit
When called in a scriptlet, will cause that scriptlet to fail (by outputting exit 1
).
Will almost certainly cause errors if called while RPM is not parsing a scriptlet.
rpmerror(string)
%error
macro, which causes RPM to store the provided
string to be used in the final error report. Doesn't cause any output or
interrupt any current scriptlet.rpmerror_exit(string)
echo
the string, call rpmerror
and
then call exit
.getflag(flag)
Not implemented.
Returns true
if the flag was passed to the macro in which the function
is called, and false
otherwise.
getioption(option)
If option
was passed to the macro in which the function is called,
returns the value of that option as a string.
Returns nil
otherwise.