diff --git a/snap/gui/signal-desktop.desktop b/snap/gui/signal-desktop.desktop new file mode 100644 index 000000000..ba1a22163 --- /dev/null +++ b/snap/gui/signal-desktop.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Name=Signal +Exec=signal-desktop --no-sandbox %U +Terminal=false +Type=Application +Icon=${SNAP}/meta/gui/signal-desktop.png +StartupWMClass=Signal +Comment=Private messaging from your desktop +MimeType=x-scheme-handler/sgnl;x-scheme-handler/signalcaptcha; +Categories=Network;InstantMessaging;Chat; diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index feafa4538..1708aceb1 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -32,15 +32,139 @@ version: 6.36.0 base: core22 grade: stable confinement: strict +compression: lzo architectures: - build-on: amd64 -compression: lzo + - build-on: arm64 parts: + # NodeJS dependency which uses a non-proxy aware fetch during its build. + # The purpose of this part is to introduce proxy awareness so the build succeeds in LP. + ringrtc: + plugin: dump + source: https://registry.npmjs.org/@signalapp/ringrtc/-/ringrtc-2.33.0.tgz + override-build: | + # Patch the file; inject a proxy agent at the top of the file + cat <<-EOF > scripts/fetch-prebuild.js + const { HttpsProxyAgent } = require('https-proxy-agent'); + const agent = new HttpsProxyAgent('${https_proxy:-}'); + $(cat scripts/fetch-prebuild.js) + EOF + + # Ensure the fetch actually uses the agent + sed -i 's|https.get(URL, async res|https.get(URL, { agent }, async res|g' scripts/fetch-prebuild.js + + # NodeJS dependency which uses a non-proxy aware fetch during its build. + # The purpose of this part is to introduce proxy awareness so the build succeeds in LP. + better-sqlite3: + plugin: dump + source: https://registry.npmjs.org/@signalapp/better-sqlite3/-/better-sqlite3-8.5.2.tgz + override-build: | + # Patch the file; inject a proxy agent at the top of the file + cat <<-EOF > deps/download.js + const { HttpsProxyAgent } = require('https-proxy-agent'); + const agent = new HttpsProxyAgent('${https_proxy:-}'); + $(cat deps/download.js) + EOF + + # Ensure the fetch actually uses the agent + sed -i 's|https.get(URL, async (res)|https.get(URL, { agent }, async (res)|g' deps/download.js + + nodejs: + plugin: dump + source: https://github.com/asdf-vm/asdf.git + source-tag: v0.13.1 + build-environment: + - NODE_VERSION: 18.15.0 + override-build: | + source "./asdf.sh" + + # Install the correct version of nodejs required by Signal-Desktop + asdf plugin add nodejs + asdf install nodejs "$NODE_VERSION" + asdf global nodejs "$NODE_VERSION" + + # Install and configure Yarn + npm install -g yarn + yarn config set python /usr/bin/python3 + yarn config set proxy "${http_proxy:-}" + yarn config set https-proxy "${https_proxy:-}" + signal-desktop: + after: + - ringrtc + - better-sqlite3 + - nodejs plugin: dump - source: https://updates.signal.org/desktop/apt/pool/s/signal-desktop/signal-desktop_$SNAPCRAFT_PROJECT_VERSION_amd64.deb + source: https://github.com/signalapp/Signal-Desktop + source-type: git + source-tag: v$SNAPCRAFT_PROJECT_VERSION + build-packages: + - git-lfs + - jq + - moreutils + - python3 + - wget + build-environment: + - SIGNAL_ENV: "production" + - USE_SYSTEM_FPM: "true" + override-build: | + # Use the version of nodejs/yarn we configured before + source "$(pwd)/../../nodejs/build/asdf.sh" + + git lfs install + + # Disable yarn auto clean functionality + rm .yarnclean + + # Don't try to build a deb (this fails on arm64) + cat package.json | jq '.build.linux.target = ["dir"]' | sponge package.json + + # If we're in a proxy environment, we need to patch some packages + if [[ -n "${http_proxy:-}" ]]; then + # Setup proxy access + export ELECTRON_GET_USE_PROXY=1 + export GLOBAL_AGENT_HTTP_PROXY="${http_proxy}" + export GLOBAL_AGENT_HTTPS_PROXY="${http_proxy}" + + # The patch applied uses this package to ensure proxy is used + yarn global add https-proxy-agent + + # Update the package.json so the build uses the patched libraries + cat package.json \ + | jq -r --arg f "file:${PWD}/../../ringrtc/build" '.dependencies."@signalapp/ringrtc"=$f' \ + | sponge package.json + + cat package.json \ + | jq -r --arg f "file:${PWD}/../../better-sqlite3/build" '.dependencies."@signalapp/better-sqlite3"=$f' \ + | sponge package.json + fi + + # Install the dependencies for the Signal-Desktop application. + # We cannot use `--frozen-lockfile` due to the patching above. + yarn install + + # This is the equivalent of 'yarn generate'. The upstream package.json + # uses npm-run-all to run multiple things, which has a bug that prevents + # this from succeeding in the snapcraft build env, so this just breaks + # that apart into its component parts. + yarn build-protobuf + yarn build:esbuild + yarn sass + yarn get-expire-time + yarn copy-components + + # This is the equivalent of 'yarn build-linux' which also runs 'yarn generate' + # which is broken (as described above). + yarn build:esbuild:prod + yarn build:release --publish=never + yarn build:electron --config.directories.output=release + + # Stage the built release. Directory is called 'linux-unpacked' for amd64, + # and 'linux-arm64-unpacked' for arm64. + mkdir -p "${CRAFT_PART_INSTALL}/opt" + mv release/linux-*unpacked "${CRAFT_PART_INSTALL}/opt/Signal" stage-packages: - libxss1 - libnspr4 @@ -94,7 +218,6 @@ parts: apps: signal-desktop: extensions: [gnome] - desktop: usr/share/applications/signal-desktop.desktop command: opt/Signal/signal-desktop --use-tray-icon --no-sandbox plugs: - browser-support