michal-grzedzicki / rpms / rpm

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