File nodejs-signal-ringrtc.spec of Package nodejs-signal-ringrtc
#
# spec file for package signal-ringrtc
#
# Copyright (c) 2020 SUSE LLC
# Copyright (c) 2019 Andreas Schneider <asn@cryptomilk.org>.
#
# 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 https://bugs.opensuse.org/
#
#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
%if 0%{?suse_version} || 0%{?fedora_version} >= 37
%bcond_without system_abseil
%else
%bcond_with system_abseil
%endif
%if 0%{?suse_version} >= 1550 || 0%{?sle_version} >= 150500 || 0%{?fedora_version}
%bcond_without system_crc32c
%bcond_without system_libyuv
%else
%bcond_with system_crc32c
%bcond_with system_libyuv
%endif
%if 0%{?suse_version} >= 1550 || 0%{?sle_version} >= 150400 || 0%{?fedora_version}
%bcond_without system_vpx
%else
%bcond_with system_vpx
%endif
%global pkg_name ringrtc
%global rpm_name signal-libringrtc
%define webrtc_req_version 5005b
Name: nodejs-signal-ringrtc
Version: 2.22.0
Release: 0
Summary: Video and voice calling services for Signal Messenger
License: GPL-3.0-or-later and BSD-3-Clause
Group: Development/Languages/Rust
URL: https://github.com/signalapp/ringrtc/
#
# Created with create_tarball.sh
Source0: webrtc-%{webrtc_req_version}.tar.xz
Source1: https://github.com/signalapp/%{pkg_name}/archive/v%{version}/%{pkg_name}-%{version}.tar.gz
# Created by prepare-vendor.sh
Source2: vendor.tar.xz
Source3: cargo_config
# Shim generators for unbundling libraries
Source20: absl_algorithm.gn
Source21: absl_base.gn
Source22: absl_cleanup.gn
Source23: absl_container.gn
Source24: absl_debugging.gn
Source25: absl_flags.gn
Source26: absl_functional.gn
Source27: absl_hash.gn
Source28: absl_memory.gn
Source29: absl_meta.gn
Source30: absl_numeric.gn
Source31: absl_random.gn
Source32: absl_status.gn
Source33: absl_strings.gn
Source34: absl_synchronization.gn
Source35: absl_time.gn
Source36: absl_types.gn
Source37: crc32c.gn
Source38: libyuv.gn
#
Patch1: signal-webrtc-disable-compiler-configs.patch
Patch2: signal-webrtc-disable-h264.patch
Patch3: replace_gn_files.patch
# From nodejs-electron
Patch4: abseil-remove-unused-targets.patch
Patch5: multi_channel_content_detector-missing-unique_ptr.patch
Patch6: system-nasm.patch
Patch7: nasm-generate-debuginfo.patch
Patch8: gcc-asmflags.patch
Patch9: shim_headers-fix-ninja.patch
#
BuildRequires: cargo >= 1.52.0
BuildRequires: nodejs
%if %{with system_crc32c}
BuildRequires: cmake(Crc32c)
%endif
BuildRequires: gn
BuildRequires: jq
BuildRequires: nasm
%if 0%{?suse_version}
BuildRequires: ninja
%else
BuildRequires: ninja-build
%endif
%if %{with system_abseil}
BuildRequires: pkgconfig(absl_algorithm_container) >= 20211000
BuildRequires: pkgconfig(absl_base)
BuildRequires: pkgconfig(absl_bind_front)
BuildRequires: pkgconfig(absl_bits)
BuildRequires: pkgconfig(absl_btree)
BuildRequires: pkgconfig(absl_cleanup)
BuildRequires: pkgconfig(absl_config)
BuildRequires: pkgconfig(absl_cord)
BuildRequires: pkgconfig(absl_core_headers)
BuildRequires: pkgconfig(absl_failure_signal_handler)
BuildRequires: pkgconfig(absl_fixed_array)
BuildRequires: pkgconfig(absl_flags)
BuildRequires: pkgconfig(absl_flags_parse)
BuildRequires: pkgconfig(absl_flags_usage)
BuildRequires: pkgconfig(absl_flat_hash_map)
BuildRequires: pkgconfig(absl_flat_hash_set)
BuildRequires: pkgconfig(absl_hash)
BuildRequires: pkgconfig(absl_inlined_vector)
BuildRequires: pkgconfig(absl_int128)
BuildRequires: pkgconfig(absl_memory)
BuildRequires: pkgconfig(absl_node_hash_map)
BuildRequires: pkgconfig(absl_node_hash_set)
BuildRequires: pkgconfig(absl_optional)
BuildRequires: pkgconfig(absl_random_random)
BuildRequires: pkgconfig(absl_span)
BuildRequires: pkgconfig(absl_stacktrace)
BuildRequires: pkgconfig(absl_status)
BuildRequires: pkgconfig(absl_statusor)
BuildRequires: pkgconfig(absl_strings)
BuildRequires: pkgconfig(absl_str_format)
BuildRequires: pkgconfig(absl_symbolize)
BuildRequires: pkgconfig(absl_synchronization)
BuildRequires: pkgconfig(absl_time)
BuildRequires: pkgconfig(absl_type_traits)
BuildRequires: pkgconfig(absl_variant)
%endif
BuildRequires: pkgconfig(alsa)
BuildRequires: pkgconfig(egl)
BuildRequires: pkgconfig(epoxy)
BuildRequires: pkgconfig(gbm)
BuildRequires: pkgconfig(gio-2.0)
BuildRequires: pkgconfig(gio-unix-2.0)
BuildRequires: pkgconfig(libdrm)
BuildRequires: pkgconfig(libevent)
BuildRequires: pkgconfig(libpipewire-0.3)
BuildRequires: pkgconfig(libpulse)
%if %{with system_libyuv}
BuildRequires: pkgconfig(libyuv)
%else
BuildRequires: pkgconfig(libjpeg) >= 1.5
%endif
BuildRequires: pkgconfig(opus) >= 1.3.1
%if %{with system_vpx}
BuildRequires: pkgconfig(vpx) >= 1.8.2
%else
BuildRequires: nasm
%endif
%if 0%{?fedora}
BuildRequires: libatomic
%endif
BuildRequires: protobuf-devel
BuildRequires: rust-packaging
%if 0%{?suse_version} > 1500 || 0%{?fedora_version}
BuildRequires: gcc >= 11
BuildRequires: gcc-c++ >= 11
%else
#It actually needs to be the same version as used by Rust.
BuildRequires: gcc11-PIE
BuildRequires: gcc11-c++
%endif
# Fedora thinks this is a native node module and adds an unwanted dependency on nodejs(abiXX)
%global __nodejs_native_requires %nil
%description
RingRTC is a middleware library providing Signal Messenger applications with
video and voice calling services built on top of WebRTC.
%package -n %rpm_name
Summary: Video and voice calling services for Signal Messenger
Group: System/Libraries
Provides: bundled(signal-webrtc) = %webrtc_req_version
%description -n %rpm_name
RingRTC is a middleware library providing Signal Messenger applications with
video and voice calling services built on top of WebRTC.
%prep
%setup -T -b 2 -n src
%autosetup -n webrtc-%{webrtc_req_version} -a1 -p1
# Shim generators for replace_gn_files.py
cp -lv %{_sourcedir}/*.gn build/linux/unbundle/
ln -sf %{pkg_name}-%{version}/src ringrtc
mv ../src/rust/vendor -t ringrtc/rust/
install -d -m 0755 ringrtc/rust/.cargo
cp -p %{SOURCE3} ringrtc/rust/.cargo/config
# Sanity check if we have the correct webrtc version
test $(grep ^WEBRTC_VERSION= %{pkg_name}-%{version}/config/version.sh | sed 's/.*=//') = %{webrtc_req_version}
# https://blogs.gnome.org/mcatanzaro/2020/05/18/patching-vendored-rust-dependencies/
pushd ringrtc/rust/vendor/libloading
jq -cj '.files={}' .cargo-checksum.json >tmp && mv tmp .cargo-checksum.json && popd
pushd ringrtc/rust/vendor/prost-build
jq -cj '.files={}' .cargo-checksum.json >tmp && mv tmp .cargo-checksum.json && popd
%build
export CFLAGS="%{optflags} -fpic -fno-semantic-interposition"
# Google has a bad coding style, using a macro `RTC_DCHECK_NOTREACHED()` that is not properly detected by GCC
# multiple times throughout the codebase. It is not possible to redefine the macro to __builtin_unreachable,
# as it has an astonishing syntax, behaving like an ostream (in debug builds it is supposed to trap and print an error message)
export CXXFLAGS="%{optflags} -fpic -fno-semantic-interposition -Wno-error=return-type"
export LDFLAGS="%{?build_ldflags}"
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-11
export CXX=g++-11
export AR=gcc-ar-11
export NM=gcc-nm-11
export RANLIB=gcc-ranlib-11
# some still call gcc/g++
mkdir -p "%{_builddir}/bin/"
ln -sfn %{_bindir}/$CC %{_builddir}/bin/gcc
ln -sfn %{_bindir}/$CXX %{_builddir}/bin/g++
export PATH="%{_builddir}/bin/:$PATH"
#/suse_version <= 1500
%endif
gn_system_libraries=(
libevent
libjpeg
opus
)
%if %{with system_abseil}
find third_party/abseil-cpp -type f ! -name "*.gn" -a ! -name "*.gni" -delete
gn_system_libraries+=(
absl_algorithm
absl_base
absl_cleanup
absl_container
absl_debugging
absl_flags
absl_functional
absl_hash
absl_memory
absl_meta
absl_numeric
absl_random
absl_status
absl_strings
absl_synchronization
absl_time
absl_types
)
rm third_party/abseil-cpp/absl/utility/BUILD.gn
%endif
%if %{with system_crc32c}
find third_party/crc32c -type f ! -name "*.gn" -a ! -name "*.gni" -delete
gn_system_libraries+=( crc32c )
%endif
%if %{with system_libyuv}
find third_party/libyuv -type f ! -name "*.gn" -a ! -name "*.gni" -delete
gn_system_libraries+=( libyuv )
%endif
%if %{with system_vpx}
find third_party/libvpx -type f ! -name "*.gn" -a ! -name "*.gni" -delete
gn_system_libraries+=( libvpx )
%endif
build/linux/unbundle/replace_gn_files.py --system-libraries ${gn_system_libraries[@]}
# Create the configuration for GN
# Available options: gn args --list out/Release/
myconf_gn=""
myconf_gn+=" custom_toolchain=\"//build/toolchain/linux/unbundle:default\""
myconf_gn+=" host_toolchain=\"//build/toolchain/linux/unbundle:default\""
myconf_gn+=" use_custom_libcxx=false"
myconf_gn+=" is_debug=false"
myconf_gn+=" use_gold=false"
myconf_gn+=" use_lld=false"
myconf_gn+=" use_sysroot=false"
myconf_gn+=" is_clang=false"
# see bin/build-electron in ringrtc tarball
myconf_gn+=" rtc_build_examples=false"
myconf_gn+=" rtc_build_tools=false"
myconf_gn+=" rtc_include_tests=false"
myconf_gn+=" rtc_enable_protobuf=false"
myconf_gn+=" rtc_use_x11=false"
myconf_gn+=" rtc_enable_sctp=false"
myconf_gn+=" rtc_libvpx_build_vp9=true"
myconf_gn+=" rtc_include_ilbc=false"
%ifarch %arm
#openSUSE only supports armhf
%ifarch armv7hl armv7hnl
myconf_gn+=" arm_version=7"
%endif
%ifarch armv6hl
myconf_gn+=" arm_version=6"
%endif
myconf_gn+=" arm_float_abi=\"hard\""
# Disable requirement of neon instructions
%ifarch armv7hnl armv8hnl armv8hcnl
myconf_gn+=" arm_use_neon=true"
%else
myconf_gn+=" arm_use_neon=false"
myconf_gn+=" arm_optionally_use_neon=true"
%endif
%endif #ifarch arm
myconf_gn+=" rtc_use_pipewire=true rtc_link_pipewire=true"
gn gen --args="${myconf_gn}" out/release
# Pass the libs only to the linker, otherwise linking abseil will take 5+ hours
LIBS_WRAPPED=$(gn desc out/release :webrtc libs|sed 's/^/ -Clink-arg=-l/')
ninja -v %{?_smp_mflags} -C out/release
export OUTPUT_DIR="$(pwd)/out"
%ifarch %ix86
export RUSTC_BOOTSTRAP=1
%endif
export RUSTFLAGS="%{build_rustflags} ${LIBS_WRAPPED} --verbose"
export RUSTC_LOG='rustc_codegen_ssa::back::link=info'
export CARGO_TERM_VERBOSE=true
export PROTOC=%{_bindir}/protoc
export PROTOC_INCLUDE=%{_includedir}
cd ringrtc/rust
cargo -vv build --offline --release --features electron
%install
install -pvDm755 ringrtc/rust/target/release/libringrtc.so \
%{buildroot}%{_libexecdir}/signal-desktop/node_modules/ringrtc/build/linux/libringrtc-$(echo -n 'console.log(require("node:process").arch)'|node).node
%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.
cd %{buildroot}%{_libexecdir}
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_'\'' '
%files -n %rpm_name
%defattr(-,root,root)
%license ringrtc-*/LICENSE
%doc ringrtc-*/README.md ringrtc-*/CHANGELOG.md
%{_libexecdir}/signal-desktop/
%changelog