Patch a module loaded by a distribution I am trying to make an installation profile that inherits the commerce kickstart distribution. In order to get this to work, I need to apply a bunch of patches through drush make.

First I have to apply a drupal core patch: http://drupal.org/node/1356276#comment-6654100

However the libraries module also needs to be made aware of the parent installation profile. So it needs to be patched as well.

My make file looks like this:

api = 2
core = 7.x

projects[drupal][type] = core
projects[drupal][patch][] = http://drupal.org/files/1356276-base-profile-d7-38-do-not-test.patch

projects[commerce_kickstart][type] = profile
projects[libraries][patch] =  patches/libraries-from-inherited-profiles.patch


The problem is that with this makefile drush will download the libraries module again to sites/all/modules and patch it there instead of just patching it in its original download location at profiles/commerce_kickstart/modules/contrib/libraries, thus I end up with the libraries module existing twice within one drupal installation.

The patch file for the libraries module looks like this:

diff --git a/libraries.module b/libraries.module
old mode 100644
new mode 100755
index 687fa29..bcf8824
--- a/libraries.module
+++ b/libraries.module
@@ -66,7 +66,6 @@
  */
 function libraries_get_libraries() {
   $searchdir = array();
-  $profile = drupal_get_path('profile', drupal_get_profile());
   $config = conf_path();

   // Similar to 'modules' and 'themes' directories in the root directory,
@@ -77,7 +76,8 @@
   // Similar to 'modules' and 'themes' directories inside an installation
   // profile, installation profiles may want to place libraries into a
   // 'libraries' directory.
-  $searchdir[] = "$profile/libraries";
+  foreach (drupal_get_profiles(drupal_get_profile()) as $profile)
+   $searchdir[] =  drupal_get_path('profile', $profile) . '/libraries';

   // Always search sites/all/libraries.
   $searchdir[] = 'sites/all/libraries';


How do I tell drush to simply patch libraries within the commerce kickstart directory and not download it again into sites/all?
For now I have solved this by patching the make file of the commerce kickstart profile:

projects[commerce_kickstart][type] = profile

projects[commerce_kickstart][patch][] = patches/commerce_kickstart.patch


The content of patches/commerce_kickstart.patch is this:

diff --git a/drupal-org.make b/drupal-org.make
index bde036e..787f6ea 100755
--- a/drupal-org.make
+++ b/drupal-org.make
@@ -31,6 +31,7 @@
 projects[taxonomy_menu][subdir] = "contrib"
 projects[libraries][version] = 2.1
 projects[libraries][subdir] = "contrib"
+projects[libraries][patch][] = patches/libraries-from-inherited-profiles.patch
 projects[views_megarow][version] = 1.0
 projects[views_megarow][subdir] = "contrib"


The patch happes to be applied on the commerce kickstart before its own makefile is executed. When it finally get executed it will also applied my libraries module patch within its directory structure.