# Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit eutils distutils DESCRIPTION="Tiny ERP is a company ERP and CRM solution" HOMEPAGE="http://tinyerp.org/" SRC_URI="http://tinyerp.org/download/sources/${P}.tar.gz" LICENSE="GPL" SLOT="0" KEYWORDS="x86" IUSE="" DEPEND=">=dev-db/postgresql-7.4 dev-python/pypgsql dev-python/reportlab dev-python/pyparsing dev-python/pydot dev-python/psycopg dev-libs/libxml2 dev-libs/libxslt" src_compile() { epatch ${FILESDIR}/netsvc-${PV}.patch distutils_src_compile } src_install() { distutils_src_install exeinto /etc/init.d newexe ${FILESDIR}/${P}.initd ${PN} insinto /etc/conf.d newins ${FILESDIR}/${P}.confd ${PN} dodir /var/run/tinyerp fperms 0755 /var/run/tinyerp } pkg_postinst() { einfo "" einfo "You should now setup the database if this is a new install." einfo "Run the command" einfo " ebuild /var/db/pkg/app-office/${PF}/${P}.ebuild config" einfo "to do this automatically with language set to english." einfo "" } pquery() { psql -q -At -U postgres -d template1 -c "$@" } pkg_config() { einfo "In the following, the 'postgres' user will be used." if ! pquery "SELECT usename FROM pg_user WHERE usename = 'terp'" | grep -q terp; then ebegin Creating database user terp createuser --quiet --username=postgres --createdb --no-adduser terp eend $? || die Failed to create database user elif ! pquery "SELECT usecreatedb FROM pg_user WHERE usename = 'terp'" | grep -q t; then ebegin Granting temporary CREATEDB permissions for terp psql -q -U postgres -d terp -c 'ALTER USER terp NOCREATEDB' eend $? || die Failed to grant permissions fi if ! pquery "SELECT datname FROM pg_database WHERE datname = 'terp'" | grep -q terp; then ebegin Creating database terp createdb --quiet --username=terp --encoding=UNICODE terp eend $? || die Failed to create database fi ebegin Revoking superflous permissions for terp psql -q -U postgres -d terp -c 'ALTER USER terp NOCREATEDB' eend $? || die Failed to revoke permissions if ! getent passwd terp >/dev/null; then enewuser terp fi chown terp:nobody /var/run/tinyerp einfo The first time tinyerp-server is run it will initialize the database. }