Overview
| Artifact ID: | 8fb0c1404842a16a774ddde2ce96ce7ee3f92a2a |
|---|---|
| Ticket: | 1426692fffffffffffffffffffffffffffffffff
package provide/package ifneeded mismatch errors |
| User & Date: | twylite on 2007-04-18 13:56:34 |
Changes
- icomment:
Logged In: YES user_id=91629 Originator: NO I'm going to add a curve ball into this problem, since it is making my migration to 8.5 very unhappy. I have used (possibly abused) the ability of "package ifneeded" to take only a major number, than then have the sourced script provide the latest version of the package havingthat major number. e.g: package ifneeded myutils 1 [list source [file join $dir myutils1.tcl]] package ifneeded myutils 2 [list source [file join $dir myutils2.tcl]] This allows me to use my version control system to track the minor versions of packages for me, by doing the following: package provide myutils "1.[lindex {$Revision: 1 $} 1]" (That's for Visual SourceSafe; CVS should be similar) The same technique allows you to specify major & minor numbers with ifneeded, and allow the SCM to handle the patchlevel for you. My point: if CompareVersions is used in Tcl_PkgRequireProc in the current manner, it is not possible to let the SCM handle any aspect of version numbering for you; you must do it manually. Which is a pain, IMHO. I consider this ability of the 8.4 ifneeded/require/provide system to be a feature. My suggestion: if the provided version is compatible with the ifneeded version (the ifneeded version is effectively the prefix of the provided version) then the package require should succeed (no warnings or errors). If there is any conflict between the provided and ifneeded versions then raise an error. e.g. package ifneeded myutils 1 [list source [file join $dir myutils2.tcl]] package require myutils --> ERROR (ifneeded 1, provided 2.1) package ifneeded myutils 3 [list source [file join $dir myutils3.tcl]] package require myutils --> 3.4 This would make the version matching logic between ifneeded and provided identical to the requirements satisfied logic for a -exact requirement (if my understanding of the latter is correct). This behaviour is also consistent with "package present". i.e. "package present myutils 1" will happily return "1.2" if that is the actual version of the package that is loaded. Required change to do this: Replace line 520: res = CompareVersions(pvi, vi, NULL); With: Tcl_Obj *ov; ov = ExactRequirement(versionToProvide); res = ! AllRequirementsSatisfied(pvi, 1, &ov); A cleaner version of this change is given in the patch below (against the latest version in CVS): Index: tclPkg.c =================================================================== RCS file: /cvsroot/tcl/tcl/generic/tclPkg.c,v retrieving revision 1.26 diff -u -r1.26 tclPkg.c --- tclPkg.c5 Dec 2006 15:36:12 -00001.26 +++ tclPkg.c18 Apr 2007 06:48:46 -0000 @@ -504,7 +504,6 @@ " provided", NULL); } else { char *pvi, *vi; - int res; if (CheckVersionAndConvert(interp, pkgPtr->version, &pvi, NULL) != TCL_OK) { @@ -514,11 +513,14 @@ ckfree(pvi); code = TCL_ERROR; } else { -res = CompareVersions(pvi, vi, NULL); + Tcl_Obj *ov; + ov = ExactRequirement(versionToProvide); + satisfies = AllRequirementsSatisfied(pvi, 1, &ov); + ckfree(pvi); ckfree(vi); -if (res != 0) { +if (!satisfies) { code = TCL_ERROR; Tcl_AppendResult(interp, "attempt to provide package ", name, " ", - login: "twylite"
- mimetype: "text/plain"
- username: "twylite"