Skip to content
Permalink
Browse files

base: Delay displaying notes for installed ports until the end of the…

… current operation

Mostly written by Jeremy Lavergne (snc).

git-svn-id: https://svn.macports.org/repository/macports/trunk/base@118304 d073be05-634f-4543-b044-5fe20cf6d1d6
  • Loading branch information
neverpanic committed Mar 29, 2014
1 parent cd8f064 commit 8ac08e18ae375a9c91feb0b92a588b1850169a1c
Showing with 84 additions and 34 deletions.
  1. +8 −0 src/macports1.0/macports.tcl
  2. +73 −0 src/port/port.tcl
  3. +3 −34 src/port1.0/portactivate.tcl
@@ -1294,6 +1294,14 @@ proc macports::worker_init {workername portpath porturl portbuildpath options va
$workername alias ui_progress_download $macports::ui_options(progress_download)
}

# notifications callback
if {[info exists macports::ui_options(notifications_append)]} {
$workername alias ui_notifications_append $macports::ui_options(notifications_append)
} else {
# provide a no-op if notifications_append wasn't set. See http://wiki.tcl.tk/3044
$workername alias ui_notifications_append return -level 0
}

$workername alias ui_prefix ui_prefix
$workername alias ui_channels ui_channels

@@ -4639,6 +4639,9 @@ proc process_cmd { argv } {
registry::exclusive_unlock
}

# Print notifications of just-activated ports.
portclient::notifications::display

# semaphore to exit
if {$action_status == -999} break
}
@@ -5167,6 +5170,74 @@ namespace eval portclient::progress {
}
}

namespace eval portclient::notifications {
##
# Ports whose notifications to display; these were either installed
# or requested to be installed.
variable notificationsToPrint
array set notificationsToPrint {}

##
# Add a port to the list for printing notifications.
#
# @param name
# The name of the port.
# @param note
# A list of notes to be stored for the given port.
proc append {name notes} {
variable notificationsToPrint

set notificationsToPrint($name) $notes
}

##
# Print port notifications.
#
proc display {} {
global env
variable notificationsToPrint

# Display notes at the end of the activation phase.
if {[array size notificationsToPrint] > 0} {
ui_notice "---> Some of the ports you installed have notes:"
foreach {name notes} [array get notificationsToPrint] {
ui_notice " $name has the following notes:"

# If env(COLUMNS) exists, limit each line's width to this width.
if {[info exists env(COLUMNS)]} {
set maxlen $env(COLUMNS)

foreach note $notes {
foreach line [split $note "\n"] {
set joiner ""
set lines ""
set newline " "

foreach word [split $line " "] {
if {[string length $newline] + [string length $word] >= $maxlen} {
lappend lines $newline
set newline " "
set joiner ""
}
::append newline $joiner $word
set joiner " "
}
if {$newline ne {}} {
lappend lines $newline
}
ui_notice [join $lines "\n"]
}
}
} else {
foreach note $notes {
ui_notice $note
}
}
}
}
}
}


##########################################
# Main
@@ -5222,6 +5293,8 @@ if {[isatty stdout]
set ui_options(progress_generic) portclient::progress::generic
}

set ui_options(notifications_append) portclient::notifications::append

# Get arguments remaining after option processing
set remaining_args [lrange $cmd_argv $cmd_argn end]

@@ -60,42 +60,11 @@ proc portactivate::activate_start {args} {
}

proc portactivate::activate_main {args} {
global env subport version revision portvariants user_options PortInfo startupitem.autostart UI_PREFIX
global subport version revision portvariants user_options PortInfo

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 {}} {
ui_notice ""
foreach note $PortInfo(notes) {
# If env(COLUMNS) exists, limit each line's width to this width.
if {[info exists env(COLUMNS)]} {
set maxlen $env(COLUMNS)

foreach line [split $note "\n"] {
set joiner ""
set lines ""
set newline ""

foreach word [split $line " "] {
if {[string length $newline] + [string length $word] >= $maxlen} {
lappend lines $newline
set newline ""
set joiner ""
}
append newline $joiner $word
set joiner " "
}
if {$newline ne {}} {
lappend lines $newline
}
ui_notice [join $lines "\n"]
}
} else {
ui_notice $note
}
}
ui_notice ""
if {[info exists PortInfo(notes)] && [llength $PortInfo(notes)] > 0} {
ui_notifications_append $subport $PortInfo(notes)
}

return 0

0 comments on commit 8ac08e1

Please sign in to comment.
You can’t perform that action at this time.