Patchwork patch.bbclass: conditional patch-tool dependency

login
register
mail settings
Submitter Bernhard Reutner-Fischer
Date Dec. 21, 2010, 5:19 p.m.
Message ID <1292951999-18969-2-git-send-email-rep.dot.nop@gmail.com>
Download mbox | patch
Permalink /patch/100/
State Accepted
Headers show

Comments

Bernhard Reutner-Fischer - Dec. 21, 2010, 5:19 p.m.
only depend do_patch on patch-tool if recipe references any patch

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
 classes/patch.bbclass |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)
Bernhard Reutner-Fischer - Jan. 3, 2011, 7:54 p.m.
On Tue, Dec 21, 2010 at 06:19:59PM +0100, Bernhard Reutner-Fischer wrote:
>only depend do_patch on patch-tool if recipe references any patch

ping?
>
>Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
>---
> classes/patch.bbclass |   21 +++++++++++++++++++--
> 1 files changed, 19 insertions(+), 2 deletions(-)
>
>diff --git a/classes/patch.bbclass b/classes/patch.bbclass
>index 7629e9a..1cfe24c 100644
>--- a/classes/patch.bbclass
>+++ b/classes/patch.bbclass
>@@ -38,7 +38,7 @@ python patch_do_patch() {
> 	src_uri = d.getVar("SRC_URI", True).split()
> 	srcurldata = bb.fetch.init(src_uri, d, True)
> 	workdir = bb.data.getVar('WORKDIR', d, 1)
>-	for url in d.getVar("SRC_URI", True).split():
>+	for url in src_uri:
> 		urldata = srcurldata[url]
> 
> 		local = urldata.localpath
>@@ -120,8 +120,25 @@ python patch_do_patch() {
> 			bb.fatal(str(exc))
> }
> 
>+def patch_deps(d):
>+    import oe.unpack
>+
>+    src_uri = d.getVar("SRC_URI", True).split()
>+    srcurldata = bb.fetch.init(src_uri, d, True)
>+    for url in src_uri:
>+        urldata = srcurldata[url]
>+        local = urldata.localpath
>+        if local:
>+            base, ext = os.path.splitext(os.path.basename(local))
>+            if ext in ('.gz', '.bz2', '.Z', '.xz'):
>+                local = base
>+            if oe.unpack.is_patch(local, urldata.parm):
>+                return "${PATCHDEPENDENCY}"
>+    return ""
>+        
>+
> addtask patch after do_unpack
> do_patch[dirs] = "${WORKDIR}"
>-do_patch[depends] = "${PATCHDEPENDENCY}"
>+do_patch[depends] = "${@patch_deps(d)}"
> 
> EXPORT_FUNCTIONS do_patch
>-- 
>1.7.2.3
>
Leon Woestenberg - Jan. 5, 2011, 12:39 p.m.
Hello,

On Tue, Dec 21, 2010 at 6:19 PM, Bernhard Reutner-Fischer
<rep.dot.nop@gmail.com> wrote:
> only depend do_patch on patch-tool if recipe references any patch
>
> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
> ---

Untested but I like it.

Acked-by: Leon Woestenberg <leon@sidebranch.com>

Patch

diff --git a/classes/patch.bbclass b/classes/patch.bbclass
index 7629e9a..1cfe24c 100644
--- a/classes/patch.bbclass
+++ b/classes/patch.bbclass
@@ -38,7 +38,7 @@  python patch_do_patch() {
 	src_uri = d.getVar("SRC_URI", True).split()
 	srcurldata = bb.fetch.init(src_uri, d, True)
 	workdir = bb.data.getVar('WORKDIR', d, 1)
-	for url in d.getVar("SRC_URI", True).split():
+	for url in src_uri:
 		urldata = srcurldata[url]
 
 		local = urldata.localpath
@@ -120,8 +120,25 @@  python patch_do_patch() {
 			bb.fatal(str(exc))
 }
 
+def patch_deps(d):
+    import oe.unpack
+
+    src_uri = d.getVar("SRC_URI", True).split()
+    srcurldata = bb.fetch.init(src_uri, d, True)
+    for url in src_uri:
+        urldata = srcurldata[url]
+        local = urldata.localpath
+        if local:
+            base, ext = os.path.splitext(os.path.basename(local))
+            if ext in ('.gz', '.bz2', '.Z', '.xz'):
+                local = base
+            if oe.unpack.is_patch(local, urldata.parm):
+                return "${PATCHDEPENDENCY}"
+    return ""
+        
+
 addtask patch after do_unpack
 do_patch[dirs] = "${WORKDIR}"
-do_patch[depends] = "${PATCHDEPENDENCY}"
+do_patch[depends] = "${@patch_deps(d)}"
 
 EXPORT_FUNCTIONS do_patch