Skip to contentSkip to conversation

conditional patch-tool dep

PATCH New Bernhard Reutner-Fischer 2 participants 4 messages Dec 21, 2010 – Jan 5, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 conditional patch-tool dep

Hi,

If a recipe doesn't reference any patch then patching doesn't make sense and neither does depending on patch-tool.

I didn't look yet if i can say
addtask patch after do_unpack if needs_patching_at_all(d) (or something like that).
So, for a start, don't depend do_patch on the patch tool if there is no patch in the SRC_URI.

untested.

PS: There should be some oe.is_compressed(uri) shorthand that is used to decide if an uri is in a compressed format, imho.

Bernhard Reutner-Fischer (1):
patch.bbclass: conditional patch-tool dependency

 classes/patch.bbclass |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)
Signature · 1 line
1.7.2.3
#1 lore raw

PATCH 1/1 patch.bbclass: conditional patch-tool dependency

only depend do_patch on patch-tool if recipe references any patch

---
 classes/patch.bbclass |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)
classes/patch.bbclass +19 -2
index 7629e9a..1cfe24c 100644
@@ -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
Signature · 1 line
1.7.2.3
#2 lore raw

Re: [PATCH] patch.bbclass: conditional patch-tool dependency

Quoted 1 line · Bernhard Reutner-Fischer

only depend do_patch on patch-tool if recipe references any patch

ping?

Quoted 49 lines

---
classes/patch.bbclass | 21 +++++++++++++++++++--

1 files changed, 19 insertions(+), 2 deletions(-)
classes/patch.bbclass +18 -1
index 7629e9a..1cfe24c 100644
@@ -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}"

classes/patch.bbclass +1 -1
-do_patch[depends] = "${PATCHDEPENDENCY}"
+do_patch[depends] = "${@patch_deps(d)}"

EXPORT_FUNCTIONS do_patch

Signature · 1 line
1.7.2.3