# Contributor: Lauren N. Liberda # Maintainer: Lauren N. Liberda pkgname=signal-desktop pkgver=6.1.0 pkgrel=0 pkgdesc="A messaging app for simple private communication with friends" url="https://github.com/signalapp/Signal-Desktop/" # same as electron # aarch64: polyval-0.5.3 crate subdep uses unstable stdsimd feature arch="x86_64" license="AGPL-3.0-only" # this build system sucks massive ass and does not add needed to anything depends=" electron ffmpeg-libs font-barlow font-eb-garamond font-inter font-parisienne libevent opus " makedepends=" alsa-lib-dev bsd-compat-headers cargo clang-dev cmake electron-dev ffmpeg-dev git-lfs glib-dev gn libepoxy-dev libevent-dev lld llvm-dev mesa-dev nodejs npm openssl-dev opus-dev pipewire-dev protoc pulseaudio-dev py3-setuptools python3 samurai sqlcipher-dev vips-dev yarn " options="net !check" # follow signal-desktop package.json -> @signalapp/libsignal-client _libsignalver=0.21.1 # follow signal-desktop package.json -> ringrtc -> commit title _ringrtcver=2.22.0 # follow ringrtc (on version above) -> config/version.sh -> WEBRTC_VERSION # downloading tarball generated with abuild snapshot (with gclient dependencies fetched) _webrtcver=5005b source=" https://github.com/signalapp/Signal-Desktop/archive/refs/tags/v$pkgver/Signal-Desktop-$pkgver.tar.gz https://github.com/signalapp/libsignal/archive/refs/tags/v$_libsignalver/libsignal-$_libsignalver.tar.gz https://github.com/signalapp/ringrtc/archive/refs/tags/v$_ringrtcver/ringrtc-$_ringrtcver.tar.gz https://s3.sakamoto.pl/lnl-aports-snapshots/webrtc-$_webrtcver.tar.xz bettersqlite-use-system-sqlcipher.patch signal-build-expire-time.patch signal-disable-updates.patch signal-update-links.patch webrtc-canonicalize-file-name.patch webrtc-use-alpine-target.patch webrtc-no-shared-deps-in-static-lib.patch signal-desktop signal-desktop.desktop " builddir="$srcdir/Signal-Desktop-$pkgver" export CC=clang export CXX=clang++ # required to find the tools export AR=llvm-ar export NM=llvm-nm export LD=clang++ # less log spam, reproducible, allow lto with rust export CFLAGS="${CFLAGS/-g/} -O2 -Wno-deprecated-builtins -Wno-unknown-warning-option -Wno-builtin-macro-redefined" export CXXFLAGS="${CXXFLAGS/-g/} -O2 -Wno-deprecated-builtins -Wno-unknown-warning-option -Wno-builtin-macro-redefined" export CPPFLAGS="$CPPFLAGS -D__DATE__= -D__TIME__= -D__TIMESTAMP__=" export CARGO_PROFILE_RELEASE_OPT_LEVEL=2 export CARGO_PROFILE_RELEASE_STRIP="symbols" export RUSTFLAGS="$RUSTFLAGS -C linker=clang -C link-arg=-fuse-ld=lld" export YARN_CACHE_FOLDER="$srcdir/.yarn" # webrtc only, the other dependencies are fine with tarballs snapshot() { mkdir -p "$srcdir" cd "$srcdir" echo " solutions = [{ 'name': 'src', 'url': 'https://github.com/signalapp/webrtc.git@$_webrtcver', }] target_cpu = ['x64'] target_cpu_only = True " > .gclient gclient sync --no-history --nohooks --tpot-cipd-ignore-platformed # needed DEPS hooks python3 'src/build/landmines.py' --landmine-scripts 'src/tools_webrtc/get_landmines.py' --src-dir 'src' python3 'src/build/util/lastchange.py' -o 'src/build/util/LASTCHANGE' for elf in $(scanelf -RA -F "%F" src); do rm -f "$elf" done mv src webrtc-$_webrtcver msg "generating tarball.." tar -cf webrtc-$_webrtcver.tar \ --exclude="ChangeLog*" \ --exclude="testdata/" \ --exclude="test_data/" \ --exclude="android_rust_toolchain/toolchain/" \ --exclude-backups \ --exclude-caches-all \ --exclude-vcs \ webrtc-$_webrtcver xz -T0 -e -9 -vv -k webrtc-$_webrtcver.tar } prepare() { ln -s "$srcdir"/webrtc-$_webrtcver "$srcdir"/ringrtc-$_ringrtcver/src/webrtc ln -sf "$srcdir"/ringrtc-$_ringrtcver/src "$srcdir"/webrtc-$_webrtcver/ringrtc msg "Applying patches" for x in $source; do case "$x" in signal-*.patch) msg "$x" patch -p1 -i "$srcdir"/$x -d "$srcdir"/Signal-Desktop-$pkgver ;; ringrtc-*.patch) msg "$x" patch -p1 -i "$srcdir"/$x -d "$srcdir"/ringrtc-$_ringrtcver ;; webrtc-*.patch) msg "$x" patch -p1 -i "$srcdir"/$x -d "$srcdir"/webrtc-$_webrtcver ;; esac done msg "Installing signal-desktop JS dependencies" echo 'ignore-engines true' > .yarnrc yarn --ignore-scripts --frozen-lockfile ( cd "$srcdir"/webrtc-$_webrtcver local use_system=" ffmpeg fontconfig freetype harfbuzz-ng icu libdrm libevent libjpeg libpng libwebp libxml libxslt opus re2 snappy zlib " for _lib in $use_system libjpeg_turbo; do msg "Removing buildscripts for system provided $_lib" find . -type f -path "*third_party/$_lib/*" \ \! -path "*third_party/$_lib/chromium/*" \ \! -path "*third_party/$_lib/google/*" \ \! -path './base/third_party/icu/*' \ \! -path './third_party/libxml/*' \ \! -path './third_party/pdfium/third_party/freetype/include/pstables.h' \ \! -path './third_party/harfbuzz-ng/utils/hb_scoped.h' \ \! -path './third_party/crashpad/crashpad/third_party/zlib/zlib_crashpad.h' \ \! -regex '.*\.\(gn\|gni\|isolate\|py\)' \ -delete done msg "Replacing gn files" python3 build/linux/unbundle/replace_gn_files.py --system-libraries \ $use_system # allow system dependencies in "official builds" sed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' \ tools/generate_shim_headers/generate_shim_headers.py ) ( cd "$srcdir"/ringrtc-$_ringrtcver/src/node msg "Installing ringrtc js dependencies" yarn --frozen-lockfile --ignore-scripts ) ( cd "$srcdir"/libsignal-$_libsignalver/node # fix target sed -i 's/unknown-linux-gnu/alpine-linux-musl/g' binding.gyp msg "Installing libsignal js dependencies" yarn --ignore-scripts --frozen-lockfile ) # remove shipped fonts for system-provided (part 1) rm -rf fonts/ } build() { chromium_arch="$(node -e 'console.log(process.arch)')" # required dependency of ringrtc ( cd "$srcdir"/webrtc-$_webrtcver local webrtc_args=" rtc_build_examples=false rtc_build_tools=false rtc_enable_protobuf=false rtc_enable_sctp=false rtc_include_tests=false rtc_include_ilbc=false rtc_libvpx_build_vp9=true rtc_use_x11=false build_with_mozilla=false chrome_pgo_phase=0 clang_use_chrome_plugins=false custom_toolchain=\"//build/toolchain/linux/unbundle:default\" is_cfi=false is_clang=true is_debug=false is_official_build=true host_toolchain=\"//build/toolchain/linux/unbundle:default\" proprietary_codecs=true rtc_link_pipewire=true rtc_use_pipewire=true symbol_level=0 use_custom_libcxx=false use_sysroot=false use_system_freetype=true use_system_harfbuzz=true use_system_libjpeg=true " mkdir -p "$srcdir"/ringrtc-$_ringrtcver/out/release msg "Building signal's webrtc" gn gen "$srcdir"/ringrtc-$_ringrtcver/out/release --args="$(echo $webrtc_args)" ninja -C "$srcdir"/ringrtc-$_ringrtcver/out/release webrtc ) # add lto for the remaining c steps (sqlite) export CFLAGS="$CFLAGS -flto" export CXXFLAGS="$CXXFLAGS -flto" export LDFLAGS="$LDFLAGS -flto -fuse-ld=lld" ( cd "$srcdir"/ringrtc-$_ringrtcver/src/rust msg "Building libringrtc" OUTPUT_DIR="$srcdir"/ringrtc-$_ringrtcver/out \ cargo build --features electron --release mkdir -p ../node/build/linux cp -fv target/release/libringrtc.so ../node/build/linux/libringrtc-$chromium_arch.node ) ( cd "$srcdir"/ringrtc-$_ringrtcver/src/node msg "Building ringrtc JS glue code" yarn build ) # module on npm intentionally unbuildable: https://github.com/signalapp/libsignal/issues/464#issuecomment-1160665052 ( cd "$srcdir"/libsignal-$_libsignalver/node msg "Building libsignal" yarn node-gyp configure --nodedir=/usr/include/electron/node_headers --build-from-source yarn node-gyp build --nodedir=/usr/include/electron/node_headers --build-from-source mkdir -p prebuilds/linux-$chromium_arch mv build/Release/libsignal_client_linux_$chromium_arch.node prebuilds/linux-$chromium_arch/node.napi.node msg "Building libsignal glue code" yarn tsc ) # from package.json postinstall yarn build:acknowledgments yarn patch-package rm -rf node_modules/dtrace-provider # use our libsignal rm -rf node_modules/@signalapp/libsignal-client/ ln -s "$srcdir"/libsignal-$_libsignalver/node/ node_modules/@signalapp/libsignal-client # use our libringrtc rm -rf node_modules/ringrtc/ ln -s "$srcdir"/ringrtc-$_ringrtcver/src/node/ node_modules/ringrtc # patch the sqlcipher module for x in $source; do case "$x" in bettersqlite-*.patch) msg "$x" patch -Np1 -i "$srcdir"/$x -d "$srcdir"/Signal-Desktop-$pkgver/node_modules/better-sqlite3/ ;; esac done # use system-provided font echo '' > node_modules/typeface-inter/inter.css rm -rf 'node_modules/typeface-inter/Inter '* npm rebuild sharp better-sqlite3 --nodedir=/usr/include/electron/node_headers --build-from-source NODE_ENV=production \ SIGNAL_ENV=production \ NODE_OPTIONS=--openssl-legacy-provider \ yarn build:dev NODE_ENV=production \ SIGNAL_ENV=production \ yarn build:electron \ --config.extraMetadata.environment=production \ --config.directories.output=release \ --linux=dir } check() { # tests run against downloaded build of electron for glibc, probably can be patched yarn test } package() { cd "$builddir"/release/linux-unpacked install -Dm644 resources/app.asar "$pkgdir"/usr/lib/$pkgname/app.asar cp -r resources/app.asar.unpacked "$pkgdir"/usr/lib/$pkgname/app.asar.unpacked install -Dm755 "$srcdir"/$pkgname "$pkgdir"/usr/bin/$pkgname install -Dm644 "$srcdir"/$pkgname.desktop "$pkgdir"/usr/share/applications/$pkgname.desktop for i in 16 32 48 128 250 256 1024; do install -Dm644 "$builddir"/images/icon_$i.png "$pkgdir"/usr/share/icons/hicolor/${i}x$i/apps/$pkgname.png done } sha512sums=" 8f5234fa018e0590b3cad934ab46797bef16ff489a36a05364df7f43be80022143e8034665d2f24a171401bfac3315a16918d702a249c9ef8acd1de78e30f52e Signal-Desktop-6.1.0.tar.gz d2c13bf0d96eb706afe018c0ef9b377f3f50d2a82690f6ccb7260efa7cc620fb5c52ae775d598d6ebcaa581acfaab244dfe6f7f1738755604bf860cd548a62b6 libsignal-0.21.1.tar.gz e263390ea2ae877edb39e9973a8c8a03e2f396f255ca48487311031c69493a93da0dedbce5f10adfef4859cb8e51579bf285fbd9b94f98fabd538acaee18c413 ringrtc-2.22.0.tar.gz 748f870d35b9a9789311c3d7cee9c0bc150aed8094838406e0a1969f2f824900ffec40d0b4fe2702f2f93d4a78d7987b0f91668cff859a8a34517663b138f8b5 webrtc-5005b.tar.xz 1aaf59c2d401ae127ed73981be330cd999794a217b455cb8033652063eb7b549c7070c63f54e4e60bf4338b475e162b6eae98683c3ce058e8f1a407588b3b2e1 bettersqlite-use-system-sqlcipher.patch 3ecfbd1b0cd03d1a697f3e53c057fa8bc2118de48ff0c3f07f8bb731f128f9478862a388efb36dd4dbc1dc5ad9977165a935fe65664aea915b8b80c38e801070 signal-build-expire-time.patch 60a45285d885922f5c21f64b761a10efbee9081baf3efa4c8c13abc6a43dc4d27662ed10e239b0fa2071ab9e3a0dbbb4b11d6e3d26fe2b74a19f39e72b74a5bd signal-disable-updates.patch c68a2a6a37c1cdea227f29c0922b9bf15259f044e9b3240b120bba14809d04d66cf0b619f52bb91abd596ad93e51e972be132b5951d0e8f6ea238fcb7bb613eb signal-update-links.patch 252b37a2ecc5e7a25385943045f426dc2e30991b28d206ceaff1be7fd8ffeeb024310a8fca6b3e69a4b1c57db535d51c570935351053525f393682d5ecd0f9a9 webrtc-canonicalize-file-name.patch 6add8b4c293f5392748a2eec9486cb4a6534e161977c6a98de71617b9abcdd1e8ad94b44014256a4b52e33eb9dd4aca380279d4161629a1bb2d7b15f8eb5b459 webrtc-use-alpine-target.patch bab56a33265b5b094f161af1462166e371913a5269fe8e7d12e9f65ec4f5b908157406b3bcbcf73db15d03470445127d27c64fd731b6ea57c631aba3f4d302cb webrtc-no-shared-deps-in-static-lib.patch 87534e7b5ad7365509eab75629e6bd1a9ed61ee92f7e358405a0abaf0df57de14623fb3894eb082f8785422e5c087e1c50f9e2e5cafbb2529591fd7bf447f7f5 signal-desktop 87ef5f3ffcf64e3cae308aa0f6bc208fb05dd8568f6a288217cdf8498ae1523f276987a7be8d6f5208f13394bab350e08734d806a8e7c08849dd8ba0dda49d66 signal-desktop.desktop "