Packaging module information in make files

Drush Make packages module information so you can build a Drupal installation with a set of downloaded modules. By turning the make file into an installation profile, you can go one step further by enabling modules and preconfiguring the Drupal site, which leads to ready to use Drupal distributions such as Open Atrium (http://openatrium.com), Open Public (http://drupal.org/project/openpublic), or Commons (http://drupal.org/project/commons).

Now we will create our own Drupal distribution. Let's suppose that we have been working on a site for promoting our favorite music festival. There is stuff in this site that we would like to use in future festival websites. We will first install Drush Make and then generate a make file out of our existing site.

Installing Drush Make

If you are using Drush 5 or installed Drush in Windows through the installer, you can skip this step because Drush 5 incorporates Drush Make.

Drush Make has commands that do not depend on a Drupal site, such as the make command, which, given a make file, downloads and creates a Drupal installation. For this reason, instead of downloading it as a normal module we are going to place it at our .drush directory so it will be available from anywhere in the command line. Drush does this for us automatically by executing the pm-download command from a non-Drupal directory.

$ cd $HOME
$ drush dl drush_make-6.x
Project drush_make (6.x-2.3) downloaded to /home/juampy/.drush/drush_make. [success]
Project drush_make contains 0 modules: .

Drush Make works for both Drupal 6 and 7 versions. That is why we specified version 6.x (there is no 7.x branch for this project). Now, let's test that the Drush Make commands are available:

$ drush help | grep make
Other commands: (drush_make,drush_make_d_o)
convert-makefile Convert the specified makefile to a drupal.org friendly format, and verify the converted file.
make Turns a makefile into a working drupal install.
make-generate Attempts to generate a makefile from the (generate-makefile) current Drupal install, specifying project version numbers unless not known or otherwise specified. Unversioned projects will be interpreted later by drush make as "most recent stable release"
make-test Run a drush make test.
verify-makefile Verify the specified makefile is in a drupal.org friendly format.

As we can see in the help information, the Drush Make commands are discovered by Drush. Now we will generate our make file.

Generating a make file out of an existing site

In the following example, we will use the two highlighted commands (make-generate and make) to create a make file with all the module information about our existing Drupal site.

Gathering information about our site and writing a make file

Generate a festival.make file by placing ourselves at the root of our site and executing the make-generate command:

$ cd /home/juampy/projects/festival
$ drush make-generate festival.make
Project information for ctools retrieved. [ok]
Project information for features retrieved. [ok]
Project information for twitter retrieved. [ok]
Project information for views retrieved. [ok]
Some of the properties in your makefile will have to be [error]
manually edited. Please do that now.
Wrote .make file festival.make [ok]

The previous command raised a warning because some of our modules do not have a version number because either they are development releases such as, the Devel module, or they simply do not exist at http://drupal.org such as, the feature that we created in the Features section of this chapter.

In order to fix this, we will simply edit the generated festival.make file and remove all the information related to modules which are not in a stable state or are custom. We will also set the subdirectory path of each module to be contrib so when we are building a Drupal installation with this make file, the modules listed in it will be downloaded at sites/all/modules/contrib. Here is how the file festival.make would look after our edits:

; This file was auto-generated by drush_make
core = 7.x
api = 2
projects[drupal][version] = "7.10"
; Modules
projects[ctools][subdir] = "contrib"

projects[ctools][version] = "1.0-rc1"
projects[features][subdir] = "contrib"

projects[features][version] = "1.0-beta6"
projects[twitter][subdir] = "contrib"

projects[twitter][version] = "3.0-beta4"
projects[views][subdir] = "contrib"

projects[views][version] = "3.1"
; Modules
; Please fill the following out. Type may be one of get, cvs, git, bzr or svn,
; and url is the url of the download.
projects[devel][download][type] = ""
projects[devel][download][url] = ""
projects[devel][type] = "module"
...

As you can see in the contents of festival.make, it defines a version of Drupal core that it will download, and a set of modules with their version numbers and destination paths. You can edit this file freely and add more modules to it.

Tip

The README.txt file of the Drush Make module provides extended information of how to download modules from Git repositories, apply patches, and download themes or libraries among other tasks.

Loading contents from the make file into a Drupal installation

Now, move festival.make out of the current Drupal installation and invoke the make command to create a new Drupal installation out of festival.make.

$ mv festival.make ../
$ cd ..
$ drush make festival.make other_festival
Project information for drupal retrieved [ok]
Project information for ctools retrieved. [ok]
Project information for features retrieved. [ok]
Project information for twitter retrieved. [ok]
Project information for views retrieved. [ok]
drupal downloaded from [ok]
http://ftp.drupal.org/files/projects/drupal-7.10.tar.gz.
ctools downloaded from [ok]
http://ftp.drupal.org/files/projects/ctools-7.x-1.0-rc1.tar.gz.
features downloaded from [ok]
http://ftp.drupal.org/files/projects/features-7.x-1.0-beta6.tar.gz.
twitter downloaded from [ok]
http://ftp.drupal.org/files/projects/twitter-7.x-3.0-beta4.tar.gz.
views downloaded from [ok]
http://ftp.drupal.org/files/projects/views-7.x-3.1.tar.gz.

This command has created a new directory called other_festival and downloaded Drupal 7.10 and the list of modules defined at festival.make. Here are the contents of the sites/all/modules/contrib directory:

$ cd other_festival
$ ls sites/all/modules/contrib/
ctools features twitter views

The modules defined at festival.make were downloaded to the directory we defined and have the version number given. Now, we can install a site within this Drupal installation and enable it.

Note

You can find further information about building installation profiles out of make files at http://drupal.org/node/1006620. Also, http://drushmake.me has a very friendly web interface to create make files on the fly.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.158.148