Drush Make is an extension for the wonderful Drush project. from the Drush make project page on drupal.org:
Drush make is an extension to drush that can create a ready-to-use drupal site, pulling sources from various locations. It does this by parsing a flat text file (similar to a drupal .info file) and downloading the sources it describes. In practical terms, this means that it is possible to distribute a complicated Drupal distribution as a single text file.
Basically we can write a shopping list for all the ingredients we need for our site and Drush make will go do the shopping, unpack the groceries and put everything away- beautiful! The shopping list, also known as a make file, is a simple text document that explains to Drush make exactly what we want. We can include different sources for the code we need, like modules from drupal.org or code from sourceforge.net, and we can use different protocols to retrieve the code, things like http or svn or git. Whenever I am learning something new I always look for an example to learn from. When looking at how to create my make file I looked at the example make file included in Drush make and the most excellent make file that is a part of the Open Atrium project. The basic make file would look something like this:
; Make file for Art Websites. api = 2 core = 6.x projects = drupal ; Modules ; Because you will always be using these two contributed modules. projects = views projects = cck
If you give this file to Drush make it will go to drupal.org and download the latest version of Drupal and unpack it in the directory where you ran the command. Drush make will also download the latest releases of views and cck and unpack them to the sites/all/modules directory.
That is it! If this is all you ever used Drush make for you have a huge win already because that has saved you a significant chunk of time, but this is only the beginning.
My goal is to build a list of all the code that will make up my Drupal site that is reliable and tested. This means that I do not want to necessarily use the latest release of any given module. Drush make allows us to easily choose a specific version of a module. To choose a specific verion of a module we change the above code to:
; Make file for Art Websites. api = 2 core = 6.x projects[drupal][version] = "6.19" ; Modules ; Because you will always be using these two contributed modules. projects[views][version] = "2.11" projects[cck][version] = "2.8"
This will allow for more control over what version is downloaded by Drush make.
Another option we have is to have our code downloaded into specific directories to keep our file system extra tidy. I like the idea of having my sites/all/modules directory organized by types of modules, usually those types will be “contrib” and “custom”. Drush make allows us to easily keep things nice and clean by telling it where to put the goods, we simply change the code to:
; Make file for Art Websites. api = 2 core = 6.x projects[drupal][version] = "6.19" ; Modules ; Because you will always be using these two contributed modules. projects[views][subdir] = "contrib" projects[views][version] = "2.11" projects[cck][subdir] = "contrib" projects[cck][version] = "2.8"
Now Drush make will extract those projects to sites/all/modules/contrib.
I am also going to need some code that does not come from drupal.org for my project. I will need code for the WYSIWYG editor for the site as well as a copy of jQuery UI. I can add external sources of code to my make file by adding the code below:
; jQuery UI libraries[jquery_ui][download][type] = "get" libraries[jquery_ui][download][url] = "http://jquery-ui.googlecode.com/files/jquery-ui-1.7.zip" libraries[jquery_ui][directory_name] = "jquery.ui" libraries[jquery_ui][destination] = "modules/contrib/jquery_ui" ; CKEditor libraries[ckeditor][download][type]= "get" libraries[ckeditor][download][url] = "http://download.cksource.com/CKEditor/CKEditor/CKEditor%203.4/ckeditor_3.4.zip" libraries[ckeditor][directory_name] = "ckeditor" libraries[ckeditor][destination] = "libraries"
You can see the type option above is set to “get”, this is the option that can be changed to “svn” or “git” to change the protocol you are using to fetch your code. You can also see that I have specified a directory for the jQuery UI library to be extracted to- slick!
If you would like to download my example make file to try out and hack on right click on this link and choose “save as”.
Finally I want to show how to use this file we have so carefully crafted. Open up a terminal and navigate to the place you would like to build your site, maybe some place like /var/www. I like to copy the make file to the directory I am building the site in, so copy the file there. Once you are in the directory and the only thing in the directory is the make file run the Drush make command and it will execute the file we have written(I have named my file art.make).
drush make art.make -y
hit enter and watch it work.
The “-y” at the end of the command tells drush make that the answers to any questions it may ask is yes, you can leave it off if you like but you will have to answer the questions manually.
We now have a code base ready to install. If you used the example make file that I linked above you may have noticed that there is a profile that was downloaded to the profiles directory. This is the subject of the next post in this series. This profile will perform the 2nd step in the process of building our base site to hit the ground running.
Drush make has changed the way I set up a Drupal site. With very little difficulty or effort you can set up a file that gets you going quickly with a solid code base. Once you start to use Drush make you will realize that I have only touched on the power of the functionaility. Soon you might find yourself patching files with Drush make, recursively calling make files in other make files or even using Drush make to build platforms in Aegir.