]> Pileus Git - ~andy/sunrise/blob - app-office/tinyerp-server/tinyerp-server-3.4.2.ebuild
app-office/tinyerp-server: Version bump
[~andy/sunrise] / app-office / tinyerp-server / tinyerp-server-3.4.2.ebuild
1 # Copyright 1999-2006 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 inherit eutils distutils
6
7 DESCRIPTION="Open Source ERP & CRM"
8 HOMEPAGE="http://tinyerp.org/"
9 SRC_URI="${P}.tar.gz"
10
11 LICENSE="GPL-2"
12 SLOT="0"
13 KEYWORDS="~x86"
14 IUSE=""
15 RESTRICT="fetch"
16
17 DEPEND=">=dev-db/postgresql-7.4
18         dev-python/pypgsql
19         dev-python/reportlab
20         dev-python/pyparsing
21         media-gfx/pydot
22         =dev-python/psycopg-1*
23         dev-libs/libxml2
24         dev-libs/libxslt"
25 RDEPEND=${DEPEND}
26
27 TINYERP_USER=terp
28 TINYERP_GROUP=terp
29 TINYERP_DATABASE=terp
30
31 DOWNLOAD_URL="http://tinyerp.com/component/option,com_vfm/Itemid,61/do,download/file,stable|source|${P}.tar.gz/"
32 pkg_nofetch() {
33         einfo "Please donwload ${SRC_URI} from:"
34         einfo ${DOWNLOAD_URL}
35         einfo "and move it to ${DISTDIR}"
36 }
37
38 pkg_setup() {
39         if ! built_with_use dev-libs/libxslt python ; then
40                 eerror "dev-libs/libxslt must be built with python"
41                 die "${PN} requires dev-libs/libxslt with USE=python"
42         fi
43 }
44
45 src_install() {
46         distutils_src_install
47
48         newinitd "${FILESDIR}"/tinyerp-init.d tinyerp
49         newconfd "${FILESDIR}"/tinyerp-conf.d tinyerp
50
51         keepdir /var/run/tinyerp
52         fowners ${TINYERP_USER} ${TINYERP_GROUP} /var/run/tinyerp
53
54         keepdir /var/log/tinyerp
55         fowners ${TINYERP_USER} ${TINYERP_GROUP} /var/log/tinyerp
56 }
57
58 pkg_postinst() {
59         enewgroup ${TINYERP_GROUP}
60         enewuser ${TINYERP_USER} -1 -1 -1 ${TINYERP_GROUP}
61
62         einfo "In order to setup the initial database, run:"
63         einfo "  emerge --config =${CATEGORY}/${PF}"
64         einfo "Be sure the database is started before"
65 }
66
67 pquery() {
68         psql -q -At -U postgres -d template1 -c "$@"
69 }
70
71 pkg_config() {
72         einfo "In the following, the 'postgres' user will be used."
73         if ! pquery "SELECT usename FROM pg_user WHERE usename = '${TINYERP_USER}'" | grep -q ${TINYERP_USER}; then
74                 ebegin "Creating database user ${TINYERP_USER}"
75                 createuser --quiet --username=postgres --no-createdb --no-adduser --no-createrole ${TINYERP_USER}
76                 eend $? || die "Failed to create database user"
77         fi
78
79         if ! pquery "SELECT datname FROM pg_database WHERE datname = '${TINYERP_DATABASE}'" |grep -q terp; then
80                 ebegin "Creating database ${TINYERP_DATABASE}"
81                 createdb --quiet --username=postgres --owner=terp --encoding=UNICODE ${TINYERP_DATABASE}
82                 eend $? || die "Failed to create database"
83         fi
84
85         einfo "The first time tinyerp-server is run it will initialize the database"
86 }