Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: enable the build:dns-fallback step from npm run generate #303

Merged
merged 4 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ screenshot-screen.png
screenshot-window.png

# remote-build logs
signal-desktop_*.txt
signal-desktop_*.txt
snapcraft-signal-desktop*.txt
83 changes: 83 additions & 0 deletions snap/patches/dns-fallback-use-resolve.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
diff --git a/ts/scripts/generate-dns-fallback.ts b/ts/scripts/generate-dns-fallback.ts
index 39f442f4b..f204fe784 100644
--- a/ts/scripts/generate-dns-fallback.ts
+++ b/ts/scripts/generate-dns-fallback.ts
@@ -1,15 +1,15 @@
// Copyright 2024 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only

-import { join } from 'path';
-import { lookup as lookupCb } from 'dns';
+import { resolve4 as resolve4Cb, resolve6 as resolve6Cb } from 'dns';
import { writeFile } from 'fs/promises';
+import { join } from 'path';
import { promisify } from 'util';
-import type { ResolvedEndpoint } from 'electron';

import { isNotNil } from '../util/isNotNil';

-const lookup = promisify(lookupCb);
+const resolve4 = promisify(resolve4Cb);
+const resolve6 = promisify(resolve6Cb);

const FALLBACK_DOMAINS = [
'chat.signal.org',
@@ -25,35 +25,31 @@ const FALLBACK_DOMAINS = [
async function main() {
const config = await Promise.all(
FALLBACK_DOMAINS.sort().map(async domain => {
- const addresses = await lookup(domain, { all: true });

- const endpoints = addresses
- .map(({ address, family }): ResolvedEndpoint | null => {
- if (family === 4) {
- return { family: 'ipv4', address };
- }
- if (family === 6) {
- return { family: 'ipv6', address };
- }
- return null;
- })
- .filter(isNotNil)
- .sort((a, b) => {
- if (a.family < b.family) {
- return -1;
- }
- if (a.family > b.family) {
- return 1;
- }
+ const ipv4endpoints = (await resolve4(domain))
+ .map(a => ({"family": "ipv4", "address": a}))
+
+ const ipv6endpoints = (await resolve6(domain))
+ .map(a => ({"family": "ipv6", "address": a}))
+
+ const endpoints = [...ipv4endpoints, ...ipv6endpoints]
+ .filter(isNotNil)
+ .sort((a, b) => {
+ if (a.family < b.family) {
+ return -1;
+ }
+ if (a.family > b.family) {
+ return 1;
+ }

- if (a.address < b.address) {
- return -1;
- }
- if (a.address > b.address) {
- return 1;
- }
- return 0;
- });
+ if (a.address < b.address) {
+ return -1;
+ }
+ if (a.address > b.address) {
+ return 1;
+ }
+ return 0;
+ })

return { domain, endpoints };
})
54 changes: 7 additions & 47 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ parts:
- jq
- moreutils
- python3
- wget
build-environment:
- SIGNAL_ENV: "production"
override-build: |
Expand All @@ -132,6 +131,12 @@ parts:

git lfs install

# When running `npm run build:dns-fallback`, the code tries to use `dns.lookup` from
# the NodeJS standard library, which makes a `getaddrinfo` syscall to try and resolve
# domain names, which seems to fail on Launchpad builders. This patch replaces the
# logic to use `dns.resolve4` and `dns.resolve6` instead.
git apply $CRAFT_PROJECT_DIR/snap/patches/dns-fallback-use-resolve.patch

# Update the package.json so the build uses the patched libraries
cat package.json \
| jq -r --arg f "file:${PWD}/../../better-sqlite3/build" '.dependencies."@signalapp/better-sqlite3"=$f' \
Expand All @@ -153,6 +158,7 @@ parts:
npm run build-protobuf
npm run build:esbuild
npm run build:icu-types
npm run build:dns-fallback
npm run build:compact-locales
npm run sass
npm run get-expire-time
Expand All @@ -167,37 +173,7 @@ parts:
# 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
- libnss3
prime:
- opt
- usr/share
- usr/lib/*/libxss*
- usr/lib/*/*nss*
- usr/lib/*/libI*
- usr/lib/*/libMagic*
- usr/lib/*/libcfit*
- usr/lib/*/libcgif*
- usr/lib/*/libexif*
- usr/lib/*/libfftw*
- usr/lib/*/libgsf*
- usr/lib/*/libheif*
- usr/lib/*/libimage*
- usr/lib/*/libmat*
- usr/lib/*/libopensli*
- usr/lib/*/libwebp*
- usr/lib/*/libHalf*
- usr/lib/*/libaom*
- usr/lib/*/libdav1d*
- usr/lib/*/libx265*
- usr/lib/*/libhdf*
- usr/lib/*/libsz*
- usr/lib/*/liblqr*
- usr/lib/*/libaec*
- usr/lib/*/libde265*
- usr/lib/*/libnuma*
- -opt/Signal/chrome-sandbox
- -opt/Signal/resources/app.asar.unpacked/node_modules/sharp/vendor/lib
- -opt/Signal/resources/app.asar.unpacked/node_modules/sharp/vendor/include
Expand All @@ -207,19 +183,6 @@ parts:
source: ./snap/local
source-type: local

cleanup:
after: [signal-desktop]
plugin: nil
build-snaps: [gnome-46-2404]
override-prime: |
set -eux
cd /snap/gnome-46-2404/current
find . -type f,l -exec rm -f $CRAFT_PRIME/{} \;
for CRUFT in bug lintian man; do
rm -rf $CRAFT_PRIME/usr/share/$CRUFT
done
find $CRAFT_PRIME/usr/share/doc/ -type f -not -name 'copyright' -delete

apps:
signal-desktop:
extensions: [gnome]
Expand All @@ -229,13 +192,10 @@ apps:
- camera
- home
- network
- opengl
- audio-playback
- audio-record
- removable-media
- unity7
- desktop
- desktop-legacy
- screen-inhibit-control
environment:
GTK_USE_PORTAL: "1"
Expand Down
Loading