dcavalca / rpms / rpm

Forked from rpms/rpm a year ago
Clone
James Antill ee2eaf
From f00bb5be9caa62220c6aeaf3f7264840d5c089e3 Mon Sep 17 00:00:00 2001
James Antill ee2eaf
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com>
James Antill ee2eaf
Date: Tue, 5 Feb 2019 18:15:47 +0100
James Antill ee2eaf
Subject: [PATCH] Add limits to autopatch macro
James Antill ee2eaf
James Antill ee2eaf
Limits allow to apply only range of patches with given parameters.
James Antill ee2eaf
Useful if something needs to be done between patch sets. Allows applying
James Antill ee2eaf
of patches with different -pX parameter in one spec file.
James Antill ee2eaf
James Antill ee2eaf
Resolves: #626
James Antill ee2eaf
Co-authored-by: Florian Festi <ffesti@redhat.com>
James Antill ee2eaf
---
James Antill ee2eaf
 macros.in | 12 ++++++++++--
James Antill ee2eaf
 1 file changed, 10 insertions(+), 2 deletions(-)
James Antill ee2eaf
James Antill ee2eaf
diff --git a/macros.in b/macros.in
James Antill ee2eaf
index 7b5b63020..912ad5997 100644
James Antill ee2eaf
--- a/macros.in
James Antill ee2eaf
+++ b/macros.in
James Antill ee2eaf
@@ -1265,11 +1265,19 @@ else\
James Antill ee2eaf
 end}
James Antill ee2eaf
 
James Antill ee2eaf
 # Automatically apply all patches
James Antill ee2eaf
-%autopatch(vp:)\
James Antill ee2eaf
+# -m<min>       Apply patches with number >= min only
James Antill ee2eaf
+# -M<max>       Apply patches with number <= max only
James Antill ee2eaf
+%autopatch(vp:m:M:)\
James Antill ee2eaf
 %{lua:\
James Antill ee2eaf
 local options = rpm.expand("%{!-v:-q} %{-p:-p%{-p*}} ")\
James Antill ee2eaf
+local low_limit = tonumber(rpm.expand("%{-m:%{-m*}}"))\
James Antill ee2eaf
+local high_limit = tonumber(rpm.expand("%{-M:%{-M*}}"))\
James Antill ee2eaf
 for i, p in ipairs(patches) do\
James Antill ee2eaf
-    print(rpm.expand("%apply_patch -m %{basename:"..p.."}  "..options..p.." "..i.."\\n"))\
James Antill ee2eaf
+    local inum = patch_nums[i]\
James Antill ee2eaf
+    if ((not low_limit or inum>=low_limit) and (not high_limit or inum<=high_limit)) \
James Antill ee2eaf
+    then\
James Antill ee2eaf
+        print(rpm.expand("%apply_patch -m %{basename:"..p.."}  "..options..p.." "..i.."\\n")) \
James Antill ee2eaf
+    end\
James Antill ee2eaf
 end}
James Antill ee2eaf
 
James Antill ee2eaf
 # One macro to (optionally) do it all.
James Antill ee2eaf
-- 
James Antill ee2eaf
2.26.2
James Antill ee2eaf