Ticket #34933: getportresourcepath.patch

File getportresourcepath.patch, 2.0 KB (added by seanfarley (Sean Farley), 12 years ago)
  • base/src/macports1.0/macports.tcl

    # HG changeset patch
    # User Sean Farley <sean@mcs.anl.gov>
    # Date 1340403602 18000
    # Node ID e4006d582ebd359a125a3b512e40e086e5dfde1a
    # Parent  80a5bfe7474dfcedb25231776997b6f95bceff7e
    base: loop through sources before returning the default path in macports::getportresourcepath
    
    diff --git a/base/src/macports1.0/macports.tcl b/base/src/macports1.0/macports.tcl
    a b  
    15051505# @param url port url
    15061506# @param path path in _resources we are interested in
    15071507# @param fallback fall back to the default source tree
    15081508# @return path to the _resources directory or the path to the fallback
    15091509proc macports::getportresourcepath {url {path ""} {fallback yes}} {
    1510     global macports::sources_default
     1510    global macports::sources_default macports::sources
    15111511
    15121512    set protocol [getprotocol $url]
    15131513
    15141514    switch -- ${protocol} {
    15151515        file {
     
    15211521    }
    15221522
    15231523    # append requested path
    15241524    set proposedpath [file join $proposedpath _resources $path]
    15251525
     1526    set oldpath $proposedpath
     1527    if {![file exists $proposedpath]} {
     1528        foreach source $sources {
     1529            set protocol [getprotocol $source]
     1530
     1531            switch -- ${protocol} {
     1532                file {
     1533                    set proposedpath [file normalize [file join [getportdir $source]]]
     1534                }
     1535                default {
     1536                    set proposedpath [getsourcepath $source]
     1537                }
     1538            }
     1539
     1540            # append requested path
     1541            set proposedpath [file join $proposedpath _resources $path]
     1542            if {[file exists $proposedpath]} {
     1543                return $proposedpath
     1544            }
     1545        }
     1546    }
     1547
    15261548    if {$fallback == "yes" && ![file exists $proposedpath]} {
    15271549        return [getdefaultportresourcepath $path]
    15281550    }
    15291551
    1530     return $proposedpath
     1552    # if we got here return the original path
     1553    return $oldpath
    15311554}
    15321555
    15331556##
    15341557# Get the path to the _resources directory of the default source
    15351558#