blob: 2589d34059f1cba04add9fe18a043a9446ad0f19 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001addtask lint before do_build
2do_lint[nostamp] = "1"
3python do_lint() {
Brad Bishop6e60e8b2018-02-01 10:27:11 -05004 pkgname = d.getVar("PN")
Patrick Williamsc124f4f2015-09-15 14:41:29 -05005
6 ##############################
7 # Test that DESCRIPTION exists
8 #
9 description = d.getVar("DESCRIPTION", False)
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", False)
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", False)
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", False).split()
Brad Bishop6e60e8b2018-02-01 10:27:11 -050038 fpaths = (d.getVar('FILESPATH') or '').split(':')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050039
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
Patrick Williamsc0f7c042017-02-23 20:41:17 -060048 f = open('%s' % path, mode = 'r')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050049 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 def checkPN(pkgname, varname, str):
58 if str.find("{PN}") != -1:
59 bb.warn("%s: should use BPN instead of PN in %s" % (pkgname, varname))
60 if str.find("{P}") != -1:
61 bb.warn("%s: should use BP instead of P in %s" % (pkgname, varname))
62
63 length = len("file://")
64 for item in srcuri:
65 if item.startswith("file://"):
66 item = item[length:]
67 if item.endswith(".patch") or item.endswith(".diff"):
68 path = findPatch(item)
69 if findKey(path, "Signed-off-by"):
70 bb.warn("%s: %s doesn't have Signed-off-by" % (pkgname, item))
71 if findKey(path, "Upstream-Status"):
72 bb.warn("%s: %s doesn't have Upstream-Status" % (pkgname, item))
73
74
75 ##############################
76 # Check for ${PN} or ${P} usage in SRC_URI or S
77 # Should use ${BPN} or ${BP} instead to avoid breaking multilib
78 #
79 for s in srcuri:
80 if not s.startswith("file://"):
81 checkPN(pkgname, 'SRC_URI', s)
82
83 checkPN(pkgname, 'S', d.getVar('S', False))
84}