File libtg_owt.spec of Package libtg_owt-devel
#
# spec file for package libtg_owt
#
# Copyright (c) 2025 SUSE LLC
#
# All modifications are released under the same license as the package itself.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
# NOTE: This package performs aggressive source patching to replace Abseil types
# with C++ standard library equivalents. This generates compiler warnings but
# produces a working library. See prep section for details.
#
%define __builder ninja
%define _lto_cflags %{nil}
Name: libtg_owt
Version: 0.0.0
Release: 0
Summary: WebRTC library for the Telegram messenger
License: BSD-3-Clause
URL: https://github.com/desktop-app/tg_owt
Source0: %{name}-%{version}.tar.zst
Source1: libtg_owt.rpmlintrc
BuildRequires: cmake
BuildRequires: fdupes
%if 0%{?sle_version} == 150400
BuildRequires: gcc10-c++
%else
BuildRequires: gcc-c++
%endif
BuildRequires: ninja
BuildRequires: pkgconfig
BuildRequires: perl
BuildRequires: yasm-devel
BuildRequires: alsa-devel
BuildRequires: libjpeg-devel
# PipeWire disabled due to API incompatibility (v1.2+ removal of spa_pod_get_values)
# BuildRequires: pipewire-devel
BuildRequires: pulseaudio-devel
BuildRequires: openssl-devel
BuildRequires: libopus-devel
BuildRequires: libX11-devel
BuildRequires: libXcomposite-devel
BuildRequires: libXdamage-devel
BuildRequires: libXext-devel
BuildRequires: libXfixes-devel
BuildRequires: libXrandr-devel
BuildRequires: libXrender-devel
BuildRequires: libXtst-devel
BuildRequires: protobuf-devel
BuildRequires: libvpx-devel
BuildRequires: libgbm-devel
BuildRequires: libdrm-devel
BuildRequires: libepoxy-devel
BuildRequires: abseil-cpp-devel
BuildRequires: cmake(Microsoft.GSL)
BuildRequires: libopenh264-devel
BuildRequires: libsrtp2-devel
#BuildRequires: libcrc32c-devel
BuildRequires: ffmpeg-devel
BuildRequires: ffmpeg-8
BuildRequires: ffmpeg-8-libavdevice-devel
BuildRequires: ffmpeg-8-libavfilter-devel
BuildRequires: ffmpeg-8-libavformat-devel
BuildRequires: ffmpeg-8-libavutil-devel
BuildRequires: ffmpeg-8-libswscale-devel
BuildRequires: ffmpeg-8-libswresample-devel
# Required for .tar.zst extraction
BuildRequires: zstd
Conflicts: ffmpeg-8-mini-libs
Conflicts: ffmpeg-8-mini-devel
%description
WebRTC library for the Telegram messenger. This package includes modifications
to replace Abseil library types with C++ standard library equivalents for
better compatibility with system libraries.
%package -n libtg_owt0
Summary: WebRTC library for the Telegram messenger
%description -n libtg_owt0
WebRTC library used by Telegram Desktop for voice and video calls.
%package devel
Summary: Development files for %{name}
Requires: libtg_owt0 = %{version}-%{release}
Requires: alsa-devel
Requires: libepoxy-devel
Requires: libgbm-devel
Requires: ffmpeg-devel
Requires: ffmpeg-8
Requires: libdrm-devel
Requires: libjpeg-devel
# Requires: pipewire-devel
Requires: pulseaudio-devel
Requires: openssl-devel
Requires: libopus-devel
Requires: libvpx-devel
Requires: libX11-devel
Requires: libXcomposite-devel
Requires: libXdamage-devel
Requires: libXext-devel
Requires: libXfixes-devel
Requires: libXrandr-devel
Requires: libXrender-devel
Requires: libXtst-devel
%description devel
Development files and headers for libtg_owt.
%prep
%autosetup -p1
# ============================================================================
# AUTOMATED SOURCE PATCHING: Abseil → C++ Standard Library
# ============================================================================
echo "=== Abseil → std:: Type Replacement ==="
# 1. Remove Abseil nullability annotations
echo "=== Removing Abseil nullability annotations ==="
find . -type f \( -name "*.h" -o -name "*.cc" -o -name "*.cpp" \) -print0 | \
xargs -0 perl -pi -e 's/absl::(?:Nonnull|Nullable)<(.+?)>/\1/g'
# Remove the include for the header we just stripped usage of
find . -type f \( -name "*.h" -o -name "*.cc" -o -name "*.cpp" \) -exec \
sed -i '/#include.*absl\/base\/nullability\.h/d' {} + 2>/dev/null || true
# 2. Replace Abseil types with std:: equivalents
echo "=== Replacing Abseil types ==="
find . -type f \( -name "*.h" -o -name "*.cc" -o -name "*.cpp" \) -exec \
sed -i \
-e 's/\babsl::optional\b/std::optional/g' \
-e 's/\babsl::make_optional\b/std::make_optional/g' \
-e 's/\babsl::nullopt\b/std::nullopt/g' \
-e 's/\babsl::string_view\b/std::string_view/g' \
-e 's/\babsl::Span\b/std::span/g' \
-e 's/\.get_value_or(/.value_or(/g' \
{} + 2>/dev/null || true
# 3. Update include headers
echo "=== Updating include headers ==="
find . -type f \( -name "*.h" -o -name "*.cc" -o -name "*.cpp" \) -exec \
sed -i \
-e 's|#include [<"]absl/types/optional.h[>"]|#include <optional>|g' \
-e 's|#include [<"]absl/strings/string_view.h[>"]|#include <string_view>|g' \
-e 's|#include [<"]absl/types/span.h[>"]|#include <span>|g' \
{} + 2>/dev/null || true
# 4. Comprehensive <cstring> Injection (GCC 15 Fix)
echo "=== Adding <cstring> includes ==="
# Phase 1: Explicitly fix known problematic files.
for file in \
src/api/video/nv12_buffer.cc \
src/modules/video_coding/utility/ivf_file_reader.cc \
src/modules/video_capture/linux/video_capture_pipewire.cc \
src/rtc_base/string_utils.cc \
src/net/dcsctp/packet/bounded_byte_writer.h
do
if [ -f "$file" ]; then
sed -i '1i#include <cstring>' "$file"
echo " ✓ Explicitly patched: $file"
fi
done
# Phase 2: Safety Net (Auto-patching)
find . -type f \( -name "*.cc" -o -name "*.cpp" \) -print0 | \
xargs -0 grep -l -E '\b(mem(cpy|move|set|cmp)|str(len|cmp|ncmp))\b' 2>/dev/null | \
while read file; do
if ! grep -qE '#include <(cstring|string\.h)>' "$file"; then
sed -i '1i#include <cstring>' "$file"
echo " ✓ Auto-patched: ${file#./}"
fi
done
# 5. Final Verification
echo "=== Final Verification ==="
# Check for critical GCC 15 fix
if ! grep -q '#include <cstring>' src/api/video/nv12_buffer.cc; then
echo "❌ ERROR: src/api/video/nv12_buffer.cc was NOT patched!"
exit 1
fi
# Check for Abseil nullability in actual code (not comments)
nonnull_in_code=$(grep -r "absl::Nonnull" . --include="*.h" --include="*.cc" --include="*.cpp" 2>/dev/null | \
grep -v -E '^\s*//|^\s*/\*|^\s*\*' | grep -v "Compatibility shim" || true)
if [ -n "$nonnull_in_code" ]; then
echo "⚠️ WARNING: absl::Nonnull found in non-comment code:"
echo "$nonnull_in_code" | head -n 3
echo " (If these are only in string literals, this is acceptable)"
else
echo "✓ No absl::Nonnull found in active code."
fi
echo "✓ Source preparation complete. Ready to build."
%build
%if 0%{?sle_version} == 150400
export LDFLAGS="%{optflags} -std=gnu++17"
export CC=gcc-10
export CXX=g++-10
%endif
export CXXFLAGS="%{optflags} -Wno-maybe-uninitialized -Wno-unknown-pragmas -Wno-format-truncation"
%cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON \
-DBUILD_SHARED_LIBS:BOOL=ON \
-DTG_OWT_USE_PROTOBUF:BOOL=OFF \
-DTG_OWT_USE_X11:BOOL=ON \
-DTG_OWT_USE_PIPEWIRE:BOOL=OFF \
-DTG_OWT_PACKAGED_BUILD:BOOL=OFF \
%if 0%{?sle_version} == 150400
-DCMAKE_CXX_STANDARD=17 \
%endif
-G Ninja
%cmake_build
%install
%cmake_install
%fdupes %{buildroot}/%{_prefix}
# Manually handle library versioning
pushd %{buildroot}%{_libdir}
# 1. Copy the actual binary content to a temp file (resolving any symlinks)
cp -L libtg_owt.so libtg_owt.so.0.0.1.tmp
# 2. Delete existing variations to clear the board
# FIX: Do NOT include libtg_owt.so.0.0.1.tmp in this list!
rm -f libtg_owt.so libtg_owt.so.0 libtg_owt.so.0.0.0
# 3. Rename the temp file to the final versioned name
mv libtg_owt.so.0.0.1.tmp libtg_owt.so.0.0.1
# 4. Create fresh symbolic links pointing to the real file
ln -s libtg_owt.so.0.0.1 libtg_owt.so.0
ln -s libtg_owt.so.0.0.1 libtg_owt.so
popd
%post -n libtg_owt0 -p /sbin/ldconfig
%postun -n libtg_owt0 -p /sbin/ldconfig
%files -n libtg_owt0
%license LICENSE
%{_libdir}/libtg_owt.so.0
%{_libdir}/libtg_owt.so.0.0.1
%files devel
%{_includedir}/tg_owt/
%{_libdir}/libtg_owt.so
%{_libdir}/cmake/tg_owt/
%changelog