Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Dist-Zilla CPAN distribution.

Report information
The Basics
Id: 68223
Status: resolved
Priority: 0/
Queue: Dist-Zilla

People
Owner: Nobody in particular
Requestors: rob [...] hoelz.ro
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 4.200006
Fixed in: (no value)



Subject: Test::DZil doesn't build dist tarballs correctly
When Test::DZil builds a tarball out of the distribution, its contents are wrong. To elaborate on that vague description, here's what my sample dist tarball looks like if I run dzil build: $ tar tzf Fake-0.01.tar.gz Fake-0.01/dist.ini Fake-0.01/Build.PL Fake-0.01/lib/Fake.pm Fake-0.01/t/00-simple.t And here's what it looks like when Test::DZil builds it: $ tar tzf Fake-0.01.tar.gz home/rob/programming/projects/Dist-Zilla-Plugin-LocalBrew/tmp/source/random_stuff/Fake-0.01/dist.ini # and so on... Attached is a test file that checks for this. -Rob
Subject: tester-tarball-contents.t
use strict; use warnings; use Archive::Tar; use Test::More 0.88; use Test::DZil; plan tests => 1; my $tzil = Builder->from_config( { dist_root => 'corpus/dist/DZT' }, { add_files => { 'source/dist.ini' => simple_ini({ name => 'DZT', }, 'GatherDir', 'MakeMaker', 'FakeRelease') }, }, ); $tzil->release; my $tarball = join('', $tzil->name, '-', $tzil->version, ($tzil->is_trial ? '-TRIAL' : ()), '.tar.gz'); $tarball = $tzil->built_in->parent->subdir('source')->file($tarball); $tarball = Archive::Tar->new($tarball); ok($tarball->contains_file('Makefile.PL'));
Subject: Re: [rt.cpan.org #68223] Test::DZil doesn't build dist tarballs correctly
Date: Sun, 15 May 2011 21:29:19 -0400
To: Rob Hoelz via RT <bug-Dist-Zilla [...] rt.cpan.org>
From: Ricardo Signes <rjbs [...] cpan.org>
* Rob Hoelz via RT <bug-Dist-Zilla@rt.cpan.org> [2011-05-15T21:25:50] Show quoted text
> And here's what it looks like when Test::DZil builds it: > > $ tar tzf Fake-0.01.tar.gz > home/rob/programming/projects/Dist-Zilla-Plugin-LocalBrew/tmp/source/random_stuff/Fake-0.01/dist.ini > # and so on...
Nice. Thanks. I do not look forward to fixing this, but I'll give it a look soon. :) -- rjbs
From: rob [...] hoelz.ro
Attached fix patch. It's kind of awful; don't judge me. On Sun May 15 21:29:30 2011, RJBS wrote: Show quoted text
> * Rob Hoelz via RT <bug-Dist-Zilla@rt.cpan.org> [2011-05-15T21:25:50]
> > And here's what it looks like when Test::DZil builds it: > > > > $ tar tzf Fake-0.01.tar.gz > > home/rob/programming/projects/Dist-Zilla-Plugin-
> LocalBrew/tmp/source/random_stuff/Fake-0.01/dist.ini
> > # and so on...
> > Nice. Thanks. I do not look forward to fixing this, but I'll give it > a look > soon. :) >
Subject: fix.patch
diff -Naur Dist-Zilla-4.200006/lib/Dist/Zilla/Dist/Builder.pm Dist-Zilla-4.200006-post/lib/Dist/Zilla/Dist/Builder.pm --- Dist-Zilla-4.200006/lib/Dist/Zilla/Dist/Builder.pm 2011-04-28 20:14:36.000000000 -0500 +++ Dist-Zilla-4.200006-post/lib/Dist/Zilla/Dist/Builder.pm 2011-05-15 20:15:47.000000000 -0500 @@ -332,11 +332,10 @@ $_->before_archive for $self->plugins_with(-BeforeArchive)->flatten; - my %seen_dir; for my $distfile (sort { length($a->name) <=> length($b->name) } $self->files->flatten) { - my $in = file($distfile->name)->dir; - $archive->add_files( $built_in->subdir($in) ) unless $seen_dir{ $in }++; - $archive->add_files( $built_in->file( $distfile->name ) ); + require File::Slurp; + my $contents = File::Slurp::read_file($built_in->file($distfile->name)); + $archive->add_data($distfile->name, $contents); } # Fix up the CHMOD on the archived files, to inhibit 'withoutworldwritables' diff -Naur Dist-Zilla-4.200006/t/tester-tarball-contents.t Dist-Zilla-4.200006-post/t/tester-tarball-contents.t --- Dist-Zilla-4.200006/t/tester-tarball-contents.t 1969-12-31 18:00:00.000000000 -0600 +++ Dist-Zilla-4.200006-post/t/tester-tarball-contents.t 2011-05-15 20:13:49.000000000 -0500 @@ -0,0 +1,28 @@ +use strict; +use warnings; + +use Archive::Tar; +use Test::More 0.88; +use Test::DZil; + +plan tests => 1; + +my $tzil = Builder->from_config( + { dist_root => 'corpus/dist/DZT' }, + { add_files => { + 'source/dist.ini' => simple_ini({ + name => 'DZT', + }, 'GatherDir', 'MakeMaker', 'FakeRelease') + }, + }, +); + +$tzil->release; + +my $tarball = join('', + $tzil->name, '-', $tzil->version, + ($tzil->is_trial ? '-TRIAL' : ()), + '.tar.gz'); +$tarball = $tzil->built_in->parent->subdir('source')->file($tarball); +$tarball = Archive::Tar->new($tarball); +ok($tarball->contains_file('Makefile.PL'));
From: rob [...] hoelz.ro
Ok, my first test and patch sucked, unless you're a fan of tarbombs. Here's a new patch (fix is included); it should be better. On Sun May 15 21:36:48 2011, hoelzro wrote: Show quoted text
> Attached fix patch. It's kind of awful; don't judge me. > > On Sun May 15 21:29:30 2011, RJBS wrote:
> > * Rob Hoelz via RT <bug-Dist-Zilla@rt.cpan.org> [2011-05-15T21:25:50]
> > > And here's what it looks like when Test::DZil builds it: > > > > > > $ tar tzf Fake-0.01.tar.gz > > > home/rob/programming/projects/Dist-Zilla-Plugin-
> > LocalBrew/tmp/source/random_stuff/Fake-0.01/dist.ini
> > > # and so on...
> > > > Nice. Thanks. I do not look forward to fixing this, but I'll give it > > a look > > soon. :) > >
> >
Subject: fix.patch
diff -Naur Dist-Zilla-4.200006/lib/Dist/Zilla/Dist/Builder.pm Dist-Zilla-4.200006-post/lib/Dist/Zilla/Dist/Builder.pm --- Dist-Zilla-4.200006/lib/Dist/Zilla/Dist/Builder.pm 2011-04-28 20:14:36.000000000 -0500 +++ Dist-Zilla-4.200006-post/lib/Dist/Zilla/Dist/Builder.pm 2011-05-15 21:03:04.000000000 -0500 @@ -323,7 +323,7 @@ my $archive = Archive::Tar->new; - my $basename = file(join(q{}, + my $basename = dir(join(q{}, $self->name, '-', $self->version, @@ -332,11 +332,10 @@ $_->before_archive for $self->plugins_with(-BeforeArchive)->flatten; - my %seen_dir; for my $distfile (sort { length($a->name) <=> length($b->name) } $self->files->flatten) { - my $in = file($distfile->name)->dir; - $archive->add_files( $built_in->subdir($in) ) unless $seen_dir{ $in }++; - $archive->add_files( $built_in->file( $distfile->name ) ); + require File::Slurp; + my $contents = File::Slurp::read_file($built_in->file($distfile->name)); + $archive->add_data($basename->file($distfile->name), $contents); } # Fix up the CHMOD on the archived files, to inhibit 'withoutworldwritables' diff -Naur Dist-Zilla-4.200006/t/tester-tarball-contents.t Dist-Zilla-4.200006-post/t/tester-tarball-contents.t --- Dist-Zilla-4.200006/t/tester-tarball-contents.t 1969-12-31 18:00:00.000000000 -0600 +++ Dist-Zilla-4.200006-post/t/tester-tarball-contents.t 2011-05-15 21:00:59.000000000 -0500 @@ -0,0 +1,30 @@ +use strict; +use warnings; + +use Archive::Tar; +use File::Spec; +use Test::More 0.88; +use Test::DZil; + +plan tests => 1; + +my $tzil = Builder->from_config( + { dist_root => 'corpus/dist/DZT' }, + { add_files => { + 'source/dist.ini' => simple_ini({ + name => 'DZT', + }, 'GatherDir', 'MakeMaker', 'FakeRelease') + }, + }, +); + +$tzil->release; + +my $basename = join('', + $tzil->name, '-', $tzil->version, + ($tzil->is_trial ? '-TRIAL' : ())); +my $tarball = $basename . '.tar.gz'; + +$tarball = $tzil->built_in->parent->subdir('source')->file($tarball); +$tarball = Archive::Tar->new($tarball); +ok($tarball->contains_file(File::Spec->catfile($basename, 'Makefile.PL')));
I've applied this patch, with some significant changes, and am making a release. I think it looks good. Thanks! -- rjbs