summaryrefslogtreecommitdiffstats
path: root/meta/classes/oelint.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/oelint.bbclass')
-rw-r--r--meta/classes/oelint.bbclass85
1 files changed, 85 insertions, 0 deletions
diff --git a/meta/classes/oelint.bbclass b/meta/classes/oelint.bbclass
new file mode 100644
index 0000000000..d00f468d9a
--- /dev/null
+++ b/meta/classes/oelint.bbclass
@@ -0,0 +1,85 @@
1addtask lint before do_fetch
2do_lint[nostamp] = "1"
3python do_lint() {
4 pkgname = d.getVar("PN", True)
5
6 ##############################
7 # Test that DESCRIPTION exists
8 #
9 description = d.getVar("DESCRIPTION")
10 if description[1:10] == '{SUMMARY}':
11 bb.warn("%s: DESCRIPTION is not set" % pkgname)
12
13
14 ##############################
15 # Test that HOMEPAGE exists
16 #
17 homepage = d.getVar("HOMEPAGE")
18 if homepage == '':
19 bb.warn("%s: HOMEPAGE is not set" % pkgname)
20 elif not homepage.startswith("http://") and not homepage.startswith("https://"):
21 bb.warn("%s: HOMEPAGE doesn't start with http:// or https://" % pkgname)
22
23
24 ##############################
25 # Test for valid SECTION
26 #
27 section = d.getVar("SECTION")
28 if section == '':
29 bb.warn("%s: SECTION is not set" % pkgname)
30 elif not section.islower():
31 bb.warn("%s: SECTION should only use lower case" % pkgname)
32
33
34 ##############################
35 # Check that all patches have Signed-off-by and Upstream-Status
36 #
37 srcuri = d.getVar("SRC_URI").split()
38 fpaths = (d.getVar('FILESPATH', True) or '').split(':')
39
40 def findPatch(patchname):
41 for dir in fpaths:
42 patchpath = dir + patchname
43 if os.path.exists(patchpath):
44 return patchpath
45
46 def findKey(path, key):
47 ret = True
48 f = file('%s' % path, mode = 'r')
49 line = f.readline()
50 while line:
51 if line.find(key) != -1:
52 ret = False
53 line = f.readline()
54 f.close()
55 return ret
56
57 length = len("file://")
58 for item in srcuri:
59 if item.startswith("file://"):
60 item = item[length:]
61 if item.endswith(".patch") or item.endswith(".diff"):
62 path = findPatch(item)
63 if findKey(path, "Signed-off-by"):
64 bb.warn("%s: %s doesn't have Signed-off-by" % (pkgname, item))
65 if findKey(path, "Upstream-Status"):
66 bb.warn("%s: %s doesn't have Upstream-Status" % (pkgname, item))
67
68
69 ##############################
70 # Check for ${PN} or ${P} usage in SRC_URI or S
71 # Should use ${BPN} or ${BP} instead to avoid breaking multilib
72 #
73 for s in srcuri:
74 if not s.startswith("file://"):
75 if not s.find("{PN}") == -1:
76 bb.warn("%s: should use BPN instead of PN in SRC_URI" % pkgname)
77 if not s.find("{P}") == -1:
78 bb.warn("%s: should use BP instead of P in SRC_URI" % pkgname)
79
80 srcpath = d.getVar("S")
81 if not srcpath.find("{PN}") == -1:
82 bb.warn("%s: should use BPN instead of PN in S" % pkgname)
83 if not srcpath.find("{P}") == -1:
84 bb.warn("%s: should use BP instead of P in S" % pkgname)
85}