5 Drush Make tips and tricks

Drush make is a fantastic tool that lets us basically have a build file for each site or multi-site base instance. I pair the make file with a custom installation profile and Aegir but on its own it is a powerful tool. Drush 5 supports a few upgrades for make so it is worth upgrading if appropriate from Drush 4.

5 Tips and Tricks

1. Use http://drushmake.me/ to generate a decent base make file for new projects.

This is also a handy way to see popular modules and libraries that have somehow been beneath your radar.

2. Patch your modules with Drush.

The syntax is fairly straightforward. You can also chain patches by applying one and then applying the next.

projects[project name][patch][] = "url to patch"

For example, to patch the CAS module for using SSL/TLSv1 you would do the following: projects[cas][patch][] = “http://drupal.org/files/enforce_tlsv1_0.patch”

3. Download your custom modules via git.

To do this you need to tell Drush make to use git and then you simply provide the public repository URL.

projects[wwuzen_gsa][download][type] = "git"
projects[wwuzen_gsa][download][url] = "https://bitbucket.org/wwuweb/wwu-google-search-appliance.git"
projects[wwuzen_gsa][type] = "module"

Unlike normal make projects you download you do not need to provide a version, but you do need to state that it is a git project and provide the URL. Whatever you put in the [] after the word projects is what the directory will be created as.

4. Move sub-directories within libraries to their proper location.

Often, external libraries do not extract from a tar or zip with the file your Drupal module is looking for. It might be buried inside of a sub-directory. With Drush 5 we can move them upon the build.This is an example from the CAS library.

libraries[CAS][download][subtree] = CAS-1.3.2/

With the subtree identified, Drush make will dowload and extract the library like normal, and then move the contents of the sub-directory CAS-1.3.2 into the main directory CAS. It might take a few attempts to figure out whether you need a / in front of the directory or not but the end result is a library extracted properly.

5. Move libraries upon install anywhere you would like.

The feeds module loves to have the Simple Pie XML parser library inside of it’s own module directory. What a pain. However, Drush make can move it for us.

libraries[simplepie][destination] = "sites/all/modules/feeds/libraries"

Just plop in the destination you would like to have the library moved to and the script makes it so. (Pun intended).

2 thoughts on “5 Drush Make tips and tricks

  1. Good stuff Max.

    I had fiddled with Make file patch syntax for a week trying to nail it down recently.
    In the end it was just a simple as you stated it above. The key for me was obvious really. Remember to call the project patch after the project.

    Now I have a ‘Core Patches’ section in my make files:
    ; Core Patches
    ; ————
    ; patch core fields module for token support: http://drupal.org/node/1070878
    projects[drupal][patch][1070878] = “http://drupal.org/files/token-support-default-field-settings-1070878-20.patch”

    Then I keep the project patches inline, below the addition of the project itself:
    projects[entityreference][version] = 1.0
    projects[entityreference][type] = “module”
    projects[entityreference][patch][1459540] = “http://drupal.org/files/entityreference-1459540-47-workaround-fatal-error.patch”

    I also started using that last bracket set for the D.O. issue number; which helps if it’s not in the patch file name.

    See ya at DrupalCon Portland!

  2. Hey Max;
    Google searched: “drush make extract and keep a sub folder”
    You were the first result!
    #4 [subtree] FTW

    Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *