Skip to content

Commit

Permalink
build: use node snap for build (#347)
Browse files Browse the repository at this point in the history
When I first switched this snap to build from source, I couldn't
make the process succeed using the node snap, which led to a
rather more complicated method for obtaining and configuring
nodejs.

Taking another look, the issues I was seeing seem to be resolved.
  • Loading branch information
jnsgruk authored Jan 23, 2025
1 parent 1e1625c commit e62cdf6
Showing 1 changed file with 4 additions and 37 deletions.
41 changes: 4 additions & 37 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,44 +46,15 @@ platforms:
arm64:

parts:
nodejs:
plugin: dump
source: https://github.com/asdf-vm/asdf.git
source-tag: v0.13.1
build-packages:
- jq
- curl
override-build: |
source "./asdf.sh"
UPSTREAM_URL="https://raw.githubusercontent.com/signalapp/Signal-Desktop/v${SNAPCRAFT_PROJECT_VERSION}"
LINUX_CI_STEPS="$(curl -s "${UPSTREAM_URL}/.github/workflows/ci.yml")"
NODE_VERSION="$(curl "${UPSTREAM_URL}/package.json" | jq -r '.engines.node')"
NPM_VERSION="$(echo "$LINUX_CI_STEPS" | grep -m1 -Po "npm install -g npm@\K[^ ]+")"
# Install the correct version of nodejs required by Signal-Desktop
asdf plugin add nodejs
asdf install nodejs "$NODE_VERSION"
asdf global nodejs "$NODE_VERSION"
# Configure NPM proxy
npm config set -g registry https://registry.npmjs.org/
npm config set -g proxy "${http_proxy:-}"
npm config set -g https-proxy "${http_proxy:-}"
# Install pinned npm version from Signal's CI
npm install -g "npm@${NPM_VERSION}"
# NodeJS dependency which uses a non-proxy aware fetch during its build.
# The purpose of this part is to download the module and fetch the required file
# using curl, which does respect the proxy, which prevents the module from trying
# to download it with the non-proxy aware fetch.
better-sqlite3:
after:
- nodejs
plugin: dump
source: https://registry.npmjs.org/@signalapp/better-sqlite3/-/better-sqlite3-9.0.9.tgz
build-snaps:
- node/20/stable
build-packages:
- curl
override-build: |
Expand All @@ -96,18 +67,17 @@ parts:
# Download the file using curl, which respects the proxy configuration
curl -s -o deps/sqlcipher.tar.gz "${base_uri}/sqlcipher-v2-${sqlcipher_version}--${extension_version}-${hash}.tar.gz"
# Use the version of nodejs we configured before and install node deps
source "$(pwd)/../../nodejs/build/asdf.sh"
npm install
signal-desktop:
after:
- better-sqlite3
- nodejs
plugin: dump
source: https://github.com/signalapp/Signal-Desktop
source-type: git
source-tag: v$SNAPCRAFT_PROJECT_VERSION
build-snaps:
- node/20/stable
build-packages:
- git-lfs
- jq
Expand All @@ -125,9 +95,6 @@ parts:
export GLOBAL_AGENT_HTTPS_PROXY="${http_proxy:-}"
fi
# Use the version of nodejs we configured before
source "$(pwd)/../../nodejs/build/asdf.sh"
git lfs install
# Update the package.json so the build uses the patched libraries
Expand Down

0 comments on commit e62cdf6

Please sign in to comment.