aboutsummaryrefslogtreecommitdiffstats
path: root/testing/kopano-webapp/APKBUILD
blob: a99a8bd1f6280d17180d0a6cc3784fd380480451 (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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# Maintainer: Noel Kuntze <noel.kuntze@contauro.com>
pkgname=kopano-webapp
pkgdesc="WebApp for Kopano"
pkgver=5.2.0
pkgrel=4
# ppc64le, mips64 and riscv64 blocked by libmdbx -> kopano-core
 arch="noarch !ppc64le !mips64 !riscv64"
url="http://www.kopano.com/"
license="AGPL-3.0-only"
options="!check" # No test suite
depends="php7 php7-fpm php7-json php7-gettext php7-iconv php7-session php7-openssl php7-simplexml php7-soap"
# kopano-core necessary for mapi php module
makedepends="apache-ant openjdk8 kopano-core bash gettext-dev libxml2-utils php7-soap"
replaces="zarafa-webapp"
subpackages="
	kopano-webapp-contactfax:simple_plugin_splitfunc:noarch
	kopano-webapp-gmaps:simple_plugin_splitfunc:noarch
	kopano-webapp-pimfolder:simple_plugin_splitfunc:noarch
	kopano-webapp-src:_src:noarch
"
# 	 kopano-webapp-passwd:kopano_webapp_passwd_splitfunc

pkgusers="kopano-webapp"
pkggroups="kopano-webapp"

install="kopano-webapp.pre-install"

source="kopano-webapp-$pkgver.zip::https://stash.kopano.io/rest/api/latest/projects/KW/repos/kopano-webapp/archive?at=refs%2Ftags%2Fv$pkgver&format=zip
	nginx-location.conf
	php-fpm.example.conf
	kopano-webapp.conf
	kopano-webapp.ini
	compress-static
	0001-Fix-fatal-errors-in-translation-files.patch
"

#	0001-Remove-error-dev-stdout.patch"
# No passwd plugin for now because of no known good upstream and untested code
#kopano-webapp-passwd-$_pkgverpasswd.tar.gz::https://github.com/silentsakky/zarafa-webapp-passwd/archive/$_commithashpasswd.tar.gz

builddir="$srcdir/"

prepare() {
	olddir="$builddir"
	builddir="$srcdir/$pkgname"
	default_prepare
	builddir="$olddir"
}

#helper function
unpack() {
	local u
	verify
	initdcheck
	mkdir -p "$srcdir"
	local gunzip="$(command -v pigz || echo gunzip)"
	[ $gunzip = "/usr/bin/pigz" ] && gunzip="$gunzip -d"
	for u in $source; do
		local s
		local filename="$(filename_from_uri $u)"
		local new_root_dir="$builddir/${filename%%-[0-9]*}"
		if is_remote "$u"; then
			s="$SRCDEST/$filename"
		else
			s="$startdir/$u"
		fi
		case "$s" in
			*.tar)
				msg "Unpacking $s..."
				mkdir -p "$new_root_dir"
				tar -C "$new_root_dir" -xf "$s" ;;
			*.tar.gz|*.tgz)
				msg "Unpacking $s..."
				mkdir -p "$new_root_dir"
				$gunzip -c "$s" | tar -C "$new_root_dir" -x ;;
			*.tar.bz2)
				msg "Unpacking $s..."
				tar -C "$new_root_dir" -jxf "$s" ;;
			*.tar.lz)
				msg "Unpacking $s..."
				tar -C "$new_root_dir" --lzip -xf "$s" ;;
			*.tar.lzma)
				msg "Unpacking $s..."
				unlzma -T 0 -c "$s" | tar -C "$new_root_dir" -x  ;;
			*.tar.xz)
				msg "Unpacking $s..."
				local threads_opt
				if [ "$(readlink -f "$(command -v unxz)")" != "/bin/busybox" ]; then
					threads_opt="--threads=0"
				fi
				unxz $threads_opt -c "$s" | tar -C "$new_root_dir" -x ;;
			*.zip)
				msg "Unpacking $s..."
				unzip -n -q "$s" -d "$new_root_dir" ;;
		esac
	done
}

build() {
	# create translations, compress javascript-files
	cd kopano-webapp/
	ant deploy
	ant deploy-plugins
	# antdeploy-plugins leads to errors
	# execution one by one
	cd "$srcdir"
	for f in kopano-webapp-*; do
		if [ -d "$f" ]; then
			dest="kopano-webapp/plugins/${f//kopano-webapp-/}"
			test="$(find . -name "$f/$f-*" 2>/dev/null | head -n 1)"
			case "${f//kopano-webapp-/}" in
				spellchecker-languagepack-italian)
				dest=kopano-webapp/plugins/spellchecker-languagepack-italian-it
				;;
				files-backend-owncloud)
				dest=kopano-webapp/plugins/filesbackendOwncloud
				;;
				files-backend-smb)
				dest=kopano-webapp/plugins/filesbackendSMB
				;;
				fetchmail)
				mv "$f"/*/ "$dest"
				;;
				*)
				;;
			esac
			if [ -d "$test" ]; then
				mv "$test" "$dest"
			else
				mv "$f" "$dest"
			fi
			cd "$dest"*
			ant deploy -Droot-folder="$(pwd)/../../" -Dtarget-folder="$(pwd)/../../deploy/plugins"
			cd "$srcdir"
		fi
	done
}
package() {
	# application
	cd "$srcdir/kopano-webapp/deploy"
	install -dm 755 "$pkgdir/usr/share/webapps/$pkgname/"

	cp -r -- * "$pkgdir/usr/share/webapps/$pkgname/"
	cp "$srcdir/kopano-webapp/.htaccess" "$pkgdir/usr/share/webapps/$pkgname/"
	rm -R -- "$pkgdir/usr/share/webapps/$pkgname/plugins/"*

	# set version
	echo "$pkgver" > "$pkgdir/usr/share/webapps/$pkgname/version"
	## precompress for nginx
	find "$pkgdir/usr/share/webapps/$pkgname" -type f -exec "$srcdir/compress-static" "{}" \;
	## config examples
	install -dm 0750 -g kopano-webapp "$pkgdir/etc/webapps/$pkgname/"
	install -Dm 0644 -g kopano-webapp "$srcdir/php-fpm.example.conf" "$srcdir/nginx-location.conf" "$pkgdir/etc/webapps/$pkgname/"
	install -Dm 0644 -g kopano-webapp "$srcdir/kopano-webapp.conf" "$pkgdir/etc/webapps/$pkgname/apache.example.conf"
	install -Dm 0644 -g kopano-webapp "$srcdir/nginx-location.conf" "$pkgdir/etc/webapps/$pkgname/nginx.example.conf"
	## config mains
	install -Dm 0644 -g kopano-webapp config.php.dist "$pkgdir/etc/webapps/$pkgname/config.php"
	sed -i 's%define("DEBUG_DUMP_FILE", BASE_PATH . "debug.txt");%define("DEBUG_DUMP_FILE",	"/var/log/kopano-webapp/debug.txt");%g' debug.php.dist

	sed -i -e 's|\(\"DEBUG_LOADER\", \).*$|\1LOAD_RELEASE);|' debug.php.dist
	install -Dm 0644 debug.php.dist "$pkgdir/etc/webapps/$pkgname/debug.php.dist"
	ln -sf "/etc/webapps/$pkgname/config.php" "$pkgdir/usr/share/webapps/$pkgname/config.php"
	ln -sf "/etc/webapps/$pkgname/debug.php" "$pkgdir/usr/share/webapps/$pkgname/debug.php"
	## php
	install -Dm 0644 "$srcdir/$pkgname.ini" "$pkgdir/etc/php7/conf.d/$pkgname.ini"
	## php-fpm
	install -Dm 0644 "$srcdir/$pkgname.conf" "$pkgdir/etc/php7/php-fpm.d/$pkgname.conf"
	# /var/lib
	install -dm 0770 -g kopano-webapp "$pkgdir/var/lib/$pkgname/" "$pkgdir/var/lib/$pkgname/plugins" "$pkgdir/var/log/$pkgname"
	install -dm 0770 -g kopano-webapp "$pkgdir/var/lib/$pkgname/tmp"
	touch "$pkgdir/var/log/$pkgname/debug.txt"
	ln -sf "/var/log/$pkgname/debug.txt" "$pkgdir/usr/share/webapps/$pkgname/debug.txt"
	chown root:kopano-webapp "$pkgdir/usr/share/webapps/$pkgname"
	chmod 750 "$pkgdir/usr/share/webapps/$pkgname"
	chmod 660 "$pkgdir/var/log/$pkgname/debug.txt"
	chown root:kopano-webapp "$pkgdir/var/log/$pkgname/debug.txt"
	# fix access
	chmod 644 "$pkgdir/usr/share/webapps/kopano-webapp/client/kopano.js.map"
	# copy dompurify
	install -dm 755 "$pkgdir/usr/share/webapps/kopano-webapp/client/dompurify"
	# we're currently in srcdir/kopano-webapp/deploy
	install -Dm 644 ../client/dompurify/*.js* "$pkgdir/usr/share/webapps/kopano-webapp/client/dompurify/"
	chmod 0755 "$pkgdir/usr/share/webapps/$pkgname/"
}

simple_plugin_splitfunc() {
	depends="kopano-webapp"
	package_plugin
}
# FUNCTIONS
package_plugin() {
	: "${pluginname:="${subpkgname//kopano-webapp-/}"}"
	echo "Pluginname: $pluginname" >&2

	echo "Packaging $pkgname with pluginname $pluginname" >&2
	cd "$srcdir/kopano-webapp/deploy/plugins/$pluginname/"
	# /usr/share
	install -dm 755 "$subpkgdir/usr/share/webapps/kopano-webapp/plugins/$pluginname/"
	cp -R -- * "$subpkgdir/usr/share/webapps/kopano-webapp/plugins/$pluginname/"
	rm -f "$subpkgdir/usr/share/webapps/kopano-webapp/plugins/$pluginname/config.php"
	"$srcdir/compress-static" "$subpkgdir/usr/share/webapps/kopano-webapp/plugins/$pluginname/"
	# /var/lib
	install -dm 0700 -o kopano-webapp -g root "$subpkgdir/var/lib/kopano-webapp/plugins/$pluginname"
	# /etc
	if [ -e "config.php" ]; then
		## perform settings
		# convert windows line break to unix: http://stackoverflow.com/questions/11680815/removing-windows-newlines-on-linux-sed-vs-awk
		sed -i -e $'s/\r//' config.php
		install -dm 0750 -g kopano-webapp "$subpkgdir/etc/webapps/kopano-webapp/plugins/$pluginname/"
		## config mains
		install -m 0750 -g kopano-webapp config.php "$subpkgdir/etc/webapps/kopano-webapp/plugins/$pluginname/config.php"
		ln -sf "/etc/webapps/kopano-webapp/plugins/$pluginname/config.php" "$subpkgdir/usr/share/webapps/kopano-webapp/plugins/$pluginname/config.php"
		## config examples
		install -m 0750 "$subpkgdir/etc/webapps/kopano-webapp/plugins/$pluginname/config.php" "$subpkgdir/etc/webapps/kopano-webapp/plugins/$pluginname/config.example.php"
	fi
	if [ -e "$srcdir/$pluginname.ini" ];	then
	  ## php
	  mkdir -p "$subpkgdir/etc/php/conf.d"
	  cp "$srcdir/$pluginname.ini" "$subpkgdir/etc/php/conf.d"
	fi
}

_src() {
	pkgdesc="kopano-webapp (sources)"
	destdir="$subpkgdir/usr/share/src/"
	mkdir -p "$destdir"
	cp -R "$srcdir/kopano-webapp/" "$destdir"
	cd "$destdir/kopano-webapp/"
	ant clean
	# everything using the -src package requires tools. Saves some seconds at build time for those packages
	ant tools
}

sha512sums="
b81a19e90da8498f94033b76e3020215f152ec4cd1f86a0545964a26f9b8d8e2e68745a4ca70d9efa7ea73154e6ae8d40a9a7b718377541864ecfd1d72f51487  kopano-webapp-5.2.0.zip
849f08412c6754603cf6d31866ae0b257719530861fcb40fd6acc4530576da59c45792eecf0ff483de41398401a21f1b20e36f1183c8cfbb88053b1b8bd603f4  nginx-location.conf
bad70098b919c4cacce3152b276da489d7a36ca195b607508ad316211401dc98f07433ef505deb82a91388993e58b398cce2bc3eb295cf812362bae96b40fb35  php-fpm.example.conf
bdfe3960f88c776264e4caae47404a3647508f545f915a5aa205d486415d32c5ac89f8b4dbd9905a0b0751ec0ed42a2aef690cf8bca20f66e1f322141fad0f01  kopano-webapp.conf
062103e4ebf63c5dc4589d25e03f5ebe1df711613d5ea27a27265f3041832677ed384a16460e2bf8905c59f800abc84ef30a70512738c2cb335b76d275332ce8  kopano-webapp.ini
a9421b4206f06ec9e61a79fad5907b3616d030386585ee06af8fc20d376b2023e0ca65fa20ef290029d3a0eb523f6ef8ed3d7a8be48a5340285ed2f004d99f9c  compress-static
f4d77690324eff874c22ff92a3717cc719fd66c0295baf60213cd8fbaa59110a8c4ca238caae9c36d4e606cbe56c7462c18225f917aaebac42b45e6b7683f0df  0001-Fix-fatal-errors-in-translation-files.patch
"