Changeset 4453 for trunk/base


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

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

Location:
trunk/base/src/port1.0
Files:
14 edited

Legend:

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

    r4399 r4453  
    7171            set pbxbuild "pbxbuild"
    7272            set xcodebuild "xcodebuild"
    73 
     73           
    7474            if {[option os.platform] != "darwin"} {
    7575                return -code error "[format [msgcat::mc "This port requires 'pbxbuild/xcodebuild', which is not available on %s."] [option os.platform]]"
    7676            }
    77        
     77           
    7878            if {[catch {set xcodebuild [binaryInPath $xcodebuild]}] == 0} {
    7979                return $xcodebuild
     
    9393proc build_start {args} {
    9494    global UI_PREFIX
    95 
     95   
    9696    ui_msg "$UI_PREFIX [format [msgcat::mc "Building %s with target %s"] [option portname] [option build.target]]"
    9797}
  • trunk/base/src/port1.0/portchecksum.tcl

    r3295 r4453  
    5454proc checksum_start {args} {
    5555    global UI_PREFIX portname
    56 
     56   
    5757    ui_msg "$UI_PREFIX [format [msgcat::mc "Verifying checksum for %s"] $portname]"
    5858}
     
    6060proc checksum_main {args} {
    6161    global distpath all_dist_files UI_PREFIX
    62 
     62   
    6363    # If no files have been downloaded there is nothing to checksum
    6464    if {![info exists all_dist_files]} {
    6565        return 0
    6666    }
    67 
     67   
    6868    if {![exists checksums]} {
    6969        ui_error "[msgcat::mc "No checksums statement in Portfile.  File checksums are:"]"
     
    7373        return -code error "[msgcat::mc "No checksums statement in Portfile."]"
    7474    }
    75 
     75   
    7676    # Optimization for the 2 argument case for checksums
    7777    if {[llength [option checksums]] == 2 && [llength $all_dist_files] == 1} {
    7878        option checksums [linsert [option checksums] 0 $all_dist_files]
    7979    }
    80 
     80   
    8181    foreach distfile $all_dist_files {
    8282        set checksum [md5 file $distpath/$distfile]
  • trunk/base/src/port1.0/portclean.tcl

    r2118 r4453  
    4545proc clean_start {args} {
    4646    global UI_PREFIX
    47 
     47   
    4848    ui_msg "$UI_PREFIX [format [msgcat::mc "Cleaning %s"] [option portname]]"
    4949}
  • trunk/base/src/port1.0/portconfigure.tcl

    r3271 r4453  
    5454proc configure_start {args} {
    5555    global UI_PREFIX
    56 
     56   
    5757    ui_msg "$UI_PREFIX [format [msgcat::mc "Configuring %s"] [option portname]]"
    5858}
     
    6161    global [info globals]
    6262    global configure configure.args configure.dir automake automake.env automake.args automake.dir autoconf autoconf.env autoconf.args autoconf.dir xmkmf libtool portname worksrcpath prefix workpath UI_PREFIX use_configure use_autoconf use_automake use_xmkmf
    63 
     63   
    6464    if {[tbool use_automake]} {
    6565        # XXX depend on automake
     
    6868        }
    6969    }
    70 
     70   
    7171    if {[tbool use_autoconf]} {
    7272        # XXX depend on autoconf
     
    7575        }
    7676    }
    77 
     77   
    7878    if {[tbool use_xmkmf]} {
    7979        # XXX depend on xmkmf
  • trunk/base/src/port1.0/portdepends.tcl

    r3304 r4453  
    5050        set|append|delete {
    5151            foreach depspec $args {
    52                         if {[regexp {([A-Za-z\./0-9]+):([A-Za-z0-9_/\-\.$^\?\+\(\)\|\\]+):([-A-Za-z\./0-9_]+)} "$depspec" match deppath depregex portname]} {
    53                                 switch $deppath {
    54                                         lib {}
    55                                         bin {}
    56                                         path {}
    57                                         default {return -code error [format [msgcat::mc "unknown depspec type: %s"] $deppath]}
    58                                 }
    59                         } else {
    60                                 return -code error [format [msgcat::mc "invalid depspec: %s"] $depspec]
    61                         }
     52                if {[regexp {([A-Za-z\./0-9]+):([A-Za-z0-9_/\-\.$^\?\+\(\)\|\\]+):([-A-Za-z\./0-9_]+)} "$depspec" match deppath depregex portname]} {
     53                    switch $deppath {
     54                        lib {}
     55                        bin {}
     56                        path {}
     57                        default {return -code error [format [msgcat::mc "unknown depspec type: %s"] $deppath]}
     58                    }
     59                } else {
     60                    return -code error [format [msgcat::mc "invalid depspec: %s"] $depspec]
     61                }
    6262            }
    6363        }
  • trunk/base/src/port1.0/portdestroot.tcl

    r3891 r4453  
    5656proc destroot_start {args} {
    5757    global UI_PREFIX prefix portname destroot portresourcepath os.platform destroot.clean
    58 
     58   
    5959    ui_msg "$UI_PREFIX [format [msgcat::mc "Staging %s into destroot"] ${portname}]"
    60 
     60   
    6161    if { ${destroot.clean} == "yes" } {
    6262        system "rm -Rf \"${destroot}\""
    6363    }
    64 
     64   
    6565    file mkdir "${destroot}"
    6666    if { ${os.platform} == "darwin" } {
     
    7878proc destroot_finish {args} {
    7979    global destroot
    80 
     80   
    8181    # Prune empty directories in ${destroot}
    8282    catch {system "find \"${destroot}\" -depth -type d -print | xargs rmdir 2>/dev/null"}
  • trunk/base/src/port1.0/portdmg.tcl

    r4026 r4453  
    4242proc dmg_main {args} {
    4343    global portname portversion portrevision package.destpath UI_PREFIX
    44 
     44   
    4545    ui_msg "$UI_PREFIX [format [msgcat::mc "Creating disk image for %s-%s"] ${portname} ${portversion}]"
    46 
     46   
    4747    return [package_dmg $portname $portversion $portrevision]
    4848}
     
    5050proc package_dmg {portname portversion portrevision} {
    5151    global UI_PREFIX package.destpath portpath
    52 
     52   
    5353    if {[expr (${portrevision} > 0)]} {
    5454        set imagename "${portname}-${portversion}-${portrevision}"
     
    5656        set imagename "${portname}-${portversion}"
    5757    }
    58 
     58   
    5959    set tmp_image ${package.destpath}/${imagename}.tmp.dmg
    6060    set final_image ${package.destpath}/${imagename}.dmg
    6161    set pkgpath ${package.destpath}/${portname}-${portversion}.pkg
    62 
     62   
    6363    if {[file readable $final_image] && ([file mtime ${final_image}] >= [file mtime ${portpath}/Portfile])} {
    6464        ui_msg "$UI_PREFIX [format [msgcat::mc "Disk Image for %s-%s is up-to-date"] ${portname} ${portversion}]"
    6565        return 0
    6666    }
    67 
     67   
    6868    # size for .dmg
    6969    set size [dirSize ${pkgpath}]
     
    7575        set blocks [expr ($size/512) + ((($size/512)*3)/100)]
    7676    }
    77 
     77   
    7878    if {[system "hdiutil create -fs HFS+ -volname ${imagename} -size ${blocks}b ${tmp_image}"] != ""} {
    7979        return -code error [format [msgcat::mc "Failed to create temporary image: %s"] ${imagename}]
     
    9393    }
    9494    system "rm -f ${tmp_image}"
    95 
     95   
    9696    return 0
    9797}
  • trunk/base/src/port1.0/portextract.tcl

    r4000 r4453  
    5757proc extract_init {args} {
    5858    global extract.only extract.dir extract.cmd extract.pre_args extract.post_args distfiles use_bzip2 use_zip workpath
    59 
     59   
    6060    if {[tbool use_bzip2]} {
    6161        option extract.cmd [binaryInPath "bzip2"]
     
    6969proc extract_start {args} {
    7070    global UI_PREFIX
    71 
     71   
    7272    ui_msg "$UI_PREFIX [format [msgcat::mc "Extracting %s"] [option portname]]"
    7373}
     
    7575proc extract_main {args} {
    7676    global UI_PREFIX
    77 
     77   
    7878    if {![exists distfiles] && ![exists extract.only]} {
    7979        # nothing to do
    8080        return 0
    8181    }
    82 
     82   
    8383    foreach distfile [option extract.only] {
    8484        ui_info "$UI_PREFIX [format [msgcat::mc "Extracting %s"] $distfile]"
  • trunk/base/src/port1.0/portfetch.tcl

    r3977 r4453  
    156156        return {}
    157157    }
    158 
     158   
    159159    set ret [list]
    160160    foreach element $portfetch::mirror_sites::sites($mirrors) {
     
    164164        set splitlist [split $element :]
    165165        if {[llength $splitlist] > 1} {
    166                 set element "[lindex $splitlist 0]:[lindex $splitlist 1]"
    167                 set mirror_tag "[lindex $splitlist 2]"
    168         }
    169 
     166            set element "[lindex $splitlist 0]:[lindex $splitlist 1]"
     167            set mirror_tag "[lindex $splitlist 2]"
     168        }
     169       
    170170        if {$subdir == "" && $mirror_tag != "nosubdir"} {
    171171            set subdir ${portname}
    172172        }
    173 
     173       
    174174        if {"$tag" != ""} {
    175175            eval append element "${subdir}:${tag}"
     
    179179        eval lappend ret $element
    180180    }
    181 
     181   
    182182    return $ret
    183183}
     
    192192        master_sites filespath master_sites.mirror_subdir \
    193193        patch_sites.mirror_subdir fallback_mirror_site
    194 
     194   
    195195    append master_sites " ${fallback_mirror_site}"
    196 
     196   
    197197    foreach list {master_sites patch_sites} {
    198198        upvar #0 $list uplist
     
    228228        }
    229229    }
    230    
     230    
    231231    if {[info exists patchfiles]} {
    232232        foreach file $patchfiles {
     
    286286    global distpath all_dist_files UI_PREFIX fetch_urls fetch.cmd os.platform fetch.pre_args
    287287    global distfile site
    288 
     288   
    289289    if {![file isdirectory $distpath]} {
    290290        if {[catch {file mkdir $distpath} result]} {
     
    328328proc fetch_init {args} {
    329329    global distfiles distname distpath all_dist_files dist_subdir fetch.type
    330 
     330   
    331331    if {[info exist distpath] && [info exists dist_subdir]} {
    332332        set distpath ${distpath}/${dist_subdir}
     
    339339proc fetch_start {args} {
    340340    global UI_PREFIX portname
    341 
     341   
    342342    ui_msg "$UI_PREFIX [format [msgcat::mc "Fetching %s"] $portname]"
    343343}
     
    349349proc fetch_main {args} {
    350350    global distname distpath all_dist_files fetch.type
    351 
     351   
    352352    # Check for files, download if neccesary
    353353    if {![info exists all_dist_files] && "${fetch.type}" == "standard"} {
  • trunk/base/src/port1.0/portinstall.tcl

    r3954 r4453  
    4343proc install_start {args} {
    4444    global UI_PREFIX portname portversion
    45 
    46         # Check to make sure this port is not already installed.  This is a
    47         # general check of the portname only, so previous versions will fail
    48         # as well.
    49         if {[string length [registry_exists $portname]]} {
    50                 # Also check to see if it's this version or another
    51                 if {[string length [registry_exists $portname $portversion]]} {
    52                         return -code error [format [msgcat::mc "Port %s already registered as installed."] $portname]
    53                 } else {
    54                         return -code error [format [msgcat::mc "Another version of Port %s is already registered as installed.  Please uninstall the port first."] $portname]
    55                 }
     45   
     46    # Check to make sure this port is not already installed.  This is a
     47    # general check of the portname only, so previous versions will fail
     48    # as well.
     49    if {[string length [registry_exists $portname]]} {
     50        # Also check to see if it's this version or another
     51        if {[string length [registry_exists $portname $portversion]]} {
     52            return -code error [format [msgcat::mc "Port %s already registered as installed."] $portname]
    5653        } else {
     54            return -code error [format [msgcat::mc "Another version of Port %s is already registered as installed.  Please uninstall the port first."] $portname]
     55        }
     56    } else {
    5757        ui_msg "$UI_PREFIX [format [msgcat::mc "Installing %s"] ${portname}]"
    58         }
     58    }
    5959}
    6060
    6161proc install_element {src_element dst_element} {
    62 # don't recursively copy directories
     62    # don't recursively copy directories
    6363    if {[file isdirectory $src_element] && [file type $src_element] != "link"} {
    6464        file mkdir $dst_element
     
    6666        file copy -force $src_element $dst_element
    6767    }
    68 
     68   
    6969    # if the file is a symlink, do not try to set file attributes
    7070    # if the destination file is an existing directory,
     
    9090        return
    9191    }
    92 
     92   
    9393    foreach name [readdir .] {
    9494        if {[string match $name "."] || [string match $name ".."]} {
     
    9696        }
    9797        set element [file join $cwd $name]
    98 
     98       
    9999        # XXX jpm's cross-platform code to find file separator
    100100        # replace with [file seperator] with tcl 8.4
     
    108108            }
    109109        }
    110 
     110       
    111111        set dst_element [file join $root $element]
    112112        set src_element [file join $rootdir $element]
     
    126126proc install_main {args} {
    127127    global portname portversion portpath categories description long_description homepage depends_run installPlist package-install uninstall workdir worksrcdir prefix UI_PREFIX destroot
    128 
     128   
    129129    # Install ${destroot} contents into /
    130130    directory_dig ${destroot} ${destroot}
    131 
     131   
    132132    # Package installed successfully, so now we must register it
    133133    set rhandle [registry_new $portname $portversion]
    134 
     134   
    135135    registry_store $rhandle [list prefix $prefix]
    136136    registry_store $rhandle [list categories $categories]
  • trunk/base/src/port1.0/portpatch.tcl

    r3220 r4453  
    4848proc patch_main {args} {
    4949    global UI_PREFIX
    50 
     50   
    5151    # First make sure that patchfiles exists and isn't stubbed out.
    5252    if {![exists patchfiles]} {
    5353        return 0
    5454    }
    55 
     55   
    5656    foreach patch [option patchfiles] {
    5757        if {[file exists [option filespath]/$patch]} {
  • trunk/base/src/port1.0/portrpmpackage.tcl

    r3375 r4453  
    4444proc rpmpackage_main {args} {
    4545    global portname portversion portrevision UI_PREFIX
    46 
     46   
    4747    ui_msg "$UI_PREFIX [format [msgcat::mc "Creating RPM package for %s-%s"] ${portname} ${portversion}]"
    48 
     48   
    4949    return [rpmpackage_pkg $portname $portversion $portrevision]
    5050}
     
    5252proc rpmpackage_pkg {portname portversion portrevision} {
    5353    global UI_PREFIX package.destpath portdbpath destpath workpath prefix portresourcepath categories maintainers description long_description homepage epoch portpath
    54 
     54   
    5555    set rpmdestpath ""
    5656    if {![string equal ${package.destpath} ${workpath}] && ![string equal ${package.destpath} ""]} {
     
    6363        set rpmdestpath "--define '_topdir ${pkgpath}'"
    6464    }
    65 
     65   
    6666    foreach dir { "${prefix}/src/apple/RPMS" "/usr/src/apple/RPMS" "/darwinports/rpms/RPMS"} {
    6767        foreach arch {"ppc" "i386" "fat"} {
     
    7373        }
    7474    }
    75 
     75   
    7676    set specpath ${workpath}/${portname}.spec
    7777    # long_description, description, or homepage may not exist
     
    8585    set category   [lindex [split $categories " "] 0]
    8686    set maintainer $maintainers
    87 
     87   
    8888    set dependencies {}
    8989    # get deplist
     
    9898        }
    9999    }
    100 
     100   
    101101    system "rm -f '${workpath}/${portname}.filelist' && touch '${workpath}/${portname}.filelist'"
    102102    #system "cd '${destpath}' && find . -type d | grep -v -E '^.$' | sed -e 's/\"/\\\"/g' -e 's/^./%dir \"/' -e 's/$/\"/' > '${workpath}/${portname}.filelist'"
     
    105105    write_spec ${specpath} $portname $portversion $portrevision $pkg_description $pkg_long_description $category $maintainer $destpath $dependencies $epoch
    106106    system "DP_USERECEIPTS='${portdbpath}/receipts' rpm -bb -v ${rpmdestpath} ${specpath}"
    107 
     107   
    108108    return 0
    109109}
     
    117117    foreach {name array} $res {
    118118        array set portinfo $array
    119 
     119       
    120120        if {[info exists portinfo(depends_run)] || [info exists portinfo(depends_lib)]} {
    121121            # get the union of depends_run and depends_lib
     
    124124            if {[info exists portinfo(depends_run)]} { eval "lappend depends $portinfo(depends_run)" }
    125125            if {[info exists portinfo(depends_lib)]} { eval "lappend depends $portinfo(depends_lib)" }
    126 
     126           
    127127            foreach depspec $depends {
    128128                set dep [lindex [split $depspec :] 2]
    129        
     129               
    130130                # xxx: nasty hack
    131131                if {$dep != "XFree86"} {
     
    144144    set specfd [open ${specfile} w+]
    145145    if {[llength ${dependencies}] != 0} {
    146        set requires [join ${dependencies} ", "]
    147        regsub -all -- "\-" $requires "_" requires
    148        set requires "Requires: ${requires}"
     146        set requires [join ${dependencies} ", "]
     147        regsub -all -- "\-" $requires "_" requires
     148        set requires "Requires: ${requires}"
    149149    } else {
    150        set requires ""
     150        set requires ""
    151151    }
    152152    regsub -all -- "\-" $portversion "_" portversion
  • trunk/base/src/port1.0/portuninstall.tcl

    r4300 r4453  
    4646proc uninstall_start {args} {
    4747    global portname portversion UI_PREFIX
    48 
     48   
    4949    if {[string length [registry_exists $portname]]} {
    5050        ui_msg "$UI_PREFIX [format [msgcat::mc "Uninstalling %s"] $portname]"
     
    5454proc uninstall_main {args} {
    5555    global portname portversion uninstall.force uninstall.nochecksum ports_force UI_PREFIX
    56 
     56   
    5757    # If global forcing is on, make it the same as a local force flag.
    5858    if {[tbool ports_force]} {
    5959        set uninstall.force "yes"
    6060    }
    61 
     61   
    6262    set rfile [registry_exists $portname]
    6363    if {[string length $rfile]} {
     
    6969        set entry [read $fd]
    7070        close $fd
    71 
     71       
    7272        # First look to see if the port has registered an uninstall procedure
    7373        set ix [lsearch $entry pkg_uninstall]
     
    8080            }
    8181        }
    82 
     82       
    8383        # Now look for a contents list
    8484        set ix [lsearch $entry contents]
     
    9090                set md5index [lsearch -regex [lrange $f 1 end] MD5]
    9191                if {$md5index != -1} {
    92                         set sumx [lindex $f [expr $md5index + 1]]
     92                    set sumx [lindex $f [expr $md5index + 1]]
    9393                } else {
    94                         # XXX There is no MD5 listed, set sumx to an empty
    95                         # list, causing the next conditional to return a
    96                         # checksum error
    97                         set sumx {}
     94                    # XXX There is no MD5 listed, set sumx to an empty
     95                    # list, causing the next conditional to return a
     96                    # checksum error
     97                    set sumx {}
    9898                }
    9999                set sum1 [lindex $sumx [expr [llength $sumx] - 1]]
     
    127127            }
    128128            if {!$uninst_err || [tbool uninstall.force]} {
    129                         registry_delete $portname
    130                         return 0
     129                registry_delete $portname
     130                return 0
    131131            }
    132132        } else {
  • 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.