diff --git a/eclass/patches.eclass b/eclass/patches.eclass new file mode 100644 index 00000000..69cb7e98 --- /dev/null +++ b/eclass/patches.eclass @@ -0,0 +1,68 @@ +# Copyright 1999-2022 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: patches.eclass +# @MAINTAINER: +# mva +# @AUTHOR: +# mva +# @BLURB: autopatching magic (pretty useful for me, but criticized for obscurity and looks like not suitable for gentoo repo) +# @DESCRIPTION: +# Eclass that checks for patches directories existance and auto-add them into PATCHES=() + +EXPORT_FUNCTIONS src_prepare + + +patches_src_prepare() { + [[ -z ${PATCHES[@]} ]] && PATCHES=() + PATCHDIR_BASE="${FILESDIR}/patches" + PATCHDIRS=("${CUSTOM_PATCHDIR:-non-existant-dir}" "${SLOT//\/*}" "${PV}" "${PV}-${PR}") + for PATCHDIR in ${PATCHDIRS[@]/#/${PATCHDIR_BASE}/}; do + if [[ -d "${PATCHDIR}" ]]; then + _patchdir_not_empty() { + local has_files + local LC_ALL=POSIX + local prev_shopt=$(shopt -p nullglob) + shopt -s nullglob + local f + local lvl=${2} + for f in "${1:-${PATCHDIR}}"/*; do + if [[ "${f}" == *.diff || "${f}" == *.patch ]] && [[ -f "${f}" || -L "${f}" ]]; then + has_files=1 + elif [[ -d "${f}" ]] && [[ "${lvl:-0}" -eq 0 ]]; then + # limit recursion to first level only, + # since eapply cannot into recursion, + # while 2-lvl "conditional" patching implemented below + let lvl+=1 + _patchdir_not_empty "${f}" "${lvl}" && has_files=1 + fi + done + ${prev_shopt} + [[ -n "${has_files}" ]]; return $? + } + + _patchdir_not_empty && PATCHES+=("${PATCHDIR}") + + if [[ -d "${PATCHDIR}/conditional" ]]; then + pushd "${PATCHDIR}/conditional" &>/dev/null + for d in *; do + if [[ -d ${d} ]]; then + if [[ "${d##no-}" == ${d} ]]; then + (use "${d}" && _patchdir_not_empty "${d}") && PATCHES+=("${PATCHDIR}/conditional/${d}") + else + (use "${d##no-}" && _patchdir_not_empty "${d}") || PATCHES+=("${PATCHDIR}/conditional/${d}") + fi + fi + done + popd &>/dev/null + fi + fi + done + if declare -f cmake-utils_src_prepare &>/dev/null; then + cmake-utils_src_prepare + elif declare -f cmake_src_prepare &>/dev/null; then + cmake_src_prepare + else + default_src_prepare + fi +} diff --git a/media-libs/libtgvoip/Manifest b/media-libs/libtgvoip/Manifest new file mode 100644 index 00000000..00bfa6f5 --- /dev/null +++ b/media-libs/libtgvoip/Manifest @@ -0,0 +1 @@ +DIST libtgvoip-2.4.5_pre20231016.tar.gz 1089860 BLAKE2B b472ed42fb089d136ec00aec55a3869acb2f5eac219747c75a6643aa4ff3715924af3379e846cdb4962bb72b69007422ca9063ba457d3c8fdb6f03ce41fec981 SHA512 6e9bc8b229622ac2d7fd5bd60f48a1709a3914b8c610a0257471a39bef613a4302d15d1eb32fcd6e13f99b22e3d82e78c9e7f91a5bccb1c84641be965c72f646 diff --git a/media-libs/libtgvoip/files/cmake/libtgvoip.cmake b/media-libs/libtgvoip/files/cmake/libtgvoip.cmake new file mode 100644 index 00000000..f1a7e90a --- /dev/null +++ b/media-libs/libtgvoip/files/cmake/libtgvoip.cmake @@ -0,0 +1,94 @@ +cmake_minimum_required(VERSION 3.14) +project(tgvoip) + +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +option(ENABLE_ALSA "Enable ALSA" ON) +option(ENABLE_PULSEAUDIO "Enable pulseaudio" ON) +option(BUILD_STATIC_LIBRARY "Build static library" OFF) +option(BUILD_SHARED_LIBRARY "Build static library" ON) + +file(GLOB TGVOIP_SOURCE_FILES + *.cpp + audio/*.cpp + os/linux/*.cpp + os/posix/*.cpp + video/*.cpp +) + +if(BUILD_SHARED_LIBRARY OR BUILD_STATIC_LIBRARY) + find_package(tg_owt REQUIRED) + find_package(PkgConfig REQUIRED) + pkg_check_modules(OPUS REQUIRED opus) + set(TGVOIP_COMPILE_DEFINITIONS TGVOIP_USE_DESKTOP_DSP WEBRTC_NS_FLOAT WEBRTC_POSIX WEBRTC_LINUX INSTALL_TARGETS) + + if(ENABLE_ALSA) + pkg_check_modules(ALSA REQUIRED alsa) + else() + file(GLOB ALSA_SOURCE_FILES + os/linux/AudioInputALSA.cpp + os/linux/AudioOutputALSA.cpp + ) + list(REMOVE_ITEM TGVOIP_SOURCE_FILES ${ALSA_SOURCE_FILES}) + list(APPEND TGVOIP_COMPILE_DEFINITIONS WITHOUT_ALSA) + endif() + + if(ENABLE_PULSEAUDIO) + pkg_check_modules(LIBPULSE REQUIRED libpulse) + else() + file(GLOB PULSEAUDIO_SOURCE_FILES + os/linux/AudioInputPulse.cpp + os/linux/AudioOutputPulse.cpp + os/linux/AudioPulse.cpp + ) + list(REMOVE_ITEM TGVOIP_SOURCE_FILES ${PULSEAUDIO_SOURCE_FILES}) + list(APPEND TGVOIP_COMPILE_DEFINITIONS WITHOUT_PULSE) + endif() + + get_target_property(OWT_INCLUDE_DIRS tg_owt::tg_owt INTERFACE_INCLUDE_DIRECTORIES) + + add_library(${PROJECT_NAME} OBJECT ${TGVOIP_SOURCE_FILES}) + list(APPEND INSTALL_TARGETS ${PROJECT_NAME}) + target_compile_definitions(${PROJECT_NAME} PUBLIC ${TGVOIP_COMPILE_DEFINITIONS}) + target_include_directories(${PROJECT_NAME} PUBLIC + "${OPUS_INCLUDE_DIRS}" +# "${CMAKE_CURRENT_LIST_DIR}/webrtc_dsp" + "${CMAKE_CURRENT_LIST_DIR}/audio" + "${CMAKE_CURRENT_LIST_DIR}/video" + "${OWT_INCLUDE_DIRS}" + ) + set(LIBTGVOIP_VERSION 2.4.4) + set(prefix "${CMAKE_INSTALL_PREFIX}") + set(exec_prefix "${CMAKE_INSTALL_PREFIX}") + set(libdir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") + set(includedir "${CMAKE_INSTALL_PREFIX}/include") + configure_file(tgvoip.pc.in tgvoip.pc @ONLY) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tgvoip.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + + set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER TgVoip.h) +# install(TARGETS ${PROJECT_NAME} PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/tgvoip") +endif(BUILD_SHARED_LIBRARY OR BUILD_STATIC_LIBRARY) + +if(BUILD_SHARED_LIBRARY) + add_library(${PROJECT_NAME}_shared SHARED $) + target_compile_definitions(${PROJECT_NAME}_shared PUBLIC ${TGVOIP_COMPILE_DEFINITIONS}) + set_target_properties(${PROJECT_NAME}_shared PROPERTIES OUTPUT_NAME ${PROJECT_NAME}) + set_target_properties(${PROJECT_NAME}_shared PROPERTIES SOVERSION 2 VERSION ${LIBTGVOIP_VERSION}) + target_link_libraries(${PROJECT_NAME}_shared dl ${OPUS_LIBRARIES} tg_owt) + list(APPEND INSTALL_TARGETS ${PROJECT_NAME}_shared) +endif(BUILD_SHARED_LIBRARY) + +if(BUILD_STATIC_LIBRARY) + add_library(${PROJECT_NAME}_static STATIC $) + target_compile_definitions(${PROJECT_NAME}_static PUBLIC ${TGVOIP_COMPILE_DEFINITIONS}) + set_target_properties(${PROJECT_NAME}_static PROPERTIES OUTPUT_NAME ${PROJECT_NAME}) + target_link_libraries(${PROJECT_NAME}_static dl ${OPUS_LIBRARIES} tg_owt) + list(APPEND INSTALL_TARGETS ${PROJECT_NAME}_static) +endif(BUILD_STATIC_LIBRARY) + +install(TARGETS ${INSTALL_TARGETS} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +install(DIRECTORY ${CMAKE_SOURCE_DIR}/ DESTINATION include/${PROJECT_NAME} FILES_MATCHING PATTERN "*.h*" PATTERN "webrtc_dsp/*" EXCLUDE PATTERN ".git*" EXCLUDE) diff --git a/media-libs/libtgvoip/libtgvoip-2.4.5_pre20231016.ebuild b/media-libs/libtgvoip/libtgvoip-2.4.5_pre20231016.ebuild new file mode 100644 index 00000000..29fb1861 --- /dev/null +++ b/media-libs/libtgvoip/libtgvoip-2.4.5_pre20231016.ebuild @@ -0,0 +1,100 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit autotools flag-o-matic patches +# cmake + +if [[ "${PV}" == 9999 ]]; then + EGIT_SUBMODULES=(-cmake) + EGIT_REPO_URI="https://github.com/telegramdesktop/${PN}" + inherit git-r3 +else + if [[ "${PV}" == *_pre* ]]; then + EGIT_COMMIT="06983098037603a4b2e5f7a8ba665da32857a631" + fi + MY_PV="${EGIT_COMMIT:-${PV}}" + SRC_URI="https://github.com/telegramdesktop/${PN}/archive/${MY_PV}.tar.gz -> ${P}.tar.gz" + KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~riscv ~x86" + # ~mips + # ^ pulseaudio + S="${WORKDIR}/${PN}-${MY_PV}" +fi + +DESCRIPTION="VoIP library for Telegram clients" +HOMEPAGE="https://github.com/telegramdesktop/libtgvoip" + +LICENSE="Unlicense" +SLOT="0" +IUSE="+alsa +dsp pulseaudio pipewire static-libs" +REQUIRED_USE="|| ( dsp alsa pulseaudio pipewire )" + +RDEPEND=" + alsa? ( media-libs/alsa-lib ) + dsp? ( + dev-cpp/abseil-cpp:= + >=media-libs/tg_owt-0_pre20230401:= + ) + dev-libs/openssl:= + media-libs/opus + pulseaudio? ( !pipewire? ( media-sound/pulseaudio-daemon ) ) + pipewire? ( + !media-sound/pulseaudio-daemon + media-video/pipewire[sound-server(-)] + ) +" +DEPEND="${RDEPEND}" +BDEPEND="virtual/pkgconfig" + +src_prepare() { + # cp "${FILESDIR}"/cmake/"${PN}".cmake "${S}"/CMakeLists.txt + rm -rf "${S}"/webrtc_dsp # we'll link over tg_owt instead + # Will be controlled by us + sed -i -e '/^CFLAGS += -DTGVOIP_NO_DSP/d' Makefile.am || die + # https://bugs.gentoo.org/717210 + echo 'libtgvoip_la_LIBTOOLFLAGS = --tag=CXX' >> Makefile.am || die + # default + patches_src_prepare + eautoreconf +} + +# src_configure() { +# filter-flags '-DDEBUG' # produces bugs in bundled forks of 3party code +# append-cppflags '-DNDEBUG' # Telegram sets that in code +# # (and I also forced that in ebuild to have the same behaviour), +# # and segfaults on voice calls on mismatch +# # (if tg was built with it, and deps are built without it, and vice versa) +# local mycmakeargs=( +# #-DDESKTOP_APP_USE_PACKAGED=TRUE +# #-DDESKTOP_APP_DISABLE_CRASH_REPORTS=TRUE +# -DBUILD_STATIC_LIBRARY=$(usex static-libs ON OFF) +# -DENABLE_ALSA=$(usex alsa ON OFF) +# -DENABLE_PULSEAUDIO=$(usex pulseaudio ON $(usex pipewire ON OFF)) +# ) +# cmake_src_configure +# } + +src_configure() { + # Not using the CMake build despite being the preferred one, because + # it's lacking relevant configure options. + local myconf=( + --disable-dsp # WebRTC is linked from tg_owt + $(use_with alsa) + $(use_with pulseaudio pulse) + $(use_with pipewire pulse) + ) + if use dsp; then + append-cppflags "-I${ESYSROOT}/usr/include/tg_owt" + # append-cppflags "-I${ESYSROOT}/usr/include/tg_owt/third_party/abseil-cpp" + append-libs '-ltg_owt' + else + append-cppflags '-DTGVOIP_NO_DSP' + fi + econf "${myconf[@]}" +} + +src_install() { + default + find "${D}" -name '*.la' -delete || die +} diff --git a/media-libs/libtgvoip/libtgvoip-9999.ebuild b/media-libs/libtgvoip/libtgvoip-9999.ebuild new file mode 100644 index 00000000..29fb1861 --- /dev/null +++ b/media-libs/libtgvoip/libtgvoip-9999.ebuild @@ -0,0 +1,100 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit autotools flag-o-matic patches +# cmake + +if [[ "${PV}" == 9999 ]]; then + EGIT_SUBMODULES=(-cmake) + EGIT_REPO_URI="https://github.com/telegramdesktop/${PN}" + inherit git-r3 +else + if [[ "${PV}" == *_pre* ]]; then + EGIT_COMMIT="06983098037603a4b2e5f7a8ba665da32857a631" + fi + MY_PV="${EGIT_COMMIT:-${PV}}" + SRC_URI="https://github.com/telegramdesktop/${PN}/archive/${MY_PV}.tar.gz -> ${P}.tar.gz" + KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~riscv ~x86" + # ~mips + # ^ pulseaudio + S="${WORKDIR}/${PN}-${MY_PV}" +fi + +DESCRIPTION="VoIP library for Telegram clients" +HOMEPAGE="https://github.com/telegramdesktop/libtgvoip" + +LICENSE="Unlicense" +SLOT="0" +IUSE="+alsa +dsp pulseaudio pipewire static-libs" +REQUIRED_USE="|| ( dsp alsa pulseaudio pipewire )" + +RDEPEND=" + alsa? ( media-libs/alsa-lib ) + dsp? ( + dev-cpp/abseil-cpp:= + >=media-libs/tg_owt-0_pre20230401:= + ) + dev-libs/openssl:= + media-libs/opus + pulseaudio? ( !pipewire? ( media-sound/pulseaudio-daemon ) ) + pipewire? ( + !media-sound/pulseaudio-daemon + media-video/pipewire[sound-server(-)] + ) +" +DEPEND="${RDEPEND}" +BDEPEND="virtual/pkgconfig" + +src_prepare() { + # cp "${FILESDIR}"/cmake/"${PN}".cmake "${S}"/CMakeLists.txt + rm -rf "${S}"/webrtc_dsp # we'll link over tg_owt instead + # Will be controlled by us + sed -i -e '/^CFLAGS += -DTGVOIP_NO_DSP/d' Makefile.am || die + # https://bugs.gentoo.org/717210 + echo 'libtgvoip_la_LIBTOOLFLAGS = --tag=CXX' >> Makefile.am || die + # default + patches_src_prepare + eautoreconf +} + +# src_configure() { +# filter-flags '-DDEBUG' # produces bugs in bundled forks of 3party code +# append-cppflags '-DNDEBUG' # Telegram sets that in code +# # (and I also forced that in ebuild to have the same behaviour), +# # and segfaults on voice calls on mismatch +# # (if tg was built with it, and deps are built without it, and vice versa) +# local mycmakeargs=( +# #-DDESKTOP_APP_USE_PACKAGED=TRUE +# #-DDESKTOP_APP_DISABLE_CRASH_REPORTS=TRUE +# -DBUILD_STATIC_LIBRARY=$(usex static-libs ON OFF) +# -DENABLE_ALSA=$(usex alsa ON OFF) +# -DENABLE_PULSEAUDIO=$(usex pulseaudio ON $(usex pipewire ON OFF)) +# ) +# cmake_src_configure +# } + +src_configure() { + # Not using the CMake build despite being the preferred one, because + # it's lacking relevant configure options. + local myconf=( + --disable-dsp # WebRTC is linked from tg_owt + $(use_with alsa) + $(use_with pulseaudio pulse) + $(use_with pipewire pulse) + ) + if use dsp; then + append-cppflags "-I${ESYSROOT}/usr/include/tg_owt" + # append-cppflags "-I${ESYSROOT}/usr/include/tg_owt/third_party/abseil-cpp" + append-libs '-ltg_owt' + else + append-cppflags '-DTGVOIP_NO_DSP' + fi + econf "${myconf[@]}" +} + +src_install() { + default + find "${D}" -name '*.la' -delete || die +} diff --git a/media-libs/libtgvoip/metadata.xml b/media-libs/libtgvoip/metadata.xml new file mode 100644 index 00000000..f53d39ee --- /dev/null +++ b/media-libs/libtgvoip/metadata.xml @@ -0,0 +1,21 @@ + + + + + mva@gentoo.org + Also, you can find me on IRC (Libera.Chat) as mva, or in Telegram as @mva_name + Vadim A. Misbakh-Soloviov + + + Enable ALSA support + Enable signal processing (echo cancellation, noise suppression, and automatic gain control) + Enable PulseAudio support + Enable PipeWire support (actually, only force needed dependencies) + + Build static library + + + grishka/libtgvoip + https://github.com/grishka/libtgvoip/issues + + diff --git a/media-libs/tg_owt/Manifest b/media-libs/tg_owt/Manifest new file mode 100644 index 00000000..5633f826 --- /dev/null +++ b/media-libs/tg_owt/Manifest @@ -0,0 +1,3 @@ +DIST libsrtp-f53df50059906e5c364eca65bd3c847cac9ef192.tar.gz 638464 BLAKE2B e876d606a73a9da226806fb14f6a53ba9339a4738c4785494144d835717fe76e37b585cd6168e98f0929faee262c8d26c021c333397712bf7bdc587e812fb8f1 SHA512 8713f84cc470540f4ccd3826d9da3460ab2ce0b81dfecc9b2d7be20a498ce945759b5f869ba722fbffdbcc68af38fddbd44342fc700f0c6b3dd05b18283fb868 +DIST libyuv-914624f0b8b92986ef385e9650ee7b5fb07099e9.tar.bz2 427558 BLAKE2B d1c87228de1120a883c4c06bdfbd809190a60862a3f8923513fbd057a28859a25882db109a1ff8e2c1ac584cb40a4c9c7d253c858c236d589019b849a78f7a8c SHA512 7596a33d2d6f94dca077929ba433d13a5e663eee01f63a9cfa8b8881d3270b7488cce8d40046429db3acf8ba3a89e58baba30f692ceb2088933a4beffc6a192e +DIST tg_owt-0_pre20231221.tar.gz 13725943 BLAKE2B cd1fd52353cbbcad0ff8bd566394ce4238ecd1714ba30b1d8b275956c29ffe87f228b78048a4ec56faad63c802150635e5c71ae09c01f8673827a67ec3a593c8 SHA512 1a11d880a209eb82f702da8bc5ccb677042e7864065c442d9e1fd0ee60fe48ac911d5421e579273fbee9a0ce4437000e3c230a9f2cb2236dceff4750c28a4dc9 diff --git a/media-libs/tg_owt/metadata.xml b/media-libs/tg_owt/metadata.xml new file mode 100644 index 00000000..4dd0b956 --- /dev/null +++ b/media-libs/tg_owt/metadata.xml @@ -0,0 +1,15 @@ + + + + + esteve.varela@gmail.com + Esteve Varela Colominas + + + proxy-maint@gentoo.org + Proxy Maintainers + + + desktop-app/tg_owt + + diff --git a/media-libs/tg_owt/tg_owt-0_pre20231221.ebuild b/media-libs/tg_owt/tg_owt-0_pre20231221.ebuild new file mode 100644 index 00000000..b737feee --- /dev/null +++ b/media-libs/tg_owt/tg_owt-0_pre20231221.ebuild @@ -0,0 +1,129 @@ +# Copyright 2020-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit cmake flag-o-matic + +DESCRIPTION="WebRTC build for Telegram" +HOMEPAGE="https://github.com/desktop-app/tg_owt" + +TG_OWT_COMMIT="afd9d5d31798d3eacf9ed6c30601e91d0f1e4d60" +LIBYUV_COMMIT="914624f0b8b92986ef385e9650ee7b5fb07099e9" +LIBSRTP_COMMIT="f53df50059906e5c364eca65bd3c847cac9ef192" +SRC_URI="https://github.com/desktop-app/tg_owt/archive/${TG_OWT_COMMIT}.tar.gz -> ${P}.tar.gz + https://gitlab.com/chromiumsrc/libyuv/-/archive/${LIBYUV_COMMIT}/libyuv-${LIBYUV_COMMIT}.tar.bz2 + https://github.com/cisco/libsrtp/archive/${LIBSRTP_COMMIT}.tar.gz -> libsrtp-${LIBSRTP_COMMIT}.tar.gz" +S="${WORKDIR}/${PN}-${TG_OWT_COMMIT}" +# Upstream libyuv: https://chromium.googlesource.com/libyuv/libyuv + +LICENSE="BSD" +SLOT="0/${PV##*pre}" +KEYWORDS="~amd64 ~arm64 ~loong ~ppc64 ~riscv" +IUSE="screencast +X" + +# This package's USE flags may change the ABI and require a rebuild of +# dependent pacakges. As such, one should make sure to depend on +# media-libs/tg_owt[x=,y=,z=] for any package that uses this. +# Furthermore, the -DNDEBUG preprocessor flag should be defined by any +# dependent package, failure to do so will change the ABI in the header files. + +# Bundled libs: +# - libyuv (no stable versioning, www-client/chromium and media-libs/libvpx bundle it) +# - libsrtp (project uses private APIs) +# - pffft (no stable versioning, patched) +RDEPEND=" + >=dev-cpp/abseil-cpp-20220623.1:= + dev-libs/openssl:= + dev-libs/protobuf:= + media-libs/libjpeg-turbo:= + >=media-libs/libvpx-1.10.0:= + media-libs/openh264:= + media-libs/opus + media-video/ffmpeg:= + dev-libs/crc32c + screencast? ( + dev-libs/glib:2 + media-video/pipewire:= + ) + X? ( + x11-libs/libX11 + x11-libs/libXcomposite + x11-libs/libXdamage + x11-libs/libXext + x11-libs/libXfixes + x11-libs/libXrender + x11-libs/libXrandr + x11-libs/libXtst + ) +" +DEPEND="${RDEPEND} + screencast? ( + media-libs/libglvnd + media-libs/mesa + x11-libs/libdrm + ) +" +BDEPEND=" + virtual/pkgconfig + X? ( x11-base/xorg-proto ) +" + +src_unpack() { + unpack "${P}.tar.gz" + unpack "libyuv-${LIBYUV_COMMIT}.tar.bz2" + mv -T "libyuv-${LIBYUV_COMMIT}" "${S}/src/third_party/libyuv" || die + unpack "libsrtp-${LIBSRTP_COMMIT}.tar.gz" + mv -T "libsrtp-${LIBSRTP_COMMIT}" "${S}/src/third_party/libsrtp" || die +} + +src_prepare() { + # libopenh264 has GENERATED files with yasm that aren't excluded by + # EXCLUDE_FROM_ALL, and I have no clue how to avoid this. + # These source files aren't used with system-openh264, anyway. + sed -i '/include(cmake\/libopenh264.cmake)/d' CMakeLists.txt || die + + # The sources for these aren't available, avoid needing them + sed -e '/include(cmake\/libcrc32c.cmake)/d' \ + -e '/include(cmake\/libabsl.cmake)/d' -i CMakeLists.txt || die + + # "lol" said the scorpion, "lmao" + sed -i '/if (BUILD_SHARED_LIBS)/{n;n;s/WARNING/DEBUG/}' CMakeLists.txt || die + + cmake_src_prepare +} + +src_configure() { + # Defined by -DCMAKE_BUILD_TYPE=Release, avoids crashes + # See https://bugs.gentoo.org/754012 + # EAPI 8 still wipes this flag. + append-cppflags '-DNDEBUG' + + local mycmakeargs=( + -DTG_OWT_USE_X11=$(usex X) + -DTG_OWT_USE_PIPEWIRE=$(usex screencast) + ) + cmake_src_configure +} + +src_install() { + cmake_src_install + + # Save about 15MB of useless headers + rm -r "${ED}/usr/include/tg_owt/rtc_base/third_party" || die + rm -r "${ED}/usr/include/tg_owt/common_audio/third_party" || die + rm -r "${ED}/usr/include/tg_owt/modules/third_party" || die + rm -r "${ED}/usr/include/tg_owt/third_party" || die + + # Install a few headers anyway, as required by net-im/telegram-desktop... + local headers=( + third_party/libyuv/include + rtc_base/third_party/sigslot + rtc_base/third_party/base64 + ) + for dir in "${headers[@]}"; do + pushd "${S}/src/${dir}" > /dev/null || die + find -type f -name "*.h" -exec install -Dm644 '{}' "${ED}/usr/include/tg_owt/${dir}/{}" \; || die + popd > /dev/null || die + done +} diff --git a/net-im/telegram-desktop/Manifest b/net-im/telegram-desktop/Manifest index 8e89b170..7dfc62f3 100644 --- a/net-im/telegram-desktop/Manifest +++ b/net-im/telegram-desktop/Manifest @@ -1 +1 @@ -DIST tdesktop-3.6.1-full.tar.gz 41226549 SHA256 1e87df0970b135d566f5af4bc6c2695fc98ba387dc1137100a478f02d48c12e8 SHA512 dd216c720ea3b1c72669805bb31319746a7ddfe746d188bf2ae0c5cdf0a10b379fc2e888a26fe755d77381fc5d9aa638cedc76b2dce1f1126a9c1ef9c02da2ba WHIRLPOOL 9cbf5c46bc937793ab37d7ccf93ab391aee2b3fb06ce7b07c1767af126875db5489a6f8aa6897281f71d44d71f08c7e6cd2ec1a24d4be673ca7e188bb6ef8030 +DIST tdesktop-4.14.15-full.tar.gz 68147116 SHA256 969b7e4d22229717ea7b210e3c429f25fd5d06ec61ef3030f993e8f912c1ebe6 SHA512 12812fa1fd067fca03b2e5cb04502ef05e98368b91a4ed5458a61a0bea8b3d6daf6c32b7632c170fe0904acb63eb422f6fa6364e4af18f73e49659e2d50f531b WHIRLPOOL fdb60f373c779e08b3f14f07b56a92fbaf92585bbec3d361baf3bbf52987765784808ac85c051db7fe12256884f315b6e34fbe8884388f47b6a377f7c23531fb diff --git a/net-im/telegram-desktop/files/tdesktop-3.3.0-fix-enchant.patch b/net-im/telegram-desktop/files/tdesktop-3.3.0-fix-enchant.patch deleted file mode 100644 index 35781fda..00000000 --- a/net-im/telegram-desktop/files/tdesktop-3.3.0-fix-enchant.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- tdesktop-3.3.0-full.orig/Telegram/lib_spellcheck/spellcheck/platform/linux/spellcheck_linux.cpp -+++ tdesktop-3.3.0-full/Telegram/lib_spellcheck/spellcheck/platform/linux/spellcheck_linux.cpp -@@ -34,7 +34,7 @@ - auto IsHebrew(const QString &word) { - // Words with mixed scripts will be automatically ignored, - // so this check should be fine. -- return ::Spellchecker::WordScript(&word) == QChar::Script_Hebrew; -+ return ::Spellchecker::WordScript(word) == QChar::Script_Hebrew; - } - - class EnchantSpellChecker { -@@ -154,7 +154,7 @@ - } - - auto EnchantSpellChecker::findSuggestions(const QString &word) { -- const auto wordScript = ::Spellchecker::WordScript(&word); -+ const auto wordScript = ::Spellchecker::WordScript(word); - auto w = word.toStdString(); - std::vector result; - if (!_validators.size()) { diff --git a/net-im/telegram-desktop/files/tdesktop-3.5.2-musl.patch b/net-im/telegram-desktop/files/tdesktop-3.5.2-musl.patch deleted file mode 100644 index 4c34d107..00000000 --- a/net-im/telegram-desktop/files/tdesktop-3.5.2-musl.patch +++ /dev/null @@ -1,33 +0,0 @@ -Stub out some glibc-specific functions - -This allows support for alternative libcs like musl - ---- tdesktop-3.5.2-full.orig/Telegram/lib_base/base/platform/linux/base_info_linux.cpp -+++ tdesktop-3.5.2-full/Telegram/lib_base/base/platform/linux/base_info_linux.cpp -@@ -22,7 +22,7 @@ - - #include - --#ifdef Q_OS_LINUX -+#if defined(Q_OS_LINUX) && defined(__GLIBC__) - #include - #endif // Q_OS_LINUX - -@@ -200,7 +200,7 @@ - } - - QString GetLibcName() { --#ifdef Q_OS_LINUX -+#if defined(Q_OS_LINUX) && defined(__GLIBC__) - return "glibc"; - #endif // Q_OS_LINUX - -@@ -208,7 +208,7 @@ - } - - QString GetLibcVersion() { --#ifdef Q_OS_LINUX -+#if defined(Q_OS_LINUX) && defined(__GLIBC__) - static const auto result = [&] { - const auto version = QString::fromLatin1(gnu_get_libc_version()); - return QVersionNumber::fromString(version).isNull() ? QString() : version; diff --git a/net-im/telegram-desktop/files/tdesktop-3.6.0-jemalloc-only-telegram.patch b/net-im/telegram-desktop/files/tdesktop-3.6.0-jemalloc-only-telegram.patch deleted file mode 100644 index 6836e693..00000000 --- a/net-im/telegram-desktop/files/tdesktop-3.6.0-jemalloc-only-telegram.patch +++ /dev/null @@ -1,41 +0,0 @@ -Only link jemalloc for the Telegram binary - -Some combination of factors is making the different codegen tools hang when -jemalloc is linked for those, and they're ran under portage's sandbox. Since -this is only used during build-time, and jemalloc is merely necessary to -improve runtime memory use, it's unnecessary to use it for anything else. - ---- tdesktop-3.6.0-full.orig/Telegram/CMakeLists.txt -+++ tdesktop-3.6.0-full/Telegram/CMakeLists.txt -@@ -1376,6 +1376,14 @@ - desktop-app::external_kwayland - ) - endif() -+ -+ if (NOT DESKTOP_APP_DISABLE_JEMALLOC) -+ target_link_libraries(Telegram -+ INTERFACE -+ $ -+ $ -+ ) -+ endif() - endif() - - if (build_macstore) ---- tdesktop-3.6.0-full.orig/cmake/options_linux.cmake -+++ tdesktop-3.6.0-full/cmake/options_linux.cmake -@@ -62,14 +62,6 @@ - target_link_options(common_options INTERFACE $,,-g -flto -fuse-linker-plugin>) - endif() - --if (NOT DESKTOP_APP_DISABLE_JEMALLOC) -- target_link_libraries(common_options -- INTERFACE -- $ -- $ -- ) --endif() -- - target_link_libraries(common_options - INTERFACE - ${CMAKE_DL_LIBS} diff --git a/net-im/telegram-desktop/files/tdesktop-3.6.0-support-ffmpeg5.patch b/net-im/telegram-desktop/files/tdesktop-3.6.0-support-ffmpeg5.patch deleted file mode 100644 index 32959acd..00000000 --- a/net-im/telegram-desktop/files/tdesktop-3.6.0-support-ffmpeg5.patch +++ /dev/null @@ -1,75 +0,0 @@ -Support FFmpeg 5 - -I'm not comfortable changing the _durationInMilliseconds formula on older -versions of ffmpeg. Doing that only for newer versions also reduces the amount -of testing this patch needs (of which it'll get very minimal amounts, this is a -job better left for upstream when they get to it). - -Also it doesn't compile under ffmpeg 4 if the variables are constants :/ - ---- tdesktop-3.6.0-full.orig/Telegram/ThirdParty/tgcalls/tgcalls/group/AudioStreamingPartInternal.cpp -+++ tdesktop-3.6.0-full/Telegram/ThirdParty/tgcalls/tgcalls/group/AudioStreamingPartInternal.cpp -@@ -104,7 +104,11 @@ - - _frame = av_frame_alloc(); - -+#if LIBAVFORMAT_VERSION_MAJOR >= 59 -+ const AVInputFormat *inputFormat = av_find_input_format(container.c_str()); -+#else - AVInputFormat *inputFormat = av_find_input_format(container.c_str()); -+#endif - if (!inputFormat) { - _didReadToEnd = true; - return; -@@ -144,7 +148,11 @@ - - _streamId = i; - -+#if LIBAVFORMAT_VERSION_MAJOR >= 59 -+ _durationInMilliseconds = inStream->duration * 1000 / 48000; -+#else - _durationInMilliseconds = (int)((inStream->duration + inStream->first_dts) * 1000 / 48000); -+#endif - - if (inStream->metadata) { - AVDictionaryEntry *entry = av_dict_get(inStream->metadata, "TG_META", nullptr, 0); ---- tdesktop-3.6.0-full.orig/Telegram/ThirdParty/tgcalls/tgcalls/group/AudioStreamingPartPersistentDecoder.cpp -+++ tdesktop-3.6.0-full/Telegram/ThirdParty/tgcalls/tgcalls/group/AudioStreamingPartPersistentDecoder.cpp -@@ -32,7 +32,11 @@ - AudioStreamingPartPersistentDecoderState(AVCodecParameters const *codecParameters, AVRational timeBase) : - _codecParameters(codecParameters), - _timeBase(timeBase) { -+#ifdef LIBAVCODEC_VERSION_MAJOR >= 59 -+ const AVCodec *codec = avcodec_find_decoder(codecParameters->codec_id); -+#else - AVCodec *codec = avcodec_find_decoder(codecParameters->codec_id); -+#endif - if (codec) { - _codecContext = avcodec_alloc_context3(codec); - int ret = avcodec_parameters_to_context(_codecContext, codecParameters); ---- tdesktop-3.6.0-full.orig/Telegram/ThirdParty/tgcalls/tgcalls/group/VideoStreamingPart.cpp -+++ tdesktop-3.6.0-full/Telegram/ThirdParty/tgcalls/tgcalls/group/VideoStreamingPart.cpp -@@ -280,7 +280,11 @@ - - int ret = 0; - -+#if LIBAVFORMAT_VERSION_MAJOR >= 59 -+ const AVInputFormat *inputFormat = av_find_input_format(container.c_str()); -+#else - AVInputFormat *inputFormat = av_find_input_format(container.c_str()); -+#endif - if (!inputFormat) { - _didReadToEnd = true; - return; -@@ -323,7 +327,11 @@ - } - - if (videoCodecParameters && videoStream) { -+#if LIBAVCODEC_VERSION_MAJOR >= 59 -+ const AVCodec *codec = avcodec_find_decoder(videoCodecParameters->codec_id); -+#else - AVCodec *codec = avcodec_find_decoder(videoCodecParameters->codec_id); -+#endif - if (codec) { - _codecContext = avcodec_alloc_context3(codec); - ret = avcodec_parameters_to_context(_codecContext, videoCodecParameters); diff --git a/net-im/telegram-desktop/files/tdesktop-3.6.1-fix-double-destruction.patch b/net-im/telegram-desktop/files/tdesktop-3.6.1-fix-double-destruction.patch deleted file mode 100644 index b18334e9..00000000 --- a/net-im/telegram-desktop/files/tdesktop-3.6.1-fix-double-destruction.patch +++ /dev/null @@ -1,46 +0,0 @@ -Description: Do not capture buttons in AccountsList that belong to inner VerticalLayout widget - This fixes a use-after-free error (double destruction) in the main menu right after account switching. -Bug-Debian: https://bugs.debian.org/1008156 -Bug-Ubuntu: https://launchpad.net/bugs/1967673 -Forwarded: https://github.com/telegramdesktop/tdesktop/pull/24301 -Author: Nicholas Guriev -Last-Update: Sat, 09 Apr 2022 13:47:55 +0300 - -diff --git a/Telegram/SourceFiles/settings/settings_information.cpp b/Telegram/SourceFiles/settings/settings_information.cpp -index 092194dcf5ce..08365a9a0c27 100644 ---- a/Telegram/SourceFiles/settings/settings_information.cpp -+++ b/Telegram/SourceFiles/settings/settings_information.cpp -@@ -78,9 +78,7 @@ class AccountsList final { - int _outerIndex = 0; - - Ui::SlideWrap *_addAccount = nullptr; -- base::flat_map< -- not_null, -- base::unique_qptr> _watched; -+ base::flat_map, Ui::SettingsButton*> _watched; - - base::unique_qptr _contextMenu; - std::unique_ptr _reorder; -@@ -730,7 +728,7 @@ void AccountsList::rebuild() { - order.reserve(inner->count()); - for (auto i = 0; i < inner->count(); i++) { - for (const auto &[account, button] : _watched) { -- if (button.get() == inner->widgetAt(i)) { -+ if (button == inner->widgetAt(i)) { - order.push_back(account->session().uniqueId()); - } - } -@@ -769,11 +767,11 @@ void AccountsList::rebuild() { - account, - std::move(activate)); - }; -- button.reset(inner->add(MakeAccountButton( -+ button = inner->add(MakeAccountButton( - inner, - _controller, - account, -- std::move(callback)))); -+ std::move(callback))); - } - } - inner->resizeToWidth(_outer->width()); diff --git a/net-im/telegram-desktop/files/tdesktop-4.10.0-system-cppgir.patch b/net-im/telegram-desktop/files/tdesktop-4.10.0-system-cppgir.patch new file mode 100644 index 00000000..39f30ff0 --- /dev/null +++ b/net-im/telegram-desktop/files/tdesktop-4.10.0-system-cppgir.patch @@ -0,0 +1,32 @@ +Use system cppgir + +https://github.com/desktop-app/cmake_helpers/issues/282 +https://github.com/desktop-app/cmake_helpers/pull/305 +--- tdesktop-4.10.0-full.orig/cmake/external/glib/CMakeLists.txt ++++ tdesktop-4.10.0-full/cmake/external/glib/CMakeLists.txt +@@ -7,14 +7,6 @@ + add_library(external_glib INTERFACE IMPORTED GLOBAL) + add_library(desktop-app::external_glib ALIAS external_glib) + +-function(add_cppgir) # isolate scope +- set(BUILD_TESTING OFF) +- set(BUILD_DOC OFF) +- set(BUILD_EXAMPLES OFF) +- add_subdirectory(cppgir EXCLUDE_FROM_ALL) +-endfunction() +-add_cppgir() +- + include(generate_cppgir.cmake) + generate_cppgir(external_glib Gio-2.0) + +--- tdesktop-4.10.0-full.orig/cmake/external/glib/generate_cppgir.cmake ++++ tdesktop-4.10.0-full/cmake/external/glib/generate_cppgir.cmake +@@ -4,6 +4,8 @@ + # For license and copyright information please follow this link: + # https://github.com/desktop-app/legal/blob/master/LEGAL + ++find_package(CppGir REQUIRED) ++ + function(generate_cppgir target_name gir) + # cppgir generates all the dependent headers everytime, better to have a global folder + set(gen_dst ${CMAKE_BINARY_DIR}/gen) diff --git a/net-im/telegram-desktop/files/tdesktop-4.10.5-qt_compare.patch b/net-im/telegram-desktop/files/tdesktop-4.10.5-qt_compare.patch new file mode 100644 index 00000000..f481ddd7 --- /dev/null +++ b/net-im/telegram-desktop/files/tdesktop-4.10.5-qt_compare.patch @@ -0,0 +1,12 @@ +diff --git a/Telegram/lib_base/base/qt/qt_compare.h b/Telegram/lib_base/base/qt/qt_compare.h +index ca03fa2..d1eb6ab 100644 +--- a/Telegram/lib_base/base/qt/qt_compare.h ++++ b/Telegram/lib_base/base/qt/qt_compare.h +@@ -10,6 +10,7 @@ + #include + + #include ++#include + + #if !defined(__apple_build_version__) || (__apple_build_version__ > 12000032) + diff --git a/net-im/telegram-desktop/telegram-desktop-3.6.1-r1.ebuild b/net-im/telegram-desktop/telegram-desktop-3.6.1-r1.ebuild deleted file mode 100644 index cb4dca48..00000000 --- a/net-im/telegram-desktop/telegram-desktop-3.6.1-r1.ebuild +++ /dev/null @@ -1,164 +0,0 @@ -# Copyright 2020-2022 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -PYTHON_COMPAT=( python3_{8..10} ) - -inherit xdg cmake python-any-r1 optfeature - -DESCRIPTION="Official desktop client for Telegram" -HOMEPAGE="https://desktop.telegram.org" - -MY_P="tdesktop-${PV}-full" -SRC_URI="https://github.com/telegramdesktop/tdesktop/releases/download/v${PV}/${MY_P}.tar.gz" -S="${WORKDIR}/${MY_P}" - -LICENSE="BSD GPL-3-with-openssl-exception LGPL-2+" -SLOT="0" -KEYWORDS="~amd64 ~arm64 ~ppc64 ~riscv" -IUSE="+dbus enchant +hunspell +jemalloc screencast +spell wayland +X" -REQUIRED_USE=" - spell? ( - ^^ ( enchant hunspell ) - ) -" - -RDEPEND=" - !net-im/telegram-desktop-bin - app-arch/lz4:= - dev-cpp/abseil-cpp:= - dev-libs/libdispatch - dev-libs/openssl:= - dev-libs/xxhash - >=dev-qt/qtcore-5.15:5 - >=dev-qt/qtgui-5.15:5[dbus?,jpeg,png,wayland?,X?] - >=dev-qt/qtimageformats-5.15:5 - >=dev-qt/qtnetwork-5.15:5[ssl] - >=dev-qt/qtsvg-5.15:5 - >=dev-qt/qtwidgets-5.15:5[png,X?] - media-fonts/open-sans - media-libs/fontconfig:= - ~media-libs/libtgvoip-2.4.4_p20220117 - media-libs/openal - media-libs/opus:= - media-libs/rnnoise - ~media-libs/tg_owt-0_pre20220209[screencast=,X=] - media-video/ffmpeg:=[opus] - sys-libs/zlib:=[minizip] - dbus? ( - dev-cpp/glibmm:2 - dev-qt/qtdbus:5 - dev-libs/libdbusmenu-qt[qt5(+)] - ) - enchant? ( app-text/enchant:= ) - hunspell? ( >=app-text/hunspell-1.7:= ) - jemalloc? ( dev-libs/jemalloc:=[-lazy-lock] ) - wayland? ( - dev-qt/qtwayland:= - kde-frameworks/kwayland:= - ) - X? ( x11-libs/libxcb:= ) -" -DEPEND="${RDEPEND} - dev-cpp/range-v3 - =dev-cpp/ms-gsl-3* -" -BDEPEND=" - ${PYTHON_DEPS} - >=dev-util/cmake-3.16 - virtual/pkgconfig -" -# dev-libs/jemalloc:=[-lazy-lock] -> https://bugs.gentoo.org/803233 - -PATCHES=( - "${FILESDIR}/tdesktop-3.6.0-jemalloc-only-telegram.patch" - "${FILESDIR}/tdesktop-3.3.0-fix-enchant.patch" - "${FILESDIR}/tdesktop-3.5.2-musl.patch" - "${FILESDIR}/tdesktop-3.6.0-support-ffmpeg5.patch" - "${FILESDIR}/tdesktop-3.6.1-fix-double-destruction.patch" -) - -# Current desktop-file-utils-0.26 does not understand Version=1.5 -QA_DESKTOP_FILE="usr/share/applications/${PN}.desktop" - -pkg_pretend() { - if has ccache ${FEATURES}; then - ewarn - ewarn "ccache does not work with ${PN} out of the box" - ewarn "due to usage of precompiled headers" - ewarn "check bug https://bugs.gentoo.org/715114 for more info" - ewarn - fi -} - -src_prepare() { - # no explicit toggle, doesn't build with the system one #752417 - sed -i 's/DESKTOP_APP_USE_PACKAGED/NO_ONE_WILL_EVER_SET_THIS/' \ - cmake/external/rlottie/CMakeLists.txt || die - - cmake_src_prepare -} - -src_configure() { - local mycmakeargs=( - -DTDESKTOP_LAUNCHER_BASENAME="${PN}" - -DCMAKE_DISABLE_FIND_PACKAGE_tl-expected=ON # header only lib, some git version. prevents warnings. - -DDESKTOP_APP_QT6=OFF - - -DDESKTOP_APP_DISABLE_DBUS_INTEGRATION=$(usex !dbus) - -DDESKTOP_APP_DISABLE_X11_INTEGRATION=$(usex !X) - -DDESKTOP_APP_DISABLE_WAYLAND_INTEGRATION=$(usex !wayland) - -DDESKTOP_APP_DISABLE_SPELLCHECK=$(usex !spell) # enables hunspell (recommended) - -DDESKTOP_APP_USE_ENCHANT=$(usex enchant) # enables enchant and disables hunspell - - # This option is heavily discouraged by upstream. - # See files/tdesktop-*-jemalloc-optional.patch - -DDESKTOP_APP_DISABLE_JEMALLOC=$(usex !jemalloc) - ) - - if [[ -n ${MY_TDESKTOP_API_ID} && -n ${MY_TDESKTOP_API_HASH} ]]; then - einfo "Found custom API credentials" - mycmakeargs+=( - -DTDESKTOP_API_ID="${MY_TDESKTOP_API_ID}" - -DTDESKTOP_API_HASH="${MY_TDESKTOP_API_HASH}" - ) - else - # https://github.com/telegramdesktop/tdesktop/blob/dev/snap/snapcraft.yaml - # Building with snapcraft API credentials by default - # Custom API credentials can be obtained here: - # https://github.com/telegramdesktop/tdesktop/blob/dev/docs/api_credentials.md - # After getting credentials you can export variables: - # export MY_TDESKTOP_API_ID="17349"" - # export MY_TDESKTOP_API_HASH="344583e45741c457fe1862106095a5eb" - # and restart the build" - # you can set above variables (without export) in /etc/portage/env/net-im/telegram-desktop - # portage will use custom variable every build automatically - mycmakeargs+=( - -DTDESKTOP_API_ID="611335" - -DTDESKTOP_API_HASH="d524b414d21f4d37f08684c1df41ac9c" - ) - fi - - cmake_src_configure -} - -pkg_postinst() { - xdg_pkg_postinst - if ! use X && ! use screencast; then - elog "both the 'X' and 'screencast' useflags are disabled, screen sharing won't work!" - elog - fi - if has_version '> cmake/external/qt/qt_static_plugins/qt_static_plugins.cpp || die + fi + # kde-frameworks/kcoreaddons is bundled when using qt6. + + # Happily fail if libraries aren't found... + find -type f \( -name 'CMakeLists.txt' -o -name '*.cmake' \) \ + \! -path './Telegram/lib_webview/CMakeLists.txt' \ + \! -path './cmake/external/expected/CMakeLists.txt' \ + \! -path './cmake/external/kcoreaddons/CMakeLists.txt' \ + \! -path './cmake/external/qt/package.cmake' \ + -print0 | xargs -0 sed -i \ + -e '/pkg_check_modules(/s/[^ ]*)/REQUIRED &/' \ + -e '/find_package(/s/)/ REQUIRED)/' || die + # Make sure to check the excluded files for new + # CMAKE_DISABLE_FIND_PACKAGE entries. + + # Control QtDBus dependency from here, to avoid messing with QtGui. + if ! use dbus; then + sed -e '/find_package(Qt[^ ]* OPTIONAL_COMPONENTS/s/DBus *//' \ + -i cmake/external/qt/package.cmake || die + fi + + cmake_src_prepare +} + +src_configure() { + # Having user paths sneak into the build environment through the + # XDG_DATA_DIRS variable causes all sorts of weirdness with cppgir: + # - bug 909038: can't read from flatpak directories (fixed upstream) + # - bug 920819: system-wide directories ignored when variable is set + export XDG_DATA_DIRS="${EPREFIX}/usr/share" + + # Evil flag (bug #919201) + filter-flags -fno-delete-null-pointer-checks + + # The ABI of media-libs/tg_owt breaks if the -DNDEBUG flag doesn't keep + # the same state across both projects. + # See https://bugs.gentoo.org/866055 + append-cppflags '-DNDEBUG' + + local qt=$(usex qt6 6 5) + local mycmakeargs=( + -DQT_VERSION_MAJOR=${qt} + + # Override new cmake.eclass defaults (https://bugs.gentoo.org/921939) + # Upstream never tests this any other way + -DCMAKE_DISABLE_PRECOMPILE_HEADERS=OFF + + # Control automagic dependencies on certain packages + ## Header-only lib, some git version. + -DCMAKE_DISABLE_FIND_PACKAGE_tl-expected=ON + -DCMAKE_DISABLE_FIND_PACKAGE_Qt${qt}Quick=$(usex !webkit) + -DCMAKE_DISABLE_FIND_PACKAGE_Qt${qt}QuickWidgets=$(usex !webkit) + -DCMAKE_DISABLE_FIND_PACKAGE_Qt${qt}WaylandClient=$(usex !wayland) + ## Only used in Telegram/lib_webview/CMakeLists.txt + -DCMAKE_DISABLE_FIND_PACKAGE_Qt${qt}WaylandCompositor=$(usex !webkit) + ## KF6CoreAddons is currently unavailable in ::gentoo + -DCMAKE_DISABLE_FIND_PACKAGE_KF${qt}CoreAddons=$(usex qt6) + + -DDESKTOP_APP_DISABLE_X11_INTEGRATION=$(usex !X) + -DDESKTOP_APP_DISABLE_WAYLAND_INTEGRATION=$(usex !wayland) + ## Enables enchant and disables hunspell + -DDESKTOP_APP_USE_ENCHANT=$(usex enchant) + ## Use system fonts instead of bundled ones + -DDESKTOP_APP_USE_PACKAGED_FONTS=$(usex !fonts) + ) + + if [[ -n ${MY_TDESKTOP_API_ID} && -n ${MY_TDESKTOP_API_HASH} ]]; then + einfo "Found custom API credentials" + mycmakeargs+=( + -DTDESKTOP_API_ID="${MY_TDESKTOP_API_ID}" + -DTDESKTOP_API_HASH="${MY_TDESKTOP_API_HASH}" + ) + else + # https://github.com/telegramdesktop/tdesktop/blob/dev/snap/snapcraft.yaml + # Building with snapcraft API credentials by default + # Custom API credentials can be obtained here: + # https://github.com/telegramdesktop/tdesktop/blob/dev/docs/api_credentials.md + # After getting credentials you can export variables: + # export MY_TDESKTOP_API_ID="17349"" + # export MY_TDESKTOP_API_HASH="344583e45741c457fe1862106095a5eb" + # and restart the build" + # you can set above variables (without export) in /etc/portage/env/net-im/telegram-desktop + # portage will use custom variable every build automatically + mycmakeargs+=( + -DTDESKTOP_API_ID="611335" + -DTDESKTOP_API_HASH="d524b414d21f4d37f08684c1df41ac9c" + ) + fi + + cmake_src_configure +} + +pkg_postinst() { + xdg_pkg_postinst + if ! use X && ! use screencast; then + ewarn "both the 'X' and 'screencast' USE flags are disabled, screen sharing won't work!" + ewarn + fi + if use wayland && ! use qt6; then + ewarn "Wayland-specific integrations have been deprecated with Qt5." + ewarn "The app will continue to function under wayland, but some" + ewarn "functionality may be reduced." + ewarn "These integrations are only supported when built with Qt6." + ewarn + fi + if use qt6 && ! use qt6-imageformats; then + elog "Enable USE=qt6-imageformats for AVIF, HEIF and JpegXL support" + elog + fi + optfeature_header + if ! use qt6; then + optfeature "AVIF, HEIF and JpegXL image support" kde-frameworks/kimageformats[avif,heif,jpegxl] + fi +}