Discussion:
[rt.cpan.org #78194] PAR::Dist::parse_dist_name mis-parses par file name when arch is darwin-2level
(too old to reply)
Ken Olstad via RT
2012-07-04 05:30:52 UTC
Permalink
Wed Jul 04 01:30:50 2012: Request 78194 was acted upon.
Transaction: Ticket created by KENO
Queue: PAR
Subject: PAR::Dist::parse_dist_name mis-parses par file name when arch is
darwin-2level
Broken in: 0.48
Severity: Important
Owner: Nobody
Requestors: ***@cpan.org
Status: new
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=78194 >


I am unable to load a module with arch=darwin-2level from a PAR::Repository. When parsing
the par file name, PAR::Dist::parse_dist_name() counts 2level as a Perl version. The test is to
create a repository containing some module that is not otherwise available on the system. I
used Acme::Drunk.

$ cat /tmp/testpar.pl
use strict;
use warnings;

use Test::More tests => 1;

BEGIN {
SKIP: {
eval{ require Acme::Drunk; 1 }
and skip 'Acme::Drunk must not be available.';
eval{ require PAR;
PAR->import( {
repository => 'file:///tmp/repo/',
fallback => 0,
} );
1; }
or skip 'Could not load PAR.';
use_ok( 'Acme::Drunk' );
}
}
$ find /tmp/repo -name \*.par
/tmp/repo/darwin-2level/5.16.0/Acme-Drunk-0.03-darwin-2level-5.16.0.par
$ ls -l Dist.pm*
lrwxr-xr-x 1 root wheel 12 Jul 4 00:20 Dist.pm -> Dist.pm.orig
-r--r--r-- 1 root wheel 43107 Jul 4 00:08 Dist.pm.new
-rw-r--r-- 1 root wheel 43106 Jul 4 00:09 Dist.pm.orig
$ diff Dist.pm.orig Dist.pm.new
1143c1143
< my $version = qr/v?(?:\d+(?:_\d+)?|\d*(?:\.\d+(?:_\d+)?)+)/;
---
my $version = qr/v?(?:\d+(?:_\d+)?|\d*(?:\.\d+(?:_\d+)?)+)$/;
$ perl /tmp/testpar.pl
1..1
not ok 1 - use Acme::Drunk;
# Failed test 'use Acme::Drunk;'
# at /tmp/testpar.pl line 17.
# Tried to use 'Acme::Drunk'.
# Error: Can't locate Acme/Drunk.pm in @INC (@INC contains: CODE(0x10088ff00) /usr/
local/lib/perl5/site_perl/5.16.0/darwin-2level /usr/local/lib/perl5/site_perl/5.16.0 /usr/
local/lib/perl5/5.16.0/darwin-2level /usr/local/lib/perl5/5.16.0 . CODE(0x100890008)) at
(eval 42) line 2.
# BEGIN failed--compilation aborted at (eval 42) line 2.
# Looks like you failed 1 test of 1.
$ sudo ln -sf Dist.pm.new Dist.pm
Password:
$ perl /tmp/testpar.pl
1..1
ok 1 - use Acme::Drunk;
$


The first fix that came to mind is shown above: just add '$' to the version regexp. But maybe
this is too restrictive; I have not tested on other platforms.
Ken Olstad via RT
2012-08-08 15:45:15 UTC
Permalink
Wed Aug 08 11:45:14 2012: Request 78194 was acted upon.
Transaction: Correspondence added by KENO
Queue: PAR
Subject: PAR::Dist::parse_dist_name mis-parses par file name when arch is darwin-2level
Broken in: 0.48
Severity: Important
Owner: Nobody
Requestors: ***@cpan.org
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=78194 >


The fix I suggested above does work but it's not the right fix. The right fix is to change line
1171 from this

if ($e =~ /^$version|any_version$/) {

to this

if ($e =~ /^(?:$version|any_version)$/) {

This is the match that was too loose.
Roderich Schupp via RT
2012-10-12 07:13:16 UTC
Permalink
Fri Oct 12 03:13:16 2012: Request 78194 was acted upon.
Transaction: Correspondence added by RSCHUPP
Queue: PAR-Dist
Subject: PAR::Dist::parse_dist_name mis-parses par file name when arch is darwin-2level
Broken in: (no value)
Severity: Important
Owner: RSCHUPP
Requestors: ***@cpan.org
Status: open
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=78194 >


Applied your patch, will be in the next release. Thanks Ken!

Cheers, Roderich

Loading...