[41040] branches/variant-descs-14482/base/src/macports1.0/macports.tcl

raimue at macports.org raimue at macports.org
Tue Oct 21 04:06:40 PDT 2008


Revision: 41040
          http://trac.macports.org/changeset/41040
Author:   raimue at macports.org
Date:     2008-10-21 04:06:39 -0700 (Tue, 21 Oct 2008)
Log Message:
-----------
macports/macport.tcl:
 * New flag "default" for sources to indicate fallback for resources (group)
 * Add parameter to getsourceconfigdir to get path for a requested file

Modified Paths:
--------------
    branches/variant-descs-14482/base/src/macports1.0/macports.tcl

Modified: branches/variant-descs-14482/base/src/macports1.0/macports.tcl
===================================================================
--- branches/variant-descs-14482/base/src/macports1.0/macports.tcl	2008-10-21 10:57:39 UTC (rev 41039)
+++ branches/variant-descs-14482/base/src/macports1.0/macports.tcl	2008-10-21 11:06:39 UTC (rev 41040)
@@ -327,6 +327,7 @@
     global macports::registry.format
     global macports::registry.path
     global macports::sources
+    global macports::sources_default
     global macports::sources_conf
     global macports::destroot_umask
     global macports::libpath
@@ -418,9 +419,12 @@
             if {[regexp {^([\w-]+://\S+)(?:\s+\[(\w+(?:,\w+)*)\])?$} $line _ url flags]} {
                 set flags [split $flags ,]
                 foreach flag $flags {
-                    if {[lsearch -exact [list nosync] $flag] == -1} {
+                    if {[lsearch -exact [list nosync default] $flag] == -1} {
                         ui_warn "$sources_conf source '$line' specifies invalid flag '$flag'"
                     }
+                    if {$flag == "default"} {
+                        set sources_default [concat [list $url] $flags]
+                    }
                 }
                 lappend sources [concat [list $url] $flags]
             } else {
@@ -900,21 +904,24 @@
 # Get the path to the .resources directory of the source
 #
 # @param url port url
-# @return path to the .resources directory or an empty string if the protocol does \
-#         not support .resources
-proc macports::getsourceconfigdir {url} {
-    if {[catch {getprotocol $url} protocol]} {
-        return ""
-    }
+# @return path to the .resources directory or the path to the fallback
+proc macports::getsourceconfigdir {url {path ""}} {
+    global macports::sources_default
 
+    set protocol [getprotocol $url]
+
     switch -- ${protocol} {
         file {
-            return [file normalize [file join [getportdir $url] .. .. .resources]]
+            set proposedpath [file normalize [file join [getportdir $url] .. .. .resources $path]]
         }
-        default {
-            return ""
-        }
     }
+
+    if {[file exists $proposedpath]} {
+        return $proposedpath
+    }
+
+    # fallback
+    return [file join [getportdir [lindex ${sources_default} 0]] .resources $path]
 }
 
 # dportopen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20081021/0444dac5/attachment.html 


More information about the macports-changes mailing list