Ignore:
Timestamp:
Jan 5, 2004, 2:45:21 AM (15 years ago)
Author:
jkh
Message:

Apply consistent formatting - looking at lines suddenly tabbed out amidst other lines which
were not was annoying me.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/port1.0/portutil.tcl

    r4422 r4453  
    6565
    6666proc option {name args} {
    67         # XXX: right now we just transparently use globals
    68         # eventually this will need to bridge the options between
    69         # the Portfile's interpreter and the target's interpreters.
    70         global $name
    71         if {[llength $args] > 0} {
    72                 ui_debug "setting option $name to $args"
    73                 set $name [lindex $args 0]
    74         }
    75         return [set $name]
     67    # XXX: right now we just transparently use globals
     68    # eventually this will need to bridge the options between
     69    # the Portfile's interpreter and the target's interpreters.
     70    global $name
     71    if {[llength $args] > 0} {
     72        ui_debug "setting option $name to $args"
     73        set $name [lindex $args 0]
     74    }
     75    return [set $name]
    7676}
    7777
     
    8282
    8383proc exists {name} {
    84         # XXX: right now we just transparently use globals
    85         # eventually this will need to bridge the options between
    86         # the Portfile's interpreter and the target's interpreters.
    87         global $name
    88         return [info exists $name]
     84    # XXX: right now we just transparently use globals
     85    # eventually this will need to bridge the options between
     86    # the Portfile's interpreter and the target's interpreters.
     87    global $name
     88    return [info exists $name]
    8989}
    9090
     
    178178proc option_proc_trace {optionName index op} {
    179179    global option_procs
    180         upvar $optionName optionValue
     180    upvar $optionName optionValue
    181181    switch $op {
    182182        w {
     
    303303   
    304304    # mode indicates what the arg is interpreted as.
    305         # possible mode keywords are: requires, conflicts, provides
    306         # The default mode is provides.  Arguments are added to the
    307         # most recently specified mode (left to right).
     305    # possible mode keywords are: requires, conflicts, provides
     306    # The default mode is provides.  Arguments are added to the
     307    # most recently specified mode (left to right).
    308308    set mode "provides"
    309309    foreach arg $args {
    310                 switch -exact $arg {
    311                         provides { set mode "provides" }
    312                         requires { set mode "requires" }
    313                         conflicts { set mode "conflicts" }
    314                         default { ditem_append $ditem $mode $arg }             
     310        switch -exact $arg {
     311            provides { set mode "provides" }
     312            requires { set mode "requires" }
     313            conflicts { set mode "conflicts" }
     314            default { ditem_append $ditem $mode $arg }         
    315315        }
    316316    }
    317317    ditem_key $ditem name "[join [ditem_key $ditem provides] -]"
    318 
     318   
    319319    # make a user procedure named variant-blah-blah
    320320    # we will call this procedure during variant-run
     
    349349proc variant_unset {name} {
    350350    global variations
    351 
     351   
    352352    set variations($name) -
    353353}
     
    358358# be more readable, and support arch and version specifics
    359359proc platform {args} {
    360         global all_variants PortInfo os.platform os.arch os.version
    361         upvar $args upargs
    362 
    363         set len [llength $args]
    364         set code [lindex $args end]
    365         set os [lindex $args 0]
    366         set args [lrange $args 1 [expr $len - 2]]
    367        
    368         set ditem [variant_new "temp-variant"]
    369 
    370         foreach arg $args {
    371                 if {[regexp {(^[0-9]$)} $arg match result]} {
    372                         set release $result
    373                 } elseif {[regexp {([a-zA-Z0-9]*)} $arg match result]} {
    374                         set arch $result
    375                 }
    376         }
    377 
    378         # Add the variant for this platform
    379         set platform $os
    380         if {[info exists release]} { set platform ${platform}_${release} }
    381         if {[info exists arch]} { set platform ${platform}_${arch} }
    382 
    383         variant $platform $code
    384 
    385         # Set the variant if this platform matches the platform we're on
    386         if {[info exists os.platform] && ${os.platform} == $os} {
    387                 set sel_platform $os
    388                 if {[info exists os.version] && [info exists release]} {
    389                         regexp {([0-9]*)[0-9\.]?} ${os.version} match major
    390                         if {$major == $release } {
    391                                 set sel_platform ${sel_platform}_${release}
    392                         }
    393                 }
    394                 if {[info exists os.arch] && [info exists arch] && ${os.arch} == $arch} {
    395                         set sel_platform $arch
    396                 }
    397                 variant_set $sel_platform
    398         }
    399        
     360    global all_variants PortInfo os.platform os.arch os.version
     361    upvar $args upargs
     362   
     363    set len [llength $args]
     364    set code [lindex $args end]
     365    set os [lindex $args 0]
     366    set args [lrange $args 1 [expr $len - 2]]
     367   
     368    set ditem [variant_new "temp-variant"]
     369   
     370    foreach arg $args {
     371        if {[regexp {(^[0-9]$)} $arg match result]} {
     372            set release $result
     373        } elseif {[regexp {([a-zA-Z0-9]*)} $arg match result]} {
     374            set arch $result
     375        }
     376    }
     377   
     378    # Add the variant for this platform
     379    set platform $os
     380    if {[info exists release]} { set platform ${platform}_${release} }
     381    if {[info exists arch]} { set platform ${platform}_${arch} }
     382   
     383    variant $platform $code
     384   
     385    # Set the variant if this platform matches the platform we're on
     386    if {[info exists os.platform] && ${os.platform} == $os} {
     387        set sel_platform $os
     388        if {[info exists os.version] && [info exists release]} {
     389            regexp {([0-9]*)[0-9\.]?} ${os.version} match major
     390            if {$major == $release } {
     391                set sel_platform ${sel_platform}_${release}
     392            }
     393        }
     394        if {[info exists os.arch] && [info exists arch] && ${os.arch} == $arch} {
     395            set sel_platform $arch
     396        }
     397        variant_set $sel_platform
     398    }
     399   
    400400}
    401401
     
    432432        return -code error "no value given for parameter \"file\" to \"reinplace\""
    433433    }
    434 
     434   
    435435    foreach file $args {
    436436        if {[catch {set tmpfile [mkstemp "/tmp/[file tail $file].sed.XXXXXXXX"]} error]} {
     
    443443            set tmpfile [lindex $tmpfile 1]
    444444        }
    445 
     445       
    446446        if {[catch {exec sed $pattern < $file >@ $tmpfd} error]} {
    447447            ui_error "reinplace: $error"
     
    449449            return -code error "reinplace failed"
    450450        }
    451 
     451       
    452452        close $tmpfd
    453 
     453       
    454454        set attributes [file attributes $file]
    455455        # We need to overwrite this file
     
    459459            return -code error "reinplace failed"
    460460        }
    461 
     461       
    462462        if {[catch {exec cp $tmpfile $file} error]} {
    463463            ui_error "reinplace: $error"
     
    482482proc filefindbypath {fname} {
    483483    global distpath filesdir workdir worksrcdir portpath
    484 
     484   
    485485    if {[file readable $portpath/$fname]} {
    486486        return $portpath/$fname
     
    582582    global targets target_state_fd portname
    583583    set dlist $targets
    584            
    585         # Select the subset of targets under $target
     584   
     585    # Select the subset of targets under $target
    586586    if {$target != ""} {
    587587        set matches [dlist_search $dlist provides $target]
    588 
     588       
    589589        if {[llength $matches] > 0} {
    590                         set dlist [dlist_append_dependents $dlist [lindex $matches 0] [list]]
    591                         # Special-case 'all'
    592                 } elseif {$target != "all"} {
    593                         ui_error "unknown target: $target"
     590            set dlist [dlist_append_dependents $dlist [lindex $matches 0] [list]]
     591            # Special-case 'all'
     592        } elseif {$target != "all"} {
     593            ui_error "unknown target: $target"
    594594            return 1
    595595        }
    596596    }
    597        
     597   
    598598    # Restore the state from a previous run.
    599599    set target_state_fd [open_statefile]
    600600   
    601601    set dlist [dlist_eval $dlist "" target_run]
    602 
     602   
    603603    if {[llength $dlist] > 0} {
    604                 # somebody broke!
    605                 set errstring "Warning: the following items did not execute (for $portname):"
    606                 foreach ditem $dlist {
    607                         append errstring " [ditem_key $ditem name]"
    608                 }
    609                 ui_info $errstring
    610                 set result 1
     604        # somebody broke!
     605        set errstring "Warning: the following items did not execute (for $portname):"
     606        foreach ditem $dlist {
     607            append errstring " [ditem_key $ditem name]"
     608        }
     609        ui_info $errstring
     610        set result 1
    611611    } else {
    612                 set result 0
    613     }
    614        
     612        set result 0
     613    }
     614   
    615615    close $target_state_fd
    616616    return $result
     
    628628    set statefile [file join $workpath .darwinports.${portname}.state]
    629629    if {[file exists $statefile]} {
    630                 if {![file writable $statefile]} {
    631                         return -code error "$statefile is not writable - check permission on port directory"
    632                 }
    633                 if {!([info exists ports_ignore_older] && $ports_ignore_older == "yes") && [file mtime $statefile] < [file mtime ${portpath}/Portfile]} {
    634                         ui_msg "Portfile changed since last build; discarding previous state."
    635                         #file delete $statefile
    636                         exec rm -rf [file join $workpath]
    637                         exec mkdir [file join $workpath]
    638                 }
    639         }
    640        
     630        if {![file writable $statefile]} {
     631            return -code error "$statefile is not writable - check permission on port directory"
     632        }
     633        if {!([info exists ports_ignore_older] && $ports_ignore_older == "yes") && [file mtime $statefile] < [file mtime ${portpath}/Portfile]} {
     634            ui_msg "Portfile changed since last build; discarding previous state."
     635            #file delete $statefile
     636            exec rm -rf [file join $workpath]
     637            exec mkdir [file join $workpath]
     638        }
     639    }
     640   
    641641    set fd [open $statefile a+]
    642642    if {[catch {flock $fd -exclusive -noblock} result]} {
     
    658658proc check_statefile {class name fd} {
    659659    global portpath workdir
    660        
     660   
    661661    seek $fd 0
    662662    while {[gets $fd line] >= 0} {
    663                 if {$line == "$class: $name"} {
    664                         return 1
    665                 }
     663        if {$line == "$class: $name"} {
     664            return 1
     665        }
    666666    }
    667667    return 0
     
    672672proc write_statefile {class name fd} {
    673673    if {[check_statefile $class $name $fd]} {
    674                 return 0
     674        return 0
    675675    }
    676676    seek $fd 0 end
     
    682682# Check that recorded selection of variants match the current selection
    683683proc check_statefile_variants {variations fd} {
    684         upvar $variations upvariations
    685        
     684    upvar $variations upvariations
     685   
    686686    seek $fd 0
    687687    while {[gets $fd line] >= 0} {
    688                 if {[regexp "variant: (.*)" $line match name]} {
    689                         set oldvariations([string range $name 1 end]) [string range $name 0 0]
     688        if {[regexp "variant: (.*)" $line match name]} {
     689            set oldvariations([string range $name 1 end]) [string range $name 0 0]
     690        }
     691    }
     692   
     693    set mismatch 0
     694    if {[array size oldvariations] > 0} {
     695        if {[array size oldvariations] != [array size upvariations]} {
     696            set mismatch 1
     697        } else {
     698            foreach key [array names upvariations *] {
     699                if {![info exists oldvariations($key)] || $upvariations($key) != $oldvariations($key)} {
     700                    set mismatch 1
     701                    break
    690702                }
    691     }
    692 
    693         set mismatch 0
    694         if {[array size oldvariations] > 0} {
    695                 if {[array size oldvariations] != [array size upvariations]} {
    696                         set mismatch 1
    697                 } else {
    698                         foreach key [array names upvariations *] {
    699                                 if {![info exists oldvariations($key)] || $upvariations($key) != $oldvariations($key)} {
    700                                         set mismatch 1
    701                                         break
    702                                 }
    703                         }
    704                 }
    705         }
    706 
    707         return $mismatch
     703            }
     704        }
     705    }
     706   
     707    return $mismatch
    708708}
    709709
     
    770770    set name [ditem_key $ditem name]
    771771    ui_debug "Executing $name provides [ditem_key $ditem provides]"
    772 
    773         # test for conflicting variants
    774         foreach v [ditem_key $ditem conflicts] {
    775                 if {[variant_isset $v]} {
    776                         ui_error "Variant $name conflicts with $v"
    777                         return 1
    778                 }
    779         }
    780 
     772   
     773    # test for conflicting variants
     774    foreach v [ditem_key $ditem conflicts] {
     775        if {[variant_isset $v]} {
     776            ui_error "Variant $name conflicts with $v"
     777            return 1
     778        }
     779    }
     780   
    781781    # execute proc with same name as variant.
    782782    if {[catch "variant-${name}" result]} {
     
    790790    global all_variants ports_force
    791791    set dlist $all_variants
    792         set result 0
     792    set result 0
    793793    upvar $variations upvariations
    794794    set chosen [choose_variants $dlist upvariations]
     
    806806   
    807807    dlist_eval $newlist "" variant_run
    808        
    809         # Make sure the variations match those stored in the statefile.
    810         # If they don't match, print an error indicating a 'port clean'
    811         # should be performed. 
    812         # - Skip this test if the statefile is empty.
    813         # - Skip this test if performing a clean.
    814         # - Skip this test if ports_force was specified.
    815 
    816         if {$target != "clean" &&
    817                 !([info exists ports_force] && $ports_force == "yes")} {
    818                 set state_fd [open_statefile]
    819        
    820                 if {[check_statefile_variants upvariations $state_fd]} {
    821                         ui_error "Requested variants do not match original selection.\nPlease perform 'port clean' or specify the force option."
    822                         set result 1
    823                 } else {
    824                         # Write variations out to the statefile
    825                         foreach key [array names upvariations *] {
    826                                 write_statefile variant $upvariations($key)$key $state_fd
    827                         }
    828                 }
    829                
    830                 close $state_fd
    831         }
    832        
    833         return $result
     808   
     809    # Make sure the variations match those stored in the statefile.
     810    # If they don't match, print an error indicating a 'port clean'
     811    # should be performed. 
     812    # - Skip this test if the statefile is empty.
     813    # - Skip this test if performing a clean.
     814    # - Skip this test if ports_force was specified.
     815   
     816    if {$target != "clean" &&
     817        !([info exists ports_force] && $ports_force == "yes")} {
     818        set state_fd [open_statefile]
     819       
     820        if {[check_statefile_variants upvariations $state_fd]} {
     821            ui_error "Requested variants do not match original selection.\nPlease perform 'port clean' or specify the force option."
     822            set result 1
     823        } else {
     824            # Write variations out to the statefile
     825            foreach key [array names upvariations *] {
     826                write_statefile variant $upvariations($key)$key $state_fd
     827            }
     828        }
     829       
     830        close $state_fd
     831    }
     832   
     833    return $result
    834834}
    835835
     
    840840    global targets
    841841    set ditem [ditem_create]
    842        
    843         ditem_key $ditem name $name
    844         ditem_key $ditem procedure $procedure
     842   
     843    ditem_key $ditem name $name
     844    ditem_key $ditem procedure $procedure
    845845   
    846846    lappend targets $ditem
     
    861861            ui_debug "$ident registered provides \'$target\', a pre-existing procedure. Target override will not be provided"
    862862        } else {
    863                 eval "proc $target {args} \{ \n\
     863            eval "proc $target {args} \{ \n\
    864864                        variable proc_index \n\
    865865                        set proc_index \[llength \[ditem_key $ditem proc\]\] \n\
     
    927927
    928928proc target_runtype {ditem args} {
    929         eval "ditem_append $ditem runtype $args"
     929    eval "ditem_append $ditem runtype $args"
    930930}
    931931
     
    974974        set options(workpath) ${newworkpath}
    975975    }
    976         # Escape regex special characters
    977         regsub -all "(\\(){1}|(\\)){1}|(\\{1}){1}|(\\+){1}|(\\{1}){1}|(\\{){1}|(\\}){1}|(\\^){1}|(\\$){1}|(\\.){1}|(\\\\){1}" $portname "\\\\&" search_string
    978 
     976    # Escape regex special characters
     977    regsub -all "(\\(){1}|(\\)){1}|(\\{1}){1}|(\\+){1}|(\\{1}){1}|(\\{){1}|(\\}){1}|(\\^){1}|(\\$){1}|(\\.){1}|(\\\\){1}" $portname "\\\\&" search_string
     978   
    979979    set res [dportsearch ^$search_string\$]
    980980    if {[llength $res] < 2} {
     
    982982        return -1
    983983    }
    984 
     984   
    985985    array set portinfo [lindex $res 1]
    986986    set porturl $portinfo(porturl)
     
    10131013    set home /dev/null
    10141014    set shell /dev/null
    1015 
     1015   
    10161016    foreach arg $args {
    10171017        if {[regexp {([a-z]*)=(.*)} $arg match key val]} {
     
    10201020        }
    10211021    }
    1022 
     1022   
    10231023    if {[existsuser ${name}] != 0 || [existsuser ${uid}] != 0} {
    10241024        return
    10251025    }
    1026 
     1026   
    10271027    if {${os.platform} == "darwin"} {
    10281028        system "niutil -create . /users/${name}"
     
    10461046    set passwd {\*}
    10471047    set users ""
    1048 
     1048   
    10491049    foreach arg $args {
    10501050        if {[regexp {([a-z]*)=(.*)} $arg match key val]} {
     
    10531053        }
    10541054    }
    1055 
     1055   
    10561056    if {[existsgroup ${name}] != 0 || [existsgroup ${gid}] != 0} {
    10571057        return
    10581058    }
    1059 
     1059   
    10601060    if {${os.platform} == "darwin"} {
    10611061        system "niutil -create . /groups/${name}"
     
    10971097        }
    10981098    }
    1099    
     1099    
    11001100    return -code error [format [msgcat::mc "Failed to locate '%s' in path: '%s'"] $binary $env(PATH)];
    11011101}
Note: See TracChangeset for help on using the changeset viewer.