Port %{load:<path>} macro from rpm5.org
- Allow loading custom macro files from eg specs. This is quite different from %include which inlines arbitrary content into a spec, but which cannot be used for including macro files as their syntax is entirely different. Both have their uses. - rpm5.org also supports %load within macro files, we dont as I find the imperative %load very alien in what's otherwise an entirely declarative file "format"
This commit is contained in:
parent
3f69897743
commit
784dfb4219
|
@ -5,6 +5,7 @@
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#include <errno.h>
|
||||||
#ifdef HAVE_GETOPT_H
|
#ifdef HAVE_GETOPT_H
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#else
|
#else
|
||||||
|
@ -111,6 +112,7 @@ static int expandMacro(MacroBuf mb, const char *src, size_t slen);
|
||||||
static void pushMacro(rpmMacroContext mc,
|
static void pushMacro(rpmMacroContext mc,
|
||||||
const char * n, const char * o, const char * b, int level);
|
const char * n, const char * o, const char * b, int level);
|
||||||
static void popMacro(rpmMacroContext mc, const char * n);
|
static void popMacro(rpmMacroContext mc, const char * n);
|
||||||
|
static int loadMacroFile(rpmMacroContext mc, const char * fn);
|
||||||
|
|
||||||
/* =============================================================== */
|
/* =============================================================== */
|
||||||
|
|
||||||
|
@ -1140,6 +1142,20 @@ expandMacro(MacroBuf mb, const char *src, size_t slen)
|
||||||
printMacro(mb, s, se);
|
printMacro(mb, s, se);
|
||||||
|
|
||||||
/* Expand builtin macros */
|
/* Expand builtin macros */
|
||||||
|
if (STREQ("load", f, fn)) {
|
||||||
|
if (g && gn > 0) {
|
||||||
|
char arg[gn + 1];
|
||||||
|
strncpy(arg, g, gn);
|
||||||
|
arg[gn] = '\0';
|
||||||
|
/* Print failure iff %{load:...} or %{!?load:...} */
|
||||||
|
if (loadMacroFile(mb->mc, arg) && chkexist == negate) {
|
||||||
|
rpmlog(RPMLOG_ERR,
|
||||||
|
_("failed to load macro file %s"), arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s = se;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (STREQ("global", f, fn)) {
|
if (STREQ("global", f, fn)) {
|
||||||
s = doDefine(mb, se, RMIL_GLOBAL, 1);
|
s = doDefine(mb, se, RMIL_GLOBAL, 1);
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue