Index: drush_make.download.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush_make/Attic/drush_make.download.inc,v
retrieving revision 1.1.2.31
diff -u -F '^f' -u -F '^f' -r1.1.2.31 drush_make.download.inc
--- drush_make.download.inc	22 Apr 2010 23:30:14 -0000	1.1.2.31
+++ drush_make.download.inc	25 Apr 2010 06:37:25 -0000
@@ -3,11 +3,9 @@
 
 class DrushMakeDownload {
   var $project;
-  var $path;
 
   function __construct($project) {
     $this->project = $project;
-    $this->path = !empty($this->project->directory_name) ? $this->project->directory_name : $this->project->name;
     $this->preDownload();
   }
 
@@ -56,10 +54,13 @@
       }
 
       // Checkout or export the module. CVS can't use absolute paths for named
-      // directories, so change into the tmp directory before checking out. 
-      if (drush_make_cd($tmp_path, "cvs -d%s %s -d%s %s %s", $download['root'], $command, $name, $flags, $download['module'])) {
+      // directories, so change into the directory just above the final
+      // destination for the checkout. 
+      $cd_to_directory = dirname($this->project->download_location);
+      $destination_directory = basename($this->project->download_location);
+      if (drush_make_cd($cd_to_directory, "cvs -d%s %s -d%s %s %s", $download['root'], $command, $destination_directory, $flags, $download['module'])) {
         drush_log(dt('%project @command from %module.', array('%project' => $name, '@command' => $command, '%module' => $download['module'])), 'ok');
-        return $name;
+        return TRUE;
       }
     }
     else {
@@ -92,16 +93,31 @@
   }
 
   protected function unpack_tar($filename) {
-    // Untar it and then delete the tar file.
+    // Untar it.
     drush_shell_exec('tar -tf %s', $filename);
+
     $info = drush_shell_exec_output();
     if ($info) {
+      // Determine the first part of the directory in the tarball directory
+      // tree.
       list($first_line) = drush_shell_exec_output();
       list($directory) = explode('/', $first_line);
-      drush_make_cd($this->project->tmp_path, 'tar -xf %s', $filename);
+      // Remove the extra directory from the tarball directory tree if
+      // we've already created it, or if it's the core project. 
+      if ($this->project->name == 'drupal' || $directory == $this->project->project_directory) {
+        $strip_components = 1;
+      }
+      else {
+        $strip_components = 0;
+      }
+      // Untar directly to final resting place -- allows tarballs to be
+      // unpacked directly over an existing structure.
+      drush_shell_exec("tar -x --strip-components %s -C %s -f %s", $strip_components, $this->project->download_location, $filename);
+
+      // Remove the tarball.
       drush_op('unlink', $filename);
 
-      return $directory;
+      return TRUE;
     }
 
     drush_make_error('PACKAGE_ERROR', dt('Could not retrieve package information for %filename.', array('%filename' => $filename)));
@@ -128,7 +144,8 @@
   }
 
   protected function unpack_zip($filename) {
-    // Find out where contents will end up. Retrieve last column of output using awk.
+    // Find the main directory in the zip file. Retrieve last column of output
+    // using awk.
     drush_shell_exec("unzip -l %s | awk '{print $4;}'", $filename);
     $info = drush_shell_exec_output();
     if ($info) {
@@ -140,15 +157,27 @@
           break;
         }
       }
+
       if (isset($directory)) {
-        drush_shell_exec("unzip %s -d %s", $filename, $this->project->tmp_path);
+        // Remove the extra directory from the destination if it already exists
+        // in the zip file. 
+        if ($directory == $this->project->project_directory) {
+          $download_location = dirname($this->project->download_location);
+        }
+        else {
+          $download_location = $this->project->download_location;
+        }
+
+        // Unzip directly to final resting place -- allows zip files to be
+        // unpacked directly over an existing structure.
+        drush_shell_exec("unzip %s -d %s", $filename, $download_location);
         if (file_exists($filename)) {
           drush_shell_exec('rm %s', $filename);
         }
-        if (is_dir($this->project->tmp_path . '/__MACOSX')) {
-          drush_shell_exec('rm -r %s', $this->project->tmp_path . '/__MACOSX');
+        if (is_dir($download_location . '/__MACOSX')) {
+          drush_shell_exec('rm -r %s', $download_location . '/__MACOSX');
         }
-        return $directory;
+        return TRUE;
       }
     }
     drush_make_error('PACKAGE_ERROR', dt('Could not retrieve package information for %filename.', array('%filename' => $filename)));
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 -F '^f' -u -F '^f' -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	25 Apr 2010 06:37:25 -0000
@@ -332,7 +332,7 @@ function drush_make_move_build($tmp_path
     }
   }
   else {
-    drush_make_fill_path(dirname($base_path));
+    drush_shell_exec("mkdir -p %s", dirname($base_path));
     drush_shell_exec("mv %s/__build__ %s", $tmp_path, $base_path);
   }
   return TRUE;
Index: drush_make.project.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush_make/Attic/drush_make.project.inc,v
retrieving revision 1.1.2.22
diff -u -F '^f' -u -F '^f' -r1.1.2.22 drush_make.project.inc
--- drush_make.project.inc	22 Apr 2010 23:30:14 -0000	1.1.2.22
+++ drush_make.project.inc	25 Apr 2010 06:37:25 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: drush_make.project.inc,v 1.1.2.22 2010/04/22 23:30:14 dmitrig01 Exp $
+// $Id: drush_make.project.inc,v 1.1.2.21 2010/02/27 16:54:48 yhahn Exp $
 
 /**
  * The base project class.
@@ -24,24 +24,28 @@
    */
   function make() {
     if (empty($this->made)) {
-      $directory = $this->queue->addItem(array($this->downloadClass, 'download'));
-      $full_path = $this->queue->addItem(array($this, 'makePath'), array(), $directory);
-      $move = $this->queue->addItem(array($this, 'move'), array(), array($directory, $full_path));
-      $this->queue->addItem(array($this, 'applyPatches'), array(), array($move));
-      $this->queue->addItem(array($this, 'recurse'), array(), array($move, $directory));
+      $download_location = $this->queue->addItem(array($this, 'findDownloadLocation'), array(), array());
+      $this->queue->addItem(array($this->downloadClass, 'download'), array(), array($download_location));
+      $this->queue->addItem(array($this, 'applyPatches'), array(), array($download_location));
+      $this->queue->addItem(array($this, 'recurse'), array(), array($download_location));
       $this->made = TRUE;
     }
     return FALSE;
   }
 
-  function makePath($directory) {
+  function findDownloadLocation($directory) {
     $this->path = $this->generatePath();
-    drush_make_fill_path($this->path);
-    if (is_dir($this->path . '/' . $directory)) {
-      drush_set_error(dt('Directory not empty: %directory', array('%directory' => $directory)));
-      drush_shell_exec('rm -r %s', $directory);
+    $this->project_directory = !empty($this->directory_name) ? $this->directory_name : $this->name;
+    $this->download_location = $this->path . '/' . $this->project_directory;
+    // This directory shouldn't exist yet -- if it does, stop.
+    if (is_dir($this->download_location)) {
+      drush_set_error(dt('Directory not empty: %directory', array('%directory' => $this->download_location)));
+      $this->queue->terminate();
     }
-    return $this->path;
+    else {
+      drush_shell_exec("mkdir -p %s", $this->download_location);
+    }
+    return $this->download_location;
   }
 
   /**
@@ -77,25 +81,10 @@
     }
   }
 
-  /**
-   * Move a project to its final resting place.
-   */
-  function move($project_directory) {
-    if (empty($this->directory_name)) {
-      drush_shell_exec("mv %s/%s %s", $this->tmp_path, $project_directory, $this->path);
-    }
-    else {
-      list($project_directory) = array_reverse(explode('/', trim($project_directory, '/')));
-      drush_shell_exec("mv %s/%s %s/%s", $this->tmp_path, $project_directory, $this->path, $this->directory_name);
-      $project_directory = $this->directory_name;
-    }
-    return $this->path . '/' . $project_directory;
-  }
-
-  /**
+   /**
    * Generate the proper path for this project type.
    *
-   * @param $absolute
+   * @param $base
    *   Whether to generate an absolute path, including the temporary directory path.
    *   Defaults to true.
    */
@@ -147,26 +136,17 @@
     $this->install_path = '';
   }
 
-  function makePath($directory) {
-    $this->path = $this->generatePath();
-    drush_make_fill_path(dirname($this->path));
-    if (is_dir($this->path . '/' . $directory)) {
-      drush_set_error(dt('Directory not empty: %directory', array('%directory' => $directory)));
-      drush_shell_exec('rm -r %s', $directory);
-      return FALSE;
+  function findDownloadLocation() {
+    $this->path = $this->download_location = $this->generatePath();
+    $this->project_directory = '';
+    if (is_dir($this->download_location)) {
+      drush_set_error(dt('Directory not empty: %directory', array('%directory' => $this->download_location)));
+      $this->queue->terminate();
     }
-    return $this->path;
-  }
-
-  /**
-   * The core project will always be the base of the build, so it needs to move
-   * itself into place a little differently.
-   *
-   * @TODO ensure that the core project is always created first.
-   */
-  function move($project_directory) {
-    drush_shell_exec("mv %s/%s %s/__build__", $this->tmp_path, $project_directory, $this->tmp_path);
-    return $this->tmp_path . '/__build__';
+    else {
+      drush_shell_exec("mkdir -p %s", $this->download_location);
+    }
+    return $this->download_location;
   }
 }
 
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 -F '^f' -u -F '^f' -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	25 Apr 2010 06:37:25 -0000
@@ -254,7 +254,7 @@ function drush_make_prepare_install($tmp
 }
 
 function drush_make_tar($tmp_path, $base_path) {
-  drush_make_fill_path(dirname($base_path));
+  drush_shell_exec("mkdir -p %s", dirname($base_path));
   $filename = basename($base_path);
   $dirname = basename($base_path, '.tar.gz');
   // Move the build directory to a more human-friendly name, so that tar will
@@ -270,23 +270,6 @@ function drush_make_tar($tmp_path, $base
 }
 
 /**
- * Wrapper around drush_op('mkdir') to create all the directories up to and including the basename().
- */
-function drush_make_fill_path($path) {
-  $built_path = array();
-  foreach (explode('/', $path) as $part) {
-    if ($part == '.') {
-      continue;
-    }
-    $built_path[] = $part;
-    $current_path = implode('/', $built_path);
-    if ($current_path && !is_dir($current_path)) {
-      drush_op('mkdir', $current_path);
-    }
-  }
-}
-
-/**
  * Logs an error unless the --force-complete command line option is specified.
  */
 function drush_make_error($error_code, $message) {
@@ -391,4 +374,4 @@ function drush_make_get_remote_file($url
   else {
     return drush_set_error('drush_make_download_error', 'Unable to download remote file. No download services supported.');
   }
-}
\ No newline at end of file
+}
