Changeset 3385 in MondoRescue
- Timestamp:
- May 13, 2015, 4:58:56 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi/mindi-get-perl-modules
r3383 r3385 9 9 use strict; 10 10 11 use File::Find;12 11 use MondoRescue::File; 13 12 use Data::Dumper; 13 use File::Basename; 14 14 15 15 =pod … … 56 56 =cut 57 57 58 my %files; 59 my %found; 58 60 59 61 my $file = mr_get_perl_modules(@ARGV) if (defined $ARGV[0]); … … 67 69 sub mr_get_perl_modules { 68 70 69 my % files;71 my %newly_found; 70 72 71 73 #print "Searching in "; 72 74 #print join "\n", @INC; 73 75 74 my $require = mr_process_file(@_); 76 my $require = mr_process_file(@_,"warnings"); 77 78 #print "Requires found:\n"; 79 #print Dumper($require); 80 #print "---------------\n"; 81 82 my $cpt = keys %$require; 83 84 # Exit recursion 85 return({}) if ($cpt == 0); 75 86 76 87 my @includes; … … 84 95 } 85 96 86 find( 87 sub { 88 if ((-f $File::Find::name) 89 && (/\.pm$/) 90 && (not defined $files{$File::Find::name})) { 91 foreach my $m (keys %$require,"warnings") { 92 (my $mod = $m) =~ s|::|/|g; 93 #print "Looking at $mod in $File::Find::name\n"; 94 if (index($File::Find::name,"$mod.pm") ne -1) { 95 $files{$File::Find::name} = $mod; 96 #push @files, $File::Find::name; 97 #print "Found $mod in $File::Find::name\n"; 98 last; 99 } 100 } 101 } 102 }, 103 @includes); 97 foreach my $m (keys %$require) { 98 (my $mod = $m) =~ s|::|/|g; 99 # Already found 100 next if (exists $found{$mod}); 101 foreach my $d (@includes) { 102 #print "Looking at $m in $d\n"; 103 if (-f "$d/$mod.pm") { 104 $files{"$d/$mod.pm"} = $mod; 105 $found{$mod} = "$d/$mod.pm"; 106 $newly_found{"$d/$mod.pm"} = $mod; 107 #print "Found $mod in $d/$mod.pm\n"; 108 last; 109 } 110 } 111 print "ERROR: Unable to find $mod. Your perl setup is incorrect\n" if (not exists $found{$mod}); 112 } 113 114 #print "Files found:\n"; 115 #print Dumper(\%files); 116 #print Dumper(\%found); 117 #print "---------------\n"; 118 119 #print "New Files found:\n"; 120 #print Dumper(\%newly_found); 121 #print "---------------\n"; 104 122 105 123 # Recurse on what we just found 106 my $found = mr_process_file(keys %files); 107 find( 108 sub { 109 if ((-f $File::Find::name) 110 && (/\.pm$/) 111 && (not defined $files{$File::Find::name})) { 112 foreach my $m (keys %$found) { 113 (my $mod = $m) =~ s|::|/|g; 114 #print "Looking at $mod in $File::Find::name\n"; 115 if (index($File::Find::name,"$mod.pm") ne -1) { 116 $files{$File::Find::name} = $mod; 117 #push @files, $File::Find::name; 118 #print "Found $mod in $File::Find::name\n"; 119 last; 120 } 121 } 122 } 123 }, 124 @includes); 125 124 my $foundrec = mr_get_perl_modules(keys %newly_found); 125 126 # Cleanup 127 foreach my $k (keys %newly_found) { 128 delete $newly_found{$k}; 129 } 130 131 foreach my $k (sort keys %$foundrec) { 132 if (not defined $files{$k}) { 133 $files{$k} = $foundrec->{$k}; 134 } 135 } 126 136 127 137 return(\%files); … … 209 219 # as a fallback module or a rarely used option 210 220 211 ($whitespace ne "" && $statement eq "require") && next; 212 221 ($whitespace !~ /^\s*$/ && $statement eq "require") && next; 222 223 #print "*** $whitespace, $statement, $module, $version ***\n"; 213 224 # if there is some interpolation of variables just skip this 214 225 # dependency, we do not want
Note:
See TracChangeset
for help on using the changeset viewer.