summaryrefslogtreecommitdiff
blob: 178f7749652e6af5852b8a8c0bbfae59fd4e8abc (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
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/www-apps/tt-rss/tt-rss-1.5.5.ebuild,v 1.1 2011/07/17 15:09:07 hwoarang Exp $

EAPI="2"

inherit eutils webapp depend.php depend.apache

DESCRIPTION="Tiny Tiny RSS - A web-based news feed (RSS/Atom) aggregator using AJAX"
HOMEPAGE="http://tt-rss.org/"
SRC_URI="http://tt-rss.org/download/${P}.tar.gz"

LICENSE="GPL-2"
KEYWORDS="~amd64"
IUSE="daemon mysql postgres"

DEPEND="dev-lang/php[mysql?,postgres?]"
RDEPEND="${DEPEND}"

need_httpd_cgi
need_php_httpd
use daemon && need_php_cli

pkg_setup() {
	webapp_pkg_setup
	use mysql && require_php_with_use mysql
	use postgres && require_php_with_use postgres
	if use daemon; then
		require_php_with_use pcntl
		einfo "Checking for ttrssd group ..."
		enewgroup ttrssd || die "Failed to check/add needed group"
		einfo "Checking for ttrssd user ..."
		enewuser ttrssd -1 /bin/sh /dev/null ttrssd || die "Failed to check/add needed user"
	fi
}

src_prepare() {
	# Customize config.php so that the right 'DB_TYPE' is already set (according to the USE flag)
	einfo "Customizing config.php..."
	mv config.php{-dist,} || die "Could not rename config.php-dist to config.php."
	if use mysql && ! use postgres; then
		sed -e "/define('DB_TYPE',/{s:pgsql:mysql:}" -i config.php || die "sed failed"
	fi
	sed -e "/define('DB_TYPE',/{s:// \(or mysql\):// pgsql \1:}" -i config.php \
		|| die "sed failed"
}

src_install() {
	webapp_src_preinst

	insinto "/${MY_HTDOCSDIR}"
	doins -r * || die "Could not copy the files to ${MY_HTDOCSDIR}."
	keepdir "/${MY_HTDOCSDIR}"/icons

	insinto /etc/logrotate.d/
	newins "${FILESDIR}"/ttrssd.logrotated ttrssd || die "Installing ttrssd logrotate config failed."

	for DIR in cache cache/htmlpurifier cache/magpie cache/simplepie lock icons; do
		webapp_serverowned "${MY_HTDOCSDIR}/${DIR}"
	done
	webapp_configfile "${MY_HTDOCSDIR}"/config.php
	if use daemon; then
		webapp_postinst_txt en "${FILESDIR}"/postinstall-en-with-daemon.txt
		newinitd "${FILESDIR}"/ttrssd.initd ttrssd
		newconfd "${FILESDIR}"/ttrssd.confd ttrssd
	else
		webapp_postinst_txt en "${FILESDIR}"/postinstall-en.txt
	fi

	webapp_src_install
}