[34469] branches/variant-descs-14482/base/src/port/port.tcl
raimue at macports.org
raimue at macports.org
Mon Feb 25 22:08:09 PST 2008
Revision: 34469
http://trac.macosforge.org/projects/macports/changeset/34469
Author: raimue at macports.org
Date: 2008-02-25 22:08:09 -0800 (Mon, 25 Feb 2008)
Log Message:
-----------
port/port.tcl:
Reading from .config/variant_descriptions actually works
Modified Paths:
--------------
branches/variant-descs-14482/base/src/port/port.tcl
Modified: branches/variant-descs-14482/base/src/port/port.tcl
===================================================================
--- branches/variant-descs-14482/base/src/port/port.tcl 2008-02-26 05:16:32 UTC (rev 34468)
+++ branches/variant-descs-14482/base/src/port/port.tcl 2008-02-26 06:08:09 UTC (rev 34469)
@@ -442,7 +442,38 @@
return $result
}
+##
+# Get description for a variant from global descriptions file
+# @param porturl url to a port
+# @param variant name
+# @return description from descriptions file or an empty string
+proc get_variant_desc {porturl desc} {
+ global variant_descs_global
+ # TODO: find a better way to find the path to .config
+ set sourcepath [file join [macports::getportdir $porturl] .. ..]
+ set sourcepath [file normalize $sourcepath]
+ set descfile [file join $sourcepath .config variant_descriptions]
+ if {![info exists variant_descs_global($sourcepath)]} {
+ set variant_descs_global($sourcepath) yes
+
+ if {[file exists $descfile]} {
+ set fd [open $descfile r]
+ while {[gets $fd line] >= 0} {
+ set variant_descs_global(${sourcepath}_[lindex $line 0]) [join [lrange $line 1 end]]
+ }
+ close $fd
+ }
+ }
+
+ if {[info exists variant_descs_global(${sourcepath}_${desc})]} {
+ return $variant_descs_global(${sourcepath}_${desc})
+ } else {
+ return ""
+ }
+}
+
+
##########################################
# Port selection
##########################################
@@ -1894,8 +1925,13 @@
# print out all the variants
puts "$portname has the variants:"
foreach v $portinfo(variants) {
- if {[info exists descs($v)]} {
- puts "\t$v: [join [string trim $descs($v)]]"
+ if {![info exists descs($v)]} {
+ # if description is not set yet, get it from the global source descriptions file
+ set descs($v) [get_variant_desc $porturl $v]
+ }
+
+ if {[info exists descs($v)] && $descs($v) != ""} {
+ puts "\t$v: [join $descs($v)]"
} else {
puts "\t$v"
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20080225/941a12c6/attachment.html
More information about the macports-changes
mailing list