[45686] users/perry/base-bugs_and_notes/src

perry at macports.org perry at macports.org
Mon Jan 19 18:19:30 PST 2009


Revision: 45686
          http://trac.macports.org/changeset/45686
Author:   perry at macports.org
Date:     2009-01-19 18:19:29 -0800 (Mon, 19 Jan 2009)
Log Message:
-----------
perry/base-bugs_and_notes - Added a new Portfile keyword (notes) and action.
* See Ticket #421 for more information.

Modified Paths:
--------------
    users/perry/base-bugs_and_notes/src/port/port.tcl
    users/perry/base-bugs_and_notes/src/port1.0/portactivate.tcl
    users/perry/base-bugs_and_notes/src/port1.0/portutil.tcl

Modified: users/perry/base-bugs_and_notes/src/port/port.tcl
===================================================================
--- users/perry/base-bugs_and_notes/src/port/port.tcl	2009-01-20 00:52:14 UTC (rev 45685)
+++ users/perry/base-bugs_and_notes/src/port/port.tcl	2009-01-20 02:19:29 UTC (rev 45686)
@@ -1694,6 +1694,55 @@
 }
 
 
+proc action_notes { action portlist opts } {
+    if {[require_portlist portlist]} {
+        return 1
+    }
+
+    foreachport $portlist {
+        # Search for the port.
+        if {[catch {mportsearch $portname no exact} result]} {
+            ui_debug $::errorInfo
+            break_softcontinue "The search for '$portname' failed: $result" \
+                               1 status
+        }
+        if {[llength $result] < 2} {
+            break_softcontinue "The port '$portname' was not found" 1 status
+        }
+
+        # Retrieve the port's URL.
+        array unset portinfo
+        array set portinfo [lindex $result 1]
+        set porturl $portinfo(porturl)
+
+        # Retrieve the port's name once more to ensure it has the proper case.
+        set portname $portinfo(name)
+
+        # Open the Portfile associated with this port.
+        if {[catch {set mport [mportopen $porturl [array get options] \
+                                         [array get merged_variations]]} \
+                   result]} {
+            ui_debug $::errorInfo
+            break_softcontinue [concat "The URL '$porturl' could not be" \
+                                       "opened: $result"] 1 status
+        }
+        array unset portinfo
+        array set portinfo [mportinfo $mport]
+        mportclose $mport
+
+        # Display notes.
+        if {[info exists portinfo(notes)] && $portinfo(notes) ne {}} {
+            puts "$portname has the following notes:"
+            # Add indentation.
+            puts -nonewline "    "
+            puts [string map {\n "\n    "} $portinfo(notes)]
+        } else {
+            puts "$portname has no notes."
+        }
+    }
+}
+
+
 proc action_provides { action portlist opts } {
     # In this case, portname is going to be used for the filename... since
     # that is the first argument we expect... perhaps there is a better way
@@ -2802,6 +2851,7 @@
     \
     info        [list action_info           [action_args_const ports]] \
     location    [list action_location       [action_args_const ports]] \
+    notes       [list action_notes          [action_args_const ports]] \
     provides    [list action_provides       [action_args_const strings]] \
     \
     activate    [list action_activate       [action_args_const ports]] \

Modified: users/perry/base-bugs_and_notes/src/port1.0/portactivate.tcl
===================================================================
--- users/perry/base-bugs_and_notes/src/port1.0/portactivate.tcl	2009-01-20 00:52:14 UTC (rev 45685)
+++ users/perry/base-bugs_and_notes/src/port1.0/portactivate.tcl	2009-01-20 02:19:29 UTC (rev 45686)
@@ -49,7 +49,13 @@
 set_ui_prefix
 
 proc activate_main {args} {
-	global portname portversion portrevision portvariants user_options
+	global portname portversion portrevision portvariants user_options portnotes
 	registry_activate $portname ${portversion}_${portrevision}${portvariants} [array get user_options]
+
+    # Display notes at the end of the activation phase.
+    if {[info exists portnotes] && $portnotes ne {}} {
+        ui_msg \n$portnotes\n
+    }
+    
     return 0
 }

Modified: users/perry/base-bugs_and_notes/src/port1.0/portutil.tcl
===================================================================
--- users/perry/base-bugs_and_notes/src/port1.0/portutil.tcl	2009-01-20 00:52:14 UTC (rev 45685)
+++ users/perry/base-bugs_and_notes/src/port1.0/portutil.tcl	2009-01-20 02:19:29 UTC (rev 45686)
@@ -367,6 +367,15 @@
     }
 }
 
+# Notes are displayed at (1) the end of the activation phase and (2) when
+# action_notes is executed.
+proc notes {args} {
+    global PortInfo portnotes
+
+    set PortInfo(notes) [string trim [join $args]]
+    set portnotes       $PortInfo(notes)
+}
+
 # variant <provides> [<provides> ...] [requires <requires> [<requires>]]
 # Portfile level procedure to provide support for declaring variants
 proc variant {args} {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090119/6fbaa63f/attachment.html>


More information about the macports-changes mailing list