[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: start mysqld from debian/rules?



On 10/31/2011 08:54 AM, Paul Wise wrote:
> On Mon, Oct 31, 2011 at 6:04 AM, Cédric Boutillier wrote:
>   
>> I was wondering what would be the best way to start (and possibly stop)
>> the mysql server from the debian/rules makefile. Could anyone help me on
>> this?
>>     
> Run mysqld from debian/rules

Hi,

We've done that in the libdbi-drivers package. The way to do it is like
this:

-- SCRIPT START --
#!/bin/sh

MYTEMP_DIR=`mktemp -d`
ME=`whoami`

mysql_install_db --no-defaults --datadir=${MYTEMP_DIR} --force
--skip-name-resolve --user=${ME}
/usr/sbin/mysqld --no-defaults --skip-grant --user=${ME}
--socket=${MYTEMP_DIR}/mysql.sock --datadir=${MYTEMP_DIR}
--skip-networking &
export MYSQL_UNIX_PORT=${MYTEMP_DIR}/mysql.sock
echo -n pinging mysqld.
attempts=0
while ! /usr/bin/mysqladmin --socket=${MYTEMP_DIR}/mysql.sock ping ; do
        sleep 3
        attempts=$((attempts+1))
        if [ ${attempts} -gt 10 ] ; then
                echo "skipping test, mysql server could not be contacted
after 30 seconds"
                exit 0
        fi
done

... DO_YOUR_TESTS_HERE ...

/usr/bin/mysqladmin --socket=${MYTEMP_DIR}/mysql.sock shutdown
rm -rf ${MYTEMP_DIR}
-- SCRIPT END --

Note that by default, you'll have login root with empty password
available, and it's up to you to create users if you need.

Also, remember to use the BUILD_OPTIONS to have the test suite
be disabled in case we don't want to run them. That's a Debian
policy requirement. So you'll also need something like that in
your debian/rules:

ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
    ./run_tests.sh
endif

Good luck,

Thomas


Reply to: