function make_prepare_projects

8.0.x make.drush.inc make_prepare_projects($recursion, $info, $contrib_destination = '', $build_path = '', $make_dir = '')
7.x make.drush.inc make_prepare_projects($recursion, $info, $contrib_destination = '', $build_path = '', $make_dir = '')
master make.drush.inc make_prepare_projects($recursion, $info, $contrib_destination = '', $build_path = '', $make_dir = '')

Gather additional data on all projects specified in the make file.

3 calls to make_prepare_projects()
drush_make_update in commands/make/update.make.inc
Command callback for make-update.
make_generate_from_makefile in commands/make/generate.contents.make.inc
Write a makefile based on data parsed from a previous makefile.
make_projects in commands/make/make.drush.inc
Process all projects specified in the make file.

File

commands/make/make.drush.inc, line 429
Drush Make commands.

Code

function make_prepare_projects($recursion, $info, $contrib_destination = '', $build_path = '', $make_dir = '') {
  $release_info = drush_get_engine('release_info');

  // Nothing to make if the project list is empty. Maybe complain about it.
  if (empty($info['projects'])) {
    if (drush_get_option('no-core') || $recursion) {
      return TRUE;
    }
    else {
      return drush_set_error('MAKE_NO_CORE', dt('No core project specified.'));
    }
  }

  // Obtain translations to download along with the projects.
  $translations = array();
  if (isset($info['translations'])) {
    $translations = $info['translations'];
  }
  if ($arg_translations = drush_get_option('translations', FALSE)) {
    $translations = array_merge(explode(',', $arg_translations), $translations);
  }

  // Normalize projects.
  $projects = array();
  $ignore_checksums = drush_get_option('ignore-checksums');
  foreach ($info['projects'] as $key => $project) {
    // Merge the known data onto the project info.
    $project += array(
      'name' => $key,
      'type' => 'module',
      'core' => $info['core'],
      'translations' => $translations,
      'build_path' => $build_path,
      'contrib_destination' => $contrib_destination,
      'version' => '',
      'location' => drush_get_option('make-update-default-url', ReleaseInfo::DEFAULT_URL),
      'subdir' => '',
      'directory_name' => '',
      'make_directory' => $make_dir,
      'options' => array(),
    );
    // MD5 Checksum.
    if ($ignore_checksums) {
      unset($project['download']['md5']);
    }
    elseif (!empty($project['md5'])) {
      $project['download']['md5'] = $project['md5'];
    }

    // If download components are specified, but not the download
    // type, default to git.
    if (isset($project['download']) && !isset($project['download']['type'])) {
      $project['download']['type'] = 'git';
    }
    // Localization server.
    if (!isset($project['l10n_url']) && ($project['location'] == ReleaseInfo::DEFAULT_URL)) {
      $project['l10n_url'] = MAKE_DEFAULT_L10N_SERVER;
    }
    // Classify projects in core or contrib.
    if ($project['type'] == 'core') {
      $project['download_type'] = 'core';
    }
    elseif ($project['location'] != ReleaseInfo::DEFAULT_URL || !isset($project['download'])) {
      $request = make_prepare_request($project);
      $is_core = $release_info->checkProject($request, 'core');
      $project['download_type'] = ($is_core ? 'core' : 'contrib');
      $project['type'] = $is_core ? 'core' : $project['type'];
    }
    else {
      $project['download_type'] = ($project['name'] == 'drupal' ? 'core' : 'contrib');
    }
    $projects[$project['download_type']][$project['name']] = $project;
  }

  // Verify there're enough cores, but not too many.
  $cores = !empty($projects['core']) ? count($projects['core']) : 0;
  if (drush_get_option('no-core')) {
    unset($projects['core']);
  }
  elseif ($cores == 0 && !$recursion) {
    return drush_set_error('MAKE_NO_CORE', dt('No core project specified.'));
  }
  elseif ($cores == 1 && $recursion) {
    unset($projects['core']);
  }
  elseif ($cores > 1) {
    return drush_set_error('MAKE_MULTIPLE_CORES', dt('More than one core project specified.'));
  }

  // Set download type = pm for suitable projects.
  foreach (array_keys($projects) as $project_type) {
    foreach ($projects[$project_type] as $project) {
      if (make_project_needs_release_info($project)) {
        $request = make_prepare_request($project, $project_type);
        $release = $release_info->selectReleaseBasedOnStrategy($request, '', 'ignore');
        if ($release === FALSE) {
          return FALSE;
        }
        // Override default project type with data from update service.
        if (!isset($info['projects'][$project['name']]['type'])) {
          $project['type'] = $release_info->get($request)->getType();
        }

        if (!isset($project['download'])) {
          $project['download'] = array(
            'type' => 'pm',
            'full_version' => $release['version'],
            'download_link' => $release['download_link'],
            'status url' => $request['status url'],
          );
        }
      }
      $projects[$project_type][$project['name']] = $project;
    }
  }
  if (!$recursion) {
    $projects += array(
      'core' => array(),
      'contrib' => array(),
    );
    drush_set_option('DRUSH_MAKE_PROJECTS', array_merge($projects['core'], $projects['contrib']));
  }
  return $projects;
}