Telegram.sh 2.71 KB
Newer Older
1 2 3 4 5 6 7
#!/bin/sh -x

# It will be run with two args: buildroot spec
BUILDROOT="$1"
SPEC="$2"

PRODUCT=Telegram
8
PRODUCTCUR=telegram-desktop
9
PKGNAME=$(basename $0 .sh)
10
PRODUCTDIR=/opt/Telegram
11

12 13
. $(dirname $0)/common.sh

14
# /usr/bin/Telegram
15
subst '1iConflicts:telegram-desktop' $SPEC
16
subst '1iConflicts:telegram-desktop-binary' $SPEC
17

18 19 20 21 22
for i in Telegram Telegram-beta ; do
    [ "$i"  = "$PKGNAME" ] && continue
    subst "1iConflicts:$i" $SPEC
done

23
# installing from tar, so we need fill some fields here
24
subst "s|^Group:.*|Group: Networking/Instant messaging|" $SPEC
25 26 27 28
subst "s|^License: unknown$|License: GPLv2|" $SPEC
subst "s|^URL:.*|URL: https://desktop.telegram.org/|" $SPEC
subst "s|^Summary:.*|Summary: Telegram Desktop messaging app|" $SPEC

29 30
add_bin_link_command
add_bin_link_command $PRODUCTCUR $PRODUCT
31

32 33 34 35 36
# Icons
iconname=$PRODUCT
url=https://github.com/telegramdesktop/tdesktop
for i in 16 32 48 64 128 256 512 ; do
    mkdir -p $BUILDROOT/usr/share/icons/hicolor/${i}x${i}/apps/
37
    epm tool eget -O $BUILDROOT/usr/share/icons/hicolor/${i}x${i}/apps/$iconname.png $url/raw/master/Telegram/Resources/art/icon$i.png || continue
38 39 40 41
    pack_file /usr/share/icons/hicolor/${i}x${i}/apps/$iconname.png
done


42 43
# Disable the official Telegram Desktop updater, creating menu entry (desktop file) and settings entries
# See https://github.com/telegramdesktop/tdesktop/issues/25718
44 45 46 47 48 49 50 51 52

# New way:
# commit 2be4641496f6f5efc7c18c2842ad00ddf51be43c
#Author: Ilya Fedin <fedin-ilja2010@ya.ru>
#Date:   Fri Jan 13 17:58:36 2023 +0400
#
#    Install launcher on every launch on Linux
# set DESKTOPINTEGRATION or disable update via set path to binary to /etc/tdesktop/externalupdater

53
mkdir -p "$BUILDROOT/etc/tdesktop"
54 55
# telegram checks with real path to the binary
echo "$PRODUCTDIR/$PRODUCT" >"$BUILDROOT/etc/tdesktop/externalupdater"
56
pack_dir /etc/tdesktop
57
pack_file /etc/tdesktop/externalupdater
58
#remove_file /opt/Telegram/Updater
59

60
# fixed above
61 62
# Hack against https://bugzilla.altlinux.org/42402
# We can't forbit creating a desktop file, so just hide it
63
#subst "s|Terminal=false|NoDisplay=true|" $BUILDROOT$PRODUCTDIR/Telegram
64 65 66 67

# TODO: tg.protocol
# https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=telegram-desktop-bin

68 69
# create desktop file
mkdir -p $BUILDROOT/usr/share/applications/
70
cat <<EOF >$BUILDROOT/usr/share/applications/org.telegram.desktop
71 72 73 74
[Desktop Entry]
Version=1.0
Name=Telegram Desktop
Comment=Official desktop version of Telegram messaging app
75 76
Exec=$PRODUCTCUR -- %u
Icon=$iconname
77 78 79 80 81 82 83
StartupWMClass=TelegramDesktop
Type=Application
Categories=Chat;Network;InstantMessaging;Qt;
MimeType=x-scheme-handler/tg;
Keywords=tg;chat;im;messaging;messenger;sms;tdesktop;
X-GNOME-UsesNotifications=true
EOF
84
pack_file /usr/share/applications/org.telegram.desktop
85

86
add_by_ldd_deps