From 5da936f082a2bd1ca38eecb7cd25c878066faca7 Mon Sep 17 00:00:00 2001
From: bash: git: command not found <eporama@gmail.com>
Date: Mon, 2 May 2011 00:07:08 -0400
Subject: [PATCH] Issues #1100686: Added psuedo-progressive batch to site-install

---
 commands/core/drupal/site_install_6.inc |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/commands/core/drupal/site_install_6.inc b/commands/core/drupal/site_install_6.inc
index b704ff3..9f211c0 100644
--- a/commands/core/drupal/site_install_6.inc
+++ b/commands/core/drupal/site_install_6.inc
@@ -17,11 +17,19 @@ function drush_core_site_install_version($profile) {
   drush_shell_exec('php -r %s', $phpcode);
   $cli_output = drush_shell_exec_output();
   $cli_cookie = end($cli_output);
+
+  // We need to bootstrap the database to be able to check the progress of the 
+  // install batch process since we're not duplicating the install process using
+  // drush_batch functions, but calling the process directly.
+  drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_DATABASE);
+
   $phpcode = _drush_site_install6_cookies($profile, $cli_cookie). ' $_GET["op"]="start"; include("'. $drupal_root .'/install.php");';
   drush_shell_exec('php -r %s', $phpcode);
 
-  $phpcode = _drush_site_install6_cookies($profile, $cli_cookie). ' $_GET["op"]="do_nojs"; include("'. $drupal_root .'/install.php");';
-  drush_shell_exec('php -r %s', $phpcode);
+  while (!_drush_site_install6_batch_check()) {
+    $phpcode = _drush_site_install6_cookies($profile, $cli_cookie). ' $_GET["op"]="do_nojs"; include("'. $drupal_root .'/install.php");';
+    drush_shell_exec('php -r %s', $phpcode);
+  }
 
   $phpcode = _drush_site_install6_cookies($profile, $cli_cookie). ' $_GET["op"]="finished"; include("'. $drupal_root .'/install.php");';
   drush_shell_exec('php -r %s', $phpcode);
@@ -71,3 +79,13 @@ register_shutdown_function("_cli_cookie_print");';
 
   return $output;
 }
+
+/**
+ * Utility function to see if batch succeeded.
+ */
+function _drush_site_install6_batch_check() {
+  if ($data = db_result(db_query("SELECT batch FROM {batch} WHERE bid = %d",1))) {
+    $batch = unserialize($data);
+  }
+  return($batch['sets'][0]['success']);
+}
-- 
1.7.1.1

