From ab081cd522d52a422ea5742aef36a99a31fdc86c Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 3 Jun 2020 15:18:27 -0400 Subject: [PATCH] Add warning when using outdated code-server script --- ci/build/code-server.sh | 43 ++++++++++++++++++------------------ ci/dev/lint.sh | 2 +- ci/images/centos7/Dockerfile | 8 ++++--- 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/ci/build/code-server.sh b/ci/build/code-server.sh index eae38000..831bcefc 100755 --- a/ci/build/code-server.sh +++ b/ci/build/code-server.sh @@ -5,31 +5,32 @@ set -eu # Runs code-server with the bundled node binary. _realpath() { - if [ "$(uname)" = "Linux" ]; then - readlink -f "$1" - return - fi + # See https://github.com/cdr/code-server/issues/1537 on why no realpath or readlink -f. - # See https://github.com/cdr/code-server/issues/1537 - if [ "$(uname)" = "Darwin" ]; then - script="$1" - if [ -L "$script" ]; then - while [ -L "$script" ]; do - # We recursively read the symlink, which may be relative from $script. - script="$(readlink "$script")" - cd "$(dirname "$script")" - done - else - cd "$(dirname "$script")" + script="$1" + cd "$(dirname "$script")" + + while [ -L "$(basename "$script")" ]; do + if [ -L "./node" ] && [ -L "./code-server" ] && + [ -f "package.json" ] && + cat package.json | grep -q '^ "name": "code-server",$'; then + echo "***** Please use the script in bin/code-server instead!" >&2 + echo "***** This script will soon be removed!" >&2 + echo "***** See the release notes at https://github.com/cdr/code-server/releases/tag/v3.4.0" >&2 fi - echo "$PWD/$(basename "$script")" - return - fi + script="$(readlink "$(basename "$script")")" + cd "$(dirname "$script")" + done - echo "Unsupported OS $(uname)" >&2 - exit 1 + echo "$PWD/$(basename "$script")" } -ROOT="$(dirname "$(dirname "$(_realpath "$0")")")" +root() { + script="$(_realpath "$0")" + bin_dir="$(dirname "$script")" + echo "$(dirname "$bin_dir")" +} + +ROOT="$(root)" exec "$ROOT/lib/node" "$ROOT" "$@" diff --git a/ci/dev/lint.sh b/ci/dev/lint.sh index 1d793717..219c3793 100755 --- a/ci/dev/lint.sh +++ b/ci/dev/lint.sh @@ -9,7 +9,7 @@ main() { tsc --noEmit # See comment in ./ci/image/debian8 if [[ ! ${CI-} ]]; then - shellcheck -e SC2046,SC2164,SC2154,SC1091,SC1090 $(git ls-files "*.sh") + shellcheck -e SC2046,SC2164,SC2154,SC1091,SC1090,SC2002 $(git ls-files "*.sh") fi } diff --git a/ci/images/centos7/Dockerfile b/ci/images/centos7/Dockerfile index 580c955f..58df99a8 100644 --- a/ci/images/centos7/Dockerfile +++ b/ci/images/centos7/Dockerfile @@ -1,8 +1,10 @@ FROM centos:7 -RUN curl -sL https://rpm.nodesource.com/setup_14.x | bash - && \ - yum install -y nodejs && \ - npm install -g yarn +RUN ARCH="$(uname -m | sed 's/86_64/64/; s/aarch64/arm64/')" && \ + curl -fsSL "https://nodejs.org/dist/v14.4.0/node-v14.4.0-linux-$ARCH.tar.xz" | tar -C /usr/local -xJ && \ + mv /usr/local/node-v14.4.0-linux-$ARCH /usr/local/node-v14.4.0 +ENV PATH=/usr/local/node-v14.4.0/bin:$PATH +RUN npm install -g yarn RUN yum groupinstall -y 'Development Tools' RUN yum install -y python2 libsecret-devel libX11-devel libxkbfile-devel