Pass patch path and ordinal as 1st and 2nd arguments to %autopatch backends

The quilt backend has been using %1 but that only worked due to flaws
in the macro engine: automatic macros are not cleared for
inner callers, they can only be overridden. This makes the the
scm backend %1 argument real to begin with, and adds another one:
the patch ordinal might be useful for some purposes.

It's tempting to use %1 and %2 from %apply_patch - we're only passing
them along unchanged, right? Well, it's just that rpm does not expand
arguments of parametric functions, so those %1 and %2 would refer
to themselves within the called macro. Gotta love it...
This commit is contained in:
Panu Matilainen 2017-01-18 15:42:48 +02:00
parent 1949aaa0bb
commit 1d7b45e484
1 changed files with 3 additions and 2 deletions

View File

@ -1139,10 +1139,11 @@ package or when debugging this package.\
%apply_patch(qp:m:)\
%{lua:\
local file = rpm.expand("%{1}")\
local num = rpm.expand("%{2}")\
if posix.access(file, "r") then\
local options = rpm.expand("%{-q} %{-p:-p%{-p*}} %{-m:-m%{-m*}}")\
local scm_apply = rpm.expand("%__scm_apply_%{__scm}")\
print(rpm.expand("%{uncompress:"..file.."} | "..scm_apply.." "..options.."\\n"))\
print(rpm.expand("%{uncompress:"..file.."} | "..scm_apply.." "..options.." "..file.." "..num.."\\n"))\
else\
print("echo 'Cannot read "..file.."'; exit 1;".."\\n")\
end}
@ -1152,7 +1153,7 @@ end}
%{lua:\
local options = rpm.expand("%{!-v:-q} %{-p:-p%{-p*}} ")\
for i, p in ipairs(patches) do\
print(rpm.expand("%apply_patch -m %{basename:"..p.."} "..options..p.."\\n"))\
print(rpm.expand("%apply_patch -m %{basename:"..p.."} "..options..p.." "..i.."\\n"))\
end}
# One macro to (optionally) do it all.