function make_move_build

8.0.x make.drush.inc make_move_build($build_path)
6.x make.drush.inc make_move_build($build_path)
7.x make.drush.inc make_move_build($build_path)
5.x make.drush.inc make_move_build($build_path)
master make.drush.inc make_move_build($build_path)

Move the completed build into place.

1 call to make_move_build()
drush_make in commands/make/make.drush.inc
Drush callback; make based on the makefile.

File

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

Code

function make_move_build($build_path) {
  $tmp_path = make_tmp();
  $ret = TRUE;
  if ($build_path == '.' || (drush_get_option('no-core', FALSE) && file_exists($build_path))) {
    $info = drush_scan_directory($tmp_path . DIRECTORY_SEPARATOR . '__build__', '/./', array('.', '..'), 0, FALSE, 'filename', 0, TRUE);
    foreach ($info as $file) {
      $destination = $build_path . DIRECTORY_SEPARATOR . $file->basename;
      if (file_exists($destination)) {
        // To prevent the removal of top-level directories such as 'modules' or
        // 'themes', descend in a level if the file exists.
        // TODO: This only protects one level of directories from being removed.
        $overwrite = drush_get_option('overwrite', FALSE) ? FILE_EXISTS_OVERWRITE : FILE_EXISTS_MERGE;
        if (is_dir($destination)) {
          $files = drush_scan_directory($file->filename, '/./', array('.', '..'), 0, FALSE);
          foreach ($files as $file) {
            $ret = $ret && drush_copy_dir($file->filename, $destination . DIRECTORY_SEPARATOR . $file->basename, $overwrite);
          }
        }
        else {
          $ret = $ret && drush_copy_dir($file->filename, $destination, $overwrite);
        }
      }
      else {
        $ret = $ret && drush_copy_dir($file->filename, $destination);
      }
    }
  }
  else {
    drush_mkdir(dirname($build_path));
    $ret = drush_move_dir($tmp_path . DIRECTORY_SEPARATOR . '__build__', $tmp_path . DIRECTORY_SEPARATOR . basename($build_path), TRUE);
    $ret = $ret && drush_copy_dir($tmp_path . DIRECTORY_SEPARATOR . basename($build_path), $build_path);
  }

  // Copying to final destination resets write permissions. Re-apply.
  if (drush_get_option('prepare-install')) {
    $default = $build_path . '/sites/default';
    chmod($default . '/settings.php', 0666);
    chmod($default . '/files', 0777);
  }

  if (!$ret) {
    return drush_set_error('MAKE_CANNOT_MOVE_BUILD', dt("Cannot move build into place."));
  }
  return $ret;
}