mapr: fix the discovery of the version of Scala

The structure of the page changed slightly between July 8th
and now (thanks Internet Archive).
Adapt the extraction code. including a more robust regex.

Also update the download location (lightbend.com instead of
typesafe.com, even if the latter is still a redirect).

Finally, expose a new variable which allows users to
force a specific version of Scala, disabling the autodetection.
This is useful to workaround possible future similar breakages
without changing the code.

Closes-Bug: #1704337

Change-Id: Ib105d08816d6833f05301e59f64163de5f070109
(cherry picked from commit 83c3011f69)
This commit is contained in:
Luigi Toscano 2017-07-14 18:12:37 +02:00
parent 873d442e3a
commit 049c2e8d3e
2 changed files with 10 additions and 3 deletions

View File

@ -37,3 +37,8 @@ DIB_MAPR_VERSION
:Required: Yes
:Description: Version of MapR to install.
:Example: ``DIB_MAPR_VERSION=5.2.0``
SCALA_VERSION
:Required: No
:Description: Force a specific version of Scala (disable autodetection).
:Example: ``SCALA_VERSION=2.12.2``

View File

@ -17,11 +17,13 @@ if [ "$RETURN_CODE" != "200" ]; then
echo "http://www.scala-lang.org is unreachable" && exit 1
fi
if [ "trusty" == "${DIB_RELEASE:-}" ]; then
if [ -n "${SCALA_VERSION:-}" ]; then
VERSION=${SCALA_VERSION}
elif [ "trusty" == "${DIB_RELEASE:-}" ]; then
# scala >= 2.12 for ubuntu depends on openjdk-8, not available on trusty
VERSION=${DEF_VERSION}
else
VERSION="$(curl -s --fail http://www.scala-lang.org|grep 'scala-version'|grep -Eo '([0-9]\.?)+')"
VERSION="$(curl -s --fail http://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"
@ -31,7 +33,7 @@ fi
PKG=scala-${VERSION}
URL="http://downloads.typesafe.com/scala/${VERSION}"
URL="http://downloads.lightbend.com/scala/${VERSION}"
if [ "$DISTRO_NAME" = "ubuntu" ]; then
wget -N ${URL}/${PKG}.deb