Has anyone familiar with DistGen looked at what Craig is doing?
Can anyone offer any assistance?

More comments inline.

On Sun, Feb 05, 2006 at 06:10:58PM -0600, Craig A. Berry wrote:
> At 3:39 PM -0800 2/5/06, Yitzchak Scott-Thoennes wrote:
> 
> >Any progress on this front?  Given that this is just for purposes of
> >running tests, maybe here the hash keys should always be lowercased?
> >
> >The previous patch to add Module::Build no longer applies cleanly;
> >
> >http://zipcon.net/~sthoenna/mbaddfull270701.patch
> >
> >is updated to match bleadperl and what's currently in cvs for MB.
> 
> I'll try to look at that again soon -- too many projects in progress
> at once.   I did some hacking with Tie:CPHash from CPAN and got a bit
> farther.  A still not fully working diff of DistGen.pm is at the end
> of this message.  I'm now getting, for example:
> 
> $ perl -"I[-.lib]" [-.lib.module.build.t]tilde.t
> 1..11
> Warning: Removing existing directory 'D0:[CRAIG.perl.t._tmp.Simple]'
> Changed file 't/basic.t'.
> Changed file 'lib/Simple.pm'.
> Changed file 'Build.PL'.
> Splitting '[]'
> Setting directory name '[]' in %names
> Splitting '[.t]'
> Setting directory name '[.t]' in %names
> Setting directory name '[.t]' in %names
> Splitting '[.lib]'
> Setting directory name '[.lib]' in %names
> Setting directory name '[.lib]' in %names
> Splitting '[]'
> Setting directory name '[]' in %names
> Removing 'lib'
> Removing 't'
> Can't call method "install_base" on an undefined value at 
> [-.lib.module.build.t]tilde.t line 44.
> # No tests run!
> 
> I think the next hurdle is that File::Find is returning directory
> names with no attached distinguishing punctuation (C<lib> or C<t>)
> but the names that we've cached do have that punctuation (C<[.lib]>
> or C<[.t]>).  File::Spec->canonpath does not normalize that:
> 
> $ perl -"MFile::Spec" -e "print File::Spec->canonpath('[.lib]');"
> [.lib]
> $ perl -"MFile::Spec" -e "print File::Spec->canonpath('lib');"
> lib
> 
> So on VMS we'll have to get more aggressive about caching directory
> names in the same form that we'll be looking them up.  Otherwise we
> don't recognize directories that we want to keep and we end up
> deleting before they are even used.
> 
> --- DistGen.pm;2        Thu Jan 26 18:48:29 2006
> +++ DistGen.pm  Sun Jan 29 15:58:55 2006
> @@ -5,7 +5,7 @@
>  use vars qw( $VERSION $VERBOSE );
>  
>  $VERSION = '0.01';
> -$VERBOSE = 0;
> +$VERBOSE = 1;
>  
>  
>  use Cwd ();
> @@ -14,6 +14,7 @@
>  use File::Path ();
>  use File::Spec ();
>  use IO::File ();
> +use Tie::CPHash;
>  
>  sub new {
>    my $package = shift;
> @@ -29,6 +30,10 @@
>    );
>    my $self = bless( \%data, $package );
>  
> +  tie %{$self->{filedata}}, 'Tie::CPHash';
> +
> +  tie %{$self->{pending}{change}}, 'Tie::CPHash';
> +
>    if ( -d $self->dirname ) {
>      warn "Warning: Removing existing directory '@{[$self->dirname]}'\n";
>      $self->remove;
> @@ -280,6 +285,7 @@
>    }
>  
>    my %names;
> +  tie %names, 'Tie::CPHash';
>    foreach my $file ( keys %{$self->{filedata}} ) {
>      my $filename = $self->_real_filename( $file );
>      my ($vol, $dirname, $f) = File::Spec->splitpath( $filename );
> @@ -288,10 +294,16 @@
>  
>      $names{$filename} = 0;
>  
> +    print "Splitting '$dirname'\n" if $VERBOSE;
>      my @dirs = File::Spec->splitdir( $dirname );
>      while ( @dirs ) {
> -      my $dir = File::Spec->catdir( @dirs );
> -      $names{$dir} = 0;
> +      my $dir = ( scalar(@dirs) == 1
> +                  ? $dirname
> +                  : File::Spec->catdir( @dirs ) );
> +      if (length $dir) {
> +        print "Setting directory name '$dir' in \%names\n" if $VERBOSE;
> +        $names{$dir} = 0;
> +      }
>        pop( @dirs );
>      }
>    }
> @@ -299,11 +311,13 @@
>    File::Find::finddepth( sub {
>      my $name = File::Spec->canonpath( $File::Find::name );
>  
> +    $name =~ s/\.\z// if $^O eq 'VMS';
> +
>      if ( not exists $names{$name} ) {

Wild stab in the dark:

  if (! ( exists $names{$name} ||
          $^O eq 'VMS' && -d $name && exists $names{"[.$name]"} ) ) {

It doesn't have to be pretty, it just has to work.

>        print "Removing '$name'\n" if $VERBOSE;
>        File::Path::rmtree( $_ );
>      }
> -  }, File::Spec->curdir );
> +  }, './' );

Why not curdir?

> 
>    chdir( $here );
>  }

Reply via email to