]> git.pld-linux.org Git - packages/rpm.git/blob - rpm-perl-req-perlfile.patch
- better perl files detection patch and test script
[packages/rpm.git] / rpm-perl-req-perlfile.patch
1 --- rpm-4.0/scripts/perl.req    Wed Jul  5 14:26:37 2000
2 +++ rpm-4.0.new/scripts/perl.req        Wed Nov 15 21:31:03 2000
3 @@ -82,6 +82,53 @@
4  exit 0;
5  
6  
7 +sub is_perlfile {
8 +    my $file = shift;
9 +    my $fh = shift;
10 +    
11 +    my $fl = <$fh>;
12 +
13 +    my $is_perl = 0;
14 +  
15 +    my $nw = 0;
16 +
17 +    if ($file =~ /\.(so|ph|h|html|pod|gz|bz2|png|gif|jpg|xpm|a|patch|o|mo)$/) {
18 +       $is_perl = 0;
19 +       
20 +       # .al, .pl, .pm and .plx (perl-Font-TTF contains *.plx files)
21 +    } elsif ($file =~ /\.p[lm]x?$/ || $file =~ /\.al$/) {      
22 +       $is_perl = 1;
23 +       #print STDERR "$file PERL by ext\n";
24 +    } elsif ($fl =~ m|bin/perl| or $fl =~ m|env\s+perl| or $fl =~ m|exec\s+perl|) {
25 +       $is_perl = 1;
26 +       #print STDERR "$file PERL by perl\n";
27 +    } elsif ($fl =~ m|bin/sh|) {
28 +       while (<$fh>) {
29 +           if (/eval/ && /perl/) {
30 +               $is_perl = 1;
31 +               last;
32 +           }
33 +           $nw++ if (/^\s*BEGIN/); 
34 +           $nw++ if (/^\s*sub\s+/);
35 +           $nw++ if (/^\s*package\s+/);
36 +           $nw++ if (/^\s*use\s+strict\s+;/);
37 +           $nw++ if (/^\s*use\s+vars\s*qw/);
38 +           last if ($. > 30);
39 +       }
40 +    }
41 +    
42 +    seek($fh, 0, 0);
43 +    
44 +    $is_perl = 1 if ($nw > 1);  # propably perl file
45 +    
46 +    #if (!$is_perl) {
47 +    #   print STDERR "NOPERL $file\n";
48 +    #   return 0;
49 +    #} 
50 +    #print STDERR "PERL $file\n" if ($is_perl);
51 +    return $is_perl;
52 +}
53 +
54  
55  sub process_file {
56    
57 @@ -90,6 +137,8 @@
58    
59    open(FILE, "<$file")||
60      die("$0: Could not open file: '$file' : $!\n");
61 +
62 +  return if (!is_perlfile($file, \*FILE));
63    
64    while (<FILE>) {
65      
66 @@ -209,6 +258,10 @@
67        # if the module name starts in a dot it is not a module name.
68  
69        ($module =~ m/^\./) && next;
70 +
71 +      # name starts in a non alphanumeric character it is not a module 
72 +      # name.
73 +      ($module =~ m/^\W/) && next;
74  
75        # if the module ends with .pm strip it to leave only basename.
76  
This page took 0.058673 seconds and 4 git commands to generate.