Opened 9 months ago

Last modified 3 months ago

#61050 new enhancement

Add `port vercmp` command

Reported by: ryandesign (Ryan Schmidt) Owned by:
Priority: Normal Milestone:
Component: base Version: 2.6.99
Keywords: Cc: kurthindenburg (Kurt Hindenburg)
Port:

Description

Portfile authors need to know in which situations they need to increase a port's epoch. To do that, they need to be able to run the MacPorts vercmp procedure and see what it prints for the port's old version and the new one, but MacPorts doesn't expose a way to do that. I have a script I often use to do this:

https://github.com/ryandesign/macports-user-ryandesign/blob/master/scripts/vercmp

I propose that we should add a port vercmp command to integrate this functionality. Proposed usage example:

$ port vercmp 1.0-rc1 1.0
MacPorts considers 1.0-rc1 to be greater than 1.0.

Change History (4)

comment:1 Changed 9 months ago by ryandesign (Ryan Schmidt)

Or if it is too difficult or weird for the port command to process its arguments in a way that is not names of ports, then we could ship a port-vercmp script.

comment:2 Changed 3 months ago by kurthindenburg (Kurt Hindenburg)

Cc: kurthindenburg added

comment:3 Changed 3 months ago by jmroot (Joshua Root)

I think this definitely falls under the category of developer tools, and isn't really appropriate as a port command. Exposing internal helper functions as actions isn't a road I think we should go down (what's next, port shellescape and port percentescape?)

The contrib script version takes about 30 seconds to write:

#!/usr/bin/env port-tclsh

package require Pextlib

set ver1 [lindex $argv 0]
set ver2 [lindex $argv 1]
set result [vercmp $ver1 $ver2]
puts "vercmp $ver1 $ver2 = $result"
if {$result > 0} {
    set relation "greater than"
} elseif {$result < 0} {
    set relation "less than"
} else {
    set relation "equal to"
}
puts "$ver1 is considered to be $relation $ver2"

And TBH it isn't hard to write puts [vercmp 1.10 1.2] in a Porfile and run port info.

comment:4 Changed 3 months ago by kurthindenburg (Kurt Hindenburg)

IMHO the real benefit is that we could add a section to the guide for epoch saying if 'port vercmp old new' is less then you need to add epoch 1 to the portfile.

Note: See TracTickets for help on using tickets.