Skip to content

Commit

Permalink
Add vercmp as a port action that compares two versions
Browse files Browse the repository at this point in the history
Expose pextlib's vercmp as a port action to allow users to determine
how macports calculates versions.

closes: https://trac.macports.org/ticket/61050
  • Loading branch information
kurthindenburg committed Mar 22, 2021
1 parent ee1ff66 commit eea6284
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/port/port.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -4230,6 +4230,26 @@ proc action_mirror { action portlist opts } {
action_target $action $portlist $opts
}

proc action_vercmp { action portlist opts } {
if {[llength $portlist] != 2} {
ui_error "Usage: port vercmp versionA versionB"
return 1
}
set versionA [lindex $portlist 0]
set versionB [lindex $portlist 1]
set result [vercmp $versionA $versionB]
ui_msg -nonewline "MacPorts considers $versionA to be "
if {$result < 0} {
ui_msg -nonewline "less than"
} elseif {$result == 0} {
ui_msg -nonewline "equal to"
} else {
ui_msg -nonewline "greater than"
}
ui_msg " $versionB"
return 0
}

proc action_exit { action portlist opts } {
# Return a semaphore telling the main loop to quit
return -999
Expand Down Expand Up @@ -4368,6 +4388,8 @@ array set action_array [list \
mpkg [list action_target [ACTION_ARGS_PORTS]] \
pkg [list action_target [ACTION_ARGS_PORTS]] \
\
vercmp [list action_vercmp [ACTION_ARGS_STRINGS]] \
\
quit [list action_exit [ACTION_ARGS_NONE]] \
exit [list action_exit [ACTION_ARGS_NONE]] \
]
Expand Down

0 comments on commit eea6284

Please sign in to comment.