aboutsummaryrefslogtreecommitdiffstats
path: root/classes/checkbashisms.bbclass
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-11-15 16:03:21 -0700
committerChris Larson <chris_larson@mentor.com>2010-11-15 16:04:06 -0700
commitfd2d95283d2b1e78fc0842ae07618a69ce5b5ac3 (patch)
tree9b41fbbdb8c67f7039715f8eda446285ff411847 /classes/checkbashisms.bbclass
parentd8d33031dc4fb8d3c8ca429a94f4f7edebe5de70 (diff)
downloadopenembedded-fd2d95283d2b1e78fc0842ae07618a69ce5b5ac3.tar.gz
checkbashisms: add initial class to run against ${S}
Currently requires that you already have checkbashisms available somewhere in your PATH. Runs against all '#!/bin/sh' scripts in ${S}, to attempt to find and fix issues with /bin/sh not being bash. Signed-off-by: Chris Larson <chris_larson@mentor.com>
Diffstat (limited to 'classes/checkbashisms.bbclass')
-rw-r--r--classes/checkbashisms.bbclass32
1 files changed, 32 insertions, 0 deletions
diff --git a/classes/checkbashisms.bbclass b/classes/checkbashisms.bbclass
new file mode 100644
index 0000000000..3a38e34d52
--- /dev/null
+++ b/classes/checkbashisms.bbclass
@@ -0,0 +1,32 @@
+python do_checkbashisms () {
+ import re
+ import oe.process
+ import oe.path
+
+ def readline(path):
+ try:
+ return iter(open(path, "r")).next()
+ except StopIteration:
+ pass
+
+ shebang = re.compile("^#! */bin/sh$")
+ errors = False
+ srcdir = d.getVar("S", True)
+ for path in oe.path.find(srcdir):
+ line = readline(path)
+ if line and shebang.match(line):
+ try:
+ output = oe_run(d, ["checkbashisms", path])
+ except oe.process.ExecutionError, exc:
+ if not errors:
+ errors = True
+ bb.note(str(exc))
+
+ if errors:
+ bb.fatal("bashisms were identified, aborting")
+}
+addtask checkbashisms after do_patch
+
+do_checkbashisms_all[recrdeptask] = "do_checkbashisms"
+do_checkbashisms_all[nostamp] = "1"
+addtask checkbashisms_all after do_checkbashisms