summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: a235112e05f51dbe68c2306d31087d0b871f35d9 (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
# 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.12.2.r28750.b03978816'
pkgrel=1
pkgdesc="A framework for secure peer-to-peer networking"
arch=('any')
url="http://gnunet.org"
license=('GPL')
provides=("${_appname}")
conflicts=("${_appname}")
depends=('gmp' 'libgcrypt' 'libextractor' 'sqlite' 'gnurl'
	 'libmicrohttpd' 'libunistring' 'libidn' 'jansson')
makedepends=('gettext' 'pkgconfig' 'autoconf' 'fakeuser-git'
	     'bluez-libs' 'python' 'glpk' 'libpulse' 'opus')
optdepends=('bluez-libs'
	    'python'
	    'glpk'
	    'libpulse'
	    'opus')
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 "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}"
	./bootstrap
	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"

}