Changeset 2839 in MondoRescue for branches/2.2.9/mindi/mindi-get-perl-modules


Ignore:
Timestamp:
Jun 26, 2011, 3:01:13 AM (13 years ago)
Author:
Bruno Cornec
Message:

-Fix mindi-get-perl-modules when perl dirs in @INC are symlinks (case on Ubuntu 11.04)

File:
1 edited

Legend:

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

    r2593 r2839  
    66
    77use File::Find;
     8use Cwd;
    89
    910my $file = get_perl_modules(@ARGV) if (defined $ARGV[0]);
     
    2829#
    2930foreach my $d (@INC) {
     31    $d = read_all_link($d) if (-l $d);
    3032    push @includes,$d if (-d $d);
    3133}
     
    5355}
    5456
     57# Cf: http://www.stonehenge.com/merlyn/UnixReview/col27.html
     58sub read_all_link {
     59
     60my $dir = cwd;
     61my $link;
     62
     63find sub {
     64    return unless -l;
     65    my @right = split /\//, $File::Find::name;
     66    my @left = do {
     67        @right && ($right[0] eq "") ?
     68        shift @right :            # quick way
     69        split /\//, $dir;
     70    };    # first element always null
     71    while (@right) {
     72        my $item = shift @right;
     73        next if $item eq "." or $item eq "";
     74        if ($item eq "..") {
     75            pop @left if @left > 1;
     76            next;
     77        }
     78        my $link = readlink (join "/", @left, $item);
     79        if (defined $link) {
     80            my @parts = split /\//, $link;
     81            if (@parts && ($parts[0] eq "")) { # absolute
     82                @left = shift @parts;   # quick way
     83            }
     84        unshift @right, @parts;
     85        next;
     86        } else {
     87            push @left, $item;
     88            next;
     89        }
     90    }
     91    #print "$File::Find::name is ", join("/", @left), "\n";
     92    $link = join("/", @left);
     93}, @_;
     94return($link);
     95}
     96
    5597# Adapted From /usr/lib/rpm/mandriva/perl.req
    5698# by Ken Estes Mail.com kestes@staff.mail.com
Note: See TracChangeset for help on using the changeset viewer.