File signal-desktop.spec of Package signal-desktop
#
# spec file for package signal-desktop
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
%global signal_env production
%global pkg_name Signal-Desktop
%global signal_ringrtc_req_version 2.39.2
%global nodejs_includedir %{_includedir}/electron
%global electron_req_version 25~
%global electron_includedir %{_includedir}/electron
# Do not check for npm requires or provides in app.asar
%global __provides_exclude ^npm(.*)|^nodejs(.*)
%global __requires_exclude ^npm(.*)|^nodejs(.*)
#Both electron and webrtc require SSE2 on the x86 port. So we can require SSE2 on all other code, too.
%ifarch %ix86
ExclusiveArch: i586 i686
BuildArch: i686
%{expand:%%global optflags %(echo "%optflags") -march=pentium4 -mtune=generic}
%{expand:%%global build_rustflags %(echo "%build_rustflags") -C target-cpu=pentium4 -Z tune-cpu=generic}
%endif
#Whether to apply fixes so that libsignal_tokenizer gets compiled with LTO.
# On Leap the system LLVM is too old.
%if 0%{?suse_version} >= 1550 || 0%{?sle_version} >= 150700 || 0%{?fedora}
# On ARM the linker segfaults. This seems to be a LLVM 18 regression.
%ifarch %arm
%bcond_with llvm_lto
%else
%bcond_without llvm_lto
%endif
%else
%bcond_with llvm_lto
%endif
Name: signal-desktop
Version: 7.4.0
Release: 0
Summary: Fast, simple and secure messaging app from your desktop
License: AGPL-3.0-only and MIT and (MIT or CC0-1.0) and Apache-2.0 and BSD-3-Clause and ISC and SUSE-Public-Domain
Group: Productivity/Networking/Instant Messenger
Url: https://github.com/signalapp/Signal-Desktop/
#
Source0: https://github.com/signalapp/Signal-Desktop/archive/v%{version}/%{pkg_name}-%{version}.tar.gz
Source1: vendor.tar.zst
Source2: %{name}.desktop
#
# Link better-sqlite3 with system openssl
Patch0: signal-desktop-better-sqlite3-dependencies.patch
# Remove HEIC support from main.js
Patch2: signal-desktop-remove-heif-support.patch
#
# Workaround for https://github.com/signalapp/Signal-Desktop/issues/5616
Patch3: 0001-ts-log-Avoid-log-spam-for-ResizeObserver-loop-limit-.patch
# Do not distribute bogus dev tool in package
# Code loaded in renderer process is webpecked, but the one in main process unfortunately isnt.
# This means we ship the same code twice. Ouch. (Probably some files in ts/ are also not needed, which means we could slim this further)
Patch5: Remove-build-time-dependencies.patch
# Inter font is available on both SUSE and Fedora
Patch6: Use-system-Inter-font.patch
Patch7: esbuild_version.patch
# Fix build on arm7
Patch8: do-not-guess-rust-target.patch
# Do not try to patch the elctron executable
Patch9: remove-fuses.patch
# fix rust breaking gcc LTO
Patch10: boringssl-sys-no-static.patch
Patch11: Revert-disable-hardware-acceleration.patch
Patch13: make-webpack-errors-comprehensible.patch
Patch19: better-sqlite3-no-download.patch
Patch20: ringrtc-no-download.patch
Patch21: system-esbuild.patch
Patch24: libsignal-client-visibility-hidden.patch
Patch27: cc-link-lib-no-static.patch
Patch29: no-comments-or-sourcemaps.patch
#
#
BuildRequires: app-builder
BuildRequires: cargo
#There are major API breaks between 0.16 and 0.17.
BuildRequires: esbuild >= 0.17
BuildRequires: fdupes
#see node_modules/@signalapp/libsignal-client/vendor/boring-sys/build.rs
BuildRequires: git-core
BuildRequires: gcc-c++
BuildRequires: hicolor-icon-theme
BuildRequires: jq
BuildRequires: make
BuildRequires: nodejs-packaging
BuildRequires: nodejs-electron-devel >= %{electron_req_version}
BuildRequires: pkgconfig(openssl)
# support for `optional` keyword is now required
BuildRequires: protobuf-devel >= 3.15
BuildRequires: python3-packaging
%if 0%{?fedora}
BuildRequires: rust-srpm-macros
%else
%if 0%{?suse_version} >= 1550 || 0%{?sle_version} >= 150600
BuildRequires: cargo-packaging >= 1.2.0+3
%else
BuildRequires: rust-packaging
%endif
BuildRequires: cargo-auditable
%endif
BuildRequires: signal-libringrtc = %{signal_ringrtc_req_version}
%if 0%{?fedora} >= 37
BuildRequires: nodejs-npm
%else
BuildRequires: npm
%endif
BuildRequires: cmake
BuildRequires: clang-devel
%if 0%{?suse_version}
%if %{with llvm_lto}
BuildRequires: llvm-gold >= 16
%endif
BuildRequires: rust-cbindgen
BuildRequires: update-desktop-files
BuildRequires: yarn
%else
%if %{with llvm_lto}
BuildRequires: llvm-libs
%endif
BuildRequires: cbindgen
BuildRequires: yarnpkg
%endif
BuildRequires: zstd
#
%electron_req
Requires: signal-libringrtc%{?_isa} = %{signal_ringrtc_req_version}
Requires: (font(inter) or inter-fonts)
#Support upgrading from old RPM versions which had separate langpacks.
#We cannot do that anymore as signal now aborts when the langpack is missing instead of gracefully falling back to english.
%define lang_subpkg() \
Provides: signal-desktop-langpack-%{1} = %{version}\
Obsoletes: signal-desktop-langpack-%{1} < %{version}
%lang_subpkg af af-ZA Afrikaans
%lang_subpkg ar ar Arabic
%lang_subpkg az az-AZ Azerbaijani
%lang_subpkg bg bg-BG Bulgarian
%lang_subpkg bn bn-BD Bengali
%lang_subpkg bs bs-BA Bosnian
%lang_subpkg ca ca Catalan
%lang_subpkg cs cs Czech
%lang_subpkg da da Danish
%lang_subpkg de de German
%lang_subpkg el el Greek
%lang_subpkg es es Spanish
%lang_subpkg et et-EE Estonian
%lang_subpkg eu eu Basque
%lang_subpkg fa fa-IR Persian
%lang_subpkg fi fi Finnish
%lang_subpkg fr fr French
%lang_subpkg ga ga-IE Irish
%lang_subpkg gl gl-ES Galician
%lang_subpkg gu gu-IN Gujarati
%lang_subpkg he he Hebrew
%lang_subpkg hi hi-IN Hindi
%lang_subpkg hr hr-HR Croatian
%lang_subpkg hu hu Hungarian
%lang_subpkg id id Indonesian
%lang_subpkg it it Italian
%lang_subpkg ja ja Japanese
%lang_subpkg ka ka-GE Georgian
%lang_subpkg kk kk-KZ Kazakh
%lang_subpkg km km-KH Khmer
%lang_subpkg kn kn-IN Kannada
%lang_subpkg ko ko Korean
%lang_subpkg ky ky-KG Kirghiz
%lang_subpkg lt lt-LT Lithuanian
%lang_subpkg lv lv-LV Latvian
%lang_subpkg mk mk-MK Macedonian
%lang_subpkg ml ml-IN Malayalam
%lang_subpkg mr mr-IN Marathi
%lang_subpkg ms ms Malay
%lang_subpkg my my Burmese
%lang_subpkg nb nb %{quote:Norwegian Bokmal}
%lang_subpkg nl nl Dutch
%lang_subpkg pa pa-IN Panjabi
%lang_subpkg pl pl Polish
%lang_subpkg pt_BR pt-BR %{quote:Brazilian Portuguese}
%lang_subpkg pt_PT pt-PT %{quote:European Portuguese}
%lang_subpkg ro ro-RO Romanian
%lang_subpkg ru ru Russian
%lang_subpkg sk sk-SK Slovak
%lang_subpkg sl sl-SI Slovenian
%lang_subpkg sq sq-AL Albanian
%lang_subpkg sr sr-RS Serbian
%lang_subpkg sv sv Swedish
%lang_subpkg sw sw Swahili
%lang_subpkg ta ta-IN Tamil
%lang_subpkg te te-IN Telugu
%lang_subpkg th th Thai
%lang_subpkg tl tl-PH Tagalog
%lang_subpkg tr tr Turkish
%lang_subpkg ug ug Uighur
%lang_subpkg uk uk-UA Ukrainian
%lang_subpkg ur ur Urdu
%lang_subpkg vi vi Vietnamese
%lang_subpkg yue yue Cantonese
%lang_subpkg zh_CN zh-CN %{quote:Simplified Chinese}
%lang_subpkg zh_HK zh-HK %{quote:Chinese (Hong Kong)}
Obsoletes: signal-desktop-langpack-cy < %version
Obsoletes: signal-desktop-langpack-eo < %version
Obsoletes: signal-desktop-langpack-fil < %version
Obsoletes: signal-desktop-langpack-gd < %version
Obsoletes: signal-desktop-langpack-is < %version
Obsoletes: signal-desktop-langpack-ku < %version
Obsoletes: signal-desktop-langpack-lo < %version
Obsoletes: signal-desktop-langpack-nn < %version
Obsoletes: signal-desktop-langpack-no < %version
Obsoletes: signal-desktop-langpack-ps < %version
Obsoletes: signal-desktop-langpack-ug < %version
Obsoletes: signal-desktop-langpack-yue < %version
Obsoletes: signal-desktop-langpack-zh_TW < %version
#
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
Signal Desktop is an Electron application that links with your Signal Android
or Signal iOS app.
%prep
%autosetup -p1 -n %{pkg_name}-%{version} -a 1
# these files are used only in tests but needed for compilation. somehow missing from tarball.
mkdir -pv node_modules/@signalapp/libsignal-client/rust/attest/tests/data
touch node_modules/@signalapp/libsignal-client/rust/attest/tests/data/cds2_test.{evidence,endorsements,mrenclave,privatekey}
#Sanity check that we've declared the correct version in header
test $(jq -cj '.version' node_modules/@signalapp/ringrtc/package.json) = %{signal_ringrtc_req_version}
# Remove HEIC releated files. We don't have heic-convert.
rm -f ts/heic-convert.d.ts
rm -f ts/workers/heicConverterMain.ts
rm -f ts/workers/heicConverterWorker.ts
#Remove vendored font, we use the system copy
rm -rf fonts/inter-v3.19
# https://blogs.gnome.org/mcatanzaro/2020/05/18/patching-vendored-rust-dependencies/
for i in boring-sys prost-build libloading bindgen rustix blake2 cc pqcrypto-kyber pqcrypto-kyber-0.7.9 pqcrypto-internals serde_derive; do
pushd node_modules/@signalapp/libsignal-client/vendor/$i
jq -cj '.files={}' .cargo-checksum.json >tmp && mv tmp .cargo-checksum.json && popd
done
# Make `node` and `npm` binaries refer to Electron
%if 0%{?suse_version}
NODEJS_DEFAULT_VER=$(echo %nodejs_version|sed 's/\..*//')
%else
NODEJS_DEFAULT_VER=
%endif
# Electron has a little known feature that make it work like a nodejs binary.
# We make use of it since the system node may be too bleeding-edge
# and to avoid building the same modules twice.
# Not all scripts work when run under electron,
# but importantly npm/yarn and GYP do.
mkdir %{_builddir}/path
cat <<"EOF" > %{_builddir}/path/cargo
#!/bin/sh
#remove our wrapper from path
export PATH="$(echo "$PATH" | sed 's[%{_builddir}/path:[[')"
exec %{_bindir}/cargo -vv $auditable "$@"
EOF
cat <<EOF > %{_builddir}/path/node
#!/bin/sh
ELECTRON_RUN_AS_NODE=1 exec %{_libdir}/electron/electron "\$@"
EOF
# HACK: This will refer to /usr/bin/npm17 on openSUSE, /usr/bin/npm on Fedora which are Node scripts
cat <<EOF > %{_builddir}/path/npm
#!/bin/sh
exec node %{_bindir}/npm${NODEJS_DEFAULT_VER} "\$@"
EOF
cat <<EOF > %{_builddir}/path/npx
#!/bin/sh
exec node %{_bindir}/npx${NODEJS_DEFAULT_VER} "\$@"
EOF
# On Fedora, /usr/bin/yarn is a node script. On openSUSE, it is a shell script.
%if 0%{?fedora}
cat <<EOF > %{_builddir}/path/yarn
#!/bin/sh
exec node %{_bindir}/yarn "\$@"
EOF
%endif
#AWFUL HACK: Custom cmake wrapper to override CFLAGS because -g -O2 seems to get stripped by Rust no matter what i do otherwise
#Compare openSUSE macros.cmake
cat <<"EOF" > %{_builddir}/path/cmake
#!/bin/bash
if [[ "$1" = --build ]]; then
exec %{_bindir}/cmake "$@"
fi
exec %{_bindir}/cmake "$@" -DCMAKE_C_FLAGS="${CFLAGS}" \
-DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS="$LDFLAGS -Wl,--as-needed -Wl,--no-undefined -Wl,-z,now" \
-DCMAKE_MODULE_LINKER_FLAGS="$LDFLAGS -Wl,--as-needed" \
-DCMAKE_SHARED_LINKER_FLAGS="$LDFLAGS -Wl,--as-needed -Wl,--no-undefined -Wl,-z,now"
EOF
cat %{_builddir}/path/cmake
chmod +x %{_builddir}/path/*
%build
#work around bsc#1216691
export SOURCE_DATE_EPOCH="$(stat --printf=%Y LICENSE)"
export RUSTFLAGS="%{build_rustflags} --verbose"
export RUSTC_LOG='rustc_codegen_ssa::back::link=info'
export RUST_BACKTRACE=1
export CARGO_TERM_VERBOSE=true
%if 0%{?suse_version}
export auditable='auditable -vv'
%endif
#[ 114s] npm ERR! error[E0554]: `#![feature]` may not be used on the stable release channel
#[ 114s] npm ERR! --> /home/abuild/rpmbuild/BUILD/Signal-Desktop-5.55.0/node_modules/@signalapp/libsignal-client/vendor/polyval/src/lib.rs:80:5
export RUSTC_BOOTSTRAP=1
export CFLAGS="%{optflags} -fpic -fno-semantic-interposition -fno-fat-lto-objects -fvisibility=hidden"
export CXXFLAGS="%{optflags} -fpic -fno-semantic-interposition -fno-fat-lto-objects -fvisibility=hidden"
export MAKEFLAGS="%{_smp_mflags}"
# use correct hardening defines also when generating headers for Rust
# this does not (currently) affect the compiled binary at all but better safe than sorry
# -fvisiblity=default works around a bug in bindgen
export BINDGEN_EXTRA_CLANG_ARGS="$(echo " $CXXFLAGS " | sed 's/ -mtls-dialect=gnu2 / /') -fvisibility=default"
LLVM_CPU_FLAGS=$(clang $(echo " $CXXFLAGS " | sed 's/ -mtls-dialect=gnu2 / /') -xc /dev/null --verbose -S 2>&1 | \
grep usr/bin/clang | \
sed 's/-target-feature\s\+/--mattr=/g' | \
sed 's/-mfloat-abi\s\+/--float-abi=/g' | \
sed 's/-target-cpu\s\+/--mcpu=/g' | \
sed 's/ /\n/g' |grep -E '^--(mattr|mcpu|float-abi)')
#make LD able to consume rust LTO libraries
export LDFLAGS="%{?build_ldflags} \
%if %{with llvm_lto}
-Wl,--plugin=LLVMgold.so -Wl,--plugin-opt=O3 $(echo "$LLVM_CPU_FLAGS" | sed 's/^/ -Wl,--plugin-opt=/' | tr "\n" ' ') \
%endif
-Wl,--gc-sections -Wl,-O2 "
export ELECTRON_CACHE=$(pwd)/vendor/cache/electron
export ELECTRON_BUILDER_CACHE=$(pwd)/vendor/cache/electron-builder
export SIGNAL_ENV=%{signal_env}
# node_modules/playwright
export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
export ELECTRON_SKIP_BINARY_DOWNLOAD=1
# libsignal-client
export PROTOC=%{_bindir}/protoc
export PROTOC_INCLUDE=%{_includedir}
# The `cc` crate tries to be too clever and passes some default cflags to cmake.
# Disable these and use only the ones from CFLAGS env. variable
export CRATE_CC_NO_DEFAULTS=1
# Ensure cmake gets the RelWithDebInfo profile
export CARGO_PROFILE_RELEASE_DEBUG=2
# make cmake louder?
export VERBOSE=1
export V=1
export ESBUILD_BINARY_PATH=%{_bindir}/esbuild
export USE_SYSTEM_APP_BUILDER=true
# Do not panic when run under different node version than specified in manifest.
yarn config set ignore-engines true
# Fix package.json
cp package.json package.json.orig
sed 's#"postinstall": .*##' -i package.json
# Use the system electron for building
electron_version="$(< %{_libdir}/electron/version)"
# Passing `--universal` as the architecture makes the output path predictable.
# Node-gyp rebuild inside electron-builder fails with Node ≥17 (Fedora)
# But we do not need to rebuild anything, since the initial `npm rebuild` is done against Electron in the first place!
sed -i -r 's#("build:electron": ").*"#\1electron-builder --config.extraMetadata.environment=$SIGNAL_ENV --linux dir --universal -c.electronDist=%{_libdir}/electron -c.electronVersion=${electron_version} -c.asar=false -c.nodeGypRebuild=false -c.npmRebuild=false"#' package.json
# We use signal-client source repo
echo ">>>>>> Use signal-client source (package.json)"
SIGNAL_CLIENT_VERSION=$(jq -cj '.dependencies."@signalapp/libsignal-client"' package.json)
sed -i 's|"@signalapp/libsignal-client": "|"@signalapp/libsignal-client": "https://github.com/signalapp/libsignal-client#v|' package.json
sed 's|"resolutions": {|"resolutions": {\n "@signalapp/libsignal-client": "https://github.com/signalapp/libsignal-client#v'${SIGNAL_CLIENT_VERSION}'",|' -i package.json
# Remove HEIF/HEIC support
sed -i '/"heic-convert": .*/d' package.json
sed -i '/".*heicConverter.bundle.js".*/d' package.json
diff -u package.json.orig package.json || true
export npm_config_nodedir="%{nodejs_includedir}"
export npm_config_build_from_source=true
# Build signal-tokenizer rust library
pushd node_modules/@signalapp/better-sqlite3/deps/sqlite3/signal-tokenizer
cargo -vv $auditable rustc --release --lib --crate-type staticlib \
%if %{with llvm_lto}
-- -Clinker-plugin-lto
# ^^^ rustc tries to produce fat objects by default, they do not work with the system linker
# which only sees native code and does not invoke the plugin
# Tell it to produce only LTO bytecode instead of fat binaries
%endif
cbindgen --profile release . -o include/signal-tokenizer.h
popd
### Rebuild node modules from source
# Copy libringrtc from signal-ringrtc package
mkdir -pv node_modules/@signalapp/ringrtc/build/linux/
cp -pv %{_libexecdir}/signal-desktop/node_modules/@signalapp/ringrtc/build/linux/*.node -t node_modules/@signalapp/ringrtc/build/linux/
# Run rebuild under electron instead of node because GYP gets broken when the system node is too new (Rawhide)
PATH="%{_builddir}/path:$PATH" npm rebuild --verbose --foreground-scripts
### Create prerequisites
#Compile typescript code in libsignal-client
pushd node_modules/@signalapp/libsignal-client
# HACK
# We need to move the @types directory or tsc will walk up to parent
# directories and pick it up.
mv ../../@types{,_ignore}
yarn --offline --no-lockfile tsc
mv ../../@types{_ignore,}
popd
#compile sticker creator
pushd sticker-creator
PATH="%{_builddir}/path:$PATH" npm rebuild --verbose --foreground-scripts
yarn --offline --no-lockfile build
popd
yarn --offline --no-lockfile generate
### Build
# Run electron-builder
yarn --offline --no-lockfile build:release
%install
install -d -m 0755 %{buildroot}%{_bindir}
cat << EOF > %{buildroot}%{_bindir}/signal-desktop
#!/bin/sh
export NODE_ENV=production
exec electron %{_libexecdir}/%{name} "\$@"
EOF
chmod +x %{buildroot}%{_bindir}/signal-desktop
# icons
for i in 16 24 32 48 64 128 256 512 1024; do
install -d -m 0755 %{buildroot}%{_datadir}/icons/hicolor/${i}x${i}/apps/
install -pm 0644 build/icons/png/${i}x${i}.png %{buildroot}%{_datadir}/icons/hicolor/${i}x${i}/apps/%{name}.png
done
# desktop file
install -d -m 0755 %{buildroot}%{_datadir}/applications/
install -pm 0644 %{SOURCE2} %{buildroot}%{_datadir}/applications/%{name}.desktop
# Copy the app itself
mkdir -pv %{buildroot}%{_libexecdir}
cp -plr release/linux-universal-unpacked/resources/app %{buildroot}%{_libexecdir}/%{name}
# Copy the native modules that were ignored by electron-builder
find -type f -name '*.node' -print -exec install -pvDm755 {} "%{buildroot}%{_libexecdir}/%{name}/{}" \;
#Remove development garbage
cd %{buildroot}%{_libexecdir}/%{name}
#JS debugging symbols
find -name '*.map' -type f -print -delete
#Source code
rm -rf node_modules/@signalapp/libsignal-client/{bin,false,java,rust,swift,vendor,node,ts}
rm -vf node_modules/@signalapp/libsignal-client/build_node_bridge.py
find -name '*.c' -type f -print -delete
find -name '*.cpp' -type f -print -delete
find -name '*.h' -type f -print -delete
find -name '*.m' -type f -print -delete
find -name '*.ts' -type f -print -delete
find -name '*.tsx' -type f -print -delete
find -name '*.gyp' -type f -print -delete
find -name '*.gypi' -type f -print -delete
find -name tsconfig.json -type f -print -delete
find -name Cargo.lock -type f -print -delete
find -name Cargo.toml -type f -print -delete
find -name '.babel*' -type f -print -delete
find -name '*.flow' -type f -print -delete
find -name bower.json -type f -print -delete
find -name composer.json -type f -print -delete
find -name component.json -type f -print -delete
find -name '*.patch' -type f -print -delete
#Compile-time-only dependencies
find -name nan -print0 |xargs -r0 -- rm -rvf --
find -name node-addon-api -print0 |xargs -r0 -- rm -rvf --
find -name test*.node -type f -print -delete
#Bogus (empty) DLLs which cannot be loaded by node
rm -rfv node_modules/@{nodert-win10-rs4/windows.{data.xml.dom,ui.notifications},signalapp/windows-dummy-keystroke}/build/Release
#Documentation
find -name '*.markdown' -type f -print -delete
find -name '*.bnf' -type f -print -delete
find -name '*.mli' -type f -print -delete
find -name CHANGES -type f -print -delete
find -name TODO -type f -print -delete
find -name usage.txt -type f -print -delete
#Other garbage
rm -rf build/icons
rm -rf protos
rm -rf release
find -name .cargo -print0 |xargs -r0 -- rm -rvf --
find -name .github -print0 |xargs -r0 -- rm -rvf --
find -name .husky -print0 |xargs -r0 -- rm -rvf --
find -name obj.target -print0 |xargs -r0 -- rm -rvf --
find -name etc -print0 |xargs -r0 -- rm -rvf --
find -name '.eslint*' -type f -print -delete
find -name .editorconfig -type f -print -delete
find -name .lint -type f -print -delete
find -name '.jscs*' -type f -print -delete
find -name '.prettier*' -type f -print -delete
find -name '.grenrc*' -type f -print -delete
find -name .npmrc -type f -print -delete
find -name .nycrc -type f -print -delete
find -name .taprc -type f -print -delete
find -name '.nvm*' -type f -print -delete
find -name '.rustfmt*' -type f -print -delete
find -name .flake8 -type f -print -delete
find -name .clippy.toml -type f -print -delete
find -name .bithoundrc -type f -print -delete
find -name .testem.json -type f -print -delete
find -name '*travis*.yml' -type f -print -delete
find -name rust-toolchain -type f -print -delete
find -name '*.podspec' -type f -print -delete
find -name '*~' -type f -print -delete
find -name '*.bak' -type f -print -delete
find -name sri-history.json -type f -print -delete
find -name Dockerfile -type f -print -delete
find -name docker-prebuildify.sh -type f -print -delete
#Remove tests
rm -rf ts/test-{both,electron,mock,node}
# this library is shipped by another package we depend on
rm -rf node_modules/@signalapp/ringrtc/build
# Remove empty directories
find . -type d -empty -print -delete
#Fix file mode
find . -type f -exec chmod 644 {} \;
find . -name '*.node' -exec chmod 755 {} \;
%fdupes %{buildroot}%{_libexecdir}/%{name}
%if 0%{?suse_version}
%suse_update_desktop_file %{name}
%endif
%check
# Sanity check that we don't have unresolved symbols. It does not fail the build in the case
# of a shared library, and that problem already happened twice in the history of this package.
# All unresolved symbols should start with node / napi / uv / v8, they are exported by electron itself.
pushd %{buildroot}%{_libexecdir}/%{name}
find . -name '*.node' -print0 | xargs -0 -t -IXXX sh -c '! ldd -d -r XXX | \
grep '\''^undefined symbol'\'' | \
grep -v '\''^undefined symbol: _ZN2v8'\'' | \
grep -v '\''^undefined symbol: _ZNK2v8'\'' | \
grep -v '\''^undefined symbol: _ZN4node'\'' | \
grep -v '\''^undefined symbol: node_'\'' | \
grep -v '\''^undefined symbol: napi_'\'' | \
grep -v '\''^undefined symbol: uv_'\'' '
# Check that all native modules are loadable.
find . -name '*.node' -print0 | xargs -0 -t -IXXX env ELECTRON_RUN_AS_NODE=1 %{_libdir}/electron/electron -e 'require("XXX")'
# Sanity check that we did not mistakenly link system openssl instead of boringssl
# since they have the same name and a similar set of exported symbols
objdump -p node_modules/@signalapp/libsignal-client/build/Release/*.node >%{_builddir}/objdump
cat %{_builddir}/objdump
! grep -F libcrypto %{_builddir}/objdump
! grep -F libssl %{_builddir}/objdump
popd
%ifnarch riscv64
# Try to run signal and ensure that it gets to the point where it tries to initialize the X server
TMPDIR=$(mktemp -d)
cp -pr %{buildroot}%{_libexecdir}/%{name} -t "$TMPDIR"
mkdir -p "${TMPDIR}/%{name}/node_modules/@signalapp/ringrtc/build/linux/"
cp -pv %{_libexecdir}/%{name}/node_modules/@signalapp/ringrtc/build/linux/*.node -t "${TMPDIR}/%{name}/node_modules/@signalapp/ringrtc/build/linux/"
electron "${TMPDIR}/%{name}" --no-sandbox >"${TMPDIR}/testlog" 2>&1 || true
cat "${TMPDIR}/testlog"
grep -F ozone_platform_x11.cc "${TMPDIR}/testlog"
%endif
#rust tests
export RUSTFLAGS="%{build_rustflags} --verbose"
export RUSTC_LOG='rustc_codegen_ssa::back::link=info'
export RUST_BACKTRACE=1
export CARGO_TERM_VERBOSE=true
%if 0%{?suse_version}
export auditable='auditable -vv'
%endif
export RUSTC_BOOTSTRAP=1
export CFLAGS="%{optflags} -fpic -fno-semantic-interposition -fno-fat-lto-objects -fvisibility=hidden"
export CXXFLAGS="%{optflags} -fpic -fno-semantic-interposition -fno-fat-lto-objects -fvisibility=hidden"
export MAKEFLAGS="%{_smp_mflags}"
export BINDGEN_EXTRA_CLANG_ARGS="$(echo " $CXXFLAGS " | sed 's/ -mtls-dialect=gnu2 / /') -fvisibility=default"
export PROTOC=%{_bindir}/protoc
export PROTOC_INCLUDE=%{_includedir}
export CRATE_CC_NO_DEFAULTS=1
export CARGO_PROFILE_RELEASE_DEBUG=2
export VERBOSE=1
export V=1
LLVM_CPU_FLAGS=$(clang $(echo " $CXXFLAGS " | sed 's/ -mtls-dialect=gnu2 / /') -xc /dev/null --verbose -S 2>&1 | \
grep usr/bin/clang | \
sed 's/-target-feature\s\+/--mattr=/g' | \
sed 's/-mfloat-abi\s\+/--float-abi=/g' | \
sed 's/-target-cpu\s\+/--mcpu=/g' | \
sed 's/ /\n/g' |grep -E '^--(mattr|mcpu|float-abi)')
export LDFLAGS="%{?build_ldflags} \
%if %{with llvm_lto}
-Wl,--plugin=LLVMgold.so -Wl,--plugin-opt=O3 $(echo "$LLVM_CPU_FLAGS" | sed 's/^/ -Wl,--plugin-opt=/' | tr "\n" ' ') \
%endif
-Wl,--gc-sections -Wl,-O2 "
pushd node_modules/@signalapp/better-sqlite3/deps/sqlite3/signal-tokenizer
cargo -vv $auditable test --release --no-fail-fast
popd
pushd node_modules/@signalapp/libsignal-client
# see build_node_bridge.py — we're trying to match the actual build environment
mytarget=$(echo "$(pwd)"/build/Release/obj.target/*.node)
CARGO_BUILD_TARGET_DIR="${mytarget}/geni/rust" \
CARGO_PROFILE_RELEASE_LTO=thin \
RUSTFLAGS="$RUSTFLAGS --cfg aes_armv8 --cfg polyval_armv8" \
cargo -vv $auditable test --release --no-fail-fast --target $(rustc -vV | awk '/host/ { print $NF }')
popd
%files
%defattr(-,root,root)
%doc README.md
%license LICENSE ACKNOWLEDGMENTS.md
%{_bindir}/%{name}
%dir %{_libexecdir}/%{name}
%{_libexecdir}/%{name}/_locales
%{_libexecdir}/%{name}/app
%dir %{_libexecdir}/%{name}/build
%{_libexecdir}/%{name}/build/available-locales.json
%{_libexecdir}/%{name}/build/country-display-names.json
%{_libexecdir}/%{name}/build/dns-fallback.json
%{_libexecdir}/%{name}/build/locale-display-names.json
%{_libexecdir}/%{name}/bundles
%{_libexecdir}/%{name}/config
%{_libexecdir}/%{name}/fonts
%{_libexecdir}/%{name}/images
%{_libexecdir}/%{name}/js
%{_libexecdir}/%{name}/node_modules
%{_libexecdir}/%{name}/sounds
%dir %{_libexecdir}/%{name}/sticker-creator
%{_libexecdir}/%{name}/sticker-creator/dist
%{_libexecdir}/%{name}/stylesheets
%{_libexecdir}/%{name}/ts
%{_libexecdir}/%{name}/package.json
%{_libexecdir}/%{name}/*.bundle.js
%{_libexecdir}/%{name}/*.html
%dir %{_datadir}/icons/hicolor/1024x1024
%dir %{_datadir}/icons/hicolor/1024x1024/apps
%{_datadir}/icons/hicolor/*/apps/%{name}.*
%{_datadir}/applications/%{name}.desktop
%changelog