Changeset 3223


Ignore:
Timestamp:
Dec 30, 2013, 10:46:26 AM (5 years ago)
Author:
bruno
Message:
  • the read_all_link subfunction is now in MondoRescue::File ready to be used by other perl script and removed from mindi itself in a near future
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mindi/mindi-get-perl-modules

    r3143 r3223  
    1111use File::Find;
    1212use Cwd;
     13use MondoRescue::File;
    1314
    1415
     
    5758
    5859
    59 my $file = get_perl_modules(@ARGV) if (defined $ARGV[0]);
     60my $file = mr_get_perl_modules(@ARGV) if (defined $ARGV[0]);
    6061
    6162foreach my $f (sort keys %$file) {
     
    6364}
    6465
    65 sub get_perl_modules {
     66sub mr_get_perl_modules {
    6667
    6768my %files;
     
    7071#print join "\n", @INC;
    7172
    72 my $require = process_file(@_);
     73my $require = mr_process_file(@_);
    7374
    7475my @includes;
     
    7879#
    7980foreach my $d (@INC) {
    80     $d = read_all_link($d) if (-l $d);
     81    $d = mr_read_all_link($d) if (-l $d);
    8182    push @includes,$d if (-d $d);
    8283}
     
    104105}
    105106
    106 # Cf: http://www.stonehenge.com/merlyn/UnixReview/col27.html
    107 sub read_all_link {
    108 
    109 my $dir = cwd;
    110 my $link;
    111 
    112 find sub {
    113     return unless -l;
    114     my @right = split /\//, $File::Find::name;
    115     my @left = do {
    116         @right && ($right[0] eq "") ?
    117         shift @right :            # quick way
    118         split /\//, $dir;
    119     };    # first element always null
    120     while (@right) {
    121         my $item = shift @right;
    122         next if $item eq "." or $item eq "";
    123         if ($item eq "..") {
    124             pop @left if @left > 1;
    125             next;
    126         }
    127         my $link = readlink (join "/", @left, $item);
    128         if (defined $link) {
    129             my @parts = split /\//, $link;
    130             if (@parts && ($parts[0] eq "")) { # absolute
    131                 @left = shift @parts;   # quick way
    132             }
    133         unshift @right, @parts;
    134         next;
    135         } else {
    136             push @left, $item;
    137             next;
    138         }
    139     }
    140     #print "$File::Find::name is ", join("/", @left), "\n";
    141     $link = join("/", @left);
    142 }, @_;
    143 return($link);
    144 }
    145 
    146107# Adapted From /usr/lib/rpm/mandriva/perl.req
    147108# by Ken Estes Mail.com kestes@staff.mail.com
    148109
    149 sub process_file {
     110sub mr_process_file {
    150111 
    151112my %line;
Note: See TracChangeset for help on using the changeset viewer.