Currently the "drush make" command automatically unpacks downloaded files when it detects that the file is a supported archive format. While this is a very handy feature, it is not always the desired behavior. In our case we want to download a Java JAR-file
to make it available in the build. As JAR files are essentially ZIP Archives with a predefined directory structure, drush unpacks
the archive which makes it unusable. I guess this would also affect PHAR archives as well.

So instead of extending the filetype determination I would suggest to add an optional parameter to prevent the automatic unpacking. This will not break the current behavior.

Comments

nmandery’s picture

The attached patch implements optional "unpack" flag.

jhedstrom’s picture

Status: Active » Needs review

I'll try to review soon. Can you provide a publicly available example we could build a test from?

nmandery’s picture

You may use the branch 7.x-dont-unpack-jar of the cartaro project as an example.

The relevant commit is this one:
http://drupalcode.org/project/cartaro.git/commit/80227b34812503fe01ad1ea...

jhedstrom’s picture

friedjoff’s picture

Status: Needs review » Reviewed & tested by the community

I've been using the above patch and everything looks good to me.

Looking forward to get this committed and deployed on drupal.org, so my distribution makefile can take use of it.

jonhattan’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/commands/make/make.download.inc
@@ -70,9 +70,13 @@ function make_download_file($name, $download, $download_location, $cache_duratio
+    // always unpack unless the unpack key is explicitly set to false
+    $unpack = isset($download['unpack']) ? strtolower($download['unpack']) == 'false' : True;

$unpack is TRUE if $download['unpack'] is 'false'? It seems wrong to me.

nmandery’s picture

Status: Needs work » Needs review
StatusFileSize
new2.28 KB

You are right - I messed up the comparison. The flag should be compared to "true" instead of "false".
I attached the new version of the patch to this reply.

friedjoff’s picture

Version: » 7.x-5.x-dev
Status: Needs review » Reviewed & tested by the community

Looks good now.

jhedstrom’s picture

Version: 7.x-5.x-dev » 8.x-6.x-dev
jhedstrom’s picture

Status: Reviewed & tested by the community » Needs work

I'm seeing a failure with this patch:

1) makeMakefileCase::testMakeBZ2SingleFile
bzip2 single file - build md5 matches expected value: 4f9d57f6caaf6ece0526d867327621cc
Failed asserting that '' contains "4f9d57f6caaf6ece0526d867327621cc".
joestewart’s picture

I did not have the test failure noted in #10, but the patch didn't seem to work for me when using the unpack option to disable unpacking.

+++ b/commands/make/make.download.incundefined
@@ -70,9 +70,13 @@ function make_download_file($name, $download, $download_location, $cache_duratio
+    // always unpack unless the unpack key is explicitly set to false
+    $unpack = isset($download['unpack']) ? strtolower($download['unpack']) == 'true' : True;
+

This ternary still doesn't seem right.

Would it be better to use yes/no instead of true/false?

Then just pass it on to make_download_file_unpack() and check the unpack value there?

Isn't a drush_get_option('unpack') needed here?

Also doesn't there need to be an array entry in make_drush_command to allow the unpack commandline option?

greg.1.anderson’s picture

Status: Needs work » Closed (won't fix)
Issue tags: +Needs migration

This issue was marked closed (won't fix) because Drush has moved to Github.

If this feature is still desired, you may copy it to our Github project. For best results, create a Pull Request that has been updated for the master branch. Post a link here to the PR, and please also change the status of this issue to closed (duplicate).

Please ask support questions on Drupal Answers.