3

Is there any way to declare target directory for a patch in a Drush make file?

I need to apply a patch to a subfolder of a module. The reason is that CiviCRM's project is composed from multiple repositories (the patch is from the civicrm-drupal repository, which corresponds to civicrm/drupal in the packaged module).

There was a proposal along these lines in #745224, but ultimately only support for -p0 and -p1-type patches was committed.

(I'm now using a work-around by declaring a library in that location and applying a patch to it, but a cleaner way would be nice).

2 Answers 2

2

After clarifying that the goal of the original question was to be able to use patches generated by pull requests on GitHub directly, I'm suggesting an alternative answer. My original answer is correct if the goal is to package this on Drupal.org. Because a drupal-org.make requires patches to be found on Drupal.org, the path can be updated in the patch to to target directories within the CiviCRM project. drupal-org.make also requires all external projects to be whitelisted. Only the sk (starterkit) build of CiviCRM is whitelisted (https://www.drupal.org/node/1588192) because of the size and licensing limits.

When using drush make locally, you can use both patches and code from any source.

IIRC it was a bit more complicated than just combining the repos?

It really isn't more complicated than just combining the repos. There is some additional logic in https://github.com/civicrm/civicrm-core/blob/master/tools/scripts/releaser/releaser and https://github.com/civicrm/civicrm-core/blob/master/distmaker/distmaker.sh, but you can really focus on what happens in...

https://github.com/civicrm/civicrm-core/blob/master/distmaker/dists/drupal_php5.sh

dm_install_core "$SRC" "$TRG" 
dm_install_packages "$SRC/packages" "$TRG/packages" 
dm_install_drupal "$SRC/drupal" "$TRG/drupal"

That combines https://github.com/civicrm/civicrm-core with https://github.com/civicrm/civicrm-drupal and https://github.com/civicrm/civicrm-packages.

Other than the versioning, that's really all that happens when a new release of CiviCRM is packaged. There isn't any code for a D7 release that doesn't come from those 3 repos. By adding each of these projects directly, the relative path of the code will match what the patch expects allowing the patch to be applied in the .make.

So to get something like https://github.com/civicrm/civicrm-drupal/pull/144.patch to work before it is merged into a release, your .make would look something like...

libraries[civicrm][download][type] = get
libraries[civicrm][download][url] = "https://github.com/civicrm/civicrm-core/archive/4.4.10.zip"
libraries[civicrm][destination] = "modules/"
libraries[civicrm][directory_name] = civicrm 

libraries[civicrm-drupal][download][type] = get
libraries[civicrm-drupal][download][url] = "https://github.com/civicrm/civicrm-drupal/archive/7.x-4.5.4.zip"
libraries[civicrm-drupal][destination] = "modules/civicrm/"
libraries[civicrm-drupal][directory_name] = drupal
libraries[civicrm-drupal][patch][144] = https://github.com/civicrm/civicrm-drupal/pull/144.patch

libraries[civicrm-drupal][download][type] = get
libraries[civicrm-drupal][download][url] = "https://github.com/civicrm/civicrm-packages/archive/4.5.3.zip"
libraries[civicrm-drupal][destination] = "modules/civicrm/"
libraries[civicrm-drupal][directory_name] = packages
1
  • This is certainly helpful to my particular use case, but I'm not sure I should accept it given the question - I suppose the answer is that Drush doesn't have any option to specify a patch subdirectory/path to use.
    – arjan
    Dec 17, 2014 at 13:44
0

You can find dozens of patches to all levels of CiviCRM (the Drupal modules, CiviCRM core, and additional libraries this project includes) in the .make for https://www.drupal.org/project/civicrm_starterkit

http://cgit.drupalcode.org/civicrm_starterkit/tree/drupal-org.make

4
  • As far as I see, those patches are all applied from the directory level of the declared project. I would want something like libraries[civicrm][patch][] = https://github.com/civicrm/civicrm-drupal/pull/144.patch, but the patch should not be applied to the civicrm folder, but a subfolder. I'm now working around it by declaring an extra project civicrm-drupal at the modules/civicrm/drupal location, even though that folder is already contained in the civicrm package.
    – arjan
    Dec 15, 2014 at 13:54
  • That is true. All of the patches are applied starting at the project level and from files on Drupal.org (a requirement to use drupal-org.make to build a package on Drupal.org).
    – kreynen
    Dec 15, 2014 at 14:52
  • I was unclear what you meant by "declare target directory for a patch". You meant in the .make vs. in the patch. AFAIK, you can only target directories within the root of a project in the patch, but I don't see why this would be a problem if you are adding the modules and root CiviCRM projects to your distribution directly from GitHub. If you want to use the patches from GitHub directly, just rebuild the CiviCRM structure from the different GitHub repos. Then you can apply patches like pull/144.patch to each repo.
    – kreynen
    Dec 15, 2014 at 15:05
  • IIRC it was a bit more complicated than just combining the repos? I think I'll stick to my hack for now :)
    – arjan
    Dec 15, 2014 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.