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

login
register
mail settings
Submitter Chong.Lu@windriver.com
Date Aug. 1, 2014, 9:03 a.m.
Message ID <c762a9f3e17b70b51950ea1e81da677a19335288.1406883469.git.Chong.Lu@windriver.com>
Download mbox | patch
Permalink /patch/77083/
State Accepted
Commit 207e94d4e1ffb7cae5310c16efc6224a7f0ce056
Headers show

Comments

Chong.Lu@windriver.com - Aug. 1, 2014, 9:03 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 d14e378..07a7ed9 100644
--- a/meta/classes/oelint.bbclass
+++ b/meta/classes/oelint.bbclass
@@ -29,4 +29,39 @@  python do_lint() {
         bb.warn("%s: SECTION is not set" % pkgname)
     elif not section.islower():
         bb.warn("%s: SECTION should only use lower case" % pkgname)
+
+
+    ##############################
+    # Check that all patches have Signed-off-by and Upstream-Status
+    #
+    srcuri = 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 srcuri:
+        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("%s: %s doesn't have Signed-off-by" % (pkgname, item))
+                if findKey(path, "Upstream-Status"):
+                    bb.warn("%s: %s doesn't have Upstream-Status" % (pkgname, item))
 }