Using a distribution as site core via Drush Make

By now most of us have used a Drupal distribution.

Drupal.org takes a distribution’s drush make file, fetches Drupal core, contributed modules, themes, libraries, adds custom modules, and provides an archive that’s ready to use and install.

While distributions provide a great base for a site, we always need additional pieces (modules, libraries) in order to satisfy our use case.
So, how do we use a distribution as a starting point, and add our modules on top?

Use case

Let’s say we want to add the node_tab module, and the bxslider library to a Commerce Kickstart v1 distribution.

Solution #1: include[]

The first thing people try is using the include[] directive to include the distribution make files.

api = 2
core = 7.x

includes[core] = drupal-org-core.make
includes[distro] = drupal-org.make

projects[node_tab] = 1.0-beta1
libraries[jquery.bxslider][type] = "libraries"
libraries[jquery.bxslider][download][type] = "file"
libraries[jquery.bxslider][download][url] = "https://github.com/wandoledzep/bxslider-4/archive/master.zip"

This is bad for two reasons:

  1. It forces you to build the distribution manually, instead of using the drupal.org build. This takes time.
  2. The drupal.org build script, and the build scripts that ship with distributions such as Kickstart and Commons have additional logic to move the files and folders to appropriate places. You will need to replicate that logic. Without replicating the whole build logic, you will get an incomplete build, with modules in wrong places, and the profile missing.

Solution #2: Specify the distribution archive as core

Now we’re on to something.
If we hardcode the url to the distribution archive, we can use it as the core instead of drupal core:

api = 2
core = 7.x

projects[commerce_kickstart][type] = "core"
projects[commerce_kickstart][download][type] = "file"
projects[commerce_kickstart][download][url] = "http://ftp.drupal.org/files/projects/commerce_kickstart-7.x-1.19-core.tar.gz"

projects[node_tab] = 1.0-beta1
libraries[jquery.bxslider][type] = "libraries"
libraries[jquery.bxslider][download][type] = "file"
libraries[jquery.bxslider][download][url] = "https://github.com/wandoledzep/bxslider-4/archive/master.zip"

This will unpack the distribution, then place all additional modules and libraries into sites/all.
Mission accomplished!
However, the problem with this method is that you need to hardcode the distribution url and update it every time there’s a new distribution release.
Would be great if Drush could figure out the url for you, like it usually does.

Solution #3: Specify the distribution as core, use Drush 6.x

Thanks to Damien Tournoud, Drush 6.x now supports a better way.
This change is not a part of Drush 6.0-beta1, you will need to use the -dev version.

EDIT (June 12th): This change has now been backported to Drush 5 as well.

api = 2
core = 7.x

; The first line is there to indicate we want the v1 branch, since v2 is the default.
projects[commerce_kickstart] = 1.x
projects[commerce_kickstart][type] = core

projects[node_tab] = 1.0-beta1
libraries[jquery.bxslider][type] = "libraries"
libraries[jquery.bxslider][download][type] = "file"
libraries[jquery.bxslider][download][url] = "https://github.com/wandoledzep/bxslider-4/archive/master.zip"
About these ads

2 thoughts on “Using a distribution as site core via Drush Make

    • No, because Drupal.org needs to deploy the new Drush 6, which they probably won’t do until it gets a stable release.
      So it might make sense to backport the patch to Drush 5, then when it lands, push for Drush to be updated on Drupal.org.

Comments are closed.