[79167] trunk/base
jmr at macports.org
jmr at macports.org
Fri Jun 3 22:00:16 PDT 2011
Revision: 79167
http://trac.macports.org/changeset/79167
Author: jmr at macports.org
Date: 2011-06-03 22:00:16 -0700 (Fri, 03 Jun 2011)
Log Message:
-----------
avoid using composite version specs for registry operations (#28084)
Modified Paths:
--------------
trunk/base/portmgr/packaging/dpkgall.tcl
trunk/base/src/macports1.0/macports.tcl
trunk/base/src/port/port.tcl
trunk/base/src/port1.0/portactivate.tcl
trunk/base/src/port1.0/portdeactivate.tcl
trunk/base/src/port1.0/portuninstall.tcl
trunk/base/src/registry2.0/portimage.tcl
trunk/base/src/registry2.0/portuninstall.tcl
trunk/base/src/registry2.0/receipt_sqlite.tcl
Modified: trunk/base/portmgr/packaging/dpkgall.tcl
===================================================================
--- trunk/base/portmgr/packaging/dpkgall.tcl 2011-06-04 04:59:15 UTC (rev 79166)
+++ trunk/base/portmgr/packaging/dpkgall.tcl 2011-06-04 05:00:16 UTC (rev 79167)
@@ -708,7 +708,7 @@
set port [lindex $portlist 0]
ui_msg "Uninstalling $port."
- if { [catch {registry_uninstall::uninstall $portname $portversion} result] } {
+ if { [catch {registry_uninstall::uninstall $portname $portversion "" 0 [array get options]} result] } {
global errorInfo
ui_debug "$errorInfo"
ui_noisy_errorr "Fatal error: Uninstalling $port failed: $result"
Modified: trunk/base/src/macports1.0/macports.tcl
===================================================================
--- trunk/base/src/macports1.0/macports.tcl 2011-06-04 04:59:15 UTC (rev 79166)
+++ trunk/base/src/macports1.0/macports.tcl 2011-06-04 05:00:16 UTC (rev 79167)
@@ -3437,7 +3437,7 @@
if {$is_dryrun eq "yes"} {
ui_msg "Skipping uninstall $newname @${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) (dry run)"
} elseif {![registry::run_target $newregref uninstall [array get options]]
- && [catch {registry_uninstall::uninstall $newname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) [array get options]} result]} {
+ && [catch {registry_uninstall::uninstall $newname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants) [array get options]} result]} {
global errorInfo
ui_debug "$errorInfo"
ui_error "Uninstall $newname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) failed: $result"
@@ -3461,7 +3461,7 @@
ui_msg "Skipping deactivate $portname @${version_active}_${revision_active}${variant_active} (dry run)"
} elseif {![catch {registry::active $portname}] &&
![registry::run_target $regref deactivate [array get options]]
- && [catch {portimage::deactivate $portname ${version_active}_${revision_active}${variant_active} [array get options]} result]} {
+ && [catch {portimage::deactivate $portname $version_active $revision_active $variant_active [array get options]} result]} {
global errorInfo
ui_debug "$errorInfo"
ui_error "Deactivating $portname @${version_active}_${revision_active}${variant_active} failed: $result"
@@ -3537,7 +3537,7 @@
if {$is_dryrun eq "yes"} {
ui_msg "Skipping uninstall $portname @${version}_${revision}${variant} (dry run)"
} elseif {![registry::run_target $regref uninstall $optionslist]
- && [catch {registry_uninstall::uninstall $portname ${version}_${revision}${variant} $optionslist} result]} {
+ && [catch {registry_uninstall::uninstall $portname $version $revision $variant $optionslist} result]} {
global errorInfo
ui_debug "$errorInfo"
# replaced_by can mean that we try to uninstall all versions of the old port, so handle errors due to dependents
Modified: trunk/base/src/port/port.tcl
===================================================================
--- trunk/base/src/port/port.tcl 2011-06-04 04:59:15 UTC (rev 79166)
+++ trunk/base/src/port/port.tcl 2011-06-04 05:00:16 UTC (rev 79167)
@@ -2234,7 +2234,7 @@
}
}
if {![macports::global_option_isset ports_dryrun]} {
- if { [catch {portimage::activate $portname $composite_version [array get options]} result] } {
+ if { [catch {portimage::activate_composite $portname $composite_version [array get options]} result] } {
global errorInfo
ui_debug "$errorInfo"
break_softcontinue "port activate failed: $result" 1 status
@@ -2270,7 +2270,7 @@
}
}
if {![macports::global_option_isset ports_dryrun]} {
- if { [catch {portimage::deactivate $portname $composite_version [array get options]} result] } {
+ if { [catch {portimage::deactivate_composite $portname $composite_version [array get options]} result] } {
global errorInfo
ui_debug "$errorInfo"
break_softcontinue "port deactivate failed: $result" 1 status
@@ -2834,7 +2834,7 @@
}
}
- if { [catch {registry_uninstall::uninstall $portname $composite_version [array get options]} result] } {
+ if { [catch {registry_uninstall::uninstall_composite $portname $composite_version [array get options]} result] } {
global errorInfo
ui_debug "$errorInfo"
break_softcontinue "port uninstall failed: $result" 1 status
Modified: trunk/base/src/port1.0/portactivate.tcl
===================================================================
--- trunk/base/src/port1.0/portactivate.tcl 2011-06-04 04:59:15 UTC (rev 79166)
+++ trunk/base/src/port1.0/portactivate.tcl 2011-06-04 05:00:16 UTC (rev 79167)
@@ -60,7 +60,7 @@
proc portactivate::activate_main {args} {
global env subport version revision portvariants user_options PortInfo
- registry_activate $subport "${version}_${revision}${portvariants}" [array get user_options]
+ registry_activate $subport $version $revision $portvariants [array get user_options]
# Display notes at the end of the activation phase.
if {[info exists PortInfo(notes)] && $PortInfo(notes) ne {}} {
Modified: trunk/base/src/port1.0/portdeactivate.tcl
===================================================================
--- trunk/base/src/port1.0/portdeactivate.tcl 2011-06-04 04:59:15 UTC (rev 79166)
+++ trunk/base/src/port1.0/portdeactivate.tcl 2011-06-04 05:00:16 UTC (rev 79167)
@@ -58,6 +58,6 @@
proc portdeactivate::deactivate_main {args} {
global subport version revision portvariants user_options
- registry_deactivate $subport "${version}_${revision}${portvariants}" [array get user_options]
+ registry_deactivate $subport $version $revision $portvariants [array get user_options]
return 0
}
Modified: trunk/base/src/port1.0/portuninstall.tcl
===================================================================
--- trunk/base/src/port1.0/portuninstall.tcl 2011-06-04 04:59:15 UTC (rev 79166)
+++ trunk/base/src/port1.0/portuninstall.tcl 2011-06-04 05:00:16 UTC (rev 79167)
@@ -58,6 +58,6 @@
proc portuninstall::uninstall_main {args} {
global subport version revision portvariants user_options
- registry_uninstall $subport "${version}_${revision}${portvariants}" [array get user_options]
+ registry_uninstall $subport $version $revision $portvariants [array get user_options]
return 0
}
Modified: trunk/base/src/registry2.0/portimage.tcl
===================================================================
--- trunk/base/src/registry2.0/portimage.tcl 2011-06-04 04:59:15 UTC (rev 79166)
+++ trunk/base/src/registry2.0/portimage.tcl 2011-06-04 05:00:16 UTC (rev 79167)
@@ -63,8 +63,18 @@
variable force 0
variable noexec 0
+# takes a composite version spec rather than separate version,revision,variants
+proc activate_composite {name {v ""} {optionslist ""}} {
+ if {$v == ""} {
+ return [activate $name "" "" 0 $optionslist]
+ } elseif {[registry::decode_spec $v version revision variants]} {
+ return [activate $name $version $revision $variants $optionslist]
+ }
+ throw registry::invalid "Registry error: Invalid version '$v' specified for ${name}. Please specify a version as recorded in the port registry."
+}
+
# Activate a "Port Image"
-proc activate {name v optionslist} {
+proc activate {name {version ""} {revision ""} {variants 0} {optionslist ""}} {
global macports::prefix macports::registry.path registry_open UI_PREFIX
array set options $optionslist
variable force
@@ -84,7 +94,7 @@
registry::read {
- set requested [_check_registry $name $v]
+ set requested [_check_registry $name $version $revision $variants]
# set name again since the one we were passed may not have had the correct case
set name [$requested name]
set version [$requested version]
@@ -103,32 +113,38 @@
# this shouldn't be possible
if { ![string equal [$requested installtype] "image"] } {
- return -code error "Image error: ${name} @${version}_${revision}${variants} not installed as an image."
+ return -code error "Image error: ${name} @${specifier} not installed as an image."
}
if {![file isfile $location]} {
return -code error "Image error: Can't find image file $location"
}
if { [string equal [$requested state] "installed"] } {
- return -code error "Image error: ${name} @${version}_${revision}${variants} is already active."
+ return -code error "Image error: ${name} @${specifier} is already active."
}
}
foreach a $todeactivate {
if {$noexec || ![registry::run_target $a deactivate [list ports_nodepcheck 1]]} {
- deactivate $name "[$a version]_[$a revision][$a variants]" [list ports_nodepcheck 1]
+ deactivate $name [$a version] [$a revision] [$a variants] [list ports_nodepcheck 1]
}
}
- if {$v != ""} {
- ui_msg "$UI_PREFIX [format [msgcat::mc "Activating %s @%s"] $name $v]"
- } else {
- ui_msg "$UI_PREFIX [format [msgcat::mc "Activating %s"] $name]"
- }
+ ui_msg "$UI_PREFIX [format [msgcat::mc "Activating %s @%s"] $name $specifier]"
_activate_contents $requested
$requested state installed
}
-proc deactivate {name v optionslist} {
+# takes a composite version spec rather than separate version,revision,variants
+proc deactivate_composite {name {v ""} {optionslist ""}} {
+ if {$v == ""} {
+ return [deactivate $name "" "" 0 $optionslist]
+ } elseif {[registry::decode_spec $v version revision variants]} {
+ return [deactivate $name $version $revision $variants $optionslist]
+ }
+ throw registry::invalid "Registry error: Invalid version '$v' specified for ${name}. Please specify a version as recorded in the port registry."
+}
+
+proc deactivate {name {version ""} {revision ""} {variants 0} {optionslist ""}} {
global UI_PREFIX macports::registry.path registry_open
array set options $optionslist
@@ -156,20 +172,18 @@
}
# set name again since the one we were passed may not have had the correct case
set name [$requested name]
- set version [$requested version]
- set revision [$requested revision]
- set variants [$requested variants]
- set specifier "${version}_${revision}${variants}"
+ set specifier "[$requested version]_[$requested revision][$requested variants]"
- if { $v != "" && ![string equal $specifier $v] } {
+ if {$version != "" && ($version != [$requested version] ||
+ ($revision != "" && ($revision != [$requested revision] || $variants != [$requested variants])))} {
+ set v $version
+ if {$revision != ""} {
+ append v _${revision}${variants}
+ }
return -code error "Active version of $name is not $v but ${specifier}."
}
- if {$v != ""} {
- ui_msg "$UI_PREFIX [format [msgcat::mc "Deactivating %s @%s"] $name $v]"
- } else {
- ui_msg "$UI_PREFIX [format [msgcat::mc "Deactivating %s"] $name]"
- }
+ ui_msg "$UI_PREFIX [format [msgcat::mc "Deactivating %s @%s"] $name $specifier]"
if { ![string equal [$requested installtype] "image"] } {
return -code error "Image error: ${name} @${specifier} not installed as an image."
@@ -187,18 +201,24 @@
$requested state imaged
}
-proc _check_registry {name v} {
+proc _check_registry {name version revision variants} {
global UI_PREFIX
- if { [registry::decode_spec $v version revision variants] } {
- set ilist [registry::entry imaged $name $version $revision $variants]
- set valid 1
- } else {
- set valid [string equal $v {}]
- set ilist [registry::entry imaged $name]
+ set searchkeys $name
+ set composite_spec ""
+ if {$version != ""} {
+ lappend searchkeys $version
+ set composite_spec $version
+ # restriction imposed by underlying registry API (see entry.c):
+ # if a revision is specified, so must variants be
+ if {$revision != ""} {
+ lappend searchkeys $revision $variants
+ append composite_spec _${revision}${variants}
+ }
}
+ set ilist [eval registry::entry imaged $searchkeys]
- if { [llength $ilist] > 1 || (!$valid && [llength $ilist] == 1) } {
+ if { [llength $ilist] > 1 } {
ui_msg "$UI_PREFIX [msgcat::mc "The following versions of $name are currently installed:"]"
foreach i $ilist {
set iname [$i name]
@@ -211,15 +231,14 @@
ui_msg "$UI_PREFIX [format [msgcat::mc " %s @%s_%s%s"] $iname $iversion $irevision $ivariants]"
}
}
- if { $valid } {
- throw registry::invalid "Registry error: Please specify the full version as recorded in the port registry."
- } else {
- throw registry::invalid "Registry error: Invalid version specified. Please specify a version as recorded in the port registry."
- }
+ throw registry::invalid "Registry error: Please specify the full version as recorded in the port registry."
} elseif { [llength $ilist] == 1 } {
return [lindex $ilist 0]
}
- throw registry::invalid "Registry error: No port of $name installed."
+ if {$composite_spec != ""} {
+ set composite_spec " @${composite_spec}"
+ }
+ throw registry::invalid "Registry error: ${name}${composite_spec} is not installed."
}
## Activates a file from an image into the filesystem. Deals with symlinks,
@@ -487,7 +506,7 @@
# deactivate ports replaced_by this one
foreach owner [array names todeactivate] {
if {$noexec || ![registry::run_target $owner deactivate [list ports_nodepcheck 1]]} {
- deactivate [$owner name] "" [list ports_nodepcheck 1]
+ deactivate [$owner name] "" "" 0 [list ports_nodepcheck 1]
}
}
@@ -529,8 +548,7 @@
# reactivate deactivated ports
foreach entry [array names todeactivate] {
if {[$entry state] == "imaged" && ($noexec || ![registry::run_target $entry activate ""])} {
- set pvers "[$entry version]_[$entry revision][$entry variants]"
- activate [$entry name] $pvers [list ports_activate_no-exec $noexec]
+ activate [$entry name] [$entry version] [$entry revision] [$entry variants] [list ports_activate_no-exec $noexec]
}
}
# remove temp image dir
Modified: trunk/base/src/registry2.0/portuninstall.tcl
===================================================================
--- trunk/base/src/registry2.0/portuninstall.tcl 2011-06-04 04:59:15 UTC (rev 79166)
+++ trunk/base/src/registry2.0/portuninstall.tcl 2011-06-04 05:00:16 UTC (rev 79167)
@@ -40,7 +40,17 @@
namespace eval registry_uninstall {
-proc uninstall {portname {v ""} optionslist} {
+# takes a composite version spec rather than separate version,revision,variants
+proc uninstall_composite {portname {v ""} {optionslist ""}} {
+ if {$v == ""} {
+ return [uninstall $portname "" "" 0 $optionslist]
+ } elseif {[registry::decode_spec $v version revision variants]} {
+ return [uninstall $portname $version $revision $variants $optionslist]
+ }
+ throw registry::invalid "Registry error: Invalid version '$v' specified for ${portname}. Please specify a version as recorded in the port registry."
+}
+
+proc uninstall {portname {version ""} {revision ""} {variants 0} {optionslist ""}} {
global uninstall.force uninstall.nochecksum UI_PREFIX \
macports::portimagefilepath
array set options $optionslist
@@ -57,13 +67,19 @@
set options(ports_deactivate_no-exec) $options(ports_uninstall_no-exec)
}
- if { [registry::decode_spec $v version revision variants] } {
- set ilist [registry::entry imaged $portname $version $revision $variants]
- set valid 1
- } else {
- set valid [string equal $v {}]
- set ilist [registry::entry imaged $portname]
+ set searchkeys $portname
+ set composite_spec ""
+ if {$version != ""} {
+ lappend searchkeys $version
+ set composite_spec $version
+ # restriction imposed by underlying registry API (see entry.c):
+ # if a revision is specified, so must variants be
+ if {$revision != ""} {
+ lappend searchkeys $revision $variants
+ append composite_spec _${revision}${variants}
+ }
}
+ set ilist [eval registry::entry imaged $searchkeys]
if { [llength $ilist] > 1 } {
# set portname again since the one we were passed may not have had the correct case
set portname [[lindex $ilist 0] name]
@@ -76,21 +92,18 @@
ui_msg "$UI_PREFIX [format [msgcat::mc " %s @%s"] [$i name] $ispec]"
}
}
- if { $valid } {
- throw registry::invalid "Registry error: Please specify the full version as recorded in the port registry."
- } else {
- throw registry::invalid "Registry error: Invalid version specified. Please specify a version as recorded in the port registry."
- }
+ throw registry::invalid "Registry error: Please specify the full version as recorded in the port registry."
} elseif { [llength $ilist] == 1 } {
set port [lindex $ilist 0]
set version [$port version]
set revision [$port revision]
set variants [$port variants]
- if {$v == ""} {
- set v "${version}_${revision}${variants}"
+ set composite_spec "${version}_${revision}${variants}"
+ } else {
+ if {$composite_spec != ""} {
+ set composite_spec " @${composite_spec}"
}
- } else {
- throw registry::invalid "Registry error: $portname not registered as installed"
+ throw registry::invalid "Registry error: ${portname}${composite_spec} not registered as installed"
}
# uninstall dependents if requested
@@ -99,9 +112,7 @@
# make sure it's still installed, since a previous dep uninstall may have removed it
if {[registry::entry exists $depport] && ([$depport state] == "imaged" || [$depport state] == "installed")} {
if {[info exists options(ports_uninstall_no-exec)] || ![registry::run_target $depport uninstall $optionslist]} {
- set depname [$depport name]
- set depver "[$depport version]_[$depport revision][$depport variants]"
- registry_uninstall::uninstall $depname $depver $optionslist
+ registry_uninstall::uninstall [$depport name] [$depport version] [$depport revision] [$depport variants] $optionslist
}
}
}
@@ -112,10 +123,10 @@
# if it's active, deactivate it
if { [string equal [$port state] installed] } {
if {[info exists options(ports_dryrun)] && [string is true -strict $options(ports_dryrun)]} {
- ui_msg "For $portname @${v}: skipping deactivate (dry run)"
+ ui_msg "For $portname @${composite_spec}: skipping deactivate (dry run)"
} else {
if {[info exists options(ports_uninstall_no-exec)] || ![registry::run_target $port deactivate $optionslist]} {
- portimage::deactivate $portname $v [array get options]
+ portimage::deactivate $portname $version $revision $variants [array get options]
}
}
}
@@ -179,9 +190,9 @@
}
if {[info exists options(ports_dryrun)] && [string is true -strict $options(ports_dryrun)]} {
- ui_msg "For $portname @${v}: skipping uninstall (dry run)"
+ ui_msg "For $portname @${composite_spec}: skipping uninstall (dry run)"
} else {
- ui_msg "$UI_PREFIX [format [msgcat::mc "Uninstalling %s @%s"] $portname $v]"
+ ui_msg "$UI_PREFIX [format [msgcat::mc "Uninstalling %s @%s"] $portname $composite_spec]"
# Get the full path to the image file
set imagefile [registry::property_retrieve $ref location]
@@ -207,8 +218,7 @@
if {[llength [registry::list_dependents $dep $iversion $irevision $ivariants]] == 0} {
set regref [registry::open_entry $dep $iversion $irevision $ivariants [lindex $i 5]]
if {![registry::property_retrieve $regref requested] && ([info exists options(ports_uninstall_no-exec)] || ![registry::run_target $regref uninstall $optionslist])} {
- set depver "${iversion}_${irevision}${ivariants}"
- registry_uninstall::uninstall $dep $depver $optionslist
+ registry_uninstall::uninstall $dep $iversion $irevision $ivariants $optionslist
}
} else {
set remaining 1
Modified: trunk/base/src/registry2.0/receipt_sqlite.tcl
===================================================================
--- trunk/base/src/registry2.0/receipt_sqlite.tcl 2011-06-04 04:59:15 UTC (rev 79166)
+++ trunk/base/src/registry2.0/receipt_sqlite.tcl 2011-06-04 05:00:16 UTC (rev 79167)
@@ -160,26 +160,22 @@
# If version is "", return all ports of that name.
# Otherwise, return only ports that exactly match this version.
# What we call version here is version_revision+variants.
+# The syntax for that can be ambiguous if there's an underscore and dash in
+# version for example, so we don't attempt to split up the composite version
+# into its components, we just compare the whole thing.
proc installed {{name ""} {version ""}} {
if { $name == "" && $version == "" } {
set ports [registry::entry imaged]
} elseif { $name != "" && $version == ""} {
set ports [registry::entry imaged $name]
} else {
- set cmd "registry::entry imaged $name"
- registry::decode_spec $version version revision variants
- if {[info exists version] && $version != ""} {
- append cmd " $version"
- if {[info exists revision] && $revision != ""} {
- append cmd " $revision"
- if {![info exists variants]} {
- set variants ""
- }
- append cmd " {$variants}"
- }
- }
- if {[catch {set ports [eval $cmd]}]} {
- set ports [list]
+ set ports {}
+ set possible_ports [registry::entry imaged $name]
+ foreach p $possible_ports {
+ if {"[$port version]_[$port revision][$port variants]" == $version
+ || [$port version] == $version} {
+ lappend ports $p
+ }
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20110603/6aefb9d8/attachment-0001.html>
More information about the macports-changes
mailing list