summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: a64aae2152fa05b255243332896e63a514526c22 (plain)
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
# Maintainer: Mike Kazantsev <mk.fraggod@gmail.com>

pkgname=telegram-tdlib-purple-minimal-git
pkgver=0.8.1.r518.1cc2a5d
pkgrel=2
pkgdesc='libpurple/pidgin Telegram plugin implemented using official tdlib client library, packaged for bitlbee, without voip and image-processing dependencies'
arch=(x86_64 aarch64)
url='https://github.com/BenWiederhake/tdlib-purple'
license=(GPL2)
depends=(libpurple)
makedepends=(cmake git gperf)
conflicts=(telegram-tdlib-purple)
provides=(telegram-tdlib-purple="${pkgver}")
source=( $pkgname::git+"$url" td::git+https://github.com/tdlib/td.git )
sha256sums=( SKIP SKIP )

pkgver() {
	cd $pkgname
	ver=$(awk '/^\s*set\(VERSION / {sub(")","",$2); print $2}' CMakeLists.txt)
	[[ -n "$ver" ]] || { echo >&2 "ERROR: Failed to parse version from CMakeLists.txt"; exit 1; }
	printf "%s.r%s.%s" "$ver" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
	cd $pkgname

	# build_and_install.sh is the proper way to build this, with the right tdlib version/commit
	# But it needs a bunch of tweaks for this build, so not used here, only grepped for that commit
	td_commit=( $(grep -Po '(?<=git checkout )\S+' build_and_install.sh ||:) )
	[[ ${#td_commit[@]} -eq 1 ]] || {
		echo >&2 "ERROR: failed to grep compatible libtd commit in build_and_install.sh script"; exit 1; }
	td_commit=${td_commit[0]} td_dir="$(realpath "$srcdir")"/td

	# Build specific tdlib version - can be long, use "makepkg -e" to avoid rebuilding from scratch
	pushd "$td_dir"
		[[ $(git rev-parse "$td_commit") = $(git rev-parse HEAD) ]] || git reset --hard "$td_commit"
		mkdir -p build && pushd build
			cmake -DCMAKE_BUILD_TYPE=Release ..
			make
			make install DESTDIR=destdir
	popd; popd

	# Build and statically link libtelegram-tdlib.so against tdlib above
	mkdir -p build && pushd build
	cmake \
		-DTd_DIR="$td_dir"/build/destdir/usr/local/lib/cmake/Td/ \
		-DNoVoip=True -DNoWebp=True -DNoLottie=True ..
	make
	popd
}

package() {
	cd $pkgname
	install -Dm755 -t "$pkgdir$(pkg-config --variable plugindir purple)" build/libtelegram-tdlib.so
}