Patchwork [2/3] oelint.bbclass: add patch checking

login
register
mail settings
Submitter Chong.Lu@windriver.com
Date Aug. 1, 2014, 7:15 a.m.
Message ID <75b2e993c6b899ab108e47b9b02d9610af972ff9.1406876955.git.Chong.Lu@windriver.com>
Download mbox | patch
Permalink /patch/77069/
State Accepted
Commit 207e94d4e1ffb7cae5310c16efc6224a7f0ce056
Headers show

Comments

Chong.Lu@windriver.com - Aug. 1, 2014, 7:15 a.m.
Check that all patches have Signed-off-by and Upstream-Status.

[YOCTO #5427]

Signed-off-by: Chong Lu <Chong.Lu@windriver.com>
---
 meta/classes/oelint.bbclass | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

Patch

diff --git a/meta/classes/oelint.bbclass b/meta/classes/oelint.bbclass
index 1c6f4b8..0bed74a 100644
--- a/meta/classes/oelint.bbclass
+++ b/meta/classes/oelint.bbclass
@@ -27,4 +27,39 @@  python do_lint() {
         bb.warn("${PN}: SECTION is not set")
     elif not s.islower():
         bb.warn("${PN}: SECTION should only use lower case")
+
+
+    ##############################
+    # Check that all patches have Signed-off-by and Upstream-Status
+    #
+    s = d.getVar("SRC_URI").split()
+    fpaths = (d.getVar('FILESPATH', True) or '').split(':')
+
+    def findPatch(patchname):
+        for dir in fpaths:
+            patchpath = dir + patchname
+            if os.path.exists(patchpath):
+                 return patchpath
+
+    def findKey(path, key):
+        ret = True
+        f = file('%s' % path, mode = 'r')
+        line = f.readline()
+        while line:
+            if line.find(key) != -1:
+                ret = False
+            line = f.readline()
+        f.close()
+        return ret
+
+    length = len("file://")
+    for item in s:
+        if item.startswith("file://"):
+            item = item[length:]
+            if item.endswith(".patch") or item.endswith(".diff"):
+                path = findPatch(item)
+                if findKey(path, "Signed-off-by"):
+                    bb.warn("${PN}: %s doesn't have Signed-off-by" % item)
+                if findKey(path, "Upstream-Status"):
+                    bb.warn("${PN}: %s doesn't have Upstream-Status" % item)
 }