summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: edb8931b711d771d4f98f0f4bcccbe370bd70473 (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
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
# Maintainer: grufo <madmurphy333 AT gmail DOT com>
# Contributor: redfish <redfish AT galactica DOT pw>
# Contributor: kertase <kertase AT gmail DOT com>
# Contributor: Sergej Pupykin <pupykin DOT s+arch AT gmail.com>
# Contributor: wahnby <wahnby AT yahoo DOT fr>

pkgname='gnunet-git'
_appname='gnunet'
pkgver='0.11.0.r26629.6339dc3bd'
pkgrel=1
pkgdesc="A framework for secure peer-to-peer networking"
arch=('x86_64')
url="http://gnunet.org"
license=('GPL')
provides=("${_appname}")
conflicts=("${_appname}")
depends=('libextractor' 'sqlite' 'gnurl'
	 'libmicrohttpd' 'jansson')
makedepends=('gettext' 'pkgconfig' 'autoconf' 'fakeuser-git'
	     'bluez-libs' 'python2' 'glpk' 'libpulse' 'opus')
optdepends=('bluez-libs'
	    'python2'
	    'glpk'
	    'libpulse'
	    'opus'
	    'python2-zbar')
install='gnunet.install'
backup=('etc/gnunetd.conf')
options=('!makeflags')

source=("git+https://gnunet.org/git/${_appname}.git"
        'gnunet.service')

md5sums=('SKIP'
         'a64f19ce71c02c200fa78ca2d1585bc8')

_fakeadd_error() {

	echo "NOTE: makepkg -R is not supported because it does not load libfakeuser."
	echo "      If pass -R, you will always see the following error message."
	echo
	echo "You must have a 'gnunet' user and group, and additionally a 'gnunetdns' group in"
	echo 'your system prior to building this package.'
	echo
	echo 'You can do:'
	echo
	echo '  groupadd -r gnunet'
	echo '  useradd -r -l -g gnunet -d /var/lib/gnunet gnunet'
	echo '  groupadd -r gnunetdns'

	return 1

}

pkgver() {

	cd "${_appname}"
	printf "'%s.r%s.%s'" \
		"$(grep 'AC_INIT' configure.ac | grep -o '[0-9]\(\.[0-9]\+\)\+')" \
		"$(git rev-list --count HEAD)" \
		"$(git rev-parse --short HEAD)"

}

prepare() {

	cd "${srcdir}/${_appname}"


	# zbar (required by gnunet-qr) only has bindings for python2, so we have to use python2
	# Not sure whether other parts of Gnunet fully support Python v3.0. It does build with v3.
	# NOTE: can't override in aclocal.m4 (that file is autogenerated)
	_redefine_py="m4_define_default([_AM_PYTHON_INTERPRETER_LIST],[python2])"
	sed -i "0,/^AM_PATH_PYTHON.*/s/^AM_PATH_PYTHON.*/$_redefine_py\n&/" configure.ac

	autoreconf -fi
	sed -i 's|contrib doc|doc|' Makefile.*
	[ -f Makefile ] || ./configure --prefix=/usr \
	--without-mysql

	# enable fakeadd under fakeroot environment
	export LD_PRELOAD='/usr/lib/fakeuser/libfakeuser.so'

}

package() {

	local _gnunet_guid=714
	local _gnunetdns_gid=715

	cd "${srcdir}/${_appname}"

	install -dm755 "${pkgdir}/etc"
	touch "${pkgdir}/etc/gnunetd.conf"

	# fakeadd
	getent group gnunet > /dev/null || fakeadd -G -n gnunet -g ${_gnunet_guid} || _fakeadd_error
	getent passwd gnunet > /dev/null || fakeadd -U -n gnunet -u ${_gnunet_guid} -g ${_gnunet_guid} -d /var/lib/gnunet || _fakeadd_error
	getent group gnunetdns > /dev/null || fakeadd -G -n gnunetdns -g ${_gnunetdns_gid} || _fakeadd_error
	install -dm755 "${pkgdir}/var/lib/gnunet"
	chown gnunet:gnunet "${pkgdir}/var/lib/gnunet"

	if ! getent group gnunet > /dev/null || ! getent passwd gnunet > /dev/null || ! getent group gnunetdns > /dev/null || [[ $(stat -c %u "${pkgdir}/var/lib/gnunet") -ne ${_gnunet_guid} ]]; then
		_fakeadd_error
	fi

	# build
	# ...I know, `make` should be inside `build()`... But we need the power of fakeadd+fakeroot *while* building!
	make
	make -C contrib

	# install
	make DESTDIR="${pkgdir}" install
	make DESTDIR="${pkgdir}" -C contrib install
	install -Dm0644 "${srcdir}/${_appname}.service" "${pkgdir}/usr/lib/systemd/system/${_appname}.service"

}