Permalink
Browse files
Add a port command check before restoring
Loading branch information
@@ -4505,8 +4505,7 @@ proc macports::snapshot_main {opts} {
# Returns:
# 0 on successful execution.
snapshot::main $opts
return 0
return [snapshot::main $opts ]
}
# restores a snapshot.
@@ -4519,8 +4518,7 @@ proc macports::restore_main {opts} {
# Returns:
# 0 on successful execution.
restore::main $opts
return 0
return [restore::main $opts ]
}
proc macports::migrate_main {opts} {
@@ -55,7 +55,7 @@ namespace eval migrate {
ui_msg " Done: snapshot '$id ':'$note ' created at $datetime "
if {[info exists macports::ui_options(questions_yesno)]} {
set msg " Migration will first uninstall all the installed ports and then reinstall."
set msg " Migration will first uninstall all the installed ports, upgrade MacPorts and then reinstall them again ."
set retvalue [$macports::ui_options(questions_yesno) $msg " MigrationPrompt" " " {y} 0 " Would you like to continue?" ]
if {$retvalue == 1} {
# quit as user answered 'no'
@@ -67,7 +67,7 @@ namespace eval migrate {
ui_msg " Uninstalling all ports.."
uninstall_installed [registry ::entry imaged]
ui_msg " Upgrading macports .."
ui_msg " Upgrading MacPorts .."
upgrade_port_command
ui_msg " Fetching ports to install.."
@@ -54,13 +54,33 @@ namespace eval restore {
}
}
if {![check_port_command]} {
return -code error " OS platform mismatch"
}
ui_msg " :: Deactivating all ports installed.."
deactivate_all
ui_msg " :: Restoring the selected snapshot.."
restore_state [$snapshot ports]
}
proc check_port_command {} {
global tcl_platform
set os_version $tcl_platform(osVersion)
set os_major [lindex [split $os_version .] 0]
set os_platform [string tolower $tcl_platform(os) ]
# Check that the current pla tform is the one we were configured for, otherwise need to do migration
if {($os_platform ne $macports::autoconf::os_platform ) || ($os_major != $macports::autoconf::os_major )} {
ui_error " Current platform \" $os_platform $os_major \" does not match expected platform \" $macports::autoconf::os_platform $macports::autoconf::os_major \" "
ui_error " If you upgraded your OS or changed the hardware architecture, you need to run 'port migrate' instead."
return 0
}
return 1
}
proc fetch_snapshot {snapshot_id} {
return [registry ::snapshot get_by_id $snapshot_id ]
}
@@ -35,7 +35,7 @@ package require registry 1.0
namespace eval snapshot {
proc main {opts} {
# The main function. Handles all the calls to the correct functions .
# Function to create a snapshot of the current state of ports .
#
# Args:
# opts - The options passed in.
@@ -52,6 +52,7 @@ namespace eval snapshot {
} else {
set note " snapshot created for migration"
}
# TODO: catch
set snapshot [registry ::snapshot create $note ]
}
return $snapshot
@@ -2826,19 +2826,16 @@ proc action_reclaim { action portlist opts } {
}
proc action_snapshot { action portlist opts} {
macports::snapshot_main $opts
return 0
proc action_snapshot { action portlist opts } {
return [macports::snapshot_main $opts ]
}
proc action_restore { action portlist opts} {
macports::restore_main $opts
return 0
proc action_restore { action portlist opts } {
return [macports::restore_main $opts ]
}
proc action_migrate { action portlist opts} {
macports::migrate_main $opts
return 0
proc action_migrate { action portlist opts } {
return [macports::migrate_main $opts ]
}
proc action_upgrade { action portlist opts } {
Toggle all file notes