File signal-sqlcipher.spec of Package signal-sqlcipher
#
# spec file for package signal-sqlcipher
#
# Copyright (c) 2024 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/
#
#Whether to apply fixes so that libsignal_tokenizer gets compiled with LTO.
# On Leap the system LLVM is too old.
%if 0%{?suse_version} >= 1650 || 0%{?fedora} >= 42
# FC41: “Expected at most one ThinLTO module per bitcode file” (bsc#1229988)
%bcond_without llvm_lto
%else
%bcond_with llvm_lto
%endif
%global __provides_exclude ^lib.*\\.so.*$
Name: signal-sqlcipher
Version: 2.4.4
Release: 0
Summary: Database library for Signal Messenger
License: AGPL-3.0-only AND BSD-3-Clause AND MIT AND (MIT OR Apache-2.0) AND (Zlib OR Apache-2.0 OR MIT)
Group: System/Libraries
Url: https://github.com/signalapp/node-sqlcipher
#
Source0: https://github.com/signalapp/node-sqlcipher/archive/refs/tags/v%{version}.tar.gz
Source1: vendor.tar.zst
Patch0: rust-output-path.patch
Patch3000: sha2-asm-noexecstack.patch
BuildRequires: cargo
%if 0%{?suse_version} > 1500 || 0%{?fedora_version}
BuildRequires: gcc-c++ >= 11
%else
BuildRequires: gcc13-PIE
BuildRequires: gcc13-c++
%endif
BuildRequires: jq
BuildRequires: nodejs-electron-devel
%if %{with llvm_lto}
BuildRequires: clang
%if 0%{?suse_version}
BuildRequires: llvm-gold >= 16
%else
BuildRequires: llvm-libs
%endif
%endif
%if 0%{?fedora}
BuildRequires: python3
BuildRequires: rust-srpm-macros
%else
BuildRequires: cargo-packaging >= 1.2.0+3
BuildRequires: cargo-auditable
BuildRequires: python3-base
%endif
BuildRequires: zstd
%description
node-sqlcipher contains sqlcipher and Signal-specific FTS5 segmenting APIs.
This package contains the NodeJS native module used by `signal-desktop` and is not intended to be used outside that application.
%prep
%autosetup -p1 -a1 -n node-sqlcipher-%{version}
# https://blogs.gnome.org/mcatanzaro/2020/05/18/patching-vendored-rust-dependencies/
for i in \
sha2-asm \
; do
pushd deps/extension/vendor/$i
jq -cj '.files={}' .cargo-checksum.json >tmp && mv tmp .cargo-checksum.json && popd
done
%build
export CC=gcc
export CXX=g++
export AR=gcc-ar
export NM=gcc-nm
export RANLIB=gcc-ranlib
%if 0%{?suse_version} && 0%{?suse_version} <= 1500
export CC=gcc-13
export CXX=g++-13
export AR=gcc-ar-13
export NM=gcc-nm-13
export RANLIB=gcc-ranlib-13
%endif
export RUSTFLAGS="%{build_rustflags} --verbose"
export RUSTC_LOG='rustc_codegen_ssa::back::link=info'
export RUST_BACKTRACE=1
export CARGO_TERM_VERBOSE=true
# https://github.com/Firstyear/cargo-packaging/pull/10
export CARGO_INCREMENTAL=0
%if 0%{?suse_version}
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}"
# The `cc` crate tries to be too clever and passes some default cflags.
# Disable these and use only the ones from CFLAGS env. variable
export CRATE_CC_NO_DEFAULTS=1
# make `sha2-asm` output build log
export CC_ENABLE_DEBUG_OUTPUT=1
%if %{with llvm_lto}
LLVM_CPU_FLAGS=$(clang $(echo " $CXXFLAGS " | sed 's/ -mtls-dialect=gnu2 / /') -xc /dev/null --verbose -S 2>&1 | \
grep -F null.s | \
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)')
%endif
#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 "
pushd deps/extension
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
popd
%electron_rebuild
%install
install -pvDm755 build/Release/node_sqlcipher.node \
%{buildroot}%{_libexecdir}/signal-desktop/node_modules/@signalapp/sqlcipher/build/Release/node_sqlcipher.node
%check
%electron_check_native
#No rust tests, and we don't bother with the JS test due to needing to vendor more
%files
%defattr(-,root,root)
%license LICENSE
%{_libexecdir}/signal-desktop
%changelog