From 98c5039009406609f661f98623776d6c18a04c2c Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Mon, 25 Feb 2008 12:24:22 +0200 Subject: [PATCH] Add %{sources} and %{patches} macros to build - push full patch + source paths to global lua tables - %{sources} and %{patches} are just easy-access wrappers to accessing the lua tables - "git-am -p1 %{patches}" and enjoy... --- build/spec.c | 30 ++++++++++++++++++++++++++++++ macros.in | 3 +++ 2 files changed, 33 insertions(+) diff --git a/build/spec.c b/build/spec.c index c5915eb..9ec1d66 100644 --- a/build/spec.c +++ b/build/spec.c @@ -13,6 +13,7 @@ #include #include "build/buildio.h" +#include "rpmio/rpmlua.h" #include "debug.h" @@ -329,6 +330,19 @@ int addSource(rpmSpec spec, Package pkg, const char *field, rpmTag tag) sprintf(buf, "%sURL%d", (flag & RPMBUILD_ISPATCH) ? "PATCH" : "SOURCE", num); addMacro(spec->macros, buf, NULL, p->fullSource, RMIL_SPEC); +#ifdef WITH_LUA + { + rpmlua lua = NULL; /* global state */ + const char * what = (flag & RPMBUILD_ISPATCH) ? "patches" : "sources"; + rpmluaPushTable(lua, what); + rpmluav var = rpmluavNew(); + rpmluavSetListMode(var, 1); + rpmluavSetValue(var, RPMLUAV_STRING, body); + rpmluaSetVar(lua, var); + var = rpmluavFree(var); + rpmluaPop(lua); + } +#endif body = _free(body); } @@ -445,6 +459,16 @@ rpmSpec newSpec(void) spec->macros = rpmGlobalMacroContext; +#ifdef WITH_LUA + { + /* make sure patches and sources tables always exist */ + rpmlua lua = NULL; /* global state */ + rpmluaPushTable(lua, "patches"); + rpmluaPushTable(lua, "sources"); + rpmluaPop(lua); + rpmluaPop(lua); + } +#endif return spec; } @@ -514,6 +538,12 @@ rpmSpec freeSpec(rpmSpec spec) spec->passPhrase = _free(spec->passPhrase); spec->cookie = _constfree(spec->cookie); +#ifdef WITH_LUA + rpmlua lua = NULL; /* global state */ + rpmluaDelVar(lua, "patches"); + rpmluaDelVar(lua, "sources"); +#endif + spec->sources = freeSources(spec->sources); spec->packages = freePackages(spec->packages); diff --git a/macros.in b/macros.in index 543e3bf..087b5da 100644 --- a/macros.in +++ b/macros.in @@ -1156,6 +1156,9 @@ done \ %{-C:${_mydir}}%{!-C:.}/configure %{_target_platform} --prefix=%{_prefix} --exec-prefix=%{_exec_prefix} --bindir=%{_bindir} --sbindir=%{_sbindir} --sysconfdir=%{_sysconfdir} --datadir=%{_datadir} --includedir=%{_includedir} --libdir=%{_libdir} --libexecdir=%{_libexecdir} --localstatedir=%{_localstatedir} --sharedstatedir=%{_sharedstatedir} --mandir=%{_mandir} --infodir=%{_infodir} %* ; \ %{-C:cd ${_mydir}; unset _mydir} +%patches %{lua: for i, p in ipairs(patches) do print(p.." ") end} +%sources %{lua: for i, s in ipairs(sources) do print(s.." ") end} + #------------------------------------------------------------------------------ # Useful perl macros (from Artur Frysiak ) # -- 2.7.4