From 7ab47b3d833436f9107a529069ae77efae840378 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 28 May 2020 00:49:37 -0400 Subject: [PATCH 01/14] Trim LD_LIBRARY_PATH on startup --- ci/build/code-server.sh | 17 +++++++++-------- src/node/entry.ts | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/ci/build/code-server.sh b/ci/build/code-server.sh index aca05745..4793cc5b 100755 --- a/ci/build/code-server.sh +++ b/ci/build/code-server.sh @@ -5,21 +5,22 @@ # More complicated than readlink -f or realpath to support macOS. # See https://github.com/cdr/code-server/issues/1537 -bin_dir() { +root_dir() { # We read the symlink, which may be relative from $0. dst="$(readlink "$0")" # We cd into the $0 directory. cd "$(dirname "$0")" || exit 1 - # Now we can cd into the dst directory. - cd "$(dirname "$dst")" || exit 1 - # Finally we use pwd -P to print the absolute path of the directory of $dst. + # Now we can cd into the directory above the dst directory which is the root + # of the release. + cd "$(dirname "$dst")/.." || exit 1 + # Finally we use pwd -P to print the absolute path the root. pwd -P || exit 1 } -BIN_DIR=$(bin_dir) +ROOT="$(root_dir)" if [ "$(uname)" = "Linux" ]; then - export LD_LIBRARY_PATH="$BIN_DIR/../lib${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}" + export LD_LIBRARY_PATH="$ROOT/lib:$LD_LIBRARY_PATH" elif [ "$(uname)" = "Darwin" ]; then - export DYLD_LIBRARY_PATH="$BIN_DIR/../lib${DYLD_LIBRARY_PATH+:$DYLD_LIBRARY_PATH}" + export DYLD_LIBRARY_PATH="$ROOT/lib:$DYLD_LIBRARY_PATH" fi -exec "$BIN_DIR/../lib/node" "$BIN_DIR/.." "$@" +exec "$ROOT/lib/node" "$ROOT" "$@" diff --git a/src/node/entry.ts b/src/node/entry.ts index 69d32ca8..42907784 100644 --- a/src/node/entry.ts +++ b/src/node/entry.ts @@ -126,7 +126,25 @@ const main = async (cliArgs: Args): Promise => { } } +function trimLDLibraryPath(): void { + let ldVar: string + if (process.platform === "linux") { + ldVar = "LD_LIBRARY_PATH" + } else if (process.platform === "darwin") { + ldVar = "DYLD_LIBRARY_PATH" + } else { + return + } + + // Removes the leading path added by ./ci/build/code-server.sh to use our bundled + // dynamic libraries. See ci/build/build-standalone-release.sh + // This is required to avoid child processes using our bundled libraries. + process.env[ldVar] = process.env[ldVar]?.replace(path.dirname(process.execPath) + ":", "") +} + async function entry(): Promise { + trimLDLibraryPath() + const tryParse = async (): Promise => { try { let args = parse(process.argv.slice(2)) From 2c2a6498afe6588e1c2221d2fc2d748a5589c919 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 28 May 2020 03:31:11 -0400 Subject: [PATCH 02/14] Parse config file in entry This way setting --data-dir and --extension-dir in the config file will work for --install--extension and whatnot. --- src/node/entry.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/node/entry.ts b/src/node/entry.ts index 42907784..53f99d10 100644 --- a/src/node/entry.ts +++ b/src/node/entry.ts @@ -31,11 +31,7 @@ try { const version = pkg.version || "development" const commit = pkg.commit || "development" -const main = async (cliArgs: Args): Promise => { - const configArgs = await readConfigFile(cliArgs.config) - // This prioritizes the flags set in args over the ones in the config file. - let args = Object.assign(configArgs, cliArgs) - +const main = async (args: Args, cliArgs: Args, configArgs: Args): Promise => { if (!args.auth) { args = { ...args, @@ -145,18 +141,21 @@ function trimLDLibraryPath(): void { async function entry(): Promise { trimLDLibraryPath() - const tryParse = async (): Promise => { + const tryParse = async (): Promise<[Args, Args, Args]> => { try { - let args = parse(process.argv.slice(2)) + const cliArgs = parse(process.argv.slice(2)) + const configArgs = await readConfigFile(cliArgs.config) + // This prioritizes the flags set in args over the ones in the config file. + let args = Object.assign(configArgs, cliArgs) args = await setDefaults(args) - return args + return [args, cliArgs, configArgs] } catch (error) { console.error(error.message) process.exit(1) } } - const args = await tryParse() + const [args, cliArgs, configArgs] = await tryParse() if (args.help) { console.log("code-server", version, commit) console.log("") @@ -200,7 +199,7 @@ async function entry(): Promise { }) vscode.on("exit", (code) => process.exit(code || 0)) } else { - wrap(() => main(args)) + wrap(() => main(args, cliArgs, configArgs)) } } From 206f195c1cbb08f6c9d610876fb7d9e397f44a97 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 3 Jun 2020 10:04:49 -0400 Subject: [PATCH 03/14] Minor grammar fixes in FAQ --- doc/FAQ.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/FAQ.md b/doc/FAQ.md index fdeb7c58..154aef3b 100644 --- a/doc/FAQ.md +++ b/doc/FAQ.md @@ -47,14 +47,15 @@ However, it is not entirely equivalent to Microsoft's VS Code. While the core of VS Code is open source, the marketplace and many published Microsoft extensions are not. -Not only are they closed source, Microsoft prohibits the use of any non-Microsoft VS Code from accessing their marketplace. +Furthermore, Microsoft prohibits the use of any non-Microsoft VS Code from accessing their marketplace. See the [TOS](https://cdn.vsassets.io/v/M146_20190123.39/_content/Microsoft-Visual-Studio-Marketplace-Terms-of-Use.pdf). > Marketplace Offerings are intended for use only with Visual Studio Products and Services > and you may only install and use Marketplace Offerings with Visual Studio Products and Services. -As a result, we have created our own marketplace for open source extensions. +As a result, we cannot offer any extensions on the Microsoft marketplace. Instead, +we have created our own marketplace for open source extensions. It works by scraping GitHub for VS Code extensions and building them. It's not perfect but getting better by the day with more and more extensions. From 02a77b528ba0fcc2df9d72a7e5312e405c407bbd Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 3 Jun 2020 10:32:11 -0400 Subject: [PATCH 04/14] Support recursive symlinks in release script See https://github.com/cdr/code-server/issues/1746#issuecomment-637830396 --- ci/build/code-server.sh | 44 +++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/ci/build/code-server.sh b/ci/build/code-server.sh index 4793cc5b..62b59a0f 100755 --- a/ci/build/code-server.sh +++ b/ci/build/code-server.sh @@ -1,26 +1,40 @@ #!/bin/sh +set -eu # This script is intended to be bundled into the standalone releases. # Runs code-server with the bundled node binary. -# More complicated than readlink -f or realpath to support macOS. -# See https://github.com/cdr/code-server/issues/1537 -root_dir() { - # We read the symlink, which may be relative from $0. - dst="$(readlink "$0")" - # We cd into the $0 directory. - cd "$(dirname "$0")" || exit 1 - # Now we can cd into the directory above the dst directory which is the root - # of the release. - cd "$(dirname "$dst")/.." || exit 1 - # Finally we use pwd -P to print the absolute path the root. - pwd -P || exit 1 +_realpath() { + if [ "$(uname)" = "Linux" ]; then + readlink -f "$1" + return + fi + + # See https://github.com/cdr/code-server/issues/1537 + if [ "$(uname)" = "Darwin" ]; then + # We read the symlink, which may be relative from $1. + script="$1" + if [ -L "$script" ]; then + while [ -L "$script" ]; do + script="$(readlink "$script")" + cd "$(dirname "$script")" + done + else + cd "$(dirname "$script")" + fi + + echo "$PWD/$(basename "$script")" + return + fi + + echo "Unsupported OS $(uname)" >&2 + exit 1 } -ROOT="$(root_dir)" +ROOT="$(dirname "$(dirname "$(_realpath "$0")")")" if [ "$(uname)" = "Linux" ]; then - export LD_LIBRARY_PATH="$ROOT/lib:$LD_LIBRARY_PATH" + export LD_LIBRARY_PATH="$ROOT/lib:${LD_LIBRARY_PATH-}" elif [ "$(uname)" = "Darwin" ]; then - export DYLD_LIBRARY_PATH="$ROOT/lib:$DYLD_LIBRARY_PATH" + export DYLD_LIBRARY_PATH="$ROOT/lib:${DYLD_LIBRARY_PATH-}" fi exec "$ROOT/lib/node" "$ROOT" "$@" From 11d793296805253a2f4d289f5e7741fe3bcfbfa4 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 3 Jun 2020 11:41:13 -0400 Subject: [PATCH 05/14] Stop bundling libraries in release - Instead we now use CentOS 7 for the static build to guarantee that we only depend on libc v2.17 - For macOS we now pull in a static node binary and bundle that instead. --- .github/workflows/ci.yaml | 6 ++-- .gitignore | 1 + ci/build/build-standalone-release.sh | 21 ----------- ci/build/code-server.sh | 7 +--- ci/build/test-standalone-release.sh | 3 +- ci/container/Dockerfile | 2 +- ci/container/arm64/Dockerfile | 53 ---------------------------- ci/container/arm64/README.md | 6 ---- ci/container/centos/Dockerfile | 22 ++++++++++++ ci/steps/release-packages.sh | 5 +++ doc/npm.md | 2 +- src/node/entry.ts | 18 ---------- 12 files changed, 35 insertions(+), 111 deletions(-) delete mode 100644 ci/container/arm64/Dockerfile delete mode 100644 ci/container/arm64/README.md create mode 100644 ci/container/centos/Dockerfile diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4696df2e..f3f3e72c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -55,7 +55,7 @@ jobs: name: npm-package path: ./release-npm-package - name: Run ./ci/steps/release-packages.sh - uses: ./ci/container + uses: ./ci/container/centos with: args: ./ci/steps/release-packages.sh - name: Upload release artifacts @@ -75,7 +75,7 @@ jobs: name: npm-package path: ./release-npm-package - name: Run ./ci/steps/release-packages.sh - uses: ./ci/container/arm64 + uses: ./ci/container/centos with: args: ./ci/steps/release-packages.sh - name: Upload release artifacts @@ -94,8 +94,6 @@ jobs: with: name: npm-package path: ./release-npm-package - - run: brew unlink node@12 - - run: brew install node - run: ./ci/steps/release-packages.sh env: # Otherwise we get rate limited when fetching the ripgrep binary. diff --git a/.gitignore b/.gitignore index 5c10b876..424cb9e7 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ release-packages/ release-gcp/ release-images/ node_modules +node-* diff --git a/ci/build/build-standalone-release.sh b/ci/build/build-standalone-release.sh index 2556e44b..df6cdc56 100755 --- a/ci/build/build-standalone-release.sh +++ b/ci/build/build-standalone-release.sh @@ -17,14 +17,6 @@ main() { mkdir -p "$RELEASE_PATH/bin" rsync ./ci/build/code-server.sh "$RELEASE_PATH/bin/code-server" rsync "$node_path" "$RELEASE_PATH/lib/node" - if [[ $OS == "linux" ]]; then - bundle_dynamic_lib libstdc++ - bundle_dynamic_lib libgcc_s - elif [[ $OS == "macos" ]]; then - bundle_dynamic_lib libicui18n - bundle_dynamic_lib libicuuc - bundle_dynamic_lib libicudata - fi ln -s "./bin/code-server" "$RELEASE_PATH/code-server" ln -s "./lib/node" "$RELEASE_PATH/node" @@ -33,17 +25,4 @@ main() { yarn --production --frozen-lockfile } -bundle_dynamic_lib() { - local lib_name="$1" - local lib_path - - if [[ $OS == "linux" ]]; then - lib_path="$(ldd "$RELEASE_PATH/lib/node" | grep "$lib_name" | awk '{print $3 }')" - elif [[ $OS == "macos" ]]; then - lib_path="$(otool -L "$RELEASE_PATH/lib/node" | grep "$lib_name" | awk '{print $1 }')" - fi - - cp "$lib_path" "$RELEASE_PATH/lib" -} - main "$@" diff --git a/ci/build/code-server.sh b/ci/build/code-server.sh index 62b59a0f..eae38000 100755 --- a/ci/build/code-server.sh +++ b/ci/build/code-server.sh @@ -12,10 +12,10 @@ _realpath() { # See https://github.com/cdr/code-server/issues/1537 if [ "$(uname)" = "Darwin" ]; then - # We read the symlink, which may be relative from $1. 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 @@ -32,9 +32,4 @@ _realpath() { } ROOT="$(dirname "$(dirname "$(_realpath "$0")")")" -if [ "$(uname)" = "Linux" ]; then - export LD_LIBRARY_PATH="$ROOT/lib:${LD_LIBRARY_PATH-}" -elif [ "$(uname)" = "Darwin" ]; then - export DYLD_LIBRARY_PATH="$ROOT/lib:${DYLD_LIBRARY_PATH-}" -fi exec "$ROOT/lib/node" "$ROOT" "$@" diff --git a/ci/build/test-standalone-release.sh b/ci/build/test-standalone-release.sh index 0344ea39..488a057a 100755 --- a/ci/build/test-standalone-release.sh +++ b/ci/build/test-standalone-release.sh @@ -15,7 +15,8 @@ main() { ./release-standalone/bin/code-server --extensions-dir "$EXTENSIONS_DIR" --install-extension ms-python.python local installed_extensions installed_extensions="$(./release-standalone/bin/code-server --extensions-dir "$EXTENSIONS_DIR" --list-extensions 2>&1)" - if [[ $installed_extensions != "ms-python.python" ]]; then + if [[ "$installed_extensions" != "info Using config file ~/.config/code-server/config.yaml +ms-python.python" ]]; then echo "Unexpected output from listing extensions:" echo "$installed_extensions" exit 1 diff --git a/ci/container/Dockerfile b/ci/container/Dockerfile index 8612f84d..fa3b16dc 100644 --- a/ci/container/Dockerfile +++ b/ci/container/Dockerfile @@ -43,7 +43,7 @@ RUN ARCH="$(dpkg --print-architecture)" && \ # rm -R shellcheck* # Install Go dependencies -RUN ARCH="$(dpkg --print-architecture)" && \ +RUN ARCH="$(uname -m | sed 's/x86_64/amd64/; s/aarch64/arm64/')" && \ curl -fsSL "https://dl.google.com/go/go1.14.3.linux-$ARCH.tar.gz" | tar -C /usr/local -xz ENV PATH=/usr/local/go/bin:/root/go/bin:$PATH ENV GO111MODULE=on diff --git a/ci/container/arm64/Dockerfile b/ci/container/arm64/Dockerfile deleted file mode 100644 index 705365bc..00000000 --- a/ci/container/arm64/Dockerfile +++ /dev/null @@ -1,53 +0,0 @@ -FROM debian:9 - -RUN apt-get update - -# Needed for debian repositories added below. -RUN apt-get install -y curl gnupg - -# Installs node. -RUN curl -fsSL https://deb.nodesource.com/setup_14.x | bash - && \ - apt-get install -y nodejs - -# Installs yarn. -RUN curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \ - apt-get update && apt-get install -y yarn - -# Installs VS Code build deps. -RUN apt-get install -y build-essential \ - libsecret-1-dev \ - libx11-dev \ - libxkbfile-dev - -# Installs envsubst. -RUN apt-get install -y gettext-base - -# Misc build dependencies. -RUN apt-get install -y git rsync unzip - -# We need latest jq from debian buster for date support. -RUN ARCH="$(dpkg --print-architecture)" && \ - curl -fsSOL http://http.us.debian.org/debian/pool/main/libo/libonig/libonig5_6.9.1-1_$ARCH.deb && \ - dpkg -i libonig*.deb && \ - curl -fsSOL http://http.us.debian.org/debian/pool/main/j/jq/libjq1_1.5+dfsg-2+b1_$ARCH.deb && \ - dpkg -i libjq*.deb && \ - curl -fsSOL http://http.us.debian.org/debian/pool/main/j/jq/jq_1.5+dfsg-2+b1_$ARCH.deb && \ - dpkg -i jq*.deb && rm *.deb - -# Installs shellcheck. -# Unfortunately coredumps on debian:8 so disabled for now. -#RUN curl -fsSL https://github.com/koalaman/shellcheck/releases/download/v0.7.1/shellcheck-v0.7.1.linux.$(uname -m).tar.xz | \ -# tar -xJ && \ -# mv shellcheck*/shellcheck /usr/local/bin && \ -# rm -R shellcheck* - -# Install Go dependencies -RUN ARCH="$(dpkg --print-architecture)" && \ - curl -fsSL "https://dl.google.com/go/go1.14.3.linux-$ARCH.tar.gz" | tar -C /usr/local -xz -ENV PATH=/usr/local/go/bin:/root/go/bin:$PATH -ENV GO111MODULE=on -RUN go get mvdan.cc/sh/v3/cmd/shfmt -RUN go get github.com/goreleaser/nfpm/cmd/nfpm - -RUN curl -fsSL https://get.docker.com | sh diff --git a/ci/container/arm64/README.md b/ci/container/arm64/README.md deleted file mode 100644 index 388572ca..00000000 --- a/ci/container/arm64/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# arm64 - -Unfortunately there is no arm64 build of `debian:8` so -we need to use `debian:9` instead. - -This is just an exact copy of [../Dockerfile](../Dockerfile) with the base image change. diff --git a/ci/container/centos/Dockerfile b/ci/container/centos/Dockerfile new file mode 100644 index 00000000..43ad9431 --- /dev/null +++ b/ci/container/centos/Dockerfile @@ -0,0 +1,22 @@ +FROM centos:7 + +RUN curl -sL https://rpm.nodesource.com/setup_14.x | bash - && \ + yum install -y nodejs && + npm install -g yarn + +RUN yum groupinstall -y 'Development Tools' +RUN yum install -y python2 libsecret-devel libX11-devel libxkbfile-devel + +RUN npm config set python python2 + +RUN yum install -y epel-release && yum install -y jq +RUN yum install -y rsync + +# Copied from ../Dockerfile +# Install Go dependencies +RUN ARCH="$(uname -m | sed 's/x86_64/amd64/; s/aarch64/arm64/')" && \ + curl -fsSL "https://dl.google.com/go/go1.14.3.linux-$ARCH.tar.gz" | tar -C /usr/local -xz +ENV PATH=/usr/local/go/bin:/root/go/bin:$PATH +ENV GO111MODULE=on +RUN go get mvdan.cc/sh/v3/cmd/shfmt +RUN go get github.com/goreleaser/nfpm/cmd/nfpm diff --git a/ci/steps/release-packages.sh b/ci/steps/release-packages.sh index bb1dcf5f..cdfcf914 100755 --- a/ci/steps/release-packages.sh +++ b/ci/steps/release-packages.sh @@ -4,6 +4,11 @@ set -euo pipefail main() { cd "$(dirname "$0")/../.." + if [[ "$OSTYPE" == darwin* ]]; then + curl -L https://nodejs.org/dist/v14.4.0/node-v14.4.0-darwin-x64.tar.gz | tar -xz + PATH="$PATH:node-v14.4.0-darwin-x64/bin" + fi + # https://github.com/actions/upload-artifact/issues/38 tar -xzf release-npm-package/package.tar.gz diff --git a/doc/npm.md b/doc/npm.md index 18d9fc5e..a612ba8c 100644 --- a/doc/npm.md +++ b/doc/npm.md @@ -20,7 +20,7 @@ sudo apt-get install -y \ ```bash sudo yum groupinstall -y 'Development Tools' -sudo yum config-manager --set-enabled PowerTools +sudo yum config-manager --set-enabled PowerTools # unnecessary on CentOS 7 sudo yum install -y python2 libsecret-devel libX11-devel libxkbfile-devel npm config set python python2 ``` diff --git a/src/node/entry.ts b/src/node/entry.ts index 53f99d10..a7d8663d 100644 --- a/src/node/entry.ts +++ b/src/node/entry.ts @@ -122,25 +122,7 @@ const main = async (args: Args, cliArgs: Args, configArgs: Args): Promise } } -function trimLDLibraryPath(): void { - let ldVar: string - if (process.platform === "linux") { - ldVar = "LD_LIBRARY_PATH" - } else if (process.platform === "darwin") { - ldVar = "DYLD_LIBRARY_PATH" - } else { - return - } - - // Removes the leading path added by ./ci/build/code-server.sh to use our bundled - // dynamic libraries. See ci/build/build-standalone-release.sh - // This is required to avoid child processes using our bundled libraries. - process.env[ldVar] = process.env[ldVar]?.replace(path.dirname(process.execPath) + ":", "") -} - async function entry(): Promise { - trimLDLibraryPath() - const tryParse = async (): Promise<[Args, Args, Args]> => { try { const cliArgs = parse(process.argv.slice(2)) From bdb670e8523b534fe6119e1e83d30f3d9e076811 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 3 Jun 2020 12:07:42 -0400 Subject: [PATCH 06/14] Rename container and release-container to images and release-image --- .github/workflows/ci.yaml | 16 ++++++++-------- .github/workflows/publish.yaml | 4 ++-- ci/README.md | 10 +++++----- ci/build/test-standalone-release.sh | 2 +- ci/dev/fmt.sh | 2 ++ ci/dev/lint.sh | 2 +- .../centos => images/centos:7}/Dockerfile | 0 ci/{container => images/debian:8}/Dockerfile | 0 .../Dockerfile | 0 ci/{release-container => release-image}/build.sh | 2 +- ci/steps/build-docker-image.sh | 2 +- ci/steps/release-packages.sh | 2 +- doc/CONTRIBUTING.md | 12 +++++++++++- doc/npm.md | 8 ++++++++ 14 files changed, 41 insertions(+), 21 deletions(-) rename ci/{container/centos => images/centos:7}/Dockerfile (100%) rename ci/{container => images/debian:8}/Dockerfile (100%) rename ci/{release-container => release-image}/Dockerfile (100%) rename ci/{release-container => release-image}/build.sh (85%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f3f3e72c..03bd00b0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,7 +8,7 @@ jobs: steps: - uses: actions/checkout@v1 - name: Run ./ci/steps/fmt.sh - uses: ./ci/container + uses: ./ci/images/debian:8 with: args: ./ci/steps/fmt.sh @@ -17,7 +17,7 @@ jobs: steps: - uses: actions/checkout@v1 - name: Run ./ci/steps/lint.sh - uses: ./ci/container + uses: ./ci/images/debian:8 with: args: ./ci/steps/lint.sh @@ -26,7 +26,7 @@ jobs: steps: - uses: actions/checkout@v1 - name: Run ./ci/steps/test.sh - uses: ./ci/container + uses: ./ci/images/debian:8 with: args: ./ci/steps/test.sh @@ -35,7 +35,7 @@ jobs: steps: - uses: actions/checkout@v1 - name: Run ./ci/steps/release.sh - uses: ./ci/container + uses: ./ci/images/debian:8 with: args: ./ci/steps/release.sh - name: Upload npm package artifact @@ -55,7 +55,7 @@ jobs: name: npm-package path: ./release-npm-package - name: Run ./ci/steps/release-packages.sh - uses: ./ci/container/centos + uses: ./ci/images/centos:7 with: args: ./ci/steps/release-packages.sh - name: Upload release artifacts @@ -75,7 +75,7 @@ jobs: name: npm-package path: ./release-npm-package - name: Run ./ci/steps/release-packages.sh - uses: ./ci/container/centos + uses: ./ci/images/centos:7 with: args: ./ci/steps/release-packages.sh - name: Upload release artifacts @@ -116,7 +116,7 @@ jobs: name: release-packages path: ./release-packages - name: Run ./ci/steps/build-docker-image.sh - uses: ./ci/container + uses: ./ci/images/debian:8 with: args: ./ci/steps/build-docker-image.sh - name: Upload release image @@ -136,7 +136,7 @@ jobs: name: release-packages path: ./release-packages - name: Run ./ci/steps/build-docker-image.sh - uses: ./ci/container/arm64 + uses: ./ci/images/debian:8 with: args: ./ci/steps/build-docker-image.sh - name: Upload release image diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 2bb7df09..0eede125 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -10,7 +10,7 @@ jobs: steps: - uses: actions/checkout@v1 - name: Run ./ci/steps/publish-npm.sh - uses: ./ci/container + uses: ./ci/images/debian:8 with: args: ./ci/steps/publish-npm.sh env: @@ -22,7 +22,7 @@ jobs: steps: - uses: actions/checkout@v1 - name: Run ./ci/steps/push-docker-manifest.sh - uses: ./ci/container + uses: ./ci/images/debian:8 with: args: ./ci/steps/push-docker-manifest.sh env: diff --git a/ci/README.md b/ci/README.md index 4ab6da56..38fb3d27 100644 --- a/ci/README.md +++ b/ci/README.md @@ -104,17 +104,17 @@ You can disable minification by setting `MINIFY=`. - Post install script for the npm package. - Bundled by`yarn release`. -## release-container +## release-image -This directory contains the release docker container. +This directory contains the release docker container image. -- [./release-container/build.sh](./release-container/build.sh) +- [./release-image/build.sh](./release-image/build.sh) - Builds the release container with the tag `codercom/code-server-$ARCH:$VERSION`. - Assumes debian releases are ready in `./release-packages`. -## container +## images -This directory contains the container for CI. +This directory contains the images for CI. ## steps diff --git a/ci/build/test-standalone-release.sh b/ci/build/test-standalone-release.sh index 488a057a..0d7010a2 100755 --- a/ci/build/test-standalone-release.sh +++ b/ci/build/test-standalone-release.sh @@ -15,7 +15,7 @@ main() { ./release-standalone/bin/code-server --extensions-dir "$EXTENSIONS_DIR" --install-extension ms-python.python local installed_extensions installed_extensions="$(./release-standalone/bin/code-server --extensions-dir "$EXTENSIONS_DIR" --list-extensions 2>&1)" - if [[ "$installed_extensions" != "info Using config file ~/.config/code-server/config.yaml + if [[ $installed_extensions != "info Using config file ~/.config/code-server/config.yaml ms-python.python" ]]; then echo "Unexpected output from listing extensions:" echo "$installed_extensions" diff --git a/ci/dev/fmt.sh b/ci/dev/fmt.sh index d7ebdbbf..b619a7e4 100755 --- a/ci/dev/fmt.sh +++ b/ci/dev/fmt.sh @@ -24,6 +24,8 @@ main() { doctoc --title '# FAQ' doc/FAQ.md > /dev/null doctoc --title '# Setup Guide' doc/guide.md > /dev/null doctoc --title '# Install' doc/install.md > /dev/null + doctoc --title '# npm Install Requirements' doc/npm.md > /dev/null + doctoc --title '# Contributing' doc/CONTRIBUTING.md > /dev/null if [[ ${CI-} && $(git ls-files --other --modified --exclude-standard) ]]; then echo "Files need generation or are formatted incorrectly:" diff --git a/ci/dev/lint.sh b/ci/dev/lint.sh index f9f54202..72de463e 100755 --- a/ci/dev/lint.sh +++ b/ci/dev/lint.sh @@ -7,7 +7,7 @@ main() { eslint --max-warnings=0 --fix $(git ls-files "*.ts" "*.tsx" "*.js") stylelint $(git ls-files "*.css") tsc --noEmit - # See comment in ./ci/container/Dockerfile + # See comment in ./ci/image/debian:8 if [[ ! ${CI-} ]]; then shellcheck -e SC2046,SC2164,SC2154,SC1091,SC1090 $(git ls-files "*.sh") fi diff --git a/ci/container/centos/Dockerfile b/ci/images/centos:7/Dockerfile similarity index 100% rename from ci/container/centos/Dockerfile rename to ci/images/centos:7/Dockerfile diff --git a/ci/container/Dockerfile b/ci/images/debian:8/Dockerfile similarity index 100% rename from ci/container/Dockerfile rename to ci/images/debian:8/Dockerfile diff --git a/ci/release-container/Dockerfile b/ci/release-image/Dockerfile similarity index 100% rename from ci/release-container/Dockerfile rename to ci/release-image/Dockerfile diff --git a/ci/release-container/build.sh b/ci/release-image/build.sh similarity index 85% rename from ci/release-container/build.sh rename to ci/release-image/build.sh index e91ea33c..5969e15a 100755 --- a/ci/release-container/build.sh +++ b/ci/release-image/build.sh @@ -5,7 +5,7 @@ main() { cd "$(dirname "$0")/../.." source ./ci/lib.sh - docker build -t "codercom/code-server-$ARCH:$VERSION" -f ./ci/release-container/Dockerfile . + docker build -t "codercom/code-server-$ARCH:$VERSION" -f ./ci/release-image/Dockerfile . } main "$@" diff --git a/ci/steps/build-docker-image.sh b/ci/steps/build-docker-image.sh index 692fa40f..16653a0e 100755 --- a/ci/steps/build-docker-image.sh +++ b/ci/steps/build-docker-image.sh @@ -5,7 +5,7 @@ main() { cd "$(dirname "$0")/../.." source ./ci/lib.sh - ./ci/release-container/build.sh + ./ci/release-image/build.sh mkdir -p release-images docker save "codercom/code-server-$ARCH:$VERSION" > "release-images/code-server-$ARCH-$VERSION.tar" diff --git a/ci/steps/release-packages.sh b/ci/steps/release-packages.sh index cdfcf914..39c51063 100755 --- a/ci/steps/release-packages.sh +++ b/ci/steps/release-packages.sh @@ -4,7 +4,7 @@ set -euo pipefail main() { cd "$(dirname "$0")/../.." - if [[ "$OSTYPE" == darwin* ]]; then + if [[ $OSTYPE == darwin* ]]; then curl -L https://nodejs.org/dist/v14.4.0/node-v14.4.0-darwin-x64.tar.gz | tar -xz PATH="$PATH:node-v14.4.0-darwin-x64/bin" fi diff --git a/doc/CONTRIBUTING.md b/doc/CONTRIBUTING.md index 5e3f689c..9e4a1d5e 100644 --- a/doc/CONTRIBUTING.md +++ b/doc/CONTRIBUTING.md @@ -1,5 +1,15 @@ + + # Contributing +- [Requirements](#requirements) +- [Development Workflow](#development-workflow) +- [Build](#build) +- [Structure](#structure) + - [VS Code Patch](#vs-code-patch) + + + - [Detailed CI and build process docs](../ci) ## Requirements @@ -11,7 +21,7 @@ Differences: - We require a minimum of node v12 but later versions should work. - We use [fnpm](https://github.com/goreleaser/nfpm) to build `.deb` and `.rpm` packages. - We use [jq](https://stedolan.github.io/jq/) to build code-server releases. -- The [CI container](../ci/container/Dockerfile) is a useful reference for all our dependencies. +- The [CI container](../ci/images/debian:8/Dockerfile) is a useful reference for all our dependencies. ## Development Workflow diff --git a/doc/npm.md b/doc/npm.md index a612ba8c..f4d0ee09 100644 --- a/doc/npm.md +++ b/doc/npm.md @@ -1,5 +1,13 @@ + + # npm Install Requirements +- [Ubuntu, Debian](#ubuntu-debian) +- [Fedora, CentOS, RHEL](#fedora-centos-rhel) +- [macOS](#macos) + + + If you're installing the npm module you'll need certain dependencies to build the native modules used by VS Code. From 5815b4a0c0dbb75e9f4d8df8f524bfe764acfea0 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 3 Jun 2020 12:09:01 -0400 Subject: [PATCH 07/14] Rename dev/container -> dev/image --- .ignore | 1 + ci/README.md | 2 +- ci/dev/{container => image}/Dockerfile | 0 ci/dev/{container => image}/exec.sh | 2 +- doc/CONTRIBUTING.md | 2 +- 5 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 .ignore rename ci/dev/{container => image}/Dockerfile (100%) rename ci/dev/{container => image}/exec.sh (93%) diff --git a/.ignore b/.ignore new file mode 100644 index 00000000..a65b4177 --- /dev/null +++ b/.ignore @@ -0,0 +1 @@ +lib diff --git a/ci/README.md b/ci/README.md index 38fb3d27..01e8a56a 100644 --- a/ci/README.md +++ b/ci/README.md @@ -40,7 +40,7 @@ Make sure you have `$GITHUB_TOKEN` set and [hub](https://github.com/github/hub) This directory contains scripts used for the development of code-server. -- [./ci/dev/container](./dev/container) +- [./ci/dev/image](./dev/image) - See [./doc/CONTRIBUTING.md](../doc/CONTRIBUTING.md) for docs on the development container. - [./ci/dev/fmt.sh](./dev/fmt.sh) (`yarn fmt`) - Runs formatters. diff --git a/ci/dev/container/Dockerfile b/ci/dev/image/Dockerfile similarity index 100% rename from ci/dev/container/Dockerfile rename to ci/dev/image/Dockerfile diff --git a/ci/dev/container/exec.sh b/ci/dev/image/exec.sh similarity index 93% rename from ci/dev/container/exec.sh rename to ci/dev/image/exec.sh index 98231c73..ea208755 100755 --- a/ci/dev/container/exec.sh +++ b/ci/dev/image/exec.sh @@ -42,7 +42,7 @@ run() { build() { echo "--- Building $container_name" - docker build -t $container_name ./ci/dev/container > /dev/null + docker build -t $container_name ./ci/dev/image > /dev/null } main "$@" diff --git a/doc/CONTRIBUTING.md b/doc/CONTRIBUTING.md index 9e4a1d5e..706a5648 100644 --- a/doc/CONTRIBUTING.md +++ b/doc/CONTRIBUTING.md @@ -35,7 +35,7 @@ yarn watch To develop inside of an isolated docker container: ```shell -./ci/dev/container/exec.sh +./ci/dev/image/exec.sh root@12345:/code-server# yarn root@12345:/code-server# yarn vscode From d4ef7c14120733d58a22888ccebaa6fad706cc96 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 3 Jun 2020 12:14:55 -0400 Subject: [PATCH 08/14] Remove colons from image filenames --- .github/workflows/ci.yaml | 16 ++++++++-------- .github/workflows/publish.yaml | 4 ++-- ci/dev/lint.sh | 2 +- ci/images/{centos:7 => centos7}/Dockerfile | 0 ci/images/{debian:8 => debian8}/Dockerfile | 0 doc/CONTRIBUTING.md | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) rename ci/images/{centos:7 => centos7}/Dockerfile (100%) rename ci/images/{debian:8 => debian8}/Dockerfile (100%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 03bd00b0..1cb58963 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,7 +8,7 @@ jobs: steps: - uses: actions/checkout@v1 - name: Run ./ci/steps/fmt.sh - uses: ./ci/images/debian:8 + uses: ./ci/images/debian8 with: args: ./ci/steps/fmt.sh @@ -17,7 +17,7 @@ jobs: steps: - uses: actions/checkout@v1 - name: Run ./ci/steps/lint.sh - uses: ./ci/images/debian:8 + uses: ./ci/images/debian8 with: args: ./ci/steps/lint.sh @@ -26,7 +26,7 @@ jobs: steps: - uses: actions/checkout@v1 - name: Run ./ci/steps/test.sh - uses: ./ci/images/debian:8 + uses: ./ci/images/debian8 with: args: ./ci/steps/test.sh @@ -35,7 +35,7 @@ jobs: steps: - uses: actions/checkout@v1 - name: Run ./ci/steps/release.sh - uses: ./ci/images/debian:8 + uses: ./ci/images/debian8 with: args: ./ci/steps/release.sh - name: Upload npm package artifact @@ -55,7 +55,7 @@ jobs: name: npm-package path: ./release-npm-package - name: Run ./ci/steps/release-packages.sh - uses: ./ci/images/centos:7 + uses: ./ci/images/centos7 with: args: ./ci/steps/release-packages.sh - name: Upload release artifacts @@ -75,7 +75,7 @@ jobs: name: npm-package path: ./release-npm-package - name: Run ./ci/steps/release-packages.sh - uses: ./ci/images/centos:7 + uses: ./ci/images/centos7 with: args: ./ci/steps/release-packages.sh - name: Upload release artifacts @@ -116,7 +116,7 @@ jobs: name: release-packages path: ./release-packages - name: Run ./ci/steps/build-docker-image.sh - uses: ./ci/images/debian:8 + uses: ./ci/images/debian8 with: args: ./ci/steps/build-docker-image.sh - name: Upload release image @@ -136,7 +136,7 @@ jobs: name: release-packages path: ./release-packages - name: Run ./ci/steps/build-docker-image.sh - uses: ./ci/images/debian:8 + uses: ./ci/images/debian8 with: args: ./ci/steps/build-docker-image.sh - name: Upload release image diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 0eede125..c2fe429b 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -10,7 +10,7 @@ jobs: steps: - uses: actions/checkout@v1 - name: Run ./ci/steps/publish-npm.sh - uses: ./ci/images/debian:8 + uses: ./ci/images/debian8 with: args: ./ci/steps/publish-npm.sh env: @@ -22,7 +22,7 @@ jobs: steps: - uses: actions/checkout@v1 - name: Run ./ci/steps/push-docker-manifest.sh - uses: ./ci/images/debian:8 + uses: ./ci/images/debian8 with: args: ./ci/steps/push-docker-manifest.sh env: diff --git a/ci/dev/lint.sh b/ci/dev/lint.sh index 72de463e..1d793717 100755 --- a/ci/dev/lint.sh +++ b/ci/dev/lint.sh @@ -7,7 +7,7 @@ main() { eslint --max-warnings=0 --fix $(git ls-files "*.ts" "*.tsx" "*.js") stylelint $(git ls-files "*.css") tsc --noEmit - # See comment in ./ci/image/debian:8 + # See comment in ./ci/image/debian8 if [[ ! ${CI-} ]]; then shellcheck -e SC2046,SC2164,SC2154,SC1091,SC1090 $(git ls-files "*.sh") fi diff --git a/ci/images/centos:7/Dockerfile b/ci/images/centos7/Dockerfile similarity index 100% rename from ci/images/centos:7/Dockerfile rename to ci/images/centos7/Dockerfile diff --git a/ci/images/debian:8/Dockerfile b/ci/images/debian8/Dockerfile similarity index 100% rename from ci/images/debian:8/Dockerfile rename to ci/images/debian8/Dockerfile diff --git a/doc/CONTRIBUTING.md b/doc/CONTRIBUTING.md index 706a5648..219e4846 100644 --- a/doc/CONTRIBUTING.md +++ b/doc/CONTRIBUTING.md @@ -21,7 +21,7 @@ Differences: - We require a minimum of node v12 but later versions should work. - We use [fnpm](https://github.com/goreleaser/nfpm) to build `.deb` and `.rpm` packages. - We use [jq](https://stedolan.github.io/jq/) to build code-server releases. -- The [CI container](../ci/images/debian:8/Dockerfile) is a useful reference for all our dependencies. +- The [CI container](../ci/images/debian8/Dockerfile) is a useful reference for all our dependencies. ## Development Workflow From cb9c5b2d4946656234a2b11b1807a4593853b56b Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 3 Jun 2020 13:48:17 -0400 Subject: [PATCH 09/14] Fix typos --- ci/images/centos7/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/images/centos7/Dockerfile b/ci/images/centos7/Dockerfile index 43ad9431..580c955f 100644 --- a/ci/images/centos7/Dockerfile +++ b/ci/images/centos7/Dockerfile @@ -1,7 +1,7 @@ FROM centos:7 RUN curl -sL https://rpm.nodesource.com/setup_14.x | bash - && \ - yum install -y nodejs && + yum install -y nodejs && \ npm install -g yarn RUN yum groupinstall -y 'Development Tools' @@ -12,7 +12,7 @@ RUN npm config set python python2 RUN yum install -y epel-release && yum install -y jq RUN yum install -y rsync -# Copied from ../Dockerfile +# Copied from ../debian8/Dockerfile # Install Go dependencies RUN ARCH="$(uname -m | sed 's/x86_64/amd64/; s/aarch64/arm64/')" && \ curl -fsSL "https://dl.google.com/go/go1.14.3.linux-$ARCH.tar.gz" | tar -C /usr/local -xz From 85ad7e4fb408ebe1c7dbf57fa9fad271e5df4363 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 3 Jun 2020 14:02:55 -0400 Subject: [PATCH 10/14] Remove duplicate log Also confirmed that #1750 is fixed. --- src/node/cli.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/node/cli.ts b/src/node/cli.ts index fdde8979..e3072b1d 100644 --- a/src/node/cli.ts +++ b/src/node/cli.ts @@ -348,7 +348,9 @@ export async function readConfigFile(configPath?: string): Promise { logger.info(`Wrote default config file to ${humanPath(configPath)}`) } - logger.info(`Using config file ${humanPath(configPath)}`) + if (!process.env.CODE_SERVER_PARENT_PID) { + logger.info(`Using config file ${humanPath(configPath)}`) + } const configFile = await fs.readFile(configPath) const config = yaml.safeLoad(configFile.toString(), { From e2789608b2a7d2262ea3f5aaf299264cc66e650f Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 3 Jun 2020 14:18:12 -0400 Subject: [PATCH 11/14] Fix autoupdates for Darwin --- ci/README.md | 1 + ci/build/build-packages.sh | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/ci/README.md b/ci/README.md index 01e8a56a..9624988b 100644 --- a/ci/README.md +++ b/ci/README.md @@ -35,6 +35,7 @@ Make sure you have `$GITHUB_TOKEN` set and [hub](https://github.com/github/hub) 10. Wait for the npm package to be published. 11. Update the homebrew package. - Send a pull request to [homebrew-core](https://github.com/Homebrew/homebrew-core) with the URL in the [formula](https://github.com/Homebrew/homebrew-core/blob/master/Formula/code-server.rb) updated. +12. Make sure to add a release without the `v` prefix for autoupdate from `3.2.0`. ## dev diff --git a/ci/build/build-packages.sh b/ci/build/build-packages.sh index 716af699..8149289c 100755 --- a/ci/build/build-packages.sh +++ b/ci/build/build-packages.sh @@ -30,9 +30,16 @@ release_archive() { local release_name="code-server-$VERSION-$OS-$ARCH" if [[ $OS == "linux" ]]; then tar -czf "release-packages/$release_name.tar.gz" --transform "s/^\.\/release-standalone/$release_name/" ./release-standalone + elif [[ $OS == "macos" && $ARCH == "x86_64" ]]; then + # Just exists to make autoupdating from 3.2.0 work again. + mv ./release-standalone "./$release_name" + zip -r "release-packages/$release_name.zip" "./$release_name" + mv "./$release_name" ./release-standalone + return else tar -czf "release-packages/$release_name.tar.gz" -s "/^release-standalone/$release_name/" release-standalone fi + echo "done (release-packages/$release_name)" release_gcp From ab081cd522d52a422ea5742aef36a99a31fdc86c Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 3 Jun 2020 15:18:27 -0400 Subject: [PATCH 12/14] 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 From fd5c5960c261fbe0d062ad41f11549d406f12063 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 3 Jun 2020 16:22:59 -0400 Subject: [PATCH 13/14] Fixes for release --- .github/workflows/ci.yaml | 2 +- ci/build/build-packages.sh | 2 +- ci/images/centos7/Dockerfile | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1cb58963..dcf91784 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -136,7 +136,7 @@ jobs: name: release-packages path: ./release-packages - name: Run ./ci/steps/build-docker-image.sh - uses: ./ci/images/debian8 + uses: ./ci/images/centos7 with: args: ./ci/steps/build-docker-image.sh - name: Upload release image diff --git a/ci/build/build-packages.sh b/ci/build/build-packages.sh index 8149289c..5c770a4a 100755 --- a/ci/build/build-packages.sh +++ b/ci/build/build-packages.sh @@ -30,7 +30,7 @@ release_archive() { local release_name="code-server-$VERSION-$OS-$ARCH" if [[ $OS == "linux" ]]; then tar -czf "release-packages/$release_name.tar.gz" --transform "s/^\.\/release-standalone/$release_name/" ./release-standalone - elif [[ $OS == "macos" && $ARCH == "x86_64" ]]; then + elif [[ "$OS" == "darwin" && "$ARCH" == "x86_64" ]]; then # Just exists to make autoupdating from 3.2.0 work again. mv ./release-standalone "./$release_name" zip -r "release-packages/$release_name.zip" "./$release_name" diff --git a/ci/images/centos7/Dockerfile b/ci/images/centos7/Dockerfile index 58df99a8..4e3f1f94 100644 --- a/ci/images/centos7/Dockerfile +++ b/ci/images/centos7/Dockerfile @@ -22,3 +22,5 @@ ENV PATH=/usr/local/go/bin:/root/go/bin:$PATH ENV GO111MODULE=on RUN go get mvdan.cc/sh/v3/cmd/shfmt RUN go get github.com/goreleaser/nfpm/cmd/nfpm + +RUN curl -fsSL https://get.docker.com | sh From c00f931500c0fe3b532da9b9d25c3bf9f6b6b6c9 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 3 Jun 2020 18:23:42 -0400 Subject: [PATCH 14/14] Remove zip library dependency --- ci/build/build-packages.sh | 2 +- ci/build/code-server.sh | 2 +- ci/dev/fmt.sh | 2 +- package.json | 2 -- src/node/app/update.ts | 43 ++------------------------------------ test/update.test.ts | 34 ++++++++++-------------------- yarn.lock | 12 ----------- 7 files changed, 16 insertions(+), 81 deletions(-) diff --git a/ci/build/build-packages.sh b/ci/build/build-packages.sh index 5c770a4a..058a5478 100755 --- a/ci/build/build-packages.sh +++ b/ci/build/build-packages.sh @@ -30,7 +30,7 @@ release_archive() { local release_name="code-server-$VERSION-$OS-$ARCH" if [[ $OS == "linux" ]]; then tar -czf "release-packages/$release_name.tar.gz" --transform "s/^\.\/release-standalone/$release_name/" ./release-standalone - elif [[ "$OS" == "darwin" && "$ARCH" == "x86_64" ]]; then + elif [[ $OS == "darwin" && $ARCH == "x86_64" ]]; then # Just exists to make autoupdating from 3.2.0 work again. mv ./release-standalone "./$release_name" zip -r "release-packages/$release_name.zip" "./$release_name" diff --git a/ci/build/code-server.sh b/ci/build/code-server.sh index 831bcefc..deb36ac3 100755 --- a/ci/build/code-server.sh +++ b/ci/build/code-server.sh @@ -29,7 +29,7 @@ _realpath() { root() { script="$(_realpath "$0")" bin_dir="$(dirname "$script")" - echo "$(dirname "$bin_dir")" + dirname "$bin_dir" } ROOT="$(root)" diff --git a/ci/dev/fmt.sh b/ci/dev/fmt.sh index b619a7e4..d3bd4191 100755 --- a/ci/dev/fmt.sh +++ b/ci/dev/fmt.sh @@ -4,7 +4,7 @@ set -euo pipefail main() { cd "$(dirname "$0")/../.." - shfmt -i 2 -w -s -sr $(git ls-files "*.sh") + shfmt -i 2 -w -sr $(git ls-files "*.sh") local prettierExts prettierExts=( diff --git a/package.json b/package.json index cd7c45ff..aa6d1fe6 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,6 @@ }, "main": "out/node/entry.js", "devDependencies": { - "@types/adm-zip": "^0.4.32", "@types/fs-extra": "^8.0.1", "@types/http-proxy": "^1.17.4", "@types/js-yaml": "^3.12.3", @@ -66,7 +65,6 @@ }, "dependencies": { "@coder/logger": "1.1.11", - "adm-zip": "^0.4.14", "env-paths": "^2.2.0", "fs-extra": "^8.1.0", "http-proxy": "^1.18.0", diff --git a/src/node/app/update.ts b/src/node/app/update.ts index 588e5201..23cfd88b 100644 --- a/src/node/app/update.ts +++ b/src/node/app/update.ts @@ -1,5 +1,4 @@ import { field, logger } from "@coder/logger" -import zip from "adm-zip" import * as cp from "child_process" import * as fs from "fs-extra" import * as http from "http" @@ -213,11 +212,7 @@ export class UpdateHttpProvider extends HttpProvider { const response = await this.requestResponse(url) try { - if (downloadPath.endsWith(".tar.gz")) { - downloadPath = await this.extractTar(response, downloadPath) - } else { - downloadPath = await this.extractZip(response, downloadPath) - } + downloadPath = await this.extractTar(response, downloadPath) logger.debug("Downloaded update", field("path", downloadPath)) // The archive should have a directory inside at the top level with the @@ -275,40 +270,6 @@ export class UpdateHttpProvider extends HttpProvider { return downloadPath } - private async extractZip(response: Readable, downloadPath: string): Promise { - logger.debug("Downloading zip", field("path", downloadPath)) - - response.pause() - await fs.remove(downloadPath) - - const write = fs.createWriteStream(downloadPath) - response.pipe(write) - response.on("error", (error) => write.destroy(error)) - response.on("close", () => write.end()) - - await new Promise((resolve, reject) => { - write.on("error", reject) - write.on("close", resolve) - response.resume - }) - - const zipPath = downloadPath - downloadPath = downloadPath.replace(/\.zip$/, "") - await fs.remove(downloadPath) - - logger.debug("Extracting zip", field("path", zipPath)) - - await new Promise((resolve, reject) => { - new zip(zipPath).extractAllToAsync(downloadPath, true, (error) => { - return error ? reject(error) : resolve() - }) - }) - - await fs.remove(zipPath) - - return downloadPath - } - /** * Given an update return the name for the packaged archived. */ @@ -329,7 +290,7 @@ export class UpdateHttpProvider extends HttpProvider { if (arch === "x64") { arch = "x86_64" } - return `code-server-${update.version}-${target}-${arch}.${target === "darwin" ? "zip" : "tar.gz"}` + return `code-server-${update.version}-${target}-${arch}.tar.gz` } private async request(uri: string): Promise { diff --git a/test/update.test.ts b/test/update.test.ts index 18f0d9a6..8725eb5f 100644 --- a/test/update.test.ts +++ b/test/update.test.ts @@ -1,8 +1,6 @@ -import zip from "adm-zip" import * as assert from "assert" import * as fs from "fs-extra" import * as http from "http" -import * as os from "os" import * as path from "path" import * as tar from "tar-fs" import * as zlib from "zlib" @@ -88,28 +86,18 @@ describe("update", () => { fs.writeFile(path.join(archivePath, archiveName, "node"), `NODE BINARY`), ]) - if (os.platform() === "darwin") { - await new Promise((resolve, reject) => { - const zipFile = new zip() - zipFile.addLocalFolder(archivePath) - zipFile.writeZip(archivePath + ".zip", (error) => { - return error ? reject(error) : resolve(error) - }) + await new Promise((resolve, reject) => { + const write = fs.createWriteStream(archivePath + ".tar.gz") + const compress = zlib.createGzip() + compress.pipe(write) + compress.on("error", (error) => compress.destroy(error)) + compress.on("close", () => write.end()) + tar.pack(archivePath).pipe(compress) + write.on("close", reject) + write.on("finish", () => { + resolve() }) - } else { - await new Promise((resolve, reject) => { - const write = fs.createWriteStream(archivePath + ".tar.gz") - const compress = zlib.createGzip() - compress.pipe(write) - compress.on("error", (error) => compress.destroy(error)) - compress.on("close", () => write.end()) - tar.pack(archivePath).pipe(compress) - write.on("close", reject) - write.on("finish", () => { - resolve() - }) - }) - } + }) }) after(() => { diff --git a/yarn.lock b/yarn.lock index f8b76db0..2ba7cba6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -910,13 +910,6 @@ traverse "^0.6.6" unified "^6.1.6" -"@types/adm-zip@^0.4.32": - version "0.4.33" - resolved "https://registry.yarnpkg.com/@types/adm-zip/-/adm-zip-0.4.33.tgz#ea5b94f771443f655613b64f920c0555867200dd" - integrity sha512-WM0DCWFLjXtddl0fu0+iN2ZF+qz8RF9RddG5OSy/S90AQz01Fu8lHn/3oTIZDxvG8gVcnBLAHMHOdBLbV6m6Mw== - dependencies: - "@types/node" "*" - "@types/color-name@^1.1.1": version "1.1.1" resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0" @@ -1130,11 +1123,6 @@ acorn@^7.1.1: resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.1.1.tgz#e35668de0b402f359de515c5482a1ab9f89a69bf" integrity sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg== -adm-zip@^0.4.14: - version "0.4.14" - resolved "https://registry.yarnpkg.com/adm-zip/-/adm-zip-0.4.14.tgz#2cf312bcc9f8875df835b0f6040bd89be0a727a9" - integrity sha512-/9aQCnQHF+0IiCl0qhXoK7qs//SwYE7zX8lsr/DNk1BRAHYxeLZPL4pguwK29gUEqasYQjqPtEpDRSWEkdHn9g== - ajv@^6.10.0, ajv@^6.10.2, ajv@^6.5.5: version "6.12.2" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.2.tgz#c629c5eced17baf314437918d2da88c99d5958cd"