[82291] trunk/base
afb at macports.org
afb at macports.org
Fri Aug 12 02:00:58 PDT 2011
Revision: 82291
http://trac.macports.org/changeset/82291
Author: afb at macports.org
Date: 2011-08-12 02:00:56 -0700 (Fri, 12 Aug 2011)
Log Message:
-----------
rename rpm-vercomp to vercmp (not really rpm compatible)
Modified Paths:
--------------
trunk/base/doc/portfile.7
trunk/base/src/cregistry/vercomp.c
trunk/base/src/macports1.0/macports.tcl
trunk/base/src/pextlib1.0/Makefile
trunk/base/src/pextlib1.0/Pextlib.c
trunk/base/src/pextlib1.0/vercomp.c
trunk/base/src/pextlib1.0/vercomp.h
trunk/base/src/port/port.tcl
trunk/base/src/port1.0/portconfigure.tcl
trunk/base/src/port1.0/portlivecheck.tcl
trunk/base/src/port1.0/portutil.tcl
trunk/base/tests/test/xcodeversion/Portfile
Added Paths:
-----------
trunk/base/src/pextlib1.0/tests/vercomp.tcl
Modified: trunk/base/doc/portfile.7
===================================================================
--- trunk/base/doc/portfile.7 2011-08-12 06:53:04 UTC (rev 82290)
+++ trunk/base/doc/portfile.7 2011-08-12 09:00:56 UTC (rev 82291)
@@ -2119,8 +2119,8 @@
.Xr mkdtemp 3 .
.It Ic md5 Ar
Compute the MD5 hashes of the file(s).
-.It Ic rpm-vercomp Ar versionA Ar versionB
-Compare two RPM-format versions for equality. The return value is like
+.It Ic vercmp Ar versionA Ar versionB
+Compare two EVR-format versions for equality. The return value is like
strcmp(), returning -1, 0, or 1 when versionA is earlier, equal to, or
later than versionB, respectively. Note that some comparisions featuring
floating-point notation may compare incorrectly, e.g. 2.101 is considered
Modified: trunk/base/src/cregistry/vercomp.c
===================================================================
--- trunk/base/src/cregistry/vercomp.c 2011-08-12 06:53:04 UTC (rev 82290)
+++ trunk/base/src/cregistry/vercomp.c 2011-08-12 09:00:56 UTC (rev 82291)
@@ -47,7 +47,7 @@
*/
/**
- * RPM version comparison. Shamelessly copied from Pextlib, with some changes to
+ * EVR version comparison. Shamelessly copied from Pextlib, with some changes to
* use string lengths instead of strlen by default. That's necessary to make it
* work with sqlite3 collations. It should be shared with Pextlib, rather than
* just copied though.
@@ -58,7 +58,7 @@
* @param [in] lengthA length of second version string, or -1 to use strlen
* @return -1 if A < B; 0 if A = B; 1 if A > B
*/
-static int rpm_vercomp (const char *versionA, int lengthA, const char *versionB,
+static int vercmp (const char *versionA, int lengthA, const char *versionB,
int lengthB) {
const char *endA, *endB;
const char *ptrA, *ptrB;
@@ -173,7 +173,7 @@
/**
* VERSION collation for sqlite3. This function collates text according to
- * pextlib's rpm-vercomp function. This allows direct comparison and sorting of
+ * pextlib's vercmp function. This allows direct comparison and sorting of
* version columns, such as port.version and port.revision.
*
* @param [in] userdata unused
@@ -185,5 +185,5 @@
*/
int sql_version(void* userdata UNUSED, int alen, const void* a, int blen,
const void* b) {
- return rpm_vercomp((const char*)a, alen, (const char*)b, blen);
+ return vercmp((const char*)a, alen, (const char*)b, blen);
}
Modified: trunk/base/src/macports1.0/macports.tcl
===================================================================
--- trunk/base/src/macports1.0/macports.tcl 2011-08-12 06:53:04 UTC (rev 82290)
+++ trunk/base/src/macports1.0/macports.tcl 2011-08-12 09:00:56 UTC (rev 82291)
@@ -3003,7 +3003,7 @@
}
# check if we we need to rebuild base
- set comp [rpm-vercomp $macports_version_new $macports::autoconf::macports_version]
+ set comp [vercmp $macports_version_new $macports::autoconf::macports_version]
if {$use_the_force_luke == "yes" || $comp > 0} {
if {[info exists options(ports_dryrun)] && $options(ports_dryrun) == "yes"} {
ui_msg "---> MacPorts base is outdated, selfupdate would install $macports_version_new (dry run)"
@@ -3226,9 +3226,9 @@
set revision [lindex $i 2]
set epoch [lindex $i 5]
if { $version_installed == {} || ($epoch > $epoch_installed && $version != $version_installed) ||
- ($epoch >= $epoch_installed && [rpm-vercomp $version $version_installed] > 0)
+ ($epoch >= $epoch_installed && [vercmp $version $version_installed] > 0)
|| ($epoch >= $epoch_installed
- && [rpm-vercomp $version $version_installed] == 0
+ && [vercmp $version $version_installed] == 0
&& $revision > $revision_installed)} {
set version_installed $version
set revision_installed $revision
@@ -3360,9 +3360,9 @@
set build_override 0
set will_install yes
# check installed version against version in ports
- if { ( [rpm-vercomp $version_installed $version_in_tree] > 0
- || ([rpm-vercomp $version_installed $version_in_tree] == 0
- && [rpm-vercomp $revision_installed $revision_in_tree] >= 0 ))
+ if { ( [vercmp $version_installed $version_in_tree] > 0
+ || ([vercmp $version_installed $version_in_tree] == 0
+ && [vercmp $revision_installed $revision_in_tree] >= 0 ))
&& ![info exists options(ports_upgrade_force)] } {
if {$portname != $newname} {
ui_debug "ignoring versions, installing replacement port"
Modified: trunk/base/src/pextlib1.0/Makefile
===================================================================
--- trunk/base/src/pextlib1.0/Makefile 2011-08-12 06:53:04 UTC (rev 82290)
+++ trunk/base/src/pextlib1.0/Makefile 2011-08-12 09:00:56 UTC (rev 82291)
@@ -22,3 +22,4 @@
${TCLSH} tests/fs-traverse.tcl ./${SHLIB_NAME}
${TCLSH} tests/symlink.tcl ./${SHLIB_NAME}
${TCLSH} tests/unsetenv.tcl ./${SHLIB_NAME}
+ ${TCLSH} tests/vercomp.tcl ./${SHLIB_NAME}
Modified: trunk/base/src/pextlib1.0/Pextlib.c
===================================================================
--- trunk/base/src/pextlib1.0/Pextlib.c 2011-08-12 06:53:04 UTC (rev 82290)
+++ trunk/base/src/pextlib1.0/Pextlib.c 2011-08-12 09:00:56 UTC (rev 82291)
@@ -484,7 +484,11 @@
Tcl_CreateObjCommand(interp, "xinstall", InstallCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "fs-traverse", FsTraverseCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "filemap", FilemapCmd, NULL, NULL);
- Tcl_CreateObjCommand(interp, "rpm-vercomp", RPMVercompCmd, NULL, NULL);
+#if 1
+ /* the name "rpm-vercomp" is deprecated, use "vercmp" instead */
+ Tcl_CreateObjCommand(interp, "rpm-vercomp", VercompCmd, NULL, NULL);
+#endif
+ Tcl_CreateObjCommand(interp, "vercmp", VercompCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "rmd160", RMD160Cmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "sha256", SHA256Cmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "base32encode", Base32EncodeCmd, NULL, NULL);
Added: trunk/base/src/pextlib1.0/tests/vercomp.tcl
===================================================================
--- trunk/base/src/pextlib1.0/tests/vercomp.tcl (rev 0)
+++ trunk/base/src/pextlib1.0/tests/vercomp.tcl 2011-08-12 09:00:56 UTC (rev 82291)
@@ -0,0 +1,47 @@
+# Test file for Pextlib's vercmp command.
+# Syntax:
+# tclsh vercomp.tcl <Pextlib name>
+
+proc main {pextlibname} {
+ load $pextlibname
+
+ # 2.0 > 1.0
+ if {[vercmp 2.0 1.0] <= 0} {
+ puts {[vercmp 2.0 1.0] <= 0}
+ exit 1
+ }
+ # 1.0 = 1.0
+ if {[vercmp 1.0 1.0] != 0} {
+ puts {[vercmp 1.0 1.0] != 0}
+ exit 1
+ }
+ # 1.0 < 2.0
+ if {[vercmp 1.0 2.0] >= 0} {
+ puts {[vercmp 1.0 2.0] >= 0}
+ exit 1
+ }
+
+ # def > abc
+ if {[vercmp def abc] <= 0} {
+ puts {[vercmp def abc] <= 0}
+ exit 1
+ }
+ # abc = abc
+ if {[vercmp abc abc] != 0} {
+ puts {[vercmp abc abc] != 0}
+ exit 1
+ }
+ # abc < def
+ if {[vercmp abc def] >= 0} {
+ puts {[vercmp abc def] >= 0}
+ exit 1
+ }
+
+ # a < 1 (digits beats alpha)
+ if {[vercmp a 1] >= 0} {
+ puts {[vercmp a 1] >= 0}
+ exit 1
+ }
+}
+
+main $argv
Modified: trunk/base/src/pextlib1.0/vercomp.c
===================================================================
--- trunk/base/src/pextlib1.0/vercomp.c 2011-08-12 06:53:04 UTC (rev 82290)
+++ trunk/base/src/pextlib1.0/vercomp.c 2011-08-12 09:00:56 UTC (rev 82291)
@@ -1,7 +1,7 @@
/*
* vercomp.c
* $Id$
- * RPM compatible version comparison
+ * version comparison
*
* Author: Landon Fuller <landonf at macports.org>
*
@@ -48,10 +48,10 @@
/*
* If A is newer than B, return an integer > 0
* If A and B are equal, return 0
- * If B is newer than A, retun an integer < 0
+ * If B is newer than A, return an integer < 0
*/
-static int rpm_vercomp (const char *versionA, const char *versionB) {
+static int vercmp (const char *versionA, const char *versionB) {
const char *ptrA, *ptrB;
const char *eptrA, *eptrB;
@@ -155,7 +155,7 @@
return -1;
}
-int RPMVercompCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
+int VercompCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *tcl_result;
const char *versionA, *versionB;
@@ -169,7 +169,7 @@
versionA = Tcl_GetString(objv[1]);
versionB = Tcl_GetString(objv[2]);
- rval = rpm_vercomp(versionA, versionB);
+ rval = vercmp(versionA, versionB);
tcl_result = Tcl_NewIntObj(rval);
Tcl_SetObjResult(interp, tcl_result);
Modified: trunk/base/src/pextlib1.0/vercomp.h
===================================================================
--- trunk/base/src/pextlib1.0/vercomp.h 2011-08-12 06:53:04 UTC (rev 82290)
+++ trunk/base/src/pextlib1.0/vercomp.h 2011-08-12 09:00:56 UTC (rev 82291)
@@ -32,4 +32,4 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-int RPMVercompCmd(ClientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]);
+int VercompCmd(ClientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]);
Modified: trunk/base/src/port/port.tcl
===================================================================
--- trunk/base/src/port/port.tcl 2011-08-12 06:53:04 UTC (rev 82290)
+++ trunk/base/src/port/port.tcl 2011-08-12 09:00:56 UTC (rev 82291)
@@ -482,9 +482,9 @@
}
set avr_ [split $a_(version) "_"]
set bvr_ [split $b_(version) "_"]
- set vercmp [rpm-vercomp [lindex $avr_ 0] [lindex $bvr_ 0]]
- if {$vercmp != 0} {
- return $vercmp
+ set versioncmp [vercmp [lindex $avr_ 0] [lindex $bvr_ 0]]
+ if {$versioncmp != 0} {
+ return $versioncmp
}
set ar_ [lindex $avr_ 1]
set br_ [lindex $bvr_ 1]
@@ -855,7 +855,7 @@
if {$installed_version != $latest_version} {
set comp_result [expr $installed_epoch - $latest_epoch]
if { $comp_result == 0 } {
- set comp_result [rpm-vercomp $installed_version $latest_version]
+ set comp_result [vercmp $installed_version $latest_version]
}
}
if { $comp_result == 0 } {
@@ -3079,7 +3079,7 @@
# Compare versions, first checking epoch, then version, then revision
set epoch_comp_result [expr $installed_epoch - $latest_epoch]
- set comp_result [rpm-vercomp $installed_version $latest_version]
+ set comp_result [vercmp $installed_version $latest_version]
if { $comp_result == 0 } {
set comp_result [expr $installed_revision - $latest_revision]
}
Modified: trunk/base/src/port1.0/portconfigure.tcl
===================================================================
--- trunk/base/src/port1.0/portconfigure.tcl 2011-08-12 06:53:04 UTC (rev 82290)
+++ trunk/base/src/port1.0/portconfigure.tcl 2011-08-12 09:00:56 UTC (rev 82291)
@@ -356,11 +356,11 @@
global xcodeversion macosx_deployment_target
if {$xcodeversion == "none" || $xcodeversion == ""} {
return cc
- } elseif {[rpm-vercomp $xcodeversion 4.2] >= 0} {
+ } elseif {[vercmp $xcodeversion 4.2] >= 0} {
return clang
- } elseif {[rpm-vercomp $xcodeversion 4.0] >= 0} {
+ } elseif {[vercmp $xcodeversion 4.0] >= 0} {
return llvm-gcc-4.2
- } elseif {[rpm-vercomp $xcodeversion 3.2] >= 0 && $macosx_deployment_target != "10.4"} {
+ } elseif {[vercmp $xcodeversion 3.2] >= 0 && $macosx_deployment_target != "10.4"} {
return gcc-4.2
} else {
return gcc-4.0
Modified: trunk/base/src/port1.0/portlivecheck.tcl
===================================================================
--- trunk/base/src/port1.0/portlivecheck.tcl 2011-08-12 06:53:04 UTC (rev 82290)
+++ trunk/base/src/port1.0/portlivecheck.tcl 2011-08-12 09:00:56 UTC (rev 82291)
@@ -175,7 +175,7 @@
while {[gets $chan line] >= 0} {
if {[regexp $the_re $line matched upver]} {
set foundmatch 1
- if {$updated_version == 0 || [rpm-vercomp $upver $updated_version] > 0} {
+ if {$updated_version == 0 || [vercmp $upver $updated_version] > 0} {
set updated_version $upver
}
ui_debug "The regex matched \"$matched\", extracted \"$upver\""
Modified: trunk/base/src/port1.0/portutil.tcl
===================================================================
--- trunk/base/src/port1.0/portutil.tcl 2011-08-12 06:53:04 UTC (rev 82290)
+++ trunk/base/src/port1.0/portutil.tcl 2011-08-12 09:00:56 UTC (rev 82291)
@@ -2722,10 +2722,10 @@
}
if {$xcodeversion == "none"} {
ui_warn "Xcode does not appear to be installed; most ports will likely fail to build."
- } elseif {[rpm-vercomp $xcodeversion $min] < 0} {
+ } elseif {[vercmp $xcodeversion $min] < 0} {
ui_error "The installed version of Xcode (${xcodeversion}) is too old to use on the installed OS version. Version $rec or later is recommended on Mac OS X ${macosx_version}."
return 1
- } elseif {[rpm-vercomp $xcodeversion $ok] < 0} {
+ } elseif {[vercmp $xcodeversion $ok] < 0} {
ui_warn "The installed version of Xcode (${xcodeversion}) is known to cause problems. Version $rec or later is recommended on Mac OS X ${macosx_version}."
}
}
Modified: trunk/base/tests/test/xcodeversion/Portfile
===================================================================
--- trunk/base/tests/test/xcodeversion/Portfile 2011-08-12 06:53:04 UTC (rev 82290)
+++ trunk/base/tests/test/xcodeversion/Portfile 2011-08-12 09:00:56 UTC (rev 82291)
@@ -19,6 +19,8 @@
}
test {
+ # rpm-vercomp is now deprecated, change it here too when removed
+ # from all ports and base (but keep this test here, meanwhile...)
if {$xcodeversion != "" && [rpm-vercomp $xcodeversion 2.1] >= 0} {
ui_msg "xcodeversion >= 2.1"
} else {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20110812/80f32aa7/attachment-0001.html>
More information about the macports-changes
mailing list