Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 61564 - DSPAM-3.1.1 does not create all the MySQL tables
Summary: DSPAM-3.1.1 does not create all the MySQL tables
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High major (vote)
Assignee: Net-Mail Packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-24 14:31 UTC by steveb
Modified: 2004-08-26 11:35 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description steveb 2004-08-24 14:31:18 UTC
When configuring DSPAM-3.1.1 I get the following output:
mail / # ebuild /var/db/pkg/mail-filter/dspam-3.1.1/dspam-3.1.1.ebuild config
mysql
 * When prompted for a password, please enter your MySQL root password
 *
 * Creating DSPAM MySQL database "dspam"
Enter password:
 * Creating DSPAM MySQL tables
/usr/sbin/ebuild.sh: line 335: /etc/mail/dspam/config/mysql_objects.sql: No such file or directory
Enter password:
 * Creating DSPAM MySQL user "dspam"
Enter password:




 * If you want to train your DSPAM with some SPAM/HAM data, then download
 * the SA-Training-Corpus from DSPAM's website:
 *
 *   cd /tmp
 *   wget http://www.nuclearelephant.com/projects/dspam/SA-Corpus.tar.gz
 *   tar zxvf SA-Corpus.tar.gz
 *   cd ./SA-Corpus
 *   ./train.pl user@example.com
 *
 * The current ebuild has installed a group called "globaluser". If you want
 * you could train the "globaluser" instead of a valid email address:
 *   ./train.pl globaluser
 *
mail / #




The reason for the problem is a missing part in the ebuild. Instead of:
newins tools.mysql_drv/mysql_objects.sql mysql_objects.sql

The command should be:
newins tools.mysql_drv/mysql_objects.sql.${MYSQL_TABLE_TYPE} mysql_objects.sql


cheers

SteveB


Reproducible: Always
Steps to Reproduce:
1.
2.
3.
Comment 1 steveb 2004-08-24 15:12:59 UTC
again me. sorry.


I would suggest to install both SQL files (speed and space optimized) and then let the user choose between them.

This is what I would change in the ebuild:
at the top of the ebuild:
-------------------------------
delete the line with MYSQL_TABLE_TYPE
-------------------------------


In the src_install () section
-------------------------------
newins tools.mysql_drv/mysql_objects.sql.speed.optimized mysql_objects.sql.speed.optimized
newins tools.mysql_drv/mysql_objects.sql.space.optimized mysql_objects.sql.space.optimized
-------------------------------


Just after pkg_config () {
-------------------------------
        if use mysql ; then
                [[ -f ${CONFIGDIR}/mysql.data ]] && mv -f ${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}\""
                while true
                do
                        /usr/bin/mysqladmin -u root -p create ${DSPAM_MySQL_DB}
                        [ "$?" == "0" ] && break
                done

                echo
                einfo "Creating DSPAM MySQL tables for data objects"
                einfo "  Please select what kind of object database you like to use."
                einfo "    [1] Speed optimized database"
                einfo "    [2] Space optimized database"
                einfo
                while true
                do
                        read -n 1 -s -p "  Press 1 or 2 on the keyboard to select database" DSPAM_MySQL_DB_Type
                        [[ "${DSPAM_MySQL_DB_Type}" == "1" || "${DSPAM_MySQL_DB_Type}" == "2" ]] && break
                done
                echo
                if [ "${DSPAM_MySQL_DB_Type}" == "1" ]
                then
                        while true
                        do
                                /usr/bin/mysql -u root -p ${DSPAM_MySQL_DB} < ${CONFIGDIR}/mysql_objects.sql.speed.optimized
                                [ "$?" == "0" ] && break
                        done
                else
                        while true
                        do
                                /usr/bin/mysql -u root -p ${DSPAM_MySQL_DB} < ${CONFIGDIR}/mysql_objects.sql.space.optimized
                                [ "$?" == "0" ] && break
                        done
                fi

                echo
                einfo "Creating DSPAM MySQL database for virtual users"
                while true
                do
                        /usr/bin/mysql -u root -p ${DSPAM_MySQL_DB} < ${CONFIGDIR}/mysql_virtual_users.sql
                        [ "$?" == "0" ] && break
                done

                echo
                einfo "Creating DSPAM MySQL user \"${DSPAM_MySQL_USER}\""
                while true
                do
                        /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
                        [ "$?" == "0" ] && break
                done

        fi
-------------------------------



cheers

SteveB
Comment 2 Lim Swee Tat (RETIRED) gentoo-dev 2004-08-26 02:54:32 UTC
Fixed in CVS.  Expect this in the rsync soon, but I did not bump the version.

I find it strange that you embed the mysql calls in a while true loop.  Is there any specific reason?  I'm not expecting a reply, but if you can give me a reasonable answer, I'll try to roll it in. :)

Regards
Lim Swee Tat
Comment 3 steveb 2004-08-26 11:35:43 UTC
the reason for the loop is:
if the user by accident enters the wrong password for root, then the return value is anything else then 0. and the loop will ask the user for the password until the return value is 0. with this, you can be sure that all the needed tables are in place, because the specified sql commands relay on each other and each of them has to be successfull executed before the next one get's executed.
if the user want's to break the process, then he needs to press ctrl + c or break the process in another way. but as long he does not interupt the process, any typos for the password will be overlooked and the password is again asked.

cheers

steve