I have not been able to determine if this is supported, but I think not at this point.

I want to download the fckeditor or simplepie library (not using the libraries api). FCKEditor for example needs to be extracted into sites/all/modules/fckeditor/fckeditor which is already a directory that exists (it is precreated in module directory). So with the following library config

; FCKEditor Library
libraries[fckeditorlib][download][type] = get
libraries[fckeditorlib][download][url] = http://downloads.sourceforge.net/project/fckeditor/FCKeditor/2.6.5/FCKeditor_2.6.5.tar.gz
libraries[fckeditorlib][destination] = modules/fckeditor
libraries[fckeditorlib][directory_name] = fckeditor
libraries[fckeditorlib][install_path] = sites/all


fckeditorlib downloaded from [ok]
http://downloads.sourceforge.net/project/fckeditor/FCKeditor/2.6.5/FCKeditor_2.6.5.tar.gz.
Directory not empty: fckeditor/ [error]

I'm cool making a patch, but I'm just not sure if there is already a way to handle this. If not, how might you want it implemented?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dmitrig01’s picture

remove the is_dir :-)

febbraro’s picture

Status: Active » Needs review
FileSize
1.51 KB

This patch allows you to additionally specify which specific files to move from the library into your destination with the copy_file key (very similar to how patch works)

Below are 3 specific examples from the project I'm building to highlight the use cases.

Case 1: Move all files into a directory that already exists.
Case 2: Move one file into a directory that already exists
Case 3: Copy the download to directory within a module

; FCKEditor Library
libraries[fckeditorlib][download][type] = get
libraries[fckeditorlib][download][url] = http://downloads.sourceforge.net/project/fckeditor/FCKeditor/2.6.5/FCKeditor_2.6.5.tar.gz
libraries[fckeditorlib][destination] = modules/fckeditor
libraries[fckeditorlib][directory_name] = fckeditor
libraries[fckeditorlib][install_path] = sites/all
libraries[fckeditorlib][copy_file][] = *

; SimplePie RSS parser
libraries[simplepie][download][type] = get
libraries[simplepie][download][url] = http://simplepie.org/downloads/simplepie_1.2.zip
libraries[simplepie][destination] = modules/feedapi
libraries[simplepie][directory_name] = parser_simplepie
libraries[simplepie][install_path] = sites/all
libraries[simplepie][copy_file][] = simplepie.inc

; ARC2 Library required by RDF 
libraries[arc][download][type] = get
libraries[arc][download][url] = http://code.semsol.org/source/arc.tar.gz
libraries[arc][destination] = modules/rdf/vendor
libraries[arc][directory_name] = arc
libraries[arc][install_path] = sites/all
febbraro’s picture

Version: 6.x-2.0-beta1 » 6.x-2.0-beta2
Category: bug » feature

Fixing version, etc.

dmitrig01’s picture

Makes sense,
1) can we use something besides glob()?
2) why do you need to define install_path?
3) can we merge destination and directory_name?
4) it should be copy_files or probably just copy
5) this won't delete the original one will it? it should (i.e. download into folder X, move everything that matches $copy from folder X to folder Y, and delete folder X)

febbraro’s picture

Thanks for the feedback.

1) Why not use glob? It allows for simplistic use of * for wildcarding of files. Is there something specific that glob does that we are trying to avoid? We could get a list of all files (recursively) and then use fnmatch() but that seems like a lot of work.

2) I have to define install_path b/c this is a .make file included in my distro (OpenPublish) and my main make file just specifies Drupal and openpublish, then after openpublish is downloaded this snippet is executed and if we do not specify install_path everything winds up in the profiles/openpublish directory (I guess that is the context) Is there a way around that? I would rather not have to specify it for each of my 50+ modules too.

3) I was just following what I thought was the correct mechanism based on the current code and examples. I am pretty sure it works either way, but we can test. Do you want to get rid of that generally for move too?

4) Yeah, I agree. I think 'copy' is best.

5) Do you think this is this because we are moving files out of within directory X instead of actually moving directory X? If so, yes I think you are right.

Once I hear back on the above I'll rework the patch.

febbraro’s picture

Ok here is an update to that patch. Changes included are:

#3) We no longer use directory_name. We don't need to. Great observation (makes the code MUCH cleaner too). destination now specifies the full path to location if we are copying files.

#4) copy is now the new key in the .make file

#5) It now also properly cleans up the downloaded library on a copy when it is done.

Thanks for the review.

This is now what I'm using to stretch it's legs

core = 6.x

projects[] = fckeditor
projects[] = feedapi
projects[] = rdf

; FCKEditor Library
libraries[fckeditorlib][download][type] = get
libraries[fckeditorlib][download][url] = http://downloads.sourceforge.net/project/fckeditor/FCKeditor/2.6.5/FCKeditor_2.6.5.tar.gz
libraries[fckeditorlib][destination] = modules/fckeditor/fckeditor
libraries[fckeditorlib][copy][] = *

; SimplePie RSS parser
libraries[simplepie][download][type] = get
libraries[simplepie][download][url] = http://simplepie.org/downloads/simplepie_1.2.zip
libraries[simplepie][destination] = modules/feedapi/parser_simplepie
libraries[simplepie][copy][] = simplepie.inc

; ARC2 Library required by RDF 
libraries[arc][download][type] = get
libraries[arc][download][url] = http://code.semsol.org/source/arc.tar.gz
libraries[arc][destination] = modules/rdf/vendor
libraries[arc][directory_name] = arc
dmitrig01’s picture

modules might want to do this for whatever reason. can we change the main makePath function?

dmitrig01’s picture

Also, this is pretty insecure. What if a rogue makefile included the copy string ../../../../../../../../../../../../../.. - it would try to copy / into that directory, and i'm not going to tell you what happens becuase I don't want to try.

febbraro’s picture

Will update the patch so that all can enjoy. Yes I do agree though, there is some inherent insecurities. The same exist surrounding install_path as well, no? We should probably create another issue to address those.

dmitrig01’s picture

Ok. Try drush_make_validate_path.

dmitrig01’s picture

Status: Needs review » Needs work
univate’s picture

A module that I am having a similar issue with is the mp3player module.

The installation instructions ask you to copy two files from the downloaded zip package to a specific location in the module directory. It would obvious be great if modules could support having their libraries exist in a configurable path like the sites/all/libraries directory, but for the moment this 'copy' operation would come in real handy.

As for the security issue raised in #8 I don't really see this as a major issue or even a real security issue, as make files are intended to run internally and are not publicly accessible. As with any scripts / application or source you download you need to trust the source you are getting it from.

febbraro’s picture

Ok, this patch moves the copy functionality up to DrushMakeProject so more folks can take advantage of it.

It does not do anything about the security concerns mentioned above. I think those need to be dealt with more generally in a different issue since it seems like it is a problem not just with copying files for libraries but with modules, themes, etc. as well.

dmitrig01’s picture

It has been dealt with. Use drush_make_validate_path.

febbraro’s picture

Where is that function? I don't see it anywhere in the drush_make codebase.

febbraro’s picture

Status: Needs work » Needs review
dmitrig01’s picture

should be in .utilities.inc

thebuckst0p’s picture

I'd like to expand this from libraries to projects: [subdir] = custom should download a module to sites/all/modules/custom even if sites and sites/all already exists. (Currently it creates sites/sites if sites already exists, which doesn't make sense to me.) Is the current behavior a bug or intentional, and if the latter, I'm curious what is the reasoning?

I'm trying to use Drush Make to combine a standard "common platform" (used on many sites) with custom code (for each site), and it's hard to do that when the root has to be essentially blank for Drush Make to work.

Please let me know if i'm missing something here, thanks!

wik’s picture

subscribing

febbraro’s picture

Sorry for the lack of progress here.

@dmitrig01 there is no function called drush_make_validate_path in drush_make.utilities.inc (or in any file in this project). Are you possibly referring to a function by a different name or in a different project?

dmitrig01’s picture

dmitrig01’s picture

Status: Needs review » Closed (won't fix)

We're not going to support broken modules. If you can't get them working with drush_make, file an issue to integrate with http://drupal.org/project/libraries

KarenS’s picture

I'm looking for a way to delete some directories (or only copy specific ones). I found #656946: Provide Delete option which was marked as a duplicate of this issue, and then this issue was marked "won't fix". Does that mean you have no intention of providing a way to selectively copy or delete files?

febbraro’s picture

I agree with the "won't fix" and pushing modules towards using the libraries module. (I don't agree that modules NOT using the libraries module are broken though)

I do think that drush make should have some support for executing your own scripts, then you could do anything you want (like delete files, selective copying, etc.)