Hi!

I just had some trouble installing a feature from a feature server as a .tgz file. While running drush make in debug mode I found the following line:

mv: cannot stat `/tmp/drush_make_tmp_1275616878/tar: Record size = 13 blocks': No such file or directory

The last directory in this path is definitely not what we would assume, so I checked the origin of the variable $directory which I've found in the file drush_make.download.inc in function unpack_tar() starting on line 94.

    drush_shell_exec('tar -tf %s', $filename);
    $info = drush_shell_exec_output();
    if ($info) {
      list($first_line) = drush_shell_exec_output();
      list($directory) = explode('/', $first_line);
      drush_make_cd($this->project->tmp_path, 'tar -xf %s', $filename);
      drush_op('unlink', $filename);

      return $directory;
    }

What is happening here is that the contents of the file get listed and from the first line of the listing the directory gets extracted. When I try tar -tf on my locale machine with tar (GNU tar) version 1.15.1 I get the follwing result for my file:

~ | tar -tf my_feature-6.x-1.0-alpha1.tgz 
my_feature/my_feature.defaults.inc
my_feature/my_feature.features.inc
my_feature/my_feature.info
my_feature/my_feature.module

But if I do the same on my dev machine with tar (GNU tar) version 1.22 it returns the following:

~ | tar -tf my_feature-6.x-1.0-alpha1.tgz 
tar: Record size = 13 blocks
my_feature/my_feature.defaults.inc
my_feature/my_feature.features.inc
my_feature/my_feature.info
my_feature/my_feature.module

What I found in the GNU tar changelog for version 1.21:

Fixed record size autodetection. If detected record size differs from the expected value (either default, or set on the command line), tar prints a warning if verbosity level is set to 1 or greater, i.e. if either -t or -v option is given.

So, I really don't know exactly what record size is expected and why not the expected value was set during creation (by features.module) but one solution that works so far is to take the last line of the listing instead of the first. I changed the snippet posted above from

    drush_shell_exec('tar -tf %s', $filename);
    $info = drush_shell_exec_output();
    if ($info) {
      list($first_line) = drush_shell_exec_output();
      list($directory) = explode('/', $first_line);
    ...

to:

    drush_shell_exec('tar -tf %s', $filename);
    $info = drush_shell_exec_output();
    if ($info) {
      $first_line = $info[count($info) - 1];
      list($directory) = explode('/', $first_line);
    ...

If you think that's a viable solution and my problem doesn't derive from some improper handling with .tgz files and its' record sizes, I'd try to post a patch for this (after succeeding in checking out Drush Make from CVS, grrrrr....).

Thanks & cheers,
Johnny.

Comments

johnnynia’s picture

StatusFileSize
new546 bytes

Okay, and here's the patch. (My first! Weehooo! :-)

yhahn’s picture

Status: Active » Needs review
StatusFileSize
new1.31 KB

Thanks for the patch. I'm a little queasy about just using the last line -- it seems like as likely a place for our beloved GNU tar maintainers to stick some unexpected output as the first.

Here's a rerolled patch that looks for the first line that has a '/' character, as a sign we've hit a directory.

dmitrig01’s picture

Status: Needs review » Closed (duplicate)