Changeset 34469


Ignore:
Timestamp:
Feb 26, 2008, 6:08:09 AM (13 years ago)
Author:
raimue@…
Message:

port/port.tcl:
Reading from .config/variant_descriptions actually works

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/variant-descs-14482/base/src/port/port.tcl

    r34420 r34469  
    443443}
    444444
     445##
     446# Get description for a variant from global descriptions file
     447# @param porturl url to a port
     448# @param variant name
     449# @return description from descriptions file or an empty string
     450proc get_variant_desc {porturl desc} {
     451    global variant_descs_global
     452
     453    # TODO: find a better way to find the path to .config
     454    set sourcepath [file join [macports::getportdir $porturl] .. ..]
     455    set sourcepath [file normalize $sourcepath]
     456    set descfile [file join $sourcepath .config variant_descriptions]
     457    if {![info exists variant_descs_global($sourcepath)]} {
     458        set variant_descs_global($sourcepath) yes
     459
     460        if {[file exists $descfile]} {
     461            set fd [open $descfile r]
     462            while {[gets $fd line] >= 0} {
     463                set variant_descs_global(${sourcepath}_[lindex $line 0]) [join [lrange $line 1 end]]
     464            }
     465            close $fd
     466        }
     467    }
     468
     469    if {[info exists variant_descs_global(${sourcepath}_${desc})]} {
     470        return $variant_descs_global(${sourcepath}_${desc})
     471    } else {
     472        return ""
     473    }
     474}
     475
    445476
    446477##########################################
     
    18951926            puts "$portname has the variants:"
    18961927            foreach v $portinfo(variants) {
    1897                 if {[info exists descs($v)]} {
    1898                     puts "\t$v: [join [string trim $descs($v)]]"
     1928                if {![info exists descs($v)]} {
     1929                    # if description is not set yet, get it from the global source descriptions file
     1930                    set descs($v) [get_variant_desc $porturl $v]
     1931                }
     1932
     1933                if {[info exists descs($v)] && $descs($v) != ""} {
     1934                    puts "\t$v: [join $descs($v)]"
    18991935                } else {
    19001936                    puts "\t$v"
Note: See TracChangeset for help on using the changeset viewer.