update Travis to build on Trusty for code layout (#10048)

* update Travis to build on Trusty for code layout

* fix shellcheck replace ! -z by -n

* shellcheck: fix  -n doesn't work with unquoted arguments

* more shellcheck fixes

* use bash instead of posix
This commit is contained in:
Denis Rouzaud 2019-05-21 14:13:28 -05:00 committed by GitHub
parent 2cc04c27aa
commit 4f3a9f46d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 30 additions and 30 deletions

View File

@ -38,7 +38,7 @@ printf "[qgis]\n" >> $CONF_MASTER_FILE
SHOW_TIPS=$(qgis --help 2>&1 | head -2 | grep 'QGIS - ' | perl -npe 'chomp; s/QGIS - (\d+)\.(\d+).*/showTips\1\2=false/')
printf "%s\n\n" "$SHOW_TIPS" >> $CONF_MASTER_FILE
if [ -n "$PLUGIN_NAME" ]; then
if [[ -n "$PLUGIN_NAME" ]]; then
# Enable plugin
printf '[PythonPlugins]\n' >> $CONF_MASTER_FILE
printf "%s=true\n\n" "$PLUGIN_NAME" >> $CONF_MASTER_FILE

View File

@ -53,6 +53,7 @@ matrix:
# CODE LAYOUT
##########################################################
- os: linux
dist: xenial
name: code layout 👗
if: type != cron
env:
@ -61,7 +62,6 @@ matrix:
apt:
sources:
- sourceline: 'ppa:jonathonf/backports' # silversearcher-ag backport
- sourceline: 'ppa:sergey-dryabzhinsky/packages' # doxygen
packages:
- doxygen
- graphviz

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash
###########################################################################
# qgis_srs.sh
# ---------------------
@ -199,7 +199,7 @@ for i in $(awk 'NR>1' ${gdal_share}/pcs.csv | cut -d, -f1); do
raw=$(epsg_tr.py -proj4 $i 2>&1 | tr "\n" " " | sed 's/ <> $//' | grep -v "^ERROR 6: ")
if [ -n "$raw" ]; then
if [[ -n "$raw" ]]; then
no=$((no + 1))
name=$(echo $raw | sed 's/^# //' | grep -o "^.\{1,\} <[[:digit:]]\{1,\}>" | sed 's/ <[[:digit:]]\{1,\}>//' | sed "s/'/''/g")
@ -222,7 +222,7 @@ for i in $(awk 'NR>1' ${gdal_share}/gcs.csv | cut -d, -f1); do
raw=$(epsg_tr.py -proj4 $i 2>&1 | tr "\n" " " | sed 's/ <> $//' | grep -v "^ERROR 6: ")
if [ -n "$raw" ]; then
if [[ -n "$raw" ]]; then
no=$((no + 1))
name=$(echo $raw | sed 's/^# //' | grep -o "^.\{1,\} <[[:digit:]]\{1,\}>" | sed 's/ <[[:digit:]]\{1,\}>//' | sed "s/'/''/g")

View File

@ -32,7 +32,7 @@ if [[ "$OSTYPE" =~ darwin* ]]; then
fi
if [[ -n $1 ]]; then
modules=($1)
modules=("$1")
else
modules=(core gui analysis server)
fi
@ -66,7 +66,7 @@ for module in "${modules[@]}"; do
sip=$(${GP}sed -r 's/(.*)\.h$/\1.sip/' <<< ${header})
if_cond=$(grep -x -E '^(#define +)?SIP_IF_MODULE\((.*)\)$' src/${module}/${header} | \
${GP}sed -r -e 's/(#define +)?SIP_IF_MODULE\((.*)\)/%If (\2)/')
if [[ ! -z $if_cond ]]; then
if [[ -n $if_cond ]]; then
echo "$if_cond" >> $file
fi
if [[ "$sip" == [0-9]* ]]; then
@ -75,7 +75,7 @@ for module in "${modules[@]}"; do
sip="./$sip"
fi
echo "%Include auto_generated/$sip" >> $file
if [[ ! -z $if_cond ]]; then
if [[ -n $if_cond ]]; then
echo "%End" >> $file
fi
fi

View File

@ -85,7 +85,7 @@ declare -A GLOBREP_IGNORE=()
ERRORFOUND=NO
for I in $(seq -f '%02g' 0 $((SPLIT-1)) ) ; do
( [[ "$INTERACTIVE" =~ YES ]] || [[ "$TRAVIS" =~ true ]] ) && printf "Progress: %d/%d\r" $(( I + 1 )) $SPLIT
{ [[ "$INTERACTIVE" =~ YES ]] || [[ "$TRAVIS" =~ true ]]; } && printf "Progress: %d/%d\r" $(( I + 1 )) $SPLIT
SPELLFILE=spelling$I~
${GP}sed -i '/^#/d' $SPELLFILE
@ -136,10 +136,10 @@ for I in $(seq -f '%02g' 0 $((SPLIT-1)) ) ; do
RUN_IGNORECASE=OFF
RUN_CASEMATCH=OFF
if [[ ! -z "${IGNORECASE}" ]]; then
if [[ -n "${IGNORECASE}" ]]; then
RUN_IGNORECASE=ON
fi
if [[ ! -z "${CASEMATCH}" ]]; then
if [[ -n "${CASEMATCH}" ]]; then
RUN_CASEMATCH=ON
fi
@ -336,7 +336,7 @@ for I in $(seq -f '%02g' 0 $((SPLIT-1)) ) ; do
done
( [[ "$INTERACTIVE" =~ YES ]] || [[ "$TRAVIS" =~ true ]] ) && echo
{ [[ "$INTERACTIVE" =~ YES ]] || [[ "$TRAVIS" =~ true ]]; } && echo
if [[ "$ERRORFOUND" =~ YES ]]; then
echo -e "\x1B[1msome errors have been found.\x1B[0m" >&2

View File

@ -5,12 +5,12 @@ set -e
echo "Spell check"
cd $(git rev-parse --show-toplevel)
if [[ ! -z $TRAVIS_PULL_REQUEST_BRANCH ]]; then
if [[ -n $TRAVIS_PULL_REQUEST_BRANCH ]]; then
# if on a PR, just analyze the changed files
echo "TRAVIS PR BRANCH: $TRAVIS_PULL_REQUEST_BRANCH"
FILES=$(git diff --diff-filter=AM --name-only $(git merge-base HEAD ${TRAVIS_BRANCH}) | tr '\n' ' ' )
export PATH=${HOME}/osgeo4travis/bin:${PATH}
elif [[ ! -z $TRAVIS_COMMIT_RANGE ]]; then
elif [[ -n $TRAVIS_COMMIT_RANGE ]]; then
echo "TRAVIS COMMIT RANGE: $TRAVIS_COMMIT_RANGE"
FILES=$(git diff --diff-filter=AM --name-only ${TRAVIS_COMMIT_RANGE/.../..} | tr '\n' ' ' )
export PATH=${HOME}/osgeo4travis/bin:${PATH}
@ -19,7 +19,7 @@ else
FILES=""
fi
if [[ ! -z $FILES ]]; then
if [[ -n $FILES ]]; then
DIR=$(git rev-parse --show-toplevel)/scripts/spell_check
${DIR}/check_spelling.sh -r $FILES
fi

View File

@ -85,7 +85,7 @@ ${DIR}/check_spelling.sh -r -l spelling_error.log~ spelling_error.dat~
${GP}sort -u -o spelling_error.log~ spelling_error.log~
DIFF=$(diff spelling_error.log~ spelling_error.expected~)
if [[ ! -z $DIFF ]]; then
if [[ -n $DIFF ]]; then
echo "SPELLING TEST FAILED" >&2
else
echo "TEST OK"

View File

@ -19,11 +19,11 @@ ASTYLEDIFF=/tmp/astyle.diff
true > $ASTYLEDIFF
if [[ ! -z $TRAVIS_PULL_REQUEST_BRANCH ]]; then
if [[ -n $TRAVIS_PULL_REQUEST_BRANCH ]]; then
# if on a PR, just analyze the changed files
echo "TRAVIS PR BRANCH: $TRAVIS_PULL_REQUEST_BRANCH"
FILES=$(git diff --diff-filter=AM --name-only $(git merge-base HEAD ${TRAVIS_BRANCH}) | tr '\n' ' ' )
elif [[ ! -z $TRAVIS_COMMIT_RANGE ]]; then
elif [[ -n $TRAVIS_COMMIT_RANGE ]]; then
echo "TRAVIS COMMIT RANGE: $TRAVIS_COMMIT_RANGE"
FILES=$(git diff --diff-filter=AM --name-only ${TRAVIS_COMMIT_RANGE/.../..} | tr '\n' ' ' )
fi

View File

@ -3,14 +3,14 @@
# check that returns are placed before note and since
output=$(unbuffer ag --noaffinity --file-search-regex '\.h$' --multiline '\\(note|since)[^\n]+(\n\s*\* [^\n]+)*\n\s*\* \\return' ${TRAVIS_BUILD_DIR} | tee /dev/stderr)
if [[ ! -z $output ]]; then
if [[ -n $output ]]; then
echo -e "\n\x1B[31m*** Docstring computation: \\\return(s) should be placed before \\\note and \\since\x1B[0m"
exit 1
fi
# check that \since and \deprecated are placed at the end of the command block
output=$(unbuffer ag --noaffinity --file-search-regex '\.h$' --multiline '(\\(deprecated|since)[^\n]+\n)+\s*\*[^\/](?!\s*\\(deprecated|since))' ${TRAVIS_BUILD_DIR} | tee /dev/stderr)
if [[ ! -z $output ]]; then
if [[ -n $output ]]; then
echo -e "\n\x1B[31m*** Docstring computation: \\\deprecated and \\\since should be placed at the end of command blocks\x1B[0m"
echo -e "To fix it, you may want to run (multiple times) at the top level directory:"
echo 'sed -i -r '"'"'$!N;s/^(\s*\*\s+\\(deprecated|since)[^\n]+)\n(\s*\*([^\/].*|$))/\3\n\1/;P;D'"'"' $(ag -c --noaffinity --file-search-regex '"'"'\.h$'"'"' --multiline '"'"'(\\(deprecated|since)[^\n]+\n)+\s*\*[^\/]'"'"' . | cut -d: -f1)'
@ -21,7 +21,7 @@ fi
# code snippets command
output=$(unbuffer ag --noaffinity --file-search-regex '\.h$' --multiline '~~~\{\.\w+\}' ${TRAVIS_BUILD_DIR} | tee /dev/stderr)
if [[ ! -z $output ]]; then
if [[ -n $output ]]; then
echo -e "\n\x1B[31m*** Docstring computation: code snippets should use \\\code{.xx} rather than ~~~{.xx} \x1B[0m"
exit 1
fi

View File

@ -19,15 +19,15 @@ PROCESS="mapserv"
LABEL="org.qgis.test-${PROCESS}"
USAGE="${0} {stop|status} or {start|restart spawn_bin fcgi_socket fcgi_bin qgis_server_temp_dir}"
if [ ! -z $2 ]; then
if [[ -n $2 ]]; then
SPAWN_BIN=$2
if [ ! -z $3 ]; then
if [[ -n $3 ]]; then
FCGI_SOCKET=$3
fi
if [ ! -z $4 ]; then
if [[ -n $4 ]]; then
FCGI_BIN=$4
fi
if [ ! -z $5 ]; then
if [[ -n $5 ]]; then
QGIS_SERVER_TEMP_DIR=$5
fi
fi

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash
###########################################################################
# lighttpd_debian.sh
# ---------------------
@ -26,7 +26,7 @@ SCRIPTNAME=$NAME
export QGIS_SERVER_TEMP_DIR=$3
if [ ! -z $4 ]; then
if [[ -n $4 ]]; then
DAEMON_OPTS="-f ${4}"
fi

View File

@ -19,12 +19,12 @@ PROCESS="lighttpd"
LABEL="org.qgis.test-${PROCESS}"
USAGE="${0} {stop|status} or {start|restart lighttpd-path lighttpd_conf qgis_server_temp_dir}"
if [ ! -z $2 ]; then
if [[ -n $2 ]]; then
LIGHTTPD_BIN=$2
if [ ! -z $3 ]; then
if [[ -n $3 ]]; then
LIGHTTPD_CONF_PATH=$3
fi
if [ ! -z $4 ]; then
if [[ -n $4 ]]; then
QGIS_SERVER_TEMP_DIR=$4
fi
fi