]> git.pld-linux.org Git - packages/rpm.git/blame - rpm-perl-req-perlfile.patch
- spec cleanup
[packages/rpm.git] / rpm-perl-req-perlfile.patch
CommitLineData
ff5da8bf
AF
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
6ecfe7c2
JR
3@@ -39,28 +39,19 @@
4 eval { require version; $HAVE_VERSION = 1; };
ff5da8bf 5
ff5da8bf
AF
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 {
6ecfe7c2 19-
ff5da8bf
AF
20- # notice we are passed a list of filenames NOT as common in unix the
21- # contents of the file.
6ecfe7c2 22-
ff5da8bf
AF
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- }
7b138760 30 }
31
32+foreach (sort keys %provide) {
33+ delete $require{$_};
34+}
35+delete $require{the}; # don't count "use the sth" as perl module
7b138760 36
6ecfe7c2
JR
37 foreach $perlver (sort keys %perlreq) {
38 print "perl >= $perlver\n";
ff5da8bf 39@@ -82,6 +74,53 @@
6ecfe7c2
JR
40 }
41 }
2699ff91 42
43+sub is_perlfile {
44+ my $file = shift;
45+ my $fh = shift;
6ecfe7c2 46+
2699ff91 47+ my $fl = <$fh>;
48+
49+ my $is_perl = 0;
6ecfe7c2 50+
2699ff91 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+ }
6ecfe7c2 77+
2699ff91 78+ seek($fh, 0, 0);
6ecfe7c2 79+
2699ff91 80+ $is_perl = 1 if ($nw > 1); # propably perl file
6ecfe7c2 81+
2699ff91 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+
2699ff91 90 sub process_file {
6ecfe7c2
JR
91
92 my ($file) = @_;
ff5da8bf 93@@ -90,6 +129,8 @@
6ecfe7c2
JR
94 return;
95 }
96
5b0f0ac9
MM
97+ return if (!is_perlfile($file, \*FILE));
98+
2699ff91 99 while (<FILE>) {
6ecfe7c2
JR
100
101 # skip the "= <<" block
ff5da8bf 102@@ -111,6 +152,10 @@
7b138760 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.
ff5da8bf 113@@ -236,6 +281,10 @@
2699ff91 114
115 ($module =~ m/^\./) && next;
5b0f0ac9 116
2699ff91 117+ # name starts in a non alphanumeric character it is not a module
118+ # name.
119+ ($module =~ m/^\W/) && next;
5b0f0ac9 120+
2699ff91 121 # if the module ends with .pm strip it to leave only basename.
122
5b0f0ac9 123 $module =~ s/\.pm$//;
This page took 0.102202 seconds and 4 git commands to generate.