tar and zip are smart enough to recursively unpack an archive, so that you can unpack it directly over a directory with contents, and it will use existing subdirs that match the archive, etc. however, the unpacking code in drush_make doesn't properly leverage these tools.
to be honest, i can't figure out what the heck it's doing... ;)
can't we just simply cd to the appropriate install path, and untar/unzip?
also, i don't see why we need the extra logic for gzip, tar has the -z option to support that natively.
this is holding up #639158: Download translations extracts just a single file
Comments
Comment #1
hunmonk commentedComment #2
hunmonk commentedwhoops
Comment #3
hunmonk commentedi've spent some more time looking at the workflow for downloading and unpacking files, and i don't think it's optimal.
the basic procedure is:
this is both overly complicated, and leads to the problem initially reported in this issue.
i'd like to propose the following workflow change:
this will both simplify the workflow and solve the unpacking issue. i see no purpose in putting anything but archives in the temp directory (other than the __build__ directory, of course). this is a build we're doing, so it seems like an extra caution that's not really needed.
please let me know if this make sense. if it does, i'll start working up a patch.
Comment #4
dmitrig01 commentedYes it does. You have my green light
Comment #5
hunmonk commentedgreat, i'll work this up tomorrow.
Comment #6
hunmonk commentedfirst crack at this, with support for the Get and CVS download classes. untar'ing for both core and contrib are tested as working, unzipping and CVS are untested, and the other VCS's still need to be converted.
please have a look and let me know if this direction is making sense. if so, please feel free to help out converting the other VCS-specific classes :)
Comment #7
hunmonk commentedattached patch:
the basic scenario of core and contrib module tarballs are still the only case that's actually been tested -- we need some folks to test the other download classes to make sure they are functioning properly.
Comment #8
dmitrig01 commentedOk, this doesn't work - I don't have --strip-components. But otherwise, I updated it to head.
Comment #9
hunmonk commentedi believe the OS X version of tar has --strip-path, which will do the equivalent. should be trivial to test for which option exists and use it.
Comment #10
dmitrig01 commentedYES! After a weekend of work, I present a robust unpacking script. Run drush unpack-test to test all 12 tests or drush unpack-test [number] to test just one.
Basically, my goal was to create an unpacking script that took (1) a filename, (2) a destination directory, (3) a tmp directory and then unpacked the filename into the destination dir. If you read the code, in _run_test, a destination directory is created and a file to put in to make sure it's not outright overridden, and then it hands it off to the unpacking class.
Comment #11
dmitrig01 commentedAlso, I had to resort to extreme ugliness to get unzip working in some cases.
Here's a --debug of the worst-case scenario. Take note of
unzip -l->unzip -d->mv->tar -c->tar -t->tar -xComment #12
dmitrig01 commentedComment #13
dmitrig01 commentedComment #14
dmitrig01 commentedlatest round of brokenness
Comment #15
dmitrig01 commentedPatch is growing...
Comment #16
dmitrig01 commentedw/ test. still growing...
Comment #17
dmitrig01 commentedComment #18
dmitrig01 commentedYESSS IT WORKS!
Comment #19
msonnabaum commentedThis should fix bzr.
Tested with core, with and without --working-copy.
Comment #20
dmitrig01 commentedgreat thanks, will commit in a moment. What repo are you pulling from and what .make file code? I'd like to turn this into a test.
Comment #21
dmitrig01 commentedComment #22
msonnabaum commentedHere's the make file I was testing with:
Comment #23
dmitrig01 commentedawesome, thanks
Comment #24
decipheredHi guys,
I hate to re-open a nicely fixed issue, but it looks like I'm having issues that are related to this patch.
Running drush make on my make file I'm getting the following error:
"Unable to find a strip option in your version of tar"
Full output of my drush make command can be found at http://pastebin.com/BRv4bZsL
Hope you can help.
Cheers,
Decipheed.
Comment #25
dmitrig01 commentedok, putting on my list - need to use cp -fn
Comment #26
jmiccolis commentedJust adding my push here; the current code doesn't work for me at all. My `tar` binary has the "--strip-components" option which this won't auto detect at all. I need to manually set a `--strip-option=components` to drush make working again. I'm all for the switch to `cp`, I think grep'ing man pages is just asking for trouble.
Comment #27
thebuckst0p commentedSame for me, I'm on a mac and
man tar | grep strip-componentreturns nothing even though the flag is valid, probably because it's bold (so it's wrapped in formatting tags which mess up the string lookup).Running
man -t tar | grep strip-component"works" by exposing all the formatting tags, but I agree with jmiccolis that man|grep is not a reliable method.For OSX users, the attached patch seems to fix the problem, but it might screw up other platforms.
Comment #28
seanpclark commented@thebuckst0p, this patch worked for me on osx.
I'm a terminal newb, but the 'col' command would also work:
man tar | col -b | grep strip-component
I don't know what effect either approaches has on different systems.
Comment #29
hunmonk commentedi see we already have an option to set the strip-option, which people can set in drushrc.php. i vote we:
this should handle most situations automatically, while still providing a setting for somebody to use if they have a weird setup that we can't deduce via OS detection.
Comment #30
dmitrig01 commentedhunmonk: I disagree - I think that if the tar --strip format worked for everything, it would be a good solution, however given the fact that I have to use cp -rn in many cases anyway (git, bzr, .zip files, etc), I don't think we'd lose anything by using that for tar as well.
Comment #31
dmitrig01 commentedhunmonk: I disagree - I think that if the tar --strip format worked for everything, it would be a good solution, however given the fact that I have to use cp -rn in many cases anyway (git, bzr, .zip files, etc), I don't think we'd lose anything by using that for tar as well.
Comment #32
dmitrig01 commentedAdditionally, detecting the operating system is a no-go. For example, on Mac OS X, you may have the system-installed version, or the version from fink, both of which have different --strip options.
Comment #33
jmiccolis commentedThis is indeed my case - I've got the bsdtar `/usr/bin/tar`, GNU tar in `/sw/bin/tar`, and still another version of GNU tar in `/opt/local/bin/tar`. So on my system it's quite necessary to look at which tar binary is in use.
If we could detect which version tar we had and from that determine which option to use that could work - but they we may be in a position of only supporting certain versions of tar. A quick survey of the various versions may tell whether this is workable.
Comment #34
BrockBoland commentedThe patch in #27 worked for me too. I'm running a fresh install of 6.x-2.0-beta8.
Comment #35
dmitrig01 commentedfixed again...
Comment #37
pearcec commentedI don't want to reopen this, but I did run into this issue on linux. I am running a minimal install of 10.04 (use to be JEOS). It doesn't include man, as a result I ran into this issue. So I installed man and everything worked fine relating to this issue.
Comment #38
dmitrig01 commentedThe dev version doesn't ever call man.
Comment #39
Thomas_Zahreddin commentedsorry, there something realy realy going wrong.
Drupal (and its modules) should work on any OS with php.
The conclusion of this requirement (http://drupal.org/requirements) is, that there should be no dependencies to OS specific tools.
So - what solution offers php for such cases?
have a look at http://pear.php.net
and you'll find packages like
http://pear.php.net/package/Archive_Tar
or http://pear.php.net/package/File_Archive
so imho these packages could solve a lot of problems.
(and it is legitimate to suppose that it is easier to install a pear package, than eg. a tool to extract tar - files via commands on e.g. windows).
best
Thomas
(working with ubuntu)
Comment #40
mradcliffeSlackware 12.0, tar 1.16:
I hacked drush_make to change strip-path to strip-components and changed strip_option to components. The --help docs said to put an = sign for key=value instead of a space.
This worked for me.
Edit: I'm not changing the status even though I feel like it should change to needs work. This really isn't a viable solution.
Comment #41
boobaaI'm getting this:
My makefile is as simple as it can be:
Anyway, it seems it's not an "error", since all the files seem to be extracted properly. Attached is a patch which works this around, though I know it's not the proper solution.
Comment #42
osopolarOn Mac OS you may use as workaround:
[edit] Sorry, I overlooked that this was already mentioned in #26.
Comment #43
boobaa@ositoblanco: Is it possible to add this to an rc file or something if I don't want to type this much on every drush make call?
Comment #44
dmitrig01 commentedThis was fixed in the latest beta. the strip-component option is no longer used. the patch is against an outdated version of drush make
Comment #45
aidanlis commentedFor those reading this, the problem has been fixed in CVS (not in beta-8 as available on the project page).
To download the latest version (dev releases are not enabled for this project) you need to run the following:
cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -d drush_make -r DRUPAL-6--2 contributions/modules/drush_make/
It took me a while to find as this bug was marked as closed, so I'm going to re-open this in the hope that the maintainer releases a new beta or enables dev releases for the project. Thanks Dmitri :)
Comment #46
dmitrig01 commentedSorry, yeah. We're currently sprinting on this beta and should be done in a few days.
Comment #47
dmitrig01 commentedComment #48
John_Buehrer commentedPerhaps related, perhaps not:
Drupal Aegir alpha13 install script has errors on my MacOS 10.5 powerpc:
Aegir install script downloads a file 'drush_make.download.inc' contains:
Both my native tar and Gnutar from MacPorts have the --strip-components option, but neither man page refers to it. Yes that's annoying, but shouldn't the Aegir script only check "tar --help" in the first place, and not rely on the man page??
Should I report this to the Aegir team, or do I misunderstand something? (It's nice when things "just work" out of the box.)
Comment #49
John_Buehrer commented...and sorry if this is the same generic error reported above. I'm unsure if the fix mentioned earlier also fixes this Aegir instance, or whether another set of patching is required in this case.
Comment #50
John_Buehrer commented...the CVS patch mentioned above fixes the Aegir problem. Drush make was mistakenly not in my drush path when I ran the install script.
Comment #51
dmitrig01 commentedthis is also fixed in the latest -dev
Comment #52
John_Buehrer commentedPerhaps the launch script could check an environment variable for the php path, before trying to find it automatically? I have both MAMP and XAMPP installed, but each environment should use only its own php for Drush. Setting a bash alias doesn't always work, as some scripts (like Aegir install) do a `which drush` which doesn't catch aliases.
Comment #53
ajuliano commentedGreat that you soon will be releasing a new beta as mentioned in #46.
FYI the patch in #27 worked great for me as well, I am on Mac OS X 10.6.
Thanks dmitrig01!
Comment #55
vunger commentedSorry, this is isn't working for me. The drupal core downloads OK but when it tries to download contributed modules it gives the error "Unable to find a strip option in your version of tar."
I'm so confused. I'm using beta9. Am I supposed to download the dev release with CVS? I tried the command given in #45 and it's not working; I get:
cvs checkout: authorization failed: server cvs.drupal.org rejected access to /cvs/drupal-contrib for user anonymous
cvs checkout: used empty password; try "cvs login" with a real password
Despair!!
In working in Unix, by the way.
Comment #56
vunger commentedI was able to check out the dev release using Cygwin on Windows. Then uploaded it to my Unix server. I got the same error messages, but it downloaded the contributed modules anyway. So I guess it's working, but only in dev, not in beta9, even though the note with beta9 says, "This release will blow your socks off: it WORKS!" So, still confused: is beta9 supposed to include the fix for this particular issue or not?
Comment #57
dmitrig01 commentedI am 100% sure you did not find the error "Unable to find a strip option in your version of tar" on beta 9, because it doesn't exist there. Please open a new issue.
Comment #58
vunger commented:P