Fix the detection of scala version (now https)

The www.scala-lang.org switched to https and the curl call did not
account for this scenario, so it failed.
Switch the address to https and as extra measure add also the -L
argument, which forces curl to follow the redirects.

Switch also the download URL to https.

Story: 2001964
Task: 15088
Change-Id: I9d28c2ad56292998a6b7aaea421b98e136fbf6e1
This commit is contained in:
Luigi Toscano 2018-05-04 17:54:58 +02:00
parent 93856090e5
commit 9abcec3c82
2 changed files with 8 additions and 8 deletions

View File

@ -6,16 +6,16 @@ DEF_VERSION="2.11.6"
if [ $test_only -eq 0 ]; then
RETURN_CODE="$(curl -s -o /dev/null -w "%{http_code}" http://www.scala-lang.org/)"
RETURN_CODE="$(curl -s -L -o /dev/null -w "%{http_code}" https://www.scala-lang.org/)"
if [ "$RETURN_CODE" != "200" ]; then
echo "http://www.scala-lang.org is unreachable" && exit 1
echo "https://www.scala-lang.org is unreachable" && exit 1
fi
if [ "${scala_version}" != "1" ]; then
VERSION=$scala_version
else
VERSION="$(curl -s --fail http://www.scala-lang.org| tr -d '\n' | sed 's/^.*<div[^<]\+scala-version">[^0-9]\+\([0-9\.\?]\+\)<.\+$/\1/')"
VERSION="$(curl -s -L --fail https://www.scala-lang.org| tr -d '\n' | sed 's/^.*<div[^<]\+scala-version">[^0-9]\+\([0-9\.\?]\+\)<.\+$/\1/')"
if [ $? != 0 -o -z "${VERSION}" ]; then
echo "Installing default version $DEF_VERSION"
@ -25,7 +25,7 @@ if [ $test_only -eq 0 ]; then
PKG=scala-${VERSION}
URL="http://downloads.lightbend.com/scala/${VERSION}"
URL="https://downloads.lightbend.com/scala/${VERSION}"
rpm -Uhv ${URL}/${PKG}.rpm
fi

View File

@ -4,9 +4,9 @@ echo "START: installing Scala"
DEF_VERSION="2.11.6"
if [ $test_only -eq 0 ]; then
RETURN_CODE="$(curl -s -o /dev/null -w "%{http_code}" http://www.scala-lang.org/)"
RETURN_CODE="$(curl -s -L -o /dev/null -w "%{http_code}" https://www.scala-lang.org/)"
if [ "$RETURN_CODE" != "200" ]; then
echo "http://www.scala-lang.org is unreachable" && exit 1
echo "https://www.scala-lang.org is unreachable" && exit 1
fi
if [ $(lsb_release -c -s) == "trusty" ]; then
@ -15,7 +15,7 @@ if [ $test_only -eq 0 ]; then
if [ "${scala_version}" != "1" ]; then
VERSION=$scala_version
else
VERSION="$(curl -s --fail http://www.scala-lang.org| tr -d '\n' | sed 's/^.*<div[^<]\+scala-version">[^0-9]\+\([0-9\.\?]\+\)<.\+$/\1/')"
VERSION="$(curl -s -L --fail https://www.scala-lang.org| tr -d '\n' | sed 's/^.*<div[^<]\+scala-version">[^0-9]\+\([0-9\.\?]\+\)<.\+$/\1/')"
if [ $? != 0 -o -z "${VERSION}" ]; then
echo "Installing default version $DEF_VERSION"
@ -26,7 +26,7 @@ if [ $test_only -eq 0 ]; then
PKG=scala-${VERSION}
URL="http://downloads.lightbend.com/scala/${VERSION}"
URL="https://downloads.lightbend.com/scala/${VERSION}"
wget -N ${URL}/${PKG}.deb
dpkg -i ${PKG}.deb