[47314] trunk/base/src
raimue at macports.org
raimue at macports.org
Wed Feb 25 14:40:48 PST 2009
Revision: 47314
http://trac.macports.org/changeset/47314
Author: raimue at macports.org
Date: 2009-02-25 14:40:47 -0800 (Wed, 25 Feb 2009)
Log Message:
-----------
macports1.0/macports.tcl, port1.0/portutil.tcl:
Allow fallback to the default source tree for specific variant descriptions,
not only the whole file. If no variant description is found in the
variant_description.conf of the current source tree, it will be looked up in
the variant_descriptions.conf of the default source tree.
Modified Paths:
--------------
trunk/base/src/macports1.0/macports.tcl
trunk/base/src/port1.0/portutil.tcl
Modified: trunk/base/src/macports1.0/macports.tcl
===================================================================
--- trunk/base/src/macports1.0/macports.tcl 2009-02-25 22:33:45 UTC (rev 47313)
+++ trunk/base/src/macports1.0/macports.tcl 2009-02-25 22:40:47 UTC (rev 47314)
@@ -794,6 +794,7 @@
$workername alias macports_create_thread macports::create_thread
$workername alias getportworkpath_from_buildpath macports::getportworkpath_from_buildpath
$workername alias getportresourcepath macports::getportresourcepath
+ $workername alias getdefaultportresourcepath macports::getdefaultportresourcepath
$workername alias getprotocol macports::getprotocol
$workername alias getportdir macports::getportdir
@@ -949,8 +950,9 @@
# Get the path to the _resources directory of the source
#
# @param url port url
+# @param fallback fall back to the default source tree
# @return path to the _resources directory or the path to the fallback
-proc macports::getportresourcepath {url {path ""}} {
+proc macports::getportresourcepath {url {path ""} {fallback yes}} {
global macports::sources_default
set protocol [getprotocol $url]
@@ -964,19 +966,31 @@
# append requested path
set proposedpath [file join $proposedpath _resources $path]
- if {![file exists $proposedpath]} {
- # fallback
- set default_source_url [lindex ${sources_default} 0]
- if {[getprotocol $default_source_url] == "file"} {
- set proposedpath [getportdir $default_source_url]
- } else {
- set proposedpath [getsourcepath $default_source_url]
- }
+ if {$fallback == "yes" && ![file exists $proposedpath]} {
+ return [getdefaultportresourcepath $porturl $path]
+ }
- # append requested path
- set proposedpath [file join $proposedpath _resources $path]
+ return $proposedpath
+}
+
+##
+# Get the path to the _resources directory of the default source
+#
+# @param url port url
+# @return path to the _resources directory of the default source
+proc macports::getdefaultportresourcepath {url {path ""}} {
+ global macports::sources_default
+
+ set default_source_url [lindex ${sources_default} 0]
+ if {[getprotocol $default_source_url] == "file"} {
+ set proposedpath [getportdir $default_source_url]
+ } else {
+ set proposedpath [getsourcepath $default_source_url]
}
+ # append requested path
+ set proposedpath [file join $proposedpath _resources $path]
+
return $proposedpath
}
Modified: trunk/base/src/port1.0/portutil.tcl
===================================================================
--- trunk/base/src/port1.0/portutil.tcl 2009-02-25 22:33:45 UTC (rev 47313)
+++ trunk/base/src/port1.0/portutil.tcl 2009-02-25 22:40:47 UTC (rev 47314)
@@ -550,15 +550,14 @@
}
##
-# Get description for a variant from global descriptions file
+# Load the global description file for a port tree
#
-# @param porturl url to a port
-# @param variant name
-# @return description from descriptions file or an empty string
-proc variant_desc {porturl variant} {
+# @param descfile path to the descriptions file
+proc load_variant_desc_file {descfile} {
global variant_descs_global
- set descfile [getportresourcepath $porturl "port1.0/variant_descriptions.conf"]
+ ui_debug "Reading variant descriptions from $descfile"
+
if {![info exists variant_descs_global($descfile)]} {
set variant_descs_global($descfile) yes
@@ -581,10 +580,30 @@
close $fd
}
}
+}
+##
+# 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 variant_desc {porturl variant} {
+ global variant_descs_global
+
+ set descfile [getportresourcepath $porturl "port1.0/variant_descriptions.conf" no]
+ load_variant_desc_file $descfile
+
if {[info exists variant_descs_global(${descfile}_${variant})]} {
return $variant_descs_global(${descfile}_${variant})
} else {
+ set descfile [getdefaultportresourcepath $porturl "port1.0/variant_descriptions.conf"]
+ load_variant_desc_file $descfile
+
+ if {[info exists variant_descs_global(${descfile}_${variant})]} {
+ return $variant_descs_global(${descfile}_${variant})
+ }
+
return ""
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090225/f55b8e20/attachment.html>
More information about the macports-changes
mailing list