michal-grzedzicki / rpms / rpm

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