TT-RSS Git Ebuild Gentoo

A little tinkering and managed to get an ebuild working for the excellent google reader replacement tt-rss.

Download it here tt-rss-9999.ebuild

# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/www-apps/tt-rss/tt-rss-9999.ebuild,v 1.0 13/07/20 13:02:05 ukjohnd Exp $

EAPI=5

inherit git-2  eutils webapp user depend.php depend.apache
MY_PN="Tiny-Tiny-RSS"
MY_P="${MY_PN}-${PV}"
DESCRIPTION="Tiny Tiny RSS - A web-based news feed (RSS/Atom) aggregator using AJAX"
HOMEPAGE="http://tt-rss.org/"
EGIT_REPO_URI="git://github.com/gothfox/Tiny-Tiny-RSS.git"
#SLOT="0"
LICENSE="GPL-2"
KEYWORDS="~amd64 ~x86"
IUSE="daemon +mysql postgres"

DEPEND="
	daemon? ( dev-lang/php[mysql?,postgres?,pcntl,curl] )
	!daemon? ( dev-lang/php[mysql?,postgres?,curl] )
"
RDEPEND="${DEPEND}"

REQUIRED_USE="|| ( mysql postgres )"

pkg_setup() {
	webapp_pkg_setup

	if use daemon; then
			enewgroup ttrssd
			enewuser ttrssd -1 /bin/sh /dev/null ttrssd
	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 -i \
				-e "/define('DB_TYPE',/{s:pgsql:mysql:}" \
				config.php || die
	fi

	sed -i \
		-e "/define('DB_TYPE',/{s:// \(or mysql\):// pgsql \1:}" \
		config.php || die

	# per 462578
	epatch_user
}

src_install() {
	webapp_src_preinst

	insinto "/${MY_HTDOCSDIR}"
	doins -r *
	keepdir "/${MY_HTDOCSDIR}"/feed-icons

	for DIR in cache lock feed-icons; do
			webapp_serverowned -R "${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-r1 ttrssd
			newconfd "${FILESDIR}"/ttrssd.confd-r1 ttrssd
			insinto /etc/logrotate.d/
			newins "${FILESDIR}"/ttrssd.logrotated ttrssd
	else
			webapp_postinst_txt en "${FILESDIR}"/postinstall-en.txt
	fi

	webapp_src_install
}