New Ticket     Tickets     Wiki     Browse Source     Timeline     Roadmap     Ticket Reports     Search

Changeset 79167


Ignore:
Timestamp:
06/03/11 22:00:16 (4 years ago)
Author:
jmr@…
Message:

avoid using composite version specs for registry operations (#28084)

Location:
trunk/base
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/portmgr/packaging/dpkgall.tcl

    r78062 r79167  
    709709 
    710710                        ui_msg "Uninstalling $port." 
    711                         if { [catch {registry_uninstall::uninstall $portname $portversion} result] } { 
     711                        if { [catch {registry_uninstall::uninstall $portname $portversion "" 0 [array get options]} result] } { 
    712712                                global errorInfo 
    713713                                ui_debug "$errorInfo" 
  • trunk/base/src/macports1.0/macports.tcl

    r79093 r79167  
    34383438            ui_msg "Skipping uninstall $newname @${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) (dry run)" 
    34393439        } elseif {![registry::run_target $newregref uninstall [array get options]] 
    3440                   && [catch {registry_uninstall::uninstall $newname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) [array get options]} result]} { 
     3440                  && [catch {registry_uninstall::uninstall $newname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants) [array get options]} result]} { 
    34413441            global errorInfo 
    34423442            ui_debug "$errorInfo" 
     
    34623462        } elseif {![catch {registry::active $portname}] && 
    34633463                  ![registry::run_target $regref deactivate [array get options]] 
    3464                   && [catch {portimage::deactivate $portname ${version_active}_${revision_active}${variant_active} [array get options]} result]} { 
     3464                  && [catch {portimage::deactivate $portname $version_active $revision_active $variant_active [array get options]} result]} { 
    34653465            global errorInfo 
    34663466            ui_debug "$errorInfo" 
     
    35383538                ui_msg "Skipping uninstall $portname @${version}_${revision}${variant} (dry run)" 
    35393539            } elseif {![registry::run_target $regref uninstall $optionslist] 
    3540                       && [catch {registry_uninstall::uninstall $portname ${version}_${revision}${variant} $optionslist} result]} { 
     3540                      && [catch {registry_uninstall::uninstall $portname $version $revision $variant $optionslist} result]} { 
    35413541                global errorInfo 
    35423542                ui_debug "$errorInfo" 
  • trunk/base/src/port/port.tcl

    r79070 r79167  
    22352235        } 
    22362236        if {![macports::global_option_isset ports_dryrun]} { 
    2237             if { [catch {portimage::activate $portname $composite_version [array get options]} result] } { 
     2237            if { [catch {portimage::activate_composite $portname $composite_version [array get options]} result] } { 
    22382238                global errorInfo 
    22392239                ui_debug "$errorInfo" 
     
    22712271        } 
    22722272        if {![macports::global_option_isset ports_dryrun]} { 
    2273             if { [catch {portimage::deactivate $portname $composite_version [array get options]} result] } { 
     2273            if { [catch {portimage::deactivate_composite $portname $composite_version [array get options]} result] } { 
    22742274                global errorInfo 
    22752275                ui_debug "$errorInfo" 
     
    28352835        } 
    28362836 
    2837         if { [catch {registry_uninstall::uninstall $portname $composite_version [array get options]} result] } { 
     2837        if { [catch {registry_uninstall::uninstall_composite $portname $composite_version [array get options]} result] } { 
    28382838            global errorInfo 
    28392839            ui_debug "$errorInfo" 
  • trunk/base/src/port1.0/portactivate.tcl

    r78062 r79167  
    6161    global env subport version revision portvariants user_options PortInfo 
    6262 
    63     registry_activate $subport "${version}_${revision}${portvariants}" [array get user_options] 
     63    registry_activate $subport $version $revision $portvariants [array get user_options] 
    6464 
    6565    # Display notes at the end of the activation phase. 
  • trunk/base/src/port1.0/portdeactivate.tcl

    r78062 r79167  
    5959proc portdeactivate::deactivate_main {args} { 
    6060    global subport version revision portvariants user_options 
    61     registry_deactivate $subport "${version}_${revision}${portvariants}" [array get user_options] 
     61    registry_deactivate $subport $version $revision $portvariants [array get user_options] 
    6262    return 0 
    6363} 
  • trunk/base/src/port1.0/portuninstall.tcl

    r78062 r79167  
    5959proc portuninstall::uninstall_main {args} { 
    6060    global subport version revision portvariants user_options 
    61     registry_uninstall $subport "${version}_${revision}${portvariants}" [array get user_options] 
     61    registry_uninstall $subport $version $revision $portvariants [array get user_options] 
    6262    return 0 
    6363} 
  • trunk/base/src/registry2.0/portimage.tcl

    r79070 r79167  
    6464variable noexec 0 
    6565 
     66# takes a composite version spec rather than separate version,revision,variants 
     67proc activate_composite {name {v ""} {optionslist ""}} { 
     68    if {$v == ""} { 
     69        return [activate $name "" "" 0 $optionslist] 
     70    } elseif {[registry::decode_spec $v version revision variants]} { 
     71        return [activate $name $version $revision $variants $optionslist] 
     72    } 
     73    throw registry::invalid "Registry error: Invalid version '$v' specified for ${name}. Please specify a version as recorded in the port registry." 
     74} 
     75 
    6676# Activate a "Port Image" 
    67 proc activate {name v optionslist} { 
     77proc activate {name {version ""} {revision ""} {variants 0} {optionslist ""}} { 
    6878    global macports::prefix macports::registry.path registry_open UI_PREFIX 
    6979    array set options $optionslist 
     
    8595    registry::read { 
    8696 
    87         set requested [_check_registry $name $v] 
     97        set requested [_check_registry $name $version $revision $variants] 
    8898        # set name again since the one we were passed may not have had the correct case 
    8999        set name [$requested name] 
     
    104114        # this shouldn't be possible 
    105115        if { ![string equal [$requested installtype] "image"] } { 
    106             return -code error "Image error: ${name} @${version}_${revision}${variants} not installed as an image." 
     116            return -code error "Image error: ${name} @${specifier} not installed as an image." 
    107117        } 
    108118        if {![file isfile $location]} { 
     
    110120        } 
    111121        if { [string equal [$requested state] "installed"] } { 
    112             return -code error "Image error: ${name} @${version}_${revision}${variants} is already active." 
     122            return -code error "Image error: ${name} @${specifier} is already active." 
    113123        } 
    114124    } 
    115125    foreach a $todeactivate { 
    116126        if {$noexec || ![registry::run_target $a deactivate [list ports_nodepcheck 1]]} { 
    117             deactivate $name "[$a version]_[$a revision][$a variants]" [list ports_nodepcheck 1] 
    118         } 
    119     } 
    120  
    121     if {$v != ""} { 
    122         ui_msg "$UI_PREFIX [format [msgcat::mc "Activating %s @%s"] $name $v]" 
    123     } else { 
    124         ui_msg "$UI_PREFIX [format [msgcat::mc "Activating %s"] $name]" 
    125     } 
     127            deactivate $name [$a version] [$a revision] [$a variants] [list ports_nodepcheck 1] 
     128        } 
     129    } 
     130 
     131    ui_msg "$UI_PREFIX [format [msgcat::mc "Activating %s @%s"] $name $specifier]" 
    126132 
    127133    _activate_contents $requested 
     
    129135} 
    130136 
    131 proc deactivate {name v optionslist} { 
     137# takes a composite version spec rather than separate version,revision,variants 
     138proc deactivate_composite {name {v ""} {optionslist ""}} { 
     139    if {$v == ""} { 
     140        return [deactivate $name "" "" 0 $optionslist] 
     141    } elseif {[registry::decode_spec $v version revision variants]} { 
     142        return [deactivate $name $version $revision $variants $optionslist] 
     143    } 
     144    throw registry::invalid "Registry error: Invalid version '$v' specified for ${name}. Please specify a version as recorded in the port registry." 
     145} 
     146 
     147proc deactivate {name {version ""} {revision ""} {variants 0} {optionslist ""}} { 
    132148    global UI_PREFIX macports::registry.path registry_open 
    133149    array set options $optionslist 
     
    157173    # set name again since the one we were passed may not have had the correct case 
    158174    set name [$requested name] 
    159     set version [$requested version] 
    160     set revision [$requested revision] 
    161     set variants [$requested variants] 
    162     set specifier "${version}_${revision}${variants}" 
    163  
    164     if { $v != "" && ![string equal $specifier $v] } { 
     175    set specifier "[$requested version]_[$requested revision][$requested variants]" 
     176 
     177    if {$version != "" && ($version != [$requested version] || 
     178        ($revision != "" && ($revision != [$requested revision] || $variants != [$requested variants])))} { 
     179        set v $version 
     180        if {$revision != ""} { 
     181            append v _${revision}${variants} 
     182        } 
    165183        return -code error "Active version of $name is not $v but ${specifier}." 
    166184    } 
    167185 
    168     if {$v != ""} { 
    169         ui_msg "$UI_PREFIX [format [msgcat::mc "Deactivating %s @%s"] $name $v]" 
    170     } else { 
    171         ui_msg "$UI_PREFIX [format [msgcat::mc "Deactivating %s"] $name]" 
    172     } 
     186    ui_msg "$UI_PREFIX [format [msgcat::mc "Deactivating %s @%s"] $name $specifier]" 
    173187 
    174188    if { ![string equal [$requested installtype] "image"] } { 
     
    188202} 
    189203 
    190 proc _check_registry {name v} { 
     204proc _check_registry {name version revision variants} { 
    191205    global UI_PREFIX 
    192206 
    193     if { [registry::decode_spec $v version revision variants] } { 
    194         set ilist [registry::entry imaged $name $version $revision $variants] 
    195         set valid 1 
    196     } else { 
    197         set valid [string equal $v {}] 
    198         set ilist [registry::entry imaged $name] 
    199     } 
    200  
    201     if { [llength $ilist] > 1 || (!$valid && [llength $ilist] == 1) } { 
     207    set searchkeys $name 
     208    set composite_spec "" 
     209    if {$version != ""} { 
     210        lappend searchkeys $version 
     211        set composite_spec $version 
     212        # restriction imposed by underlying registry API (see entry.c): 
     213        # if a revision is specified, so must variants be 
     214        if {$revision != ""} { 
     215            lappend searchkeys $revision $variants 
     216            append composite_spec _${revision}${variants} 
     217        } 
     218    } 
     219    set ilist [eval registry::entry imaged $searchkeys] 
     220 
     221    if { [llength $ilist] > 1 } { 
    202222        ui_msg "$UI_PREFIX [msgcat::mc "The following versions of $name are currently installed:"]" 
    203223        foreach i $ilist { 
     
    212232            } 
    213233        } 
    214         if { $valid } { 
    215             throw registry::invalid "Registry error: Please specify the full version as recorded in the port registry." 
    216         } else { 
    217             throw registry::invalid "Registry error: Invalid version specified. Please specify a version as recorded in the port registry." 
    218         } 
     234        throw registry::invalid "Registry error: Please specify the full version as recorded in the port registry." 
    219235    } elseif { [llength $ilist] == 1 } { 
    220236        return [lindex $ilist 0] 
    221237    } 
    222     throw registry::invalid "Registry error: No port of $name installed." 
     238    if {$composite_spec != ""} { 
     239        set composite_spec " @${composite_spec}" 
     240    } 
     241    throw registry::invalid "Registry error: ${name}${composite_spec} is not installed." 
    223242} 
    224243 
     
    488507        foreach owner [array names todeactivate] { 
    489508            if {$noexec || ![registry::run_target $owner deactivate [list ports_nodepcheck 1]]} { 
    490                 deactivate [$owner name] "" [list ports_nodepcheck 1] 
     509                deactivate [$owner name] "" "" 0 [list ports_nodepcheck 1] 
    491510            } 
    492511        } 
     
    530549        foreach entry [array names todeactivate] { 
    531550            if {[$entry state] == "imaged" && ($noexec || ![registry::run_target $entry activate ""])} { 
    532                 set pvers "[$entry version]_[$entry revision][$entry variants]" 
    533                 activate [$entry name] $pvers [list ports_activate_no-exec $noexec] 
     551                activate [$entry name] [$entry version] [$entry revision] [$entry variants] [list ports_activate_no-exec $noexec] 
    534552            } 
    535553        } 
  • trunk/base/src/registry2.0/portuninstall.tcl

    r79070 r79167  
    4141namespace eval registry_uninstall { 
    4242 
    43 proc uninstall {portname {v ""} optionslist} { 
     43# takes a composite version spec rather than separate version,revision,variants 
     44proc uninstall_composite {portname {v ""} {optionslist ""}} { 
     45    if {$v == ""} { 
     46        return [uninstall $portname "" "" 0 $optionslist] 
     47    } elseif {[registry::decode_spec $v version revision variants]} { 
     48        return [uninstall $portname $version $revision $variants $optionslist] 
     49    } 
     50    throw registry::invalid "Registry error: Invalid version '$v' specified for ${portname}. Please specify a version as recorded in the port registry." 
     51} 
     52 
     53proc uninstall {portname {version ""} {revision ""} {variants 0} {optionslist ""}} { 
    4454    global uninstall.force uninstall.nochecksum UI_PREFIX \ 
    4555           macports::portimagefilepath 
     
    5868    } 
    5969 
    60     if { [registry::decode_spec $v version revision variants] } { 
    61         set ilist [registry::entry imaged $portname $version $revision $variants] 
    62         set valid 1 
    63     } else { 
    64         set valid [string equal $v {}] 
    65         set ilist [registry::entry imaged $portname] 
    66     } 
     70    set searchkeys $portname 
     71    set composite_spec "" 
     72    if {$version != ""} { 
     73        lappend searchkeys $version 
     74        set composite_spec $version 
     75        # restriction imposed by underlying registry API (see entry.c): 
     76        # if a revision is specified, so must variants be 
     77        if {$revision != ""} { 
     78            lappend searchkeys $revision $variants 
     79            append composite_spec _${revision}${variants} 
     80        } 
     81    } 
     82    set ilist [eval registry::entry imaged $searchkeys] 
    6783    if { [llength $ilist] > 1 } { 
    6884        # set portname again since the one we were passed may not have had the correct case 
     
    7793            } 
    7894        } 
    79         if { $valid } { 
    80             throw registry::invalid "Registry error: Please specify the full version as recorded in the port registry." 
    81         } else { 
    82             throw registry::invalid "Registry error: Invalid version specified. Please specify a version as recorded in the port registry." 
    83         } 
     95        throw registry::invalid "Registry error: Please specify the full version as recorded in the port registry." 
    8496    } elseif { [llength $ilist] == 1 } { 
    8597        set port [lindex $ilist 0] 
     
    8799        set revision [$port revision] 
    88100        set variants [$port variants] 
    89         if {$v == ""} { 
    90             set v "${version}_${revision}${variants}" 
    91         } 
     101        set composite_spec "${version}_${revision}${variants}" 
    92102    } else { 
    93         throw registry::invalid "Registry error: $portname not registered as installed" 
     103        if {$composite_spec != ""} { 
     104            set composite_spec " @${composite_spec}" 
     105        } 
     106        throw registry::invalid "Registry error: ${portname}${composite_spec} not registered as installed" 
    94107    } 
    95108 
     
    100113            if {[registry::entry exists $depport] && ([$depport state] == "imaged" || [$depport state] == "installed")} { 
    101114                if {[info exists options(ports_uninstall_no-exec)] || ![registry::run_target $depport uninstall $optionslist]} { 
    102                     set depname [$depport name] 
    103                     set depver "[$depport version]_[$depport revision][$depport variants]" 
    104                     registry_uninstall::uninstall $depname $depver $optionslist 
     115                    registry_uninstall::uninstall [$depport name] [$depport version] [$depport revision] [$depport variants] $optionslist 
    105116                } 
    106117            } 
     
    113124    if { [string equal [$port state] installed] } { 
    114125        if {[info exists options(ports_dryrun)] && [string is true -strict $options(ports_dryrun)]} { 
    115             ui_msg "For $portname @${v}: skipping deactivate (dry run)" 
     126            ui_msg "For $portname @${composite_spec}: skipping deactivate (dry run)" 
    116127        } else { 
    117128            if {[info exists options(ports_uninstall_no-exec)] || ![registry::run_target $port deactivate $optionslist]} { 
    118                 portimage::deactivate $portname $v [array get options] 
     129                portimage::deactivate $portname $version $revision $variants [array get options] 
    119130            } 
    120131        } 
     
    180191 
    181192    if {[info exists options(ports_dryrun)] && [string is true -strict $options(ports_dryrun)]} { 
    182         ui_msg "For $portname @${v}: skipping uninstall (dry run)" 
     193        ui_msg "For $portname @${composite_spec}: skipping uninstall (dry run)" 
    183194    } else { 
    184         ui_msg "$UI_PREFIX [format [msgcat::mc "Uninstalling %s @%s"] $portname $v]" 
     195        ui_msg "$UI_PREFIX [format [msgcat::mc "Uninstalling %s @%s"] $portname $composite_spec]" 
    185196 
    186197        # Get the full path to the image file 
     
    208219                            set regref [registry::open_entry $dep $iversion $irevision $ivariants [lindex $i 5]] 
    209220                            if {![registry::property_retrieve $regref requested] && ([info exists options(ports_uninstall_no-exec)] || ![registry::run_target $regref uninstall $optionslist])} { 
    210                                 set depver "${iversion}_${irevision}${ivariants}" 
    211                                 registry_uninstall::uninstall $dep $depver $optionslist 
     221                                registry_uninstall::uninstall $dep $iversion $irevision $ivariants $optionslist 
    212222                            } 
    213223                        } else { 
  • trunk/base/src/registry2.0/receipt_sqlite.tcl

    r77511 r79167  
    161161# Otherwise, return only ports that exactly match this version. 
    162162# What we call version here is version_revision+variants. 
     163# The syntax for that can be ambiguous if there's an underscore and dash in 
     164# version for example, so we don't attempt to split up the composite version 
     165# into its components, we just compare the whole thing. 
    163166proc installed {{name ""} {version ""}} { 
    164167        if { $name == "" && $version == "" } { 
     
    167170            set ports [registry::entry imaged $name] 
    168171        } else { 
    169             set cmd "registry::entry imaged $name" 
    170             registry::decode_spec $version version revision variants 
    171             if {[info exists version] && $version != ""} { 
    172                 append cmd " $version" 
    173                 if {[info exists revision] && $revision != ""} { 
    174                     append cmd " $revision" 
    175                     if {![info exists variants]} { 
    176                         set variants "" 
    177                     } 
    178                     append cmd " {$variants}" 
    179                 } 
    180         } 
    181             if {[catch {set ports [eval $cmd]}]} { 
    182                 set ports [list] 
     172            set ports {} 
     173            set possible_ports [registry::entry imaged $name] 
     174            foreach p $possible_ports { 
     175                if {"[$port version]_[$port revision][$port variants]" == $version 
     176                    || [$port version] == $version} { 
     177                    lappend ports $p 
     178                } 
    183179            } 
    184180        } 
Note: See TracChangeset for help on using the changeset viewer.