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
This commit is contained in:
Luigi Toscano 2017-07-14 18:12:37 +02:00
parent 802379aba6
commit 83c3011f69
2 changed files with 10 additions and 3 deletions

View File

@ -37,3 +37,8 @@ DIB_MAPR_VERSION
:Required: Yes :Required: Yes
:Description: Version of MapR to install. :Description: Version of MapR to install.
:Example: ``DIB_MAPR_VERSION=5.2.0`` :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 echo "http://www.scala-lang.org is unreachable" && exit 1
fi fi
if [ "trusty" == "${DIB_RELEASE:-}" ]; then if [ -n "${SCALA_VERSION:-}" ]; then
VERSION=${SCALA_VERSION}
elif [ "trusty" == "${DIB_RELEASE:-}" ]; then
# scale >= 2.12 for ubuntu depends on openjdk-8, not available on trusty # scale >= 2.12 for ubuntu depends on openjdk-8, not available on trusty
VERSION=${DEF_VERSION} VERSION=${DEF_VERSION}
else 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 if [ $? != 0 -o -z "${VERSION}" ]; then
echo "Installing default version $DEF_VERSION" echo "Installing default version $DEF_VERSION"
@ -31,7 +33,7 @@ fi
PKG=scala-${VERSION} PKG=scala-${VERSION}
URL="http://downloads.typesafe.com/scala/${VERSION}" URL="http://downloads.lightbend.com/scala/${VERSION}"
if [ "$DISTRO_NAME" = "ubuntu" ]; then if [ "$DISTRO_NAME" = "ubuntu" ]; then
wget -N ${URL}/${PKG}.deb wget -N ${URL}/${PKG}.deb