Revision d6fad186
Von Udo Spallek vor etwa 18 Jahren hinzugefügt
scripts/find-use.pl | ||
---|---|---|
1 |
#!/usr/bin/perl -w |
|
2 |
=head1 NAME |
|
3 |
|
|
4 |
find-use |
|
5 |
|
|
6 |
=head1 EXAMPLE |
|
7 |
|
|
8 |
~/ledgersmb # utils/devel/find-use |
|
9 |
0.000000 : HTML::Entities |
|
10 |
0.000000 : Locale::Maketext::Lexicon |
|
11 |
0.000000 : Module::Build |
|
12 |
... |
|
13 |
|
|
14 |
=head1 EXPLINATION |
|
15 |
|
|
16 |
This util is useful for package builders to identify all the CPAN dependencies we've made. It required Module::CoreList (which is core, but is not yet in any stable |
|
17 |
release of perl) to determine if a module is distributed with perl or not. The output reports which version of perl the module is in. If it reports 0.000000, then the |
|
18 |
module is not in core perl, and needs to be installed before Lx-Office will operate. |
|
19 |
|
|
20 |
=head1 AUTHOR |
|
21 |
|
|
22 |
http://www.ledgersmb.org/ - The LedgerSMB team |
|
23 |
|
|
24 |
=head1 LICENSE |
|
25 |
|
|
26 |
Distributed under the terms of the LedgerSMB code. |
|
27 |
|
|
28 |
=cut |
|
29 |
|
|
30 |
|
|
31 |
use strict; |
|
32 |
use warnings; |
|
33 |
|
|
34 |
open GREP, "grep -r '^use ' . |"; |
|
35 |
use Module::CoreList; |
|
36 |
|
|
37 |
my %uselines; |
|
38 |
while(<GREP>) { |
|
39 |
next if /SL::/; |
|
40 |
next if /LX::/; |
|
41 |
next if /use warnings/; |
|
42 |
next if /use strict/; |
|
43 |
next if /use vars/; |
|
44 |
chomp; |
|
45 |
my ($file, $useline) = m/^([^:]+):use\s(.*?)$/; |
|
46 |
$uselines{$useline}||=[]; |
|
47 |
push @{$uselines{$useline}}, $file; |
|
48 |
} |
|
49 |
|
|
50 |
my %modules; |
|
51 |
foreach my $useline (keys %uselines) { |
|
52 |
|
|
53 |
my ($module) = grep { $_ } $useline =~ /(?:base ['"]([a-z:]+)|([a-z:]+)(?:\s|;))/i; |
|
54 |
my $version = Module::CoreList->first_release($module); |
|
55 |
$modules{$module} = $version||0; |
|
56 |
} |
|
57 |
|
|
58 |
foreach my $mod (sort { $modules{$a} == 0 ? -1 : $modules{$b} == 0 ? 1 : 0 or $a cmp $b } keys %modules) { |
|
59 |
printf "%2.6f : %s\n", $modules{$mod}, $mod; |
|
60 |
} |
|
61 |
|
Auch abrufbar als: Unified diff
Script: find-use
Findet alle benoetigten Module von Lx. (Uebernommen und angepasst von LeggerSMB)