From 7868f4db2300bc7749f232cc43aa60266b81a4ce Mon Sep 17 00:00:00 2001 From: Asher Date: Thu, 21 Sep 2023 23:21:01 -0800 Subject: [PATCH] Fix cross-compilation (#6441) * Avoid packaging yarn.lock Since the shrinkwrap is what we want everything to use. * Build with npm It seems we stuck with yarn because npm was giving us errors but I will try sorting it out now so we can build with npm as originally intended. * Remove build from source Not using CentOS 7 anymore so based on the comment we no longer need this. Keytar seems to install fine now. * Update missed Node version These numbers are all over the place. * npm_config_arch must be lowercase * Patch out Kerberos I am not sure exactly how it is used but I think it is not a path code-server worries about, at least not right now. Just going to patch it out rather than figure out how to build it on armv7l but we can revisit later. --- .github/workflows/release.yaml | 12 +++--- .node-version | 2 +- ci/build/build-release.sh | 3 -- ci/build/build-standalone-release.sh | 4 -- ci/build/npm-postinstall.sh | 4 -- patches/dependencies.diff | 62 ++++++++++++++++++++++++++++ patches/series | 1 + 7 files changed, 69 insertions(+), 19 deletions(-) create mode 100644 patches/dependencies.diff diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3bd5f36b7aed..46814c9f6ee3 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -119,7 +119,7 @@ jobs: CC: ${{ format('{0}-gcc', matrix.prefix) }} CXX: ${{ format('{0}-g++', matrix.prefix) }} LINK: ${{ format('{0}-g++', matrix.prefix) }} - NPM_CONFIG_ARCH: ${{ matrix.arch }} + npm_config_arch: ${{ matrix.arch }} NODE_VERSION: v18.15.0 steps: @@ -150,15 +150,13 @@ jobs: - name: Decompress npm package run: tar -xzf package.tar.gz - # NOTE@jsjoeio - npm fails here - # so use yarn - name: Build standalone release - run: yarn release:standalone + run: npm run release:standalone - name: Replace node with cross-compile equivalent run: | - wget https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-linux-${NPM_CONFIG_ARCH}.tar.xz - tar -xf node-${NODE_VERSION}-linux-${NPM_CONFIG_ARCH}.tar.xz node-${NODE_VERSION}-linux-${NPM_CONFIG_ARCH}/bin/node --strip-components=2 + wget https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-linux-${npm_config_arch}.tar.xz + tar -xf node-${NODE_VERSION}-linux-${npm_config_arch}.tar.xz node-${NODE_VERSION}-linux-${npm_config_arch}/bin/node --strip-components=2 mv ./node ./release-standalone/lib/node # NOTE@jsjoeio - we do this so we can strip out the v @@ -171,7 +169,7 @@ jobs: - name: Build packages with nfpm env: VERSION: ${{ env.VERSION }} - run: yarn package ${NPM_CONFIG_ARCH} + run: yarn package ${npm_config_arch} - uses: softprops/action-gh-release@v1 with: diff --git a/.node-version b/.node-version index b6a7d89c68e0..3c032078a4a2 100644 --- a/.node-version +++ b/.node-version @@ -1 +1 @@ -16 +18 diff --git a/ci/build/build-release.sh b/ci/build/build-release.sh index 576b084ae9ca..ec5b3f4424bd 100755 --- a/ci/build/build-release.sh +++ b/ci/build/build-release.sh @@ -56,7 +56,6 @@ bundle_code_server() { } EOF ) > "$RELEASE_PATH/package.json" - rsync yarn.lock "$RELEASE_PATH" mv npm-shrinkwrap.json "$RELEASE_PATH" rsync ci/build/npm-postinstall.sh "$RELEASE_PATH/postinstall.sh" @@ -95,12 +94,10 @@ bundle_vscode() { "$VSCODE_SRC_PATH/remote/package.json" \ "$VSCODE_SRC_PATH/package.json" > "$VSCODE_OUT_PATH/package.json" - rsync "$VSCODE_SRC_PATH/remote/yarn.lock" "$VSCODE_OUT_PATH/yarn.lock" mv "$VSCODE_SRC_PATH/remote/npm-shrinkwrap.json" "$VSCODE_OUT_PATH/npm-shrinkwrap.json" # Include global extension dependencies as well. rsync "$VSCODE_SRC_PATH/extensions/package.json" "$VSCODE_OUT_PATH/extensions/package.json" - rsync "$VSCODE_SRC_PATH/extensions/yarn.lock" "$VSCODE_OUT_PATH/extensions/yarn.lock" mv "$VSCODE_SRC_PATH/extensions/npm-shrinkwrap.json" "$VSCODE_OUT_PATH/extensions/npm-shrinkwrap.json" rsync "$VSCODE_SRC_PATH/extensions/postinstall.mjs" "$VSCODE_OUT_PATH/extensions/postinstall.mjs" } diff --git a/ci/build/build-standalone-release.sh b/ci/build/build-standalone-release.sh index 8ae02de3bf44..c06b19653104 100755 --- a/ci/build/build-standalone-release.sh +++ b/ci/build/build-standalone-release.sh @@ -1,10 +1,6 @@ #!/usr/bin/env bash set -euo pipefail -# This is due to an upstream issue with RHEL7/CentOS 7 comptability with node-argon2 -# See: https://github.com/cdr/code-server/pull/3422#pullrequestreview-677765057 -export npm_config_build_from_source=true - main() { cd "$(dirname "${0}")/../.." diff --git a/ci/build/npm-postinstall.sh b/ci/build/npm-postinstall.sh index 028c1bad60ef..0dac63b3ee48 100755 --- a/ci/build/npm-postinstall.sh +++ b/ci/build/npm-postinstall.sh @@ -53,10 +53,6 @@ symlink_bin_script() { OS="$(os)" -# This is due to an upstream issue with RHEL7/CentOS 7 comptability with node-argon2 -# See: https://github.com/cdr/code-server/pull/3422#pullrequestreview-677765057 -export npm_config_build_from_source=true - main() { # Grabs the major version of node from $npm_config_user_agent which looks like # yarn/1.21.1 npm/? node/v14.2.0 darwin x64 diff --git a/patches/dependencies.diff b/patches/dependencies.diff new file mode 100644 index 000000000000..815633543e26 --- /dev/null +++ b/patches/dependencies.diff @@ -0,0 +1,62 @@ +Modify VS Code dependencies + +1. Kerberos: this is not building in our cross-compile step. It does not look + like something code-server uses right now anyway. + +Index: code-server/lib/vscode/remote/package.json +=================================================================== +--- code-server.orig/lib/vscode/remote/package.json ++++ code-server/lib/vscode/remote/package.json +@@ -18,7 +18,6 @@ + "http-proxy-agent": "^2.1.0", + "https-proxy-agent": "^2.2.3", + "jschardet": "3.0.0", +- "kerberos": "^2.0.1", + "keytar": "7.9.0", + "minimist": "^1.2.6", + "native-watchdog": "^1.4.1", +Index: code-server/lib/vscode/remote/yarn.lock +=================================================================== +--- code-server.orig/lib/vscode/remote/yarn.lock ++++ code-server/lib/vscode/remote/yarn.lock +@@ -454,15 +454,6 @@ jschardet@3.0.0: + resolved "https://registry.yarnpkg.com/jschardet/-/jschardet-3.0.0.tgz#898d2332e45ebabbdb6bf2feece9feea9a99e882" + integrity sha512-lJH6tJ77V8Nzd5QWRkFYCLc13a3vADkh3r/Fi8HupZGWk2OVVDfnZP8V/VgQgZ+lzW0kG2UGb5hFgt3V3ndotQ== + +-kerberos@^2.0.1: +- version "2.0.1" +- resolved "https://registry.yarnpkg.com/kerberos/-/kerberos-2.0.1.tgz#663b0b46883b4da84495f60f2e9e399a43a33ef5" +- integrity sha512-O/jIgbdGK566eUhFwIcgalbqirYU/r76MW7/UFw06Fd9x5bSwgyZWL/Vm26aAmezQww/G9KYkmmJBkEkPk5HLw== +- dependencies: +- bindings "^1.5.0" +- node-addon-api "^4.3.0" +- prebuild-install "7.1.1" +- + keytar@7.9.0: + version "7.9.0" + resolved "https://registry.yarnpkg.com/keytar/-/keytar-7.9.0.tgz#4c6225708f51b50cbf77c5aae81721964c2918cb" +@@ -604,24 +595,6 @@ picomatch@^2.3.1: + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== + +-prebuild-install@7.1.1: +- version "7.1.1" +- resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-7.1.1.tgz#de97d5b34a70a0c81334fd24641f2a1702352e45" +- integrity sha512-jAXscXWMcCK8GgCoHOfIr0ODh5ai8mj63L2nWrjuAgXE6tDyYGnx4/8o/rCgU+B4JSyZBKbeZqzhtwtC3ovxjw== +- dependencies: +- detect-libc "^2.0.0" +- expand-template "^2.0.3" +- github-from-package "0.0.0" +- minimist "^1.2.3" +- mkdirp-classic "^0.5.3" +- napi-build-utils "^1.0.1" +- node-abi "^3.3.0" +- pump "^3.0.0" +- rc "^1.2.7" +- simple-get "^4.0.0" +- tar-fs "^2.0.0" +- tunnel-agent "^0.6.0" +- + prebuild-install@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-7.0.1.tgz#c10075727c318efe72412f333e0ef625beaf3870" diff --git a/patches/series b/patches/series index dba2e20a31a5..195f702d4581 100644 --- a/patches/series +++ b/patches/series @@ -20,3 +20,4 @@ display-language.diff cli-window-open.diff getting-started.diff safari.diff +dependencies.diff