Opened 17 years ago

Closed 13 years ago

Last modified 10 years ago

#11873 closed defect (fixed)

Need alternate floating point version comparison function for perl5 portgroup ports

Reported by: vinc17@… Owned by: ghosthound
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: ghosthound, kballard (Lily Ballard), boeyms@…, ryandesign (Ryan Carsten Schmidt), MarcusCalhoun-Lopez (Marcus Calhoun-Lopez), raimue (Rainer Müller), cooljeanius (Eric Gallager)
Port:

Description

"port outdated" doesn't list p5-xml-libxml, though the latest version isn't installed:

prunille:~> port outdated
The following installed ports are outdated:
goffice                        0.3.5_0 < 0.3.8_0         
pango                          1.16.2_0 < 1.16.4_0       
sqlite3                        3.3.16_0 < 3.3.17_0       
wormux                         0.8alpha1_0 < 0.7.9_0
prunille:~> port installed p5-xml-libxml
The following ports are currently installed:
  p5-xml-libxml @1.62001_0 (active)
prunille:~> port list p5-xml-libxml
p5-xml-libxml                  @1.63           perl/p5-xml-libxml
p5-xml-libxml                  @1.62001        perl/p5-xml-libxml
prunille:~> port info p5-xml-libxml
Warning: Found 2 port p5-xml-libxml definitions, displaying first one.
p5-xml-libxml 1.63, perl/p5-xml-libxml (Variants: universal)
http://search.cpan.org/~msergeant/XML-LibXML-1.63/
[...]

and the primary PortIndex file says that the version is 1.63.

I wonder if "port outdated" doesn't list p5-xml-libxml because 62001 > 63. Instead, the comparison should be done on floating-point numbers 1.63 and 1.62001 (AFAIK, this is the rule for Perl).

Attachments (1)

perl5-versions.diff (1.2 KB) - added by jmroot (Joshua Root) 14 years ago.

Download all attachments as: .zip

Change History (24)

comment:1 Changed 17 years ago by kballard (Lily Ballard)

Cc: eridius@… added

You sure it's not because you have 2 entries for p5-xml-libxml?

Which begs the question... why do you have 2 entries for p5-xml-libxml? There's only 1 in the dports tree.

comment:2 Changed 17 years ago by vinc17@…

I have 2 entries (one from the SVN working copy and one from rsync[*]), but as shown by "port list", version 1.63 has the precedence.

[*] My /opt/local/etc/ports/sources.conf file contains:

file:///Users/vinc17/wd/macosx/dports
file:///Users/vinc17/software/dports
rsync://rsync.macports.org/dpupdate/dports

comment:3 Changed 17 years ago by vinc17@…

"port -v outdated" says:

p5-xml-libxml                  1.62001_0 > 1.63_0       !

comment:4 Changed 17 years ago by kballard (Lily Ballard)

You're right. Our version comparison function is seeing 62001 > 63. The easiest fix is to throw an epoch value on the Portfile, which is basically a timestamp. I don't see any way to teach the version comparison function to do this one "right" without breaking other comparisons like 1.10_0 > 1.9_0.

comment:5 Changed 17 years ago by boeyms@…

Cc: boeyms@… added

There's a function currently in glibc called strverscmp() that would get this right. I've been working on a make-alike implementation that can be released on less restrictive terms than the GPL (I'm not terribly fussed about exactly what terms) in order to patch a port that requires it, and I'd be willing to add it to Pextlib or wherever it would be most appropriate. I'm fairly confident that my current implementation works as it should, but I haven't written a test suite for it yet, and I've been trying to think about how to make it more elegant and efficient.

comment:6 Changed 17 years ago by boeyms@…

I take back my previous comment; in the case we have here, both strverscmp and the current rpm-vercomp function report 1.62001 as larger than 1.63 because they take the meaning of the dot (in this case) to be a integer separator rather than a decimal point. I don't believe that we could create a function that automatically detects this; MacPorts will only ever compare two version strings (the installed one and the latest one), and with that limited context there seems to be no way that one could tell whether, say, 2.11 versus 2.2 is supposed to be compared with the dot as a decimal point or as an integer separator.

I think that the only way to fix this would be to introduce another field into Portfiles (e.g. "version_comparison_method") to indicate which of these should be the case, and to add functionality for the decimal comparison case (which hopefully should not be too difficult).

comment:7 Changed 17 years ago by vinc17@…

For Perl modules, the dot is always a decimal point, as said in the perlmodlib(1) man page: "This should be a floating point number with at least two digits after the decimal". So, the perl5 portgroup should be designed so that version comparisons work as expected for Perl modules, without having to add something to portfiles.

comment:8 Changed 17 years ago by kballard (Lily Ballard)

Nice idea, but there are a couple of ports that use the Perl5 group and don't follow this version format. For example net/smokeping, or perl/p5-astro-fits-header. But maybe we can work around these aberrant ports.

comment:9 Changed 17 years ago by kballard (Lily Ballard)

Owner: changed from macports-dev@… to eridius@…
Status: newassigned

comment:10 Changed 17 years ago by vinc17@…

The best solution would be to fix these ports. Otherwise the version comparison rule for the Perl5 group could be: if there is a single period, then use the comparison of floating-point numbers as described by the perlmodlib(1) man page; otherwise the usual MacPorts comparison should be used.

comment:11 Changed 17 years ago by jmpp@…

Milestone: MacPorts 1.4Needs developer review

Setting to "needs dev review" as no decision has been reached yet and I'll be closing the 1.4 milestone soon enough now.

-jmpp

comment:12 Changed 17 years ago by kballard (Lily Ballard)

Yeah I've been meaning to fix this but haven't had much time to work on MacPorts lately.

comment:13 Changed 17 years ago by jmpp@…

Milestone: Needs developer reviewMacPorts base bugs

Milestone Needs developer review deleted

comment:14 Changed 17 years ago by nox@…

Priority: ExpectedNormal
Summary: "port outdated" doesn't list p5-xml-libxml (bad version comparison?)BUG: "port outdated" doesn't list p5-xml-libxml (bad version comparison?)
Version: 1.4.3

comment:15 Changed 16 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: ryandesign@… added
Summary: BUG: "port outdated" doesn't list p5-xml-libxml (bad version comparison?)Need alternate floating point version comparison function for perl5 portgroup ports

comment:16 Changed 15 years ago by tobypeterson

Milestone: MacPorts base bugsMacPorts Future

Milestone MacPorts base bugs deleted

comment:17 Changed 15 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)

Cc: mcalhoun@… added

Cc Me!

comment:18 Changed 14 years ago by jmroot (Joshua Root)

Cc: vinc17@… removed
Milestone: MacPorts FutureMacPorts 1.9.0
Owner: changed from eridius@… to macports-tickets@…
Status: assignednew

comment:19 Changed 14 years ago by raimue (Rainer Müller)

Cc: raimue@… added

Instead of inventing a different comparison function, we should just convert the version number to something compatible. The rpm-based Linux distribution Mandriva does this as of 2009. As we are using the same rpm version comparison algorithm, this would be compatible. They are using a macro %perl_convert_version which would be equivalent to:

$ perl -Mversion -le '$v=version->new(1.337)->normal; $v=~s/^v//; print $v'

For more information refer to perldoc version.

I propose that perl5.setup in the perl5 PortGroup should convert the version and set the version option converted. Additionally there could be a perl5.module_version variable local to the Portfile for use at other places in the Portfile (perl5.version is already in use).

perl5.setup Foo-Bar 1.337
# => name p5-foo-bar
# => version 1.337.0
# => perl5.module_version 1.337
perl5.setup Foo-Bar 1.4
# => name p5-foo-bar
# => version 1.400.0
# => perl5.module_version 1.4

There needs to be a decision if we want to call out to the perl binary for this conversion or if we should implement the same in Tcl or C.

comment:20 Changed 14 years ago by jmroot (Joshua Root)

Cc: ricci@… added
Component: baseports
Milestone: MacPorts 1.9.0

Attached patch implements the version conversion in the perl5 portgroup.

Changed 14 years ago by jmroot (Joshua Root)

Attachment: perl5-versions.diff added

comment:21 Changed 13 years ago by ghosthound

Owner: changed from macports-tickets@… to ricci@…

comment:22 Changed 13 years ago by jmroot (Joshua Root)

Resolution: fixed
Status: newclosed

comment:23 Changed 10 years ago by cooljeanius (Eric Gallager)

Cc: egall@… added

Cc Me!

Note: See TracTickets for help on using tickets.