Hello,

The use case for my feature request is fairly easy. I need to download the library TinyMCE, and also a language pack. But that language pack (which is an archive containing many files) must be extracted inside TinyMCE's folder tree, without any containing folder (the archive contains many files that go in many directories inside TinyMCE tree).
The problem is that, at the moment, this is impossible to achieve using drush_make, as it stops with an error, if trying to extract a project in a non empty directory.

The attached patch provides the new option "overwrite" in Drush Make. I a project (or library) has this option set to 1, then it can be extracted in a non empty folder. For example, the drush make lines concerning TinyMCE and its French language pack would be the following :

; TinyMCE JS library
libraries[tinymce][download][type] = "file"
libraries[tinymce][download][url] = "http://github.com/downloads/tinymce/tinymce/tinymce_3.4.2.zip"
libraries[tinymce][directory_name] = "tinymce"

; TinyMCE French language pack (JS export)
libraries[tinymce_fr][download][type] = "file"
libraries[tinymce_fr][download][request_type] = "post"
libraries[tinymce_fr][download][url] = "http://tinymce.moxiecode.com/i18n/index.php?ctrl=export&act=zip"
libraries[tinymce_fr][download][data] = "la[]=fr&la_export=js&pr_id=7&submitted=Download"
; Force filename so Drush Make unzips it
libraries[tinymce_fr][download][filename] = "tinymce_fr.zip"
; The two following lines are telling drush make to put the archive files in libraries/tinymce/jscripts/tiny_mce
libraries[tinymce_fr][destination] = "libraries/tinymce/jscripts"
libraries[tinymce_fr][directory_name] = "tiny_mce"
; Allow drush make to install librairies[tinymce_fr] inside a non empty directory
libraries[tinymce_fr][overwrite] = 1

Provided patch includes documentation of the new option.
Any comment is welcome.

Regards,
David

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

David Stosik’s picture

Patch also works on 2.2 version. :)

izmeez’s picture

subscribing, also need this for swftools flowplayer3 libraries.

David Stosik’s picture

To help the issue going forward, please test the attached patch, and post your feedback here. :)

izmeez’s picture

David,

Yes, I was just bookmarking this so that I could return when time was available and this has not been until now.

The patch works, thank you. I like the introduction of the new option 'overwrite' which if not declared behaves as false preserving the default behavior and when declared true it permits adding to existing directories. This is useful for different modules and libraries such as fckeditor and flowplayer3.

Here are a few suggestions for the patch. I will include them in this post rather than as revised patch so you can decide.

php TRUE = -1 and substituting 1 for a conditional flag may cause problems down the road.

Suggest change in readme be:

- `overwrite`

  Allows the project to be installed in a directory that is not empty.
  If not specified this is treated as FALSE, drush_make sets an error when the directory is not empty.
  If specified TRUE, drush_make will continue and use the existing directory.
  Useful when adding extra files and folders to existing folders in libraries or module extensions.

        projects[myproject][overwrite] = TRUE

Suggest change in drush_make.project.inc be:

    // If directory exists and overwrite is not true, set error
    if (is_dir($this->download_location) && !$this->overwrite) {
 

Thanks for your efforts.

Izzy

David Stosik’s picture

FileSize
1.54 KB

Didn't use TRUE cause I was not sure about $this->overwrite to be parsed as a boolean. I checked, and it is parsed as a boolean, so I see no problem in including your suggestions. :)
I attached a new patch. Thanks Izzy for your support.

David

izmeez’s picture

Status: Needs review » Reviewed & tested by the community

David,

Thanks for the patch. I have marked it as RTBC.

Izzy

David Stosik’s picture

Up ?

j0nathan’s picture

Hi,
Thanks for the patch. I used it with drush_make 2.2 and drush 4.4. It works well with this:

projects[civicrm][directory_name] = civicrm
projects[civicrm][download][type] = get
projects[civicrm][download][url] = http://downloads.sourceforge.net/project/civicrm/civicrm-stable/3.4.1/civicrm-3.4.1-drupal.tar.gz

libraries[civicrm_l10n][destination] = modules
libraries[civicrm_l10n][directory_name] = civicrm
libraries[civicrm_l10n][download][type] = get
libraries[civicrm_l10n][download][url] = http://downloads.sourceforge.net/project/civicrm/civicrm-stable/3.4.1/civicrm-3.4.1-l10n.tar.gz
libraries[civicrm_l10n][overwrite] = TRUE
David Stosik’s picture

Thanks for the test. :)
Is there any chance this get commited sooner or later ?

Regards,

David

helmo’s picture

Nice, I also needed a TinyMCE translation.

The patch works great.

For reference there is an old issue that raised a similar problem but got a won't-fix: #628198: Allow library downloads into a directory that already exists

Andrew_Mallis’s picture

subscribe

anarcat’s picture

Status: Reviewed & tested by the community » Fixed

Committed as 913f245 in 3.x and as cb84d38 in 2.x.

Status: Fixed » Closed (fixed)

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

David Stosik’s picture

Title: Allow a DrushMakeProject to be installed in a non empty directory » Allow a DrushMakeProject to be installed in a non empty directory (Port to Drush 5)
Project: Drush Make » Drush
Version: 6.x-2.x-dev »
Component: Code » Make
Status: Closed (fixed) » Active

Would it be possible to port this to Drush 5?

Regards,
David

helmo’s picture

Status: Active » Fixed

You are going to need an extra drush module: http://drupal.org/project/make_post

I created it specifically to download tinymce translations.

Please open a new issue if you encounter more problems.

David Stosik’s picture

Status: Fixed » Active

My problem has nothing to do with POST data, but with the "overwrite" property, allowing to install many projects in the same directory (Drush 4 was throwing a warning and aborted without completing, I don't think it has changed in Drupal 5).
By the way, I don't need this only for POST downloads, but for any (Git, GET, etc.) DrushMakeProject I would like to unpack in a non empty directory.

David Stosik’s picture

Status: Active » Closed (fixed)

OK, I get it, the patch I initially wrote for Drush Make a year ago was actually included in Drush 5, so as you said, the problem shall really come from POST data. Why does it work on Drush Make, not in Drush 5, I don't know...
I guess that would be a good idea to include Drush Make Post to Drush, but that belongs to another issue...

izmeez’s picture

@David

OK, I get it, the patch I initially wrote for Drush Make a year ago was actually included in Drush 5, ... Why does it work on Drush Make, not in Drush 5, I don't know...

So , is this overwrite patch working in drush 5?

David Stosik’s picture

Yes. But POST type request, that worked in Drush Make for Drush 4 don't work anymore. That's a regression and you'll need make_post module.