File autopatch.diff of Package rpm
Index: build/parsePreamble.c
===================================================================
--- build/parsePreamble.c
+++ build/parsePreamble.c
@@ -318,6 +318,15 @@ static int addSource(rpmSpec spec, Packa
rpmluaSetVar(lua, var);
rpmluavFree(var);
rpmluaPop(lua);
+
+ what = (flag & RPMBUILD_ISPATCH) ? "patch_nums" : "source_nums";
+ rpmluaPushTable(lua, what);
+ var = rpmluavNew();
+ rpmluavSetListMode(var, 1);
+ rpmluavSetValueNum(var, p->num);
+ rpmluaSetVar(lua, var);
+ rpmluavFree(var);
+ rpmluaPop(lua);
}
#endif
free(body);
Index: build/spec.c
===================================================================
--- build/spec.c
+++ build/spec.c
@@ -219,8 +219,14 @@ rpmSpec newSpec(void)
rpmlua lua = NULL; /* global state */
rpmluaDelVar(lua, "patches");
rpmluaDelVar(lua, "sources");
+ rpmluaDelVar(lua, "patch_nums");
+ rpmluaDelVar(lua, "source_nums");
rpmluaPushTable(lua, "patches");
rpmluaPushTable(lua, "sources");
+ rpmluaPushTable(lua, "patch_nums");
+ rpmluaPushTable(lua, "source_nums");
+ rpmluaPop(lua);
+ rpmluaPop(lua);
rpmluaPop(lua);
rpmluaPop(lua);
}
@@ -274,6 +282,8 @@ rpmSpec rpmSpecFree(rpmSpec spec)
rpmlua lua = NULL; /* global state */
rpmluaDelVar(lua, "patches");
rpmluaDelVar(lua, "sources");
+ rpmluaDelVar(lua, "patch_nums");
+ rpmluaDelVar(lua, "source_nums");
#endif
spec->sources = freeSources(spec->sources);
Index: macros.in
===================================================================
--- macros.in
+++ macros.in
@@ -1091,10 +1091,15 @@ done \
%{uncompress:%{1}} | %{expand:%__scm_apply_%{__scm} %{-q} %{-p:-p%{-p*}} %{-m:-m%{-m*}}}
# Automatically apply all patches
-%autopatch(vp:)\
+%autopatch(vp:m:M:)\
%{lua:\
+local lo = tonumber(rpm.expand("%{-m:%{-m*}}"))\
+local hi = tonumber(rpm.expand("%{-M:%{-M*}}"))\
for i, p in ipairs(patches) do\
- print(rpm.expand("%apply_patch -m %{basename:"..p.."} "..rpm.expand("%{!-v:-q} %{-p:-p%{-p*}} ")..p.."\\n"))\
+ local inum = patch_nums[i]\
+ if ((not lo or inum>=lo) and (not hi or inum<=hi)) then\
+ print(rpm.expand("%apply_patch -m %{basename:"..p.."} "..rpm.expand("%{!-v:-q} %{-p:-p%{-p*}} ")..p.."\\n"))\
+ end\
end}
# One macro to (optionally) do it all.