From 683ce3254f822412e77e0ea70121f1cae0a27eb9 Mon Sep 17 00:00:00 2001 From: kytv Date: Fri, 20 Sep 2013 22:32:05 +0000 Subject: [PATCH] testscripts build target: check shell scripts for validity (also adding missing shebang lines) --- build.xml | 1 + core/c/build.sh | 2 +- core/c/jbigi/build-all.sh | 2 +- tests/scripts/checkpo.sh | 1 + tests/scripts/checkscripts.sh | 72 +++++++++++++++++++++++++++++++++++ tests/scripts/checkutf8.sh | 1 + tests/scripts/checkxml.sh | 1 + tests/scripts/testjbigi.sh | 1 + 8 files changed, 79 insertions(+), 2 deletions(-) create mode 100755 tests/scripts/checkscripts.sh diff --git a/build.xml b/build.xml index 9b984740bf..b244b3007e 100644 --- a/build.xml +++ b/build.xml @@ -1380,6 +1380,7 @@ + diff --git a/core/c/build.sh b/core/c/build.sh index 8ac53fb639..e0cd8a65f0 100755 --- a/core/c/build.sh +++ b/core/c/build.sh @@ -1,4 +1,4 @@ -#/bin/sh +#!/bin/sh (cd jcpuid ; sh build.sh ; cd ..) (cd jbigi ; sh build.sh ; cd ..) diff --git a/core/c/jbigi/build-all.sh b/core/c/jbigi/build-all.sh index d5dc7d4c51..04c3180fc5 100755 --- a/core/c/jbigi/build-all.sh +++ b/core/c/jbigi/build-all.sh @@ -1,4 +1,4 @@ -#/bin/sh +#!/bin/sh case `uname -sr` in MINGW*) diff --git a/tests/scripts/checkpo.sh b/tests/scripts/checkpo.sh index bc7d939d3e..de90bf5d56 100755 --- a/tests/scripts/checkpo.sh +++ b/tests/scripts/checkpo.sh @@ -1,3 +1,4 @@ +#!/bin/sh # # Run 'msgfmt -c' on all .po files # Returns nonzero on failure diff --git a/tests/scripts/checkscripts.sh b/tests/scripts/checkscripts.sh new file mode 100755 index 0000000000..7abbb8f972 --- /dev/null +++ b/tests/scripts/checkscripts.sh @@ -0,0 +1,72 @@ +#!/bin/sh + +# Check scripts in the I2P source for validity by running with "sh -n +# $SCRIPTNAME". Optionally checks for bashisms if "checkbashisms" is installed. + +# Exits 0 if no errors, non-zero otherwise + + +cd `dirname $0`/../.. + +# Only Bourne-compatible scripts should be in this list. +SCRIPTFILES="\ + ./apps/desktopgui/bundle-messages.sh \ + ./apps/i2psnark/java/bundle-messages.sh \ + ./apps/i2psnark/launch-i2psnark \ + ./apps/i2ptunnel/java/bundle-messages-proxy.sh \ + ./apps/i2ptunnel/java/bundle-messages.sh \ + ./apps/routerconsole/java/bundle-messages-news.sh \ + ./apps/routerconsole/java/bundle-messages.sh \ + ./apps/sam/c/examples/i2p-ping/pinger.sh \ + ./apps/susidns/src/bundle-messages.sh \ + ./apps/susimail/bundle-messages.sh \ + ./core/c/build.sh \ + ./core/c/jbigi/build-all.sh \ + ./core/c/jbigi/build_jbigi.sh \ + ./core/c/jbigi/build.sh \ + ./core/c/jbigi/mbuild-all.sh \ + ./core/c/jcpuid/build.sh \ + ./core/c/mbuild.sh \ + ./debian/i2p.config \ + ./debian/i2p-doc.preinst \ + ./debian/i2p.init \ + ./debian/i2p.postinst \ + ./debian/i2p.postrm \ + ./debian/i2p.preinst \ + ./debian/libjbigi-jni.preinst \ + ./debian/repack.sh \ + ./installer/resources/certificates/show.sh \ + ./installer/resources/install_i2p_service_osx.command \ + ./installer/resources/install_i2p_service_unix \ + ./installer/resources/locale/bundle-messages.sh \ + ./installer/resources/makegeoipv6.sh \ + ./installer/resources/postinstall.sh \ + ./installer/resources/runplain.sh \ + ./installer/resources/uninstall_i2p_service_osx.command + ./installer/resources/uninstall_i2p_service_unix \ + ./tests/scripts/checkcerts.sh \ + ./tests/scripts/checkpo.sh \ + ./tests/scripts/checksitecert.sh \ + ./tests/scripts/checkutf8.sh \ + ./tests/scripts/checkxml.sh \ + ./tests/scripts/testjbigi.sh \ +" + +for script in $SCRIPTFILES; do + echo "Checking $script …" + if sh -n "$script" ; then : ; else + echo "********* FAILED CHECK FOR $script *************" + FAIL=1 + fi + if $(which checkbashisms > /dev/null 2>&1) ; then + checkbashisms $script + fi +done + +if [ "$FAIL" != "" ] +then + echo "******** At least one file failed check *********" +else + echo "All files passed" +fi +exit $FAIL diff --git a/tests/scripts/checkutf8.sh b/tests/scripts/checkutf8.sh index ccd5047286..524e84973d 100755 --- a/tests/scripts/checkutf8.sh +++ b/tests/scripts/checkutf8.sh @@ -1,3 +1,4 @@ +#!/bin/sh # # Check for UTF-8 problems in all files where they might appear # Also check all Java source files diff --git a/tests/scripts/checkxml.sh b/tests/scripts/checkxml.sh index 4a862d6457..f8ca8ad8ed 100755 --- a/tests/scripts/checkxml.sh +++ b/tests/scripts/checkxml.sh @@ -1,3 +1,4 @@ +#!/bin/sh # # Validate XML and HTML files using xmllint # Returns nonzero on failure diff --git a/tests/scripts/testjbigi.sh b/tests/scripts/testjbigi.sh index db0a212469..c1c347a8ed 100755 --- a/tests/scripts/testjbigi.sh +++ b/tests/scripts/testjbigi.sh @@ -1,3 +1,4 @@ +#!/bin/sh # # Runs a test using each libjbigi-linux-*.so file # Returns nonzero on failure, but it will always