]>
git.ipfire.org Git - people/ms/ipfire-3.x.git/blob - pkgs/core/build-essentials/buildsystem-tools/perl.prov
73bec513b12fe5021c5815aeb6bc117f3c506398
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 alternative 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 script to print the proper name for perl libraries.
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 proper name 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 lines in the file which match the pattern
33 # (m/^\s*\$VERSION\s*=\s+/)
34 # then these are taken to be the version numbers of the modules.
35 # Special care is taken with a few known idioms for specifying version
36 # numbers of files under rcs/cvs control.
38 # If there are strings in the file which match the pattern
39 # m/^\s*\$RPM_Provides\s*=\s*["'](.*)['"]/i
40 # then these are treated as additional names which are provided by the
41 # file and are printed as well.
43 # I plan to rewrite this in C so that perl is not required by RPM at
46 # by Ken Estes Mail.com kestes@staff.mail.com
54 # notice we are passed a list of filenames NOT as common in unix the
55 # contents of the file.
63 foreach $module (sort keys %require) {
64 if (length($require{$module}) == 0) {
65 print "perl($module)\n";
68 # I am not using rpm3.0 so I do not want spaces arround my
69 # operators. Also I will need to change the processing of the
70 # $RPM_* variable when I upgrade.
72 print "perl($module)=$require{$module}\n";
85 open(FILE
, "<$file") || return;
87 my ($package, $version, $incomment, $inover) = ();
91 # skip the documentation
93 # we should not need to have item in this if statement (it
94 # properly belongs in the over/back section) but people do not
97 if (m/^=(head[1-4]|pod|item)/) {
114 if ($incomment || $inover) {
118 # skip the data section
119 if (m/^__(DATA|END)__$/) {
123 # not everyone puts the package name of the file as the first
124 # package name so we report all namespaces except some common
125 # false positives as if they were provided packages (really ugly).
127 if (m/^\s*package\s+([_:a-zA-Z0-9]+)\s*;/) {
130 if ($package eq 'main') {
133 # If $package already exists in the $require hash, it means
134 # the package definition is broken up over multiple blocks.
135 # In that case, don't stomp a previous $VERSION we might have
136 # found. (See BZ#214496.)
137 $require{$package}=undef unless (exists $require{$package});
141 # after we found the package name take the first assignment to
142 # $VERSION as the version number. Exporter requires that the
143 # variable be called VERSION so we are safe.
145 # here are examples of VERSION lines from the perl distribution
147 #FindBin.pm:$VERSION = $VERSION = sprintf("%d.%02d", q$Revision: 1.9 $ =~ /(\d+)\.(\d+)/);
148 #ExtUtils/Install.pm:$VERSION = substr q$Revision: 1.9 $, 10;
149 #CGI/Apache.pm:$VERSION = (qw$Revision: 1.9 $)[1];
150 #DynaLoader.pm:$VERSION = $VERSION = "1.03"; # avoid typo warning
151 #General.pm:$Config::General::VERSION = 2.33;
153 # or with the new "our" pragma you could (read will) see:
155 # our $VERSION = '1.00'
156 if (($package) && (m/^\s*(our\s+)?\$(\Q$package\E::)?VERSION\s*=\s+/)) {
158 # first see if the version string contains the string
159 # '$Revision' this often causes bizzare strings and is the most
160 # common method of non static numbering.
162 if (m/(\$Revision: (\d+[.0-9]+))/) {
164 } elsif (m/[\'\"]?(\d+[.0-9]+)[\'\"]?/) {
166 # look for a static number hard coded in the script
170 $require{$package}=$version;
173 # Allow someone to have a variable that defines virtual packages
174 # The variable is called $RPM_Provides. It must be scoped with
175 # "our", but not "local" or "my" (just would not make sense).
179 # $RPM_Provides = "blah bleah"
181 # Will generate provides for "blah" and "bleah".
183 # Each keyword can appear multiple times. Don't
184 # bother with datastructures to store these strings,
185 # if we need to print it print it now.
187 if ( m/^\s*(our\s+)?\$RPM_Provides\s*=\s*["'](.*)['"]/i) {
188 foreach $_ (split(/\s+/, $2)) {
196 die("$0: Could not close file: '$file' : $!\n");