summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: b165d167421e285db24887ac88da2638b07c5f5b (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Maintainer: Alex Dewar <alex.dewar@gmx.co.uk>
pkgname=arsdk3
pkgver=3.14.0
pkgrel=6
pkgdesc="The SDK for Parrot Bebop drones"
arch=('x86_64')
url="http://developer.parrot.com/docs/SDK3/"
license=('custom')
source=('git+https://github.com/Parrot-Developers/arsdk_manifests')
options=(!emptydirs staticlibs)
md5sums=('SKIP')
makedepends=('repo' 'python2')

prepare() {
	cd "$srcdir"
	yes|repo init -u arsdk_manifests -b 4b50e865427e6f2f2f19be1d4c55ab87a03b804a \
			--no-clone-bundle --depth=1
	repo sync
}

build() {
	# Make sure to use python 2 with scripts: they fail with v3.6+
	mkdir "$srcdir/bin" || true
	ln -s /usr/bin/python2 "$srcdir/bin/python"
	export PATH="$srcdir/bin":$PATH

	"$srcdir"/build.sh -p arsdk-native -t build-sdk -j
}

package() {
	cd "$srcdir"/out/arsdk-native/staging

	_target="$pkgdir"/opt/$pkgname
	install -d $_target
	install -Dm 755 native-wrapper.sh "$_target"

	cd usr
	cp -r bin include lib "$_target"

	cd share
	install -d "$pkgdir"/usr/share
	cp -r mavlink "$pkgdir"/usr/share/mavlink
	mkdir "$_target"/share
	cp -r aclocal "$_target"/share/aclocal

	# simplify directory structure, but add symlinks for compatibility
	cd "$_target"
	ln -s . usr
	install -d out/arsdk-native
	ln -s ../.. out/arsdk-native/staging

	# install license
	install -Dm 644 "$srcdir"/packages/ARSDKBuildUtils/LICENSE.md "$pkgdir"/usr/share/licenses/LICENSE

	# copy samples
	install -d samples
	cp -r "$srcdir"/packages/Samples/Unix/* samples

	# fix up hard-coded paths
	cd $_target
	_srcpath=`realpath "${srcdir}/out/arsdk-native/staging/usr"`
	sed -i "s|$_srcpath|/opt/$pkgname|g" bin/curl-config
	sed -i "s|`realpath "${srcdir}/out/arsdk-native/staging/"`|/opt/$pkgname|g" bin/curl-config
	for f in lib/pkgconfig/*; do
		sed -i "s|$_srcpath|/opt/$pkgname|g" "$f"
	done

    # set ARSDK_ROOT environment variable
    install -d "${pkgdir}"/etc/profile.d
    echo export ARSDK_ROOT_DIR=/opt/arsdk3 > "${pkgdir}"/etc/profile.d/arsdk3.sh
}