Telegram.sh 2.48 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 9
PRODUCTCUR=telegram-desktop
PRODUCTDIR=/opt/Telegram
10

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

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

17
subst "s|^Group:.*|Group: Networking/Instant messaging|" $SPEC
18 19 20 21
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

22 23 24

# move package to /opt
ROOTDIR=$(basename $(find $BUILDROOT -mindepth 1 -maxdepth 1 -type d))
25
mkdir $BUILDROOT/opt
26 27
mv $BUILDROOT/$ROOTDIR $BUILDROOT$PRODUCTDIR
subst "s|\"/$ROOTDIR/|\"$PRODUCTDIR/|" $SPEC
28

29
# add binary to the search path
30
mkdir -p $BUILDROOT/usr/bin/
31
ln -s $PRODUCTDIR/Telegram $BUILDROOT/usr/bin/$PRODUCT
32
subst "s|%files|%files\n/usr/bin/$PRODUCT|" $SPEC
33 34
ln -s $PRODUCTDIR/Telegram $BUILDROOT/usr/bin/$PRODUCTCUR
subst "s|%files|%files\n/usr/bin/$PRODUCTCUR|" $SPEC
35

36 37 38 39 40
# 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/
41
    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
42 43 44 45 46 47 48 49 50 51
    pack_file /usr/share/icons/hicolor/${i}x${i}/apps/$iconname.png
done


# Disable the official Telegram Desktop updater
mkdir -p "$BUILDROOT/etc/tdesktop"
echo "$PRODUCTCUR" >"$BUILDROOT/etc/tdesktop/externalupdater"
pack_file /etc/tdesktop/externalupdater
remove_file /opt/Telegram/Updater

52 53 54
# Hack against https://bugzilla.altlinux.org/42402
# We can't forbit creating a desktop file, so just hide it
subst "s|Terminal=false|NoDisplay=true|" $BUILDROOT$PRODUCTDIR/Telegram
55 56 57 58

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

59 60 61 62 63 64 65
# create desktop file
mkdir -p $BUILDROOT/usr/share/applications/
cat <<EOF >$BUILDROOT/usr/share/applications/$PRODUCT.desktop
[Desktop Entry]
Version=1.0
Name=Telegram Desktop
Comment=Official desktop version of Telegram messaging app
66 67
TryExec=$PRODUCTDIR/Telegram
Exec=$PRODUCTDIR/Telegram -- %u
68 69 70 71 72 73 74 75 76 77
Icon=$PRODUCT
Terminal=false
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
subst "s|%files|%files\n/usr/share/applications/$PRODUCT.desktop|" $SPEC