# Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit webapp eutils # BUG: # naming rule is insane MY_PV_DATE=${PV/#[[:digit:]].[[:digit:]]./} MY_PV=${PV/%.${MY_PV_DATE}/-${MY_PV_DATE}} MY_P="${PN}_${MY_PV}" MY_PN=${PN/_web/} DESCRIPTION="a browser-based multilingual IMAP client using AJAX" HOMEPAGE="http://www.roundcube.net" SRC_URI="mirror://sourceforge/${MY_PN}/${MY_P}.tar.gz" LICENSE="GPL-2" KEYWORDS="~x86" # ${S} is roundcubemail-0.1-20051021 S=${WORKDIR}/${MY_PN}-${MY_PV} IUSE="mysql sqlite" RDEPEND=" mysql? (>=dev-db/mysql-4) sqlite? ( dev-db/sqlite ) !mysql? ( ( !sqlite ( dev-db/mysql ) ) ) virtual/httpd-php " # postgresql? (dev-db/postgresql) # BUG: # I don't know Gentoo's default DB, dev-db/mysql is default # *.inc should be *.inc.php src_install () { webapp_src_preinst cd ${S} dodoc CHANGELOG README UPGRADING cp -R . ${D}/${MY_HTDOCSDIR} local files="config logs program skins temp" for file in ${files}; do webapp_serverowned "${MY_HTDOCSDIR}/${file}" done # removed from dist #webapp_serverowned ${MY_HTDOCSDIR}/logs/errors #webapp_serverowned ${MY_HTDOCSDIR}/logs/sendmail webapp_postinst_txt en ${FILESDIR}/postinstall-en.txt # BUG: # webapp.eclass doesn't support sqlite # webapp_sqlscript sqlite SQL/sqlite.initial.sql webapp_sqlscript mysql SQL/mysql.initial.sql # removed postgresql support #webapp_sqlscript postgres SQL/postgres.initial.sql webapp_configfile ${MY_HTDOCSDIR}/config/db.inc.php webapp_configfile ${MY_HTDOCSDIR}/config/main.inc.php webapp_src_install } pkg_postinst () { einfo "Now run ebuild /var/db/pkg/${CATEGORY}/${PF}/${PF}.ebuild config" einfo "to setup the database" webapp_pkg_postinst } pkg_config() { # default values for db stuff D_DB="roundcube" D_HOST="localhost" D_USER="roundcube" # do we want to start mysqld? # BUG: # NO, you shouldn't RESTART database # you don't need root priv. to create a database # if an admin is stupid enough to execute SQL without RDBMS running, # s/he is just asking for troubles # # also, i'm not sure this pkg_config is useful # if you cannot execute a simple SQL script, you shoudn't run RDBMS in the # first place # # what if the remote database listens on a port other than its default? # how about postgresql? what if the upstream supports addtional database? # # what if the upstream change required priv. on the database? # /etc/init.d/mysql restart || die "mysql needs to be running" echo -n "mysql db name [${D_DB}]: "; read MY_DB [[ -z ${MY_DB} ]] && MY_DB=${D_DB} echo -n "mysql db host [${D_HOST}]: "; read MY_HOST [[ -z ${MY_HOST} ]] && MY_HOST=${D_HOST} echo -n "mysql dbuser name [${D_USER}]: "; read MY_USER [[ -z ${MY_USER} ]] && MY_USER=${D_USER} echo -n "mysql dbuser password: "; read mypwd [[ -z ${mypwd} ]] && die "Error: no dbuser password" # privileges echo -n "Please enter login info for user who has grant privileges on ${MY_HOST} [$USER]: "; read adminuser [[ -z ${adminuser} ]] && adminuser="$USER" if [ "${MY_HOST}" != "localhost" ]; then echo -n "Client address (at db side) [$(hostname -f)]: "; read clientaddr [[ -z ${clientaddr} ]] && clientaddr="$(hostname -f)" fi # this will be default for localhost [[ -z ${clientaddr} ]] && clientaddr="${MY_HOST}" # if $MY_HOST == localhost, don't specify -h argument, so local socket can be used. host=${MY_HOST/localhost} mysqladmin -u ${adminuser} ${host:+-h ${host}} -p create ${MY_DB} || die "Error creating database" #FIXME: need to find out if all these are really required mysql -u "${adminuser}" "${host:+-h ${host}}" -p \ -e "GRANT SELECT,INSERT,UPDATE,DELETE,INDEX,ALTER,CREATE,DROP,REFERENCES ON ${MY_DB}.* TO '${MY_USER}'@'${clientaddr}' IDENTIFIED BY '${mypwd}'; FLUSH PRIVILEGES;" || die "Error initializing database. Please grant permissions manually." }