[67209] trunk/base/src
raimue at macports.org
raimue at macports.org
Sun May 2 13:23:05 PDT 2010
Revision: 67209
http://trac.macports.org/changeset/67209
Author: raimue at macports.org
Date: 2010-05-02 13:23:03 -0700 (Sun, 02 May 2010)
Log Message:
-----------
Handle notes as a usual port option, which allows to use notes-append
Modified Paths:
--------------
trunk/base/src/port/port.tcl
trunk/base/src/port1.0/portactivate.tcl
trunk/base/src/port1.0/portmain.tcl
trunk/base/src/port1.0/portutil.tcl
Modified: trunk/base/src/port/port.tcl
===================================================================
--- trunk/base/src/port/port.tcl 2010-05-02 20:18:04 UTC (rev 67208)
+++ trunk/base/src/port/port.tcl 2010-05-02 20:23:03 UTC (rev 67209)
@@ -2168,7 +2168,9 @@
# Display the notes.
if {$portnotes ne {}} {
ui_notice "$portname has the following notes:"
- puts [wrap $portnotes 0 " " 1]
+ foreach note $portnotes {
+ puts [wrap $note 0 " " 1]
+ }
} else {
puts "$portname has no notes."
}
Modified: trunk/base/src/port1.0/portactivate.tcl
===================================================================
--- trunk/base/src/port1.0/portactivate.tcl 2010-05-02 20:18:04 UTC (rev 67208)
+++ trunk/base/src/port1.0/portactivate.tcl 2010-05-02 20:23:03 UTC (rev 67209)
@@ -62,39 +62,41 @@
}
proc portactivate::activate_main {args} {
- global env name version revision portvariants user_options portnotes
+ global env name version revision portvariants user_options PortInfo
registry_activate $name "${version}_${revision}${portvariants}" [array get user_options]
# Display notes at the end of the activation phase.
- if {[info exists portnotes] && $portnotes ne {}} {
- # If env(COLUMNS) exists, limit each line's width to this width.
- if {[info exists env(COLUMNS)]} {
- set maxlen $env(COLUMNS)
+ if {[info exists PortInfo(notes)] && $PortInfo(notes) ne {}} {
+ ui_msg ""
+ 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)
- ui_msg ""
- foreach line [split $portnotes "\n"] {
- set joiner ""
- set lines ""
- set newline ""
+ foreach line [split $note "\n"] {
+ set joiner ""
+ set lines ""
+ set newline ""
- foreach word [split $line " "] {
- if {[string length $newline] + [string length $word] >= $maxlen} {
+ 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
- set newline ""
- set joiner ""
}
- append newline $joiner $word
- set joiner " "
+ ui_msg [join $lines "\n"]
}
- if {$newline ne {}} {
- lappend lines $newline
- }
- ui_msg [join $lines "\n"]
+ } else {
+ ui_msg $note
}
- ui_msg ""
- } else {
- ui_msg \n$portnotes\n
}
+ ui_msg ""
}
return 0
Modified: trunk/base/src/port1.0/portmain.tcl
===================================================================
--- trunk/base/src/port1.0/portmain.tcl 2010-05-02 20:18:04 UTC (rev 67208)
+++ trunk/base/src/port1.0/portmain.tcl 2010-05-02 20:23:03 UTC (rev 67209)
@@ -45,19 +45,23 @@
# define options
options prefix name version revision epoch categories maintainers
-options long_description description homepage license provides conflicts replaced_by
+options long_description description homepage notes license provides conflicts replaced_by
options worksrcdir filesdir distname portdbpath libpath distpath sources_conf os.platform os.subplatform os.version os.major os.arch os.endian platforms default_variants install.user install.group macosx_deployment_target
options universal_variant os.universal_supported
options supported_archs depends_skip_archcheck
options copy_log_files
options compiler.cpath compiler.library_path
-# Export options via PortInfo
-options_export name version revision epoch categories maintainers platforms description long_description homepage license provides conflicts replaced_by
+# Order of option_proc and option_export matters. Filter before exporting.
# Assign option procedure to default_variants
option_proc default_variants handle_default_variants
+# Handle notes special for better formatting
+option_proc notes handle_option_string
+# Export options via PortInfo
+options_export name version revision epoch categories maintainers platforms description long_description notes homepage license provides conflicts replaced_by
+
default workpath {[getportworkpath_from_buildpath $portbuildpath]}
default prefix /opt/local
default applications_dir /Applications/MacPorts
Modified: trunk/base/src/port1.0/portutil.tcl
===================================================================
--- trunk/base/src/port1.0/portutil.tcl 2010-05-02 20:18:04 UTC (rev 67208)
+++ trunk/base/src/port1.0/portutil.tcl 2010-05-02 20:23:03 UTC (rev 67209)
@@ -447,29 +447,41 @@
}
}
-# Notes are displayed at (1) the end of the activation phase and (2) when
-# action_notes is executed.
-proc notes {args} {
- global PortInfo portnotes
+##
+# Filter options which take strings removing indent to ease Portfile writing
+proc handle_option_string {option action args} {
+ global $option
- # Strip trailing empty lines
- set notes [string trim [join $args] "\n"]
- # Determine indent level
- set indent ""
- for {set i 0} {$i < [string length $notes]} {incr i} {
- set c [string index $notes $i]
- if {$c != " " && $c != "\t"} {
- break
+ switch $action {
+ set {
+ set args [join $args]
+
+ set fulllist {}
+ # args is a list of strings/list
+ foreach arg $args {
+ # Strip trailing empty lines
+ set txt [string trim $arg "\n"]
+
+ # Determine indent level
+ set indent ""
+ for {set i 0} {$i < [string length $txt]} {incr i} {
+ set c [string index $txt $i]
+ if {$c != " " && $c != "\t"} {
+ break
+ }
+ append indent $c
+ }
+ # Remove indent on first line
+ set txt [string replace $txt 0 [expr $i - 1]]
+ # Remove indent on each other line
+ set txt [string map "\"\n$indent\" \"\n\"" $txt]
+
+ lappend fulllist $txt
+ }
+
+ set $option $fulllist
}
- append indent $c
}
- # Remove indent on first line
- set notes [string replace $notes 0 [expr $i - 1]]
- # Remove indent on each other line
- set notes [string map "\"\n$indent\" \"\n\"" $notes]
-
- set PortInfo(notes) $notes
- set portnotes $PortInfo(notes)
}
# variant <provides> [<provides> ...] [requires <requires> [<requires>]]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20100502/78f25f73/attachment-0001.html>
More information about the macports-changes
mailing list