Index: drush_make.drush.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush_make/Attic/drush_make.drush.inc,v
retrieving revision 1.11.2.40
diff -u -p -r1.11.2.40 drush_make.drush.inc
--- drush_make.drush.inc	25 Feb 2010 05:38:00 -0000	1.11.2.40
+++ drush_make.drush.inc	8 Jun 2010 20:16:14 -0000
@@ -45,6 +45,26 @@ function drush_make_drush_command() {
     ),
   );
 
+  $items['remake'] = array(
+    'bootstrap' => DRUSH_BOOTSTRAP_DRUSH,
+    'description' => 'Rebuilds an existing drupal installation using a makefile.',
+    'arguments' => array(
+      'makefile' => 'Filename of the makefile to use for this build.',
+      'build path' => 'The path of the existing drupal installation to rebuild using the specified makefile.',
+    ),
+    'examples' => array(
+      'drush remake example.make example' => 'Build the example.make makefile in a temporary directory, and copy over the existing site\'s files and settings.  If the build is successful, the site in the example directory is overwritten with the new build.',
+    ),
+    'options' => array(
+      '--contrib-destination=path' => 'Specify a path under which modules and themes should be placed. Defaults to sites/all.',
+      '--force-complete' => 'Force a complete build even if errors occur.',
+      '--no-clean' => 'Leave temporary build directories in place instead of cleaning up after completion.',
+      '--no-core' => 'Do not require a Drupal core project to be specified.',
+      '--no-patch-txt' => 'Do not write a PATCHES.txt file in the directory of each patched project.',
+      '--working-copy' => 'Where possible, retrieve a working copy of projects from their respective repositories.',
+    ),
+  );
+
   $items['generate-makefile'] = array(
     'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
     'description' => 'Attempts to generate a makefile from the current drupal install.',
@@ -60,6 +80,8 @@ function drush_make_drush_help($section)
   switch ($section) {
     case 'drush:make':
       return dt('Turns a makefile into a working drupal install. For a full description of options and makefile syntax, see the README.txt included with drush make.');
+    case 'drush:remake':
+      return dt('Rebuilds an existing drupal installation using a makefile.  The makefile is built in a temporary directory, and the existing site\'s files and settings are copied.  If the build is successful, the existing site is overwritten with the new build.');
     case 'drush:generate makefile':
       return dt('Attempts to generate a makefile from the current drupal install.');
   }
@@ -102,6 +124,39 @@ function drush_drush_make_make($makefile
   $queue->execute();
 }
 
+/**
+ * Drush callback; remake based on the makefile.
+ */
+function drush_drush_make_remake($makefile = NULL, $base_path = NULL) {
+  $queue = new DrushMakeQueue();
+  $drush_version = $queue->addItem('drush_make_ensure_version');
+  $base_path = $queue->addItem('drush_make_base_path', array($base_path), array($drush_version));
+  $file_exists = $queue->addItem('drush_make_base_path_validate_remake', array(), $base_path);
+  $info  = $queue->addItem('drush_make_parse_info_file', $makefile, $file_exists);
+  $valid = $queue->addItem('drush_make_validate_info_file', array(), $info);
+  $tmp = $queue->addItem('drush_make_create_tmp', array(), $valid);
+  $projects = $queue->addItem('drush_make_add_projects', array(FALSE, drush_get_option('contrib-destination', 'sites/all')), array($tmp, $base_path, $valid));
+  $queue->addItem('drush_make_add_libraries', array(drush_get_option('contrib-destination', 'sites/all')), array($tmp, $base_path, $valid));
+  $queue->execute();
+
+  $queue->addItem('drush_make_add_files', array(), array($tmp, $base_path, $valid));
+  $queue->addItem('drush_make_add_settings', array(), array($tmp, $base_path, $valid));
+  $queue->execute();
+
+  $queue->addItem('drush_make_move_site', array(), array($base_path, $valid));
+  $queue->addItem('drush_make_move_build', array(), array($tmp, $base_path, $valid));
+  $queue->addItem('drush_make_clean_tmp', array(), array($tmp));
+  $queue->execute();
+}
+
+function drush_make_add_files($tmp_path, $base_path, $info, $queue) {
+  return drush_shell_exec("cp -a %s/sites/default/files/ %s/__build__/sites/default/files/", $base_path, $tmp_path, $base_path);
+}
+
+function drush_make_add_settings($tmp_path, $base_path, $info, $queue) {
+  return copy($base_path . '/sites/default/settings.php', $tmp_path . '/__build__/sites/default/settings.php');
+}
+
 function drush_make_add_projects($recursion, $install_path, $tmp_path, $base_path, $info, $queue) {
   $projects = array();
   foreach ($info['projects'] as $key => $project) {
@@ -323,6 +378,13 @@ function drush_make_base_path($base_path
   return $base_path;
 }
 
+function drush_make_move_site($base_path) {
+  $backup_path = $base_path . '/../backups/' . date('Ymd-His-') . basename($base_path);
+  drush_make_fill_path($backup_path);
+  drush_shell_exec("mv %s %s", $base_path, $backup_path);
+  return TRUE;
+}
+
 function drush_make_move_build($tmp_path, $base_path) {
   if ($base_path == '.') {
     drush_shell_exec('ls -A %s/__build__', $tmp_path);
Index: drush_make.utilities.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush_make/Attic/drush_make.utilities.inc,v
retrieving revision 1.1.2.28
diff -u -p -r1.1.2.28 drush_make.utilities.inc
--- drush_make.utilities.inc	22 Apr 2010 23:30:14 -0000	1.1.2.28
+++ drush_make.utilities.inc	8 Jun 2010 20:16:14 -0000
@@ -25,6 +25,50 @@ function drush_make_base_path_validate($
 }
 
 /**
+ * Check whether $dir contains any files/directories aside from those listed in $content_array
+ */
+function drush_make_directory_validate($dir, $content_array) {
+  $dh = opendir($dir);
+  $error = FALSE;
+  while (($file = readdir($dh)) !== false) {
+    if (!in_array($file, array_merge(array('.','..'),$content_array))) {
+      drush_set_error(dt("Found '%file' in %path.  I'm not sure what this is, so I'm not going to continue.", array('%file' => $file, '%path' => $dir)));
+      $error = TRUE;
+    }
+  }
+  closedir($dh);
+  return !$error;
+}
+
+function drush_make_base_path_validate_remake($base_path) {
+  if ($base_path == '.') {
+    drush_set_error(dt("'.' cannot be used as the remake base path."));
+    return FALSE;
+  }
+
+  if (!file_exists($base_path)) {
+    drush_set_error(dt('Base path %path doesn\'t already exist', array('%path' => $base_path)));
+    return FALSE;
+  }
+
+  $sites_path = $base_path . '/sites';
+  if (!file_exists($sites_path . '/default/settings.php')) {
+    drush_set_error(dt('Can\'t find settings.php for the default site in %path', array('%path' => $base_path)));
+    return FALSE;
+  }
+
+  if (!drush_make_directory_validate($sites_path, array('all','default'))) {
+    return FALSE;
+  }
+
+  if (!drush_make_directory_validate($sites_path . '/default', array('default.settings.php','settings.php','files'))) {
+    return FALSE;
+  }
+
+  return TRUE;
+}
+
+/**
  * Parse Drupal info file format.
  *
  * Copied with modifications from includes/common.inc.
