drush_make_tar() is busted.

here's the line in question: drush_shell_exec("tar -C%s -s/__build__/%s/ -Pc __build__ | gzip > %s", $tmp_path, basename($base_path, '.tar.gz'), $base_path);

the big problem is that it looks like the -s switch is being used like a regex, but in reality the -s switch for tar does this: "list of names to extract is sorted to match archive".

also, the output is being piped through gzip manually, which isn't necessary -- the -z switch can take care of that.

attached patch fixes the problem in local testing. i didn't see any other switch for tar that would let you substitute the name of the directory prior to tar'ing, so i just do an ol' fashioned mv -- the entire temp dir is wiped clean anyways before the end of the cycle, so this works fine and doesn't leave any mess.

Comments

dmitrig01’s picture

Looks good, except I'd like to do it the other way around - tar and them move - that way, if we encounter any errors with tarring, it doesn't get moved.

hunmonk’s picture

StatusFileSize
new1.14 KB

the problem is that we need to move it before the tar operation, otherwise the root dir of the tar'd file is __build__, which is not what we want.

attached patch moves the previously moved dir back to it's original location immediately after the tar operation -- this leaves things in a consistent state regardless of the outcome of tar.

dmitrig01’s picture

that was not so much the problem, it's more about cleaning up. can we rename __build__, tar it, and then move the tar file?

hunmonk’s picture

StatusFileSize
new1.35 KB

you mean like this?

dmitrig01’s picture

Status: Needs review » Fixed

yep - comitted - thanks!

moshe weitzman’s picture

FYI, tar -C does not work on Windows or Solaris. See #636738: tar command doesn't work on windows or solaris

dmitrig01’s picture

Status: Fixed » Needs work

drush_shell_exec("(cd %s; tar -Pczf %s/%s %s)", $tmp_path, $tmp_path, $filename, $dirname) maybe?

moshe weitzman’s picture

I try to use php when possible since otherwise you run into problems with windows and hosts with odd restrictions in php (safe_mode, etc.). So, chdir() instead of cd. Also, changing directory is dangerous in drush. Make sure that you change back, even if you have an error condition.

dmitrig01’s picture

Status: Needs work » Fixed

fix comitted

Status: Fixed » Closed (fixed)

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