# Con#tributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
setvar pkgname = 'patchwork'
setvar pkgver = '1.1.3'
setvar pkgrel = '0'
setvar pkgdesc = ""Web-based patch tracking system""
setvar url = ""https://github.com/getpatchwork/patchwork""
setvar arch = ""noarch""
setvar license = ""GPL""
setvar depends = ""py-django py-django-registration git py-psycopg2""
setvar subpackages = ""$pkgname-doc $pkgname-uwsgi-apache2:apache2_wsgi $pkgname-uwsgi-nginx:nginx_wsgi $pkgname-mysql
	$pkgname-postgresql pwclient:pwclient""
setvar source = ""$pkgname-$pkgver.tar.gz::https://github.com/getpatchwork/$pkgname/archive/v$pkgver.tar.gz
	0001-support-busybox-readlink.patch
	0002-remove-uneeded-bashism-from-tools-and-change-path.patch
	nginx-uwsgi-patchwork-conf.ini
	nginx-patchwork.conf""

setvar builddir = ""$srcdir"/$pkgname-$pkgver"

proc build {
	cd $builddir
	return 0
}

proc package {
	cd $builddir
	mkdir -p "$pkgdir"/usr/share/webapps/$pkgname
	install -Dm644 COPYING \
		"$pkgdir"/usr/share/doc/$pkgname/COPYING
	rm -f COPYING
	install -Dm644 patchwork/settings/production.example.py \
		"$pkgdir"/etc/$pkgname/production.py
	mv * "$pkgdir"/usr/share/webapps/$pkgname
	cd "$pkgdir"/usr/share/webapps/patchwork/patchwork/settings
	ln -sf /etc/patchwork/production.py
}

proc apache2_wsgi {
	setvar pkgdesc = ""$pkgname apache2 wsgi support""
	setvar depends = ""apache2 apache2-mod-wsgi""
	setvar replaces = ""$pkgname-apache2-wsgi""
	setvar install_if = ""$pkgname=$pkgver-r$pkgrel apache2-mod-wsgi""
	install -Dm644 "$pkgdir"/usr/share/webapps/patchwork/lib/apache2/patchwork.wsgi.conf \
		"$subpkgdir"/etc/apache2/conf.d/patchwork.wsgi.conf
}

proc nginx_wsgi {
	setvar pkgdesc = ""$pkgname nginx wsgi support""
	setvar depends = ""nginx uwsgi-python""
	setvar replaces = ""$pkgname-nginx_wsgi""
	setvar install_if = ""nginx patchwork uwsgi""
	install -Dm644 "$srcdir"/nginx-patchwork.conf \
		"$subpkgdir"/etc/nginx/conf.d/patchwork.conf
	install -Dm644 "$srcdir"/nginx-uwsgi-patchwork-conf.ini \
		"$subpkgdir"/etc/uwsgi/conf.d/patchwork.ini
}

proc mysql {
	setvar pkgdesc = ""$pkgname mysql support""
	setvar depends = ""py-mysqldb""
	mkdir -p $subpkgdir
}

proc postgresql {
	setvar pkgdesc = ""$pkgname postgresql support""
	setvar depends = ""py-psycopg2""
	mkdir -p $subpkgdir
}

proc pwclient {
	setvar pkgdesc = ""command-line client for patchwork""
	setvar depends = ""python2""
	install -Dm775 "$pkgdir"/usr/share/webapps/patchwork/patchwork/bin/pwclient \
		"$subpkgdir"/usr/bin/pwclient
}

setvar sha512sums = ""e718ce942781c64e672c7ce9df4362277df418ba2adb61d8b512bf11ffd275d675f972703ceb301600e9b9914741f9b7f44229c1f1e5dec1470ce72b15a4598b  patchwork-1.1.3.tar.gz
a5d4e24741b66092a39c1ef4fdc76dffa1ddf87a69544ab0c374fb0701b0f7340a62ead86835d9bb412df5713f3ea3c0218e9e2e0cd01d9a1aad9414a3cc75fa  0001-support-busybox-readlink.patch
12d1b184c6cb1d3f2c51adab6b60638e4869e055e677897bb66ee1a52312e77817bec543842324e2cbc2c226f3ab9d11c3782b5ef3a6f5f5712996cadbc6c9c9  0002-remove-uneeded-bashism-from-tools-and-change-path.patch
28911a25e00a254237f7214fb681e5e984a2eae331e610be62967d5e246958e0f8d3f84861d8fd17c1190c1df72a25f28ddb33843b3679a3864beb00cb4b4961  nginx-uwsgi-patchwork-conf.ini
862dd2522236a0b18d2a8d06f1ad91ad0fd0936fa502d95e09556641e67d42e1212821bfd7fb98923e4fe8b8a7369ded8c23831fb496b1e2833d9831c1b23725  nginx-patchwork.conf""