3 # RPM (and it's 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 makedepends 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 arround my
63 # operators. Also I will need to change the processing of the
64 # $RPM_* vairable when I upgrage.
66 print "perl($module) >= $require{$module}\n";
79 open(FILE, "<$file") || return;
83 # skip the documentation
85 # we should not need to have item in this if statement (it
86 # properly belongs in the over/back section) but people do not
89 if ( (m/^=(head1|head2|pod|item)/) .. (m/^=(cut)/) ) {
93 if ( (m/^=(over)/) .. (m/^=(back)/) ) {
97 # skip the data section
98 if (m/^__(DATA|END)__$/) {
102 # Each keyword can appear multiple times. Don't
103 # bother with datastructures to store these strings,
104 # if we need to print it print it now.
106 if ( m/^\s*\$RPM_Requires\s*=\s*["'](.*)['"]/i) {
107 foreach $_ (spit(/\s+/, $1)) {
114 # ouch could be in a eval, perhaps we do not want these since we catch
115 # an exception they must not be required
117 # eval { require Term::ReadLine } or die $@;
118 # eval "require Term::Rendezvous;" or die $@;
119 # eval { require Carp } if defined $^S; # If error/warning during compilation,
122 (m/^\s* # we hope the inclusion starts the line
123 (do|require|use)\s+(?!\{) # do not want 'do {' loops
124 # quotes around name are always legal
125 [\'\"]?([^\;\ \'\"\t]*)[\'\"]?[\t\;\ ]
126 # the syntax for 'use' allows version requirements
130 my ($module, $version) = ($2,$3);
132 # if there is some interpolation of variables just skip this
133 # dependency, we do not want
134 # do "$ENV{LOGDIR}/$rcfile";
136 ($module =~ m/\$/) && next;
138 # if the module ends in a comma we probaly caught some
139 # documentation of the form 'check stuff,\n do stuff, clean
140 # stuff.' there are several of these in the perl distribution
142 ($module =~ m/[,>]$/) && next;
144 # if the module name starts in a dot it is not a module name.
145 # Is this necessary? Please give me an example if you turn this
148 # ($module =~ m/^\./) && next;
150 # if the module ends with .pm strip it to leave only basename.
152 $module =~ s/\.pm$//;
154 # some perl programmers write 'require URI/URL;' when
155 # they mean 'require URI::URL;'
159 # trim off trailing parenthesis if any. Sometimes people pass
160 # the module an empty list.
162 $module =~ s/\(\s*\)$//;
164 if ( $module =~ m/^[0-9._]+$/ ) {
165 # if module is a number then both require and use interpret that
166 # to mean that a particular version of perl is specified
168 print "perl > $module\n";
172 # ph files do not use the package name inside the file.
173 # perlmodlib documentation says:
175 # the .ph files made by h2ph will probably end up as
176 # extension modules made by h2xs.
178 # so do not expend much effort on these.
181 # there is no easy way to find out if a file named systeminfo.ph
182 # will be included with the name sys/systeminfo.ph so only use the
183 # basename of *.ph files
185 ($module =~ m/\.ph$/) && ($module =~ s!.*/!!g );
188 $require{$module}=$version;
195 die("$0: Could not close file: '$file' : $!\n");