Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | addtask lint before do_build |
| 2 | do_lint[nostamp] = "1" |
| 3 | python do_lint() { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 4 | pkgname = d.getVar("PN") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5 | |
| 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 38 | fpaths = (d.getVar('FILESPATH') or '').split(':') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 48 | f = open('%s' % path, mode = 'r') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 | 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 | } |