# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=3

inherit webapp eutils #depend.php

MY_PV="2"
MY_P=${PN}-${MY_PV}

DESCRIPTION="Web-based storage application where all your data is under your own control"
HOMEPAGE="http://owncloud.org"
SRC_URI="http://owncloud.org/releases/${MY_P}.tar.bz2"
LICENSE="GPL-3"

KEYWORDS="~amd64 ~x86"
IUSE=""

DEPEND=""
RDEPEND="dev-lang/php[json,xmlwriter,zip]"

need_httpd_cgi
need_php_httpd

S="${WORKDIR}/${PN}"

DOCS="README"


pkg_setup() {
	webapp_pkg_setup
}

src_install() {
	webapp_src_preinst

	dodoc ${DOCS} || die
	rm -f ${DOCS} || die
	insinto "${MY_HTDOCSDIR}"
	doins -r . || die
	dodir "${MY_HTDOCSDIR}"/data || die
	webapp_serverowned "${MY_HTDOCSDIR}"/data
	webapp_serverowned "${MY_HTDOCSDIR}"/config

	webapp_src_install
}

pkg_preinst() {
	if has_version "<${CATEGORY}/${P}" ; then
		elog "The webdav address has changed from webdav://ADDRESS/webdav/owncloud.php to webdav://ADDRESS/files/webdav.php"
		elog "Make sure to erase your config file and all tables in the database before using owncloud."
	fi
}