function make_download_bzr

8.0.x make.download.inc make_download_bzr($name, $type, $download, $download_location)
6.x make.download.inc make_download_bzr($name, $type, $download, $download_location)
7.x make.download.inc make_download_bzr($name, $type, $download, $download_location)
5.x make.download.inc make_download_bzr($name, $type, $download, $download_location)
master make.download.inc make_download_bzr($name, $type, $download, $download_location)

Checks out a Bazaar repository to the specified download location.

Return value

mixed The download location on success, FALSE otherwise.

File

commands/make/make.download.inc, line 368
Download-specific functions for Drush Make.

Code

function make_download_bzr($name, $type, $download, $download_location) {
  $tmp_path = make_tmp();
  $tmp_location = drush_tempdir() . '/' . basename($download_location);
  $wc = _get_working_copy_option($download);
  if (!empty($download['url'])) {
    $args = array();
    $command = 'bzr';
    if ($wc) {
      $command .= ' branch  --use-existing-dir';
    }
    else {
      $command .= ' export';
    }
    if (isset($download['revision'])) {
      $command .= ' -r %s';
      $args[] = $download['revision'];
    }
    $command .= ' %s %s';
    if ($wc) {
      $args[] = $download['url'];
      $args[] = $tmp_location;
    }
    else {
      $args[] = $tmp_location;
      $args[] = $download['url'];
    }
    array_unshift($args, $command);
    if (call_user_func_array('drush_shell_exec', $args)) {
      drush_log(dt('@project downloaded from @url.', array('@project' => $name, '@url' => $download['url'])), LogLevel::OK);
      drush_copy_dir($tmp_location, $download_location, FILE_EXISTS_OVERWRITE);
      return dirname($download_location);
    }
  }
  else {
    $download['url'] = dt("unspecified location");
  }
  make_error('DOWNLOAD_ERROR', dt('Unable to download @project from @url.', array('@project' => $name, '@url' => $download['url'])));
  drush_delete_dir(dirname($tmp_location), TRUE);
  return FALSE;
}