Bug 214496 - perl.prov can miss $VERSION for packages defined in multiple blocks
Summary: perl.prov can miss $VERSION for packages defined in multiple blocks
Alias: None
Product: Fedora
Classification: Fedora
Component: rpm
Version: 7
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Panu Matilainen
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2006-11-07 21:08 UTC by James Ralston
Modified: 2007-11-30 22:11 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2007-08-28 11:04:58 UTC
Type: ---

Attachments (Terms of Use)
patch to correct perl.prov's behavior (586 bytes, patch)
2007-08-24 21:24 UTC, James Ralston
no flags Details | Diff

Description James Ralston 2006-11-07 21:08:05 UTC
/usr/lib/perl5/5.8.8/Getopt/Long.pm contains:

use vars qw($VERSION);
$VERSION        =  2.35;
# For testing versions only.
#use vars qw($VERSION_STRING);
#$VERSION_STRING = "2.35";

But rpm's perl.prov script can't parse the version number:

$ /usr/lib/rpm/perl.prov /usr/lib/perl5/5.8.8/Getopt/Long.pm 

As a result, trying to use a construct like this in a spec file will fail:

Requires: perl(Getopt::Long)
Conflicts: perl(Getopt::Long) < 2.30

...because as far as rpm is concerned, it doesn't know what version
perl(Getopt::Long) is providing.

The package versions in question are:

$ rpm -q perl rpm

This is a minor bug, but still an annoying one.

Comment 1 Red Hat Bugzilla 2007-08-21 05:29:13 UTC
User pnasrat's account has been closed

Comment 2 Panu Matilainen 2007-08-22 06:34:58 UTC
Reassigning to owner after bugzilla made a mess, sorry about the noise...

Comment 3 James Ralston 2007-08-24 21:24:36 UTC
Created attachment 172460 [details]
patch to correct perl.prov's behavior

Well, here's the problem:

$ grep -E '^\s*(package|\$VERSION)' /usr/lib/perl5/5.8.8/Getopt/Long.pm
package Getopt::Long;
$VERSION	=  2.35;
package Getopt::Long::Parser;
package Getopt::Long;

The problem is, when /usr/lib/rpm/perl.prov sees a "package" statement, it
forgets about any previous $VERSION line it saw.  In other words, perl.prov is
expecting this:

$ grep -E '^\s*(package|\$VERSION)' /usr/lib/perl5/5.8.8/Getopt/Long.pm
package Getopt::Long;
$VERSION	=  2.35;
package Getopt::Long::Parser;
package Getopt::Long;
$VERSION	=  2.35;

But from reading /usr/lib/perl5/5.8.8/Getopt/Long.pm, this is clearly wrong;
the second "package Getopt::Long" definition is concatenating with the first

I think perl.prov should try to match perl's behavior.	And we can test that:

$ cat native-perl-provides
#! /usr/bin/perl
use Getopt::Long;
use strict;
use warnings;
if (defined $Getopt::Long::VERSION) {
   print "perl(Getopt::Long) = $Getopt::Long::VERSION\n";
} else {
   print "perl(Getopt::Long)\n";
if (defined $Getopt::Long::Parser::VERSION) {
   print "perl(Getopt::Long) = $Getopt::Long::Parser::VERSION\n";
} else {
   print "perl(Getopt::Long::Parser)\n";

perl(Getopt::Long) = 2.35

So, according to perl itself, Getopt::Long has a version, but
Getopt::Long::Parser does not.	That means that successive definitions of the
same package should NOT stomp a previously-found $VERSION.

The attached patch implements this behavior.

Comment 4 Panu Matilainen 2007-08-28 11:04:58 UTC
Fixed in rpm in next rawhide push. final should find it's
way to F7 too eventually...

Thanks for the patch!

Note You need to log in before you can comment on or make changes to this bug.