patch.bbclass: conditional patch-tool dependency
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Tue, 21 Dec 2010 12:40:52 +0000 (13:40 +0100)
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Tue, 11 Jan 2011 20:29:10 +0000 (21:29 +0100)
only depend do_patch on patch-tool if recipe references any patch

The whole of do_patch should be gated through a facility to determine if
there is any patch at all. TODO.

Acked-by: Leon Woestenberg <leon@sidebranch.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
classes/patch.bbclass

index bc52ae7..edfb5e9 100644 (file)
@@ -43,7 +43,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
@@ -97,7 +97,7 @@ python patch_do_patch() {
                                continue
 
                if "maxrev" in parm:
-                       srcrev = bb.data.getVar('SRCREV', d, 1)         
+                       srcrev = bb.data.getVar('SRCREV', d, 1)
                        if srcrev and srcrev > parm["maxrev"]:
                                bb.note("Patch '%s' applies to earlier revisions" % pname)
                                continue
@@ -125,8 +125,24 @@ 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