aboutsummaryrefslogtreecommitdiffstats
path: root/testing/telegram-desktop/APKBUILD
blob: e6f4f864c9c2a2e1f96368a762aaa786aaed0926 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# Maintainer: Alex Raschi <raschi.alex@gmail.com>
pkgname=telegram-desktop
pkgver=1.6.7
_pkgurl="https://github.com/telegramdesktop/tdesktop.git"
# https://github.com/telegramdesktop/tdesktop/blob/v$pkgver/docs/building-cmake.md
_gypver=702ac58e477214c635d9b541932e75a95d349352
_gypurl="https://chromium.googlesource.com/external/gyp"
_rangever=0.5.0
_rangeurl="https://github.com/ericniebler/range-v3.git"
pkgrel=0
pkgdesc="Telegram Desktop messaging app"
url="https://desktop.telegram.org/"
arch="all !s390x"
license="GPL-3.0-or-later WITH OpenSSL"
depends="qt5-qtimageformats"
makedepends="cmake
	zlib-dev
	opus-dev
	libva-dev
	libvdpau-dev
	ffmpeg-dev
	portaudio-dev
	openal-soft-dev
	openssl-dev
	libxkbcommon-dev
	qt5-qtbase-dev
	libexif-dev
	xz-dev
	minizip-dev
	alsa-lib-dev
	libexecinfo-dev
	python2
	grep"
source="http://dev.alpinelinux.org/archive/$pkgname/$pkgname-$pkgver.tar.gz
	libtgvoip.patch
	musl.patch
	no-gtk2.patch
	no-pulse.patch
	tdesktop.patch
	xdg.patch
	ppc64le-enable-arch.patch
	system-wide-fonts.patch"
builddir="$srcdir/$pkgname-$pkgver"
_reldir="$builddir/out/Release"

snapshot() {
	local libs="$builddir"/Libraries

	mkdir -p "$srcdir"
	cd "$srcdir"
	git clone --recurse-submodules "$_pkgurl" -b "v$pkgver" "$builddir"

	# clone also gyp and range-v3
	mkdir "$libs"
	cd "$libs"
	git clone --recurse-submodules "$_gypurl" -b "master" gyp
	git clone --recurse-submodules "$_rangeurl" -b "$_rangever" range-v3
	cd gyp
	# chromium.googlesource.com doesn't support cloning commits
	git reset --hard "$_gypver"

	cd "$srcdir"
	find "$builddir" -name .git -exec rm -rf {} +
	# git archive doesn't support submodules
	tar czf "$builddir".tar.gz "${builddir##*/}"
	scp "$builddir".tar.gz dev.alpinelinux.org:/archive/$pkgname/
}

prepare() {
	cd "$builddir/Telegram/ThirdParty"
	rm -rf minizip # we have this system-wide

	cd "$builddir/Libraries"
	patch -p1 -i "$builddir"/Telegram/Patches/gyp.diff -d "gyp"

	default_prepare
}

build() {
	cd "$builddir/Telegram/gyp"
	export CPPFLAGS="$CPPFLAGS -Winvalid-pch"
	export CXXFLAGS="$CXXFLAGS -Winvalid-pch"

	# https://git.archlinux.org/svntogit/community.git/tree/trunk/PKGBUILD?h=packages/telegram-desktop#n80
	../../Libraries/gyp/gyp \
		-Dapi_id=17349 \
		-Dapi_hash=344583e45741c457fe1862106095a5eb \
		-Dbuild_defines="TDESKTOP_DISABLE_CRASH_REPORTS,TDESKTOP_DISABLE_AUTOUPDATE,TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME,TDESKTOP_DISABLE_GTK_INTEGRATION,TDESKTOP_DISABLE_DESKTOP_FILE_GENERATION" \
		-Gconfig=Release \
		--depth=. \
		--generator-output=../.. \
		-Goutput_dir=out \
		Telegram.gyp \
		--format=cmake

	cd "$_reldir"
	printf '%s\n' 'set_target_properties(Telegram PROPERTIES SKIP_BUILD_RPATH TRUE)' >> CMakeLists.txt

	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
		-DCMAKE_C_FLAGS="$CFLAGS" \
		-DCMAKE_ASM_COMPILER=as \
		${CMAKE_CROSSOPTS}
	make
}

check() {
	local test

	cd "$_reldir"
	for test in tests_*; do
		./"$test"
	done
}

package() {
	local size

	cd "$_reldir"
	mkdir -p "$pkgdir"/usr/bin
	mv Telegram "$pkgdir"/usr/bin/telegram-desktop

	cd "$builddir"
	mkdir -p "$pkgdir"/usr/share/applications
	mv lib/xdg/telegramdesktop.desktop "$pkgdir"/usr/share/applications/telegram-desktop.desktop

	mkdir -p "$pkgdir"/usr/share/kservices5
	mv lib/xdg/tg.protocol "$pkgdir"/usr/share/kservices5

	cd Telegram/Resources/art
	mkdir -p "$pkgdir"/usr/share/icons/hicolor
	for size in 16 32 48 64 128 256 512; do
		mkdir -p "$pkgdir"/usr/share/icons/hicolor/"$size"x"$size"/apps
		mv icon"$size".png "$pkgdir"/usr/share/icons/hicolor/"$size"x"$size"/apps/telegram.png
	done
}

sha512sums="7a6775c42869617789862594a0665b2b9e6a1b3a05162f3c684a0fcc9960f608404a0f21f1edea261ab01e0bc0fa843a37e0cf1b0c189f3d5593cbe1abd8bcf8  telegram-desktop-1.6.7.tar.gz
9ee0dbc4b04454a2f440daa381df765616962e8e8c4330e96851dbc5f2a283da687282d666d2667aac67c3467d2079a94e4fef358dbb18eb24a064d55adc7a40  libtgvoip.patch
fc672d8168f6b2807e596570bc57f3b89296891b5d62b8e12b38193ed4919e4eb17efd72691c4086fb0ff4383de54695a9faf9874a0727a0980ef35e5ca4bee7  musl.patch
cb01655dd097b68e89b15e6e4b1f6da10c52e8bec681eeef9807ca376283b10cb3da34acc976c790f3c8dea05acbef1ba1967612920a2e4acb3b9da79e251a0d  no-gtk2.patch
9df70f5057fd9938cab87529693ad9617da0fdbb9084ff57395cd540343a0dcc1ecfba4f868b0043b252fe1aca33d0d214fb07931860296e66fbf11825f95fb9  no-pulse.patch
cdcc343e8507aed807ffb683f2b728db78c3b981a765746bbda59a97c00b373bfeb13c4251e36e8bc78c84728e91f964eb9d31616b4082393e074d7c12b44454  tdesktop.patch
8de8c0508177da5fcac4f2dcee4d8baef4b99f74f1dca296567bc3689a6bd17a47c1c945df504abc8811b82a687010d0709503c7c32e47d2ebb1cf0e374c80c5  xdg.patch
3647ad5fff6326ba9c75fa98189a08c0909af8d1c2b704c8c62fd9da6603f5162af3176c37daa67eb5896bebe3814bf1fd66b9e93c78cbd9b439e472d0db4b44  ppc64le-enable-arch.patch
ce6be003220267bac5483caf8302b492e1581892bc36d35a61236ebf9f9d766b8bd2159557a1c36256aa85f461797a38bfaae57b12da7a72101b21c0b17ed653  system-wide-fonts.patch"