diff --git a/README.txt b/README.txt index 685706c..8dccca0 100644 --- a/README.txt +++ b/README.txt @@ -159,11 +159,21 @@ Do not use both types of declarations for a single project in your makefile. - `patch` One or more patches to apply to this project. An array of URLs from which - each patch should be retrieved. + each patch should be retrieved. By default, this assumes patch should be + executed with the -p1 option (see http://drupal.org/patch/create and + http://groups.drupal.org/node/140204). You may specify different options + using the options array on the patch. These options can either be a single + string, or an array of options. projects[calendar][patch][rfc-fixes][url] = "http://drupal.org/files/issues/cal-760316-rfc-fixes-2.diff" projects[calendar][patch][rfc-fixes][md5] = "e4876228f449cb0c37ffa0f2142" + ; -p1 will be used by default, but this diff was created using -p0 + projects[calendar][patch][rfc-fixes][options] = "-p0" + ; Alternately, you can specify an array of patch command options. + projects[calendar][patch][rfc-fixes][options][] = "-p0" + projects[calendar][patch][rfc-fixes][options][] = "-f" + ; shorthand syntax if no md5 checksum is specified projects[adminrole][patch][] = "http://drupal.org/files/issues/adminrole_exceptions.patch" diff --git a/drush_make.project.inc b/drush_make.project.inc index d0f2a48..390fa71 100644 --- a/drush_make.project.inc +++ b/drush_make.project.inc @@ -70,16 +70,39 @@ class DrushMakeProject { if (!is_array($info)) { $info = array('url' => $info); } + // Set up patch command options, if they exist. + if (isset($info['options'])) { + $options = is_array($info['options']) ? implode(' ', $info['options']) : $info['options']; + } + // Download the patch. if ($filename = _drush_make_download_file($info)) { - $patched = drush_shell_exec("patch -p0 -d %s < %s", $project_directory, $filename); + // Default to -p1. See http://drupal.org/patch/create and + // http://groups.drupal.org/node/140204 + $options = isset($options) ? $options : '-p1'; + $patched = drush_shell_exec("patch %s -d %s < %s", $options, $project_directory, $filename); + + // Log any command output, visible only in --verbose or --debug mode. + if ($output = drush_shell_exec_output()) { + drush_log(implode("\n", $output)); + } + + // Set up string placeholders to pass to dt(). + $dt_args = array( + '@name' => $this->name, + '@filename' => basename($filename), + ); + if ($patched) { if (!$ignore_checksums && !_drush_make_verify_checksums($info, $filename)) { return FALSE; } $patches_txt .= '- ' . $info['url'] . "\n"; + drush_log(dt('@name patched with @filename.', $dt_args), 'ok'); + } + else { + drush_log(dt("Unable to patch @name with @filename.", $dt_args), 'error'); } - drush_log($this->name . ' patched with ' . basename($filename) . '.', $patched ? 'ok' : 'error'); drush_op('unlink', $filename); } else {