From 9536a3c98e25fe8d6f08dc99764f4ec94319e4d5 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sat, 25 Jan 2020 09:44:58 +0400 Subject: [PATCH] Use packaged build in the snap package --- .github/workflows/snap.yml | 99 ++++ .../platform/linux/main_window_linux.cpp | 12 +- .../linux/notifications_manager_linux.cpp | 4 + .../platform/linux/specific_linux.cpp | 4 + snap/plugins/x-autotools-subsource.py | 66 --- snap/plugins/x-gyp-cmake.py | 100 ---- snap/plugins/x-patched-python.py | 65 -- snap/plugins/x-qtbuilder.py | 204 ------- snap/scripts/telegram-launch | 24 - snap/snapcraft.yaml | 557 ++++++------------ 10 files changed, 286 insertions(+), 849 deletions(-) create mode 100644 .github/workflows/snap.yml delete mode 100644 snap/plugins/x-autotools-subsource.py delete mode 100644 snap/plugins/x-gyp-cmake.py delete mode 100644 snap/plugins/x-patched-python.py delete mode 100644 snap/plugins/x-qtbuilder.py delete mode 100755 snap/scripts/telegram-launch diff --git a/.github/workflows/snap.yml b/.github/workflows/snap.yml new file mode 100644 index 000000000..ed4fe99d8 --- /dev/null +++ b/.github/workflows/snap.yml @@ -0,0 +1,99 @@ +name: Snap. + +on: + push: + paths-ignore: + - 'docs/**' + - '*.md' + pull_request: + paths-ignore: + - 'docs/**' + - '*.md' + +jobs: + + linux: + name: Ubuntu 18.04 + runs-on: ubuntu-18.04 + + env: + UPLOAD_ARTIFACT: "false" + ONLY_CACHE: "false" + MANUAL_CACHING: "3" + + steps: + - name: Clone. + uses: actions/checkout@v1 + with: + submodules: recursive + + - name: First set up. + run: | + sudo apt-get update + sudo apt-get install gcc-8 g++-8 -y + sudo snap install --classic snapcraft + + # Workaround for snapcraft + # See https://forum.snapcraft.io/t/permissions-problem-using-snapcraft-in-azure-pipelines/13258 + sudo chown root:root / + + snapcraft --version > CACHE_KEY.txt + gcc-8 --version >> CACHE_KEY.txt + echo $MANUAL_CACHING >> CACHE_KEY.txt + md5cache=$(md5sum CACHE_KEY.txt | cut -c -32) + echo ::set-env name=CACHE_KEY::$md5cache + + awk -v RS="" -v ORS="\n\n" '/^ cmake:/' snap/snapcraft.yaml > CMAKE_CACHE_KEY.txt + md5cache=$(md5sum CMAKE_CACHE_KEY.txt | cut -c -32) + echo ::set-env name=CMAKE_CACHE_KEY::$md5cache + + awk -v RS="" -v ORS="\n\n" '/^ enchant:/' snap/snapcraft.yaml > ENCHANT_CACHE_KEY.txt + md5cache=$(md5sum ENCHANT_CACHE_KEY.txt | cut -c -32) + echo ::set-env name=ENCHANT_CACHE_KEY::$md5cache + + - name: CMake cache. + id: cache-cmake + uses: actions/cache@v1 + with: + path: parts/cmake + key: ${{ runner.OS }}-cmake-${{ env.CACHE_KEY }}-${{ env.CMAKE_CACHE_KEY }} + + - name: CMake build. + if: steps.cache-cmake.outputs.cache-hit != 'true' + run: snapcraft build --destructive-mode cmake + + - name: Enchant cache. + id: cache-enchant + uses: actions/cache@v1 + with: + path: parts/enchant + key: ${{ runner.OS }}-enchant-${{ env.CACHE_KEY }}-${{ env.ENCHANT_CACHE_KEY }} + + - name: Enchant build. + if: steps.cache-enchant.outputs.cache-hit != 'true' + run: snapcraft build --destructive-mode enchant + + - name: Telegram Desktop snap build. + if: env.ONLY_CACHE == 'false' + run: snapcraft --destructive-mode + + - name: Move artifact. + if: env.UPLOAD_ARTIFACT == 'true' + run: | + artifact_name=$(echo telegram-desktop_*.snap) + echo ::set-env name=ARTIFACT_NAME::$artifact_name + + mkdir artifact + mv $artifact_name artifact + + - uses: actions/upload-artifact@master + if: env.UPLOAD_ARTIFACT == 'true' + name: Upload artifact. + with: + name: ${{ env.ARTIFACT_NAME }} + path: artifact + + - name: Remove unneeded directories for cache. + run: | + rm -rf parts/{cmake,enchant}/{build,src,ubuntu} + rm -rf parts/{cmake,enchant}/state/{stage,prime} diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp index 9c2b41ef6..5e3346905 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp @@ -29,6 +29,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Platform { namespace { +constexpr auto kLauncherBasename = str_const(MACRO_TO_STRING(TDESKTOP_LAUNCHER_BASENAME) ".desktop"); + bool noQtTrayIcon = false, tryAppIndicator = false; bool useGtkBase = false, useAppIndicator = false, useStatusIcon = false, trayIconChecked = false, useUnityCount = false; @@ -557,7 +559,7 @@ void MainWindow::psFirstShow() { auto snapName = QString::fromLatin1(qgetenv("SNAP_NAME")); if(snapName.isEmpty()) { std::vector possibleDesktopFiles = { - MACRO_TO_STRING(TDESKTOP_LAUNCHER_BASENAME) ".desktop", + str_const_toString(kLauncherBasename), "Telegram.desktop" }; @@ -573,8 +575,12 @@ void MainWindow::psFirstShow() { LOG(("Could not get Unity Launcher entry!")); } } else { - LOG(("SNAP Environment detected, setting Launcher entry to %1-telegramdesktop.desktop!").arg(snapName)); - _desktopFile = snapName + "_telegramdesktop.desktop"; + LOG(("SNAP Environment detected, setting Launcher entry to %1_%2.desktop!") + .arg(snapName) + .arg(str_const_toString(kLauncherBasename))); + _desktopFile = snapName + + '_' + + str_const_toString(kLauncherBasename); useUnityCount=true; } _dbusPath = "/com/canonical/unity/launcherentry/" + QString::number(djbStringHash("application://" + _desktopFile)); diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index a10314e75..0a75776aa 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -234,7 +234,11 @@ void NotificationData::setImage(const QString &imagePath) { const QByteArray imageBytes( (const char*)image.constBits(), +#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) + image.byteCount()); +#else image.sizeInBytes()); +#endif ImageData imageData; imageData.width = image.width(); diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index 764ab3804..817ecbfb5 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -200,6 +200,8 @@ QString CurrentExecutablePath(int argc, char *argv[]) { } QString SingleInstanceLocalServerName(const QString &hash) { + const auto isSnap = !qgetenv("SNAP").isEmpty(); + const auto runtimeDir = QStandardPaths::writableLocation( QStandardPaths::RuntimeLocation); @@ -208,6 +210,8 @@ QString SingleInstanceLocalServerName(const QString &hash) { + qsl("/app/") + QString::fromUtf8(qgetenv("FLATPAK_ID")) + '/' + hash; + } else if (QFileInfo::exists(runtimeDir) && isSnap) { + return runtimeDir + '/' + hash; } else if (QFileInfo::exists(runtimeDir)) { return runtimeDir + '/' + hash + '-' + cGUIDStr(); } else { // non-systemd distros diff --git a/snap/plugins/x-autotools-subsource.py b/snap/plugins/x-autotools-subsource.py deleted file mode 100644 index 330ea0b1b..000000000 --- a/snap/plugins/x-autotools-subsource.py +++ /dev/null @@ -1,66 +0,0 @@ -# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- -# -# Author: Marco Trevisan -# Copyright (C) 2017-2018 Canonical Ltd -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 3 as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import os -import snapcraft - -from snapcraft.internal import sources -from snapcraft.plugins import autotools - -class Dict2Object(object): - def __init__(self, d): - for k, v in d.items(): - setattr(self, k.replace('-', '_'), v) - - -class AutotoolsSubsourcePlugin(autotools.AutotoolsPlugin): - - @classmethod - def schema(cls): - schema = super().schema() - - schema['properties']['sub-sources'] = { - 'type': 'array', - 'minitems': 0, - 'uniqueItems': True, - 'items': { - 'type': 'object', - 'additionalProperties': True, - }, - 'default': [], - } - - return schema - - @classmethod - def get_pull_properties(cls): - return [ - 'sub-sources', - ] - - def pull(self): - super().pull() - - for src in self.options.sub_sources: - [name] = src.keys() - [values] = src.values() - - if 'source' in values: - dest = values['dest'] if 'dest' in values else '' - sources.get(os.path.join(self.sourcedir, dest), - os.path.join(self.build_basedir, dest), - Dict2Object(values)) diff --git a/snap/plugins/x-gyp-cmake.py b/snap/plugins/x-gyp-cmake.py deleted file mode 100644 index 94a5ba1a8..000000000 --- a/snap/plugins/x-gyp-cmake.py +++ /dev/null @@ -1,100 +0,0 @@ -# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- -# -# Author: Marco Trevisan -# Copyright (C) 2017-2018 Canonical Ltd -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 3 as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import os -import snapcraft - -from snapcraft.plugins import cmake - - -class GypCMakePlugin(cmake.CMakePlugin): - """A basic plugin for snapcraft that generates CMake files from gyp""" - - @classmethod - def schema(cls): - schema = super().schema() - - schema['properties']['gyp-file'] = { - 'type': 'string' - } - - schema['properties']['build-type'] = { - 'type': 'string', - 'default': 'Release', - 'enum': ['Debug', 'Release'], - } - - schema['properties']['environment'] = { - 'type': 'array', - 'minitems': 0, - 'uniqueItems': True, - 'items': { - 'type': 'object', - 'minitems': 0, - 'uniqueItems': True, - 'items': { - 'type': 'string', - }, - }, - 'default': [], - } - - schema['required'].append('gyp-file') - - schema['build-properties'].extend([ - 'build-type', - 'gyp-file', - ]) - - return schema - - def __init__(self, name, options, project): - super().__init__(name, options, project) - self.build_packages.extend([ - 'binutils', - 'python', - ]) - self.builddir = os.path.join( - self.build_basedir, 'out', self.options.build_type) - - def build(self): - env = self._build_environment() - gyp_path = os.path.join(self.sourcedir, os.path.dirname(self.options.gyp_file)) - - for environ in self.options.environment: - [env_name] = list(environ) - env[env_name] = str(environ[env_name]) - - if not os.path.exists(os.path.join(self.builddir, 'CMakeLists.txt')): - gyp_command = ['gyp'] + self.options.configflags + ['--format=cmake'] - gyp_command.append('--generator-output={}'.format(self.build_basedir)) - gyp_command.append(os.path.basename(self.options.gyp_file)) - self.run(gyp_command, cwd=gyp_path) - - if not os.path.exists(os.path.join(self.builddir, 'Makefile')): - self.run(['cmake', '.'], env=env) - - self.make(env=env) - - if self.options.artifacts and self.options.build_type == 'Release': - for artifact in self.options.artifacts: - dest = os.path.join(self.installdir, artifact) - if os.path.isfile(dest): - mime_type = self.run_output( - 'file --mime-type -b {}'.format(dest).split()) - if 'application/x-executable' in mime_type: - self.run(['strip', dest]) diff --git a/snap/plugins/x-patched-python.py b/snap/plugins/x-patched-python.py deleted file mode 100644 index 0444ac667..000000000 --- a/snap/plugins/x-patched-python.py +++ /dev/null @@ -1,65 +0,0 @@ -# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- -# -# Author: Marco Trevisan -# Copyright (C) 2017-2018 Canonical Ltd -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 3 as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import os -import snapcraft -import requests - -from snapcraft.plugins import python - -class PatchedPythonPlugin(python.PythonPlugin): - - @classmethod - def schema(cls): - schema = super().schema() - - schema['properties']['patches'] = { - 'type': 'array', - 'minitems': 0, - 'uniqueItems': True, - 'items': { - 'type': 'string', - }, - 'default': [], - } - - schema['pull-properties'].extend([ - 'patches', - ]) - - return schema - - def pull(self): - super().pull() - - for patch in self.options.patches: - patch_name = os.path.basename(patch) - patch_stamp = os.path.join( - self.sourcedir, '.snapcraft-patched-{}'.format(patch_name)) - - if not os.path.exists(patch_stamp): - if os.path.exists(patch): - patch_file = os.path.join(os.getcwd(), patch) - else: - patch_file = os.path.join( - self.sourcedir, 'snapcraft-patch-{}'.format(patch_name)) - with open(patch_file, 'wb') as file: - file.write(requests.get(patch).content) - - patch_cmd = 'git apply -v3 {}'.format(patch_file).split() - self.run(patch_cmd, cwd=self.sourcedir) - open(patch_stamp, 'a').close() diff --git a/snap/plugins/x-qtbuilder.py b/snap/plugins/x-qtbuilder.py deleted file mode 100644 index 860cd448a..000000000 --- a/snap/plugins/x-qtbuilder.py +++ /dev/null @@ -1,204 +0,0 @@ -# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- -# -# Author: Marco Trevisan -# Copyright (C) 2017-2018 Canonical Ltd -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 3 as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import os -import shutil -import snapcraft - -from snapcraft.plugins import make - -class QtBuilderPlugin(make.MakePlugin): - - @classmethod - def schema(cls): - schema = super().schema() - - schema['properties']['configflags'] = { - 'type': 'array', - 'minitems': 1, - 'uniqueItems': False, - 'items': { - 'type': 'string', - }, - 'default': [], - } - - schema['properties']['qt-source-git'] = { - 'type': 'string' - } - - schema['properties']['qt-source-depth'] = { - 'type': 'integer', - 'default': 1 - } - - schema['properties']['qt-version'] = { - 'type': 'string' - } - - schema['properties']['qt-patches-base-url'] = { - 'type': 'string' - } - - schema['properties']['qt-patches-path'] = { - 'type': 'string' - } - - schema['properties']['qt-submodules'] = { - 'type': 'array', - 'minitems': 0, - 'uniqueItems': True, - 'items': { - 'type': 'string', - }, - 'default': [], - } - - schema['properties']['qt-extra-plugins'] = { - 'type': 'array', - 'minitems': 0, - 'uniqueItems': True, - 'items': { - 'type': 'object', - 'minitems': 0, - 'uniqueItems': True, - 'items': { - 'type': 'string', - }, - }, - 'default': [], - } - - schema['properties']['environment'] = { - 'type': 'array', - 'minitems': 0, - 'uniqueItems': True, - 'items': { - 'type': 'object', - 'minitems': 0, - 'uniqueItems': True, - 'items': { - 'type': 'string', - }, - }, - 'default': [], - } - - schema['required'].append('qt-source-git') - - schema['build-properties'].append('configflags') - - return schema - - @classmethod - def get_pull_properties(cls): - return [ - 'qt-version', - 'qt-patches-base-url', - 'qt-patches-path', - 'qt-submodules', - 'qt-extra-plugins', - ] - - def __init__(self, name, options, project): - super().__init__(name, options, project) - self.build_packages.extend(['g++', 'patch', 'perl', 'wget']) - self.options.source_depth = self.options.qt_source_depth - - if self.options.qt_version: - if self.options.qt_version[0] == 'v': - self.options.source_branch = self.options.qt_version - self.options.qt_version = self.options.qt_version[1:] - else: - self.options.source_branch = '.'.join( - self.options.qt_version.split('.')[:-1]) - - - def pull(self): - if not os.path.exists(os.path.join(self.sourcedir, '.git')) or \ - not os.path.exists(os.path.join(self.sourcedir, 'init-repository')): - shutil.rmtree(self.sourcedir, ignore_errors=True) - command = 'git clone {} {}'.format( - self.options.qt_source_git, self.sourcedir).split() - if self.options.source_branch: - command.extend(['--branch', str(self.options.source_branch)]) - if self.options.source_depth: - command.extend(['--depth', str(self.options.source_depth)]) - - self.run(command) - - command = 'perl init-repository --branch -f'.split() - if len(self.options.qt_submodules): - command.extend('--module-subset={}'.format( - ','.join(self.options.qt_submodules)).split()) - self.run(command, cwd=self.sourcedir) - - if self.options.qt_version: - self.run("git submodule foreach git checkout v{}".format( - self.options.qt_version).split(), self.sourcedir) - - patch_file_template = '${{name}}{}.diff'.format( - '_' + self.options.qt_version.replace('.', '_') \ - if self.options.qt_version else '') - - if self.options.qt_patches_base_url: - patch_uri_template = '{}/{}'.format( - self.options.qt_patches_base_url, patch_file_template) - - patch_cmd = 'git submodule foreach -q'.split() + \ - ['[ -e {touch_file} ] || ' \ - 'wget -q -O - {patch_uri_template} | patch -p1 && ' \ - 'touch {touch_file}'.format( - patch_uri_template=patch_uri_template, - touch_file='.snapcraft-qt-patched')] - - self.run(patch_cmd, cwd=self.sourcedir) - - if self.options.qt_patches_path: - patch_path_template = os.path.join( - os.getcwd(), self.options.qt_patches_path, patch_file_template) - - patch_cmd = 'git submodule foreach -q'.split() + \ - ['[ -e {patch} ] && git apply -v3 {patch} || true'.format( - patch=patch_path_template)] - - self.run(patch_cmd, cwd=self.sourcedir) - - for extra_plugin in self.options.qt_extra_plugins: - [framework] = list(extra_plugin) - - final_path = os.path.join(self.sourcedir, 'qtbase', 'src', - 'plugins', framework) - - for repo in extra_plugin[framework]: - repo_path = os.path.basename(repo) - if repo_path.endswith('.git'): - repo_path = repo_path[:-4] - - if not os.path.exists(os.path.join(final_path, repo_path)): - command = 'git clone {}'.format(repo).split() - self.run(command, cwd=final_path) - - def build(self): - env = {} - - for environ in self.options.environment: - [env_name] = list(environ) - env[env_name] = str(environ[env_name]) - - self.run(['./configure'] + self.options.configflags, env=env) - super().build() diff --git a/snap/scripts/telegram-launch b/snap/scripts/telegram-launch deleted file mode 100755 index 8fe62b1fe..000000000 --- a/snap/scripts/telegram-launch +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -default_downloaddir="$SNAP_USER_DATA/Telegram Desktop" - -if [ -d "$default_downloaddir" ] && [ ! -L "$default_downloaddir" ]; then - dest_downloaddir="$SNAP_USER_COMMON/$(basename "$default_downloaddir")" - if [ -d "$dest_downloaddir" ]; then - mv -v "$default_downloaddir/*" "$dest_downloaddir/" - rmdir "$default_downloaddir" - else - mv -v "$default_downloaddir" "$SNAP_USER_COMMON" - fi - ln -sv "$dest_downloaddir" "$default_downloaddir" -fi - -default_im_module="xim" - -if [ -n "$TELEGRAM_QT_IM_MODULE" ]; then - export QT_IM_MODULE="$TELEGRAM_QT_IM_MODULE" -elif [ -z "$QT_IM_MODULE" ] || [ "$QT_IM_MODULE" == "ibus" ]; then - export QT_IM_MODULE="$default_im_module" -fi - -exec desktop-launch Telegram $* diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 6461bba7b..0b4c5a3ac 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,438 +1,221 @@ name: telegram-desktop -version: git adopt-info: telegram -description: | - Telegram is a popular messaging protocol with encryption and security as - its key focus. - - Fast and secure desktop app, perfectly synced with your mobile phone. +icon: Telegram/Resources/art/icon512@2x.png +base: core18 grade: stable confinement: strict -version-script: | - set -x - 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[^-]\+,,')" - - echo $version - apps: telegram-desktop: - command: telegram-launch + command: bin/desktop-launch telegram-desktop common-id: org.telegram.desktop + desktop: share/applications/telegramdesktop.desktop environment: - DISABLE_WAYLAND: 1 - WAYLAND_DISPLAY: no-display - QTCOMPOSE: $SNAP/usr/share/X11/locale - HOME: "$SNAP_USER_COMMON" + # Use GTK3 cursor theme, icon theme and open/save file dialogs. + QT_QPA_PLATFORMTHEME: gtk3 plugs: - desktop - desktop-legacy - - gsettings - home - network - - network-bind - network-manager - pulseaudio - removable-media - unity7 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/usr/share/themes + target: $SNAP/data-dir/themes default-provider: gtk-common-themes icon-themes: interface: content - target: $SNAP/usr/share/icons + target: $SNAP/data-dir/icons default-provider: gtk-common-themes sound-themes: interface: content - target: $SNAP/usr/share/sounds + target: $SNAP/data-dir/sounds default-provider: gtk-common-themes parts: telegram: - plugin: gyp-cmake + plugin: cmake source: . source-type: git - parse-info: [lib/xdg/telegramdesktop.appdata.xml] - build-packages: - - libappindicator-dev - - libappindicator3-dev - - libenchant-dev - - libexif-dev - - libicu-dev - - liblzma-dev - - libssl-dev - - libdee-dev - - zlib1g-dev - gyp-file: Telegram/gyp/Telegram.gyp - build-type: 'Release' - artifacts: ['Telegram'] - environment: - - CC: gcc-8 - - CXX: g++-8 - organize: - Telegram: bin/Telegram - configflags: - - -Dapi_id=611335 - - -Dapi_hash=d524b414d21f4d37f08684c1df41ac9c - - -Dlinux_path_breakpad=$SNAPCRAFT_STAGE - - -Dlinux_path_range=$SNAPCRAFT_STAGE/range-v3 - - -Dlinux_path_ffmpeg=$SNAPCRAFT_STAGE - - -Dlinux_path_libexif_lib=$SNAPCRAFT_STAGE - - -Dlinux_path_openal=$SNAPCRAFT_STAGE - - -Dlinux_path_opus_include=$SNAPCRAFT_STAGE/include/opus - - -Dlinux_path_qt=$SNAPCRAFT_STAGE - - -Dlinux_path_va=$SNAPCRAFT_STAGE - - -Dlinux_path_vdpau=$SNAPCRAFT_STAGE - - -Dlinux_path_xkbcommon=$SNAPCRAFT_STAGE - - -Dlinux_lib_ssl=-lssl - - -Dlinux_lib_crypto=-lcrypto - - -Dlinux_lib_icu=-licuuc -licutu -licui18n - - -Dbuild_defines=TDESKTOP_DISABLE_AUTOUPDATE, - TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME, - TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION - - --depth=. - override-build: | - set -xe - snapcraftctl build - part_src=$SNAPCRAFT_PART_INSTALL/../src - snap_gui=$SNAPCRAFT_STAGE/../snap/gui - mkdir -vp $snap_gui - cp -v $part_src/lib/xdg/telegramdesktop.desktop $snap_gui - cp -v $part_src/Telegram/Resources/art/icon512@2x.png $snap_gui/icon.png - sed -i "s|^Icon=.*|Icon=\${SNAP}/meta/gui/icon.png|g" $snap_gui/telegramdesktop.desktop - after: - - breakpad - - ffmpeg - - gyp - - libva - - openal - - qt - - range-v3 - - gcc8 - - telegram-launcher: - plugin: dump - source: snap/scripts - organize: - telegram-launch: bin/telegram-launch - - desktop-integration: - plugin: nil - stage-packages: - - libappindicator3-1 - - libnotify4 - - libpulse0 - after: [desktop-gtk3] - stage: - - -./usr/share/fonts/** - - -./usr/share/themes/** - - -./usr/share/icons/** - - -./usr/share/sounds/** - - desktop-gtk3: - stage: - - -./usr/share/fonts/** - - -./usr/share/themes/** - - -./usr/share/icons/** - - -./usr/share/sounds/** - override-build: | - set -xe - snapcraftctl build - export XDG_DATA_DIRS=$SNAPCRAFT_PART_INSTALL/usr/share - update-mime-database $SNAPCRAFT_PART_INSTALL/usr/share/mime - - for dir in $SNAPCRAFT_PART_INSTALL/usr/share/icons/*/; do - if [ -f $dir/index.theme ]; then - gtk-update-icon-cache-3.0 -q $dir - fi - done - - libva: - source: https://github.com/01org/libva.git - source-depth: 1 - plugin: autotools - build-packages: - - libdrm-dev - - libegl1-mesa-dev - - libgl1-mesa-dev - - libx11-dev - - libxext-dev - - libxfixes-dev - configflags: - - --enable-static - prime: [-./*] - - libvdpau: - source: https://gitlab.freedesktop.org/vdpau/libvdpau.git - source-depth: 1 - source-branch: libvdpau-1.2 - plugin: autotools - build-packages: - - libx11-dev - - x11proto-dri2-dev - - libxext-dev - configflags: - - --enable-static - prime: [-./*] - - opus: - source: https://github.com/xiph/opus.git - source-depth: 1 - source-branch: v1.2.1 - plugin: autotools - prime: [-./*] - - ffmpeg: - source: https://github.com/FFmpeg/FFmpeg.git - source-depth: 1 - source-branch: release/3.4 - plugin: autotools - build-packages: - - libass-dev - - libfreetype6-dev - - libgpac-dev - - liblzma-dev - - libsdl1.2-dev - - libtheora-dev - - libtool - - libvorbis-dev - - libxcb1-dev - - libxcb-shm0-dev - - libxcb-xfixes0-dev - - pkg-config - - texi2html - - yasm - - zlib1g-dev - configflags: - - --prefix=/ - - --disable-debug - - --disable-programs - - --disable-doc - - --disable-everything - - --enable-gpl - - --enable-version3 - - --enable-libopus - - --enable-decoder=aac - - --enable-decoder=aac_latm - - --enable-decoder=aasc - - --enable-decoder=flac - - --enable-decoder=gif - - --enable-decoder=h264 - - --enable-decoder=h264_vdpau - - --enable-decoder=mp1 - - --enable-decoder=mp1float - - --enable-decoder=mp2 - - --enable-decoder=mp2float - - --enable-decoder=mp3 - - --enable-decoder=mp3adu - - --enable-decoder=mp3adufloat - - --enable-decoder=mp3float - - --enable-decoder=mp3on4 - - --enable-decoder=mp3on4float - - --enable-decoder=mpeg4 - - --enable-decoder=mpeg4_vdpau - - --enable-decoder=msmpeg4v2 - - --enable-decoder=msmpeg4v3 - - --enable-decoder=opus - - --enable-decoder=vorbis - - --enable-decoder=wavpack - - --enable-decoder=wmalossless - - --enable-decoder=wmapro - - --enable-decoder=wmav1 - - --enable-decoder=wmav2 - - --enable-decoder=wmavoice - - --enable-encoder=libopus - - --enable-hwaccel=h264_vaapi - - --enable-hwaccel=h264_vdpau - - --enable-hwaccel=mpeg4_vaapi - - --enable-hwaccel=mpeg4_vdpau - - --enable-parser=aac - - --enable-parser=aac_latm - - --enable-parser=flac - - --enable-parser=h264 - - --enable-parser=mpeg4video - - --enable-parser=mpegaudio - - --enable-parser=opus - - --enable-parser=vorbis - - --enable-demuxer=aac - - --enable-demuxer=flac - - --enable-demuxer=gif - - --enable-demuxer=h264 - - --enable-demuxer=mov - - --enable-demuxer=mp3 - - --enable-demuxer=ogg - - --enable-demuxer=wav - - --enable-muxer=ogg - - --enable-muxer=opus - after: - - libva - - libvdpau - - opus - prime: [-./*] - - openal: - source: https://github.com/kcat/openal-soft.git - source-depth: 1 - source-tag: openal-soft-1.19.1 - plugin: cmake - build-packages: - - oss4-dev - - portaudio19-dev - configflags: - - -DCMAKE_BUILD_TYPE=Release - - -DALSOFT_EXAMPLES=OFF - - -DALSOFT_TESTS=OFF - - -DALSOFT_UTILS=OFF - - -DLIBTYPE=STATIC - after: - - ffmpeg - prime: [-./*] - - libxkbcommon: - source: https://github.com/xkbcommon/libxkbcommon.git - source-depth: 1 - source-tag: xkbcommon-0.8.4 - plugin: autotools - build-packages: - - xutils-dev - - bison - - python-xcbgen - prime: [-./*] - - qt: - plugin: qtbuilder - qt-version: 5.12.5 - qt-source-git: https://code.qt.io/qt/qt5.git - qt-submodules: ['qtbase', 'qtimageformats'] - qt-patches-base-url: https://raw.githubusercontent.com/desktop-app/patches/master - qt-extra-plugins: - - platforminputcontexts: - - https://github.com/telegramdesktop/fcitx.git - - https://github.com/telegramdesktop/hime.git - - https://github.com/telegramdesktop/nimf.git - environment: - - CC: gcc-8 - - CXX: g++-8 - - QMAKE_CC: gcc-8 - - QMAKE_CXX: g++-8 + parse-info: [share/metainfo/telegramdesktop.appdata.xml] build-packages: + - gcc-8 + - g++-8 + - qtbase5-private-dev + - libayatana-appindicator3-dev + - libgtk-3-dev - libasound2-dev - - libdbusmenu-glib-dev - - libffi-dev + - libavcodec-dev + - libavformat-dev + - libavutil-dev + - libswscale-dev + - libswresample-dev + - liblz4-dev - liblzma-dev + - libminizip-dev + - libopenal-dev + - libopus-dev - libpulse-dev - libssl-dev - - libx11-xcb-dev - - libxcb-xkb-dev - - libxcb-icccm4-dev - - libxcb-image0-dev - - libxcb-keysyms1-dev - - libxcb-randr0-dev - - libxcb-render-util0-dev - - libxcb-sync-dev - - libxcb-util0-dev - - libxcb-xfixes0-dev - - libxcb1-dev - - libxrender-dev + - zlib1g-dev + stage-packages: + - qt5-image-formats-plugins + - libayatana-appindicator3-1 + - libasound2 + - libavcodec57 + - libavformat57 + - libavutil55 + - libswscale4 + - libswresample2 + - liblz4-1 + - liblzma5 + - libminizip1 + - libopenal1 + - libopus0 + - libpulse0 + - libssl1.1 + - zlib1g configflags: - - -prefix - - $SNAPCRAFT_STAGE - - -release - - -force-debug-info - - -opensource - - -confirm-license - - -qt-zlib - - -qt-libpng - - -qt-libjpeg - - -qt-harfbuzz - - -qt-pcre - - -qt-xcb - - -no-gtk - - -no-mirclient - - -system-freetype - - -fontconfig - - -no-opengl - - -static - - -dbus-runtime - - -openssl-linked - - -nomake - - examples - - -nomake - - tests + - -DCMAKE_C_COMPILER=gcc-8 + - -DCMAKE_CXX_COMPILER=g++-8 + - -DCMAKE_BUILD_TYPE=Release + - -DTDESKTOP_API_ID=611335 + - -DTDESKTOP_API_HASH=d524b414d21f4d37f08684c1df41ac9c + - -DDESKTOP_APP_USE_PACKAGED_FONTS=OFF + - -DDESKTOP_APP_USE_PACKAGED_RLOTTIE=OFF + - -DTDESKTOP_USE_PACKAGED_TGVOIP=OFF + 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=/share/icons/hicolor/512x512/apps/telegram.png|g' lib/xdg/telegramdesktop.desktop after: - - libxkbcommon - - gcc8 + - cmake + - desktop-qt5 + - enchant + - range-v3 + - xxhash + + spellchecking: + plugin: nil + stage-packages: + - hunspell-de-de + - hunspell-en-au + - hunspell-en-ca + - hunspell-en-gb + - hunspell-en-us + - hunspell-en-za + - hunspell-fr-classical + - hunspell-it + - hunspell-pl + - hunspell-es + - hunspell-pt-br + - hunspell-pt-pt + + desktop-qt5: + source: https://github.com/ubuntu/snapcraft-desktop-helpers.git + source-subdir: qt + plugin: make + make-parameters: ["FLAVOR=qt5"] + build-packages: + - build-essential + - qtbase5-dev + - dpkg-dev + stage-packages: + - libxkbcommon0 + - ttf-ubuntu-font-family + - dmz-cursor-theme + - light-themes + - adwaita-icon-theme + - gnome-themes-standard + - shared-mime-info + - libqt5gui5 + - libgdk-pixbuf2.0-0 + - libqt5svg5 # for loading icon themes which are svg + - try: [appmenu-qt5] # not available on core18 + - locales-all + - xdg-user-dirs + - fcitx-frontend-qt5 + + qt5-gtk-platform: + plugin: nil + stage-packages: + - qt5-gtk-platformtheme + + cmake: + source: "https://gitlab.kitware.com/cmake/cmake.git" + source-depth: 1 + source-branch: master + source-type: git + plugin: make + override-build: | + ${SNAPCRAFT_PART_SRC}/bootstrap \ + --parallel=${SNAPCRAFT_PARALLEL_BUILD_COUNT} \ + -- \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=/ \ + -DBUILD_TESTING=OFF + snapcraftctl build + build-packages: + - build-essential + - libssl-dev + - libncurses5-dev + stage-packages: + - libssl1.1 + - libncurses5 + - libtinfo5 prime: [-./*] - breakpad: - plugin: autotools-subsource - source: https://chromium.googlesource.com/breakpad/breakpad - source-type: git - source-commit: bc8fb886 - sub-sources: - - linux-syscall-support: - dest: src/third_party/lss - source: https://chromium.googlesource.com/linux-syscall-support - source-type: git - source-commit: a91633d1 - prime: [-./*] + enchant: + source: https://github.com/AbiWord/enchant.git + source-depth: 1 + source-tag: v2.2.7 + plugin: autotools + build-packages: + - libglib2.0-dev + - libhunspell-dev + stage-packages: + - libglib2.0-0 + - libhunspell-1.6-0 + configflags: + - --enable-relocatable + prime: [-./bin/*] range-v3: source: https://github.com/ericniebler/range-v3.git source-depth: 1 source-tag: 0.10.0 - plugin: nil - override-build: | - set -x - snapcraftctl build - mkdir $SNAPCRAFT_PART_INSTALL/range-v3 - cp -rv * $SNAPCRAFT_PART_INSTALL/range-v3 + plugin: cmake + configflags: + - -DRANGE_V3_TESTS=OFF + - -DRANGE_V3_EXAMPLES=OFF + - -DRANGE_V3_DOCS=OFF prime: [-./*] - gyp: - plugin: patched-python - source: https://chromium.googlesource.com/external/gyp - source-type: git - source-commit: 702ac58e47 - python-version: python2 - patches: - - Telegram/Patches/gyp.diff - prime: [-./*] - - # Since this is supposed to be built against ubuntu 16.04, we need to manually - # install gcc8, and this is a workaround to achieve this. - # This part can be safely removed when build.snapcraft.io will allow - # to build against 18.04. - gcc8: - plugin: nil - build-packages: - - libmpc-dev - - libcloog-ppl-dev - override-pull: | - set -x - echo "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main" | \ - sudo tee /etc/apt/sources.list.d/ubuntu-toolchain-r.list - sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 60C317803A41BA51845E371A1E9377A2BA9EF27F - sudo apt-get update \ - -o Dir::Etc::sourcelist="sources.list.d/ubuntu-toolchain-r.list" \ - -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0" - snapcraftctl pull - override-build: | - set -x - snapcraftctl build - sudo apt install gcc-8 g++-8 -o Debug::pkgProblemResolver=yes --no-install-recommends -y - sudo apt-mark auto gcc-8 g++-8 - sudo rm -f /etc/apt/sources.list.d/ubuntu-toolchain-r.list - prime: [-./*] + xxhash: + source: https://github.com/Cyan4973/xxHash.git + source-depth: 1 + source-tag: v0.7.2 + plugin: make + make-parameters: [PREFIX=] + prime: [-./bin/*]