commit 159a2c97a5a1dc504cc12f4650f30b09ded303f7 Author: Damien Tournoud Date: Fri May 10 12:05:11 2013 +0200 Make: Support using a distribution as core. diff --git a/commands/make/make.download.inc b/commands/make/make.download.inc index 74096d0..f766731 100644 --- a/commands/make/make.download.inc +++ b/commands/make/make.download.inc @@ -10,10 +10,10 @@ * @return mixed * The destination path on success, FALSE on failure. */ -function make_download_factory($name, $download, $download_location) { +function make_download_factory($name, $type, $download, $download_location) { $function = 'make_download_' . $download['type']; if (function_exists($function)) { - return $function($name, $download, $download_location); + return $function($name, $type, $download, $download_location); } else { return FALSE; @@ -23,7 +23,7 @@ function make_download_factory($name, $download, $download_location) { /** * Download project using drush's pm-download command. */ -function make_download_pm($name, $download, $download_location) { +function make_download_pm($name, $type, $download, $download_location) { $full_project_version = $name . '-' . $download['full_version']; $options = array( @@ -33,10 +33,10 @@ function make_download_pm($name, $download, $download_location) { 'source' => $download['status url'], // This is only relevant for profiles, but we always want the variant to // be 'profile-only' so we don't end up with extra copies of core. - 'variant' => 'profile-only', + 'variant' => $type == 'core' ? 'full' : 'profile-only', 'cache' => TRUE, ); - if ($name == 'drupal') { + if ($type == 'core') { $options['drupal-project-rename'] = basename($download_location); } if (drush_get_option('no-cache', FALSE)) { @@ -64,7 +64,7 @@ function make_download_pm($name, $download, $download_location) { * @return mixed * The destination directory on success, FALSE on failure. */ -function make_download_file($name, $download, $download_location, $cache_duration = DRUSH_CACHE_LIFETIME_DEFAULT) { +function make_download_file($name, $type, $download, $download_location, $cache_duration = DRUSH_CACHE_LIFETIME_DEFAULT) { if ($filename = _make_download_file($download['url'], $cache_duration)) { if (!drush_get_option('ignore-checksums') && !_make_verify_checksums($download, $filename)) { return FALSE; @@ -190,8 +190,8 @@ function _make_download_file_move($tmp_path, $filename, $download_location, $sub /** * For backwards compatibility. */ -function make_download_get($name, $download, $download_location) { - return make_download_file($name, $download, $download_location); +function make_download_get($name, $type, $download, $download_location) { + return make_download_file($name, $type, $download, $download_location); } /** @@ -213,7 +213,7 @@ function make_download_get($name, $download, $download_location) { * @return mixed * The download location on success, FALSE otherwise. */ -function make_download_git($name, $download, $download_location) { +function make_download_git($name, $type, $download, $download_location) { $tmp_path = make_tmp(); $wc = drush_get_option('working-copy'); // If no download URL specified, assume anonymous clone from git.drupal.org. @@ -346,7 +346,7 @@ function make_download_git($name, $download, $download_location) { * @return mixed * The download location on success, FALSE otherwise. */ -function make_download_bzr($name, $download, $download_location) { +function make_download_bzr($name, $type, $download, $download_location) { $tmp_path = make_tmp(); $tmp_location = drush_tempdir() . '/' . basename($download_location); if (!empty($download['url'])) { @@ -392,7 +392,7 @@ function make_download_bzr($name, $download, $download_location) { * @return mixed * The download location on success, FALSE otherwise. */ -function make_download_svn($name, $download, $download_location) { +function make_download_svn($name, $type, $download, $download_location) { if (!empty($download['url'])) { if (!empty($download['interactive'])) { $function = 'drush_shell_exec_interactive'; diff --git a/commands/make/make.drush.inc b/commands/make/make.drush.inc index 2004d63..e1a5521 100644 --- a/commands/make/make.drush.inc +++ b/commands/make/make.drush.inc @@ -357,8 +357,10 @@ function make_projects($recursion, $contrib_destination, $info, $build_path, $ma } // Restore the previous '--cache' option value. drush_set_option('cache', $cache_before); - // Translate release_info key for project_type to drush make. - $project['type'] = $request['project_type']; + if (!isset($project['type'])) { + // Translate release_info key for project_type to drush make. + $project['type'] = $request['project_type']; + } if (!isset($project['download'])) { $project['download'] = array( 'type' => 'pm', diff --git a/commands/make/make.project.inc b/commands/make/make.project.inc index 412d16d..e89211d 100644 --- a/commands/make/make.project.inc +++ b/commands/make/make.project.inc @@ -122,7 +122,7 @@ class DrushMakeProject { $this->download['full_version'] = $full_version; } - if (make_download_factory($this->name, $this->download, $this->download_location) === FALSE) { + if (make_download_factory($this->name, $this->type, $this->download, $this->download_location) === FALSE) { $this->downloaded = FALSE; } return $this->downloaded; diff --git a/tests/makeTest.php b/tests/makeTest.php index 6798f43..5bba714 100644 --- a/tests/makeTest.php +++ b/tests/makeTest.php @@ -349,6 +349,13 @@ class makeMakefileCase extends Drush_CommandTestCase { $this->assertFileExists(UNISH_SANDBOX . '/sites/all/modules/contrib/cck_signup/README.txt'); } + /** + * Test that a distribution can be used as a "core" project. + */ + function testMakeUseDistributionAsCore() { + $this->runMakefileTest('use-distribution-as-core'); + } + function getMakefile($key) { static $tests = array( 'get' => array( @@ -540,6 +547,13 @@ class makeMakefileCase extends Drush_CommandTestCase { 'md5' => '7c10e6fc65728a77a2b0aed4ec2a29cd', 'options' => array('no-core' => NULL, 'libraries' => 'drush_make,token'), ), + 'use-distribution-as-core' => array( + 'name' => 'Use distribution as core', + 'makefile' => 'use-distribution-as-core.make', + 'build' => TRUE, + 'md5' => '643a603025a20d498eb583a1e7970bad', + 'options' => array(), + ), ); return $tests[$key]; } diff --git a/tests/makefiles/use-distribution-as-core.make b/tests/makefiles/use-distribution-as-core.make new file mode 100644 index 0000000..489c520 --- /dev/null +++ b/tests/makefiles/use-distribution-as-core.make @@ -0,0 +1,7 @@ +api = 2 +core = 7.x + +projects[commerce_kickstart][type] = core +projects[commerce_kickstart][version] = "7.x-1.19" +projects[oauth2_server][type] = module +projects[oauth2_server][version] = "1.0-beta2"