📜 ⬆️ ⬇️

Drupal, drush & svn

In our project we use svn for version control. However, as it turned out, “making friends” with him drupal is not a trivial task.
Until we discovered drush, we had to spend a lot of gestures to perform the update of the kernel and the modules used.
Drush - drupal shell - A command line administration tool for drupal.
Project page: http://drupal.org/project/drush .
Among its features are the download / update of the kernel and modules, as well as integration with version control systems, in particular, svn.

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

So, let's begin.

Loading an empty project from the repository


Let's load our still empty project from the svn repository into the / home / user / workspace / drupal folder:
')
[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 drupal kernel in a folder named drupal-x.xx, where x.xx is the drupal version, so for convenience we will create the www folder - our project code will be stored there, and during the update we will use symlinks are not hers.

[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/


Let's add the created folder to the repository - this is necessary for correct work in the future.

[user@drush drupal]$ svn add www

Kernel loading


For example, let's start working with the kernel version 6.14, so let's create for the www folder the symlink drupal-6.14 inside the drupal folder:

[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/


Add the created symlink to the svn repository:

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

Load the kernel:

[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.


The dl command is designed to load the kernel or modules.
The --svnsync parameter is used to automatically update information about changes in the svn repository.

We check how and what was loaded:

[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]$


We see that everything is loaded that is necessary and as it should. Check the information for the svn repository:

[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]$


We see that everything is in order here.

Loading modules


To load modules, create a modules folder and add it to the repository - this is necessary for proper operation in the future.

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


Actually loading the modules we need:

[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.


As you can see, the modules are loaded, the information for the svn repository has been updated. Beauty!

Kernel update


Since version 6.14 a lot of water has passed under the bridge, many bugs have been found, so it’s time to upgrade to 6.16.
I omit the commits of the previous examples in the repository, we will immediately move on to the most interesting.
Create the www symlink drupal-6.16 for the www folder inside the drupal folder:

[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


Download the latest (at the time of this writing) kernel version:

[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.


That's all!

Instead of conclusion


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

Source: https://habr.com/ru/post/91287/


All Articles