OpenPKG CVS Repository http://cvs.openpkg.org/ ____________________________________________________________________________
Server: cvs.openpkg.org Name: Ralf S. Engelschall Root: /v/openpkg/cvs Email: [EMAIL PROTECTED] Module: openpkg-src Date: 29-Feb-2008 19:17:35 Branch: HEAD Handle: 2008022918173400 Modified files: openpkg-src/drupal drupal-setup.sh drupal.spec Log: add support for PostgreSQL and DCron Summary: Revision Changes Path 1.10 +52 -12 openpkg-src/drupal/drupal-setup.sh 1.143 +57 -18 openpkg-src/drupal/drupal.spec ____________________________________________________________________________ patch -p0 <<'@@ .' Index: openpkg-src/drupal/drupal-setup.sh ============================================================================ $ cvs diff -u -r1.9 -r1.10 drupal-setup.sh --- openpkg-src/drupal/drupal-setup.sh 16 Feb 2008 11:26:03 -0000 1.9 +++ openpkg-src/drupal/drupal-setup.sh 29 Feb 2008 18:17:34 -0000 1.10 @@ -1,28 +1,62 @@ -#!/bin/sh [EMAIL PROTECTED]@ ## ## drupal-setup.sh -- Drupal RDBMS Setup Utility ## +# command line argument sanity check +if [ $# -eq 0 ]; then + echo "$0:ERROR: invalid command line" 1>&2 + echo "$0:USAGE: $0 install [<database-directory>]" 1>&2 + echo "$0:USAGE: $0 uninstall" 1>&2 + exit 1 +fi + # database configuration +db_dir="@l_prefix@/var/drupal/db" +db_type="@l_dbtype@" db_name="drupal" db_user="drupal" db_pass="drupal" # determine RDBMS-specific details -db_suser=`grep "^user" @l_prefix@/etc/mysql/my.pwd |\ - sed -e 's;^user[^=]*= *;;' -e 's; *$;;'` -db_spass=`grep "^password" @l_prefix@/etc/mysql/my.pwd |\ - sed -e 's;^password[^=]*= *;;' -e 's; *$;;'` +if [ ".$db_type" = .mysql ]; then + db_sname="mysql" + db_suser=`grep "^user" @l_prefix@/etc/mysql/my.pwd |\ + sed -e 's;^user[^=]*= *;;' -e 's; *$;;'` + db_spass=`grep "^password" @l_prefix@/etc/mysql/my.pwd |\ + sed -e 's;^password[^=]*= *;;' -e 's; *$;;'` +elif [ ".$db_type" = .pgsql ]; then + db_sname=`grep "^superuser_database" @l_prefix@/var/postgresql/db/pg_superuser.conf |\ + sed -e 's;^ *superuser_database="\(.*\)".*;\1;'` + db_suser=`grep "^superuser_username" @l_prefix@/var/postgresql/db/pg_superuser.conf |\ + sed -e 's;^ *superuser_username="\(.*\)".*;\1;'` + db_spass=`grep "^superuser_password" @l_prefix@/var/postgresql/db/pg_superuser.conf |\ + sed -e 's;^ *superuser_password="\(.*\)".*;\1;'` +fi # dispatch operation cmd="${1:-"install"}" +shift case "$cmd" in install ) # create the database - @l_prefix@/bin/mysqladmin --user="$db_suser" --password="$db_spass" create "$db_name" - ( echo "GRANT ALL PRIVILEGES ON $db_name.* TO [EMAIL PROTECTED] IDENTIFIED BY '$db_pass';" - echo "FLUSH PRIVILEGES;" - ) | @l_prefix@/bin/mysql --user="$db_suser" --password="$db_spass" mysql + if [ $# -gt 0 ]; then + db_dir="$1" + shift + fi + if [ ".$db_type" = .mysql ]; then + # FIXME: MySQL doesn't allow easy relocation of tablespaces AFAIK --rse + @l_prefix@/bin/mysqladmin --user="$db_suser" --password="$db_spass" create "$db_name" + ( echo "GRANT ALL PRIVILEGES ON $db_name.* TO [EMAIL PROTECTED] IDENTIFIED BY '$db_pass';" + echo "FLUSH PRIVILEGES;" + ) | @l_prefix@/bin/mysql --user="$db_suser" --password="$db_spass" "$db_sname" + elif [ ".$db_type" = .pgsql ]; then + ( echo "CREATE ROLE $db_user LOGIN ENCRYPTED PASSWORD '$db_pass' NOCREATEDB NOCREATEUSER;" + echo "CREATE TABLESPACE $db_name OWNER $db_user LOCATION '$db_dir';" + echo "CREATE DATABASE $db_name OWNER $db_user TABLESPACE $db_name ENCODING 'UTF8';" + ) | PGPASSWORD="$db_spass" @l_prefix@/bin/psql -q -U "$db_suser" -d "$db_sname" -f- + PGPASSWORD="$db_pass" @l_prefix@/bin/psql -q -U "$db_user" -d "$db_name" -f- <$db_script + fi # activate configuration directory # (is automatically deactivated by installer afterwards) @@ -30,12 +64,18 @@ ;; uninstall ) # remove the database - ( echo "DROP DATABASE $db_name;" - ) | @l_prefix@/bin/mysql --user="$db_suser" --password="$db_spass" mysql + elif [ ".$db_type" = .mysql ]; then + ( echo "DROP DATABASE $db_name;" + ) | @l_prefix@/bin/mysql --user="$db_suser" --password="$db_spass" "$db_sname" + elif [ ".$db_type" = .pgsql ]; then + ( echo "DROP DATABASE $db_name;" + echo "DROP TABLESPACE $db_name;" + echo "DROP ROLE $db_user;" + ) | PGPASSWORD="$db_spass" @l_prefix@/bin/psql -q -U "$db_suser" -d "$db_sname" -f- + fi # remove the generated configuration rm -f @l_prefix@/share/drupal/sites/default/settings.php - rm -f @l_prefix@/var/drupal/files/* ;; esac @@ . patch -p0 <<'@@ .' Index: openpkg-src/drupal/drupal.spec ============================================================================ $ cvs diff -u -r1.142 -r1.143 drupal.spec --- openpkg-src/drupal/drupal.spec 29 Feb 2008 17:26:44 -0000 1.142 +++ openpkg-src/drupal/drupal.spec 29 Feb 2008 18:17:34 -0000 1.143 @@ -130,6 +130,19 @@ Version: %{V_drupal} Release: 20080229 +# package options +%option with_mysql yes +%option with_pgsql no +%option with_dcron no + +# checking for option conflicts +%if "%{with_mysql}" == "no" && "%{with_pgsql}" == "no" + %{error:one of the build-time options 'with_mysql' or 'with_pgsql' have to be enabled} +%endif +%if "%{with_mysql}" == "yes" && "%{with_pgsql}" == "yes" + %{error:only one of the build-time options 'with_mysql' or 'with_pgsql' can be enabled at a time} +%endif + # list of sources Source0: http://ftp.drupal.org/files/projects/drupal-%{V_drupal}.tar.gz Source1: http://ftp.drupal.org/files/projects/archive-%{V_module_archive}.tar.gz @@ -236,10 +249,18 @@ PreReq: apache-php::with_mbstring = yes PreReq: apache-php::with_session = yes PreReq: apache-php::with_mm = yes -PreReq: apache-php::with_mysql = yes PreReq: apache-php::with_pcre = yes PreReq: apache-php::with_xml = yes PreReq: apache-php::with_sendmail = yes +%if "%{with_mysql}" == "yes" +PreReq: apache-php::with_mysql = yes +%endif +%if "%{with_pgsql}" == "yes" +PreReq: apache-php::with_pgsql = yes +%endif +%if "%{with_dcron}" == "yes" +PreReq: dcron +%endif PreReq: MTA AutoReq: no AutoReqProv: no @@ -812,7 +833,8 @@ $RPM_BUILD_ROOT%{l_prefix}/share/drupal \ $RPM_BUILD_ROOT%{l_prefix}/var/drupal/files \ $RPM_BUILD_ROOT%{l_prefix}/var/drupal/run \ - $RPM_BUILD_ROOT%{l_prefix}/var/drupal/log + $RPM_BUILD_ROOT%{l_prefix}/var/drupal/log \ + $RPM_BUILD_ROOT%{l_prefix}/var/drupal/db # install all files (and strip down installation afterwards) cp -rp * .htaccess \ @@ -820,7 +842,12 @@ # pre-configure settings.php %{l_shtool} subst \ +%if "%{with_mysql}" == "yes" -e 's|^\( *\$db_url\) *=.*$|\1 = "mysql://drupal:[EMAIL PROTECTED]/drupal";|' \ +%endif +%if "%{with_pgsql}" == "yes" + -e 's|^\( *\$db_url\) *=.*$|\1 = "pgsql://drupal:[EMAIL PROTECTED]/drupal";|' \ +%endif $RPM_BUILD_ROOT%{l_prefix}/share/drupal/sites/default/default.settings.php # set data location @@ -833,12 +860,26 @@ %{SOURCE rc.drupal} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/ # install database setup script +%if "%{with_mysql}" == "yes" + l_dbtype="mysql" +%endif +%if "%{with_pgsql}" == "yes" + l_dbtype="pgsql" +%endif %{l_shtool} install -c -m 755 %{l_value -s -a} \ + -e "s;@l_dbtype@;$l_dbtype;g" \ + -e "s;@l_bash@;%{l_bash};g" \ %{SOURCE drupal-setup.sh} $RPM_BUILD_ROOT%{l_prefix}/sbin/drupal-setup # install crond(8) job script %{l_shtool} install -c -m 755 %{l_value -s -a} \ %{SOURCE drupal-cron.sh} $RPM_BUILD_ROOT%{l_prefix}/sbin/drupal-cron +%if "%{with_dcron}" == "yes" + %{l_shtool} mkdir -f -p -m 755 \ + $RPM_BUILD_ROOT%{l_prefix}/etc/dcron/crontabs + echo "*/5 * * * * su %{l_rusr} -c %{l_prefix}/sbin/drupal-cron" \ + >$RPM_BUILD_ROOT%{l_prefix}/etc/dcron/crontabs/drupal +%endif # install custom Apache configuration l_hostname=`%{l_shtool} echo -e %h` @@ -864,10 +905,15 @@ %post if [ $1 -eq 1 ]; then # display final hints on initial installation - ( echo "1. To complete this installation of Drupal please start MySQL and" - echo " initialize the Drupal database like this:" + ( echo "1. To complete this installation of Drupal please start the RDMBS" + echo " and initialize the Drupal database like this:" +%if "%{with_mysql}" == "yes" echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc mysql start" - echo " \$ $RPM_INSTALL_PREFIX/sbin/drupal-setup" +%endif +%if "%{with_pgsql}" == "yes" + echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc postgresql start" +%endif + echo " \$ $RPM_INSTALL_PREFIX/sbin/drupal-setup install" echo "" echo "2. Now Drupal by running" echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc drupal start" @@ -879,23 +925,14 @@ echo " The first account will automatically become the main administrator" echo " account with total control over your Drupal site." echo "" - echo "3. By default, Drupal is run by the OpenPKG cron jobs only every" - echo " 15 minutes. To run Drupal every 5 minutes for more granular" - echo " data gathering, set this variable:" - echo " # $RPM_INSTALL_PREFIX/etc/rc.conf:" - echo " drupal_cron=\"no\"" - echo " and insert a new cronjob for user %{l_rusr}" - echo " # system crontab:" - echo " */5 * * * * %{l_rusr} $RPM_INSTALL_PREFIX/sbin/drupal-cron" - echo "" - echo "4. By default, Drupal runs its own Apache server on IPv4 address" + echo "3. By default, Drupal runs its own Apache server on IPv4 address" echo " 127.0.0.1, TCP port 80. Please change this by editing the" echo " \"Listen 127.0.0.1:80\" directive in" echo " $RPM_INSTALL_PREFIX/etc/drupal/drupal-apache.conf" echo " Also do not forget to adjust the \$base_url variable in:" echo " $RPM_INSTALL_PREFIX/etc/drupal/default/settings.php" echo "" - echo "5. access Drupal via:" + echo "4. access Drupal via:" echo " http://127.0.0.1:8080/drupal/ (website view)" echo " http://127.0.0.1:8080/drupal/admin (website admin)" ) | %{l_rpmtool} msg -b -t notice @@ -917,8 +954,10 @@ if [ $1 -eq 0 ]; then # before erase, stop service and remove log files %{l_rc} drupal stop 2>/dev/null - rm -f $RPM_INSTALL_PREFIX/var/drupal/log/* >/dev/null 2>&1 || true - rm -f $RPM_INSTALL_PREFIX/var/drupal/run/* >/dev/null 2>&1 || true + rm -f $RPM_INSTALL_PREFIX/var/drupal/files/* >/dev/null 2>&1 || true + rm -f $RPM_INSTALL_PREFIX/var/drupal/log/* >/dev/null 2>&1 || true + rm -f $RPM_INSTALL_PREFIX/var/drupal/run/* >/dev/null 2>&1 || true + rm -f $RPM_INSTALL_PREFIX/var/drupal/db/* >/dev/null 2>&1 || true fi exit 0 @@ . ______________________________________________________________________ OpenPKG http://openpkg.org CVS Repository Commit List openpkg-cvs@openpkg.org