Skip to content

Commit

Permalink
macports/restore: Use snapshot::diff to display summary
Browse files Browse the repository at this point in the history
At the end of migration, show a summary of which ports failed to
install, or which (requested) ports were installed, for example, with
changed variants due to a change in default variants.

This message should eventually be extended with information how to
re-attempt migration by re-running 'port restore' as well a pointer on
how to run 'port snapshot --diff <id> --all' to see all differences.

Additionally, the message should recommend running cleanup steps such as
reclaim and uninstall inactive.
  • Loading branch information
neverpanic committed Mar 25, 2024
1 parent d10fdd6 commit 2a3a7fc
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions src/macports1.0/restore.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,70 @@ namespace eval restore {
set note "Migration finished.\n"
}

array set diff [snapshot::diff $snapshot]

foreach field {added removed changed} {
set result {}
foreach port $diff($field) {
lassign $port _ requested
if {$requested} {
lappend result $port
}
set diff($field) $result
}
}

if {[llength $diff(added)] > 0} {
append note "The following requested ports were additionally installed:\n"
foreach added_port [lsort -ascii -index 0 $diff(added)] {
lassign $added_port name _ _ _ requested_variants
if {$requested_variants ne ""} {
append note " - $name\n"
} else {
append note " - $name $requested_variants\n"
}
}
}

if {[llength $diff(removed)] > 0} {
append note "The following ports could not be restored:\n"
foreach removed_port [lsort -ascii -index 0 $diff(removed)] {
lassign $removed_port name _ _ _ requested_variants
if {$requested_variants ne ""} {
append note " - $name\n"
} else {
append note " - $name $requested_variants\n"
}
if {[info exists failed($name)]} {
lassign $failed($name) type reason
switch $type {
skipped {
append note " Skipped becuase its $reason\n"
}
failed {
append note " Failed to build: $reason\n"
}
}
}
}
}

if {[llength $diff(changed)] > 0} {
append note "The following ports were restored with changes:\n"
foreach changed_port [lsort -ascii -index 0 $diff(changed)] {
lassign $changed_port name _ _ _ requested_variants changes
if {$requested_variants ne ""} {
append note " - $name\n"
} else {
append note " - $name $requested_variants\n"
}
foreach change $changes {
lassign $change field old new
append note " $field changed from '$old' to '$new'\n"
}
}
}

if {[info exists macports::ui_options(notifications_system)]} {
$macports::ui_options(notifications_system) $note
} else {
Expand Down

0 comments on commit 2a3a7fc

Please sign in to comment.