tdesktop/snap/snapcraft.yaml
2021-06-17 11:55:10 +04:00

497 lines
13 KiB
YAML

name: telegram-desktop
adopt-info: telegram
icon: Telegram/Resources/art/icon512@2x.png
base: core20
grade: stable
confinement: strict
compression: lzo
architectures:
- build-on: amd64
- build-on: arm64
- build-on: armhf
- build-on: ppc64el
apps:
telegram-desktop:
command: bin/desktop-launch telegram-desktop
common-id: org.telegram.desktop
desktop: usr/share/applications/telegram-desktop_telegram-desktop.desktop
environment:
# Tell glib to use portals on file associations handling.
GTK_USE_PORTAL: 1
# Use sandboxed ibus api
IBUS_USE_PORTAL: 1
plugs:
- alsa
- audio-playback
- audio-record
- camera
- desktop
- desktop-legacy
- home
- network
- network-manager-observe
- opengl
- pulseaudio
- removable-media
- unity7
- wayland
- x11
slots:
- tdesktop-mpris
plugs:
# Support for common GTK themes
# https://forum.snapcraft.io/t/how-to-use-the-system-gtk-theme-via-the-gtk-common-themes-snap/6235
gsettings:
gtk-3-themes:
interface: content
target: $SNAP/data-dir/themes
default-provider: gtk-common-themes
icon-themes:
interface: content
target: $SNAP/data-dir/icons
default-provider: gtk-common-themes
sound-themes:
interface: content
target: $SNAP/data-dir/sounds
default-provider: gtk-common-themes
slots:
tdesktop-mpris:
interface: mpris
name: tdesktop
layout:
/usr/share/alsa:
bind: $SNAP/usr/share/alsa
/usr/share/X11:
bind: $SNAP/usr/share/X11
/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/webkit2gtk-4.0:
bind: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/webkit2gtk-4.0
parts:
telegram:
plugin: cmake
source: .
source-type: git
parse-info: [usr/share/metainfo/telegram-desktop_telegram-desktop.appdata.xml]
build-environment:
- LD_LIBRARY_PATH: $SNAPCRAFT_STAGE/usr/lib/$SNAPCRAFT_ARCH_TRIPLET:$LD_LIBRARY_PATH
build-packages:
- python
- libasound2-dev
- libglib2.0-dev
- libglibmm-2.4-dev
- libgtk-3-dev
- liblzma-dev
- libopus-dev
- libpulse-dev
- libssl-dev
- libwebkit2gtk-4.0-dev
- libxcb1-dev
- libxcb-keysyms1-dev
- libxcb-record0-dev
- libxcb-screensaver0-dev
- zlib1g-dev
stage-packages:
- libasound2
- libglib2.0-0
- libglibmm-2.4-1v5
- libgtk-3-0
- liblzma5
- libopus0
- libpulse0
- libssl1.1
- libwebkit2gtk-4.0-37
- libxcb1
- libxcb-keysyms1
- libxcb-record0
- libxcb-screensaver0
- zlib1g
cmake-parameters:
- -DCMAKE_BUILD_TYPE=Release
- -DCMAKE_INSTALL_PREFIX=/usr
- -DTDESKTOP_API_ID=611335
- -DTDESKTOP_API_HASH=d524b414d21f4d37f08684c1df41ac9c
- -DDESKTOP_APP_USE_PACKAGED_LAZY=ON
- -DDESKTOP_APP_USE_PACKAGED_LAZY_PLATFORMTHEMES=OFF
- -DTDESKTOP_LAUNCHER_BASENAME=telegram-desktop_telegram-desktop
override-pull: |
snapcraftctl pull
version_file=Telegram/build/version
version=$(sed -n "s/AppVersionStr[ ]\+\(.*\)\+/\1/p" $version_file)
beta=$(sed -n "s/BetaChannel[ ]\+\(.*\)\+/\1/p" $version_file)
if [ "$beta" != "0" ]; then
version="$version-beta"
fi
version="${version}$(git describe --tags | sed 's,^v[^-]\+,,')"
snapcraftctl set-version "$version"
sed -i 's|^Icon=.*|Icon=${SNAP}/meta/gui/icon.png|g' lib/xdg/telegramdesktop.desktop
override-build: |
snapcraftctl build
rm -rf "$SNAPCRAFT_PART_INSTALL/usr/share/icons"
stage:
- -./usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libjpeg.so.8.2.2
after:
- desktop-qt5
- extra-cmake-modules
- ffmpeg
- kwayland
- mozjpeg
- openal
- rnnoise
- webrtc
patches:
source: https://github.com/desktop-app/patches.git
source-depth: 1
plugin: dump
organize:
"*": patches/
prime: [-./*]
desktop-qt5:
source: https://github.com/desktop-app/snapcraft-desktop-helpers.git
source-subdir: qt
plugin: make
make-parameters: ["FLAVOR=qt5"]
build-packages:
- build-essential
- dpkg-dev
stage-packages:
- libxkbcommon0
- ttf-ubuntu-font-family
- dmz-cursor-theme
- light-themes
- adwaita-icon-theme
- gnome-themes-standard
- shared-mime-info
- libgdk-pixbuf2.0-0
- locales-all
- xdg-user-dirs
stage:
- -./usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libjpeg.so.8.2.2
after:
- mozjpeg
- qt5
extra-cmake-modules:
source: https://github.com/KDE/extra-cmake-modules.git
source-depth: 1
source-tag: v5.77.0
plugin: cmake
cmake-parameters:
- -DCMAKE_BUILD_TYPE=Release
- -DCMAKE_INSTALL_PREFIX=/usr
- -DBUILD_TESTING=OFF
prime: [-./*]
ffmpeg:
plugin: nil
build-packages:
- libavcodec-dev
- libavformat-dev
- libavutil-dev
- libswresample-dev
- libswscale-dev
stage-packages:
- libavcodec58
- libavformat58
- libavutil56
- libswresample3
- libswscale5
stage:
- -./usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libjpeg.so.8.2.2
after:
- mozjpeg
kwayland:
source: https://github.com/KDE/kwayland.git
source-depth: 1
source-tag: v5.77.0
plugin: cmake
build-packages:
- libwayland-dev
- wayland-protocols
stage-packages:
- libwayland-client0
- libwayland-server0
cmake-parameters:
- -DCMAKE_BUILD_TYPE=Release
- -DCMAKE_INSTALL_PREFIX=/usr
- -DBUILD_TESTING=OFF
prime:
- -./usr/include
- -./usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libexec
- -./usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pkgconfig
- -./usr/lib/$SNAPCRAFT_ARCH_TRIPLET/*.so
- -./usr/mkspecs
- -./usr/share
after:
- extra-cmake-modules
- desktop-qt5
- plasma-wayland-protocols
mozjpeg:
source: https://github.com/mozilla/mozjpeg.git
source-depth: 1
source-tag: v4.0.1-rc2
plugin: cmake
cmake-parameters:
- -DCMAKE_BUILD_TYPE=Release
- -DCMAKE_INSTALL_PREFIX=/usr
- -DENABLE_STATIC=OFF
- -DWITH_JPEG8=ON
- -DPNG_SUPPORTED=OFF
prime:
- -./usr/bin
- -./usr/include
- -./usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pkgconfig
- -./usr/lib/$SNAPCRAFT_ARCH_TRIPLET/*.so
- -./usr/share
openal:
source: https://github.com/telegramdesktop/openal-soft.git
source-depth: 1
source-branch: fix_pulse_default
plugin: cmake
build-packages:
- libasound2-dev
- libpulse-dev
stage-packages:
- libasound2
- libpulse0
cmake-parameters:
- -DCMAKE_BUILD_TYPE=Release
- -DCMAKE_INSTALL_PREFIX=/usr
- -DALSOFT_EXAMPLES=OFF
- -DALSOFT_TESTS=OFF
- -DALSOFT_UTILS=OFF
- -DALSOFT_CONFIG=OFF
prime:
- -./usr/include
- -./usr/lib/$SNAPCRAFT_ARCH_TRIPLET/cmake
- -./usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pkgconfig
- -./usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libopenal.so
plasma-wayland-protocols:
source: https://github.com/KDE/plasma-wayland-protocols.git
source-depth: 1
source-tag: v1.1.1
plugin: cmake
cmake-parameters:
- -DCMAKE_BUILD_TYPE=Release
- -DCMAKE_INSTALL_PREFIX=/usr
prime: [-./*]
after:
- extra-cmake-modules
qt5:
plugin: nil
build-packages:
- libdbus-1-dev
- libegl-dev
- libfontconfig1-dev
- libfreetype-dev
- libgl-dev
- libglib2.0-dev
- libharfbuzz-dev
- libicu-dev
- libpcre2-dev
- libpng-dev
- libssl-dev
- libwayland-dev
- libx11-dev
- libx11-xcb-dev
- libxcb1-dev
- libxcb-glx0-dev
- libxcb-icccm4-dev
- libxcb-image0-dev
- libxcb-keysyms1-dev
- libxcb-randr0-dev
- libxcb-render0-dev
- libxcb-render-util0-dev
- libxcb-shape0-dev
- libxcb-shm0-dev
- libxcb-sync-dev
- libxcb-util-dev
- libxcb-xfixes0-dev
- libxcb-xinerama0-dev
- libxcb-xinput-dev
- libxcb-xkb-dev
- libxcursor-dev
- libxkbcommon-dev
- libxkbcommon-x11-dev
- zlib1g-dev
stage-packages:
- libdbus-1-3
- libegl1
- libfontconfig1
- libfreetype6
- libgl1
- libglib2.0-0
- libharfbuzz0b
- libicu66
- libpcre2-16-0
- libpng16-16
- libssl1.1
- libwayland-client0
- libwayland-cursor0
- libwayland-egl1
- libx11-6
- libx11-xcb1
- libxcb1
- libxcb-glx0
- libxcb-icccm4
- libxcb-image0
- libxcb-keysyms1
- libxcb-randr0
- libxcb-render0
- libxcb-render-util0
- libxcb-shape0
- libxcb-shm0
- libxcb-sync1
- libxcb-util1
- libxcb-xfixes0
- libxcb-xinerama0
- libxcb-xinput0
- libxcb-xkb1
- libxcursor1
- libxkbcommon0
- libxkbcommon-x11-0
- zlib1g
override-pull: |
QT=5_15_2
git clone -b v5.15.2 --depth=1 git://code.qt.io/qt/qt5.git .
perl init-repository --module-subset=qtbase,qtwayland,qtimageformats,qtsvg
git submodule update qtbase qtwayland qtimageformats qtsvg
cd qtbase
find $SNAPCRAFT_STAGE/patches/qtbase_${QT} -type f -print0 | sort -z | xargs -r0 git apply
cd ../qtwayland
find $SNAPCRAFT_STAGE/patches/qtwayland_${QT} -type f -print0 | sort -z | xargs -r0 git apply
cd ..
override-build: |
./configure \
-prefix /usr \
-bindir /usr/lib/qt5/bin \
-libdir /usr/lib/$SNAPCRAFT_ARCH_TRIPLET \
-docdir /usr/share/qt5/doc \
-headerdir /usr/include/$SNAPCRAFT_ARCH_TRIPLET/qt5 \
-datadir /usr/share/qt5 \
-archdatadir /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/qt5 \
-plugindir /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/qt5/plugins \
-importdir /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/qt5/imports \
-translationdir /usr/share/qt5/translations \
-hostdatadir /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/qt5 \
-sysconfdir /etc/xdg \
-examplesdir /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/qt5/examples \
-release \
-opensource \
-confirm-license \
-no-gtk \
-no-feature-xcb-sm \
-no-feature-xcomposite-egl \
-no-feature-xcomposite-glx \
-no-feature-wayland-server \
-openssl-linked \
-nomake examples \
-nomake tests \
-I $SNAPCRAFT_STAGE/usr/include \
-L $SNAPCRAFT_STAGE/usr/lib/$SNAPCRAFT_ARCH_TRIPLET
make -j$SNAPCRAFT_PARALLEL_BUILD_COUNT
make INSTALL_ROOT="$SNAPCRAFT_PART_INSTALL" install
stage:
- -./usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libjpeg.so.8.2.2
prime:
- -./usr/include
- -./usr/lib/$SNAPCRAFT_ARCH_TRIPLET/cmake
- -./usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pkgconfig
- -./usr/lib/$SNAPCRAFT_ARCH_TRIPLET/qt5/bin
- -./usr/lib/$SNAPCRAFT_ARCH_TRIPLET/qt5/mkspecs
- -./usr/lib/$SNAPCRAFT_ARCH_TRIPLET/qt5/examples
- -./usr/lib/$SNAPCRAFT_ARCH_TRIPLET/*.a
- -./usr/lib/$SNAPCRAFT_ARCH_TRIPLET/*.la
- -./usr/lib/$SNAPCRAFT_ARCH_TRIPLET/*.prl
- -./usr/lib/$SNAPCRAFT_ARCH_TRIPLET/*.so
- -./usr/lib/qt5
- -./usr/share
after:
- mozjpeg
- patches
rnnoise:
source: https://gitlab.xiph.org/xiph/rnnoise.git
source-depth: 1
source-commit: 7f449bf8bd3b933891d12c30112268c4090e4d59
plugin: autotools
autotools-configure-parameters:
- --prefix=/usr
- --libdir=\${exec_prefix}/lib/$SNAPCRAFT_ARCH_TRIPLET
- --disable-static
- --disable-examples
- --disable-doc
prime:
- -./usr/include
- -./usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pkgconfig
- -./usr/lib/$SNAPCRAFT_ARCH_TRIPLET/librnnoise.la
- -./usr/lib/$SNAPCRAFT_ARCH_TRIPLET/librnnoise.so
- -./usr/share
webrtc:
source: https://github.com/desktop-app/tg_owt.git
source-depth: 1
source-commit: f03ef05abf665437649a4f71886db1343590e862
plugin: cmake
build-packages:
- yasm
- libglib2.0-dev
- libopus-dev
- libpipewire-0.2-dev
- libssl-dev
- libx11-dev
- libxcomposite-dev
- libxdamage-dev
- libxext-dev
- libxfixes-dev
- libxrender-dev
- libxrandr-dev
- libxtst-dev
stage-packages:
- libglib2.0-0
- libopus0
- libpipewire-0.2-1
- libssl1.1
- libx11-6
- libxcomposite1
- libxdamage1
- libxext6
- libxfixes3
- libxrender1
- libxrandr2
- libxtst6
cmake-parameters:
- -DCMAKE_BUILD_TYPE=Release
- -DCMAKE_INSTALL_PREFIX=/usr
- -DBUILD_SHARED_LIBS=OFF
- -DJPEG_LIBRARY_RELEASE=$SNAPCRAFT_STAGE/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libjpeg.so
- -DJPEG_INCLUDE_DIR=$SNAPCRAFT_STAGE/usr/include
- -DTG_OWT_BUILD_AUDIO_BACKENDS=OFF
prime:
- -./usr/include
- -./usr/lib/$SNAPCRAFT_ARCH_TRIPLET/cmake
- -./usr/lib/$SNAPCRAFT_ARCH_TRIPLET/*.a
after:
- ffmpeg
- mozjpeg