]> git.pld-linux.org Git - packages/rpm.git/blob - rpm-perl-req-perlfile.patch
- enable support for read-only bdb backend
[packages/rpm.git] / rpm-perl-req-perlfile.patch
1 --- rpm-4.2/scripts/perl.req.wigperl    Tue Apr  1 13:33:52 2003
2 +++ rpm-4.2/scripts/perl.req    Tue Apr  1 13:39:47 2003
3 @@ -39,28 +39,19 @@
4  eval { require version; $HAVE_VERSION = 1; };
5  
6  
7 -if ("@ARGV") {
8 -  foreach (@ARGV) {
9 +foreach ( @ARGV ? @ARGV : <> ) {
10 +       chomp;
11      if (m=/usr/(sbin|bin|lib|share|X11R6/(lib|bin))/=) {
12        if (! m=(/(doc|man|info|usr/src)/|\.(so|ph|h|html|pod)$)=) {
13 -        process_file($_);
14 +        process_file($_) if -f;
15        }
16      }
17 -  }
18 -} else {
19 -
20 -  # notice we are passed a list of filenames NOT as common in unix the
21 -  # contents of the file.
22 -
23 -  foreach (<>) {
24 -     if (m=/usr/(sbin|bin|lib|share|X11R6/(lib|bin))/=) {
25 -       if (! m=(/(doc|man|info|usr/src)/|\.(so|ph|h|html|pod)$)=) {
26 -         process_file($_);
27 -       }
28 -     }
29 -  }
30  }
31  
32 +foreach (sort keys %provide) {
33 +    delete $require{$_};
34 +}
35 +delete $require{the}; # don't count "use the sth" as perl module  
36  
37  foreach $perlver (sort keys %perlreq) {
38    print "perl >= $perlver\n";
39 @@ -82,6 +74,53 @@
40    }
41  }
42  
43 +sub is_perlfile {
44 +    my $file = shift;
45 +    my $fh = shift;
46 +
47 +    my $fl = <$fh>;
48 +
49 +    my $is_perl = 0;
50 +
51 +    my $nw = 0;
52 +
53 +    if ($file =~ /\.(so|ph|h|html|pod|gz|bz2|png|gif|jpg|xpm|a|patch|o|mo)$/) {
54 +       $is_perl = 0;
55 +       
56 +       # .al, .pl, .pm and .plx (perl-Font-TTF contains *.plx files)
57 +    } elsif ($file =~ /\.p[lm]x?$/ || $file =~ /\.al$/) {      
58 +       $is_perl = 1;
59 +       #print STDERR "$file PERL by ext\n";
60 +    } elsif ($fl =~ m|bin/perl| or $fl =~ m|env\s+perl| or $fl =~ m|exec\s+perl|) {
61 +       $is_perl = 1;
62 +       #print STDERR "$file PERL by perl\n";
63 +    } elsif ($fl =~ m|bin/sh|) {
64 +       while (<$fh>) {
65 +           if (/eval/ && /perl/) {
66 +               $is_perl = 1;
67 +               last;
68 +           }
69 +           $nw++ if (/^\s*BEGIN/); 
70 +           $nw++ if (/^\s*sub\s+/);
71 +           $nw++ if (/^\s*package\s+/);
72 +           $nw++ if (/^\s*use\s+strict\s+;/);
73 +           $nw++ if (/^\s*use\s+vars\s*qw/);
74 +           last if ($. > 30);
75 +       }
76 +    }
77 +
78 +    seek($fh, 0, 0);
79 +
80 +    $is_perl = 1 if ($nw > 1);  # propably perl file
81 +
82 +    #if (!$is_perl) {
83 +    #   print STDERR "NOPERL $file\n";
84 +    #   return 0;
85 +    #} 
86 +    #print STDERR "PERL $file\n" if ($is_perl);
87 +    return $is_perl;
88 +}
89 +
90  sub process_file {
91  
92    my ($file) = @_;
93 @@ -90,6 +129,8 @@
94      return;
95    }
96  
97 +  return if (!is_perlfile($file, \*FILE));
98 +
99    while (<FILE>) {
100  
101      # skip the "= <<" block
102 @@ -111,6 +152,10 @@
103        last;
104      }
105  
106 +    if (m/^\s*package\s+([_:a-zA-Z0-9]+)\s*;/) {
107 +       $provide{$1} = 1;
108 +    }
109 +
110      # Each keyword can appear multiple times.  Don't
111      #  bother with datastructures to store these strings,
112      #  if we need to print it print it now.
113 @@ -236,6 +281,10 @@
114  
115        ($module =~ m/^\./) && next;
116  
117 +      # name starts in a non alphanumeric character it is not a module 
118 +      # name.
119 +      ($module =~ m/^\W/) && next;
120 +
121        # if the module ends with .pm strip it to leave only basename.
122  
123        $module =~ s/\.pm$//;
This page took 0.038546 seconds and 3 git commands to generate.