Browse Source

SQSCANNER-35 Fix script home detection and path quoting issues

tags/2.9.0.670
Duarte Meneses 7 years ago
parent
commit
0c5295ed0e
2 changed files with 26 additions and 66 deletions
  1. 13
    33
      src/main/assembly/bin/sonar-runner
  2. 13
    33
      src/main/assembly/bin/sonar-scanner

+ 13
- 33
src/main/assembly/bin/sonar-runner View File

@@ -34,35 +34,19 @@
# authors and should not be interpreted as representing official policies, either expressed
# or implied, of Jon Disnard.
real_path () {
OIFS=$IFS
IFS='/'
for I in $1
do
# Resolve relative path punctuation.
if [ "$I" = "." ] || [ -z "$I" ]
then continue
elif [ "$I" = ".." ]
then FOO="${FOO%%/${FOO##*/}}"
continue
else FOO="${FOO}/${I}"
fi
target=$1

# Dereference symbolic links.
if [ -h "$FOO" ] && [ -x "/bin/ls" ]
then IFS=$OIFS
set `/bin/ls -l "$FOO"`
while shift ;
do
if [ "$1" = "->" ]
then FOO=$2
shift $#
break
fi
done
fi
(
while true; do
cd "$(dirname "$target")"
target=$(basename "$target")
link=$(readlink "$target")
test "$link" || break
target=$link
done
IFS=$OIFS
echo "$FOO"

echo "$(pwd -P)/$target"
)
}

echo WARN: 'sonar-runner' script is deprecated. Please use 'sonar-scanner' instead.
@@ -71,11 +55,7 @@ script_path="$0"

if [ -h "$script_path" ] ; then
# resolve recursively symlinks
r_script_path=$(real_path "$script_path")
until [ "$R_script_path" = "$script_path" ]; do
script_path="$R_script_path"
r_script_path=$(real_path "$script_path")
done
script_path=$(real_path "$script_path")
fi

sonar_runner_home=$(dirname "$script_path")/..
@@ -115,7 +95,7 @@ project_home=$(pwd)
exec "$java_cmd" \
-Djava.awt.headless=true \
$SONAR_SCANNER_OPTS \
-classpath $jar_file \
-classpath "$jar_file" \
-Dscanner.home=\$sonar_runner_home \
-Dproject.home=\$project_home \
org.sonarsource.scanner.cli.Main "$@"

+ 13
- 33
src/main/assembly/bin/sonar-scanner View File

@@ -35,46 +35,26 @@
# authors and should not be interpreted as representing official policies, either expressed
# or implied, of Jon Disnard.
real_path () {
OIFS=$IFS
IFS='/'
for I in $1
do
# Resolve relative path punctuation.
if [ "$I" = "." ] || [ -z "$I" ]
then continue
elif [ "$I" = ".." ]
then FOO="${FOO%%/${FOO##*/}}"
continue
else FOO="${FOO}/${I}"
fi
target=$1

# Dereference symbolic links.
if [ -h "$FOO" ] && [ -x "/bin/ls" ]
then IFS=$OIFS
set `/bin/ls -l "$FOO"`
while shift ;
do
if [ "$1" = "->" ]
then FOO=$2
shift $#
break
fi
done
fi
(
while true; do
cd "$(dirname "$target")"
target=$(basename "$target")
link=$(readlink "$target")
test "$link" || break
target=$link
done
IFS=$OIFS
echo "$FOO"

echo "$(pwd -P)/$target"
)
}

script_path="$0"

if [ -h "$script_path" ] ; then
# resolve recursively symlinks
r_script_path=$(real_path "$script_path")
until [ "$r_script_path" = "$script_path" ]; do
script_path="$r_script_path"
r_script_path=`real_path "$script_path"`
done
script_path=$(real_path "$script_path")
fi

sonar_scanner_home=$(dirname "$script_path")/..
@@ -107,7 +87,7 @@ exec "$java_cmd" \
-Djava.awt.headless=true \
$SONAR_SCANNER_OPTS \
$SONAR_SCANNER_DEBUG_OPTS \
-classpath $jar_file \
-classpath "$jar_file" \
-Dscanner.home=\$sonar_scanner_home \
-Dproject.home=\$project_home \
org.sonarsource.scanner.cli.Main "$@"

Loading…
Cancel
Save