Exemple #1
0
 /**
  * Pick right release from the XML (dev, latest published+recommended, ...).
  */
 public function testReleaseXML()
 {
     _drush_add_commandfiles(array(DRUSH_BASE_PATH . '/commands/pm'));
     $release_info = drush_include_engine('release_info', 'updatexml');
     // Use a local, static XML file because live files change over time.
     $xml = simplexml_load_file(dirname(__FILE__) . '/devel.xml');
     $project_release_info = new \Drush\UpdateService\Project($xml);
     // Pick specific release.
     $release = $project_release_info->getSpecificRelease('6.x-1.18');
     $this->assertEquals('6.x-1.18', $release['version']);
     // Pick latest recommended+published with no further specification.
     // 6.x-2.2 is skipped because it is unpublished.
     // 6.x-2.2-rc1 is skipped because it is not a stable release.
     $release = $project_release_info->getRecommendedOrSupportedRelease();
     $this->assertEquals('6.x-2.1', $release['version']);
     // Pick latest from a specific branch.
     $release = $project_release_info->getSpecificRelease('6.x-1');
     $this->assertEquals('6.x-1.23', $release['version']);
     // Pick latest from a different branch.
     // 6.x-2.2 is skipped because it is unpublished.
     // 6.x-2.2-rc1 is skipped because it is not a stable release.
     $release = $project_release_info->getSpecificRelease('6.x-2');
     $this->assertEquals('6.x-2.1', $release['version']);
     // Pick a -dev release.
     $release = $project_release_info->getSpecificRelease('6.x-1.x');
     $this->assertEquals('6.x-1.x-dev', $release['version']);
     // Test UpdateServiceProject::getSpecificRelease().
     // Test we get latest release in branch 1.
     $release = $project_release_info->getSpecificRelease('6.x-1');
     $this->assertEquals('6.x-1.23', $release['version']);
     // Test UpdateServiceProject::getDevRelease().
     $release = $project_release_info->getDevRelease();
     $this->assertEquals('6.x-1.x-dev', $release['version']);
 }
Exemple #2
0
 public function getAllModulePerms()
 {
     $permissions = array();
     drush_include_engine('drupal', 'environment');
     $module_list = drush_module_list();
     ksort($module_list);
     foreach ($module_list as $module) {
         if ($perms = $this->getModulePerms($module)) {
             $permissions = array_merge($permissions, $perms);
         }
     }
     return $permissions;
 }
Exemple #3
0
 public function install($profile)
 {
     $options['account-name'] = drush_prompt(dt('Enter the administrator (uid=1) account name'));
     $options['account-pass'] = drush_prompt(dt('Enter the administrator (uid=1) password'));
     $options['account-mail'] = drush_prompt(dt('Enter the administrator (uid=1) e-mail address'));
     $options['locale'] = drush_prompt(dt('Enter your desired locale'));
     $options['site-name'] = drush_prompt(dt('Enter the name of your site'));
     $options['site-mail'] = drush_prompt(dt('Enter the global mail address of your site'));
     // Setting the options as a drush command specific context so the site install
     // routine picks it up.
     drush_set_context('specific', $options);
     // Determin the major version and launch version specific installation.
     drush_include_engine('drupal', 'site_install', drush_drupal_major_version());
     drush_core_site_install_version($profile, $options);
     drush_log(dt('Installation finished.'), 'success');
 }
Exemple #4
0
 /**
  * Obtains release info for projects.
  */
 private function getAvailableReleases($projects)
 {
     drush_log(dt('Checking available update data ...'), LogLevel::OK);
     $release_info = drush_include_engine('release_info', 'updatexml');
     $available = array();
     foreach ($projects as $project_name => $project) {
         // Discard projects with unknown installation path.
         if ($project_name != 'drupal' && !isset($project['path'])) {
             continue;
         }
         drush_log(dt('Checking available update data for !project.', array('!project' => $project['label'])), LogLevel::OK);
         $request = pm_parse_request($project_name, NULL, $project_name);
         $project_release_info = $release_info->get($request);
         if ($project_release_info) {
             $available[$project_name] = $project_release_info;
         }
     }
     // Clear any error set by a failed project. This avoid rollbacks.
     drush_clear_error();
     return $available;
 }
Exemple #5
0
 /**
  * Pick right release from the XML (dev, latest published+recommended, ...).
  */
 public function testReleaseXML()
 {
     _drush_add_commandfiles(array(DRUSH_BASE_PATH . '/commands/pm'));
     drush_include_engine('release_info', 'updatexml');
     // Use a local, static XML file because live files change over time.
     $xml = simplexml_load_file(dirname(__FILE__) . '/devel.xml');
     // Pick specific release.
     $request_data = array('name' => 'devel', 'drupal_version' => '6.x', 'project_version' => '1.18', 'version' => '6.x-1.18');
     $release = updatexml_parse_release($request_data, $xml);
     $this->assertEquals('6.x-1.18', $release['version']);
     // Pick latest recommended+published with no further specification.
     // 6.x-2.2 is skipped because it is unpublished.
     // 6.x-2.2-rc1 is skipped because it is not a stable release.
     $request_data = array('name' => 'devel', 'drupal_version' => '6.x');
     $release = updatexml_parse_release($request_data, $xml);
     $this->assertEquals('6.x-2.1', $release['version']);
     // Pick latest from a specific branch.
     $request_data = array('name' => 'devel', 'drupal_version' => '6.x', 'version' => '6.x-1');
     $release = updatexml_parse_release($request_data, $xml);
     $this->assertEquals('6.x-1.23', $release['version']);
     // Pick latest from a different branch.
     $request_data = array('name' => 'devel', 'drupal_version' => '6.x', 'version' => '6.x-2');
     $release = updatexml_parse_release($request_data, $xml);
     // 6.x-2.2 is skipped because it is unpublished.
     // 6.x-2.2-rc1 is skipped because it is not a stable release.
     $this->assertEquals('6.x-2.1', $release['version']);
     // Pick a -dev release.
     $request_data = array('name' => 'devel', 'drupal_version' => '6.x', 'version' => '6.x-1.x');
     $release = updatexml_parse_release($request_data, $xml);
     $this->assertEquals('6.x-1.x-dev', $release['version']);
     // Test $restrict_to parameter.
     $request_data['version'] = '6.x-1';
     $release = updatexml_parse_release($request_data, $xml, 'version');
     $this->assertEquals('6.x-1.23', $release['version']);
     $release = updatexml_parse_release($request_data, $xml, 'dev');
     $this->assertEquals('6.x-1.x-dev', $release['version']);
 }
Exemple #6
0
 public function getModulePerms($module)
 {
     drush_include_engine('drupal', 'environment');
     $perms = drush_module_invoke($module, 'permission');
     return $perms ? array_keys($perms) : array();
 }
Exemple #7
0
 public function dumpFile($file)
 {
     $database = $this->db_spec['database'];
     // $file is passed in to us usually via --result-file.  If the user
     // has set $options['result-file'] = TRUE, then we
     // will generate an SQL dump file in the same backup
     // directory that pm-updatecode uses.
     if ($file) {
         if ($file === TRUE) {
             // User did not pass a specific value for --result-file. Make one.
             $backup = drush_include_engine('version_control', 'backup');
             $backup_dir = $backup->prepare_backup_dir($database);
             if (empty($backup_dir)) {
                 $backup_dir = drush_find_tmp();
             }
             $file = $backup_dir . '/@DATABASE_@DATE.sql';
         }
         $file = str_replace(array('@DATABASE', '@DATE'), array($database, gmdate('Ymd_His')), $file);
     }
     return $file;
 }
Exemple #8
0
 /**
  * Attempt to load the full Drupal system.
  */
 function bootstrap_drupal_full()
 {
     drush_include_engine('drupal', 'environment');
     $this->add_logger();
     // Write correct install_profile to cache as needed. Used by _drush_find_commandfiles().
     $cid = drush_cid_install_profile();
     $install_profile = $this->get_profile();
     if ($cached_install_profile = drush_cache_get($cid)) {
         // We have a cached profile. Check it for correctness and save new value if needed.
         if ($cached_install_profile->data != $install_profile) {
             drush_cache_set($cid, $install_profile);
         }
     } else {
         // No cached entry so write to cache.
         drush_cache_set($cid, $install_profile);
     }
     _drush_log_drupal_messages();
 }
Exemple #9
0
/**
 * Automatically download project dependencies at pm-enable time.
 *
 * Use a pre-pm_enable hook to download before your module is enabled,
 * or a post-pm_enable hook (drush_hook_post_pm_enable) to run after
 * your module is enabled.
 *
 * Your hook will be called every time pm-enable is executed; you should
 * only download dependencies when your module is being enabled.  Respect
 * the --skip flag, and take no action if it is present.
 */
function drush_hook_pre_pm_enable()
{
    // Get the list of modules being enabled; only download dependencies if our
    // module name appears in the list.
    $modules = drush_get_context('PM_ENABLE_MODULES');
    if (in_array('hook', $modules) && !drush_get_option('skip')) {
        $url = 'http://server.com/path/MyLibraryName.tgz';
        $path = drush_get_context('DRUSH_DRUPAL_ROOT');
        drush_include_engine('drupal', 'environment');
        if (drush_module_exists('libraries')) {
            $path .= '/' . libraries_get_path('MyLibraryName') . '/MyLibraryName.tgz';
        } else {
            $path .= '/' . drupal_get_path('module', 'hook') . '/MyLibraryName.tgz';
        }
        drush_download_file($url, $path) && drush_tarball_extract($path);
    }
}