]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
install-deps: install dashboard_v2 development dependencies
authorRicardo Dias <rdias@suse.com>
Wed, 14 Feb 2018 15:53:47 +0000 (15:53 +0000)
committerRicardo Dias <rdias@suse.com>
Mon, 5 Mar 2018 13:07:14 +0000 (13:07 +0000)
Signed-off-by: Ricardo Dias <rdias@suse.com>
Signed-off-by: Kai Wagner <kwagner@suse.com>
install-deps.sh

index 0282b472493ce48a25d635e61298472c62e100a7..30828559166c673948e090fbd57c00e7ef1a3efc 100755 (executable)
@@ -21,6 +21,8 @@ if test $(id -u) != 0 ; then
 fi
 export LC_ALL=C # the following is vulnerable to i18n
 
+ARCH=`uname -m`
+
 function munge_ceph_spec_in {
     local OUTFILE=$1
     sed -e 's/@//g' -e 's/%bcond_with make_check/%bcond_without make_check/g' < ceph.spec.in > $OUTFILE
@@ -105,6 +107,68 @@ EOF
     fi
 }
 
+function ensure_min_npm_version {
+  local install_npm_pkg_cmd=$1
+
+  if [ "$ARCH" = "aarch64" ]; then
+    # we don't support dashboard frontend development in arm64 architecture
+    return 0
+  fi
+
+  if ! type npm > /dev/null 2>&1; then
+    $SUDO $install_npm_pkg_cmd
+  fi
+
+  NODE_VER=`node -v`
+  NODE_VER_MAJOR=`node -v | sed 's/v\(\w\+\).*/\1/g'`
+  NODE_VER_MINOR=`node -v | sed 's/v\w\+\.\(\w\+\).*/\1/g'`
+
+  # The minimum node version required is 4.8.0 so that we can use yarn below
+  UPDATE_NODE=false
+  if [ $NODE_VER_MAJOR -lt 4 ]; then
+    UPDATE_NODE=true
+  elif [ $NODE_VER_MAJOR -eq 4 ] && [ $NODE_VER_MINOR -lt 8 ]; then
+    UPDATE_NODE=true
+  fi
+  if $UPDATE_NODE; then
+    $SUDO npm install -g n
+    # installs nodejs version 4.8.0
+    $SUDO n 4.8.0
+    $SUDO npm uninstall -g n
+    hash -d node > /dev/null 2>&1 || true
+  fi
+
+  NPM_VER=`npm -v`
+  NPM_VER_MAJOR=`npm -v | sed 's/\(\w\+\).*/\1/g'`
+
+  # The minimum npm version required is 5.0.0 so that we can install and use
+  # a local nodejs installation (required by the dashboard angular2 frontend)
+  if [ $NPM_VER_MAJOR -lt 5 ]; then
+    $SUDO npm install -g yarn
+    $SUDO yarn global add npm@^5.0.0  # install npm version 5.0.0 or later
+  fi
+  hash -d npm > /dev/null 2>&1 || true
+
+  NEW_NODE_VER=`node -v`
+  NEW_NPM_VER=`npm -v`
+  if [ ! "$NODE_VER" = "$NEW_NODE_VER" ]; then
+cat <<EOF
+*****************************************************************************
+      YOUR NODE VERSION WAS UPDATED FROM $NODE_VER TO $NEW_NODE_VER
+*****************************************************************************
+EOF
+  fi
+  if [ ! "$NPM_VER" = "$NEW_NPM_VER" ]; then
+cat <<EOF
+*****************************************************************************
+      YOUR NPM VERSION WAS UPDATED FROM $NPM_VER TO $NEW_NPM_VER
+      TO RETURN TO VERSION $NPM_VER run the following command:
+          $ $SUDO yarn global remove npm && hash -d npm
+*****************************************************************************
+EOF
+  fi
+}
+
 if [ x`uname`x = xFreeBSDx ]; then
     $SUDO pkg install -yq \
         devel/babeltrace \
@@ -190,6 +254,11 @@ else
        $SUDO env DEBIAN_FRONTEND=noninteractive mk-build-deps --install --remove --tool="apt-get -y --no-install-recommends $backports" $control || exit 1
        $SUDO env DEBIAN_FRONTEND=noninteractive apt-get -y remove ceph-build-deps
        if [ -n "$backports" ] ; then rm $control; fi
+        if [ ! "$ARCH" = "aarch64" ]; then
+          $SUDO env DEBIAN_FRONTEND=noninteractive apt-get -y install nodejs
+          [ ! -e /usr/bin/node ] && $SUDO env DEBIAN_FRONTEND=noninteractive apt-get -y install nodejs-legacy
+          ensure_min_npm_version "env DEBIAN_FRONTEND=noninteractive apt-get -y install npm"
+        fi
         ;;
     centos|fedora|rhel|ol|virtuozzo)
         yumdnf="yum"
@@ -250,6 +319,7 @@ else
             ensure_decent_gcc_on_rh $dts_ver
        fi
         ! grep -q -i error: $DIR/yum-builddep.out || exit 1
+        ensure_min_npm_version "$yumdnf install -y npm"
         ;;
     opensuse|suse|sles)
         echo "Using zypper to install dependencies"
@@ -257,6 +327,7 @@ else
         $SUDO $zypp_install lsb-release systemd-rpm-macros
         munge_ceph_spec_in $DIR/ceph.spec
         $SUDO $zypp_install $(rpmspec -q --buildrequires $DIR/ceph.spec) || exit 1
+        ensure_min_npm_version "zypper --non-interactive install npm"
         ;;
     alpine)
         # for now we need the testing repo for leveldb