]>
git.ipfire.org Git - pakfire.git/blob - scripts/perl.req
3 # RPM (and its source code) is covered under two separate licenses.
5 # The entire code base may be distributed under the terms of the GNU
6 # General Public License (GPL), which appears immediately below.
7 # Alternatively, all of the source code in the lib subdirectory of the
8 # RPM source code distribution as well as any code derived from that
9 # code may instead be distributed under the GNU Library General Public
10 # License (LGPL), at the choice of the distributor. The complete text
11 # of the LGPL appears at the bottom of this file.
13 # This alternatively is allowed to enable applications to be linked
14 # against the RPM library (commonly called librpm) without forcing
15 # such applications to be distributed under the GPL.
17 # Any questions regarding the licensing of RPM should be addressed to
18 # Erik Troan <ewt@redhat.com>.
20 # a simple makedepend like script for perl.
22 # To save development time I do not parse the perl grammmar but
23 # instead just lex it looking for what I want. I take special care to
24 # ignore comments and pod's.
26 # It would be much better if perl could tell us the dependencies of a
29 # The filenames to scan are either passed on the command line or if
30 # that is empty they are passed via stdin.
32 # If there are strings in the file which match the pattern
33 # m/^\s*\$RPM_Requires\s*=\s*["'](.*)['"]/i
34 # then these are treated as additional names which are required by the
35 # file and are printed as well.
37 # I plan to rewrite this in C so that perl is not required by RPM at
40 # by Ken Estes Mail.com kestes@staff.mail.com
48 # notice we are passed a list of filenames NOT as common in unix the
49 # contents of the file.
57 foreach $module (sort keys %require) {
58 if (length($require{$module}) == 0) {
59 print "perl($module)\n";
62 # I am not using rpm3.0 so I do not want spaces around my
63 # operators. Also I will need to change the processing of the
64 # $RPM_* variable when I upgrade.
66 print "perl($module)>=$require{$module}\n";
79 open(FILE
, "<$file") || return;
83 # skip the "= <<" block
85 if ( ( m/^\s*\$(?:.*)\s*=\s*<<\s*(["'`])(.*)\1/) ||
86 ( m/^\s*\$(.*)\s*=\s*<<(\w*)\s*;/) ) {
90 ( $_ eq $tag ) && last;
95 # skip q{} quoted sections - just hope we don't have curly brackets
96 # within the quote, nor an escaped hash mark that isn't a comment
97 # marker, such as occurs right here. Draw the line somewhere.
98 if ( m/^.*\Wq[qxwr]?\s*([\{\(\[#|\/])[^})\
]#|\/]*$/ && ! m/^\s*(require|use)\s/ ) {
100 $tag =~ tr/{\(\[\#|\//})]#|\//;
102 ( $_ =~ m/\}/ ) && last;
106 # skip the documentation
108 # we should not need to have item in this if statement (it
109 # properly belongs in the over/back section) but people do not
112 if ( (m/^=(head[1-4]|pod|item)/) .. (m/^=(cut)/) ) {
116 if ( (m/^=(over)/) .. (m/^=(back)/) ) {
120 # skip the data section
121 if (m/^__(DATA|END)__$/) {
125 # Each keyword can appear multiple times. Don't
126 # bother with datastructures to store these strings,
127 # if we need to print it print it now.
129 # Again allow for "our".
130 if ( m/^\s*(our\s+)?\$RPM_Requires\s*=\s*["'](.*)['"]/i) {
131 foreach $_ (split(/\s+/, $2)) {
138 # ouch could be in a eval, perhaps we do not want these since we catch
139 # an exception they must not be required
141 # eval { require Term::ReadLine } or die $@;
142 # eval "require Term::Rendezvous;" or die $@;
143 # eval { require Carp } if defined $^S; # If error/warning during compilation,
146 (m
/^(\s
*) # we hope the inclusion starts the line
147 (require|use)\s
+(?
!\
{) # do not want 'do {' loops
148 # quotes around name are always legal
149 [\'\"]?
([^\
;\
\'\"\t]*)[\'\"]?
[\t\
;\
]
150 # the syntax for 'use' allows version requirements
154 my ($whitespace, $statement, $module, $version) = ($1, $2, $3,$4);
156 # we only consider require statements that are flush against
157 # the left edge. any other require statements give too many
158 # false positives, as they are usually inside of an if statement
159 # as a fallback module or a rarely used option
161 ($whitespace ne "" && $statement eq "require") && next;
163 # if there is some interpolation of variables just skip this
164 # dependency, we do not want
165 # do "$ENV{LOGDIR}/$rcfile";
167 ($module =~ m/\$/) && next;
169 # skip if the phrase was "use of" -- shows up in gimp-perl, et al.
170 next if $module eq 'of';
172 # if the module ends in a comma we probaly caught some
173 # documentation of the form 'check stuff,\n do stuff, clean
174 # stuff.' there are several of these in the perl distribution
176 ($module =~ m/[,>]$/) && next;
178 # if the module name starts in a dot it is not a module name.
179 # Is this necessary? Please give me an example if you turn this
182 # ($module =~ m/^\./) && next;
184 # if the module ends with .pm strip it to leave only basename.
185 # starts with /, which means its an absolute path to a file
186 if ($module =~ m
(^/)) {
191 # sometimes people do use POSIX qw(foo), or use POSIX(qw(foo)) etc.
192 # we can strip qw.*$, as well as (.*$:
193 $module =~ s/qw.*$//;
194 $module =~ s/\(.*$//;
196 $module =~ s/\.pm$//;
198 # some perl programmers write 'require URI/URL;' when
199 # they mean 'require URI::URL;'
203 # trim off trailing parentheses if any. Sometimes people pass
204 # the module an empty list.
206 $module =~ s/\(\s*\)$//;
208 if ( $module =~ m/^v?([0-9._]+)$/ ) {
209 # if module is a number then both require and use interpret that
210 # to mean that a particular version of perl is specified
213 if ($ver =~ /5.00/) {
214 print "perl>=0:$ver\n";
218 print "perl>=1:$ver\n";
224 # ph files do not use the package name inside the file.
225 # perlmodlib documentation says:
227 # the .ph files made by h2ph will probably end up as
228 # extension modules made by h2xs.
230 # so do not expend much effort on these.
233 # there is no easy way to find out if a file named systeminfo.ph
234 # will be included with the name sys/systeminfo.ph so only use the
235 # basename of *.ph files
237 ($module =~ m/\.ph$/) && next;
239 $require{$module}=$version;
246 die("$0: Could not close file: '$file' : $!\n");