summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDomarys Correa <domarys.correa@ossystems.com.br>2020-04-14 15:20:20 -0300
committerSteve Sakoman <steve@sakoman.com>2020-05-01 10:12:13 -1000
commit9ed54437b00aed1d41993f7658820d8adfb09282 (patch)
treec32a8a6c569f11cc4a7847949ce26bfef89d1a1b
parent4e64f0bc62fd81f91d75a1f46230fff7c71650e2 (diff)
downloadopenembedded-core-contrib-9ed54437b00aed1d41993f7658820d8adfb09282.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 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>
-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 \
split-strip packages-list pkgv-undefined var-undefined \
version-going-backwards expanded-d invalid-chars \
license-checksum dev-elf file-rdeps configure-unsafe \
- configure-gettext perllocalpod \
+ configure-gettext perllocalpod shebang-size \
"
# Add usrmerge QA check based on distro feature
ERROR_QA_append = "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', ' usrmerge', '', d)}"
@@ -83,6 +83,29 @@ def package_qa_add_message(messages, section, new_msg):
else:
messages[section] = messages[section] + "\n" + new_msg
+QAPATHTEST[shebang-size] = "package_qa_check_shebang_size"
+def package_qa_check_shebang_size(path, name, d, elf, messages):
+ if os.path.islink(path) or elf:
+ return
+
+ try:
+ with open(path, 'rb') as f:
+ stanza = f.readline(130)
+ except IOError:
+ return
+
+ if stanza.startswith(b'#!'):
+ #Shebang not found
+ try:
+ stanza = stanza.decode("utf-8")
+ except UnicodeDecodeError:
+ #If it is not a text file, it is not a script
+ return
+
+ if len(stanza) > 129:
+ 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)))
+ return
+
QAPATHTEST[libexec] = "package_qa_check_libexec"
def package_qa_check_libexec(path,name, d, elf, messages):