ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/Perl-LibExtractor/LibExtractor.pm
(Generate patch)

Comparing cvsroot/Perl-LibExtractor/LibExtractor.pm (file contents):
Revision 1.6 by root, Sun Jan 15 14:14:15 2012 UTC vs.
Revision 1.7 by root, Mon Jan 16 18:46:05 2012 UTC

34package Perl::LibExtractor; 34package Perl::LibExtractor;
35 35
36our $VERSION = '0.1'; 36our $VERSION = '0.1';
37 37
38use Config; 38use Config;
39use File::Spec ();
39use File::Temp (); 40use File::Temp ();
40 41
41use common::sense; 42use common::sense;
42 43
43sub I_SRC () { 0 } 44sub I_SRC () { 0 }
44sub I_DEP () { 1 } 45sub I_DEP () { 1 }
45 46
46sub croak($) { 47sub croak($) {
47 require Carp; 48 require Carp;
48 Carp::croak "(Perl::LibExtractor) $_[0]"; 49 Carp::croak "(Perl::LibExtractor) $_[0]";
50}
51
52my $canonpath = File::Spec->can ("canonpath");
53
54sub canonpath($) {
55 local $_ = $canonpath->(File::Spec::, $_[0]);
56 s%\\%/%g;
57 $_
49} 58}
50 59
51=head2 CREATION 60=head2 CREATION
52 61
53=over 4 62=over 4
139} 148}
140 149
141sub _set_inc { 150sub _set_inc {
142 my ($self) = @_; 151 my ($self) = @_;
143 152
153 $self->{inc} = [ map canonpath $_, @{ $self->{inc }} ];
154
144 my $matchprefix = join "|", map "\Q$_", @{ $self->{inc }}; 155 my $matchprefix = join "|", map "\Q$_", @{ $self->{inc }};
156
157 $matchprefix =~ s%\\[/\\]%[/\\\\]%g; # we support / and \ on all OSes, keep your fingers crossed
158 $matchprefix = qr<$matchprefix>i if File::Spec->case_tolerant;
159
145 $matchprefix = qr<^(?:$matchprefix)/>; 160 $matchprefix = qr<^(?:$matchprefix)/>;
146 161
147 my %lib; 162 my %lib;
148 my @packlists; 163 my @packlists;
149 164
192 $root = qr<^\Q$root/>; 207 $root = qr<^\Q$root/>;
193 208
194 while (<$fh>) { 209 while (<$fh>) {
195 chomp; 210 chomp;
196 s/ .*$//; # newer-style .packlists might contain key=value pairs 211 s/ .*$//; # newer-style .packlists might contain key=value pairs
197 s%/\./%/%g; # yeah, these too
198 212
199 s/$root// or next; 213 s/$root// or next;
200 exists $lib{$_} or next; 214 exists $lib{$_} or next;
201 215
202 push @packlist, $_; 216 push @packlist, $_;
384 or croak "$dir/out: $!"; 398 or croak "$dir/out: $!";
385 local $/; 399 local $/;
386 scalar readline $fh 400 scalar readline $fh
387 }; 401 };
388 402
403 $_ = canonpath $_
404 for @inc;
405
389 my $matchprefix = $self->{matchprefix}; 406 my $matchprefix = $self->{matchprefix};
390 407
391 # remove the library directory prefix, hope for the best 408 # remove the library directory prefix, hope for the best
392 s/$matchprefix// 409 s/$matchprefix//
393 or croak "$_: file outside any library directory" 410 or croak "$_: file outside any library directory"
454 my $file = do { local $/; readline $fh }; 471 my $file = do { local $/; readline $fh };
455 472
456 $self->_trace_flush if exists $self->{trace_check}; 473 $self->_trace_flush if exists $self->{trace_check};
457 $self->{trace_check} = $file; 474 $self->{trace_check} = $file;
458 475
459 $self->{set}{"$self->{exedir}/$exe"} = ["$dir/$exe"]; 476 $self->{set}{"$self->{bindir}/$exe"} = ["$dir/$exe"];
460 next exe; 477 next exe;
461 } 478 }
462 } 479 }
463 480
464 croak "add_script ($exe): executable not found"; 481 croak "add_script ($exe): executable not found";
509=cut 526=cut
510 527
511sub add_perl { 528sub add_perl {
512 my ($self) = @_; 529 my ($self) = @_;
513 530
514 $self->{set}{"$self->{bindir}/perl$Config{_exe}"} = [_perl_path]; 531 $self->{set}{"$self->{exedir}/perl$Config{_exe}"} = [_perl_path];
515 532
516 # on debian, we have the special case of a perl binary linked against 533 # on debian, we have the special case of a perl binary linked against
517 # a static libperl.a (which is not available), but the Config says to use 534 # a static libperl.a (which is not available), but the Config says to use
518 # a shared library, which is in the wrong directory, too (which breaks 535 # a shared library, which is in the wrong directory, too (which breaks
519 # every other perl installation on the system - they are so stupid). 536 # every other perl installation on the system - they are so stupid).

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines