]> git.pld-linux.org Git - packages/rpm.git/blame - rpm-perl-req-perlfile.patch
- release 0.%%{snap}.3
[packages/rpm.git] / rpm-perl-req-perlfile.patch
CommitLineData
5b0f0ac9
MM
1--- rpm-4.0.4/scripts/perl.req.wiget Tue Feb 12 21:49:36 2002
2+++ rpm-4.0.4/scripts/perl.req Tue Feb 12 21:51:41 2002
7b138760 3@@ -61,6 +61,11 @@
4 }
5 }
6
7+foreach (sort keys %provide) {
8+ delete $require{$_};
9+}
10+delete $require{the}; # don't count "use the sth" as perl module
11+
12
13 foreach $module (sort keys %require) {
14 if (length($require{$module}) == 0) {
5b0f0ac9 15@@ -82,6 +87,53 @@
2699ff91 16 exit 0;
17
18
19+sub is_perlfile {
20+ my $file = shift;
21+ my $fh = shift;
22+
23+ my $fl = <$fh>;
24+
25+ my $is_perl = 0;
26+
27+ my $nw = 0;
28+
29+ if ($file =~ /\.(so|ph|h|html|pod|gz|bz2|png|gif|jpg|xpm|a|patch|o|mo)$/) {
30+ $is_perl = 0;
31+
32+ # .al, .pl, .pm and .plx (perl-Font-TTF contains *.plx files)
33+ } elsif ($file =~ /\.p[lm]x?$/ || $file =~ /\.al$/) {
34+ $is_perl = 1;
35+ #print STDERR "$file PERL by ext\n";
36+ } elsif ($fl =~ m|bin/perl| or $fl =~ m|env\s+perl| or $fl =~ m|exec\s+perl|) {
37+ $is_perl = 1;
38+ #print STDERR "$file PERL by perl\n";
39+ } elsif ($fl =~ m|bin/sh|) {
40+ while (<$fh>) {
41+ if (/eval/ && /perl/) {
42+ $is_perl = 1;
43+ last;
44+ }
45+ $nw++ if (/^\s*BEGIN/);
46+ $nw++ if (/^\s*sub\s+/);
47+ $nw++ if (/^\s*package\s+/);
48+ $nw++ if (/^\s*use\s+strict\s+;/);
49+ $nw++ if (/^\s*use\s+vars\s*qw/);
50+ last if ($. > 30);
51+ }
52+ }
53+
54+ seek($fh, 0, 0);
55+
56+ $is_perl = 1 if ($nw > 1); # propably perl file
57+
58+ #if (!$is_perl) {
59+ # print STDERR "NOPERL $file\n";
60+ # return 0;
61+ #}
62+ #print STDERR "PERL $file\n" if ($is_perl);
63+ return $is_perl;
64+}
65+
66
67 sub process_file {
68
5b0f0ac9 69@@ -90,6 +142,8 @@
2699ff91 70
5b0f0ac9 71 open(FILE, "<$file") || return;
2699ff91 72
5b0f0ac9
MM
73+ return if (!is_perlfile($file, \*FILE));
74+
2699ff91 75 while (<FILE>) {
76
5b0f0ac9
MM
77 # skip the documentation
78@@ -111,6 +165,10 @@
7b138760 79 last;
80 }
81
82+ if (m/^\s*package\s+([_:a-zA-Z0-9]+)\s*;/) {
83+ $provide{$1} = 1;
84+ }
85+
86 # Each keyword can appear multiple times. Don't
87 # bother with datastructures to store these strings,
88 # if we need to print it print it now.
5b0f0ac9 89@@ -229,6 +287,10 @@
2699ff91 90
91 ($module =~ m/^\./) && next;
5b0f0ac9 92
2699ff91 93+ # name starts in a non alphanumeric character it is not a module
94+ # name.
95+ ($module =~ m/^\W/) && next;
5b0f0ac9 96+
2699ff91 97 # if the module ends with .pm strip it to leave only basename.
98
5b0f0ac9 99 $module =~ s/\.pm$//;
This page took 0.096077 seconds and 4 git commands to generate.