Home | Docs | Forums | Lists | Bugs | Planet | Store | GMN | Get Gentoo!
View Bug Activity | Format For Printing | XML | Clone This Bug
When trying to emerge the 3.1.0_beta11 ebuild of dspam, I get the following error: emerge: there are no masked or unmasked ebuilds to satisfy "(". !!! Problem with ebuild mail-filter/dspam-3.1.0_beta11 !!! Possibly a DEPEND/*DEPEND problem. !!! Depgraph creation failed. runing it with debug options gets the following error: # emerge --debug -pv dspam These are the packages that I would merge, in order: Calculating dependencies Parent: None Depstring: mail-filter/dspam Candidates: ['mail-filter/dspam'] ebuild: mail-filter/dspam-3.1.0_beta11 binpkg: None \ Parent: ebuild / mail-filter/dspam-3.1.0_beta11 merge Depstring: mysql? ( >=dev-db/mysql-3.23 ) || ( >=sys-libs/db-4.0 ) procmail? ( >=mail-filter/procmail-3.22 ) x86? ( cyrus? ( >=net-mail/cyrus-imapd-2.1.15 )) maildrop? ( >=mail-filter/maildrop-1.5.3 ) exim? ( >=mail-mta/exim-4.34 ) !bootstrap? ( sys-devel/patch ) virtual/cron app-admin/logrotate Candidates: ['))', '(', '>=net-mail/cyrus-imapd-2.1.15'] emerge: there are no masked or unmasked ebuilds to satisfy "))". !!! Error calculating dependencies. Please correct. changing the line "x86? ( cyrus? ( >=net-mail/cyrus-imapd-2.1.15 ))" to "x86? ( cyrus? ( >=net-mail/cyrus-imapd-2.1.15 ) )" in the ebuild fixes the problem: # emerge --debug -pv dspam These are the packages that I would merge, in order: Calculating dependencies Parent: None Depstring: mail-filter/dspam Candidates: ['mail-filter/dspam'] ebuild: mail-filter/dspam-3.1.0_beta11 binpkg: None \ Parent: ebuild / mail-filter/dspam-3.1.0_beta11 merge Depstring: mysql? ( >=dev-db/mysql-3.23 ) || ( >=sys-libs/db-4.0 ) procmail? ( >=mail-filter/procmail-3.22 ) x86? ( cyrus? ( >=net-mail/cyrus-imapd-2.1.15 ) ) maildrop? ( >=mail-filter/maildrop-1.5.3 ) exim? ( >=mail-mta/exim-4.34 ) !bootstrap? ( sys-devel/patch ) virtual/cron app-admin/logrotate Candidates: [] Exiting... ebuild / mail-filter/dspam-3.1.0_beta11 merge Exiting... None ...done! [ebuild U ] mail-filter/dspam-3.1.0_beta11 [3.0.0-r1] -cyrus -debug -exim -maildrop +mysql -neural -procmail 594 kB Total size of downloads: 594 kB If I am allowed to post more stuff about the DSPAM ebuild, then I would like the maintainer to include PostgreSQL support as well into the ebuild: elif use postgres ; then myconf="${myconf} --with-storage-driver=pgsql_drv" myconf="${myconf} --with-pgsql-includes=/usr/include/postgresql" myconf="${myconf} --with-pgsql-libraries=/usr/lib/postgresql" # an experimental feature available with PGSQL backend if use neural ; then myconf="${myconf} --enable-neural-networking" fi cheers SteveB Reproducible: Always Steps to Reproduce: 1. 2. 3.
Tat, There isn't a mail-filter herd that you have it listed in metadata.xml for this package. bug-wranglers always assign mail-filter bugs to net-mail. Please add yourself to the file /var/mail/alias/misc/net-mail to receive bugzilla email for this package. Best, Tuan
Hi, cool. I've added the support for the postgres, but that's rather rudimentary, because I do not have the time to look up the documentation for scripting the creation of the database and user on the postgres server. If someone is able to work on that, I'll definitely appreciate it. I'll leave this bug open till I get a script from someone or 5 days later, which ever is earlier. Regards Lim Swee Tat
I will help you with the scripting. But to be honest: Why does this have to be scripted? Scripts are okay, but the more scripts we add to portage, the bigger the portage gets and rsync takes much longer. I am more into printing the information on screen and let the user do the stuff by hand. What do you think about that?
Hi, The scripting I need is to be just a simple script that creates the database tables in postgres. This simplifies installation for users who want to use postgres as the database for their dspam. Look at the example install_mysql.sh
I know, you will hate me for posting this now. I would like to change serval things in the DSPAM ebuild. If you allow me, then I start first with the dspam.cron stuff. I would like to have only one script for all the installations. How about something like this?: #!/bin/bash # Remove old signatures and unimportant tokens from the DSPAM database for foo in awk head tail do DSPAM_Check_App="$(${foo} --version 2>&1)" if [[ "${DSPAM_Check_App/ *}" == "bash:" ]] then echo "Command ${foo} not found." exit 1 fi done DSPAM_HOMEDIR="$(grep ^dspam /etc/passwd|awk -F : '{print $6}')" [[ ! -d "${DSPAM_HOMEDIR}" ]] && exit 2 if [[ -f "${DSPAM_HOMEDIR}/mysql.data" ]] then [[ ! -f "${DSPAM_HOMEDIR}/config/mysql_purge.sql" ]] && exit 3 [[ ! -f "/usr/bin/mysql" ]] && exit 4 DSPAM_MySQL_HOST="$(cat ${DSPAM_HOMEDIR}/mysql.data|head -n 1|tail -n 1)" DSPAM_MySQL_PORT="$(cat ${DSPAM_HOMEDIR}/mysql.data|head -n 2|tail -n 1)" DSPAM_MySQL_USER="$(cat ${DSPAM_HOMEDIR}/mysql.data|head -n 3|tail -n 1)" DSPAM_MySQL_PWD="$(cat ${DSPAM_HOMEDIR}/mysql.data|head -n 4|tail -n 1)" DSPAM_MySQL_DB="$(cat ${DSPAM_HOMEDIR}/mysql.data|head -n 5|tail -n 1)" (/usr/bin/mysql -u ${DSPAM_MySQL_USER} -p"${DSPAM_MySQL_PWD}" ${DSPAM_MySQL_DB} < ${DSPAM_HOMEDIR}/config/mysql_purge.sql) 1>/dev/null 2>&1 exit $? elif [[ -f "${DSPAM_HOMEDIR}/pgsql.data" ]] then [[ ! -f "${DSPAM_HOMEDIR}/config/pgsql_purge.sql" ]] && exit 3 [[ ! -f "/usr/bin/pgsql" ]] && exit 4 DSPAM_PgSQL_HOST="$(cat ${DSPAM_HOMEDIR}/pgsql.data|head -n 1|tail -n 1)" DSPAM_PgSQL_PORT="$(cat ${DSPAM_HOMEDIR}/pgsql.data|head -n 2|tail -n 1)" DSPAM_PgSQL_USER="$(cat ${DSPAM_HOMEDIR}/pgsql.data|head -n 3|tail -n 1)" DSPAM_PgSQL_PWD="$(cat ${DSPAM_HOMEDIR}/pgsql.data|head -n 4|tail -n 1)" DSPAM_PgSQL_DB="$(cat ${DSPAM_HOMEDIR}/pgsql.data|head -n 5|tail -n 1)" (PGUSER=${DSPAM_PgSQL_USER};PGPASSWORD=${DSPAM_PgSQL_PWD};/usr/bin/psql -U ${DSPAM_PgSQL_USER} -d ${DSPAM_PgSQL_DB} -p ${DSPAM_PgSQL_PORT}-h ${DSPAM_PgSQL_HOST} -f ${DSPAM_HOMEDIR}/config/pgsql_purge.sql) 1>/dev/null 2>&1 exit $? elif [[ -f "${DSPAM_HOMEDIR}/oracle.data" ]] then [[ ! -f "${DSPAM_HOMEDIR}/config/oracle_purge.sql" ]] && exit 3 [[ ! -f "/usr/bin/sqlplus" ]] && exit 4 DSPAM_Oracle_HOST="$(cat ${DSPAM_HOMEDIR}/oracle.data|head -n 1|tail -n 1)" DSPAM_Oracle_PORT="$(cat ${DSPAM_HOMEDIR}/oracle.data|head -n 2|tail -n 1)" DSPAM_Oracle_USER="$(cat ${DSPAM_HOMEDIR}/oracle.data|head -n 3|tail -n 1)" DSPAM_Oracle_PWD="$(cat ${DSPAM_HOMEDIR}/oracle.data|head -n 4|tail -n 1)" DSPAM_Oracle_DB="$(cat ${DSPAM_HOMEDIR}/oracle.data|head -n 5|tail -n 1)" (/usr/bin/sqlplus /nolog @${DSPAM_HOMEDIR}/config/oracle_purge.sql) 1>/dev/null 2>&1 exit $? else [[ ! -f "/usr/bin/dspam_clean" ]] && exit 4 /usr/bin/dspam_clean -s -p -u 1>/dev/null 2>&1 exit $? fi I know, the script is far away from beeing perfect, but I think it is more flexible then hardcoding the stuff directly into the script. What do you think? cheers SteveB
okay... I once again changed some stuff. This time I went over the ebuild. I am still experimenting with it: # Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/mail-filter/dspam/dspam-3.1.0_beta20.ebuild,v 1.1 2004/07/28 17:14:15 st_lim Exp $ inherit eutils MY_PV=${PV/_beta20/.beta.2} S=${WORKDIR}/${PN}-${MY_PV} DESCRIPTION="A statistical-algorithmic hybrid anti-spam filter" SRC_URI="http://www.nuclearelephant.com/projects/dspam/sources/${PN}-${MY_PV}.tar.gz" HOMEPAGE="http://www.nuclearelephant.com/projects/dspam/index.html" LICENSE="GPL-2" IUSE="cyrus debug exim mysql maildrop neural oci8 postgres procmail" DEPEND="exim? ( >=mail-mta/exim-4.34 ) mysql? ( >=dev-db/mysql-3.23 ) || ( >=sys-libs/db-4.0 ) maildrop? ( >=mail-filter/maildrop-1.5.3 ) postgres? ( >=dev-db/postgresql-7.4.3 ) procmail? ( >=mail-filter/procmail-3.22 ) x86? ( cyrus? ( >=net-mail/cyrus-imapd-2.1.15 ) ) " RDEPEND="virtual/cron app-admin/logrotate" KEYWORDS="~x86 ~ppc" SLOT="0" # some FHS-like structure HOMEDIR="/etc/mail/dspam" DATADIR="/var/spool/dspam" LOGDIR="/var/log/dspam" CONFIGDIR="${HOMEDIR}/config" MYSQL_TABLE_TYPE="space.optimized" pkg_setup() { if use mysql && use postgres; then echo ewarn "You have both \"mysql\" and \"postgres\" in your USE flags." ewarn "Will default to MySQL as your dspam database backend." ewarn "If you want to build with Postgres support; hit Control-C now." ewarn "Change your USE flag -mysql and emerge again." echo has_version ">=sys-apps/portage-2.0.50" && ( einfo "It would be best practice to add the set of USE flags that you use for this" einfo "package to the file: /etc/portage/package.use. Example:" einfo "\`echo \"net-mail/dspam -mysql postgres\" >> /etc/portage/package.use\`" einfo "to build dspam with Postgres database as your dspam backend." ) echo ewarn "Waiting 30 seconds before starting..." ewarn "(Control-C to abort)..." sleep 30 fi id dspam 2>/dev/null || enewgroup dspam 65532 id dspam 2>/dev/null || enewuser dspam 65532 /bin/bash ${HOMEDIR} dspam } src_compile() { local myconf local agent # these are the default settings myconf="${myconf} --with-signature-life=14" if use cyrus; then agent="/usr/lib/cyrus/deliver %u" elif use exim; then agent="/usr/sbin/exim -oMr spam-scanned" elif use maildrop; then agent="/usr/bin/maildrop -d %u" elif use procmail; then agent="/usr/bin/procmail" fi myconf="${myconf} --enable-source-address-tracking" myconf="${myconf} --enable-large-scale" myconf="${myconf} --enable-long-username" myconf="${myconf} --enable-spam-subject" myconf="${myconf} --enable-signature-headers" myconf="${myconf} --enable-whitelist" myconf="${myconf} --enable-chi-square" myconf="${myconf} --enable-robinson" myconf="${myconf} --enable-robinson-pvalues" # ${HOMEDIR}/data is a symlink to ${DATADIR} myconf="${myconf} --with-dspam-home=${HOMEDIR}" myconf="${myconf} --with-dspam-mode=4755" myconf="${myconf} --with-dspam-owner=dspam" myconf="${myconf} --with-dspam-group=dspam" myconf="${myconf} --with-dspam-home-owner=dspam" myconf="${myconf} --with-dspam-home-group=dspam" myconf="${myconf} --with-dspam-home-mode=4755" # enables support for debugging (touch /etc/dspam/.debug to turn on) # optional: even MORE debugging output, use with extreme caution! use debug && myconf="${myconf} --enable-debug --enable-verbose-debug" # select storage driver if use mysql ; then myconf="${myconf} --with-storage-driver=mysql_drv" myconf="${myconf} --with-mysql-includes=/usr/include/mysql" myconf="${myconf} --with-mysql-libraries=/usr/lib/mysql" myconf="${myconf} --with-client-compression" myconf="${myconf} --enable-virtual-users" # an experimental feature available with MySQL and PgSQL backend if use neural ; then myconf="${myconf} --enable-neural-networking" fi elif use postgres ; then myconf="${myconf} --with-storage-driver=pgsql_drv" myconf="${myconf} --with-pgsql-includes=/usr/include/postgresql" myconf="${myconf} --with-pgsql-libraries=/usr/lib/postgresql" myconf="${myconf} --enable-virtual-users" # an experimental feature available with MySQL and PgSQL backend if use neural ; then myconf="${myconf} --enable-neural-networking" fi elif use oci8 ; then myconf="${myconf} --with-storage-driver=ora_drv" myconf="${myconf} --with-oracle-home=${ORACLE_HOME}" myconf="${myconf} --enable-virtual-users" # I am in no way a Oracle specialist. If someone knows # how to query the version of Oracle, then let me know. if (expr ${ORACLE_HOME/*\/} : 10 1>/dev/null 2>&1) then --with-oracle-version=MAJOR myconf="${myconf} --with-oracle-version=10" fi else myconf="${myconf} --with-storage-driver=libdb4_drv" myconf="${myconf} --with-db4-includes=/usr/include" myconf="${myconf} --with-db4-libraries=/usr/lib" fi econf ${myconf} \ --with-delivery-agent="${agent}" || die emake || die } src_install () { # open up perms on /etc/mail/dspam diropts -m0775 -o dspam -g dspam dodir ${HOMEDIR} keepdir ${HOMEDIR} # keeps dspam data in /var diropts -m0770 -o dspam -g dspam dodir ${DATADIR} keepdir ${DATADIR} # keeps dspam log in /var/log diropts -m0775 -o dspam -g dspam dodir ${LOGDIR} keepdir ${LOGDIR} # make install make DESTDIR=${D} install || die chmod 4755 ${D}/usr/bin/dspam # documentation dodoc CHANGELOG LICENSE README RELEASE.NOTES dodoc ${FILESDIR}/README.postfix ${FILESDIR}/README.qmail if use mysql ; then newdoc tools.mysql_drv/README README.MYSQL fi if use postgres ; then newdoc tools.pgsql_drv/README README.PGSQL fi if use oic8 ; then newdoc tools.pgsql_drv/README README.ORACLE fi # install some initial configuration insinto ${HOMEDIR} insopts -m0640 -o dspam -g dspam doins ${FILESDIR}/trusted.users if use cyrus; then echo "/usr/lib/cyrus/deliver %u" > ${T}/untrusted.mailer_args elif use exim; then echo "/usr/sbin/exim -oMr spam-scanned" > ${T}/untrusted.mailer_args elif use courier; then echo "/usr/bin/maildrop -d %u" > ${T}/untrusted.mailer_args elif use procmail; then echo "/usr/bin/procmail -d %u" > ${T}/untrusted.mailer_args fi local PASSWORD="${RANDOM}${RANDOM}${RANDOM}${RANDOM}" # database related configuration and scripts if use mysql ; then # Create the mysql.data file echo "127.0.0.1" >${T}/mysql.data echo "3306" >>${T}/mysql.data echo "dspam" >>${T}/mysql.data echo "${PASSWORD}" >>${T}/mysql.data echo "dspam" >>${T}/mysql.data insinto ${CONFIGDIR} insopts -m644 -o dspam -g dspam newins tools.mysql_drv/mysql_objects.sql.${MYSQL_TABLE_TYPE} mysql_objects.sql newins tools.mysql_drv/virtual_users.sql mysql_virtual_users.sql newins tools.mysql_drv/purge.sql mysql_purge.sql newins ${FILESDIR}/upgrade.sql mysql_upgrade.sql doins ${T}/mysql.data elif use postgres ; then # Create the pgsql.data file echo "127.0.0.1" >${T}/pgsql.data echo "5432" >>${T}/pgsql.data echo "dspam" >>${T}/pgsql.data echo "${PASSWORD}" >>${T}/pgsql.data echo "dspam" >>${T}/pgsql.data insinto ${CONFIGDIR} insopts -m644 -o dspam -g dspam newins tools.pgsql_drv/pgsql_objects.sql pgsql_objects.sql newins tools.pgsql_drv/virtual_users.sql pgsql_virtual_users.sql newins tools.pgsql_drv/purge.sql pgsql_purge.sql doins ${T}/pgsql.data elif use oic8 ; then # Create the pgsql.data file echo "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521))(CONNECT_DATA=(SID=PROD)))" >${T}/oracle.data echo "dspam" >>${T}/oracle.data echo "${PASSWORD}" >>${T}/oracle.data echo "dspam" >>${T}/oracle.data insinto ${CONFIGDIR} insopts -m644 -o dspam -g dspam newins tools.ora_drv/oral_objects.sql ora_objects.sql newins tools.ora_drv/virtual_users.sql ora_virtual_users.sql newins tools.ora_drv/purge.sql ora_purge.sql doins ${T}/oracle.data fi # installs the cron job to the cron directory diropts -m0755 -o dspam -g dspam dodir /etc/cron.daily keepdir /etc/cron.daily exeinto /etc/cron.daily exeopts -m0755 -o dspam -g dspam doexe ${FILESDIR}/dspam.cron # installs the logrotation scripts to the logrotate.d directory diropts -m0755 -o dspam -g dspam dodir /etc/logrotate.d keepdir /etc/logrotate.d insinto /etc/logrotate.d insopts -m0755 -o dspam -g dspam newins ${FILESDIR}/logrotate.dspam dspam # Symlinks data to HOMEDIR dosym ${DATADIR} ${HOMEDIR}/data # Log files for symlinks diropts -m0755 -o dspam -g dspam dodir ${LOGDIR} keepdir ${LOGDIR} touch ${D}${LOGDIR}/sql.errors touch ${D}${LOGDIR}/system.log touch ${D}${LOGDIR}/dspam.debug touch ${D}${LOGDIR}/dspam.messages # dspam still wants to write to a few files in it's home dir dosym ${LOGDIR}/sql.errors ${HOMEDIR}/sql.errors dosym ${LOGDIR}/system.log ${HOMEDIR}/system.log dosym ${LOGDIR}/dspam.debug ${HOMEDIR}/dspam.debug dosym ${LOGDIR}/dspam.messages ${HOMEDIR}/dspam.messages } pkg_postinst() { if use mysql || use postgres; then einfo "To setup dspam to run out-of-the-box on your system with a mysql or pgsql database, run:" einfo "ebuild /var/db/pkg/${CATEGORY}/${PF}/${PF}.ebuild config" fi if use exim ; then echo einfo "To use dspam in conjunction with your exim system, you should read the README" fi dodir /etc/env.d echo "CONFIG_PROTECT_MASK=${CONFIGDIR}" > ${D}/etc/env.d/40dspam } pkg_config () { if use mysql ; then mv ${CONFIGDIR}/mysql.data ${HOMEDIR} DSPAM_MySQL_USER="$(cat ${HOMEDIR}/mysql.data|head -n 3|tail -n 1)" DSPAM_MySQL_PWD="$(cat ${HOMEDIR}/mysql.data|head -n 4|tail -n 1)" DSPAM_MySQL_DB="$(cat ${HOMEDIR}/mysql.data|head -n 5|tail -n 1)" ewarn "When prompted for a password, please enter your MySQL root password" ewarn "" einfo "Creating DSPAM MySQL database \"${DSPAM_MySQL_DB}\"" /usr/bin/mysqladmin -u root -p create ${DSPAM_MySQL_DB} einfo "Creating DSPAM MySQL tables" /usr/bin/mysql -u root -p ${DSPAM_MySQL_DB} < ${CONFIGDIR}/mysql_objects.sql /usr/bin/mysql -u root -p ${DSPAM_MySQL_DB} < ${CONFIGDIR}/mysql_virtual_users.sql einfo "Creating DSPAM MySQL user \"${DSPAM_MySQL_USER}\"" /usr/bin/mysql -u root -p -e "GRANT SELECT,INSERT,UPDATE,DELETE ON ${DSPAM_MySQL_DB}.* TO ${DSPAM_MySQL_USER}@localhost IDENTIFIED BY '${DSPAM_MySQL_PWD}';FLUSH PRIVILEGES;" -D mysql fi if use postgres ; then mv ${CONFIGDIR}/pgsql.data ${HOMEDIR} DSPAM_PgSQL_USER="$(cat ${HOMEDIR}/pgsql.data|head -n 3|tail -n 1)" DSPAM_PgSQL_PWD="$(cat ${HOMEDIR}/pgsql.data|head -n 4|tail -n 1)" DSPAM_PgSQL_DB="$(cat ${HOMEDIR}/pgsql.data|head -n 5|tail -n 1)" ewarn "When prompted for a password, please enter your PgSQL postgres password" ewarn "" einfo "Creating DSPAM PostgreSQL user \"${DSPAM_PgSQL_USER}\"" /usr/bin/psql -d template1 -U postgres -c "CREATE USER ${DSPAM_PgSQL_USER} WITH PASSWORD '${DSPAM_PgSQL_PWD}' NOCREATEDB NOCREATEUSER;" 1>/dev/null 2>&1 einfo "Creating DSPAM PostgreSQL database \"${DSPAM_PgSQL_DB}\"" /usr/bin/psql -d template1 -U postgres -c "CREATE DATABASE ${DSPAM_PgSQL_DB};" 1>/dev/null 2>&1 einfo "Getting DSPAM PostgreSQL userid for \"${DSPAM_PgSQL_USER}\"" DSPAM_PgSQL_USERID=$(/usr/bin/psql -d ${DSPAM_PgSQL_DB} -U postgres -t -c "SELECT usesysid FROM pg_user WHERE usename='${DSPAM_PgSQL_USER}';" | head -n1 | sed "s/^[ ]*\([^ ]*\).*/\1/g") einfo " UserID: ${DSPAM_PgSQL_USERID}" einfo "Getting DSPAM PostgreSQL databaseid for \"${DSPAM_PgSQL_DB}\"" DSPAM_PgSQL_DBID=$(/usr/bin/psql -d ${DSPAM_PgSQL_DB} -U postgres -t -c "SELECT datdba FROM pg_database WHERE datname='${DSPAM_PgSQL_DB}';" | head -n1 | sed "s/^[ ]*\([^ ]*\).*/\1/g") einfo " DBID: ${DSPAM_PgSQL_DBID}" einfo "Changing owner of DSPAM PostgreSQL database \"${DSPAM_PgSQL_DB}\" to \"${DSPAM_PgSQL_USER}\"" /usr/bin/psql -d ${DSPAM_PgSQL_DB} -U postgres -c "UPDATE pg_database SET datdba=${DSPAM_PgSQL_USERID} WHERE datname='${DSPAM_PgSQL_DB}';" 1>/dev/null 2>&1 einfo "Creating DSPAM PostgreSQL tables" PGUSER=${DSPAM_PgSQL_USER} PGPASSWORD=${DSPAM_PgSQL_PWD} /usr/bin/psql -d ${DSPAM_PgSQL_DB} -U ${DSPAM_PgSQL_USER} -f ${CONFIGDIR}/pgsql_objects.sql 1>/dev/null 2>&1 PGUSER=${DSPAM_PgSQL_USER} PGPASSWORD=${DSPAM_PgSQL_PWD} /usr/bin/psql -d ${DSPAM_PgSQL_DB} -U ${DSPAM_PgSQL_USER} -f ${CONFIGDIR}/pgsql_virtual_users.sql 1>/dev/null 2>&1 einfo "Grant privileges to DSPAM PostgreSQL objects to \"${DSPAM_PgSQL_USER}\"" for foo in $(/usr/bin/psql -t -d ${DSPAM_PgSQL_DB} -c "SELECT tablename FROM pg_tables WHERE tablename LIKE 'dspam\%';") do /usr/bin/psql -d ${DSPAM_PgSQL_DB} -U postgres -c "GRANT ALL PRIVILEGES ON TABLE ${foo} TO ${DSPAM_PgSQL_USER};" 1>/dev/null 2>&1 done /usr/bin/psql -d ${DSPAM_PgSQL_DB} -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE ${DSPAM_PgSQL_DB} TO ${DSPAM_PgSQL_USER};" 1>/dev/null 2>&1 /usr/bin/psql -d ${DSPAM_PgSQL_DB} -U postgres -c "GRANT ALL PRIVILEGES ON SCHEMA public TO ${DSPAM_PgSQL_USER};" 1>/dev/null 2>&1 fi } I have added a /etc/env.d/ entry for dspam to protect the configuration (I don't like the data to be overwritten by emerge). I included as well oracle support (not testet at all) and I included the other way of doing the cron stuff. This is the script I would like to deploy for the end-user (I try to be independent of the database used and the password. But I have not testet all of the options in the dspam cron script). Content of dspam.cron: #!/bin/bash # Remove old signatures and unimportant tokens from the DSPAM database for foo in awk head tail do DSPAM_Check_App="$(${foo} --version 2>&1)" if [[ "${DSPAM_Check_App/ *}" == "bash:" ]] then echo "Command ${foo} not found." exit 1 fi done DSPAM_HOMEDIR="$(grep ^dspam /etc/passwd|awk -F : '{print $6}')" [[ ! -d "${DSPAM_HOMEDIR}" ]] && exit 2 if [[ -f "${DSPAM_HOMEDIR}/mysql.data" ]] then [[ ! -f "${DSPAM_HOMEDIR}/config/mysql_purge.sql" ]] && exit 3 [[ ! -f "/usr/bin/mysql" ]] && exit 4 DSPAM_MySQL_HOST="$(cat ${DSPAM_HOMEDIR}/mysql.data|head -n 1|tail -n 1)" DSPAM_MySQL_PORT="$(cat ${DSPAM_HOMEDIR}/mysql.data|head -n 2|tail -n 1)" DSPAM_MySQL_USER="$(cat ${DSPAM_HOMEDIR}/mysql.data|head -n 3|tail -n 1)" DSPAM_MySQL_PWD="$(cat ${DSPAM_HOMEDIR}/mysql.data|head -n 4|tail -n 1)" DSPAM_MySQL_DB="$(cat ${DSPAM_HOMEDIR}/mysql.data|head -n 5|tail -n 1)" (/usr/bin/mysql -u ${DSPAM_MySQL_USER} -p"${DSPAM_MySQL_PWD}" ${DSPAM_MySQL_DB} < ${DSPAM_HOMEDIR}/config/mysql_purge.sql) 1>/dev/null 2>&1 exit $? elif [[ -f "${DSPAM_HOMEDIR}/pgsql.data" ]] then [[ ! -f "${DSPAM_HOMEDIR}/config/pgsql_purge.sql" ]] && exit 3 [[ ! -f "/usr/bin/psql" ]] && exit 4 DSPAM_PgSQL_HOST="$(cat ${DSPAM_HOMEDIR}/pgsql.data|head -n 1|tail -n 1)" DSPAM_PgSQL_PORT="$(cat ${DSPAM_HOMEDIR}/pgsql.data|head -n 2|tail -n 1)" DSPAM_PgSQL_USER="$(cat ${DSPAM_HOMEDIR}/pgsql.data|head -n 3|tail -n 1)" DSPAM_PgSQL_PWD="$(cat ${DSPAM_HOMEDIR}/pgsql.data|head -n 4|tail -n 1)" DSPAM_PgSQL_DB="$(cat ${DSPAM_HOMEDIR}/pgsql.data|head -n 5|tail -n 1)" (PGUSER=${DSPAM_PgSQL_USER} PGPASSWORD=${DSPAM_PgSQL_PWD} /usr/bin/psql -U ${DSPAM_PgSQL_USER} -d ${DSPAM_PgSQL_DB} -p ${DSPAM_PgSQL_PORT} -h ${DSPAM_PgSQL_HOST} -f ${DSPAM_HOMEDIR}/config/pgsql_purge.sql) 1>/dev/null 2>&1 exit $? elif [[ -f "${DSPAM_HOMEDIR}/oracle.data" ]] then [[ ! -f "${DSPAM_HOMEDIR}/config/oracle_purge.sql" ]] && exit 3 [[ ! -f "/usr/bin/sqlplus" ]] && exit 4 DSPAM_Oracle_DBLINK="$(cat ${DSPAM_HOMEDIR}/oracle.data|head -n 1|tail -n 1)" DSPAM_Oracle_USER="$(cat ${DSPAM_HOMEDIR}/oracle.data|head -n 2|tail -n 1)" DSPAM_Oracle_PWD="$(cat ${DSPAM_HOMEDIR}/oracle.data|head -n 3|tail -n 1)" DSPAM_Oracle_SCHEMA="$(cat ${DSPAM_HOMEDIR}/oracle.data|head -n 4|tail -n 1)" (/usr/bin/sqlplus -s ${DSPAM_Oracle_USER}/${DSPAM_Oracle_PWD} @${DSPAM_HOMEDIR}/config/oracle_purge.sql) 1>/dev/null 2>&1 exit $? else [[ ! -f "/usr/bin/dspam_clean" ]] && exit 4 /usr/bin/dspam_clean -s -p -u 1>/dev/null 2>&1 exit $? fi Executing the config option from the ebuild gives me the following output: # ebuild dspam-3.1.0_beta20.ebuild config postgres * When prompted for a password, please enter your PgSQL postgres password * * Creating DSPAM PostgreSQL user "dspam" * Creating DSPAM PostgreSQL database "dspam" * Getting DSPAM PostgreSQL userid for "dspam" * UserID: 106 * Getting DSPAM PostgreSQL databaseid for "dspam" * DBID: 1 * Changing owner of DSPAM PostgreSQL database "dspam" to "dspam" * Creating DSPAM PostgreSQL tables * Grant privileges to DSPAM PostgreSQL objects to "dspam" I hope this is what you wanted me to do? If you want, I can upload the ebuild and the other stuf to this bug report. cheers SteveB
Created an attachment (id=36476) [edit] dspam-3.1.0_beta20.ebuild Okay... This ebuild now has no permission problems (the old and the original one had trouble with the various files in /var/log). If you can test it with MySQL, then I would be very happy. cheers SteveB
Created an attachment (id=36477) [edit] dspam.cron The dspam.cron file used in dspam-3.1.0_beta20.ebuild. I hope someone with a Oracle installation will help us to get the stuff correct for Oracle. cheers SteveB
i found again something wich is not nice. this time it is the logrotate part. the script looks like this: /var/log/dspam/sql.errors /var/log/dspam/system.log /var/log/dspam/dspam.debug /var/log/dspam/dspam.messages { weekly compress create 0644 root mail } but when installing, the files get installed with diffrend rights and diffrend owners: # Log files for symlinks diropts -m0755 -o dspam -g dspam dodir ${LOGDIR} keepdir ${LOGDIR} touch ${T}/empty.file newins ${T}/empty.file sql.errors newins ${T}/empty.file system.log newins ${T}/empty.file dspam.debug newins ${T}/empty.file dspam.messages this sure needs to be adjusted to maybe something like this (in logrotate): /var/log/dspam/sql.errors /var/log/dspam/system.log /var/log/dspam/dspam.debug /var/log/dspam/dspam.messages { weekly compress create 0755 dspam dspam } what do you think? cheers SteveB
Wow, you've done quite a deal. I'll look into this, and try to roll it in. :) Regards Lim Swee Tat
I hope it helps? ;)
Hi, Sorry, been busy and was unable to test your scripts. But I'll like to say that I will prefer it if oracle scripts are kept separately from postgres and the such for mysql scripts too. I'll try to roll in the changes by Saturday nite. :) Work... And more work... :( Thanx for the help though. Ciao ST Lim
having one script for the maintenance of the diffrend database backends is sure much nicer then having serval scripts doing (almost) the same. one script would make migration from one database backend to another much more easy then having serval scripts for serval database backends. but it is your ebuild. you deside what you think is the best. cheers SteveB
Sorry about this. I'll try to close this bug by today.
oh...I forgot to comment. Your reasoning is good, but if you think about it, I'll rather manage 1 script for each backend because, upon installation, you really just want the user to manage 1 set of scripts, so he should have the ability to look into his own set of scripts and not have to forage through a whole set of scripts for other db that he has no concern for. Thanx for the help though. Regards Lim Swee Tat
Tested with mysql, works great.
*** Bug 61149 has been marked as a duplicate of this bug. ***
Commited work with 3.1.1