From c2b060aabe32026cecc0aed3c5d9adad48b510d6 Mon Sep 17 00:00:00 2001 From: Matthew Radcliffe Date: Sat, 8 Aug 2015 14:59:46 -0400 Subject: [PATCH] Issue #38: Decouple download and installation of Drupal core and modules. --- environments/drupal-7.sh | 11 +++++++++-- environments/drupal-8.sh | 9 ++++++++- functions/drupal.sh | 18 ++++++++++++++---- runners/behat/before_script.sh | 2 +- runners/phpunit-core/before_script.sh | 6 +++--- runners/simpletest/before_script.sh | 2 +- 6 files changed, 36 insertions(+), 12 deletions(-) diff --git a/environments/drupal-7.sh b/environments/drupal-7.sh index d28bc96..04bda49 100644 --- a/environments/drupal-7.sh +++ b/environments/drupal-7.sh @@ -2,9 +2,16 @@ # @file # Drupal-7 environment variables and functions. -function drupal_ti_install_drupal() { +function drupal_ti_download_drupal() { drush --yes dl drupal-7 --drupal-project-rename=drupal - cd drupal +} + +function drupal_ti_install_drupal() { + if [ ! -f install.php ] + then + return -1 + fi + php -d sendmail_path=$(which true) ~/.composer/vendor/bin/drush.php --yes site-install "$DRUPAL_TI_INSTALL_PROFILE" --db-url="$DRUPAL_TI_DB_URL" drush use $(pwd)#default } diff --git a/environments/drupal-8.sh b/environments/drupal-8.sh index b4ee5f1..8fe0b9e 100644 --- a/environments/drupal-8.sh +++ b/environments/drupal-8.sh @@ -2,10 +2,17 @@ # @file # Drupal-8 environment variables and functions. -function drupal_ti_install_drupal() { +function drupal_ti_download_drupal() { git clone --depth 1 --branch "$DRUPAL_TI_CORE_BRANCH" http://git.drupal.org/project/drupal.git cd drupal composer install +} + +function drupal_ti_install_drupal() { + if [ ! -f install.php ] + then + return -1 + fi php -d sendmail_path=$(which true) ~/.composer/vendor/bin/drush.php --yes -v site-install "$DRUPAL_TI_INSTALL_PROFILE" --db-url="$DRUPAL_TI_DB_URL" drush use $(pwd)#default } diff --git a/functions/drupal.sh b/functions/drupal.sh index 122bbd1..3115228 100644 --- a/functions/drupal.sh +++ b/functions/drupal.sh @@ -3,7 +3,7 @@ # Common functionality for common tasks. # -# Ensures that the right Drupal version is installed. +# Ensures that the right Drupal version exists. # function drupal_ti_ensure_drupal() { # This function is re-entrant. @@ -23,12 +23,22 @@ function drupal_ti_ensure_drupal() { export PATH="$BIN_DIR:$PATH" fi - # Create database and install Drupal. - mysql -e "create database $DRUPAL_TI_DB" - mkdir -p "$DRUPAL_TI_DRUPAL_BASE" cd "$DRUPAL_TI_DRUPAL_BASE" + drupal_ti_download_drupal +} + +# +# Ensures that Drupal is installed. +# +function drupal_ti_ensure_drupal_installed() { + drupal_ti_ensure_drupal + + # Create database and install Drupal. + mysql -e "create database $DRUPAL_TI_DB" + + cd drupal drupal_ti_install_drupal } diff --git a/runners/behat/before_script.sh b/runners/behat/before_script.sh index cebdd15..7afe134 100755 --- a/runners/behat/before_script.sh +++ b/runners/behat/before_script.sh @@ -4,7 +4,7 @@ set -e $DRUPAL_TI_DEBUG # Ensure the right Drupal version is installed. -drupal_ti_ensure_drupal +drupal_ti_ensure_drupal_installed # Ensure the module is linked into the code base and enabled. drupal_ti_ensure_module diff --git a/runners/phpunit-core/before_script.sh b/runners/phpunit-core/before_script.sh index 1711d53..9954abf 100755 --- a/runners/phpunit-core/before_script.sh +++ b/runners/phpunit-core/before_script.sh @@ -3,11 +3,11 @@ set -e $DRUPAL_TI_DEBUG -# Ensure the right Drupal version is installed. +# Ensure the right Drupal version is downloaded. drupal_ti_ensure_drupal -# Ensure the module is linked into the code base and enabled. -drupal_ti_ensure_module +# Ensure the module is linked into the code base. +drupal_ti_ensure_module_linked # Ensure server is running for Functional tests drupal_ti_run_server diff --git a/runners/simpletest/before_script.sh b/runners/simpletest/before_script.sh index 5a526b6..1876359 100755 --- a/runners/simpletest/before_script.sh +++ b/runners/simpletest/before_script.sh @@ -4,7 +4,7 @@ set -e $DRUPAL_TI_DEBUG # Ensure the right Drupal version is installed. -drupal_ti_ensure_drupal +drupal_ti_ensure_drupal_installed # Enable simpletest module. cd "$DRUPAL_TI_DRUPAL_DIR"