summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorDomarys Correa <domarys.correa@ossystems.com.br>2020-04-14 15:20:20 -0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-05-07 13:03:30 +0100
commit72a1526fd9c8d24fad161ab434fc42004effa572 (patch)
treed7c1ddebf65377aaa9f24e1f877f456b7c2f2037 /meta
parentdf9e772bc7426ebb7001fba648138aad48add929 (diff)
downloadpoky-72a1526fd9c8d24fad161ab434fc42004effa572.tar.gz
insane.bbclass: Add test for shebang line length
Shebang lines longer than 128 characters can give an error depending on the operating system. This implements a test that signals an error when locating a faulty shebang. YOCTO: #11053 (From OE-Core rev: 9ed54437b00aed1d41993f7658820d8adfb09282) Signed-off-by: Domarys Correa <domarys.correa@ossystems.com.br> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/insane.bbclass25
1 files changed, 24 insertions, 1 deletions
diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index 478240fa57..7fc8f33a98 100644
--- a/meta/classes/insane.bbclass
+++ b/meta/classes/insane.bbclass
@@ -35,7 +35,7 @@ ERROR_QA ?= "dev-so debug-deps dev-deps debug-files arch pkgconfig la \
35 split-strip packages-list pkgv-undefined var-undefined \ 35 split-strip packages-list pkgv-undefined var-undefined \
36 version-going-backwards expanded-d invalid-chars \ 36 version-going-backwards expanded-d invalid-chars \
37 license-checksum dev-elf file-rdeps configure-unsafe \ 37 license-checksum dev-elf file-rdeps configure-unsafe \
38 configure-gettext perllocalpod \ 38 configure-gettext perllocalpod shebang-size \
39 " 39 "
40# Add usrmerge QA check based on distro feature 40# Add usrmerge QA check based on distro feature
41ERROR_QA_append = "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', ' usrmerge', '', d)}" 41ERROR_QA_append = "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', ' usrmerge', '', d)}"
@@ -83,6 +83,29 @@ def package_qa_add_message(messages, section, new_msg):
83 else: 83 else:
84 messages[section] = messages[section] + "\n" + new_msg 84 messages[section] = messages[section] + "\n" + new_msg
85 85
86QAPATHTEST[shebang-size] = "package_qa_check_shebang_size"
87def package_qa_check_shebang_size(path, name, d, elf, messages):
88 if os.path.islink(path) or elf:
89 return
90
91 try:
92 with open(path, 'rb') as f:
93 stanza = f.readline(130)
94 except IOError:
95 return
96
97 if stanza.startswith(b'#!'):
98 #Shebang not found
99 try:
100 stanza = stanza.decode("utf-8")
101 except UnicodeDecodeError:
102 #If it is not a text file, it is not a script
103 return
104
105 if len(stanza) > 129:
106 package_qa_add_message(messages, "shebang-size", "%s: %s maximum shebang size exceeded, the maximum size is 128." % (name, package_qa_clean_path(path, d)))
107 return
108
86QAPATHTEST[libexec] = "package_qa_check_libexec" 109QAPATHTEST[libexec] = "package_qa_check_libexec"
87def package_qa_check_libexec(path,name, d, elf, messages): 110def package_qa_check_libexec(path,name, d, elf, messages):
88 111