Alon Bar-Lev has uploaded a new change for review. Change subject: packaging: build: validate shell scripts ......................................................................
packaging: build: validate shell scripts Change-Id: Ib16140e4abcb3740a51f4c3b77b9eee3a6e5cffd Signed-off-by: Alon Bar-Lev <[email protected]> --- M Makefile A build/shell-check.sh M ovirt-engine.spec.in M packaging/services/ovirt-engine-notifier/ovirt-engine-notifier.sysv.in M packaging/services/ovirt-engine/ovirt-engine.sysv.in M packaging/services/ovirt-websocket-proxy/ovirt-websocket-proxy.sysv.in M packaging/setup/dbutils/encodingvalidator.sh 7 files changed, 53 insertions(+), 14 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/34/22334/1 diff --git a/Makefile b/Makefile index 90d9164..9f6fd38 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ BUILD_DEV=0 BUILD_UT=1 EXTRA_BUILD_FLAGS= -BUILD_PYTHON_VALIDATION=1 +BUILD_VALIDATION=1 DEV_REBUILD=1 DEV_BUILD_GWT_DRAFT=0 DEV_EXTRA_BUILD_FLAGS= @@ -191,8 +191,7 @@ all: \ generated-files \ - python-validation \ - dbscripts-validations \ + validations \ $(BUILD_FILE) \ $(NULL) @@ -310,13 +309,13 @@ install -m "$${MASK}" "$(SOURCEDIR)/$${f}" "$$(dirname "$(TARGETDIR)/$${f}")"; \ done -python-validation: generated-files - if [ "$(BUILD_PYTHON_VALIDATION)" != 0 ]; then \ - build/python-check.sh; \ - fi -dbscripts-validations: - build/dbscripts/check_for_duplicate_upgrade_scripts.sh +validations: generated-files + if [ "$(BUILD_VALIDATION)" != 0 ]; then \ + build/shell-check.sh && \ + build/python-check.sh && \ + build/dbscripts/check_for_duplicate_upgrade_scripts.sh; \ + fi install_artifacts: # we must exclude tmp.repos directory so we diff --git a/build/shell-check.sh b/build/shell-check.sh new file mode 100755 index 0000000..a3e984f --- /dev/null +++ b/build/shell-check.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +SRCDIR="$(dirname "$0")/.." +cd "${SRCDIR}" + +if [ -z "${VALIDATION_SHELL}" ]; then + # prefer dash over bash for POSIX complaint + [ -x /bin/dash ] && VALIDATION_SHELL="/bin/dash" || VALIDATION_SHELL="/bin/sh" +fi + +EXTRA_ARGS="" +# if bash use POSIX parsing +"${VALIDATION_SHELL}" --version 2>&1 | grep -q bash && EXTRA_ARGS="${EXTRA_ARGS} --posix" + +ret="$( + find packaging build -type f \( -executable -or -name '*.sh' -or -name '*.bash' \) -and -not -name '*.py' | while read f; do + read l < "${f}" + shell="/bin/sh" + candidate="${l#\#!}" + candidate="${candidate# *}" # remove leading spaces + candidate="${candidate% *}" # remove parameter + [ "${candidate}" != "${l}" ] && shell="${candidate}" + skip= + case "${shell}" in + /bin/sh) shell="${VALIDATION_SHELL} ${EXTRA_ARGS}" ;; + /bin/bash) ;; + /usr/bin/python) skip=1 ;; + *) + echo "ERROR: Unknown shell '${shell}' for '${f}'" + ret=1 + ;; + esac + if [ -z "${skip}" ]; then + ${shell} -n "${f}" || ret=1 + fi + echo "${ret}" + done | tail -n 1 +)" + +exit ${ret} diff --git a/ovirt-engine.spec.in b/ovirt-engine.spec.in index a9432d3..d0dc28c 100644 --- a/ovirt-engine.spec.in +++ b/ovirt-engine.spec.in @@ -111,7 +111,7 @@ BUILD_GWT=%{ovirt_build_gwt} \\\ BUILD_LOCALES=%{ovirt_build_locales} \\\ BUILD_UT=%{ovirt_build_ut} \\\ - BUILD_PYTHON_VALIDATION=0 \\\ + BUILD_VALIDATION=0 \\\ PACKAGE_NAME=%{name} \\\ RPM_VERSION=%{version} \\\ RPM_RELEASE=%{release} \\\ diff --git a/packaging/services/ovirt-engine-notifier/ovirt-engine-notifier.sysv.in b/packaging/services/ovirt-engine-notifier/ovirt-engine-notifier.sysv.in index 8992268..b154df4 100644 --- a/packaging/services/ovirt-engine-notifier/ovirt-engine-notifier.sysv.in +++ b/packaging/services/ovirt-engine-notifier/ovirt-engine-notifier.sysv.in @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/sh # # Start/stop oVirt Engine # diff --git a/packaging/services/ovirt-engine/ovirt-engine.sysv.in b/packaging/services/ovirt-engine/ovirt-engine.sysv.in index c196505..7cf7a08 100644 --- a/packaging/services/ovirt-engine/ovirt-engine.sysv.in +++ b/packaging/services/ovirt-engine/ovirt-engine.sysv.in @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/sh # # Start/stop oVirt Engine # diff --git a/packaging/services/ovirt-websocket-proxy/ovirt-websocket-proxy.sysv.in b/packaging/services/ovirt-websocket-proxy/ovirt-websocket-proxy.sysv.in index 3243705..a012330 100644 --- a/packaging/services/ovirt-websocket-proxy/ovirt-websocket-proxy.sysv.in +++ b/packaging/services/ovirt-websocket-proxy/ovirt-websocket-proxy.sysv.in @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/sh # # Start/stop oVirt Engine # diff --git a/packaging/setup/dbutils/encodingvalidator.sh b/packaging/setup/dbutils/encodingvalidator.sh index bdf7d31..dd02f0a 100755 --- a/packaging/setup/dbutils/encodingvalidator.sh +++ b/packaging/setup/dbutils/encodingvalidator.sh @@ -1,3 +1,4 @@ +#!/bin/bash ############################################################################################################### # The purpose of this utility is to find not UTF8 template1 encoding , display it and enable to fix it # Only support may access this utility with care @@ -6,7 +7,6 @@ # It is highly recomended to backup the database before using this utility. ############################################################################################################### -#!/bin/bash #include db general functions pushd $(dirname ${0})>/dev/null source ./common.sh -- To view, visit http://gerrit.ovirt.org/22334 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib16140e4abcb3740a51f4c3b77b9eee3a6e5cffd Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.3.2 Gerrit-Owner: Alon Bar-Lev <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
