Changeset 79070
- Timestamp:
- 05/31/11 20:07:30 (4 years ago)
- Location:
- trunk/base/src
- Files:
-
- 5 edited
-
macports1.0/macports.tcl (modified) (7 diffs)
-
port/port.tcl (modified) (8 diffs)
-
port1.0/portinstall.tcl (modified) (4 diffs)
-
registry2.0/portimage.tcl (modified) (11 diffs)
-
registry2.0/portuninstall.tcl (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/base/src/macports1.0/macports.tcl
r79009 r79070 946 946 } 947 947 948 # init registry if needed 949 if {${registry.format} == "receipt_sqlite"} { 950 set db_path [file join ${registry.path} registry registry.db] 951 set db_exists [file exists $db_path] 952 registry::open $db_path 953 # for the benefit of the portimage code that is called from multiple interpreters 954 global registry_open 955 set registry_open yes 956 # convert any flat receipts if we just created a new db 957 if {$db_exists == 0 && [file writable $db_path]} { 958 ui_warn "Converting your registry to sqlite format, this might take a while..." 959 if {[catch {registry::convert_to_sqlite}]} { 960 ui_debug "$::errorInfo" 961 file delete -force $db_path 962 error "Failed to convert your registry to sqlite!" 963 } else { 964 ui_warn "Successfully converted your registry to sqlite!" 965 } 948 # init registry 949 set db_path [file join ${registry.path} registry registry.db] 950 set db_exists [file exists $db_path] 951 registry::open $db_path 952 # for the benefit of the portimage code that is called from multiple interpreters 953 global registry_open 954 set registry_open yes 955 # convert any flat receipts if we just created a new db 956 if {$db_exists == 0 && [file writable $db_path]} { 957 ui_warn "Converting your registry to sqlite format, this might take a while..." 958 if {[catch {registry::convert_to_sqlite}]} { 959 ui_debug "$::errorInfo" 960 file delete -force $db_path 961 error "Failed to convert your registry to sqlite!" 962 } else { 963 ui_warn "Successfully converted your registry to sqlite!" 966 964 } 967 965 } … … 970 968 # call this just before you exit 971 969 proc mportshutdown {} { 972 global macports::registry.format 973 if {${registry.format} == "receipt_sqlite"} { 974 # close it down so the cleanup stuff is called, e.g. vacuuming the db 975 registry::close 976 } 970 # close it down so the cleanup stuff is called, e.g. vacuuming the db 971 registry::close 977 972 } 978 973 … … 1382 1377 # opens a portfile stored in the registry 1383 1378 proc mportopen_installed {name version revision variants options} { 1384 global macports::registry.format macports::registry.path 1385 if {${registry.format} != "receipt_sqlite"} { 1386 return -code error "mportopen_installed requires sqlite registry" 1387 } 1379 global macports::registry.path 1388 1380 set regref [lindex [registry::entry imaged $name $version $revision $variants] 0] 1389 1381 set portfile_dir [file join ${registry.path} registry portfiles $name "${version}_${revision}${variants}"] … … 3294 3286 } 3295 3287 3296 global macports::registry.format3297 3288 # are we installing an existing version due to force or epoch override? 3298 3289 if {[registry::entry_exists $newname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants)] … … 3306 3297 if {$is_dryrun eq "yes"} { 3307 3298 ui_msg "Skipping uninstall $newname @${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) (dry run)" 3308 } elseif {! (${registry.format} == "receipt_sqlite" && [registry::run_target $newregref uninstall [array get options]])3299 } elseif {![registry::run_target $newregref uninstall [array get options]] 3309 3300 && [catch {registry_uninstall::uninstall $newname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) [array get options]} result]} { 3310 3301 global errorInfo … … 3330 3321 ui_msg "Skipping deactivate $portname @${version_active}_${revision_active}${variant_active} (dry run)" 3331 3322 } elseif {![catch {registry::active $portname}] && 3332 ! (${registry.format} == "receipt_sqlite" && [registry::run_target $regref deactivate [array get options]])3323 ![registry::run_target $regref deactivate [array get options]] 3333 3324 && [catch {portimage::deactivate $portname ${version_active}_${revision_active}${variant_active} [array get options]} result]} { 3334 3325 global errorInfo … … 3406 3397 if {$is_dryrun eq "yes"} { 3407 3398 ui_msg "Skipping uninstall $portname @${version}_${revision}${variant} (dry run)" 3408 } elseif {! (${registry.format} == "receipt_sqlite" && [registry::run_target $regref uninstall $optionslist])3399 } elseif {![registry::run_target $regref uninstall $optionslist] 3409 3400 && [catch {registry_uninstall::uninstall $portname ${version}_${revision}${variant} $optionslist} result]} { 3410 3401 global errorInfo -
trunk/base/src/port/port.tcl
r78621 r79070 2218 2218 2219 2219 proc action_activate { action portlist opts } { 2220 global macports::registry.format2221 2220 set status 0 2222 2221 if {[require_portlist portlist] || [prefix_unwritable]} { … … 2225 2224 foreachport $portlist { 2226 2225 set composite_version [composite_version $portversion [array get variations]] 2227 if {${macports::registry.format} == "receipt_sqlite" 2228 && ![info exists options(ports_activate_no-exec)] 2226 if {![info exists options(ports_activate_no-exec)] 2229 2227 && ![catch {set ilist [registry::installed $portname $composite_version]}] 2230 2228 && [llength $ilist] == 1} { … … 2252 2250 2253 2251 proc action_deactivate { action portlist opts } { 2254 global macports::registry.format2255 2252 set status 0 2256 2253 if {[require_portlist portlist] || [prefix_unwritable]} { … … 2259 2256 foreachport $portlist { 2260 2257 set composite_version [composite_version $portversion [array get variations]] 2261 if {${macports::registry.format} == "receipt_sqlite" 2262 && ![info exists options(ports_deactivate_no-exec)] 2258 if {![info exists options(ports_deactivate_no-exec)] 2263 2259 && ![catch {set ilist [registry::active $portname]}]} { 2264 2260 … … 2413 2409 2414 2410 proc action_setrequested { action portlist opts } { 2415 global macports::registry.format2416 2411 set status 0 2417 2412 if {[require_portlist portlist] || [prefix_unwritable]} { … … 2427 2422 set regref [registry::open_entry $portname [lindex $i 1] [lindex $i 2] [lindex $i 3] [lindex $i 5]] 2428 2423 registry::property_store $regref requested $val 2429 if {${macports::registry.format} != "receipt_sqlite"} {2430 registry::write_entry $regref2431 }2432 2424 } 2433 2425 } else { … … 2810 2802 2811 2803 proc action_uninstall { action portlist opts } { 2812 global macports::registry.format2813 2804 set status 0 2814 2805 if {[macports::global_option_isset port_uninstall_old]} { … … 2832 2823 } 2833 2824 set composite_version [composite_version $portversion [array get variations]] 2834 if {${macports::registry.format} == "receipt_sqlite" 2835 && ![info exists options(ports_uninstall_no-exec)] 2825 if {![info exists options(ports_uninstall_no-exec)] 2836 2826 && ![catch {set ilist [registry::installed $portname $composite_version]}] 2837 2827 && [llength $ilist] == 1} { -
trunk/base/src/port1.0/portinstall.tcl
r78660 r79070 55 55 proc portinstall::install_start {args} { 56 56 global UI_PREFIX subport version revision portvariants 57 global prefix registry_open registry. format registry.path57 global prefix registry_open registry.path 58 58 ui_notice "$UI_PREFIX [format [msgcat::mc "Installing %s @%s_%s%s"] $subport $version $revision $portvariants]" 59 59 … … 67 67 # end gsoc08-privileges 68 68 69 if { ${registry.format} == "receipt_sqlite" &&![info exists registry_open]} {69 if {![info exists registry_open]} { 70 70 registry::open [file join ${registry.path} registry registry.db] 71 71 set registry_open yes … … 484 484 worksrcdir UI_PREFIX destroot revision maintainers user_options \ 485 485 portvariants negated_variants targets depends_lib PortInfo epoch license \ 486 registry.formatos.platform os.major portarchivetype installPlist486 os.platform os.major portarchivetype installPlist 487 487 488 488 set oldpwd [pwd] … … 504 504 } 505 505 506 if {[string equal ${registry.format} "receipt_sqlite"]} { 507 # registry2.0 508 509 # can't do this inside the write transaction due to deadlock issues with _get_dep_port 510 set dep_portnames [list] 511 foreach deplist {depends_lib depends_run} { 512 if {[info exists $deplist]} { 513 foreach dep [set $deplist] { 514 set dep_portname [_get_dep_port $dep] 515 if {$dep_portname != ""} { 516 lappend dep_portnames $dep_portname 517 } 506 # can't do this inside the write transaction due to deadlock issues with _get_dep_port 507 set dep_portnames [list] 508 foreach deplist {depends_lib depends_run} { 509 if {[info exists $deplist]} { 510 foreach dep [set $deplist] { 511 set dep_portname [_get_dep_port $dep] 512 if {$dep_portname != ""} { 513 lappend dep_portnames $dep_portname 518 514 } 519 515 } 520 516 } 521 522 registry::write { 523 524 set regref [registry::entry create $subport $version $revision $portvariants $epoch] 525 526 if {[info exists user_options(ports_requested)]} { 527 $regref requested $user_options(ports_requested) 528 } else { 529 $regref requested 0 530 } 531 $regref os_platform ${os.platform} 532 $regref os_major ${os.major} 533 $regref archs [get_canonical_archs] 534 # Trick to have a portable GMT-POSIX epoch-based time. 535 $regref date [expr [clock scan now -gmt true] - [clock scan "1970-1-1 00:00:00" -gmt true]] 536 if {[info exists negated_variants]} { 537 $regref negated_variants $negated_variants 538 } 539 540 foreach dep_portname $dep_portnames { 541 $regref depends $dep_portname 542 } 543 544 $regref installtype image 545 $regref state imaged 546 $regref location $location 547 548 if {[info exists installPlist]} { 549 # register files 550 $regref map $installPlist 551 } 552 553 # store portfile 554 set fd [open [file join ${portpath} Portfile]] 555 $regref portfile [read $fd] 556 close $fd 557 } 558 } else { 559 # Begin the registry entry 560 set regref [registry_new $subport $version $revision $portvariants $epoch] 517 } 518 519 registry::write { 520 521 set regref [registry::entry create $subport $version $revision $portvariants $epoch] 522 523 if {[info exists user_options(ports_requested)]} { 524 $regref requested $user_options(ports_requested) 525 } else { 526 $regref requested 0 527 } 528 $regref os_platform ${os.platform} 529 $regref os_major ${os.major} 530 $regref archs [get_canonical_archs] 531 # Trick to have a portable GMT-POSIX epoch-based time. 532 $regref date [expr [clock scan now -gmt true] - [clock scan "1970-1-1 00:00:00" -gmt true]] 561 533 if {[info exists negated_variants]} { 562 registry_prop_store $regref negated_variants $negated_variants 563 } 564 565 registry_prop_store $regref location $location 566 567 if {[info exists user_options(ports_requested)]} { 568 registry_prop_store $regref requested $user_options(ports_requested) 569 } else { 570 registry_prop_store $regref requested 0 571 } 572 registry_prop_store $regref categories $categories 573 574 registry_prop_store $regref os_platform ${os.platform} 575 registry_prop_store $regref os_major ${os.major} 576 registry_prop_store $regref archs [get_canonical_archs] 577 578 if {[info exists description]} { 579 registry_prop_store $regref description [string map {\n \\n} ${description}] 580 } 581 if {[info exists long_description]} { 582 registry_prop_store $regref long_description [string map {\n \\n} ${long_description}] 583 } 584 if {[info exists license]} { 585 registry_prop_store $regref license ${license} 586 } 587 if {[info exists homepage]} { 588 registry_prop_store $regref homepage ${homepage} 589 } 590 if {[info exists maintainers]} { 591 registry_prop_store $regref maintainers ${maintainers} 592 } 593 if {[info exists depends_run]} { 594 registry_prop_store $regref depends_run $depends_run 595 registry_register_deps $depends_run $subport 596 } 597 if {[info exists depends_lib]} { 598 registry_prop_store $regref depends_lib $depends_lib 599 registry_register_deps $depends_lib $subport 600 } 534 $regref negated_variants $negated_variants 535 } 536 537 foreach dep_portname $dep_portnames { 538 $regref depends $dep_portname 539 } 540 541 $regref installtype image 542 $regref state imaged 543 $regref location $location 544 601 545 if {[info exists installPlist]} { 602 registry_prop_store $regref contents [_fake_fileinfo_for_index $installPlist] 603 } 604 if {[info exists package-install]} { 605 registry_prop_store $regref package-install ${package-install} 606 } 607 if {[info proc pkg_uninstall] == "pkg_uninstall"} { 608 registry_prop_store $regref pkg_uninstall [proc_disasm pkg_uninstall] 609 } 610 611 registry_write $regref 546 # register files 547 $regref map $installPlist 548 } 549 550 # store portfile 551 set fd [open [file join ${portpath} Portfile]] 552 $regref portfile [read $fd] 553 close $fd 612 554 } 613 555 -
trunk/base/src/registry2.0/portimage.tcl
r78957 r79070 62 62 63 63 variable force 0 64 variable use_reg2 065 64 variable noexec 0 66 65 67 66 # Activate a "Port Image" 68 67 proc activate {name v optionslist} { 69 global macports::prefix macports::registry. format macports::registry.path registry_open UI_PREFIX68 global macports::prefix macports::registry.path registry_open UI_PREFIX 70 69 array set options $optionslist 71 70 variable force 72 variable use_reg273 71 variable noexec 74 72 … … 79 77 set noexec $options(ports_activate_no-exec) 80 78 } 81 if {[string equal ${macports::registry.format} "receipt_sqlite"]} { 82 set use_reg2 1 83 if {![info exists registry_open]} { 84 registry::open [file join ${macports::registry.path} registry registry.db] 85 set registry_open yes 86 } 79 if {![info exists registry_open]} { 80 registry::open [file join ${macports::registry.path} registry registry.db] 81 set registry_open yes 87 82 } 88 83 set todeactivate [list] 89 84 90 if {$use_reg2} { 91 registry::read { 92 93 set requested [_check_registry $name $v] 94 # set name again since the one we were passed may not have had the correct case 95 set name [$requested name] 96 set version [$requested version] 97 set revision [$requested revision] 98 set variants [$requested variants] 99 set specifier "${version}_${revision}${variants}" 100 set location [$requested location] 101 102 # if another version of this port is active, deactivate it first 103 set current [registry::entry installed $name] 104 foreach i $current { 105 if { ![string equal $specifier "[$i version]_[$i revision][$i variants]"] } { 106 lappend todeactivate $i 107 } 108 } 109 110 # this shouldn't be possible 111 if { ![string equal [$requested installtype] "image"] } { 112 return -code error "Image error: ${name} @${version}_${revision}${variants} not installed as an image." 113 } 114 if {![file isfile $location]} { 115 return -code error "Image error: Can't find image file $location" 116 } 117 if { [string equal [$requested state] "installed"] } { 118 return -code error "Image error: ${name} @${version}_${revision}${variants} is already active." 119 } 120 } 121 foreach a $todeactivate { 122 if {$noexec || ![registry::run_target $a deactivate [list ports_nodepcheck 1]]} { 123 deactivate $name "[$a version]_[$a revision][$a variants]" [list ports_nodepcheck 1] 124 } 125 } 126 } else { 127 # registry1.0 128 set ilist [_check_registry $name $v] 85 registry::read { 86 87 set requested [_check_registry $name $v] 129 88 # set name again since the one we were passed may not have had the correct case 130 set name [lindex $ilist 0] 131 set version [lindex $ilist 1] 132 set revision [lindex $ilist 2] 133 set variants [lindex $ilist 3] 89 set name [$requested name] 90 set version [$requested version] 91 set revision [$requested revision] 92 set variants [$requested variants] 93 set specifier "${version}_${revision}${variants}" 94 set location [$requested location] 134 95 135 96 # if another version of this port is active, deactivate it first 136 set ilist [registry::installed $name] 137 if { [llength $ilist] > 1 } { 138 foreach i $ilist { 139 set iversion [lindex $i 1] 140 set irevision [lindex $i 2] 141 set ivariants [lindex $i 3] 142 set iactive [lindex $i 4] 143 if { ![string equal "${iversion}_${irevision}${ivariants}" "${version}_${revision}${variants}"] && $iactive == 1 } { 144 lappend todeactivate "${iversion}_${irevision}${ivariants}" 145 } 146 } 147 } 148 149 set ref [registry::open_entry $name $version $revision $variants] 150 151 if { ![string equal [registry::property_retrieve $ref installtype] "image"] } { 97 set current [registry::entry installed $name] 98 foreach i $current { 99 if { ![string equal $specifier "[$i version]_[$i revision][$i variants]"] } { 100 lappend todeactivate $i 101 } 102 } 103 104 # this shouldn't be possible 105 if { ![string equal [$requested installtype] "image"] } { 152 106 return -code error "Image error: ${name} @${version}_${revision}${variants} not installed as an image." 153 107 } 154 set location [registry::property_retrieve $ref location]155 108 if {![file isfile $location]} { 156 109 return -code error "Image error: Can't find image file $location" 157 110 } 158 if { [ registry::property_retrieve $ref active] != 0} {111 if { [string equal [$requested state] "installed"] } { 159 112 return -code error "Image error: ${name} @${version}_${revision}${variants} is already active." 160 113 } 161 162 foreach a $todeactivate { 163 deactivate $name $a [list ports_nodepcheck 1] 114 } 115 foreach a $todeactivate { 116 if {$noexec || ![registry::run_target $a deactivate [list ports_nodepcheck 1]]} { 117 deactivate $name "[$a version]_[$a revision][$a variants]" [list ports_nodepcheck 1] 164 118 } 165 119 } … … 171 125 } 172 126 173 if {$use_reg2} { 174 _activate_contents $requested 175 $requested state installed 176 } else { 177 set contents [registry::property_retrieve $ref contents] 178 179 set imagefiles {} 180 foreach content_element $contents { 181 lappend imagefiles [lindex $content_element 0] 182 } 183 184 registry::open_file_map 185 _activate_contents $name $imagefiles $location 186 187 registry::property_store $ref active 1 188 189 registry::write_entry $ref 190 191 foreach file $imagefiles { 192 registry::register_file $file $name 193 } 194 registry::write_file_map 195 registry::close_file_map 196 } 127 _activate_contents $requested 128 $requested state installed 197 129 } 198 130 199 131 proc deactivate {name v optionslist} { 200 global UI_PREFIX macports::registry. format macports::registry.path registry_open132 global UI_PREFIX macports::registry.path registry_open 201 133 array set options $optionslist 202 variable use_reg2203 134 204 135 if {[info exists options(ports_force)] && [string is true -strict $options(ports_force)] } { … … 210 141 set force 0 211 142 } 212 if {[string equal ${macports::registry.format} "receipt_sqlite"]} { 213 set use_reg2 1 214 if {![info exists registry_open]} { 215 registry::open [file join ${macports::registry.path} registry registry.db] 216 set registry_open yes 217 } 218 } 219 220 if {$use_reg2} { 221 if { [string equal $name ""] } { 222 throw registry::image-error "Registry error: Please specify the name of the port." 223 } 224 set ilist [registry::entry installed $name] 225 if { [llength $ilist] == 1 } { 226 set requested [lindex $ilist 0] 227 } else { 228 throw registry::image-error "Image error: port ${name} is not active." 229 } 230 # set name again since the one we were passed may not have had the correct case 231 set name [$requested name] 232 set version [$requested version] 233 set revision [$requested revision] 234 set variants [$requested variants] 235 set specifier "${version}_${revision}${variants}" 143 if {![info exists registry_open]} { 144 registry::open [file join ${macports::registry.path} registry registry.db] 145 set registry_open yes 146 } 147 148 if { [string equal $name ""] } { 149 throw registry::image-error "Registry error: Please specify the name of the port." 150 } 151 set ilist [registry::entry installed $name] 152 if { [llength $ilist] == 1 } { 153 set requested [lindex $ilist 0] 236 154 } else { 237 set ilist [registry::active $name] 238 if { [llength $ilist] > 1 } { 239 return -code error "Registry error: Please specify the name of the port." 240 } else { 241 set ilist [lindex $ilist 0] 242 } 243 # set name again since the one we were passed may not have had the correct case 244 set name [lindex $ilist 0] 245 set version [lindex $ilist 1] 246 set revision [lindex $ilist 2] 247 set variants [lindex $ilist 3] 248 set specifier "${version}_${revision}${variants}" 249 } 155 throw registry::image-error "Image error: port ${name} is not active." 156 } 157 # set name again since the one we were passed may not have had the correct case 158 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}" 250 163 251 164 if { $v != "" && ![string equal $specifier $v] } { … … 259 172 } 260 173 261 if {$use_reg2} { 262 if { ![string equal [$requested installtype] "image"] } { 263 return -code error "Image error: ${name} @${specifier} not installed as an image." 264 } 265 # this shouldn't be possible 266 if { [$requested state] != "installed" } { 267 return -code error "Image error: ${name} @${specifier} is not active." 268 } 269 270 if {![info exists options(ports_nodepcheck)] || ![string is true -strict $options(ports_nodepcheck)]} { 271 registry::check_dependents $requested $force "deactivate" 272 } 273 274 _deactivate_contents $requested [$requested files] $force 275 $requested state imaged 276 } else { 277 set ref [registry::open_entry $name $version $revision $variants] 278 279 if { ![string equal [registry::property_retrieve $ref installtype] "image"] } { 280 return -code error "Image error: ${name} @${specifier} not installed as an image." 281 } 282 if { [registry::property_retrieve $ref active] != 1 } { 283 return -code error "Image error: ${name} @${specifier} is not active." 284 } 285 286 registry::open_file_map 287 set imagefiles [registry::port_registered $name] 288 289 _deactivate_contents $name $imagefiles 290 291 foreach file $imagefiles { 292 registry::unregister_file $file 293 } 294 registry::write_file_map 295 registry::close_file_map 296 297 registry::property_store $ref active 0 298 299 registry::write_entry $ref 300 } 174 if { ![string equal [$requested installtype] "image"] } { 175 return -code error "Image error: ${name} @${specifier} not installed as an image." 176 } 177 # this shouldn't be possible 178 if { [$requested state] != "installed" } { 179 return -code error "Image error: ${name} @${specifier} is not active." 180 } 181 182 if {![info exists options(ports_nodepcheck)] || ![string is true -strict $options(ports_nodepcheck)]} { 183 registry::check_dependents $requested $force "deactivate" 184 } 185 186 _deactivate_contents $requested [$requested files] $force 187 $requested state imaged 301 188 } 302 189 303 190 proc _check_registry {name v} { 304 191 global UI_PREFIX 305 variable use_reg2 306 307 if {$use_reg2} { 308 if { [registry::decode_spec $v version revision variants] } { 309 set ilist [registry::entry imaged $name $version $revision $variants] 310 set valid 1 192 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) } { 202 ui_msg "$UI_PREFIX [msgcat::mc "The following versions of $name are currently installed:"]" 203 foreach i $ilist { 204 set iname [$i name] 205 set iversion [$i version] 206 set irevision [$i revision] 207 set ivariants [$i variants] 208 if { [$i state] == "installed" } { 209 ui_msg "$UI_PREFIX [format [msgcat::mc " %s @%s_%s%s (active)"] $iname $iversion $irevision $ivariants]" 210 } else { 211 ui_msg "$UI_PREFIX [format [msgcat::mc " %s @%s_%s%s"] $iname $iversion $irevision $ivariants]" 212 } 213 } 214 if { $valid } { 215 throw registry::invalid "Registry error: Please specify the full version as recorded in the port registry." 311 216 } else { 312 set valid [string equal $v {}] 313 set ilist [registry::entry imaged $name] 314 } 315 316 if { [llength $ilist] > 1 || (!$valid && [llength $ilist] == 1) } { 317 ui_msg "$UI_PREFIX [msgcat::mc "The following versions of $name are currently installed:"]" 318 foreach i $ilist { 319 set iname [$i name] 320 set iversion [$i version] 321 set irevision [$i revision] 322 set ivariants [$i variants] 323 if { [$i state] == "installed" } { 324 ui_msg "$UI_PREFIX [format [msgcat::mc " %s @%s_%s%s (active)"] $iname $iversion $irevision $ivariants]" 325 } else { 326 ui_msg "$UI_PREFIX [format [msgcat::mc " %s @%s_%s%s"] $iname $iversion $irevision $ivariants]" 327 } 328 } 329 if { $valid } { 330 throw registry::invalid "Registry error: Please specify the full version as recorded in the port registry." 331 } else { 332 throw registry::invalid "Registry error: Invalid version specified. Please specify a version as recorded in the port registry." 333 } 334 } elseif { [llength $ilist] == 1 } { 335 return [lindex $ilist 0] 336 } 337 throw registry::invalid "Registry error: No port of $name installed." 338 } else { 339 # registry1.0 340 set ilist [registry::installed $name $v] 341 if { [string equal $v ""] && [llength $ilist] > 1 } { 342 # set name again since the one we were passed may not have had the correct case 343 set name [lindex [lindex $ilist 0] 0] 344 ui_msg "$UI_PREFIX [msgcat::mc "The following versions of $name are currently installed:"]" 345 foreach i $ilist { 346 set iname [lindex $i 0] 347 set iversion [lindex $i 1] 348 set irevision [lindex $i 2] 349 set ivariants [lindex $i 3] 350 set iactive [lindex $i 4] 351 if { $iactive == 0 } { 352 ui_msg "$UI_PREFIX [format [msgcat::mc " %s @%s_%s%s"] $iname $iversion $irevision $ivariants]" 353 } elseif { $iactive == 1 } { 354 ui_msg "$UI_PREFIX [format [msgcat::mc " %s @%s_%s%s (active)"] $iname $iversion $irevision $ivariants]" 355 } 356 } 357 return -code error "Registry error: Please specify the full version as recorded in the port registry." 358 } elseif {[llength $ilist] == 1} { 359 return [lindex $ilist 0] 360 } 361 return -code error "Registry error: No port of $name installed." 362 } 217 throw registry::invalid "Registry error: Invalid version specified. Please specify a version as recorded in the port registry." 218 } 219 } elseif { [llength $ilist] == 1 } { 220 return [lindex $ilist 0] 221 } 222 throw registry::invalid "Registry error: No port of $name installed." 363 223 } 364 224 … … 535 395 proc _activate_contents {port {imagefiles {}} {location {}}} { 536 396 variable force 537 variable use_reg2538 397 variable noexec 539 398 global macports::prefix … … 541 400 set files [list] 542 401 set baksuffix .mp_[clock seconds] 543 if {$use_reg2} { 544 set location [$port location] 545 set imagefiles [$port imagefiles] 546 } else { 547 set name $port 548 } 402 set location [$port location] 403 set imagefiles [$port imagefiles] 549 404 set extracted_dir [extract_archive_to_tmpdir $location] 550 405 … … 557 412 # we remove the file from the file_map, take ownership of it, and 558 413 # clobber it 559 if {$use_reg2} { 560 array set todeactivate {} 561 try { 562 registry::write { 563 foreach file $imagefiles { 564 set srcfile "${extracted_dir}${file}" 565 566 # To be able to install links, we test if we can lstat the file to 567 # figure out if the source file exists (file exists will return 568 # false for symlinks on files that do not exist) 569 if { [catch {file lstat $srcfile dummystatvar}] } { 570 throw registry::image-error "Image error: Source file $srcfile does not appear to exist (cannot lstat it). Unable to activate port [$port name]." 414 array set todeactivate {} 415 try { 416 registry::write { 417 foreach file $imagefiles { 418 set srcfile "${extracted_dir}${file}" 419 420 # To be able to install links, we test if we can lstat the file to 421 # figure out if the source file exists (file exists will return 422 # false for symlinks on files that do not exist) 423 if { [catch {file lstat $srcfile dummystatvar}] } { 424 throw registry::image-error "Image error: Source file $srcfile does not appear to exist (cannot lstat it). Unable to activate port [$port name]." 425 } 426 427 set owner [registry::entry owner $file] 428 429 if {$owner != {} && $owner != $port} { 430 # deactivate conflicting port if it is replaced_by this one 431 set result [mportlookup [$owner name]] 432 array unset portinfo 433 array set portinfo [lindex $result 1] 434 if {[info exists portinfo(replaced_by)] && [lsearch -regexp $portinfo(replaced_by) "(?i)^[$port name]\$"] != -1} { 435 # we'll deactivate the owner later, but before activating our files 436 set todeactivate($owner) yes 437 set owner "replaced" 571 438 } 572 573 set owner [registry::entry owner $file] 574 575 if {$owner != {} && $owner != $port} { 576 # deactivate conflicting port if it is replaced_by this one 577 set result [mportlookup [$owner name]] 578 array unset portinfo 579 array set portinfo [lindex $result 1] 580 if {[info exists portinfo(replaced_by)] && [lsearch -regexp $portinfo(replaced_by) "(?i)^[$port name]\$"] != -1} { 581 # we'll deactivate the owner later, but before activating our files 582 set todeactivate($owner) yes 583 set owner "replaced" 439 } 440 441 if {$owner != "replaced"} { 442 if { [string is true -strict $force] } { 443 # if we're forcing the activation, then we move any existing 444 # files to a backup file, both in the filesystem and in the 445 # registry 446 if { [file exists $file] } { 447 set bakfile "${file}${baksuffix}" 448 ui_warn "File $file already exists. Moving to: $bakfile." 449 file rename -force -- $file $bakfile 450 lappend backups $file 451 } 452 if { $owner != {} } { 453 $owner deactivate [list $file] 454 $owner activate [list $file] [list "${file}${baksuffix}"] 455 } 456 } else { 457 # if we're not forcing the activation, then we bail out if 458 # we find any files that already exist, or have entries in 459 # the registry 460 if { $owner != {} && $owner != $port } { 461 throw registry::image-error "Image error: $file is being used by the active [$owner name] port. Please deactivate this port first, or use 'port -f activate [$port name]' to force the activation." 462 } elseif { $owner == {} && ![catch {file type $file}] } { 463 throw registry::image-error "Image error: $file already exists and does not belong to a registered port. Unable to activate port [$port name]. Use 'port -f activate [$port name]' to force the activation." 584 464 } 585 465 } 586 587 if {$owner != "replaced"} { 588 if { [string is true -strict $force] } { 589 # if we're forcing the activation, then we move any existing 590 # files to a backup file, both in the filesystem and in the 591 # registry 592 if { [file exists $file] } { 593 set bakfile "${file}${baksuffix}" 594 ui_warn "File $file already exists. Moving to: $bakfile." 595 file rename -force -- $file $bakfile 596 lappend backups $file 597 } 598 if { $owner != {} } { 599 $owner deactivate [list $file] 600 $owner activate [list $file] [list "${file}${baksuffix}"] 601 } 602 } else { 603 # if we're not forcing the activation, then we bail out if 604 # we find any files that already exist, or have entries in 605 # the registry 606 if { $owner != {} && $owner != $port } { 607 throw registry::image-error "Image error: $file is being used by the active [$owner name] port. Please deactivate this port first, or use 'port -f activate [$port name]' to force the activation." 608 } elseif { $owner == {} && ![catch {file type $file}] } { 609 throw registry::image-error "Image error: $file already exists and does not belong to a registered port. Unable to activate port [$port name]. Use 'port -f activate [$port name]' to force the activation." 610 } 611 } 612 } 613 614 # Split out the filename's subpaths and add them to the 615 # imagefile list. 616 # We need directories first to make sure they will be there 617 # before links. However, because file mkdir creates all parent 618 # directories, we don't need to have them sorted from root to 619 # subpaths. We do need, nevertheless, all sub paths to make sure 620 # we'll set the directory attributes properly for all 621 # directories. 622 set directory [file dirname $file] 623 while { [lsearch -exact $files $directory] == -1 } { 624 lappend files $directory 625 set directory [file dirname $directory] 626 } 627 628 # Also add the filename to the imagefile list. 629 lappend files $file 630 } 631 } 632 633 # deactivate ports replaced_by this one 634 foreach owner [array names todeactivate] { 635 if {$noexec || ![registry::run_target $owner deactivate [list ports_nodepcheck 1]]} { 636 deactivate [$owner name] "" [list ports_nodepcheck 1] 637 } 638 } 639 640 # Sort the list in forward order, removing duplicates. 641 # Since the list is sorted in forward order, we're sure that 642 # directories are before their elements. 643 # We don't have to do this as mentioned above, but it makes the 644 # debug output of activate make more sense. 645 set files [lsort -increasing -unique $files] 646 set rollback_filelist {} 647 648 registry::write { 649 # Activate it, and catch errors so we can roll-back 650 try { 651 $port activate $imagefiles 652 foreach file $files { 653 if {[_activate_file "${extracted_dir}${file}" $file] == 1} { 654 lappend rollback_filelist $file 655 } 656 } 657 } catch {*} { 658 ui_debug "Activation failed, rolling back." 659 # can't do it here since we're already inside a transaction 660 set deactivate_this yes 661 throw 662 } 663 } 664 } catch {*} { 665 # roll back activation of this port 666 if {[info exists deactivate_this]} { 667 _deactivate_contents $port $rollback_filelist yes yes 668 } 669 # if any errors occurred, move backed-up files back to their original 670 # locations, then rethrow the error. Transaction rollback will take care 671 # of this in the registry. 672 foreach file $backups { 673 file rename -force -- "${file}${baksuffix}" $file 674 } 675 # reactivate deactivated ports 676 foreach entry [array names todeactivate] { 677 if {[$entry state] == "imaged" && ($noexec || ![registry::run_target $entry activate ""])} { 678 set pvers "[$entry version]_[$entry revision][$entry variants]" 679 activate [$entry name] $pvers [list ports_activate_no-exec $noexec] 680 } 681 } 682 # remove temp image dir 683 file delete -force $extracted_dir 684 throw 685 } 686 } else { 687 # registry1.0 688 set deactivated [list] 689 foreach file $imagefiles { 690 set srcfile "${extracted_dir}${file}" 691 692 # To be able to install links, we test if we can lstat the file to 693 # figure out if the source file exists (file exists will return 694 # false for symlinks on files that do not exist) 695 if { [catch {file lstat $srcfile dummystatvar}] } { 696 file delete -force $extracted_dir 697 return -code error "Image error: Source file $srcfile does not appear to exist (cannot lstat it). Unable to activate port $name." 698 } 699 700 set port [registry::file_registered $file] 701 702 if {$port != 0 && $port != $name} { 703 # deactivate conflicting port if it is replaced_by this one 704 if {[catch {mportlookup $port} result]} { 705 global errorInfo 706 ui_debug "$errorInfo" 707 file delete -force $extracted_dir 708 return -code error "port lookup failed: $result" 709 } 710 array unset portinfo 711 array set portinfo [lindex $result 1] 712 if {[info exists portinfo(replaced_by)] && [lsearch -regexp $portinfo(replaced_by) "(?i)^${name}\$"] != -1} { 713 lappend deactivated [lindex [registry::active $port] 0] 714 deactivate $port "" "" 715 set port 0 716 } 717 } 718 719 if { $port != 0 && $force != 1 && $port != $name } { 720 file delete -force $extracted_dir 721 return -code error "Image error: $file is being used by the active $port port. Please deactivate this port first, or use 'port -f activate $name' to force the activation." 722 } elseif { [file exists $file] && $force != 1 } { 723 file delete -force $extracted_dir 724 return -code error "Image error: $file already exists and does not belong to a registered port. Unable to activate port $name. Use 'port -f activate $name' to force the activation." 725 } elseif { $force == 1 && [file exists $file] || $port != 0 } { 726 set bakfile "${file}${baksuffix}" 727 728 if {[file exists $file]} { 729 ui_warn "File $file already exists. Moving to: $bakfile." 730 file rename -force -- $file $bakfile 731 lappend backups $file 732 } 733 734 if { $port != 0 } { 735 set bakport [registry::file_registered $file] 736 registry::unregister_file $file 737 if {[file exists $bakfile]} { 738 registry::register_file $bakfile $bakport 739 } 740 } 741 } 742 743 # Split out the filename's subpaths and add them to the imagefile list. 744 # We need directories first to make sure they will be there before 745 # links. However, because file mkdir creates all parent directories, 746 # we don't need to have them sorted from root to subpaths. We do need, 747 # nevertheless, all sub paths to make sure we'll set the directory 748 # attributes properly for all directories. 749 set directory [file dirname $file] 750 while { [lsearch -exact $files $directory] == -1 } { 751 lappend files $directory 752 set directory [file dirname $directory] 753 } 754 755 # Also add the filename to the imagefile list. 756 lappend files $file 757 } 758 registry::write_file_map 466 } 467 468 # Split out the filename's subpaths and add them to the 469 # imagefile list. 470 # We need directories first to make sure they will be there 471 # before links. However, because file mkdir creates all parent 472 # directories, we don't need to have them sorted from root to 473 # subpaths. We do need, nevertheless, all sub paths to make sure 474 # we'll set the directory attributes properly for all 475 # directories. 476 set directory [file dirname $file] 477 while { [lsearch -exact $files $directory] == -1 } { 478 lappend files $directory 479 set directory [file dirname $directory] 480 } 481 482 # Also add the filename to the imagefile list. 483 lappend files $file 484 } 485 } 486 487 # deactivate ports replaced_by this one 488 foreach owner [array names todeactivate] { 489 if {$noexec || ![registry::run_target $owner deactivate [list ports_nodepcheck 1]]} { 490 deactivate [$owner name] "" [list ports_nodepcheck 1] 491 } 492 } 759 493 760 494 # Sort the list in forward order, removing duplicates. 761 # Since the list is sorted in forward order, we're sure that directories762 # are before their elements.495 # Since the list is sorted in forward order, we're sure that 496 # directories are before their elements. 763 497 # We don't have to do this as mentioned above, but it makes the 764 498 # debug output of activate make more sense. … … 766 500 set rollback_filelist {} 767 501 768 # Activate it, and catch errors so we can roll-back 769 if { [catch { foreach file $files { 770 if {[_activate_file "${extracted_dir}${file}" $file] == 1} { 771 lappend rollback_filelist $file 772 } 773 }} result]} { 774 ui_debug "Activation failed, rolling back." 775 _deactivate_contents $name $rollback_filelist yes yes 776 # return backed up files to their old locations 777 foreach f $backups { 778 set bakfile "${f}${baksuffix}" 779 set bakport [registry::file_registered $bakfile] 780 if {$bakport != 0} { 781 registry::unregister_file $bakfile 782 registry::register_file $f $bakport 783 } 784 file rename -force -- $bakfile $file 785 } 786 # reactivate deactivated ports 787 foreach entry $deactivated { 788 set pname [lindex $entry 0] 789 set pvers "[lindex $entry 1]_[lindex $entry 2][lindex $entry 3]" 790 activate $pname $pvers "" 791 } 792 registry::write_file_map 793 794 file delete -force $extracted_dir 795 return -code error $result 796 } 502 registry::write { 503 # Activate it, and catch errors so we can roll-back 504 try { 505 $port activate $imagefiles 506 foreach file $files { 507 if {[_activate_file "${extracted_dir}${file}" $file] == 1} { 508 lappend rollback_filelist $file 509 } 510 } 511 } catch {*} { 512 ui_debug "Activation failed, rolling back." 513 # can't do it here since we're already inside a transaction 514 set deactivate_this yes 515 throw 516 } 517 } 518 } catch {*} { 519 # roll back activation of this port 520 if {[info exists deactivate_this]} { 521 _deactivate_contents $port $rollback_filelist yes yes 522 } 523 # if any errors occurred, move backed-up files back to their original 524 # locations, then rethrow the error. Transaction rollback will take care 525 # of this in the registry. 526 foreach file $backups { 527 file rename -force -- "${file}${baksuffix}" $file 528 } 529 # reactivate deactivated ports 530 foreach entry [array names todeactivate] { 531 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] 534 } 535 } 536 # remove temp image dir 537 file delete -force $extracted_dir 538 throw 797 539 } 798 540 file delete -force $extracted_dir … … 818 560 819 561 proc _deactivate_contents {port imagefiles {force 0} {rollback 0}} { 820 variable use_reg2821 562 set files [list] 822 563 … … 853 594 854 595 # Remove all elements. 855 if { $use_reg2 &&!$rollback} {596 if {!$rollback} { 856 597 registry::write { 857 598 $port deactivate $imagefiles -
trunk/base/src/registry2.0/portuninstall.tcl
r78086 r79070 43 43 proc uninstall {portname {v ""} optionslist} { 44 44 global uninstall.force uninstall.nochecksum UI_PREFIX \ 45 macports:: registry.format macports::portimagefilepath45 macports::portimagefilepath 46 46 array set options $optionslist 47 47 … … 57 57 set options(ports_deactivate_no-exec) $options(ports_uninstall_no-exec) 58 58 } 59 # check which registry API to use 60 set use_reg2 [string equal ${macports::registry.format} "receipt_sqlite"] 61 62 if {$use_reg2} { 63 if { [registry::decode_spec $v version revision variants] } { 64 set ilist [registry::entry imaged $portname $version $revision $variants] 65 set valid 1 66 } else { 67 set valid [string equal $v {}] 68 set ilist [registry::entry imaged $portname] 69 } 70 } else { 71 set ilist [registry::installed $portname $v] 59 60 if { [registry::decode_spec $v version revision variants] } { 61 set ilist [registry::entry imaged $portname $version $revision $variants] 72 62 set valid 1 63 } else { 64 set valid [string equal $v {}] 65 set ilist [registry::entry imaged $portname] 73 66 } 74 67 if { [llength $ilist] > 1 } { 75 68 # set portname again since the one we were passed may not have had the correct case 76 if {$use_reg2} { 77 set portname [[lindex $ilist 0] name] 78 } else { 79 set portname [lindex [lindex $ilist 0] 0] 80 } 69 set portname [[lindex $ilist 0] name] 81 70 ui_msg "$UI_PREFIX [msgcat::mc "The following versions of $portname are currently installed:"]" 82 71 foreach i [portlist_sortint $ilist] { 83 if {$use_reg2} { 84 set ispec "[$i version]_[$i revision][$i variants]" 85 if { [string equal [$i state] installed] } { 86 ui_msg "$UI_PREFIX [format [msgcat::mc " %s @%s (active)"] [$i name] $ispec]" 87 } else { 88 ui_msg "$UI_PREFIX [format [msgcat::mc " %s @%s"] [$i name] $ispec]" 89 } 72 set ispec "[$i version]_[$i revision][$i variants]" 73 if { [string equal [$i state] installed] } { 74 ui_msg "$UI_PREFIX [format [msgcat::mc " %s @%s (active)"] [$i name] $ispec]" 90 75 } else { 91 set iname [lindex $i 0] 92 set iversion [lindex $i 1] 93 set irevision [lindex $i 2] 94 set ivariants [lindex $i 3] 95 set iactive [lindex $i 4] 96 if { $iactive == 1 } { 97 ui_msg "$UI_PREFIX [format [msgcat::mc " %s @%s_%s%s (active)"] $iname $iversion $irevision $ivariants]" 98 } else { 99 ui_msg "$UI_PREFIX [format [msgcat::mc " %s @%s_%s%s"] $iname $iversion $irevision $ivariants]" 100 } 76 ui_msg "$UI_PREFIX [format [msgcat::mc " %s @%s"] [$i name] $ispec]" 101 77 } 102 78 } … … 107 83 } 108 84 } elseif { [llength $ilist] == 1 } { 109 if {$use_reg2} { 110 set port [lindex $ilist 0] 111 set version [$port version] 112 set revision [$port revision] 113 set variants [$port variants] 114 } else { 115 set version [lindex [lindex $ilist 0] 1] 116 set revision [lindex [lindex $ilist 0] 2] 117 set variants [lindex [lindex $ilist 0] 3] 118 set active [lindex [lindex $ilist 0] 4] 119 } 85 set port [lindex $ilist 0] 86 set version [$port version] 87 set revision [$port revision] 88 set variants [$port variants] 120 89 if {$v == ""} { 121 90 set v "${version}_${revision}${variants}" … … 125 94 } 126 95 127 if {$use_reg2} { 128 # uninstall dependents if requested 129 if {[info exists options(ports_uninstall_follow-dependents)] && $options(ports_uninstall_follow-dependents) eq "yes"} { 130 foreach depport [$port dependents] { 131 # make sure it's still installed, since a previous dep uninstall may have removed it 132 if {[registry::entry exists $depport] && ([$depport state] == "imaged" || [$depport state] == "installed")} { 133 if {[info exists options(ports_uninstall_no-exec)] || ![registry::run_target $depport uninstall $optionslist]} { 134 set depname [$depport name] 135 set depver "[$depport version]_[$depport revision][$depport variants]" 136 registry_uninstall::uninstall $depname $depver $optionslist 137 } 138 } 139 } 96 # uninstall dependents if requested 97 if {[info exists options(ports_uninstall_follow-dependents)] && $options(ports_uninstall_follow-dependents) eq "yes"} { 98 foreach depport [$port dependents] { 99 # make sure it's still installed, since a previous dep uninstall may have removed it 100 if {[registry::entry exists $depport] && ([$depport state] == "imaged" || [$depport state] == "installed")} { 101 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 105 } 106 } 107 } 108 } else { 109 # check its dependents 110 registry::check_dependents $port ${uninstall.force} "uninstall" 111 } 112 # if it's active, deactivate it 113 if { [string equal [$port state] installed] } { 114 if {[info exists options(ports_dryrun)] && [string is true -strict $options(ports_dryrun)]} { 115 ui_msg "For $portname @${v}: skipping deactivate (dry run)" 140 116 } else { 141 # check its dependents 142 registry::check_dependents $port ${uninstall.force} "uninstall" 143 } 144 # if it's active, deactivate it 145 if { [string equal [$port state] installed] } { 146 if {[info exists options(ports_dryrun)] && [string is true -strict $options(ports_dryrun)]} { 147 ui_msg "For $portname @${v}: skipping deactivate (dry run)" 148 } else { 149 if {[info exists options(ports_uninstall_no-exec)] || ![registry::run_target $port deactivate $optionslist]} { 150 portimage::deactivate $portname $v [array get options] 151 } 152 } 153 } 154 } else { 155 # registry1.0 156 157 # determine if it's the only installed port with that name or not. 158 if {$v == ""} { 159 set nb_versions_installed 1 160 } else { 161 set ilist [registry::installed $portname ""] 162 set nb_versions_installed [llength $ilist] 163 } 164 165 set ref [registry::open_entry $portname $version $revision $variants] 166 167 # Check and make sure no ports depend on this one 168 registry::open_dep_map 169 set deplist [registry::list_dependents $portname $version $revision $variants] 170 if { [llength $deplist] > 0 } { 171 set dl [list] 172 # Check the deps first 173 foreach dep $deplist { 174 set depport [lindex $dep 2] 175 ui_debug "$depport depends on this port" 176 if {[registry::entry_exists_for_name $depport]} { 177 lappend dl $depport 178 } 179 } 180 # Now see if we need to error 181 if { [llength $dl] > 0 } { 182 if {[info exists options(ports_uninstall_follow-dependents)] && $options(ports_uninstall_follow-dependents) eq "yes"} { 183 foreach depport $dl { 184 # make sure it's still installed, since a previous dep uninstall may have removed it 185 if {[registry::entry_exists_for_name $depport]} { 186 registry_uninstall::uninstall $depport "" $optionslist 187 } 188 } 189 } else { 190 # will need to change this when we get version/variant dependencies 191 if {$nb_versions_installed == 1 || $active == 1} { 192 ui_msg "$UI_PREFIX [format [msgcat::mc "Unable to uninstall %s %s_%s%s, the following ports depend on it:"] $portname $version $revision $variants]" 193 foreach depport $dl { 194 ui_msg "$UI_PREFIX [format [msgcat::mc " %s"] $depport]" 195 } 196 if { [string is true -strict ${uninstall.force}] } { 197 ui_warn "Uninstall forced. Proceeding despite dependencies." 198 } else { 199 return -code error "Please uninstall the ports that depend on $portname first." 200 } 201 } 202 } 203 } 204 } 205 206 if { [registry::property_retrieve $ref active] == 1} { 207 if {[info exists options(ports_dryrun)] && [string is true -strict $options(ports_dryrun)]} { 208 ui_msg "For $portname @${version}_${revision}${variants}: skipping deactivate (dry run)" 209 } else { 210 portimage::deactivate $portname ${version}_${revision}${variants} $optionslist 211 } 212 } 213 } 214 215 if {$use_reg2} { 216 set ref $port 217 } 117 if {[info exists options(ports_uninstall_no-exec)] || ![registry::run_target $port deactivate $optionslist]} { 118 portimage::deactivate $portname $v [array get options] 119 } 120 } 121 } 122 123 set ref $port 218 124 219 125 # note deps before we uninstall if we're going to uninstall them too … … 222 128 set all_dependencies {} 223 129 # look up deps from the saved portfile if possible 224 if { $use_reg2 &&![catch {set mport [mportopen_installed [$port name] [$port version] [$port revision] [$port variants] $optionslist]}]} {130 if {![catch {set mport [mportopen_installed [$port name] [$port version] [$port revision] [$port variants] $optionslist]}]} { 225 131 array set depportinfo [mportinfo $mport] 226 132 mportclose_installed $mport … … 277 183 } else { 278 184 ui_msg "$UI_PREFIX [format [msgcat::mc "Uninstalling %s @%s"] $portname $v]" 279 280 if {!$use_reg2} { 281 # Look to see if the port has registered an uninstall procedure 282 set uninstall [registry::property_retrieve $ref pkg_uninstall] 283 if { $uninstall != 0 } { 284 if {![catch {eval [string map { \\n \n } $uninstall]} err]} { 285 ui_info "Executing pkg_uninstall procedure" 286 if {[catch {pkg_uninstall $portname "${version}_${revision}${variants}" } err]} { 287 ui_error [format [msgcat::mc "Error executing pkg_uninstall procedure: %s"] $err] 288 } 289 } else { 290 global errorInfo 291 ui_debug "$errorInfo" 292 ui_error [format [msgcat::mc "Could not evaluate pkg_uninstall procedure: %s"] $err] 293 } 294 } 295 296 # Remove the port from the dep_map if only one version was installed. 297 # This is a temporary fix for a deeper problem that is that the dependency 298 # map doesn't take the port version into account (but should). 299 # Fixing it means transitioning to a new dependency map format. 300 if {$nb_versions_installed == 1} { 301 registry::unregister_dependencies $portname 302 } 303 } 304 185 305 186 # Get the full path to the image file 306 187 set imagefile [registry::property_retrieve $ref location] … … 310 191 catch {file delete [file dirname $imagefile]} 311 192 312 if {$use_reg2} { 313 registry::entry delete $port 314 } else { 315 ui_info "$UI_PREFIX [format [msgcat::mc "Uninstall is removing %s from the port registry."] $portname]" 316 registry::delete_entry $ref 317 } 193 registry::entry delete $port 318 194 } 319 195 … … 331 207 if {[llength [registry::list_dependents $dep $iversion $irevision $ivariants]] == 0} { 332 208 set regref [registry::open_entry $dep $iversion $irevision $ivariants [lindex $i 5]] 333 if {![registry::property_retrieve $regref requested] && ( !$use_reg2 ||[info exists options(ports_uninstall_no-exec)] || ![registry::run_target $regref uninstall $optionslist])} {209 if {![registry::property_retrieve $regref requested] && ([info exists options(ports_uninstall_no-exec)] || ![registry::run_target $regref uninstall $optionslist])} { 334 210 set depver "${iversion}_${irevision}${ivariants}" 335 211 registry_uninstall::uninstall $dep $depver $optionslist
Note: See TracChangeset
for help on using the changeset viewer.

