Drupal, drush & svn

    In our project, we use svn for version control. However, as it turned out, making friends with him drupal is a non-trivial task.
    Until we discovered drush, we had to spend a lot of body movements to update the kernel and the modules used.
    Drush - drupal shell - A tool for administering drupal from the command line.
    Project Page: http://drupal.org/project/drush .
    Among its features are loading / updating the kernel and modules, as well as integration with version control systems, in particular - svn.

    Below I will give a small example of how drush is used to update drupal components and transfer these updates to our svn repository.

    So, let's begin.

    Download empty project from repository


    Download from our svn repository our still empty project in the folder / home / user / workspace / drupal:

    [user@drush ~]$cd /home/user/workspace/
    [user@drush workspace]$ svn checkout xxx/bully/drush drupal --username=xxx --password=xxx


    Preparing the folder structure


    When loading, drush places the core of drupal in a folder with the name drupal-x.xx, where x.xx is the version of drupal, so for convenience we will create a folder www in the future - it will store the code for our project, and when updating we will use symlink is not her. Add the created folder to the repository - this is necessary for correct work in the future.

    [user@drush workspace]$ cd drupal
    [user@drush drupal]$ md www
    [user@drush drupal]$ ls -l
    total 4
    drwxr-xr-x 2 user user 4096 2010-04-17 17:30 www/




    [user@drush drupal]$ svn add www

    Kernel loading


    For example, let's start working with the kernel version 6.14, so let's create a drupal-6.14 symlink for the www folder inside the drupal folder: Add the created symlink to the svn repository: Load the kernel: The dl command is designed to load the kernel or modules. The --svnsync parameter is designed to automatically update information about changes in the svn repository. We check how and what loaded: We see that everything that is needed and how it is downloaded is loaded. Check the information for the svn repository: We see that everything is in order here.

    [user@drush drupal]$ ln -s www drupal-6.14
    [user@drush drupal]$ ls -l
    total 4
    lrwxrwxrwx 1 user user 3 2010-04-17 17:33 drupal-6.14 -> www/
    drwxr-xr-x 2 user user 4096 2010-04-17 17:30 www/




    [user@drush drupal]$ svn add drupal-6.14



    [user@drush drupal]$ drush dl drupal-6.14 --svnsync
    Project drupal (6.14) downloaded to /home/user/workspace/drupal/drupal-6.14/. [success]
    You should consider committing the new code to your Subversion repository.
    If this version becomes undesireable, use Subversion to roll back.







    [user@drush drupal]$ ls -l
    total 4
    lrwxrwxrwx 1 user user 3 2010-04-17 20:33 drupal-6.14 -> www/
    drwxr-xr-x 10 user user 4096 2009-09-16 23:40 www/

    [user@drush drupal]$ cd www
    [user@drush www]$ ls -l
    total 224
    -rw-r--r-- 1 user user 43058 2009-09-16 23:34 CHANGELOG.txt
    -rw-r--r-- 1 user user 988 2009-09-14 16:50 COPYRIGHT.txt
    -rw-r--r-- 1 user user 262 2006-08-09 11:42 cron.php
    drwxr-xr-x 3 user user 4096 2010-04-17 20:35 includes/
    -rw-r--r-- 1 user user 980 2007-12-26 11:46 index.php
    -rw-r--r-- 1 user user 1308 2007-11-19 22:53 INSTALL.mysql.txt
    -rw-r--r-- 1 user user 1075 2007-11-26 19:36 INSTALL.pgsql.txt
    -rw-r--r-- 1 user user 46926 2009-04-27 14:50 install.php
    -rw-r--r-- 1 user user 15646 2008-07-09 23:15 INSTALL.txt
    -rw-r--r-- 1 user user 18048 2009-01-06 20:27 LICENSE.txt
    -rw-r--r-- 1 user user 1924 2009-04-29 21:15 MAINTAINERS.txt
    drwxr-xr-x 4 user user 4096 2010-04-17 20:35 misc/
    drwxr-xr-x 36 user user 4096 2010-04-17 20:35 modules/
    drwxr-xr-x 4 user user 4096 2010-04-17 20:35 profiles/
    -rw-r--r-- 1 user user 1590 2008-12-10 23:12 robots.txt
    drwxr-xr-x 3 user user 4096 2010-04-17 20:35 scripts/
    drwxr-xr-x 5 user user 4096 2010-04-17 20:35 sites/
    drwxr-xr-x 8 user user 4096 2010-04-17 20:35 themes/
    -rw-r--r-- 1 user user 25457 2009-03-30 15:15 update.php
    -rw-r--r-- 1 user user 5002 2008-01-04 19:15 UPGRADE.txt
    -rw-r--r-- 1 user user 352 2005-12-10 22:26 xmlrpc.php
    [user@drush www]$




    [user@drush www]$ cd ..
    [user@drush drupal]$ svn status
    A www
    A www/profiles
    A www/profiles/default
    A www/profiles/default/default.profile
    A www/INSTALL.txt
    A www/themes
    ...
    A www/modules/user/user-profile-item.tpl.php
    A www/modules/user/user.admin.inc
    A www/update.php
    A www/INSTALL.pgsql.txt
    A www/.htaccess
    A drupal-6.14
    [user@drush drupal]$




    Loading modules


    To load modules, create the modules folder and add it to the repository - this is necessary for correct work in the future. Actually loading the modules we need: As you can see, the modules have loaded, the information for the svn repository has been updated. Beauty!

    [user@drush all]$ cd /home/user/workspace/drupal/www/sites/all
    [user@drush all]$ md modules
    [user@drush all]$ svn add modules




    [user@drush all]$ drush dl views cck context --svnsync
    Project views (6.x-2.10) downloaded to [success]
    /home/user/workspace/drupal/www/sites/all/modules/views.
    You should consider committing the new code to your Subversion repository.
    If this version becomes undesireable, use Subversion to roll back.
    Project cck (6.x-2.6) downloaded to /home/user/workspace/drupal/www/sites/all/modules/cck. [success]
    You should consider committing the new code to your Subversion repository.
    If this version becomes undesireable, use Subversion to roll back.
    Project context (6.x-2.0-beta7) downloaded to [success]
    /home/user/workspace/drupal/www/sites/all/modules/context.
    You should consider committing the new code to your Subversion repository.
    If this version becomes undesireable, use Subversion to roll back.




    Kernel update


    Since version 6.14, a lot of water has leaked, many bugs have been found, so it would be time to upgrade to 6.16.
    I omit the commits of the previous examples to the repository, we will immediately pass on to the most interesting.
    For the www folder, create a drupal-6.16 symlink inside the drupal folder: Download the latest (at the time of this writing) kernel version: That's it!

    [user@drush www]$ cd /home/user/workspace/drupal/
    [user@drush drupal]$ ln -s www drupal-6.16
    [user@drush drupal]$ svn add drupal-6.16




    [user@drush drupal]$ drush dl drupal-6.16 --svnsync
    Project drupal (6.16) downloaded to /home/user/workspace/drupal/drupal-6.16/. [success]
    You should consider committing the new code to your Subversion repository.
    If this version becomes undesireable, use Subversion to roll back.




    Instead of a conclusion


    Drush is an indispensable tool for administrators and developers, which makes it possible to quickly and conveniently manage sites throughout the project landscape.

    Also popular now: