Speed Up Your Drupal Development Using Installations and Distributions

At the very top of linuxjournal.make, I need to add the following two lines to define the API version as well as the version of Drupal core that I'm using:

api = 2
core = 7.x

Here is the syntax for adding a project—in this case, the Administration Menu module—into a profile. Personally, I like to download projects from their Git repositories, although they could just be downloaded from drupal.org using wget. It's worth noting that the download URL doesn't have to be a URL at drupal.org. You can download projects from other sources, such as GitHub or BitBucket, or any other source, including from local file directories:

projects[admin_menu][type] = module
projects[admin_menu][subdir] = contrib
projects[admin_menu][version] = 3.0-rc3
projects[admin_menu][download][type] = git
projects[admin_menu][download][url] = 
projects[admin_menu][download][branch] = 7.x-3.x

All modules specified will be located in the profiles/linuxjournal/modules directory by default; however, I prefer to store contributed modules in a subdirectory called contrib, hence the subdir value. I've also specified which version of the module to use and which branch within the Git repository to use. If I didn't specify a version number, the latest commit to the specified branch would be used.

To make the Administration Menu module enabled by default after installing the profile, I can declare it as a dependency by adding the following line into linuxjournal.info in the same way that I did for the dblog and block modules earlier:

dependencies[] = admin_menu

If I update my version of Drupal with these changes and try following the installation process, I will get an error because I've made the profile dependent on the Administration Menu module, but this module hasn't been downloaded yet for this instance of Drupal. The next step is to create a distribution that contains the linuxjournal installation profile, as well as all of the projects that are defined in linuxjournal.make.

Figure 4. The Error on Installation

Creating a Distribution

To create a distribution, the first thing I need to do is make a new file called distro.make that will be used to compile an instance of Drupal that contains the linuxjournal profile. As with linuxjournal.make, I need to start with declaring the API version and the version of Drupal core. I also need to declare Drupal core as a project as well as include the linuxjournal profile:

api = 2
core = 7.x

projects[drupal][type] = core
projects[drupal][version] = "7"

; Add the Linux Journal profile to the full distribution build.
projects[linuxjournal][type] = profile
projects[linuxjournal][download][type] = git
projects[linuxjournal][download][url] = 

Again, I'm using Git to download the installation profile and providing the distribution with the URL to the repository at GitHub. With distro.make saved, I now can compile Drupal using the following Drush command:

drush make distro.make directory

The last parameter is the name of the directory that you want Drupal to be compiled into. If one isn't specified, the directory that you're currently in will be used, which I wouldn't recommend. I want the resulting directory to be placed in the same level as my linuxjournal_profile directory, so I need to move up one level before specifying the name of the directory, which is going to be linuxjournal_demo:

drush make distro.make ../linuxjournal_demo

This command will download the latest version of Drupal 7 core, as well as all projects defined within linuxjournal.profile, into the linuxjournal_demo directory. Once that's compiled everything, within the profiles/linuxjournal directory, there is a new directory called modules/contrib that contains the admin_menu module. With all of the dependencies downloaded, I now can go to install.php again and go through the installation process without any errors.

Adding Themes into an Installation Profile

I can add a theme into my profile by declaring it within linuxjournal.make in the same way that I can for modules. As I use Omega as a base theme for most of my themes, I'll include that within my profile so that it's downloaded automatically:

; Themes =========================================================
projects[omega][type] = theme
projects[omega][version] = 3.1
projects[omega][download][type] = git
projects[omega][download][url] = 
projects[omega][download][branch] = 7.x-3.x

For now, I'll be creating the sub-theme manually, so I won't change the default theme here.

Customizing the Site Configuration Form

When going through the installation process, I usually make several changes to the site configuration form—namely setting a default site name and adding the default country. I can automate these changes by adding an implementation of hook_form_FORM_ID_alter() into linuxjournal.profile, as any functions defined in this file will take effect during the installation process. I know that the ID of the form is install_configure_form, and the name of the function that I'm going to create will be linuxjournal_form_install_configure_form_alter():

 * Implements hook_form_alter().
 * Allows the profile to alter the site configuration form.
function linuxjournal_form_install_configure_form_alter(&$form, 
 ↪$form_state) {
  // Set a default site name.
  $form['site_information']['site_name']['#default_value'] = 
 ↪t('Linux Journal Demo');

As the form object is passed into the function by reference, I can add or overwrite information within the object by using this function. Here I'm setting a default value for the site's name field that will be pre-populated on the site configuration form the next time I follow the installation process. I can add and override any other values on the form by adding them into this function:

 * Implements hook_form_alter().
 * Allows the profile to alter the site configuration form.
function linuxjournal_form_install_configure_form_alter(&$form, 
 ↪$form_state) {
  // Set a default site name and email address.
 ↪= t('Linux Journal Demo');
 ↪= 'linuxjournal@oliverdavies.co.uk';

  // Set a default username and email address.
 ↪= 'Oliver Davies';
 ↪= 'linuxjournal@oliverdavies.co.uk';

  // Set a default country and timezone.
 ↪= 'GB';
 ↪= 'Europe/London';

  // Disable the 'receive email notifications' check box.
↪['#default_value'][1] = 0;

Now, as well as adding a default site name, I've also added a default site e-mail address, a default user name and e-mail address for the first user account, added a default time zone and country, and disabled the option to receive e-mail alerts when new updates are available. For security reasons, I don't want to define my password in this file and will continue to enter this onto the form directly. I'm using #default_value and not #value so I can edit these predefined values on the form if I need to for this site. If I used #value, I would not be able to do so.

Figure 5. Site Configuration Form


Oliver Davies is an Application Developer at Nomensa, specializing in Drupal and PHP development. Outside work, Oliver is a keen contributor to the Drupal community—attending local user groups and maintaining several of his own contributed modules.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.


Anonymous's picture

Thanks for this article. It's just what I was searching for. I am always interested in this subject. Will bookmark it.

thanks for the information,

dherach's picture

thanks for the information, this article really helped me in performing their duties. this my blog resep ayam

Reply to comment | Linux Journal

cell port thailand's picture

cellport clinic bangkok

Feel free to visit my weblog ... cell port thailand

Reply to comment | Linux Journal

d'leedon's picture

Potong Pasir MRT at the doorstep, residents can easily access almost to any destination

thanks for the information,

dherach's picture

thanks for the information, this article really helped me in performing their duties. this my blog resep ayam

The difference between install profiles and distros

marcvangend's picture

Thanks for the article. A quick note about the title: I think you meant to say "Installation Profiles" instead of "Installations".

Your article is mainly about creating installation profiles and not so much about distributions. That's okay, because installation profiles are great and they can indeed speed up your development process.

IMHO it's too easy to say that "distributions are install profiles on drupal.org" and be done with it. The big difference is that if you use a distribution, you're no longer the maintainer of that code. That has some advantages like the availability of support and updates. The disadvantage is, that if you want to change the way a distribution works, you cannot simply go in and change the code. If you did that, it would get much harder to get support and install updates. In my experience, a distribution can dramatically speed up your development process if it is exactly (or very close to) what you need. If you are planning to make a lot of changes, building on a distribution may even slow down your development process. This is especially true for distributions with lots of features and styling, such as Open Atrium.

Features / Exportables

btopro's picture

Nice article, Features, Profiler and Profiler Builder modules would all help in making a more complete export and install package (and faster) :)