For the Aegir project, I'm considering creating Debian packages for both Provision and Drush so that we can easily create new platforms with automated scripts. To do this right, Provision would logically need to be installed in /usr/share/drush/provision (since it's a non-binary shared library):

       /usr/share
              This directory contains subdirectories with specific application
              data, that can be shared among different  architectures  of  the
              same  OS.   Often  one  finds  stuff  here  that used to live in
              /usr/doc or /usr/lib or /usr/man.

The system-wide configuration file should be in /etc/drush/drushrc.php:

       /etc   Contains  configuration  files  which  are local to the machine.
              Some larger software packages, like X11, can have their own sub‐
              directories  below  /etc.   Site-wide configuration files may be
              placed here  or  in  /usr/etc.   Nevertheless,  programs  should
              always  look  for these files in /etc and you may have links for
              these files to /usr/etc.

Indeed, there's already a TODO for that in the code:

  // TODO: This really should be a proper, system-wide location.
  $configs['drush'] = dirname(__FILE__) . '/../drushrc.php';

So I attach a patch to fix both those issues. It doesn't enforce anything: you can still use ~/.drush for rc files or modules, but it adds support for those directories. It does, however, drop support for drushrc in the drush directory. This is trivial to add back, I think.

This would greatly facilitate packaging and code separation. It will also facilitate interoperability with other systems, as the Drush files will be in a consistent, predictable directory (/etc or /usr/share).

This is a must for Provision, especially for /etc/drush because we will soon need to have "server verification" in which some system-wide settings need to be written to a configuration file. That would be /etc/drush/drushrc.php.

For third party packages, it is also essential that a system-wide location is available to load commands from. ~/.drush will not work because the commands will be available to only one user (the same could apply to drushrc.php).

I am therefore marking this as critical so it makes it into 2.0, which provision 0.2 and later will depend upon.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

Looks fine to me. Feel free to commit when you think it is ready.

anarcat’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
3.24 KB

Thanks, but I don't have commit access. :)

Adrian requested that I add PREFIX support somehow, so here's a stab at that.

anarcat’s picture

FileSize
2.3 KB

rah, i screwed up that patch again. here's a reroll without my local, unrelated test changes

moshe weitzman’s picture

rush_get_context('PREFIX', '') . '/etc/drush/drushrc.php' ... what would be an example value for prefix? seems a bit odd to me, especially since we already support arbitrary locations with -c flag.

moshe weitzman’s picture

lets see what folks think of the 2 patches. feedback wanted.

moshe weitzman’s picture

whoops. ignore that last follow-up

adrian’s picture

Moshe, the prefix context exists, so that an installer package (such as macports or apt-get) can create a drushrc.php in the drush directly during installation, to properly point to /opt/local/etc/drush or /usr/local/etc/drush (same for finding modules).

It allows for a clean point in the code that they can specify these distribution specific settings without having to patch drush itself.

anarcat’s picture

Status: Needs review » Reviewed & tested by the community

PREFIX is for packaging. It will be "" (not set) on Debian and most Linuxes, it will be "/usr/local" on BSDs and maybe "/opt" on OSX.

The idea is to provide a hook for packagers to modify that core behaviour without reverting to patching or using -c all the time.

I think this can be committed now, Adrian just wanted that PREFIX and now it's there...

adrian’s picture

Status: Reviewed & tested by the community » Fixed

I committed this , with some differences.

Firstly, the system level config is not meant to replace the drush level config.

I added the system level config in addition to the drush level config, so that packages can create the $drushpath/drushrc.php file,
and set the configs that modify the location of the /etc/drush and /usr/share/drush/commands paths.

Secondly, there are two different prefixes, the ETC_PREFIX and the SHARE_PREFIX.

The default SHARE_PREFIX is '/usr', and the default ETC_PREFIX is ''.
If they were sharing the same context, if you set the prefix to '/usr', the config
file will be looked for at '/usr/etc/drush/drushrc.php'.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.