Ignore:
Timestamp:
Jun 21, 2013, 7:46:52 PM (7 years ago)
Author:
snc@…
Message:

gsoc11-statistics/base: rebase /trunk/base

Location:
branches/gsoc11-statistics/base
Files:
32 edited

Legend:

Unmodified
Added
Removed
  • branches/gsoc11-statistics/base

  • branches/gsoc11-statistics/base/src/darwintracelib1.0/darwintrace.c

    r105638 r107206  
    33 * Copyright (c) 2005-2006 Paul Guyot <pguyot@kallisys.net>,
    44 * All rights reserved.
     5 * Copyright (c) 2006-2013 The MacPorts Project
    56 *
    67 * $Id$
     
    595596 */
    596597__attribute__((always_inline))
    597 inline int __darwintrace_is_in_sandbox(const char* path, char * newpath) {
     598static inline int __darwintrace_is_in_sandbox(const char* path, char * newpath) {
    598599        char *t, *p, *_;
     600        char *strpos, *normpos;
    599601        char lpath[MAXPATHLEN];
     602        char normalizedpath[MAXPATHLEN];
    600603       
    601604        __darwintrace_setup();
     
    614617                strcat(lpath, path);
    615618        }
    616 
    617619        p = lpath;
     620
     621        normalizedpath[0] = '\0';
     622        strpos = p + 1;
     623        normpos = normalizedpath;
     624        for (;;) {
     625                char *curpos = strsep(&strpos, "/");
     626                if (curpos == NULL) {
     627                        /* reached the end of the path */
     628                        break;
     629                } else if (*curpos == '\0') {
     630                        /* empty entry, ignore */
     631                        continue;
     632                } else if (strcmp(curpos, ".") == 0) {
     633                        /* no-op directory, ignore */
     634                        continue;
     635                } else if (strcmp(curpos, "..") == 0) {
     636                        /* walk up one directory */
     637                        char *lastSep = strrchr(normalizedpath, '/');
     638                        if (lastSep == NULL) {
     639                                /* path is completely empty */
     640                                normpos = normalizedpath;
     641                                *normpos = '\0';
     642                                continue;
     643                        }
     644                        /* remove last component by overwriting the slash with \0, update normpos */
     645                        *lastSep = '\0';
     646                        normpos = lastSep;
     647                }
     648                /* default case: standard path, copy */
     649                strcat(normpos, "/");
     650                normpos++;
     651                strcat(normpos, curpos);
     652                debug_printf("path %s, processing entry %s, normalized %s\n", path, curpos, normalizedpath);
     653        }
     654        if (*normalizedpath == '\0') {
     655                strcat(normalizedpath, "/");
     656        }
    618657
    619658        for (t = filemap; *t;) {
    620659                char state;
    621660               
    622                 if (__darwintrace_strbeginswith(p, t)) {
     661                if (__darwintrace_strbeginswith(normalizedpath, t)) {
    623662                        /* move t to the integer describing how to handle this match */
    624663                        t += strlen(t) + 1;
     
    638677                                                *_ = '/';
    639678                                        }
    640                                         strcpy(_, p);
     679                                        strcpy(_, normalizedpath);
    641680                                        return 1;
    642681                                case 2:
    643682                                        /* ask the socket whether this file is OK */
    644                                         return ask_for_dependency(p);
     683                                        return ask_for_dependency(normalizedpath);
    645684                                default:
    646685                                        fprintf(stderr, "darwintrace: error: unexpected byte in file map: `%x'\n", *t);
     
    675714        }
    676715
    677         __darwintrace_log_op("sandbox_violation", path, 0);
     716        __darwintrace_log_op("sandbox_violation", normalizedpath, 0);
    678717        return 0;
    679718}
  • branches/gsoc11-statistics/base/src/macports1.0/macports.tcl

    r105577 r107206  
    77# Copyright (c) 2004 - 2006 Ole Guldberg Jensen <olegb@opendarwin.org>.
    88# Copyright (c) 2004 - 2005 Robert Shaw <rshaw@opendarwin.org>
    9 # Copyright (c) 2004 - 2012 The MacPorts Project
     9# Copyright (c) 2004 - 2013 The MacPorts Project
    1010# All rights reserved.
    1111#
     
    4040
    4141namespace eval macports {
    42     namespace export bootstrap_options user_options portinterp_options open_mports ui_priorities port_phases 
     42    namespace export bootstrap_options user_options portinterp_options open_mports ui_priorities port_phases
    4343    variable bootstrap_options "\
    4444        portdbpath libpath binpath auto_path extra_env sources_conf prefix portdbformat \
     
    5151        master_site_local patch_site_local archive_site_local buildfromsource stats_participate stats_url stats_id \
    5252        revupgrade_autorun revupgrade_mode revupgrade_check_id_loadcmds \
    53         host_blacklist preferred_hosts\
     53        host_blacklist preferred_hosts sandbox_enable \
    5454        packagemaker_path default_compilers pkg_post_unarchive_deletions"
    55     variable user_options ""
     55    variable user_options {}
    5656    variable portinterp_options "\
    5757        portdbpath porturl portpath portbuildpath auto_path prefix prefix_frozen portsharepath \
     
    6262        applications_dir current_phase frameworks_dir developer_dir universal_archs build_arch \
    6363        os_arch os_endian os_version os_major os_platform macosx_version macosx_deployment_target \
    64         packagemaker_path default_compilers \
     64        packagemaker_path default_compilers sandbox_enable \
    6565        pkg_post_unarchive_deletions $user_options"
    6666
     
    7474    variable ui_priorities "error warn msg notice info debug any"
    7575    variable port_phases "any fetch checksum"
    76     variable current_phase "main"
     76    variable current_phase main
    7777
    7878    variable ui_prefix "---> "
     
    101101proc macports::ui_isset {val} {
    102102    if {[info exists macports::ui_options($val)]} {
    103         if {$macports::ui_options($val) == "yes"} {
     103        if {$macports::ui_options($val) eq "yes"} {
    104104            return 1
    105105        }
     
    112112proc macports::global_option_isset {val} {
    113113    if {[info exists macports::global_options($val)]} {
    114         if {$macports::global_options($val) == "yes"} {
     114        if {$macports::global_options($val) eq "yes"} {
    115115            return 1
    116116        }
     
    131131    # Add our log-channel to all already initialized channels
    132132    foreach key [array names channels] {
    133         set macports::channels($key) [concat $macports::channels($key) "debuglog"]
     133        set macports::channels($key) [concat $macports::channels($key) debuglog]
    134134    }
    135135    return 0
     
    145145    set logname [macports::getportlogpath $portpath $portname]
    146146    file mkdir $logname
    147     set logname [file join $logname "main.log"]
     147    set logname [file join $logname main.log]
    148148
    149149    set ::debuglogname $logname
     
    151151    # Truncate the file if already exists
    152152    set ::debuglog [open $::debuglogname w]
    153     puts $::debuglog "version:1"
     153    puts $::debuglog version:1
    154154}
    155155proc macports::push_log {mport} {
     
    175175    }
    176176}
     177
    177178proc macports::pop_log {} {
    178179    global ::logenabled ::logstack ::debuglog ::debuglogname
     
    197198    global macports::current_phase
    198199    set macports::current_phase $phase
    199     if {$phase != "main"} {
     200    if {$phase ne "main"} {
    200201        set cur_time [clock format [clock seconds] -format  {%+}]
    201202        ui_debug "$phase phase started at $cur_time"
     
    206207    global macports::channels ::debuglog macports::current_phase
    207208    foreach chan $macports::channels($priority) {
    208         if {[info exists ::debuglog] && ($chan == "debuglog")} {
     209        if {[info exists ::debuglog] && ($chan eq "debuglog")} {
    209210            set chan $::debuglog
    210211            if {[info exists macports::current_phase]} {
    211212                set phase $macports::current_phase
    212213            }
    213             set strprefix ":$priority:$phase "
    214             if {[lindex $args 0] == "-nonewline"} {
    215                 puts -nonewline $chan "$strprefix[lindex $args 1]"
     214            set strprefix ":${priority}:$phase "
     215            if {[lindex $args 0] eq "-nonewline"} {
     216                puts -nonewline $chan $strprefix[lindex $args 1]
    216217            } else {
    217                 puts $chan "$strprefix[lindex $args 0]"
    218             }
    219  
     218                puts $chan $strprefix[lindex $args 0]
     219            }
     220
    220221        } else {
    221             if {[lindex $args 0] == "-nonewline"} {
    222                 puts -nonewline $chan "$prefix[lindex $args 1]"
     222            if {[lindex $args 0] eq "-nonewline"} {
     223                puts -nonewline $chan $prefix[lindex $args 1]
    223224            } else {
    224                 puts $chan "$prefix[lindex $args 0]"
     225                puts $chan $prefix[lindex $args 0]
    225226            }
    226227        }
     
    236237        set channels($priority) $default_channel
    237238    }
    238    
     239
    239240    # if some priority initialized after log file is being created
    240241    if {[info exists ::debuglog]} {
    241         set channels($priority) [concat $channels($priority) "debuglog"]
     242        set channels($priority) [concat $channels($priority) debuglog]
    242243    }
    243244    # Simplify ui_$priority.
     
    251252        eval ::ui_init $priority $prefix $channels($priority) $args
    252253    } catch * {
    253         interp alias {} ui_$priority {} ui_message $priority $prefix ""
     254        interp alias {} ui_$priority {} ui_message $priority $prefix {}
    254255        foreach phase $phases {
    255             interp alias {} ui_${priority}_${phase} {} ui_message $priority $prefix $phase
     256            interp alias {} ui_${priority}_$phase {} ui_message $priority $prefix $phase
    256257        }
    257258    }
     
    260261# Default implementation of ui_prefix
    261262proc macports::ui_prefix_default {priority} {
    262     switch $priority {
     263    switch -- $priority {
    263264        debug {
    264265            return "DEBUG: "
     
    271272        }
    272273        default {
    273             return ""
     274            return {}
    274275        }
    275276    }
     
    281282# ui_options(ports_quiet) - If set, don't output "standard messages"
    282283proc macports::ui_channels_default {priority} {
    283     switch $priority {
     284    switch -- $priority {
    284285        debug {
    285286            if {[ui_isset ports_debug]} {
    286                 return {stderr}
     287                return stderr
    287288            } else {
    288289                return {}
     
    291292        info {
    292293            if {[ui_isset ports_verbose]} {
    293                 return {stdout}
     294                return stdout
    294295            } else {
    295296                return {}
     
    300301                return {}
    301302            } else {
    302                 return {stdout}
     303                return stdout
    303304            }
    304305        }
    305306        msg {
    306             return {stdout}
     307            return stdout
    307308        }
    308309        warn -
    309310        error {
    310             return {stderr}
     311            return stderr
    311312        }
    312313        default {
    313             return {stdout}
     314            return stdout
    314315        }
    315316    }
     
    332333# find a binary either in a path defined at MacPorts' configuration time
    333334# or in the PATH environment variable through macports::binaryInPath (fallback)
    334 proc macports::findBinary {prog {autoconf_hint ""}} {
    335     if {${autoconf_hint} != "" && [file executable ${autoconf_hint}]} {
    336         return ${autoconf_hint}
     335proc macports::findBinary {prog {autoconf_hint {}}} {
     336    if {$autoconf_hint ne {} && [file executable $autoconf_hint]} {
     337        return $autoconf_hint
    337338    } else {
    338         if {[catch {set cmd_path [macports::binaryInPath ${prog}]} result] == 0} {
    339             return ${cmd_path}
     339        if {[catch {set cmd_path [macports::binaryInPath $prog]} result] == 0} {
     340            return $cmd_path
    340341        } else {
    341             return -code error "${result} or at its MacPorts configuration time location, did you move it?"
     342            return -code error "$result or at its MacPorts configuration time location, did you move it?"
    342343        }
    343344    }
     
    359360proc macports::getoption {name} {
    360361    global macports::$name
    361     return [expr $$name]
     362    return [set $name]
    362363}
    363364
    364365# deferred and on-need extraction of xcodeversion and xcodebuildcmd.
    365366proc macports::setxcodeinfo {name1 name2 op} {
    366     global macports::xcodeversion
    367     global macports::xcodebuildcmd
     367    global macports::xcodeversion macports::xcodebuildcmd
    368368
    369369    trace remove variable macports::xcodeversion read macports::setxcodeinfo
     
    373373        if {![info exists xcodeversion]} {
    374374            # Determine xcode version
    375             set macports::xcodeversion "2.0orlower"
     375            set macports::xcodeversion 2.0orlower
    376376            if {[catch {set xcodebuildversion [exec -- $xcodebuild -version 2> /dev/null]}] == 0} {
    377377                if {[regexp {Xcode ([0-9.]+)} $xcodebuildversion - xcode_v] == 1} {
     
    379379                } elseif {[regexp "DevToolsCore-(.*);" $xcodebuildversion - devtoolscore_v] == 1} {
    380380                    if {$devtoolscore_v >= 1809.0} {
    381                         set macports::xcodeversion "3.2.6"
     381                        set macports::xcodeversion 3.2.6
    382382                    } elseif {$devtoolscore_v >= 1204.0} {
    383                         set macports::xcodeversion "3.1.4"
     383                        set macports::xcodeversion 3.1.4
    384384                    } elseif {$devtoolscore_v >= 1100.0} {
    385                         set macports::xcodeversion "3.1"
     385                        set macports::xcodeversion 3.1
    386386                    } elseif {$devtoolscore_v >= 921.0} {
    387                         set macports::xcodeversion "3.0"
     387                        set macports::xcodeversion 3.0
    388388                    } elseif {$devtoolscore_v >= 798.0} {
    389                         set macports::xcodeversion "2.5"
     389                        set macports::xcodeversion 2.5
    390390                    } elseif {$devtoolscore_v >= 762.0} {
    391                         set macports::xcodeversion "2.4.1"
     391                        set macports::xcodeversion 2.4.1
    392392                    } elseif {$devtoolscore_v >= 757.0} {
    393                         set macports::xcodeversion "2.4"
     393                        set macports::xcodeversion 2.4
    394394                    } elseif {$devtoolscore_v > 650.0} {
    395395                        # XXX find actual version corresponding to 2.3
    396                         set macports::xcodeversion "2.3"
     396                        set macports::xcodeversion 2.3
    397397                    } elseif {$devtoolscore_v >= 650.0} {
    398                         set macports::xcodeversion "2.2.1"
     398                        set macports::xcodeversion 2.2.1
    399399                    } elseif {$devtoolscore_v > 620.0} {
    400400                        # XXX find actual version corresponding to 2.2
    401                         set macports::xcodeversion "2.2"
     401                        set macports::xcodeversion 2.2
    402402                    } elseif {$devtoolscore_v >= 620.0} {
    403                         set macports::xcodeversion "2.1"
     403                        set macports::xcodeversion 2.1
    404404                    }
    405405                }
    406406            } else {
    407407                ui_warn "xcodebuild exists but failed to execute"
    408                 set macports::xcodeversion "none"
     408                set macports::xcodeversion none
    409409            }
    410410        }
    411411        if {![info exists xcodebuildcmd]} {
    412             set macports::xcodebuildcmd "$xcodebuild"
     412            set macports::xcodebuildcmd $xcodebuild
    413413        }
    414414    } else {
    415415        if {![info exists xcodeversion]} {
    416             set macports::xcodeversion "none"
     416            set macports::xcodeversion none
    417417        }
    418418        if {![info exists xcodebuildcmd]} {
    419             set macports::xcodebuildcmd "none"
     419            set macports::xcodebuildcmd none
    420420        }
    421421    }
     
    459459
    460460    trace remove variable macports::developer_dir read macports::set_developer_dir
    461    
     461
    462462    # Look for xcodeselect, and make sure it has a valid value
    463463    if {![catch {findBinary xcode-select $macports::autoconf::xcode_select_path} xcodeselect]} {
     
    472472
    473473        # The directory from xcode-select isn't correct.
    474        
     474
    475475        # Ask mdfind where Xcode is and make some suggestions for the user,
    476476        # searching by bundle identifier for various Xcode versions (3.x and 4.x)
     
    479479            set installed_xcodes [exec $mdfind "kMDItemCFBundleIdentifier == 'com.apple.Xcode' || kMDItemCFBundleIdentifier == 'com.apple.dt.Xcode'"]
    480480        }
    481        
     481
    482482        # In case mdfind metadata wasn't complete, also look in two well-known locations for Xcode.app
    483483        foreach app {/Applications/Xcode.app /Developer/Applications/Xcode.app} {
     
    486486            }
    487487        }
    488        
     488
    489489        # Form a list of unique xcode installations
    490490        set installed_xcodes [lsort -unique $installed_xcodes]
     
    498498            foreach xcode $installed_xcodes {
    499499                set vers [exec $mdls -raw -name kMDItemVersion $xcode]
    500                 if {$vers == "(null)"} { set vers "unknown" }
    501                 if {[_is_valid_developer_dir "${xcode}/Contents/Developer"]} {
     500                if {$vers eq "(null)"} {set vers unknown}
     501                if {[_is_valid_developer_dir ${xcode}/Contents/Developer]} {
    502502                    # Though xcode-select shipped with xcode 4.3 supports and encourages
    503503                    # direct use of the app path, older xcode-select does not.
    504504                    # Specify the Contents/Developer directory if it exists
    505                     ui_error "    sudo xcode-select -switch ${xcode}/Contents/Developer # version ${vers}"
     505                    ui_error "    sudo xcode-select -switch ${xcode}/Contents/Developer # version $vers"
    506506                } elseif {[vercmp $vers 4.3] >= 0} {
    507507                    # Future proofing: fall back to the app-path only for xcode >= 4.3, since Contents/Developer doesn't exist
    508                     ui_error "    sudo xcode-select -switch ${xcode} # version ${vers}"
    509                 } elseif {[_is_valid_developer_dir "${xcode}/../.."]} {
     508                    ui_error "    sudo xcode-select -switch $xcode # version $vers"
     509                } elseif {[_is_valid_developer_dir ${xcode}/../..]} {
    510510                    # Older xcode (< 4.3) is below the developer directory
    511                     ui_error "    sudo xcode-select -switch [file normalize ${xcode}/../..] # version ${vers}"
     511                    ui_error "    sudo xcode-select -switch [file normalize ${xcode}/../..] # version $vers"
    512512                } else {
    513                     ui_error "    # malformed Xcode at ${xcode}, version ${vers}"
     513                    ui_error "    # malformed Xcode at ${xcode}, version $vers"
    514514                }
    515515            }
     
    523523    # Try the default
    524524    if {$os_major >= 11 && [vercmp $xcodeversion 4.3] >= 0} {
    525         set devdir "/Applications/Xcode.app/Contents/Developer"
     525        set devdir /Applications/Xcode.app/Contents/Developer
    526526    } else {
    527         set devdir "/Developer"
     527        set devdir /Developer
    528528    }
    529529
     
    541541    # Verify that the directory has some key subdirectories
    542542    foreach subdir {Library usr} {
    543         if {![file isdirectory "${dir}/${subdir}"]} {
     543        if {![file isdirectory ${dir}/$subdir]} {
    544544            return 0
    545545        }
     
    552552
    553553proc mportinit {{up_ui_options {}} {up_options {}} {up_variations {}}} {
    554     if {$up_ui_options eq ""} {
     554    if {$up_ui_options eq {}} {
    555555        array set macports::ui_options {}
    556556    } else {
     
    558558        array set macports::ui_options [array get temp_ui_options]
    559559    }
    560     if {$up_options eq ""} {
     560    if {$up_options eq {}} {
    561561        array set macports::global_options {}
    562562    } else {
     
    564564        array set macports::global_options [array get temp_options]
    565565    }
    566     if {$up_variations eq ""} {
     566    if {$up_variations eq {}} {
    567567        array set variations {}
    568568    } else {
     
    571571
    572572    # Initialize ui_*
    573     foreach priority ${macports::ui_priorities} {
     573    foreach priority $macports::ui_priorities {
    574574        macports::ui_init $priority
    575575    }
    576576
    577     global auto_path env tcl_platform
    578     global macports::autoconf::macports_conf_path
    579     global macports::macports_user_dir
    580     global macports::bootstrap_options
    581     global macports::user_options
    582     global macports::extra_env
    583     global macports::portconf
    584     global macports::portdbpath
    585     global macports::portsharepath
    586     global macports::registry.format
    587     global macports::registry.path
    588     global macports::sources
    589     global macports::sources_default
    590     global macports::sources_conf
    591     global macports::destroot_umask
    592     global macports::libpath
    593     global macports::prefix
    594     global macports::macportsuser
    595     global macports::prefix_frozen
    596     global macports::rsync_dir
    597     global macports::rsync_options
    598     global macports::rsync_server
    599     global macports::variants_conf
    600     global macports::stats_participate
    601     global macports::stats_url
    602     global macports::stats_id
    603     global macports::xcodebuildcmd
    604     global macports::xcodeversion
    605     global macports::gccversion
    606     global macports::configureccache
    607     global macports::ccache_dir
    608     global macports::ccache_size
    609     global macports::configuredistcc
    610     global macports::configurepipe
    611     global macports::buildnicevalue
    612     global macports::buildmakejobs
    613     global macports::universal_archs
    614     global macports::build_arch
    615     global macports::os_arch
    616     global macports::os_endian
    617     global macports::os_version
    618     global macports::os_major
    619     global macports::os_platform
    620     global macports::macosx_version
    621     global macports::macosx_deployment_target
    622     global macports::archivefetch_pubkeys
    623     global macports::ping_cache
    624     global macports::host_blacklisted
    625     global macports::host_preferred
     577    global auto_path env tcl_platform \
     578        macports::autoconf::macports_conf_path \
     579        macports::macports_user_dir \
     580        macports::bootstrap_options \
     581        macports::user_options \
     582        macports::portconf \
     583        macports::portsharepath \
     584        macports::registry.format \
     585        macports::registry.path \
     586        macports::sources \
     587        macports::sources_default \
     588        macports::destroot_umask \
     589        macports::libpath \
     590        macports::prefix \
     591        macports::macportsuser \
     592        macports::prefix_frozen \
     593        macports::xcodebuildcmd \
     594        macports::xcodeversion \
     595        macports::configureccache \
     596        macports::ccache_dir \
     597        macports::ccache_size \
     598        macports::configuredistcc \
     599        macports::configurepipe \
     600        macports::buildnicevalue \
     601        macports::buildmakejobs \
     602        macports::universal_archs \
     603        macports::build_arch \
     604        macports::os_arch \
     605        macports::os_endian \
     606        macports::os_version \
     607        macports::os_major \
     608        macports::os_platform \
     609        macports::macosx_version \
     610        macports::macosx_deployment_target \
     611        macports::archivefetch_pubkeys \
     612        macports::ping_cache \
     613        macports::host_blacklisted \
     614        macports::host_preferred \
     615        macports::stats_participate \
     616        macports::stats_url \
     617        macports::stats_id
    626618
    627619    # Set the system encoding to utf-8
     
    630622    # set up platform info variables
    631623    set os_arch $tcl_platform(machine)
    632     if {$os_arch == "Power Macintosh"} { set os_arch "powerpc" }
    633     if {$os_arch == "i586" || $os_arch == "i686" || $os_arch == "x86_64"} { set os_arch "i386" }
     624    if {$os_arch eq "Power Macintosh"} {set os_arch "powerpc"}
     625    if {$os_arch eq "i586" || $os_arch eq "i686" || $os_arch eq "x86_64"} {set os_arch "i386"}
    634626    set os_version $tcl_platform(osVersion)
    635627    set os_major [lindex [split $os_version .] 0]
     
    638630    set os_endian [string range $tcl_platform(byteOrder) 0 end-6]
    639631    set macosx_version {}
    640     if {$os_platform == "darwin"} {
     632    if {$os_platform eq "darwin"} {
    641633        # This will probably break when Apple changes versioning
    642         set macosx_version [expr 10.0 + ($os_major - 4) / 10.0]
     634        set macosx_version [expr {10.0 + ($os_major - 4) / 10.0}]
    643635    }
    644636
     
    648640        set macports::user_home $env(HOME)
    649641        set macports::macports_user_dir [file normalize $macports::autoconf::macports_user_dir]
    650     } elseif {[info exists env(SUDO_USER)] && $os_platform == "darwin"} {
     642    } elseif {[info exists env(SUDO_USER)] && $os_platform eq "darwin"} {
    651643        set macports::user_home [exec dscl -q . -read /Users/$env(SUDO_USER) NFSHomeDirectory | cut -d ' ' -f 2]
    652         set macports::macports_user_dir [file join ${macports::user_home} [string range $macports::autoconf::macports_user_dir 2 end]]
    653     } elseif {[exec id -u] != 0 && $os_platform == "darwin"} {
     644        set macports::macports_user_dir [file join $macports::user_home [string range $macports::autoconf::macports_user_dir 2 end]]
     645    } elseif {[exec id -u] != 0 && $os_platform eq "darwin"} {
    654646        set macports::user_home [exec dscl -q . -read /Users/[exec id -un] NFSHomeDirectory | cut -d ' ' -f 2]
    655         set macports::macports_user_dir [file join ${macports::user_home} [string range $macports::autoconf::macports_user_dir 2 end]]
     647        set macports::macports_user_dir [file join $macports::user_home [string range $macports::autoconf::macports_user_dir 2 end]]
    656648    } else {
    657649        # Otherwise define the user directory as a directory that will never exist
    658         set macports::macports_user_dir "/dev/null/NO_HOME_DIR"
    659         set macports::user_home "/dev/null/NO_HOME_DIR"
     650        set macports::macports_user_dir /dev/null/NO_HOME_DIR
     651        set macports::user_home /dev/null/NO_HOME_DIR
    660652    }
    661653
    662654    # Configure the search path for configuration files
    663     set conf_files ""
    664     lappend conf_files "${macports_conf_path}/macports.conf"
    665     if { [file isdirectory $macports_user_dir] } {
    666         lappend conf_files "${macports_user_dir}/macports.conf"
     655    set conf_files {}
     656    lappend conf_files ${macports_conf_path}/macports.conf
     657    if {[file isdirectory $macports_user_dir]} {
     658        lappend conf_files ${macports_user_dir}/macports.conf
    667659    }
    668660    if {[info exists env(PORTSRC)]} {
    669661        set PORTSRC $env(PORTSRC)
    670         lappend conf_files ${PORTSRC}
     662        lappend conf_files $PORTSRC
    671663    }
    672664
    673665    # Process all configuration files we find on conf_files list
    674666    foreach file $conf_files {
    675         if [file exists $file] {
     667        if {[file exists $file]} {
    676668            set portconf $file
    677669            set fd [open $file r]
     
    689681
    690682    # Process per-user only settings
    691     set per_user "${macports_user_dir}/user.conf"
    692     if [file exists $per_user] {
     683    set per_user ${macports_user_dir}/user.conf
     684    if {[file exists $per_user]} {
    693685        set fd [open $per_user r]
    694686        while {[gets $fd line] >= 0} {
     
    716708                        ui_warn "$sources_conf source '$line' specifies invalid flag '$flag'"
    717709                    }
    718                     if {$flag == "default"} {
     710                    if {$flag eq "default"} {
    719711                        if {[info exists sources_default]} {
    720712                            ui_warn "More than one default port source is defined."
     
    734726    # contain _resources.
    735727    if {![info exists sources_default]} {
    736         ui_warn "No default port source specified in $sources_conf, using last source as default"
     728        ui_warn "No default port source specified in ${sources_conf}, using last source as default"
    737729        set sources_default [lindex $sources end]
    738730    }
     
    740732    if {![info exists sources]} {
    741733        if {[file isdirectory ports]} {
    742             set sources "file://[pwd]/ports"
     734            set sources file://[pwd]/ports
    743735        } else {
    744736            return -code error "No sources defined in $sources_conf"
     
    747739
    748740    if {[info exists variants_conf]} {
    749         if {[file exist $variants_conf]} {
     741        if {[file exists $variants_conf]} {
    750742            set fd [open $variants_conf r]
    751743            while {[gets $fd line] >= 0} {
     
    773765    # pubkeys.conf
    774766    set macports::archivefetch_pubkeys {}
    775     if {[file isfile [file join ${macports_conf_path} pubkeys.conf]]} {
    776         set fd [open [file join ${macports_conf_path} pubkeys.conf] r]
     767    if {[file isfile [file join $macports_conf_path pubkeys.conf]]} {
     768        set fd [open [file join $macports_conf_path pubkeys.conf] r]
    777769        while {[gets $fd line] >= 0} {
    778770            set line [string trim $line]
     
    804796    # Format for receipts; currently only "sqlite" is allowed
    805797    # could previously be "flat", so we switch that to sqlite
    806     if {![info exists portdbformat] || $portdbformat == "flat" || $portdbformat == "sqlite"} {
     798    if {![info exists portdbformat] || $portdbformat eq "flat" || $portdbformat eq "sqlite"} {
    807799        set registry.format receipt_sqlite
    808800    } else {
     
    812804    # Autoclean mode, whether to automatically call clean after "install"
    813805    if {![info exists portautoclean]} {
    814         set macports::portautoclean "yes"
     806        set macports::portautoclean yes
    815807        global macports::portautoclean
    816808    }
    817809    # whether to keep logs after successful builds
    818810    if {![info exists keeplogs]} {
    819         set macports::keeplogs "no"
     811        set macports::keeplogs no
    820812        global macports::keeplogs
    821813    }
    822    
     814
    823815    # Check command line override for autoclean
    824816    if {[info exists macports::global_options(ports_autoclean)]} {
    825         if {![string equal $macports::global_options(ports_autoclean) $portautoclean]} {
     817        if {$macports::global_options(ports_autoclean) ne $portautoclean} {
    826818            set macports::portautoclean $macports::global_options(ports_autoclean)
    827819        }
     
    829821    # Trace mode, whether to use darwintrace to debug ports.
    830822    if {![info exists porttrace]} {
    831         set macports::porttrace "no"
     823        set macports::porttrace no
    832824        global macports::porttrace
    833825    }
    834826    # Check command line override for trace
    835827    if {[info exists macports::global_options(ports_trace)]} {
    836         if {![string equal $macports::global_options(ports_trace) $porttrace]} {
     828        if {$macports::global_options(ports_trace) ne $porttrace} {
    837829            set macports::porttrace $macports::global_options(ports_trace)
    838830        }
     
    842834        && ![info exists macports::global_options(ports_source_only)]
    843835        && [info exists macports::buildfromsource]} {
    844         if {${macports::buildfromsource} == "never"} {
     836        if {$macports::buildfromsource eq "never"} {
    845837            set macports::global_options(ports_binary_only) yes
    846838            set temp_options(ports_binary_only) yes
    847         } elseif {${macports::buildfromsource} == "always"} {
     839        } elseif {$macports::buildfromsource eq "always"} {
    848840            set macports::global_options(ports_source_only) yes
    849841            set temp_options(ports_source_only) yes
    850         } elseif {${macports::buildfromsource} != "ifneeded"} {
    851             ui_warn "'buildfromsource' set to unknown value '${macports::buildfromsource}', using 'ifneeded' instead"
     842        } elseif {$macports::buildfromsource ne "ifneeded"} {
     843            ui_warn "'buildfromsource' set to unknown value '$macports::buildfromsource', using 'ifneeded' instead"
    852844        }
    853845    }
     
    863855    # Export verbosity.
    864856    if {![info exists portverbose]} {
    865         set macports::portverbose "no"
     857        set macports::portverbose no
    866858        global macports::portverbose
    867859    }
    868860    if {[info exists macports::ui_options(ports_verbose)]} {
    869         if {![string equal $macports::ui_options(ports_verbose) $portverbose]} {
     861        if {$macports::ui_options(ports_verbose) ne $portverbose} {
    870862            set macports::portverbose $macports::ui_options(ports_verbose)
    871863        }
     
    876868    global macports::portarchivetype
    877869    if {![info exists portarchivetype]} {
    878         set macports::portarchivetype "tbz2"
     870        set macports::portarchivetype tbz2
    879871    } else {
    880872        set macports::portarchivetype [lindex $portarchivetype 0]
     
    883875    # Set rync options
    884876    if {![info exists rsync_server]} {
     877        global macports::rsync_server
    885878        set macports::rsync_server rsync.macports.org
    886         global macports::rsync_server
    887879    }
    888880    if {![info exists rsync_dir]} {
     881        global macports::rsync_dir
    889882        set macports::rsync_dir release/tarballs/base.tar
    890         global macports::rsync_dir
    891883    }
    892884    if {![info exists rsync_options]} {
     885        global macports::rsync_options
    893886        set rsync_options "-rtzv --delete-after"
    894         global macports::rsync_options
    895887    }
    896888
     
    901893
    902894    if {![info exists libpath]} {
    903         set libpath "${prefix}/share/macports/Tcl"
     895        set libpath ${prefix}/share/macports/Tcl
    904896    }
    905897
    906898    if {![info exists binpath]} {
    907         set env(PATH) "${prefix}/bin:${prefix}/sbin:/bin:/sbin:/usr/bin:/usr/sbin"
     899        set env(PATH) ${prefix}/bin:${prefix}/sbin:/bin:/sbin:/usr/bin:/usr/sbin
    908900    } else {
    909         set env(PATH) "$binpath"
     901        set env(PATH) $binpath
    910902    }
    911903
    912904    # Set startupitem default type (can be overridden by portfile)
    913905    if {![info exists macports::startupitem_type]} {
    914         set macports::startupitem_type "default"
     906        set macports::startupitem_type default
    915907    }
    916908
     
    933925    }
    934926    if {![info exists macports::ccache_size]} {
    935         set macports::ccache_size "2G"
     927        set macports::ccache_size 2G
    936928    }
    937929    if {![info exists macports::configuredistcc]} {
     
    965957        ui_warn "invalid universal_archs configured (should contain at least 2 archs)"
    966958    }
    967    
     959
    968960    # Default arch to build for
    969961    if {![info exists macports::build_arch]} {
    970         if {$os_platform == "darwin"} {
     962        if {$os_platform eq "darwin"} {
    971963            if {$os_major >= 10} {
    972964                if {[sysctl hw.cpu64bit_capable] == 1} {
     
    976968                }
    977969            } else {
    978                 if {$os_arch == "powerpc"} {
     970                if {$os_arch eq "powerpc"} {
    979971                    set macports::build_arch ppc
    980972                } else {
     
    983975            }
    984976        } else {
    985             set macports::build_arch ""
     977            set macports::build_arch {}
    986978        }
    987979    } else {
     
    997989    }
    998990    if {![info exists macports::revupgrade_mode]} {
    999         set macports::revupgrade_mode "rebuild"
     991        set macports::revupgrade_mode rebuild
    1000992    }
    1001993    if {![info exists macports::global_options(ports_rev-upgrade_id-loadcmd-check)]
    1002994         && [info exists macports::revupgrade_check_id_loadcmds]} {
    1003         set macports::global_options(ports_rev-upgrade_id-loadcmd-check) ${macports::revupgrade_check_id_loadcmds}
    1004         set temp_options(ports_rev-upgrade_id-loadcmd-check) ${macports::revupgrade_check_id_loadcmds}
     995        set macports::global_options(ports_rev-upgrade_id-loadcmd-check) $macports::revupgrade_check_id_loadcmds
     996        set temp_options(ports_rev-upgrade_id-loadcmd-check) $macports::revupgrade_check_id_loadcmds
     997    }
     998
     999    if {![info exists macports::sandbox_enable]} {
     1000        set macports::sandbox_enable yes
    10051001    }
    10061002
     
    10201016    }
    10211017    if {[info exists extra_env]} {
    1022         set keepenvkeys [concat ${keepenvkeys} ${extra_env}]
     1018        set keepenvkeys [concat $keepenvkeys $extra_env]
    10231019    }
    10241020
     
    10401036    # don't keep unusable TMPDIR/TMP values
    10411037    foreach var {TMP TMPDIR} {
    1042         if {[info exists env($var)] && [file writable $env($var)] && 
    1043             ([getuid] != 0 || $macportsuser == "root" ||
    1044              [file attributes $env($var) -owner] == $macportsuser)} {
     1038        if {[info exists env($var)] && [file writable $env($var)] &&
     1039            ([getuid] != 0 || $macportsuser eq "root" ||
     1040             [file attributes $env($var) -owner] eq $macportsuser)} {
    10451041            lappend keepenvkeys $var
    10461042        }
     
    10551051
    10561052    # unset environment an extra time, to work around bugs in Leopard Tcl
    1057     if {$macosx_version == "10.5"} {
     1053    if {$macosx_version eq "10.5"} {
    10581054        foreach envkey $env_names {
    10591055            if {[lsearch -exact $keepenvkeys $envkey] == -1} {
     
    10761072
    10771073    if {![info exists developer_dir]} {
    1078         if {$os_platform == "darwin"} {
     1074        if {$os_platform eq "darwin"} {
    10791075            trace add variable macports::developer_dir read macports::set_developer_dir
    10801076        } else {
    1081             set macports::developer_dir ""
     1077            set macports::developer_dir {}
    10821078        }
    10831079    } else {
    1084         if {$os_platform == "darwin" && ![file isdirectory $developer_dir]} {
     1080        if {$os_platform eq "darwin" && ![file isdirectory $developer_dir]} {
    10851081            ui_warn "Your developer_dir setting in macports.conf points to a non-existing directory.\
    10861082                Since this is known to cause problems, please correct the setting or comment it and let\
     
    10891085    }
    10901086
    1091     if {[getuid] == 0 && $os_major >= 11 && $os_platform == "darwin" &&
     1087    if {[getuid] == 0 && $os_major >= 11 && $os_platform eq "darwin" &&
    10921088            [file isfile "${macports::user_home}/Library/Preferences/com.apple.dt.Xcode.plist"]} {
    10931089        macports::copy_xcode_plist $env(HOME)
     
    11001096
    11011097    if {[info exists master_site_local] && ![info exists env(MASTER_SITE_LOCAL)]} {
    1102         set env(MASTER_SITE_LOCAL) "$master_site_local"
     1098        set env(MASTER_SITE_LOCAL) $master_site_local
    11031099    }
    11041100    if {[info exists patch_site_local] && ![info exists env(PATCH_SITE_LOCAL)]} {
    1105         set env(PATCH_SITE_LOCAL) "$patch_site_local"
     1101        set env(PATCH_SITE_LOCAL) $patch_site_local
    11061102    }
    11071103    if {[info exists archive_site_local] && ![info exists env(ARCHIVE_SITE_LOCAL)]} {
    1108         set env(ARCHIVE_SITE_LOCAL) "$archive_site_local"
     1104        set env(ARCHIVE_SITE_LOCAL) $archive_site_local
    11091105    }
    11101106
    11111107    # Proxy handling (done this late since Pextlib is needed)
    1112     if {![info exists proxy_override_env] } {
    1113         set proxy_override_env "no"
     1108    if {![info exists proxy_override_env]} {
     1109        set proxy_override_env no
    11141110    }
    11151111    if {[catch {array set sysConfProxies [get_systemconfiguration_proxies]} result]} {
    11161112        return -code error "Unable to get proxy configuration from system: $result"
    11171113    }
    1118     if {![info exists env(http_proxy)] || $proxy_override_env == "yes" } {
     1114    if {![info exists env(http_proxy)] || $proxy_override_env eq "yes"} {
    11191115        if {[info exists proxy_http]} {
    11201116            set env(http_proxy) $proxy_http
     
    11231119        }
    11241120    }
    1125     if {![info exists env(HTTPS_PROXY)] || $proxy_override_env == "yes" } {
     1121    if {![info exists env(HTTPS_PROXY)] || $proxy_override_env eq "yes"} {
    11261122        if {[info exists proxy_https]} {
    11271123            set env(HTTPS_PROXY) $proxy_https
     
    11301126        }
    11311127    }
    1132     if {![info exists env(FTP_PROXY)] || $proxy_override_env == "yes" } {
     1128    if {![info exists env(FTP_PROXY)] || $proxy_override_env eq "yes"} {
    11331129        if {[info exists proxy_ftp]} {
    11341130            set env(FTP_PROXY) $proxy_ftp
     
    11371133        }
    11381134    }
    1139     if {![info exists env(RSYNC_PROXY)] || $proxy_override_env == "yes" } {
     1135    if {![info exists env(RSYNC_PROXY)] || $proxy_override_env eq "yes"} {
    11401136        if {[info exists proxy_rsync]} {
    11411137            set env(RSYNC_PROXY) $proxy_rsync
    11421138        }
    11431139    }
    1144     if {![info exists env(NO_PROXY)] || $proxy_override_env == "yes" } {
     1140    if {![info exists env(NO_PROXY)] || $proxy_override_env eq "yes"} {
    11451141        if {[info exists proxy_skip]} {
    11461142            set env(NO_PROXY) $proxy_skip
     
    11511147
    11521148    # add ccache to environment
    1153     set env(CCACHE_DIR) ${macports::ccache_dir}
     1149    set env(CCACHE_DIR) $macports::ccache_dir
    11541150
    11551151    # load cached ping times
     
    11581154        array set macports::ping_cache [gets $pingfile]
    11591155        close $pingfile
    1160     }]} { array set macports::ping_cache {} }
     1156    }]} {array set macports::ping_cache {}}
    11611157    # set up arrays of blacklisted and preferred hosts
    11621158    if {[info exists macports::host_blacklist]} {
    1163         foreach host ${macports::host_blacklist} {
     1159        foreach host $macports::host_blacklist {
    11641160            set macports::host_blacklisted($host) 1
    11651161        }
    11661162    }
    11671163    if {[info exists macports::preferred_hosts]} {
    1168         foreach host ${macports::preferred_hosts} {
     1164        foreach host $macports::preferred_hosts {
    11691165            set macports::host_preferred($host) 1
    11701166        }
     
    11751171
    11761172    if {![info exists macports::ui_options(ports_no_old_index_warning)]} {
    1177         set default_source_url [lindex ${sources_default} 0]
    1178         if {[macports::getprotocol $default_source_url] == "file" || [macports::getprotocol $default_source_url] == "rsync"} {
     1173        set default_source_url [lindex $sources_default 0]
     1174        if {[macports::getprotocol $default_source_url] eq "file" || [macports::getprotocol $default_source_url] eq "rsync"} {
    11791175            set default_portindex [macports::getindex $default_source_url]
    1180             if {[file exists $default_portindex] && [expr [clock seconds] - [file mtime $default_portindex]] > 1209600} {
     1176            if {[file exists $default_portindex] && [clock seconds] - [file mtime $default_portindex] > 1209600} {
    11811177                ui_warn "port definitions are more than two weeks old, consider updating them by running 'port selfupdate'."
    11821178            }
     
    11951191        ui_warn "Converting your registry to sqlite format, this might take a while..."
    11961192        if {[catch {registry::convert_to_sqlite}]} {
    1197             ui_debug "$::errorInfo"
     1193            ui_debug $::errorInfo
    11981194            file delete -force $db_path
    11991195            error "Failed to convert your registry to sqlite!"
     
    12081204    # save ping times
    12091205    global macports::ping_cache macports::portdbpath
    1210     if {[file writable ${macports::portdbpath}]} {
     1206    if {[file writable $macports::portdbpath]} {
    12111207        catch {
    12121208            foreach host [array names ping_cache] {
    12131209                # don't save expired entries
    1214                 if {[expr [clock seconds] - [lindex $ping_cache($host) 1]] < 86400} {
     1210                if {[clock seconds] - [lindex $ping_cache($host) 1] < 86400} {
    12151211                    lappend pinglist_fresh $host $ping_cache($host)
    12161212                }
     
    12321228    file delete -force "${target_dir}/com.apple.dt.Xcode.plist"
    12331229    if {[file isfile $user_plist]} {
    1234         if {![file isdirectory "${target_dir}"]} {
    1235             if {[catch {file mkdir "${target_dir}"} result]} {
     1230        if {![file isdirectory $target_dir]} {
     1231            if {[catch {file mkdir $target_dir} result]} {
    12361232                ui_warn "Failed to create Library/Preferences in ${target_homedir}: $result"
    12371233                return
    12381234            }
    12391235        }
    1240         if {[file writable ${target_dir}] && [catch {
    1241             ui_debug "Copying $user_plist to ${target_dir}"
     1236        if {[file writable $target_dir] && [catch {
     1237            ui_debug "Copying $user_plist to $target_dir"
    12421238            file copy -force $user_plist $target_dir
    1243             file attributes "${target_dir}/com.apple.dt.Xcode.plist" -owner $macportsuser -permissions 0644
     1239            file attributes ${target_dir}/com.apple.dt.Xcode.plist -owner $macportsuser -permissions 0644
    12441240        } result]} {
    12451241            ui_warn "Failed to copy com.apple.dt.Xcode.plist to ${target_dir}: $result"
     
    12801276
    12811277    # instantiate the UI call-backs
    1282     foreach priority ${macports::ui_priorities} {
     1278    foreach priority $macports::ui_priorities {
    12831279        $workername alias ui_$priority ui_$priority
    1284         foreach phase ${macports::port_phases} {
    1285             $workername alias ui_${priority}_${phase} ui_${priority}_${phase}
    1286         }
    1287  
     1280        foreach phase $macports::port_phases {
     1281            $workername alias ui_${priority}_$phase ui_${priority}_$phase
     1282        }
     1283
    12881284    }
    12891285
    12901286    $workername alias ui_prefix ui_prefix
    12911287    $workername alias ui_channels ui_channels
    1292    
     1288
    12931289    $workername alias ui_warn_once ui_warn_once
    12941290
     
    14141410        .tbz -
    14151411        .tbz2 {
    1416             return "-j"
     1412            return -j
    14171413        }
    14181414        .tgz {
    1419             return "-z"
     1415            return -z
    14201416        }
    14211417        .txz {
     
    14261422        }
    14271423        default {
    1428             return "-"
     1424            return -
    14291425        }
    14301426    }
     
    14511447    set tarcmd [findBinary tar $macports::autoconf::tar_path]
    14521448    set tarflags [get_tar_flags [file extension $fetchfile]]
    1453     set qflag ${macports::autoconf::tar_q}
     1449    set qflag $macports::autoconf::tar_q
    14541450    set cmdline "$tarcmd ${tarflags}${qflag}xOf \"$fetchfile\" +CONTENTS"
    1455     ui_debug "$cmdline"
     1451    ui_debug $cmdline
    14561452    if {![catch {set contents [eval exec $cmdline]}]} {
    14571453        set binary 1
    14581454        ui_debug "getting port name from binary archive"
    14591455        # get the portname from the contents file
    1460         foreach line [split $contents "\n"] {
    1461             if {[lindex $line 0] == "@name"} {
    1462                 # actually ${name}-${version}_${revision}
     1456        foreach line [split $contents \n] {
     1457            if {[lindex $line 0] eq "@name"} {
     1458                # actually ${name}-${version}_$revision
    14631459                set portname [lindex $line 1]
    14641460            }
     
    14791475        set cmdline "$tarcmd ${tarflags}xf \"$fetchfile\""
    14801476    }
    1481     ui_debug "$cmdline"
     1477    ui_debug $cmdline
    14821478    if {[catch {eval exec $cmdline} result]} {
    14831479        return -code error "Port extract failed: $result"
     
    14901486proc macports::getprotocol {url} {
    14911487    if {[regexp {(?x)([^:]+)://.+} $url match protocol] == 1} {
    1492         return ${protocol}
     1488        return $protocol
    14931489    } else {
    14941490        return -code error "Can't parse url $url"
     
    15001496# fetched port will be downloaded to (currently only applies to
    15011497# mports:// sources).
    1502 proc macports::getportdir {url {destdir "."}} {
     1498proc macports::getportdir {url {destdir .}} {
    15031499    global macports::extracted_portdirs
    15041500    set protocol [macports::getprotocol $url]
    1505     switch ${protocol} {
     1501    switch -- $protocol {
    15061502        file {
    1507             set path [file normalize [string range $url [expr [string length $protocol] + 3] end]]
     1503            set path [file normalize [string range $url [expr {[string length $protocol] + 3}] end]]
    15081504            if {![file isfile $path]} {
    15091505                return $path
     
    15431539# @param fallback fall back to the default source tree
    15441540# @return path to the _resources directory or the path to the fallback
    1545 proc macports::getportresourcepath {url {path ""} {fallback yes}} {
     1541proc macports::getportresourcepath {url {path {}} {fallback yes}} {
    15461542    global macports::sources_default
    15471543
    15481544    set protocol [getprotocol $url]
    15491545
    1550     switch -- ${protocol} {
     1546    switch -- $protocol {
    15511547        file {
    15521548            set proposedpath [file normalize [file join [getportdir $url] .. ..]]
     
    15601556    set proposedpath [file join $proposedpath _resources $path]
    15611557
    1562     if {$fallback == "yes" && ![file exists $proposedpath]} {
     1558    if {$fallback eq "yes" && ![file exists $proposedpath]} {
    15631559        return [getdefaultportresourcepath $path]
    15641560    }
     
    15721568# @param path path in _resources we are interested in
    15731569# @return path to the _resources directory of the default source
    1574 proc macports::getdefaultportresourcepath {{path ""}} {
     1570proc macports::getdefaultportresourcepath {{path {}}} {
    15751571    global macports::sources_default
    15761572
    1577     set default_source_url [lindex ${sources_default} 0]
    1578     if {[getprotocol $default_source_url] == "file"} {
     1573    set default_source_url [lindex $sources_default 0]
     1574    if {[getprotocol $default_source_url] eq "file"} {
    15791575        set proposedpath [getportdir $default_source_url]
    15801576    } else {
     
    15951591# MacPorts Portfile.
    15961592
    1597 proc mportopen {porturl {options ""} {variations ""} {nocache ""}} {
     1593proc mportopen {porturl {options {}} {variations {}} {nocache {}}} {
    15981594    global macports::portdbpath macports::portconf macports::open_mports auto_path
    15991595
    16001596    # Look for an already-open MPort with the same URL.
    16011597    # if found, return the existing reference and bump the refcount.
    1602     if {$nocache != ""} {
     1598    if {$nocache ne {}} {
    16031599        set mport {}
    16041600    } else {
    16051601        set mport [dlist_match_multi $macports::open_mports [list porturl $porturl variations $variations options $options]]
    16061602    }
    1607     if {$mport != {}} {
     1603    if {$mport ne {}} {
    16081604        # just in case more than one somehow matches
    16091605        set mport [lindex $mport 0]
     
    16181614        set portdir $options_array(portdir)
    16191615    } else {
    1620         set portdir ""
     1616        set portdir {}
    16211617    }
    16221618
     
    16651661    global macports::registry.path
    16661662    set regref [lindex [registry::entry imaged $name $version $revision $variants] 0]
    1667     set portfile_dir [file join ${registry.path} registry portfiles $name "${version}_${revision}${variants}"]
     1663    set portfile_dir [file join ${registry.path} registry portfiles $name ${version}_${revision}$variants]
    16681664    file mkdir $portfile_dir
    1669     set fd [open "${portfile_dir}/Portfile" w]
     1665    set fd [open ${portfile_dir}/Portfile w]
    16701666    puts $fd [$regref portfile]
    16711667    close $fd
    1672     file mtime "${portfile_dir}/Portfile" [$regref date]
     1668    file mtime ${portfile_dir}/Portfile [$regref date]
    16731669
    16741670    set variations {}
     
    16761672    set plusvariant [lrange [split [$regref variants] +] 1 end]
    16771673    foreach v $plusvariant {
    1678         lappend variations $v "+"
     1674        lappend variations $v +
    16791675    }
    16801676    foreach v $minusvariant {
    1681         lappend variations $v "-"
     1677        lappend variations $v -
    16821678    }
    16831679    lappend options subport $name
    1684     return [mportopen "file://${portfile_dir}/" $options $variations]
     1680    return [mportopen file://${portfile_dir}/ $options $variations]
    16851681}
    16861682
     
    16941690    mportclose $mport
    16951691    set portfiles_dir [file join ${registry.path} registry portfiles $subport]
    1696     set portfile [file join $portfiles_dir "${version}_${revision}${portvariants}" Portfile]
     1692    set portfile [file join $portfiles_dir ${version}_${revision}$portvariants Portfile]
    16971693    file delete -force $portfile [file dirname $portfile]
    16981694    if {[llength [glob -nocomplain -directory $portfiles_dir *]] == 0} {
     
    17231719        set pathToCategory [file join $root $category]
    17241720        # process the category dirs but not _resources
    1725         if {[file isdirectory $pathToCategory] && [string index [file tail $pathToCategory] 0] != "_"} {
     1721        if {[file isdirectory $pathToCategory] && [string index [file tail $pathToCategory] 0] ne "_"} {
    17261722            # Iterate on port directories.
    17271723            foreach port [lsort -increasing -unique [readdir $pathToCategory]] {
    17281724                set pathToPort [file join $pathToCategory $port]
    17291725                if {[file isdirectory $pathToPort] &&
    1730                   [file exists [file join $pathToPort "Portfile"]]} {
     1726                  [file exists [file join $pathToPort Portfile]]} {
    17311727                    # Call the function.
    17321728                    $func [file join $category $port]
     
    17781774            return [file join $path $filename]
    17791775        } else {
    1780             return ""
     1776            return {}
    17811777        }
    17821778    } else {
     
    17921788    # Check for the presence of the port in the registry
    17931789    set workername [ditem_key $mport workername]
    1794     return [$workername eval registry_exists_for_name \${subport}]
     1790    return [$workername eval registry_exists_for_name \$subport]
    17951791}
    17961792
     
    17981794proc _mportactive {mport} {
    17991795    set workername [ditem_key $mport workername]
    1800     if {![catch {set reslist [$workername eval registry_active \${subport}]}] && [llength $reslist] > 0} {
     1796    if {![catch {set reslist [$workername eval registry_active \$subport]}] && [llength $reslist] > 0} {
    18011797        set i [lindex $reslist 0]
    18021798        set name [lindex $i 0]
     
    18051801        set variants [lindex $i 3]
    18061802        array set portinfo [mportinfo $mport]
    1807         if {$name == $portinfo(name) && $version == $portinfo(version)
     1803        if {$name eq $portinfo(name) && $version == $portinfo(version)
    18081804            && $revision == $portinfo(revision) && $variants == $portinfo(canonical_active_variants)} {
    18091805            return 1
     
    18181814        return 0
    18191815    } else {
    1820         return [expr [llength $reslist] > 0]
     1816        return [expr {[llength $reslist] > 0}]
    18211817    }
    18221818}
     
    18421838        set workername [ditem_key $mport workername]
    18431839        set type [lindex [split $depspec :] 0]
    1844         switch $type {
    1845             lib { return [$workername eval _libtest $depspec] }
    1846             bin { return [$workername eval _bintest $depspec] }
    1847             path { return [$workername eval _pathtest $depspec] }
    1848             port { return 0 }
     1840        switch -- $type {
     1841            lib {return [$workername eval _libtest $depspec]}
     1842            bin {return [$workername eval _bintest $depspec]}
     1843            path {return [$workername eval _pathtest $depspec]}
     1844            port {return 0}
    18491845            default {return -code error "unknown depspec type: $type"}
    18501846        }
     
    18681864        ui_debug "Checking for conflicts against [_mportkey $mport subport]"
    18691865        foreach conflictport $portinfo(conflicts) {
    1870             if {[_mportispresent $mport port:${conflictport}]} {
     1866            if {[_mportispresent $mport port:$conflictport]} {
    18711867                lappend conflictlist $conflictport
    18721868            }
     
    18761872    }
    18771873
    1878     if {[llength ${conflictlist}] != 0} {
     1874    if {[llength $conflictlist] != 0} {
    18791875        if {[macports::global_option_isset ports_force]} {
    1880             ui_warn "Force option set; installing $portinfo(name) despite conflicts with: ${conflictlist}"
     1876            ui_warn "Force option set; installing $portinfo(name) despite conflicts with: $conflictlist"
    18811877        } else {
    18821878            if {![macports::ui_isset ports_debug]} {
    1883                 ui_msg ""
    1884             }
    1885             return -code error "Can't install $portinfo(name) because conflicting ports are installed: ${conflictlist}"
     1879                ui_msg {}
     1880            }
     1881            return -code error "Can't install $portinfo(name) because conflicting ports are installed: $conflictlist"
    18861882        }
    18871883    }
     
    19001896        ![catch {$workername eval eval_targets $target} result] && $result == 0} {
    19011897        # If auto-clean mode, clean-up after dependency install
    1902         if {[string equal ${macports::portautoclean} "yes"]} {
     1898        if {$macports::portautoclean eq "yes"} {
    19031899            # Make sure we are back in the port path before clean
    19041900            # otherwise if the current directory had been changed to
     
    19181914        global ::logenabled ::debuglogname
    19191915        ui_error "Failed to install $portname"
    1920         ui_debug "$::errorInfo"
     1916        ui_debug $::errorInfo
    19211917        if {[info exists ::logenabled] && $::logenabled && [info exists ::debuglogname]} {
    19221918            ui_notice "Please see the log file for port $portname for details:\n    $::debuglogname"
     
    19391935    }
    19401936    set portname [_mportkey $mport subport]
    1941     if {$target != "clean"} {
     1937    if {$target ne "clean"} {
    19421938        macports::push_log $mport
    19431939    }
     
    19621958        registry::exclusive_lock
    19631959        # see if we actually need to build this port
    1964         if {($target != "activate" && $target != "install") ||
     1960        if {($target ne "activate" && $target ne "install") ||
    19651961            ![$workername eval registry_exists \$subport \$version \$revision \$portvariants]} {
    1966    
     1962
    19671963            # upgrade dependencies that are already installed
    19681964            if {![macports::global_option_isset ports_nodeps]} {
     
    19741970        if {[macports::ui_isset ports_debug]} {
    19751971            # play nice with debug messages
    1976             ui_msg ""
     1972            ui_msg {}
    19771973        }
    19781974        if {[mportdepends $mport $target] != 0} {
     
    19801976        }
    19811977        if {![macports::ui_isset ports_debug]} {
    1982             ui_msg ""
     1978            ui_msg {}
    19831979        }
    19841980
     
    19881984
    19891985        dlist_delete dlist $mport
    1990        
     1986
    19911987        # print the dep list
    19921988        if {[llength $dlist] > 0} {
     
    19991995
    20001996        # install them
    2001         set result [dlist_eval $dlist _mportactive [list _mportexec "activate"]]
     1997        set result [dlist_eval $dlist _mportactive [list _mportexec activate]]
    20021998
    20031999        registry::exclusive_unlock
    20042000
    2005         if {$result != {}} {
     2001        if {$result ne {}} {
    20062002            set errstring "The following dependencies were not installed:"
    20072003            foreach ditem $result {
     
    20212017    } else {
    20222018        # No dependencies, but we still need to check for conflicts.
    2023         if {$target == "" || $target == "install" || $target == "activate"} {
     2019        if {$target eq {} || $target eq "install" || $target eq "activate"} {
    20242020            _mporterrorifconflictsinstalled $mport
    20252021        }
     
    20272023
    20282024    set clean 0
    2029     if {[string equal ${macports::portautoclean} "yes"] && ([string equal $target "install"] || [string equal $target "activate"])} {
     2025    if {$macports::portautoclean eq "yes" && ($target eq "install" || $target eq "activate")} {
    20302026        # If we're doing an install, check if we should clean after
    20312027        set clean 1
     
    20422038        $workername eval eval_targets clean
    20432039    }
    2044    
     2040
    20452041    global ::logenabled ::debuglogname
    20462042    if {[info exists ::logenabled] && $::logenabled && [info exists ::debuglogname]} {
     
    20732069        foreach depspec $portinfo($deptype) {
    20742070            set dep_portname [$workername eval _get_dep_port $depspec]
    2075             if {$dep_portname != "" && ![info exists depscache(port:$dep_portname)] && [$test $dep_portname]} {
     2071            if {$dep_portname ne {} && ![info exists depscache(port:$dep_portname)] && [$test $dep_portname]} {
    20762072                set variants {}
    2077    
     2073
    20782074                # check that the dep has the required archs
    20792075                set active_archs [_get_registry_archs $dep_portname]
    2080                 if {$deptype != "depends_fetch" && $deptype != "depends_extract"
    2081                     && $active_archs != "" && $active_archs != "noarch" && $required_archs != "noarch"
     2076                if {$deptype ne "depends_fetch" && $deptype ne "depends_extract"
     2077                    && $active_archs ne {} && $active_archs ne "noarch" && $required_archs ne "noarch"
    20822078                    && [lsearch -exact $depends_skip_archcheck $dep_portname] == -1} {
    20832079                    set missing {}
     
    21312127                    }
    21322128                }
    2133    
    2134                 set status [macports::upgrade $dep_portname "port:$dep_portname" $variants $options depscache]
     2129
     2130                set status [macports::upgrade $dep_portname port:$dep_portname $variants $options depscache]
    21352131                # status 2 means the port was not found in the index
    21362132                if {$status != 0 && $status != 2 && ![macports::ui_isset ports_processall]} {
     
    21492145    set archs [registry::property_retrieve $regref archs]
    21502146    if {$archs == 0} {
    2151         set archs ""
     2147        set archs {}
    21522148    }
    21532149    return $archs
     
    21732169# @param url source URL to check
    21742170# @return a list containing filename and extension or an empty list
    2175 proc _source_is_snapshot {url {filename ""} {extension ""}} {
     2171proc _source_is_snapshot {url {filename {}} {extension {}}} {
    21762172    upvar $filename myfilename
    21772173    upvar $extension myextension
     
    21872183}
    21882184
    2189 proc macports::getportbuildpath {id {portname ""}} {
     2185proc macports::getportbuildpath {id {portname {}}} {
    21902186    global macports::portdbpath
    21912187    regsub {://} $id {.} port_path
     
    21942190}
    21952191
    2196 proc macports::getportlogpath {id {portname ""}} {
     2192proc macports::getportlogpath {id {portname {}}} {
    21972193    global macports::portdbpath
    21982194    regsub {://} $id {.} port_path
     
    22052201}
    22062202
    2207 proc macports::getportworkpath_from_portdir {portpath {portname ""}} {
     2203proc macports::getportworkpath_from_portdir {portpath {portname {}}} {
    22082204    return [macports::getportworkpath_from_buildpath [macports::getportbuildpath $portpath $portname]]
    22092205}
     
    22112207proc macports::getindex {source} {
    22122208    # Special case file:// sources
    2213     if {[macports::getprotocol $source] == "file"} {
     2209    if {[macports::getprotocol $source] eq "file"} {
    22142210        return [file join [macports::getportdir $source] PortIndex]
    22152211    }
     
    22192215
    22202216proc mportsync {{optionslist {}}} {
    2221     global macports::sources macports::portdbpath macports::rsync_options tcl_platform
    2222     global macports::portverbose
    2223     global macports::autoconf::rsync_path macports::autoconf::tar_path macports::autoconf::openssl_path
     2217    global macports::sources macports::portdbpath macports::rsync_options \
     2218           tcl_platform macports::portverbose macports::autoconf::rsync_path \
     2219          macports::autoconf::tar_path macports::autoconf::openssl_path
    22242220    array set options $optionslist
    22252221    if {[info exists options(no_reindex)]} {
     
    22422238            {^file$} {
    22432239                set portdir [macports::getportdir $source]
    2244                 set svn_cmd ""
     2240                set svn_cmd {}
    22452241                catch {set svn_cmd [macports::findBinary svn]}
    2246                 set git_cmd ""
     2242                set git_cmd {}
    22472243                catch {set git_cmd [macports::findBinary git]}
    2248                 if {$svn_cmd != "" && ([file exists $portdir/.svn] || ![catch {exec $svn_cmd info $portdir > /dev/null 2>@1}])} {
    2249                     set svn_commandline "$svn_cmd update --non-interactive ${portdir}"
     2244                if {$svn_cmd ne {} && ([file exists ${portdir}/.svn] || ![catch {exec $svn_cmd info $portdir > /dev/null 2>@1}])} {
     2245                    set svn_commandline "$svn_cmd update --non-interactive $portdir"
    22502246                    ui_debug $svn_commandline
    22512247                    if {
     
    22652261                        }]
    22662262                    } {
    2267                         ui_debug "$::errorInfo"
     2263                        ui_debug $::errorInfo
    22682264                        ui_error "Synchronization of the local ports tree failed doing an svn update"
    22692265                        incr numfailed
    22702266                        continue
    22712267                    }
    2272                 } elseif {$git_cmd != "" && [file exists $portdir/.git]} {
     2268                } elseif {$git_cmd ne {} && [file exists ${portdir}/.git]} {
    22732269                    set git_commandline "pushd $portdir ; $git_cmd pull --rebase ; popd"
    22742270                    ui_debug $git_commandline
     
    22892285                        }]
    22902286                    } {
    2291                         ui_debug "$::errorInfo"
     2287                        ui_debug $::errorInfo
    22922288                        ui_error "Synchronization of the local ports tree failed doing a git pull --rebase"
    22932289                        incr numfailed
     
    23082304
    23092305                if {$is_tarball} {
    2310                     set exclude_option ""
     2306                    set exclude_option {}
    23112307                    # need to do a few things before replacing the ports tree in this case
    23122308                    set destdir [file dirname $destdir]
    23132309                } else {
    23142310                    # Keep rsync happy with a trailing slash
    2315                     if {[string index $source end] != "/"} {
    2316                         append source "/"
     2311                    if {[string index $source end] ne "/"} {
     2312                        append source /
    23172313                    }
    23182314                    # don't sync PortIndex yet; we grab the platform specific one afterwards
    2319                     set exclude_option "'--exclude=/PortIndex*'"
     2315                    set exclude_option '--exclude=/PortIndex*'
    23202316                }
    23212317                # Do rsync fetch
    2322                 set rsync_commandline "${macports::autoconf::rsync_path} ${rsync_options} ${exclude_option} ${source} ${destdir}"
     2318                set rsync_commandline "$macports::autoconf::rsync_path $rsync_options $exclude_option $source $destdir"
    23232319                ui_debug $rsync_commandline
    23242320                if {[catch {system $rsync_commandline}]} {
     
    23312327                    # verify signature for tarball
    23322328                    global macports::archivefetch_pubkeys
    2333                     set rsync_commandline "${macports::autoconf::rsync_path} ${rsync_options} ${exclude_option} ${source}.rmd160 ${destdir}"
     2329                    set rsync_commandline "$macports::autoconf::rsync_path $rsync_options $exclude_option ${source}.rmd160 $destdir"
    23342330                    ui_debug $rsync_commandline
    23352331                    if {[catch {system $rsync_commandline}]} {
     
    23382334                        continue
    23392335                    }
    2340                     set tarball "${destdir}/[file tail $source]"
    2341                     set signature "${tarball}.rmd160"
     2336                    set tarball ${destdir}/[file tail $source]
     2337                    set signature ${tarball}.rmd160
    23422338                    set openssl [macports::findBinary openssl $macports::autoconf::openssl_path]
    23432339                    set verified 0
    2344                     foreach pubkey ${macports::archivefetch_pubkeys} {
     2340                    foreach pubkey $macports::archivefetch_pubkeys {
    23452341                        if {![catch {exec $openssl dgst -ripemd160 -verify $pubkey -signature $signature $tarball} result]} {
    23462342                            set verified 1
     
    23612357                    set tar [macports::findBinary tar $macports::autoconf::tar_path]
    23622358                    file mkdir ${destdir}/tmp
    2363                     set tar_cmd "$tar -C ${destdir}/tmp -xf ${tarball}"
     2359                    set tar_cmd "$tar -C ${destdir}/tmp -xf $tarball"
    23642360                    ui_debug $tar_cmd
    23652361                    if {[catch {system $tar_cmd}]} {
     
    23832379                set needs_portindex 1
    23842380                # now sync the index if the local file is missing or older than a day
    2385                 if {![file isfile $indexfile] || [expr [clock seconds] - [file mtime $indexfile]] > 86400
     2381                if {![file isfile $indexfile] || [clock seconds] - [file mtime $indexfile] > 86400
    23862382                      || [info exists options(no_reindex)]} {
    23872383                    if {$is_tarball} {
     
    23892385                        set index_source [string range $source 0 end-[string length [file tail $source]]]
    23902386                    } else {
    2391                         set index_source $source 
     2387                        set index_source $source
    23922388                    }
    23932389                    set remote_indexfile "${index_source}PortIndex_${macports::os_platform}_${macports::os_major}_${macports::os_arch}/PortIndex"
    2394                     set rsync_commandline "${macports::autoconf::rsync_path} ${rsync_options} $remote_indexfile ${destdir}"
     2390                    set rsync_commandline "$macports::autoconf::rsync_path $rsync_options $remote_indexfile $destdir"
    23952391                    ui_debug $rsync_commandline
    23962392                    if {[catch {system $rsync_commandline}]} {
     
    24032399                            set needs_portindex 1
    24042400                            # verify signature for PortIndex
    2405                             set rsync_commandline "${macports::autoconf::rsync_path} ${rsync_options} ${remote_indexfile}.rmd160 ${destdir}"
     2401                            set rsync_commandline "$macports::autoconf::rsync_path $rsync_options ${remote_indexfile}.rmd160 $destdir"
    24062402                            ui_debug $rsync_commandline
    24072403                            if {![catch {system $rsync_commandline}]} {
    2408                                 foreach pubkey ${macports::archivefetch_pubkeys} {
     2404                                foreach pubkey $macports::archivefetch_pubkeys {
    24092405                                    if {![catch {exec $openssl dgst -ripemd160 -verify $pubkey -signature ${destdir}/PortIndex.rmd160 ${destdir}/PortIndex} result]} {
    24102406                                        set ok 1
     
    24472443                    }
    24482444
    2449                     if {(![info exists options(ports_force)] || $options(ports_force) != "yes") && $updated <= 0} {
     2445                    if {(![info exists options(ports_force)] || $options(ports_force) ne "yes") && $updated <= 0} {
    24502446                        ui_info "No updates for $source"
    24512447                        continue
     
    24552451
    24562452                    set verboseflag {}
    2457                     if {$macports::portverbose == "yes"} {
    2458                         set verboseflag "-v"
     2453                    if {$macports::portverbose eq "yes"} {
     2454                        set verboseflag -v
    24592455                    }
    24602456
     
    24662462
    24672463                    set extflag {}
    2468                     switch $extension {
     2464                    switch -- $extension {
    24692465                        {tar.gz} {
    2470                             set extflag "-z"
     2466                            set extflag -z
    24712467                        }
    24722468                        {tar.bz2} {
    2473                             set extflag "-j"
     2469                            set extflag -j
    24742470                        }
    24752471                    }
    24762472
    24772473                    set tar [macports::findBinary tar $macports::autoconf::tar_path]
    2478                     if { [catch { system "cd $destdir/.. && $tar ${verboseflag} ${extflag} -xf $filename" } error] } {
     2474                    if {[catch {system "cd ${destdir}/.. && $tar $verboseflag $extflag -xf $filename"} error]} {
    24792475                        ui_error "Extracting $source failed ($error)"
    24802476                        incr numfailed
     
    24872483
    24882484                    set platindex "PortIndex_${macports::os_platform}_${macports::os_major}_${macports::os_arch}/PortIndex"
    2489                     if {[file isfile ${destdir}/${platindex}] && [file isfile ${destdir}/${platindex}.quick]} {
    2490                         file rename -force "${destdir}/${platindex}" "${destdir}/${platindex}.quick" $destdir
     2485                    if {[file isfile ${destdir}/$platindex] && [file isfile ${destdir}/${platindex}.quick]} {
     2486                        file rename -force ${destdir}/$platindex ${destdir}/${platindex}.quick $destdir
    24912487                    }
    24922488
     
    25042500            }
    25052501        }
    2506        
     2502
    25072503        if {$needs_portindex} {
    25082504            set any_needed_portindex 1
     
    25302526    global macports::portdbpath macports::sources
    25312527    set matches [list]
    2532     set easy [expr { $field == "name" }]
     2528    set easy [expr {$field eq "name"}]
    25332529
    25342530    set found 0
     
    25362532        set source [lindex $source 0]
    25372533        set protocol [macports::getprotocol $source]
    2538         if {$protocol == "mports"} {
     2534        if {$protocol eq "mports"} {
    25392535            set res [macports::index::search $macports::portdbpath $source [list name $pattern]]
    25402536            eval lappend matches $res
     
    25592555                        }
    25602556
    2561                         switch $matchstyle {
     2557                        switch -- $matchstyle {
    25622558                            exact {
    2563                                 set matchres [expr 0 == ( {$case_sensitive == "yes"} ? [string compare $pattern $target] : [string compare -nocase $pattern $target] )]
     2559                                set matchres [expr {0 == ($case_sensitive eq "yes" ? [string compare $pattern $target] : [string compare -nocase $pattern $target])}]
    25642560                            }
    25652561                            glob {
    2566                                 set matchres [expr {$case_sensitive == "yes"} ? [string match $pattern $target] : [string match -nocase $pattern $target]]
     2562                                set matchres [expr {$case_sensitive eq "yes" ? [string match $pattern $target] : [string match -nocase $pattern $target]}]
    25672563                            }
    25682564                            regexp -
    25692565                            default {
    2570                                 set matchres [expr {$case_sensitive == "yes"} ? [regexp -- $pattern $target] : [regexp -nocase -- $pattern $target]]
     2566                                set matchres [expr {$case_sensitive eq "yes" ? [regexp -- $pattern $target] : [regexp -nocase -- $pattern $target]}]
    25712567                            }
    25722568                        }
     
    25762572                                array set portinfo $line
    25772573                            }
    2578                             switch $protocol {
     2574                            switch -- $protocol {
    25792575                                rsync {
    25802576                                    # Rsync files are local
    2581                                     set source_url "file://[macports::getsourcepath $source]"
     2577                                    set source_url file://[macports::getsourcepath $source]
    25822578                                }
    25832579                                https -
     
    25862582                                    if {[_source_is_snapshot $source filename extension]} {
    25872583                                        # daily snapshot tarball
    2588                                         set source_url "file://[macports::getsourcepath $source]"
     2584                                        set source_url file://[macports::getsourcepath $source]
    25892585                                    } else {
    25902586                                        # default action
     
    26112607                        }
    26122608                    }
    2613                 } catch {*} {
     2609                } catch * {
    26142610                    ui_warn "It looks like your PortIndex file for $source may be corrupt."
    26152611                    throw
     
    26402636        set source [lindex $source 0]
    26412637        set protocol [macports::getprotocol $source]
    2642         if {$protocol != "mports"} {
     2638        if {$protocol ne "mports"} {
    26432639            global macports::quick_index
    2644             if {![info exists quick_index($sourceno,[string tolower $name])]} {
     2640            if {![info exists quick_index(${sourceno},[string tolower $name])]} {
    26452641                incr sourceno 1
    26462642                continue
     
    26492645            # offset in the main PortIndex where the given port's PortInfo
    26502646            # line can be found.
    2651             set offset $quick_index($sourceno,[string tolower $name])
     2647            set offset $quick_index(${sourceno},[string tolower $name])
    26522648            incr sourceno 1
    26532649            if {[catch {set fd [open [macports::getindex $source] r]} result]} {
     
    26632659                    array set portinfo $line
    26642660
    2665                     switch $protocol {
     2661                    switch -- $protocol {
    26662662                        rsync {
    2667                             set source_url "file://[macports::getsourcepath $source]"
     2663                            set source_url file://[macports::getsourcepath $source]
    26682664                        }
    26692665                        https -
     
    26712667                        ftp {
    26722668                            if {[_source_is_snapshot $source filename extension]} {
    2673                                 set source_url "file://[macports::getsourcepath $source]"
     2669                                set source_url file://[macports::getsourcepath $source]
    26742670                             } else {
    26752671                                set source_url $source
     
    26922688                    close $fd
    26932689                    set fd -1
    2694                 } catch {*} {
     2690                } catch * {
    26952691                    ui_warn "It looks like your PortIndex file for $source may be corrupt."
    26962692                } finally {
     
    27242720        set source [lindex $source 0]
    27252721        set protocol [macports::getprotocol $source]
    2726         if {$protocol != "mports"} {
     2722        if {$protocol ne "mports"} {
    27272723            if {![catch {set fd [open [macports::getindex $source] r]} result]} {
    27282724                try {
     
    27362732                        array set portinfo $line
    27372733
    2738                         switch $protocol {
     2734                        switch -- $protocol {
    27392735                            rsync {
    2740                                 set source_url "file://[macports::getsourcepath $source]"
     2736                                set source_url file://[macports::getsourcepath $source]
    27412737                            }
    27422738                            https -
     
    27442740                            ftp {
    27452741                                if {[_source_is_snapshot $source filename extension]} {
    2746                                     set source_url "file://[macports::getsourcepath $source]"
     2742                                    set source_url file://[macports::getsourcepath $source]
    27472743                                } else {
    27482744                                    set source_url $source
     
    27632759                        lappend matches $name $line
    27642760                    }
    2765                 } catch {*} {
     2761                } catch * {
    27662762                    ui_warn "It looks like your PortIndex file for $source may be corrupt."
    27672763                    throw
     
    27982794        set source [lindex $source 0]
    27992795        set index [macports::getindex $source]
    2800         if {![file exists ${index}]} {
     2796        if {![file exists $index]} {
    28012797            incr sourceno
    28022798            continue
     
    28042800        if {![file exists ${index}.quick]} {
    28052801            ui_warn "No quick index file found, attempting to generate one for source: $source"
    2806             if {[catch {set quicklist [mports_generate_quickindex ${index}]}]} {
     2802            if {[catch {set quicklist [mports_generate_quickindex $index]}]} {
    28072803                incr sourceno
    28082804                continue
     
    28202816            }
    28212817        }
    2822         foreach entry [split $quicklist "\n"] {
    2823             set quick_index($sourceno,[lindex $entry 0]) [lindex $entry 1]
     2818        foreach entry [split $quicklist \n] {
     2819            set quick_index(${sourceno},[lindex $entry 0]) [lindex $entry 1]
    28242820        }
    28252821        incr sourceno 1
     
    28312827
    28322828proc mports_generate_quickindex {index} {
    2833     if {[catch {set indexfd [open ${index} r]} result] || [catch {set quickfd [open ${index}.quick w]} result]} {
     2829    if {[catch {set indexfd [open $index r]} result] || [catch {set quickfd [open ${index}.quick w]} result]} {
    28342830        ui_warn "Can't open index file: $index"
    28352831        return -code error
     
    28372833        try {
    28382834            set offset [tell $indexfd]
    2839             set quicklist ""
     2835            set quicklist {}
    28402836            while {[gets $indexfd line] >= 0} {
    28412837                if {[llength $line] != 2} {
     
    28432839                }
    28442840                set name [lindex $line 0]
    2845                 append quicklist "[string tolower $name] ${offset}\n"
     2841                append quicklist "[string tolower $name] $offset\n"
    28462842
    28472843                set len [lindex $line 1]
     
    28502846            }
    28512847            puts -nonewline $quickfd $quicklist
    2852         } catch {*} {
     2848        } catch * {
    28532849            ui_warn "It looks like your PortIndex file $index may be corrupt."
    28542850            throw
     
    28962892proc _mportkey {mport key} {
    28972893    set workername [ditem_key $mport workername]
    2898     return [$workername eval "return \$${key}"]
     2894    return [$workername eval "return \$$key"]
    28992895}
    29002896
     
    29142910# accDeps -> accumulator for recursive calls
    29152911# return 0 if everything was ok, an non zero integer otherwise.
    2916 proc mportdepends {mport {target ""} {recurseDeps 1} {skipSatisfied 1} {accDeps 0}} {
     2912proc mportdepends {mport {target {}} {recurseDeps 1} {skipSatisfied 1} {accDeps 0}} {
    29172913
    29182914    array set portinfo [mportinfo $mport]
     
    29252921    # progress indicator
    29262922    if {![macports::ui_isset ports_debug]} {
    2927         ui_info -nonewline "."
     2923        ui_info -nonewline .
    29282924        flush stdout
    29292925    }
    2930    
    2931     if {$target == "" || $target == "install" || $target == "activate"} {
     2926
     2927    if {$target eq {} || $target eq "install" || $target eq "activate"} {
    29322928        _mporterrorifconflictsinstalled $mport
    29332929    }
     
    29582954            set dep_portname [$workername eval _get_dep_port $depspec]
    29592955            # skip port/archs combos we've already seen, and ones with the same port but less archs than ones we've seen (or noarch)
    2960             set seenkey "${dep_portname},[join $required_archs ,]"
     2956            set seenkey ${dep_portname},[join $required_archs ,]
    29612957            set seen 0
    29622958            if {[info exists port_seen($seenkey)]} {
     
    29672963                foreach key $prev_seenkeys {
    29682964                    set key_archs [lrange [split $key ,] 1 end]
    2969                     if {$key_archs == "noarch" || $required_archs == "noarch" || [llength $key_archs] > $nrequired} {
     2965                    if {$key_archs eq "noarch" || $required_archs eq "noarch" || [llength $key_archs] > $nrequired} {
    29702966                        set seen 1
    29712967                        set seenkey $key
     
    29812977                continue
    29822978            }
    2983            
     2979
    29842980            # Is that dependency satisfied or this port installed?
    29852981            # If we don't skip or if it is not, add it to the list.
    29862982            set present [_mportispresent $mport $depspec]
    29872983
    2988             if {!$skipSatisfied && $dep_portname == ""} {
     2984            if {!$skipSatisfied && $dep_portname eq {}} {
    29892985                set dep_portname [lindex [split $depspec :] end]
    29902986            }
    29912987
    29922988            set check_archs 0
    2993             if {$dep_portname != "" && $deptype != "depends_fetch" && $deptype != "depends_extract" && [lsearch -exact $depends_skip_archcheck $dep_portname] == -1} {
     2989            if {$dep_portname ne {} && $deptype ne "depends_fetch" && $deptype ne "depends_extract" && [lsearch -exact $depends_skip_archcheck $dep_portname] == -1} {
    29942990                set check_archs 1
    29952991            }
     
    30043000                if {[catch {set res [mportlookup $dep_portname]} error]} {
    30053001                    global errorInfo
    3006                     ui_msg ""
    3007                     ui_debug "$errorInfo"
     3002                    ui_msg {}
     3003                    ui_debug $errorInfo
    30083004                    ui_error "Internal error: port lookup failed: $error"
    30093005                    return 1
     
    30143010                if {![info exists dep_portinfo(porturl)]} {
    30153011                    if {![macports::ui_isset ports_debug]} {
    3016                         ui_msg ""
     3012                        ui_msg {}
    30173013                    }
    30183014                    ui_error "Dependency '$dep_portname' not found."
     
    30283024                set depport [dlist_match_multi $macports::open_mports [list porturl $dep_portinfo(porturl) options $dep_options]]
    30293025
    3030                 if {$depport == {}} {
     3026                if {$depport eq {}} {
    30313027                    # We haven't opened this one yet.
    30323028                    set depport [mportopen $dep_portinfo(porturl) $dep_options $variations]
     
    30473043                    # a universal variant is offered
    30483044                    set has_universal 1
    3049                     if {![info exists variation_array(universal)] || $variation_array(universal) != "+"} {
     3045                    if {![info exists variation_array(universal)] || $variation_array(universal) ne "+"} {
    30503046                        set variation_array(universal) +
    30513047                        # try again with +universal
     
    30693065
    30703066                # Append the sub-port's provides to the port's requirements list.
    3071                 set depport_provides "[ditem_key $depport provides]"
     3067                set depport_provides [ditem_key $depport provides]
    30723068                ditem_append_unique $mport requires $depport_provides
    30733069                # record actual archs we ended up getting
    30743070                set port_seen(${dep_portname},[join [macports::_mport_archs $depport] ,]) $depport_provides
    3075             } elseif {$present && $dep_portname != ""} {
     3071            } elseif {$present && $dep_portname ne {}} {
    30763072                # record actual installed archs
    30773073                set port_seen(${dep_portname},[join [macports::_active_archs $dep_portname] ,]) 0
     
    30843080        foreach depport $depPorts {
    30853081            # Sub ports should be installed (all dependencies must be satisfied).
    3086             set res [mportdepends $depport "" $recurseDeps $skipSatisfied 1]
     3082            set res [mportdepends $depport {} $recurseDeps $skipSatisfied 1]
    30873083            if {$res != 0} {
    30883084                return $res
     
    30963092# check if the given mport can support dependents with the given archs
    30973093proc macports::_mport_supports_archs {mport required_archs} {
    3098     if {$required_archs == "noarch"} {
     3094    if {$required_archs eq "noarch"} {
    30993095        return 1
    31003096    }
    31013097    set provided_archs [_mport_archs $mport]
    3102     if {$provided_archs == "noarch"} {
     3098    if {$provided_archs eq "noarch"} {
    31033099        return 1
    31043100    }
     
    31193115# check if the active version of a port supports the given archs
    31203116proc macports::_active_supports_archs {portname required_archs} {
    3121     if {$required_archs == "noarch"} {
     3117    if {$required_archs eq "noarch"} {
    31223118        return 1
    31233119    }
     
    31263122    }
    31273123    set provided_archs [_active_archs $portname]
    3128     if {$provided_archs == "noarch" || $provided_archs == "" || $provided_archs == 0} {
     3124    if {$provided_archs eq "noarch" || $provided_archs eq {} || $provided_archs == 0} {
    31293125        return 1
    31303126    }
     
    31403136proc macports::_active_archs {portname} {
    31413137    if {[catch {set ilist [registry::active $portname]}]} {
    3142         return ""
     3138        return {}
    31433139    }
    31443140    set i [lindex $ilist 0]
     
    31513147    global macports::universal_archs
    31523148    if {![macports::ui_isset ports_debug]} {
    3153         ui_msg ""
     3149        ui_msg {}
    31543150    }
    31553151    ui_error "Cannot install $port for the arch(s) '$required_archs' because"
    3156     if {$supported_archs != ""} {
     3152    if {$supported_archs ne {}} {
    31573153        foreach arch $required_archs {
    31583154            if {[lsearch -exact $supported_archs $arch] == -1} {
     
    31813177    array set portinfo [mportinfo $mport]
    31823178    foreach type $deptypes {
    3183         if {[info exists portinfo($type)] && $portinfo($type) != ""} {
     3179        if {[info exists portinfo($type)] && $portinfo($type) ne {}} {
    31843180            return 1
    31853181        }
     
    32083204        rpm -
    32093205        dpkg -
    3210         srpm { return 1 }
    3211         default { return 0 }
     3206        srpm {return 1}
     3207        default {return 0}
    32123208    }
    32133209}
     
    32153211# Determine dependency types required for target
    32163212proc macports::_deptypes_for_target {target workername} {
    3217     switch $target {
     3213    switch -- $target {
    32183214        fetch       -
    3219         checksum    { return "depends_fetch" }
     3215        checksum    {return depends_fetch}
    32203216        extract     -
    3221         patch       { return "depends_fetch depends_extract" }
     3217        patch       {return "depends_fetch depends_extract"}
    32223218        configure   -
    3223         build       { return "depends_fetch depends_extract depends_build depends_lib" }
     3219        build       {return "depends_fetch depends_extract depends_build depends_lib"}
    32243220        test        -
    32253221        srpm        -
    3226         destroot    { return "depends_fetch depends_extract depends_build depends_lib depends_run" }
     3222        destroot    {return "depends_fetch depends_extract depends_build depends_lib depends_run"}
    32273223        dmg         -
    32283224        pkg         -
     
    32403236        install     -
    32413237        activate    -
    3242         ""          {
     3238        {}          {
    32433239            if {[global_option_isset ports_binary_only] ||
    32443240                [$workername eval registry_exists \$subport \$version \$revision \$portvariants]
     
    32503246        }
    32513247    }
    3252     return ""
     3248    return {}
    32533249}
    32543250
    32553251# selfupdate procedure
    3256 proc macports::selfupdate {{optionslist {}} {updatestatusvar ""}} {
    3257     global macports::prefix macports::portdbpath macports::libpath macports::rsync_server macports::rsync_dir macports::rsync_options
    3258     global macports::autoconf::macports_version macports::autoconf::rsync_path tcl_platform
    3259     global macports::autoconf::openssl_path macports::autoconf::tar_path
     3252proc macports::selfupdate {{optionslist {}} {updatestatusvar {}}} {
     3253    global macports::prefix macports::portdbpath macports::libpath \
     3254           macports::rsync_server macports::rsync_dir macports::rsync_options \
     3255           macports::autoconf::macports_version macports::autoconf::rsync_path \
     3256           tcl_platform macports::autoconf::openssl_path macports::autoconf::tar_path
    32603257    array set options $optionslist
    3261    
     3258
    32623259    # variable that indicates whether we actually updated base
    3263     if {$updatestatusvar != ""} {
     3260    if {$updatestatusvar ne {}} {
    32643261        upvar $updatestatusvar updatestatus
    32653262        set updatestatus no
     
    32683265    # are we syncing a tarball? (implies detached signature)
    32693266    set is_tarball 0
    3270     if {[string range ${rsync_dir} end-3 end] == ".tar"} {
     3267    if {[string range $rsync_dir end-3 end] eq ".tar"} {
    32713268        set is_tarball 1
    3272         set mp_source_path [file join $portdbpath sources ${rsync_server} [file dirname ${rsync_dir}]]
     3269        set mp_source_path [file join $portdbpath sources $rsync_server [file dirname $rsync_dir]]
    32733270    } else {
    3274         if {[string index $rsync_dir end] != "/"} {
    3275             append rsync_dir "/"
    3276         }
    3277         set mp_source_path [file join $portdbpath sources ${rsync_server} ${rsync_dir}]
     3271        if {[string index $rsync_dir end] ne "/"} {
     3272            append rsync_dir /
     3273        }
     3274        set mp_source_path [file join $portdbpath sources $rsync_server $rsync_dir]
    32783275    }
    32793276    # create the path to the to be downloaded sources if it doesn't exist
     
    32853282    # sync the MacPorts sources
    32863283    ui_msg "$macports::ui_prefix Updating MacPorts base sources using rsync"
    3287     if { [catch { system "$rsync_path $rsync_options rsync://${rsync_server}/${rsync_dir} $mp_source_path" } result ] } {
     3284    if {[catch {system "$rsync_path $rsync_options rsync://${rsync_server}/$rsync_dir $mp_source_path"} result]} {
    32883285       return -code error "Error synchronizing MacPorts sources: $result"
    32893286    }
     
    32923289        # verify signature for tarball
    32933290        global macports::archivefetch_pubkeys
    3294         if { [catch { system "$rsync_path $rsync_options rsync://${rsync_server}/${rsync_dir}.rmd160 $mp_source_path" } result ] } {
     3291        if {[catch {system "$rsync_path $rsync_options rsync://${rsync_server}/${rsync_dir}.rmd160 $mp_source_path"} result]} {
    32953292            return -code error "Error synchronizing MacPorts source signature: $result"
    32963293        }
    32973294        set openssl [findBinary openssl $macports::autoconf::openssl_path]
    3298         set tarball "${mp_source_path}/[file tail $rsync_dir]"
    3299         set signature "${tarball}.rmd160"
     3295        set tarball ${mp_source_path}/[file tail $rsync_dir]
     3296        set signature ${tarball}.rmd160
    33003297        set verified 0
    3301         foreach pubkey ${macports::archivefetch_pubkeys} {
     3298        foreach pubkey $macports::archivefetch_pubkeys {
    33023299            if {![catch {exec $openssl dgst -ripemd160 -verify $pubkey -signature $signature $tarball} result]} {
    33033300                set verified 1
     
    33123309            return -code error "Failed to verify signature for MacPorts source!"
    33133310        }
    3314        
     3311
    33153312        # extract tarball and move into place
    33163313        set tar [macports::findBinary tar $macports::autoconf::tar_path]
    33173314        file mkdir ${mp_source_path}/tmp
    3318         set tar_cmd "$tar -C ${mp_source_path}/tmp -xf ${tarball}"
     3315        set tar_cmd "$tar -C ${mp_source_path}/tmp -xf $tarball"
    33193316        ui_debug $tar_cmd
    33203317        if {[catch {system $tar_cmd}]} {
     
    33313328    ui_msg "MacPorts base version $macports::autoconf::macports_version installed,"
    33323329
    3333     if { [info exists options(ports_force)] && $options(ports_force) == "yes" } {
     3330    if {[info exists options(ports_force)] && $options(ports_force) eq "yes"} {
    33343331        set use_the_force_luke yes
    33353332        ui_debug "Forcing a rebuild and reinstallation of MacPorts"
     
    33563353
    33573354    # syncing ports tree.
    3358     if {![info exists options(ports_selfupdate_nosync)] || $options(ports_selfupdate_nosync) != "yes"} {
     3355    if {![info exists options(ports_selfupdate_nosync)] || $options(ports_selfupdate_nosync) ne "yes"} {
    33593356        if {$comp > 0} {
    3360             # updated portfiles potentially need new base to parse - tell sync to try to 
     3357            # updated portfiles potentially need new base to parse - tell sync to try to
    33613358            # use prefabricated PortIndex files and signal if it couldn't
    33623359            lappend optionslist no_reindex 1 needed_portindex_var needed_portindex
     
    33673364    }
    33683365
    3369     if {$use_the_force_luke == "yes" || $comp > 0} {
    3370         if {[info exists options(ports_dryrun)] && $options(ports_dryrun) == "yes"} {
     3366    if {$use_the_force_luke eq "yes" || $comp > 0} {
     3367        if {[info exists options(ports_dryrun)] && $options(ports_dryrun) eq "yes"} {
    33713368            ui_msg "$macports::ui_prefix MacPorts base is outdated, selfupdate would install $macports_version_new (dry run)"
    33723369        } else {
     
    33743371
    33753372            # get installation user/group and permissions
    3376             set owner [file attributes ${prefix} -owner]
    3377             set group [file attributes ${prefix} -group]
    3378             set perms [string range [file attributes ${prefix} -permissions] end-3 end]
    3379             if {$tcl_platform(user) != "root" && ![string equal $tcl_platform(user) $owner]} {
    3380                 return -code error "User $tcl_platform(user) does not own ${prefix} - try using sudo"
     3373            set owner [file attributes $prefix -owner]
     3374            set group [file attributes $prefix -group]
     3375            set perms [string range [file attributes $prefix -permissions] end-3 end]
     3376            if {$tcl_platform(user) ne "root" && $tcl_platform(user) ne $owner} {
     3377                return -code error "User $tcl_platform(user) does not own $prefix - try using sudo"
    33813378            }
    33823379            ui_debug "Permissions OK"
     
    33843381            # where to install a link to our macports1.0 tcl package
    33853382            set mp_tclpackage_path [file join $portdbpath .tclpackage]
    3386             if { [file exists $mp_tclpackage_path]} {
     3383            if {[file exists $mp_tclpackage_path]} {
    33873384                set fd [open $mp_tclpackage_path r]
    33883385                gets $fd tclpackage
     
    33943391            set configure_args "--prefix=$prefix --with-tclpackage=$tclpackage --with-install-user=$owner --with-install-group=$group --with-directory-mode=$perms"
    33953392            # too many users have an incompatible readline in /usr/local, see ticket #10651
    3396             if {$tcl_platform(os) != "Darwin" || $prefix == "/usr/local"
    3397                 || ([glob -nocomplain "/usr/local/lib/lib{readline,history}*"] == "" && [glob -nocomplain "/usr/local/include/readline/*.h"] == "")} {
     3393            if {$tcl_platform(os) ne "Darwin" || $prefix eq "/usr/local"
     3394                || ([glob -nocomplain /usr/local/lib/lib{readline,history}*] eq {} && [glob -nocomplain /usr/local/include/readline/*.h] eq {})} {
    33983395                append configure_args " --enable-readline"
    33993396            } else {
     
    34013398            }
    34023399
    3403             if {$prefix == "/usr/local" || $prefix == "/usr"} {
     3400            if {$prefix eq "/usr/local" || $prefix eq "/usr"} {
    34043401                append configure_args " --with-unsupported-prefix"
    34053402            }
    34063403
    34073404            # Choose a sane compiler
    3408             set cc_arg ""
    3409             if {$::macports::os_platform == "darwin"} {
     3405            set cc_arg {}
     3406            if {$::macports::os_platform eq "darwin"} {
    34103407                set cc_arg "CC=/usr/bin/cc OBJC=/usr/bin/cc "
    34113408            }
    34123409
    34133410            # do the actual configure, build and installation of new base
    3414             ui_msg "Installing new MacPorts release in $prefix as $owner:$group; permissions $perms; Tcl-Package in $tclpackage\n"
    3415             if { [catch { system "cd $mp_source_path && ${cc_arg}./configure $configure_args && make SELFUPDATING=1 && make install SELFUPDATING=1" } result] } {
     3411            ui_msg "Installing new MacPorts release in $prefix as ${owner}:${group}; permissions ${perms}; Tcl-Package in $tclpackage\n"
     3412            if {[catch {system "cd $mp_source_path && ${cc_arg}./configure $configure_args && make SELFUPDATING=1 && make install SELFUPDATING=1"} result]} {
    34163413                return -code error "Error installing new MacPorts base: $result"
    34173414            }
     
    34293426    set sources_owner [file attributes [file join $portdbpath sources/] -owner]
    34303427    ui_debug "Setting MacPorts sources ownership to $sources_owner"
    3431     if { [catch { exec [findBinary chown $macports::autoconf::chown_path] -R $sources_owner [file join $portdbpath sources/] } result] } {
    3432         return -code error "Couldn't change permissions of the MacPorts sources at $mp_source_path to $sources_owner: $result"
    3433     }
    3434 
    3435     if {![info exists options(ports_selfupdate_nosync)] || $options(ports_selfupdate_nosync) != "yes"} {
     3428    if {[catch {exec [findBinary chown $macports::autoconf::chown_path] -R $sources_owner [file join $portdbpath sources/]} result]} {
     3429        return -code error "Couldn't change permissions of the MacPorts sources at $mp_source_path to ${sources_owner}: $result"
     3430    }
     3431
     3432    if {![info exists options(ports_selfupdate_nosync)] || $options(ports_selfupdate_nosync) ne "yes"} {
    34363433        if {[info exists needed_portindex]} {
    34373434            ui_msg "Not all sources could be fully synced using the old version of MacPorts."
     
    34523449#   2 = port name not found in index
    34533450#   3 = port not installed
    3454 proc macports::upgrade {portname dspec variationslist optionslist {depscachename ""}} {
     3451proc macports::upgrade {portname dspec variationslist optionslist {depscachename {}}} {
    34553452    # only installed ports can be upgraded
    34563453    if {![registry::entry_exists_for_name $portname]} {
     
    34583455        return 3
    34593456    }
    3460     if {![string match "" $depscachename]} {
     3457    if {$depscachename ne {}} {
    34613458        upvar $depscachename depscache
    34623459    } else {
     
    34693466        set orig_nodeps no
    34703467    }
    3471    
     3468
    34723469    # run the actual upgrade
    34733470    set status [macports::_upgrade $portname $dspec $variationslist $optionslist depscache]
    3474    
     3471
    34753472    if {!$orig_nodeps} {
    34763473        unset -nocomplain macports::global_options(ports_nodeps)
     
    34813478
    34823479# main internal upgrade procedure
    3483 proc macports::_upgrade {portname dspec variationslist optionslist {depscachename ""}} {
     3480proc macports::_upgrade {portname dspec variationslist optionslist {depscachename {}}} {
    34843481    global macports::global_variations
    34853482    array set options $optionslist
    34863483
    3487     if {![string match "" $depscachename]} {
     3484    if {$depscachename ne {}} {
    34883485        upvar $depscachename depscache
    34893486    }
     
    35083505    if {[catch {mportlookup $portname} result]} {
    35093506        global errorInfo
    3510         ui_debug "$errorInfo"
     3507        ui_debug $errorInfo
    35113508        ui_error "port lookup failed: $result"
    35123509        return 1
    35133510    }
    35143511    # argh! port doesnt exist!
    3515     if {$result == ""} {
     3512    if {$result eq {}} {
    35163513        ui_warn "No port $portname found in the index."
    35173514        return 2
     
    35243521
    35253522    set ilist {}
    3526     if { [catch {set ilist [registry::installed $portname ""]} result] } {
    3527         if {$result == "Registry error: $portname not registered as installed." } {
     3523    if {[catch {set ilist [registry::installed $portname {}]} result]} {
     3524        if {$result eq "Registry error: $portname not registered as installed."} {
    35283525            ui_debug "$portname is *not* installed by MacPorts"
    35293526
     
    35313528            # actually declaring the dependency on the one we're checking for.
    35323529            # We got here via _upgrade_dependencies, so we grab it from 2 levels up.
    3533             upvar 2 workername parentworker
    3534             if {![_mportispresent $parentworker $dspec ] } {
     3530            upvar 2 mport parentmport
     3531            if {![_mportispresent $parentmport $dspec]} {
    35353532                # open porthandle
    35363533                set porturl $portinfo(porturl)
     
    35413538                upvar 2 variations variations
    35423539
    3543                 if {[catch {set workername [mportopen $porturl [array get options] [array get variations]]} result]} {
     3540                if {[catch {set mport [mportopen $porturl [array get options] [array get variations]]} result]} {
    35443541                    global errorInfo
    3545                     ui_debug "$errorInfo"
     3542                    ui_debug $errorInfo
    35463543                    ui_error "Unable to open port: $result"
    35473544                    return 1
     
    35493546                # While we're at it, update the portinfo
    35503547                array unset portinfo
    3551                 array set portinfo [mportinfo $workername]
    3552                
     3548                array set portinfo [mportinfo $mport]
     3549
    35533550                # upgrade its dependencies first
    35543551                set status [_upgrade_dependencies portinfo depscache variationslist options]
    35553552                if {$status != 0 && $status != 2 && ![ui_isset ports_processall]} {
    3556                     catch {mportclose $workername}
     3553                    catch {mportclose $mport}
    35573554                    return $status
    35583555                }
    35593556                # now install it
    3560                 if {[catch {set result [mportexec $workername activate]} result]} {
     3557                if {[catch {set result [mportexec $mport activate]} result]} {
    35613558                    global errorInfo
    3562                     ui_debug "$errorInfo"
     3559                    ui_debug $errorInfo
    35633560                    ui_error "Unable to exec port: $result"
    3564                     catch {mportclose $workername}
     3561                    catch {mportclose $mport}
    35653562                    return 1
    35663563                }
    35673564                if {$result > 0} {
    35683565                    ui_error "Problem while installing $portname"
    3569                     catch {mportclose $workername}
     3566                    catch {mportclose $mport}
    35703567                    return $result
    35713568                }
    35723569                # we just installed it, so mark it done in the cache
    3573                 set depscache(port:${portname}) 1
    3574                 mportclose $workername
     3570                set depscache(port:$portname) 1
     3571                mportclose $mport
    35753572            } else {
    35763573                # dependency is satisfied by something other than the named port
     
    35883585    } else {
    35893586        # we'll now take care of upgrading it, so we can add it to the cache
    3590         set depscache(port:${portname}) 1
    3591     }
    3592    
     3587        set depscache(port:$portname) 1
     3588    }
     3589
    35933590    # set version_in_tree and revision_in_tree
    35943591    if {![info exists portinfo(version)]} {
    3595         ui_error "Invalid port entry for $portname, missing version"
     3592        ui_error "Invalid port entry for ${portname}, missing version"
    35963593        return 1
    35973594    }
    3598     set version_in_tree "$portinfo(version)"
    3599     set revision_in_tree "$portinfo(revision)"
    3600     set epoch_in_tree "$portinfo(epoch)"
     3595    set version_in_tree $portinfo(version)
     3596    set revision_in_tree $portinfo(revision)
     3597    set epoch_in_tree $portinfo(epoch)
    36013598
    36023599    # find latest version installed and active version (if any)
     
    36083605        set revision [lindex $i 2]
    36093606        set epoch [lindex $i 5]
    3610         if { $version_installed == {} || ($epoch > $epoch_installed && $version != $version_installed) ||
     3607        if {$version_installed eq {} || ($epoch > $epoch_installed && $version != $version_installed) ||
    36113608                ($epoch >= $epoch_installed && [vercmp $version $version_installed] > 0)
    36123609                || ($epoch >= $epoch_installed
     
    36313628    # output version numbers
    36323629    ui_debug "epoch: in tree: $epoch_in_tree installed: $epoch_installed"
    3633     ui_debug "$portname ${version_in_tree}_${revision_in_tree} exists in the ports tree"
    3634     ui_debug "$portname ${version_installed}_${revision_installed} $variant_installed is the latest installed"
     3630    ui_debug "$portname ${version_in_tree}_$revision_in_tree exists in the ports tree"
     3631    ui_debug "$portname ${version_installed}_$revision_installed $variant_installed is the latest installed"
    36353632    if {$anyactive} {
    3636         ui_debug "$portname ${version_active}_${revision_active} $variant_active is active"
     3633        ui_debug "$portname ${version_active}_$revision_active $variant_active is active"
    36373634        # save existing variant for later use
    36383635        set oldvariant $variant_active
     
    36643661    # merged in later on, so it applies only to this port's upgrade
    36653662    array set variations $variationslist
    3666    
     3663
    36673664    set globalvarlist [array get macports::global_variations]
    36683665
    36693666    set minusvariant [lrange [split $oldnegatedvariant -] 1 end]
    36703667    set plusvariant [lrange [split $oldvariant +] 1 end]
    3671     ui_debug "Merging existing variants '${oldvariant}${oldnegatedvariant}' into variants"
     3668    ui_debug "Merging existing variants '${oldvariant}$oldnegatedvariant' into variants"
    36723669    set oldvariantlist [list]
    36733670    foreach v $plusvariant {
    3674         lappend oldvariantlist $v "+"
     3671        lappend oldvariantlist $v +
    36753672    }
    36763673    foreach v $minusvariant {
    3677         lappend oldvariantlist $v "-"
     3674        lappend oldvariantlist $v -
    36783675    }
    36793676
    36803677    # merge in the old variants
    36813678    foreach {variation value} $oldvariantlist {
    3682         if { ![info exists variations($variation)]} {
     3679        if {![info exists variations($variation)]} {
    36833680            set variations($variation) $value
    36843681        }
     
    36883685    # We wait until now so that existing variants for this port
    36893686    # override global variations
    3690     foreach { variation value } $globalvarlist {
    3691         if { ![info exists variations($variation)] } {
     3687    foreach {variation value} $globalvarlist {
     3688        if {![info exists variations($variation)]} {
    36923689            set variations($variation) $value
    36933690        }
     
    36953692
    36963693    ui_debug "new fully merged portvariants: [array get variations]"
    3697    
     3694
    36983695    # at this point we need to check if a different port will be replacing this one
    36993696    if {[info exists portinfo(replaced_by)] && ![info exists options(ports_upgrade_no-replace)]} {
     
    37013698        if {[catch {mportlookup $portinfo(replaced_by)} result]} {
    37023699            global errorInfo
    3703             ui_debug "$errorInfo"
     3700            ui_debug $errorInfo
    37043701            ui_error "port lookup failed: $result"
    37053702            return 1
    37063703        }
    3707         if {$result == ""} {
     3704        if {$result eq {}} {
    37083705            ui_error "No port $portinfo(replaced_by) found."
    37093706            return 1
     
    37173714            set porturl file://./
    37183715        }
    3719         set depscache(port:${newname}) 1
     3716        set depscache(port:$newname) 1
    37203717    } else {
    37213718        set newname $portname
     
    37263723    set interp_options(subport) $newname
    37273724
    3728     if {[catch {set workername [mportopen $porturl [array get interp_options] [array get variations]]} result]} {
     3725    if {[catch {set mport [mportopen $porturl [array get interp_options] [array get variations]]} result]} {
    37293726        global errorInfo
    3730         ui_debug "$errorInfo"
     3727        ui_debug $errorInfo
    37313728        ui_error "Unable to open port: $result"
    37323729        return 1
     
    37353732
    37363733    array unset portinfo
    3737     array set portinfo [mportinfo $workername]
    3738     set version_in_tree "$portinfo(version)"
    3739     set revision_in_tree "$portinfo(revision)"
    3740     set epoch_in_tree "$portinfo(epoch)"
     3734    array set portinfo [mportinfo $mport]
     3735    set version_in_tree $portinfo(version)
     3736    set revision_in_tree $portinfo(revision)
     3737    set epoch_in_tree $portinfo(epoch)
    37413738
    37423739    set build_override 0
    37433740    set will_install yes
    37443741    # check installed version against version in ports
    3745     if { ( [vercmp $version_installed $version_in_tree] > 0
     3742    if {([vercmp $version_installed $version_in_tree] > 0
    37463743            || ([vercmp $version_installed $version_in_tree] == 0
    3747                 && [vercmp $revision_installed $revision_in_tree] >= 0 ))
    3748         && ![info exists options(ports_upgrade_force)] } {
    3749         if {$portname != $newname} {
     3744                && [vercmp $revision_installed $revision_in_tree] >= 0))
     3745        && ![info exists options(ports_upgrade_force)]} {
     3746        if {$portname ne $newname} {
    37503747            ui_debug "ignoring versions, installing replacement port"
    3751         } elseif { $epoch_installed < $epoch_in_tree } {
     3748        } elseif {$epoch_installed < $epoch_in_tree && $version_installed != $version_in_tree} {
    37523749            set build_override 1
    37533750            ui_debug "epoch override ... upgrading!"
     
    37553752                  && [info exists portinfo(canonical_active_variants)] && $portinfo(canonical_active_variants) != $oldvariant} {
    37563753            ui_debug "variant override ... upgrading!"
    3757         } elseif {$os_platform_installed != "" && $os_major_installed != "" && $os_platform_installed != 0
    3758                   && ([_mportkey $workername "{os.platform}"] != $os_platform_installed
    3759                   || [_mportkey $workername "{os.major}"] != $os_major_installed)} {
     3754        } elseif {$os_platform_installed ne {} && $os_major_installed ne {} && $os_platform_installed != 0
     3755                  && ([_mportkey $mport "{os.platform}"] != $os_platform_installed
     3756                  || [_mportkey $mport "{os.major}"] != $os_major_installed)} {
    37603757            ui_debug "platform mismatch ... upgrading!"
    37613758            set build_override 1
     
    37703767            if {[info exists portinfo(canonical_active_variants)] && $portinfo(canonical_active_variants) != $oldvariant} {
    37713768                if {[llength $variationslist] > 0} {
    3772                     ui_warn "Skipping upgrade since $portname ${version_installed}_${revision_installed} >= $portname ${version_in_tree}_${revision_in_tree}, even though installed variants \"$oldvariant\" do not match \"$portinfo(canonical_active_variants)\". Use 'upgrade --enforce-variants' to switch to the requested variants."
     3769                    ui_warn "Skipping upgrade since $portname ${version_installed}_$revision_installed >= $portname ${version_in_tree}_${revision_in_tree}, even though installed variants \"$oldvariant\" do not match \"$portinfo(canonical_active_variants)\". Use 'upgrade --enforce-variants' to switch to the requested variants."
    37733770                } else {
    3774                     ui_debug "Skipping upgrade since $portname ${version_installed}_${revision_installed} >= $portname ${version_in_tree}_${revision_in_tree}, even though installed variants \"$oldvariant\" do not match \"$portinfo(canonical_active_variants)\"."
     3771                    ui_debug "Skipping upgrade since $portname ${version_installed}_$revision_installed >= $portname ${version_in_tree}_${revision_in_tree}, even though installed variants \"$oldvariant\" do not match \"$portinfo(canonical_active_variants)\"."
    37753772                }
    37763773            } else {
    3777                 ui_debug "No need to upgrade! $portname ${version_installed}_${revision_installed} >= $portname ${version_in_tree}_${revision_in_tree}"
     3774                ui_debug "No need to upgrade! $portname ${version_installed}_$revision_installed >= $portname ${version_in_tree}_$revision_in_tree"
    37783775            }
    37793776            set will_install no
     
    37943791    if {![info exists options(ports_nodeps)] && !$is_revupgrade} {
    37953792        # the last arg is because we might have to build from source if a rebuild is being forced
    3796         set status [_upgrade_dependencies portinfo depscache variationslist options [expr $will_build && $already_installed]]
     3793        set status [_upgrade_dependencies portinfo depscache variationslist options [expr {$will_build && $already_installed}]]
    37973794        if {$status != 0 && $status != 2 && ![ui_isset ports_processall]} {
    3798             catch {mportclose $workername}
     3795            catch {mportclose $mport}
    37993796            return $status
    38003797        }
     
    38163813            }
    38173814
    3818             if { [llength deplist] > 0 } {
     3815            if {[llength deplist] > 0} {
    38193816                foreach dep $deplist {
    38203817                    set mpname [lindex $dep 2]
    3821                     if {![llength [array get depscache port:${mpname}]]} {
    3822                         set status [macports::_upgrade $mpname port:${mpname} $variationslist [array get options] depscache]
     3818                    if {![llength [array get depscache port:$mpname]]} {
     3819                        set status [macports::_upgrade $mpname port:$mpname $variationslist [array get options] depscache]
    38233820                        if {$status != 0 && $status != 2 && ![ui_isset ports_processall]} {
    3824                             catch {mportclose $workername}
     3821                            catch {mportclose $mport}
    38253822                            return $status
    38263823                        }
     
    38293826            }
    38303827        }
    3831         mportclose $workername
     3828        mportclose $mport
    38323829        return 0
    38333830    }
    38343831
    38353832    if {$will_build} {
    3836         # install version_in_tree (but don't activate yet)
    3837         if {[catch {set result [mportexec $workername install]} result] || $result != 0} {
    3838             if {[info exists ::errorInfo]} {
    3839                 ui_debug "$::errorInfo"
    3840             }
    3841             ui_error "Unable to upgrade port: $result"
    3842             catch {mportclose $workername}
    3843             return 1
     3833        if {$already_installed
     3834            && ([info exists options(ports_upgrade_force)] || $build_override == 1)} {
     3835            # Tell archivefetch/unarchive not to use the installed archive, i.e. a
     3836            # fresh one will be either fetched or built locally.
     3837            # Ideally this would be done in the interp_options when we mportopen,
     3838            # but we don't know if we want to do this at that point.
     3839            set workername [ditem_key $mport workername]
     3840            $workername eval "set force_archive_refresh yes"
     3841
     3842            # run archivefetch and destroot for version_in_tree
     3843            # doing this instead of just running install ensures that we have the
     3844            # new copy ready but not yet installed, so we can safely uninstall the
     3845            # existing one.
     3846            if {[catch {set result [mportexec $mport archivefetch]} result] || $result != 0} {
     3847                if {[info exists ::errorInfo]} {
     3848                    ui_debug $::errorInfo
     3849                }
     3850                ui_error "Unable to upgrade port: $result"
     3851                catch {mportclose $mport}
     3852                return 1
     3853            }
     3854            # the following is a noop if archivefetch found an archive
     3855            if {[catch {set result [mportexec $mport destroot]} result] || $result != 0} {
     3856                if {[info exists ::errorInfo]} {
     3857                    ui_debug $::errorInfo
     3858                }
     3859                ui_error "Unable to upgrade port: $result"
     3860                catch {mportclose $mport}
     3861                return 1
     3862            }
     3863        } else {
     3864            # Normal non-forced case
     3865            # install version_in_tree (but don't activate yet)
     3866            if {[catch {set result [mportexec $mport install]} result] || $result != 0} {
     3867                if {[info exists ::errorInfo]} {
     3868                    ui_debug $::errorInfo
     3869                }
     3870                ui_error "Unable to upgrade port: $result"
     3871                catch {mportclose $mport}
     3872                return 1
     3873            }
    38443874        }
    38453875    }
     
    38593889                  && [catch {registry_uninstall::uninstall $newname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants) [array get options]} result]} {
    38603890            global errorInfo
    3861             ui_debug "$errorInfo"
     3891            ui_debug $errorInfo
    38623892            ui_error "Uninstall $newname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) failed: $result"
    3863             catch {mportclose $workername}
     3893            catch {mportclose $mport}
    38643894            return 1
    38653895        }
     
    38683898        }
    38693899        if {$anyactive && $version_in_tree == $version_active && $revision_in_tree == $revision_active
    3870             && $portinfo(canonical_active_variants) == $variant_active && $portname == $newname} {
     3900            && $portinfo(canonical_active_variants) == $variant_active && $portname eq $newname} {
    38713901            set anyactive no
    38723902        }
    38733903    }
    3874     if {$anyactive && $portname != $newname} {
     3904    if {$anyactive && $portname ne $newname} {
    38753905        # replaced_by in effect, deactivate the old port
    38763906        # we have to force the deactivate in case of dependents
     
    38783908        set options(ports_force) yes
    38793909        if {$is_dryrun eq "yes"} {
    3880             ui_msg "Skipping deactivate $portname @${version_active}_${revision_active}${variant_active} (dry run)"
     3910            ui_msg "Skipping deactivate $portname @${version_active}_${revision_active}$variant_active (dry run)"
    38813911        } elseif {![catch {registry::active $portname}] &&
    38823912                  ![registry::run_target $regref deactivate [array get options]]
    38833913                  && [catch {portimage::deactivate $portname $version_active $revision_active $variant_active [array get options]} result]} {
    38843914            global errorInfo
    3885             ui_debug "$errorInfo"
    3886             ui_error "Deactivating $portname @${version_active}_${revision_active}${variant_active} failed: $result"
    3887             catch {mportclose $workername}
     3915            ui_debug $errorInfo
     3916            ui_error "Deactivating $portname @${version_active}_${revision_active}$variant_active failed: $result"
     3917            catch {mportclose $mport}
    38883918            return 1
    38893919        }
     
    38933923        set anyactive no
    38943924    }
    3895     if {[info exists options(port_uninstall_old)] && $portname == $newname} {
     3925    if {[info exists options(port_uninstall_old)] && $portname eq $newname} {
    38963926        # uninstalling now could fail due to dependents when not forced,
    38973927        # because the new version is not installed
     
    39013931    if {$is_dryrun eq "yes"} {
    39023932        if {$anyactive} {
    3903             ui_msg "Skipping deactivate $portname @${version_active}_${revision_active}${variant_active} (dry run)"
     3933            ui_msg "Skipping deactivate $portname @${version_active}_${revision_active}$variant_active (dry run)"
    39043934        }
    39053935        ui_msg "Skipping activate $newname @${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) (dry run)"
    3906     } elseif {[catch {set result [mportexec $workername activate]} result]} {
     3936    } elseif {[catch {set result [mportexec $mport activate]} result]} {
    39073937        global errorInfo
    3908         ui_debug "$errorInfo"
     3938        ui_debug $errorInfo
    39093939        ui_error "Couldn't activate $newname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants): $result"
    3910         catch {mportclose $workername}
     3940        catch {mportclose $mport}
    39113941        return 1
    39123942    }
     
    39183948
    39193949        registry::open_dep_map
    3920         if {$portname != $newname} {
     3950        if {$portname ne $newname} {
    39213951            set deplist [registry::list_dependents $newname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants)]
    39223952        } else {
     
    39293959        }
    39303960
    3931         if { [llength deplist] > 0 } {
     3961        if {[llength deplist] > 0} {
    39323962            foreach dep $deplist {
    39333963                set mpname [lindex $dep 2]
    3934                 if {![llength [array get depscache port:${mpname}]]} {
    3935                     set status [macports::_upgrade $mpname port:${mpname} $variationslist [array get options] depscache]
     3964                if {![llength [array get depscache port:$mpname]]} {
     3965                    set status [macports::_upgrade $mpname port:$mpname $variationslist [array get options] depscache]
    39363966                    if {$status != 0 && $status != 2 && ![ui_isset ports_processall]} {
    3937                         catch {mportclose $workername}
     3967                        catch {mportclose $mport}
    39383968                        return $status
    39393969                    }
     
    39433973    }
    39443974
    3945     if {[info exists uninstall_later] && $uninstall_later == yes} {
     3975    if {[info exists uninstall_later] && $uninstall_later eq yes} {
    39463976        foreach i $ilist {
    39473977            set version [lindex $i 1]
    39483978            set revision [lindex $i 2]
    39493979            set variant [lindex $i 3]
    3950             if {$version == $version_in_tree && $revision == $revision_in_tree && $variant == $portinfo(canonical_active_variants) && $portname == $newname} {
     3980            if {$version == $version_in_tree && $revision == $revision_in_tree && $variant == $portinfo(canonical_active_variants) && $portname eq $newname} {
    39513981                continue
    39523982            }
    39533983            set epoch [lindex $i 5]
    3954             ui_debug "Uninstalling $portname ${version}_${revision}${variant}"
     3984            ui_debug "Uninstalling $portname ${version}_${revision}$variant"
    39553985            set regref [registry::open_entry $portname $version $revision $variant $epoch]
    39563986            if {$is_dryrun eq "yes"} {
    3957                 ui_msg "Skipping uninstall $portname @${version}_${revision}${variant} (dry run)"
     3987                ui_msg "Skipping uninstall $portname @${version}_${revision}$variant (dry run)"
    39583988            } elseif {![registry::run_target $regref uninstall $optionslist]
    39593989                      && [catch {registry_uninstall::uninstall $portname $version $revision $variant $optionslist} result]} {
    39603990                global errorInfo
    3961                 ui_debug "$errorInfo"
     3991                ui_debug $errorInfo
    39623992                # replaced_by can mean that we try to uninstall all versions of the old port, so handle errors due to dependents
    3963                 if {$result != "Please uninstall the ports that depend on $portname first." && ![ui_isset ports_processall]} {
    3964                     ui_error "Uninstall $portname @${version}_${revision}${variant} failed: $result"
    3965                     catch {mportclose $workername}
     3993                if {$result ne "Please uninstall the ports that depend on $portname first." && ![ui_isset ports_processall]} {
     3994                    ui_error "Uninstall $portname @${version}_${revision}$variant failed: $result"
     3995                    catch {mportclose $mport}
    39663996                    return 1
    39673997                }
     
    39714001
    39724002    # close the port handle
    3973     mportclose $workername
     4003    mportclose $mport
    39744004    return 0
    39754005}
     
    39824012          $variationslistname variationslist \
    39834013          $optionsname options
    3984     upvar workername parentworker
     4014    upvar mport parentmport
    39854015
    39864016    # If we're following dependents, we only want to follow this port's
     
    39964026    unset -nocomplain options(ports_do_dependents)
    39974027
    3998     set parent_interp [ditem_key $parentworker workername]
     4028    set parentworker [ditem_key $parentmport workername]
    39994029    # each required dep type is upgraded
    40004030    if {$build_needed && ![global_option_isset ports_binary_only]} {
    4001         set dtypes [_deptypes_for_target destroot $parent_interp]
     4031        set dtypes [_deptypes_for_target destroot $parentworker]
    40024032    } else {
    4003         set dtypes [_deptypes_for_target install $parent_interp]
     4033        set dtypes [_deptypes_for_target install $parentworker]
    40044034    }
    40054035
     
    40084038        if {[info exists portinfo($dtype)]} {
    40094039            foreach i $portinfo($dtype) {
    4010                 set d [$parent_interp eval _get_dep_port $i]
    4011                 if {![llength [array get depscache port:${d}]] && ![llength [array get depscache $i]]} {
    4012                     if {$d != ""} {
     4040                set d [$parentworker eval _get_dep_port $i]
     4041                if {![llength [array get depscache port:$d]] && ![llength [array get depscache $i]]} {
     4042                    if {$d ne {}} {
    40134043                        set dspec port:$d
    40144044                    } else {
     
    40334063#   * command: The only valid commands are list, set and show
    40344064#   * group: This argument should correspond to a directory under
    4035 #            $macports::prefix/etc/select.
     4065#            ${macports::prefix}/etc/select.
    40364066#   * version: This argument is only used by the 'set' command.
    40374067# On error mportselect returns with the code 'error'.
    4038 proc mportselect {command group {version ""}} {
     4068proc mportselect {command group {version {}}} {
    40394069    ui_debug "mportselect \[$command] \[$group] \[$version]"
    40404070
    4041     set conf_path "$macports::prefix/etc/select/$group"
     4071    set conf_path ${macports::prefix}/etc/select/$group
    40424072    if {![file isdirectory $conf_path]} {
    40434073        return -code error "The specified group '$group' does not exist."
     
    40484078            if {[catch {set versions [glob -directory $conf_path *]} result]} {
    40494079                global errorInfo
    4050                 ui_debug "$result: $errorInfo"
    4051                 return -code error [concat "No configurations associated " \
     4080                ui_debug "${result}: $errorInfo"
     4081                return -code error [concat "No configurations associated" \
    40524082                                           "with '$group' were found."]
    40534083            }
     
    40664096        }
    40674097        set {
    4068             # Use $conf_path/$version to read in sources.
    4069             if {$version == "" || $version == "base" || $version == "current"
    4070                     || [catch {set src_file [open "$conf_path/$version"]} result]} {
     4098            # Use ${conf_path}/$version to read in sources.
     4099            if {$version eq {} || $version eq "base" || $version eq "current"
     4100                    || [catch {set src_file [open "${conf_path}/$version"]} result]} {
    40714101                global errorInfo
    4072                 ui_debug "$result: $errorInfo"
     4102                ui_debug "${result}: $errorInfo"
    40734103                return -code error "The specified version '$version' is not valid."
    40744104            }
     
    40764106            close $src_file
    40774107
    4078             # Use $conf_path/base to read in targets.
    4079             if {[catch {set tgt_file [open "$conf_path/base"]} result]} {
     4108            # Use ${conf_path}/base to read in targets.
     4109            if {[catch {set tgt_file [open ${conf_path}/base]} result]} {
    40804110                global errorInfo
    4081                 ui_debug "$result: $errorInfo"
    4082                 return -code error [concat "The configuration file " \
    4083                                            "'$conf_path/base' could not be " \
     4111                ui_debug "${result}: $errorInfo"
     4112                return -code error [concat "The configuration file" \
     4113                                           "'${conf_path}/base' could not be" \
    40844114                                           "opened."]
    40854115            }
    4086             set tgts [split [read -nonewline $tgt_file] "\n"]
     4116            set tgts [split [read -nonewline $tgt_file] \n]
    40874117            close $tgt_file
    40884118
     
    41164146                    }
    41174147                }
    4118                 set i [expr $i+1]
     4148                incr i
    41194149            }
    41204150
    41214151            # Update the selected version.
    4122             set selected_version "$conf_path/current"
     4152            set selected_version ${conf_path}/current
    41234153            if {[file exists $selected_version]} {
    41244154                file delete $selected_version
     
    41284158        }
    41294159        show {
    4130             set selected_version "$conf_path/current"
     4160            set selected_version ${conf_path}/current
    41314161
    41324162            if {![file exists $selected_version]} {
    4133                 return "none"
     4163                return none
    41344164            } else {
    41354165                return [file readlink $selected_version]
     
    41484178        return $env(TMPDIR)
    41494179    } else {
    4150         return "/tmp"
     4180        return /tmp
    41514181    }
    41524182}
     
    41554185proc macports::arch_runnable {arch} {
    41564186    global macports::os_major macports::os_arch macports::os_platform
    4157     if {${macports::os_platform} == "darwin"} {
    4158         if {${macports::os_major} >= 11 && [string first "ppc" $arch] == 0} {
     4187    if {$macports::os_platform eq "darwin"} {
     4188        if {$macports::os_major >= 11 && [string first "ppc" $arch] == 0} {
    41594189            return no
    4160         } elseif {${macports::os_arch} == "i386" && $arch == "ppc64"} {
     4190        } elseif {$macports::os_arch eq "i386" && $arch eq "ppc64"} {
    41614191            return no
    4162         } elseif {${macports::os_major} <= 8 && $arch == "x86_64"} {
     4192        } elseif {$macports::os_major <= 8 && $arch eq "x86_64"} {
    41634193            return no
    41644194        }
     
    41834213    set files [registry::file search active 1 binary -null]
    41844214    set files_count [llength $files]
    4185     set fancy_output [expr ![macports::ui_isset ports_debug] && [isatty stdout]]
     4215    set fancy_output [expr {![macports::ui_isset ports_debug] && [isatty stdout]}]
    41864216    if {$files_count > 0} {
    41874217        registry::write {
     
    41924222                    if {$fancy_output} {
    41934223                        if {$files_count < 10000 || $i % 10 == 1 || $i == $files_count} {
    4194                             ui_msg -nonewline "\r$macports::ui_prefix Updating database of binaries: [expr ($i * 1000 / $files_count) / 10.0]%"
     4224                            ui_msg -nonewline "\r$macports::ui_prefix Updating database of binaries: [expr {($i * 1000 / $files_count) / 10.0}]%"
    41954225                            flush stdout
    41964226                        }
    41974227                    }
    41984228                    set fpath [$f actual_path]
    4199                     ui_debug "Updating binary flag for file $i of $files_count: $fpath"
     4229                    ui_debug "Updating binary flag for file $i of ${files_count}: $fpath"
    42004230                    incr i
    42014231
     
    42034233                        # handle errors (e.g. file not found, permission denied) gracefully
    42044234                        if {$fancy_output} {
    4205                             ui_msg ""
     4235                            ui_msg {}
    42064236                        }
    42074237                        ui_warn "Error determining file type of `$fpath': $fileIsBinaryError"
     
    42144244            }
    42154245        }
    4216         ui_msg ""
     4246        ui_msg {}
    42174247    }
    42184248
     
    42234253        ui_msg -nonewline "$macports::ui_prefix Scanning binaries for linking errors"
    42244254        set handle [machista::create_handle]
    4225         if {$handle == "NULL"} {
     4255        if {$handle eq "NULL"} {
    42264256            error "Error creating libmachista handle"
    42274257        }
     
    42334263            if {$fancy_output} {
    42344264                if {$binary_count < 10000 || $i % 10 == 1 || $i == $binary_count} {
    4235                     ui_msg -nonewline "\r$macports::ui_prefix Scanning binaries for linking errors: [expr ($i * 1000 / $binary_count) / 10.0]%"
     4265                    ui_msg -nonewline "\r$macports::ui_prefix Scanning binaries for linking errors: [expr {($i * 1000 / $binary_count) / 10.0}]%"
    42364266                    flush stdout
    42374267                }
    42384268            }
    42394269            set bpath [$b actual_path]
    4240             #ui_debug "$i/$binary_count: $bpath"
     4270            #ui_debug "${i}/${binary_count}: $bpath"
    42414271            incr i
    42424272
     
    42524282                } else {
    42534283                    if {$fancy_output} {
    4254                         ui_msg ""
     4284                        ui_msg {}
    42554285                    }
    42564286                    ui_warn "Error parsing file ${bpath}: [machista::strerror $returncode]"
     
    42604290
    42614291            set architecture [$result cget -mt_archs]
    4262             while {$architecture != "NULL"} {
    4263                 if {[info exists options(ports_rev-upgrade_id-loadcmd-check)] && $options(ports_rev-upgrade_id-loadcmd-check) == "yes"} {
    4264                     if {[$architecture cget -mat_install_name] != "NULL" && [$architecture cget -mat_install_name] != ""} {
     4292            while {$architecture ne "NULL"} {
     4293                if {[info exists options(ports_rev-upgrade_id-loadcmd-check)] && $options(ports_rev-upgrade_id-loadcmd-check) eq "yes"} {
     4294                    if {[$architecture cget -mat_install_name] ne "NULL" && [$architecture cget -mat_install_name] ne {}} {
    42654295                        # check if this lib's install name actually refers to this file itself
    42664296                        # if this is not the case software linking against this library might have erroneous load commands
    42674297                        if {0 == [catch {set idloadcmdpath [revupgrade_handle_special_paths $bpath [$architecture cget -mat_install_name]]}]} {
    4268                             if {[string index $idloadcmdpath 0] != "/"} {
     4298                            if {[string index $idloadcmdpath 0] ne "/"} {
    42694299                                set port [registry::entry owner $bpath]
    4270                                 if {$port != ""} {
     4300                                if {$port ne {}} {
    42714301                                    set portname [$port name]
    42724302                                } else {
    4273                                     set portname "<unknown-port>"
     4303                                    set portname <unknown-port>
    42744304                                }
    42754305                                if {$fancy_output} {
    4276                                     ui_msg ""
     4306                                    ui_msg {}
    42774307                                }
    42784308                                ui_warn "ID load command in ${bpath}, arch [machista::get_arch_name [$architecture cget -mat_arch]] (belonging to port $portname) contains relative path"
    42794309                            } elseif {![file exists $idloadcmdpath]} {
    42804310                                set port [registry::entry owner $bpath]
    4281                                 if {$port != ""} {
     4311                                if {$port ne {}} {
    42824312                                    set portname [$port name]
    42834313                                } else {
    4284                                     set portname "<unknown-port>"
     4314                                    set portname <unknown-port>
    42854315                                }
    42864316                                if {$fancy_output} {
    4287                                     ui_msg ""
     4317                                    ui_msg {}
    42884318                                }
    42894319                                ui_warn "ID load command in ${bpath}, arch [machista::get_arch_name [$architecture cget -mat_arch]] refers to non-existant file $idloadcmdpath"
    42904320                                ui_warn "This is probably a bug in the $portname port and might cause problems in libraries linking against this file"
    42914321                            } else {
    4292    
     4322
    42934323                                set hash_this [sha256 file $bpath]
    42944324                                set hash_idloadcmd [sha256 file $idloadcmdpath]
    4295    
    4296                                 if {$hash_this != $hash_idloadcmd} {
     4325
     4326                                if {$hash_this ne $hash_idloadcmd} {
    42974327                                    set port [registry::entry owner $bpath]
    4298                                     if {$port != ""} {
     4328                                    if {$port ne {}} {
    42994329                                        set portname [$port name]
    43004330                                    } else {
    4301                                         set portname "<unknown-port>"
     4331                                        set portname <unknown-port>
    43024332                                    }
    43034333                                    if {$fancy_output} {
    4304                                         ui_msg ""
     4334                                        ui_msg {}
    43054335                                    }
    4306                                     ui_warn "ID load command in ${bpath}, arch [machista::get_arch_name [$architecture cget -mat_arch]] refers to file $idloadcmdpath, which is a different file"
     4336                                    ui_warn "ID load command in ${bpath}, arch [machista::get_arch_name [$architecture cget -mat_arch]] refers to file ${idloadcmdpath}, which is a different file"
    43074337                                    ui_warn "This is probably a bug in the $portname port and might cause problems in libraries linking against this file"
    43084338                                }
     
    43214351                set loadcommand [$architecture cget -mat_loadcmds]
    43224352
    4323                 while {$loadcommand != "NULL"} {
     4353                while {$loadcommand ne "NULL"} {
    43244354                    if {0 != [catch {set filepath [revupgrade_handle_special_paths $bpath [$loadcommand cget -mlt_install_name]]}]} {
    43254355                        set loadcommand [$loadcommand cget -next]
     
    43344364                        if {![info exists files_warned_about($filepath)]} {
    43354365                            if {[macports::ui_isset ports_verbose]} {
    4336                                 ui_msg ""
     4366                                ui_msg {}
    43374367                            }
    4338                             ui_info "Could not open $filepath: [machista::strerror $libreturncode] (referenced from $bpath)"
     4368                            ui_info "Could not open ${filepath}: [machista::strerror $libreturncode] (referenced from $bpath)"
    43394369                            set files_warned_about($filepath) yes
    43404370                        }
     
    43494379                    set libarchitecture [$libresult cget -mt_archs]
    43504380                    set libarch_found false;
    4351                     while {$libarchitecture != "NULL"} {
    4352                         if {[$architecture cget -mat_arch] != [$libarchitecture cget -mat_arch]} {
     4381                    while {$libarchitecture ne "NULL"} {
     4382                        if {[$architecture cget -mat_arch] ne [$libarchitecture cget -mat_arch]} {
    43534383                            set libarchitecture [$libarchitecture cget -next]
    43544384                            continue;
    43554385                        }
    43564386
    4357                         if {[$loadcommand cget -mlt_version] != [$libarchitecture cget -mat_version] && [$loadcommand cget -mlt_comp_version] > [$libarchitecture cget -mat_comp_version]} {
     4387                        if {[$loadcommand cget -mlt_version] ne [$libarchitecture cget -mat_version] && [$loadcommand cget -mlt_comp_version] > [$libarchitecture cget -mat_comp_version]} {
    43584388                            if {[macports::ui_isset ports_verbose]} {
    4359                                 ui_msg ""
     4389                                ui_msg {}
    43604390                            }
    43614391                            ui_info "Incompatible library version: $bpath requires version [machista::format_dylib_version [$loadcommand cget -mlt_comp_version]] or later, but $filepath provides version [machista::format_dylib_version [$libarchitecture cget -mat_comp_version]]"
     
    43684398                    }
    43694399
    4370                     if {$libarch_found == false} {
     4400                    if {$libarch_found eq false} {
    43714401                        ui_debug "Missing architecture [machista::get_arch_name [$architecture cget -mat_arch]] in file $filepath"
    43724402                        if {[path_is_in_prefix $filepath]} {
     
    43844414            }
    43854415        }
    4386         ui_msg ""
     4416        ui_msg {}
    43874417
    43884418        machista::destroy_handle $handle
     
    43974427        foreach file $broken_files {
    43984428            set port [registry::entry owner $file]
    4399             if {$port != ""} {
     4429            if {$port ne {}} {
    44004430                lappend broken_ports $port
    44014431                lappend broken_files_by_port($port) $file
     
    44064436        set broken_ports [lsort -unique $broken_ports]
    44074437
    4408         if {${macports::revupgrade_mode} == "rebuild"} {
     4438        if {$macports::revupgrade_mode eq "rebuild"} {
    44094439            # don't try to rebuild ports that don't exist in the tree
    44104440            set temp_broken_ports {}
     
    44124442                set portname [$port name]
    44134443                if {[catch {mportlookup $portname} result]} {
    4414                     ui_debug "$::errorInfo"
     4444                    ui_debug $::errorInfo
    44154445                    error "lookup of portname $portname failed: $result"
    44164446                }
     
    44444474                    ui_error "Please run port -d -y rev-upgrade and use the output to report a bug."
    44454475                }
    4446                 error "Port $portname still broken after rebuilding [expr $broken_port_counts($portname) - 1] time(s)"
     4476                error "Port $portname still broken after rebuilding [expr {$broken_port_counts($portname) - 1}] time(s)"
    44474477            } elseif {$broken_port_counts($portname) > 1 && [global_option_isset ports_binary_only]} {
    44484478                error "Port $portname still broken after reinstalling -- can't rebuild due to binary-only mode"
     
    44524482        unset temp_broken_ports
    44534483
    4454         if {${macports::revupgrade_mode} != "rebuild"} {
     4484        if {$macports::revupgrade_mode ne "rebuild"} {
    44554485            ui_msg "$macports::ui_prefix Found [llength $broken_ports] broken port(s):"
    44564486            foreach port $broken_ports {
     
    45054535                    set unsorted_ports [lreplace $unsorted_ports $index $index]
    45064536
    4507                     # remove edges 
     4537                    # remove edges
    45084538                    foreach target $revadjlist($port) {
    45094539                        set index [lsearch -exact $adjlist($target) $port]
     
    45444574            if {![info exists depscache(port:$portname)]} {
    45454575                # set rev-upgrade options and nodeps if this is not the first run
    4546                 set my_options(ports_revupgrade) "yes"
     4576                set my_options(ports_revupgrade) yes
    45474577                unset -nocomplain my_options(ports_nodeps)
    45484578                unset -nocomplain my_options(ports_revupgrade_second_run)
     
    45554585
    45564586                # call macports::upgrade with ports_revupgrade option to rebuild the port
    4557                 set status [macports::upgrade $portname "port:$portname" \
     4587                set status [macports::upgrade $portname port:$portname \
    45584588                    {} [array get my_options] depscache]
    45594589                ui_debug "Rebuilding port $portname finished with status $status"
     
    45644594        }
    45654595
    4566         if {[info exists options(ports_dryrun)] && $options(ports_dryrun) == "yes"} {
     4596        if {[info exists options(ports_dryrun)] && $options(ports_dryrun) eq "yes"} {
    45674597            ui_warn "If this was no dry run, rev-upgrade would now run the checks again to find unresolved and newly created problems"
    45684598            return 0
     
    45974627    set corrected_path $path
    45984628
    4599     set loaderpath_idx [string first "@loader_path" $corrected_path]
     4629    set loaderpath_idx [string first @loader_path $corrected_path]
    46004630    if {$loaderpath_idx != -1} {
    4601         set corrected_path [string replace $corrected_path $loaderpath_idx $loaderpath_idx+11 [file dirname $fname]]
    4602     }
    4603 
    4604     set executablepath_idx [string first "@executable_path" $corrected_path]
     4631        set corrected_path [string replace $corrected_path $loaderpath_idx ${loaderpath_idx}+11 [file dirname $fname]]
     4632    }
     4633
     4634    set executablepath_idx [string first @executable_path $corrected_path]
    46054635    if {$executablepath_idx != -1} {
    46064636        ui_debug "Ignoring loadcommand containing @executable_path in $fname"
     
    46084638    }
    46094639
    4610     set rpath_idx [string first "@rpath" $corrected_path]
     4640    set rpath_idx [string first @rpath $corrected_path]
    46114641    if {$rpath_idx != -1} {
    46124642        ui_debug "Ignoring loadcommand containing @rpath in $fname"
     
    46414671            # make this port the new last broken port by prepending it to the stack
    46424672            set stack [linsert $stack 0 $dep]
    4643            
     4673
    46444674            set is_broken_port true
    46454675        }
     
    46644694    } elseif {[info exists ping_cache($host)]} {
    46654695        # expire entries after 1 day
    4666         if {[expr [clock seconds] - [lindex $ping_cache($host) 1]] <= 86400} {
     4696        if {[clock seconds] - [lindex $ping_cache($host) 1] <= 86400} {
    46674697            return [lindex $ping_cache($host) 0]
    46684698        }
     
    46844714        set all_names {}
    46854715        array set defaults {applications_dir /Applications/MacPorts prefix /opt/local type tbz2}
    4686         set conf_file "${macports_conf_path}/archive_sites.conf"
     4716        set conf_file ${macports_conf_path}/archive_sites.conf
    46874717        set conf_options {applications_dir frameworks_dir name prefix type urls}
    46884718        if {[file isfile $conf_file]} {
     
    46914721                if {[regexp {^(\w+)([ \t]+(.*))?$} $line match option ignore val] == 1} {
    46924722                    if {[lsearch -exact $conf_options $option] >= 0} {
    4693                         if {$option == "name"} {
     4723                        if {$option eq "name"} {
    46944724                            set cur_name $val
    46954725                            lappend all_names $val
    46964726                        } elseif {[info exists cur_name]} {
    46974727                            set trimmedval [string trim $val]
    4698                             if {$option == "urls"} {
     4728                            if {$option eq "urls"} {
    46994729                                set processed_urls {}
    47004730                                foreach url $trimmedval {
     
    47314761                if {![info exists sites($cur_name)]} {
    47324762                    ui_warn "archive_sites.conf: no urls set for $cur_name"
    4733                     set sites($cur_name) ""
    4734                     lappend archive_sites_conf_values portfetch::mirror_sites::sites($cur_name) ""
     4763                    set sites($cur_name) {}
     4764                    lappend archive_sites_conf_values portfetch::mirror_sites::sites($cur_name) {}
    47354765                }
    47364766            }
  • branches/gsoc11-statistics/base/src/package1.0/portarchivefetch.tcl

    r105085 r107206  
    33#
    44# Copyright (c) 2002 - 2003 Apple Inc.
    5 # Copyright (c) 2004 - 2012 The MacPorts Project
     5# Copyright (c) 2004 - 2013 The MacPorts Project
    66# All rights reserved.
    77#
     
    9494            continue
    9595        }
    96         if {$portfetch::mirror_sites::archive_prefix($site) == $prefix &&
     96        if {$portfetch::mirror_sites::sites($site) ne {} &&
     97            $portfetch::mirror_sites::archive_prefix($site) == $prefix &&
    9798            $portfetch::mirror_sites::archive_frameworks_dir($site) == $frameworks_dir &&
    9899            $portfetch::mirror_sites::archive_applications_dir($site) == $applications_dir &&
     
    153154# the listed url variable and associated archive file
    154155proc portarchivefetch::fetchfiles {args} {
    155     global archivefetch.fulldestpath UI_PREFIX
    156     global archivefetch.user archivefetch.password archivefetch.use_epsv \
    157            archivefetch.ignore_sslcert
    158     global portverbose ports_binary_only
     156    global archivefetch.fulldestpath UI_PREFIX \
     157          archivefetch.user archivefetch.password archivefetch.use_epsv \
     158           archivefetch.ignore_sslcert \
     159          portverbose ports_binary_only
    159160    variable archivefetch_urls
    160161    variable ::portfetch::urlmap
  • branches/gsoc11-statistics/base/src/package1.0/portdmg.tcl

    r105085 r107206  
    5858
    5959proc portdmg::package_dmg {portname portversion portrevision} {
    60     global UI_PREFIX package.destpath portpath
    61     global os.platform os.arch os.version os.major
     60    global UI_PREFIX package.destpath portpath \
     61          os.platform os.arch os.version os.major
    6262
    6363    if {[expr (${portrevision} > 0)]} {
  • branches/gsoc11-statistics/base/src/package1.0/portdpkg.tcl

    r105085 r107206  
    4545
    4646# Options
    47 options dpkg.asroot
    48 options package.destpath
     47options dpkg.asroot \
     48        package.destpath
    4949
    5050# Set up defaults
  • branches/gsoc11-statistics/base/src/package1.0/portmdmg.tcl

    r105085 r107206  
    33# $Id$
    44#
    5 # Copyright (c) 2005, 2007-2011 The MacPorts Project
     5# Copyright (c) 2005, 2007-2013 The MacPorts Project
    66# Copyright (c) 2003-2004 Apple Inc.
    77# All rights reserved.
     
    5858
    5959proc portmdmg::package_mdmg {portname portepoch portversion portrevision} {
    60     global UI_PREFIX package.destpath portpath
    61     global os.platform os.arch os.version os.major
     60    global UI_PREFIX package.destpath portpath \
     61          os.platform os.arch os.version os.major
    6262
    6363    if {[expr (${portrevision} > 0)]} {
  • branches/gsoc11-statistics/base/src/package1.0/portmpkg.tcl

    r105085 r107206  
    33# $Id$
    44#
    5 # Copyright (c) 2005, 2007 - 2012 The MacPorts Project
     5# Copyright (c) 2005, 2007 - 2013 The MacPorts Project
    66# Copyright (c) 2002 - 2004 Apple Inc.
    77# All rights reserved.
  • branches/gsoc11-statistics/base/src/package1.0/portpkg.tcl

    r105577 r107206  
    33# $Id$
    44#
    5 # Copyright (c) 2005, 2007 - 2012 The MacPorts Project
     5# Copyright (c) 2005, 2007 - 2013 The MacPorts Project
    66# Copyright (c) 2002 - 2003 Apple Inc.
    77# All rights reserved.
  • branches/gsoc11-statistics/base/src/package1.0/portrpm.tcl

    r105085 r107206  
    33# $Id$
    44#
    5 # Copyright (c) 2005 - 2007, 2009 - 2011 The MacPorts Project
     5# Copyright (c) 2005 - 2007, 2009 - 2011, 2013 The MacPorts Project
    66# Copyright (c) 2002 - 2003 Apple Inc.
    77# All rights reserved.
     
    4444
    4545# Options
    46 options rpm.asroot
    47 options package.destpath
     46options rpm.asroot \
     47        package.destpath
    4848
    4949# Set up defaults
     
    6464
    6565proc portrpm::rpm_pkg {portname portversion portrevision} {
    66     global UI_PREFIX rpm.asroot package.destpath portdbpath destpath workpath prefix categories maintainers description long_description homepage epoch portpath
    67         global os.platform os.arch os.version os.major supported_archs configure.build_arch license
     66    global UI_PREFIX rpm.asroot package.destpath portdbpath destpath workpath \
     67           prefix categories maintainers description long_description \
     68           homepage epoch portpath os.platform os.arch os.version os.major \
     69           supported_archs configure.build_arch license
    6870
    6971    set rpmdestpath ""
  • branches/gsoc11-statistics/base/src/package1.0/portsrpm.tcl

    r105085 r107206  
    33# $Id$
    44#
    5 # Copyright (c) 2007, 2009, 2011 The MacPorts Project
     5# Copyright (c) 2007, 2009, 2011, 2013 The MacPorts Project
    66# Copyright (c) 2002 - 2003 Apple Inc.
    77# All rights reserved.
     
    6060
    6161proc portsrpm::srpm_pkg {portname portversion portrevision} {
    62     global UI_PREFIX package.destpath portdbpath destpath workpath distpath prefix categories maintainers description long_description homepage epoch portpath distfiles
    63         global os.platform os.arch os.version os.major
     62    global UI_PREFIX package.destpath portdbpath destpath workpath distpath \
     63           prefix categories maintainers description long_description \
     64           homepage epoch portpath distfiles os.platform os.arch os.version \
     65           os.major
    6466
    6567    set fetch_urls {}
  • branches/gsoc11-statistics/base/src/package1.0/portunarchive.tcl

    r105085 r107206  
    279279        file mtime $statefile [clock seconds]
    280280        chownAsRoot $statefile
     281        update_statefile checksum [sha256 file [option portpath]/Portfile] $statefile
    281282        set newstate 1
    282283    } else {
  • branches/gsoc11-statistics/base/src/pextlib1.0/system.c

    r105085 r107206  
    8181{
    8282    Tcl_Obj *tcl_result;
    83     int supported;
     83    int active;
    8484    int len;
    8585
    86     tcl_result = Tcl_GetVar2Ex(interp, "portsandbox_supported", NULL, TCL_GLOBAL_ONLY);
    87     if (!tcl_result || Tcl_GetBooleanFromObj(interp, tcl_result, &supported) != TCL_OK || !supported) {
     86    tcl_result = Tcl_GetVar2Ex(interp, "portsandbox_active", NULL, TCL_GLOBAL_ONLY);
     87    if (!tcl_result || Tcl_GetBooleanFromObj(interp, tcl_result, &active) != TCL_OK || !active) {
    8888        return 0;
    8989    }
  • branches/gsoc11-statistics/base/src/pextlib1.0/tracelib.c

    r105814 r107206  
    33 * $Id$
    44 *
    5  * Copyright (c) 2007 Eugene Pimenov (GSoC), The MacPorts Project.
     5 * Copyright (c) 2007-2008 Eugene Pimenov (GSoC)
     6 * Copyright (c) 2008-2010, 2012-2013 The MacPorts Project
    67 * All rights reserved.
    78 *
  • branches/gsoc11-statistics/base/src/port/port-help.tcl

    r105085 r107206  
    4343Removes files associated with the given ports
    4444
     45--archive     Removes temporary archives
    4546--dist        Removes downloaded distfiles
    4647--logs        Removes log files
  • branches/gsoc11-statistics/base/src/port/port.tcl

    r105577 r107206  
    66# $Id$
    77#
    8 # Copyright (c) 2004-2012 The MacPorts Project
     8# Copyright (c) 2004-2013 The MacPorts Project
    99# Copyright (c) 2004 Robert Shaw <rshaw@opendarwin.org>
    1010# Copyright (c) 2002-2003 Apple Inc.
     
    39463946proc action_portcmds { action portlist opts } {
    39473947    # Operations on the port's directory and Portfile
    3948     global env boot_env
    3949     global current_portdir
     3948    global env boot_env current_portdir
    39503949
    39513950    array set local_options $opts
     
    44654464    uninstall   {follow-dependents follow-dependencies no-exec}
    44664465    variants    {index}
    4467     clean       {all dist work logs}
     4466    clean       {all archive dist work logs}
    44684467    mirror      {new}
    44694468    lint        {nitpick}
     
    46634662
    46644663proc process_cmd { argv } {
    4665     global cmd_argc cmd_argv cmd_argn
    4666     global global_options global_options_base private_options ui_options
    4667     global current_portdir
     4664    global cmd_argc cmd_argv cmd_argn \
     4665           global_options global_options_base private_options ui_options \
     4666          current_portdir
    46684667    set cmd_argv $argv
    46694668    set cmd_argc [llength $argv]
     
    47984797# return text action beginning with $text
    47994798proc complete_action { text state } {   
    4800     global action_array
    4801     global complete_choices complete_position
     4799    global action_array complete_choices complete_position
    48024800
    48034801    if {$state == 0} {
     
    49904988term_init_size
    49914989
     4990global env boot_env argv0 cmdname argc argv cmd_argc cmd_argv cmd_argn \
     4991       current_portdir global_options_base exit_status
     4992
    49924993# Save off a copy of the environment before mportinit monkeys with it
    4993 global env boot_env
    49944994array set boot_env [array get env]
    49954995
    4996 global argv0
    4997 global cmdname
    49984996set cmdname [file tail $argv0]
    49994997
    50004998# Setp cmd_argv to match argv
    5001 global argc argv
    5002 global cmd_argc cmd_argv cmd_argn
    50034999set cmd_argv $argv
    50045000set cmd_argc $argc
     
    50455041
    50465042# Set up some global state for our code
    5047 global current_portdir
    50485043set current_portdir [pwd]
    50495044
    50505045# Freeze global_options into global_options_base; global_options
    50515046# will be reset to global_options_base prior to processing each command.
    5052 global global_options_base
    50535047set global_options_base [array get global_options]
    50545048
    50555049# First process any remaining args as action(s)
    5056 global exit_status
    50575050set exit_status 0
    50585051if { [llength $remaining_args] > 0 } {
  • branches/gsoc11-statistics/base/src/port1.0/fetch_common.tcl

    r105085 r107206  
    33#
    44# Copyright (c) 2002 - 2003 Apple Inc.
    5 # Copyright (c) 2004 - 2012 The MacPorts Project
     5# Copyright (c) 2004 - 2013 The MacPorts Project
    66# All rights reserved.
    77#
     
    8585# pre-registered set of sites, and if so, return them.
    8686proc portfetch::mirror_sites {mirrors tag subdir mirrorfile} {
    87     global UI_PREFIX name dist_subdir
    88     global global_mirror_site fallback_mirror_site
     87    global UI_PREFIX name dist_subdir \
     88          global_mirror_site fallback_mirror_site
    8989
    9090    if {[file exists $mirrorfile]} {
     
    344344    # check_broken_dns returns true at most once, so we don't have to worry about spamming this message
    345345    if {[check_broken_dns]} {
    346         ui_warn "Your DNS server(s) incorrectly claim to know the address of nonexistent hosts. This may cause checksum mismatches for some ports."
    347     }
    348 }
     346        ui_warn "Your DNS servers incorrectly claim to know the address of nonexistent hosts. This may cause checksum mismatches for some ports."
     347    }
     348}
  • branches/gsoc11-statistics/base/src/port1.0/portactivate.tcl

    r79672 r107206  
    6060
    6161proc portactivate::activate_main {args} {
    62     global env subport version revision portvariants user_options PortInfo
     62    global env subport version revision portvariants user_options PortInfo startupitem.autostart UI_PREFIX
    6363
    6464    registry_activate $subport $version $revision $portvariants [array get user_options]
     
    9898    }
    9999
     100    if {[tbool startupitem.autostart]} {
     101        ui_notice "$UI_PREFIX [format [msgcat::mc "Loading %s"] [option subport]]"
     102        if {[eval_targets "load"]} {
     103            ui_error [format [msgcat::mc "Failed to load %s"] [option subport]]
     104            return 1
     105        }
     106    }
     107
    100108    return 0
    101109}
  • branches/gsoc11-statistics/base/src/port1.0/portbuild.tcl

    r105085 r107206  
    33# $Id$
    44#
    5 # Copyright (c) 2007 - 2012 The MacPorts Project
     5# Copyright (c) 2007 - 2013 The MacPorts Project
    66# Copyright (c) 2002 - 2004 Apple Inc.
    77# All rights reserved.
     
    4444
    4545# define options
    46 options build.asroot
    47 options build.jobs
    48 options build.target
    49 options build.type
    50 options use_parallel_build
     46options build.asroot \
     47        build.jobs \
     48        build.target \
     49        build.type \
     50        use_parallel_build
    5151commands build
    5252# defaults
     
    6767# dependency.
    6868proc portbuild::add_automatic_buildsystem_dependencies {} {
     69    global build.type.add_deps
     70    if {!${build.type.add_deps}} {
     71        return
     72    }
    6973    if {[option build.type] == "bsd" && [option os.platform] == "darwin"} {
    7074        ui_debug "build.type is BSD, adding bin:bsdmake:bsdmake build dependency"
     
    8084# Register the above procedure as a callback after Portfile evaluation
    8185port::register_callback portbuild::add_automatic_buildsystem_dependencies
     86# and an option to turn it off if required
     87options build.type.add_deps
     88default build.type.add_deps yes
    8289
    8390proc portbuild::build_getmaketype {args} {
  • branches/gsoc11-statistics/base/src/port1.0/portchecksum.tcl

    r105085 r107206  
    201201#
    202202proc portchecksum::checksum_main {args} {
    203     global UI_PREFIX all_dist_files checksum_types checksums_array portverbose checksum.skip
    204     global usealtworkpath altprefix default_checksum_types
     203    global UI_PREFIX all_dist_files checksum_types checksums_array portverbose checksum.skip \
     204          usealtworkpath altprefix default_checksum_types
    205205
    206206    # If no files have been downloaded, there is nothing to checksum.
  • branches/gsoc11-statistics/base/src/port1.0/portclean.tcl

    r82923 r107206  
    11# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
    2 # portclean.tcl
    32# $Id$
    43#
    5 # Copyright (c) 2005-2007, 2009-2011 The MacPorts Project
     4# Copyright (c) 2005-2007, 2009-2011, 2013 The MacPorts Project
    65# Copyright (c) 2004 Robert Shaw <rshaw@opendarwin.org>
    76# Copyright (c) 2002 - 2003 Apple Inc.
     
    6261
    6362proc portclean::clean_main {args} {
    64     global UI_PREFIX
    65     global ports_clean_dist ports_clean_work ports_clean_logs
    66     global ports_clean_all keeplogs usealtworkpath
     63    global UI_PREFIX ports_clean_dist ports_clean_work ports_clean_logs \
     64           ports_clean_archive ports_clean_all keeplogs usealtworkpath
    6765
    6866    if {$usealtworkpath} {
     
    7573        clean_dist
    7674    }
     75    if {([info exists ports_clean_all] && $ports_clean_all == "yes" || \
     76        [info exists ports_clean_archive] && $ports_clean_archive == "yes")
     77        && !$usealtworkpath} {
     78        ui_info "$UI_PREFIX [format [msgcat::mc "Removing temporary archives for %s"] [option subport]]"
     79        clean_archive
     80    }
    7781    if {[info exists ports_clean_all] && $ports_clean_all == "yes" || \
    7882        [info exists ports_clean_work] && $ports_clean_work == "yes" || \
     83        [info exists ports_clean_archive] && $ports_clean_archive == "yes" || \
     84        [info exists ports_clean_dist] && $ports_clean_dist == "yes" || \
    7985        !([info exists ports_clean_logs] && $ports_clean_logs == "yes")} {
    8086         ui_info "$UI_PREFIX [format [msgcat::mc "Removing work directory for %s"] [option subport]]"
     
    260266    return 0
    261267}
     268
     269proc portclean::clean_archive {args} {
     270    global subport ports_version_glob portdbpath
     271
     272    # Define archive destination directory, target filename, regex for archive name
     273    set archivepath [file join $portdbpath incoming]
     274
     275    if {[info exists ports_version_glob]} {
     276        # Match all possible archive variants that match the version
     277        # glob specified by the user.
     278        set fileglob "$subport-[option ports_version_glob]*.*.*.*"
     279    } else {
     280        # Match all possible archives for this port.
     281        set fileglob "$subport-*_*.*.*.*"
     282    }
     283
     284    # Remove the archive files
     285    set count 0
     286    foreach dir [list $archivepath ${archivepath}/verified] {
     287        set archivelist [glob -nocomplain -directory $dir $fileglob]
     288        foreach path $archivelist {
     289            # Make sure file is truly an archive file for this port, and not
     290            # an accidental match with some other file that might exist. Also
     291            # delete anything ending in .TMP since those are incomplete and
     292            # thus can't be checked and aren't useful anyway.
     293            set archivetype [string range [file extension $path] 1 end]
     294            if {[file isfile $path] && ($archivetype == "TMP"
     295                || [extract_archive_metadata $path $archivetype portname] == $subport)} {
     296                ui_debug "Removing archive: $path"
     297                if {[catch {delete $path} result]} {
     298                    ui_debug "$::errorInfo"
     299                    ui_error "$result"
     300                }
     301                if {[file isfile ${path}.rmd160]} {
     302                    ui_debug "Removing archive signature: ${path}.rmd160"
     303                    if {[catch {delete ${path}.rmd160} result]} {
     304                        ui_debug "$::errorInfo"
     305                        ui_error "$result"
     306                    }
     307                }
     308                incr count
     309            }
     310        }
     311    }
     312    if {$count > 0} {
     313        ui_debug "$count archive(s) removed."
     314    } else {
     315        ui_debug "No archives found to remove at $archivepath"
     316    }
     317
     318    return 0
     319}
  • branches/gsoc11-statistics/base/src/port1.0/portconfigure.tcl

    r105577 r107206  
    128128default configure.mtune     {}
    129129# We could have debug/optimizations be global configurable at some point.
    130 options configure.optflags
    131 options configure.cflags configure.cxxflags configure.objcflags
    132 options configure.cppflags configure.ldflags configure.libs
    133 options configure.fflags configure.f90flags configure.fcflags
    134 options configure.classpath
     130options configure.optflags \
     131        configure.cflags configure.cxxflags configure.objcflags \
     132        configure.cppflags configure.ldflags configure.libs \
     133        configure.fflags configure.f90flags configure.fcflags \
     134        configure.classpath
    135135# compiler flags section
    136136default configure.optflags  {-Os}
     
    147147
    148148# tools section
    149 options configure.perl configure.python configure.ruby
    150 options configure.install configure.awk configure.bison
    151 options configure.pkg_config configure.pkg_config_path
     149options configure.perl configure.python configure.ruby \
     150        configure.install configure.awk configure.bison \
     151        configure.pkg_config configure.pkg_config_path
    152152default configure.perl              {}
    153153default configure.python            {}
     
    168168}
    169169
    170 options configure.universal_archs configure.universal_args
    171 options configure.universal_cflags configure.universal_cxxflags
    172 options configure.universal_cppflags configure.universal_ldflags
     170options configure.universal_archs configure.universal_args \
     171        configure.universal_cflags configure.universal_cxxflags \
     172        configure.universal_cppflags configure.universal_ldflags
    173173default configure.universal_archs       {[portconfigure::choose_supported_archs ${universal_archs}]}
    174174default configure.universal_args        {--disable-dependency-tracking}
     
    591591# automatically add a dependency when needed
    592592proc portconfigure::add_automatic_compiler_dependencies {} {
    593     global configure.compiler
     593    global configure.compiler configure.compiler.add_deps
     594
     595    if {!${configure.compiler.add_deps}} {
     596        return
     597    }
    594598
    595599    # The default value requires substitution before use.
     
    618622# Register the above procedure as a callback after Portfile evaluation
    619623port::register_callback portconfigure::add_automatic_compiler_dependencies
     624# and an option to turn it off if required
     625options configure.compiler.add_deps
     626default configure.compiler.add_deps yes
    620627
    621628proc portconfigure::configure_main {args} {
    622629    global [info globals]
    623     global worksrcpath use_configure use_autoreconf use_autoconf use_automake use_xmkmf
    624     global configure.env configure.pipe configure.libs configure.classpath configure.universal_args
    625     global configure.perl configure.python configure.ruby configure.install configure.awk configure.bison
    626     global configure.pkg_config configure.pkg_config_path
    627     global configure.ccache configure.distcc configure.cpp configure.javac configure.sdkroot
    628     global configure.march configure.mtune
    629     global os.platform os.major
     630    global worksrcpath use_configure use_autoreconf use_autoconf use_automake use_xmkmf \
     631           configure.env configure.pipe configure.libs configure.classpath configure.universal_args \
     632           configure.perl configure.python configure.ruby configure.install configure.awk configure.bison \
     633           configure.pkg_config configure.pkg_config_path \
     634           configure.ccache configure.distcc configure.cpp configure.javac configure.sdkroot \
     635           configure.march configure.mtune \
     636          os.platform os.major
    630637    foreach tool {cc cxx objc f77 f90 fc ld} {
    631638        global configure.${tool} configure.${tool}_archflags
  • branches/gsoc11-statistics/base/src/port1.0/portdeactivate.tcl

    r79672 r107206  
    5858
    5959proc portdeactivate::deactivate_main {args} {
    60     global subport version revision portvariants user_options
     60    global subport version revision portvariants user_options startupitem.autostart UI_PREFIX
     61
     62    if {[tbool startupitem.autostart]} {
     63        ui_notice "$UI_PREFIX [format [msgcat::mc "Unloading %s"] [option subport]]"
     64        if {[eval_targets "unload"]} {
     65            ui_warn [format [msgcat::mc "Failed to unload %s, continuing anyway."] [option subport]]
     66        }
     67    }
     68
    6169    registry_deactivate $subport $version $revision $portvariants [array get user_options]
    6270    return 0
  • branches/gsoc11-statistics/base/src/port1.0/portdestroot.tcl

    r105085 r107206  
    55# Copyright (c) 2002 - 2003 Apple Inc.
    66# Copyright (c) 2004 - 2005 Robert Shaw <rshaw@opendarwin.org>
    7 # Copyright (c) 2004-2005, 2007-2012 The MacPorts Project
     7# Copyright (c) 2004-2005, 2007-2013 The MacPorts Project
    88# All rights reserved.
    99#
     
    4848
    4949# define options
    50 options destroot.target destroot.destdir destroot.clean destroot.keepdirs destroot.umask
    51 options destroot.violate_mtree destroot.asroot destroot.delete_la_files
    52 options startupitem.create startupitem.requires startupitem.init
    53 options startupitem.name startupitem.start startupitem.stop startupitem.restart
    54 options startupitem.type startupitem.executable
    55 options startupitem.pidfile startupitem.logfile startupitem.logevents startupitem.netchange
    56 options startupitem.uniquename startupitem.plist startupitem.location startupitem.install
     50options destroot.target destroot.destdir destroot.clean destroot.keepdirs destroot.umask \
     51        destroot.violate_mtree destroot.asroot destroot.delete_la_files \
     52        startupitem.autostart startupitem.create startupitem.executable \
     53        startupitem.init startupitem.install startupitem.location \
     54        startupitem.logevents startupitem.logfile startupitem.name \
     55        startupitem.netchange startupitem.pidfile startupitem.plist \
     56        startupitem.requires startupitem.restart startupitem.start \
     57        startupitem.stop startupitem.type startupitem.uniquename
    5758commands destroot
    5859
     
    7273default destroot.delete_la_files no
    7374
     75default startupitem.autostart   no
     76default startupitem.executable  ""
     77default startupitem.init        ""
     78default startupitem.install     {$system_options(startupitem_install)}
     79default startupitem.location    LaunchDaemons
     80default startupitem.logevents   no
     81default startupitem.logfile     ""
    7482default startupitem.name        {${subport}}
    75 default startupitem.uniquename  {org.macports.${startupitem.name}}
     83default startupitem.netchange   no
     84default startupitem.pidfile     ""
    7685default startupitem.plist       {${startupitem.uniquename}.plist}
    77 default startupitem.location    LaunchDaemons
    78 default startupitem.init        ""
     86default startupitem.requires    ""
     87default startupitem.restart     ""
    7988default startupitem.start       ""
    8089default startupitem.stop        ""
    81 default startupitem.restart     ""
    82 default startupitem.requires    ""
    83 default startupitem.executable  ""
    8490default startupitem.type        {$system_options(startupitem_type)}
    85 default startupitem.pidfile     ""
    86 default startupitem.logfile     ""
    87 default startupitem.logevents   no
    88 default startupitem.netchange   no
    89 default startupitem.install     {$system_options(startupitem_install)}
     91default startupitem.uniquename  {org.macports.${startupitem.name}}
    9092
    9193set_ui_prefix
     
    103105
    104106proc portdestroot::destroot_start {args} {
    105     global UI_PREFIX prefix subport porturl destroot os.platform destroot.clean portsharepath
    106     global destroot.umask destroot.asroot euid egid
    107     global applications_dir frameworks_dir
     107    global UI_PREFIX prefix subport porturl destroot os.platform destroot.clean portsharepath \
     108           destroot.umask destroot.asroot euid egid \
     109          applications_dir frameworks_dir
    108110    variable oldmask
    109111
     
    150152
    151153proc portdestroot::destroot_finish {args} {
    152     global UI_PREFIX destroot prefix subport startupitem.create destroot.violate_mtree
    153     global applications_dir frameworks_dir destroot.keepdirs destroot.delete_la_files
    154     global os.platform os.version
     154    global UI_PREFIX destroot prefix subport startupitem.create destroot.violate_mtree \
     155           applications_dir frameworks_dir destroot.keepdirs destroot.delete_la_files \
     156          os.platform os.version
    155157    variable oldmask
    156158
  • branches/gsoc11-statistics/base/src/port1.0/portdistcheck.tcl

    r105085 r107206  
    5454
    5555proc portdistcheck::distcheck_main {args} {
    56     global distcheck.type
    57     global fetch.type
    58     global fetch.ignore_sslcert
    59     global subport portpath
     56    global distcheck.type fetch.type fetch.ignore_sslcert \
     57           subport portpath
    6058
    6159    set port_moddate [file mtime ${portpath}/Portfile]
  • branches/gsoc11-statistics/base/src/port1.0/portfetch.tcl

    r105085 r107206  
    324324# information in a custom .cvspass file
    325325proc portfetch::cvsfetch {args} {
    326     global workpath cvs.env cvs.cmd cvs.args cvs.post_args
    327     global cvs.root cvs.date cvs.tag cvs.method cvs.password
    328     global patch_sites patchfiles filespath
     326    global workpath cvs.env cvs.cmd cvs.args cvs.post_args \
     327          cvs.root cvs.date cvs.tag cvs.method cvs.password
     328          patch_sites patchfiles filespath
    329329
    330330    set cvs.args "${cvs.method} ${cvs.args}"
     
    421421# Perform a git fetch
    422422proc portfetch::gitfetch {args} {
    423     global worksrcpath patchfiles
    424     global git.url git.branch git.sha1 git.cmd
     423    global worksrcpath patchfiles \
     424          git.url git.branch git.sha1 git.cmd
    425425
    426426    set options "-q"
     
    477477# the listed url variable and associated distfile
    478478proc portfetch::fetchfiles {args} {
    479     global distpath all_dist_files UI_PREFIX
    480     global fetch.user fetch.password fetch.use_epsv fetch.ignore_sslcert fetch.remote_time
    481     global fallback_mirror_site portverbose usealtworkpath altprefix
     479    global distpath all_dist_files UI_PREFIX \
     480           fetch.user fetch.password fetch.use_epsv fetch.ignore_sslcert fetch.remote_time \
     481          fallback_mirror_site portverbose usealtworkpath altprefix
    482482    variable fetch_urls
    483483    variable urlmap
  • branches/gsoc11-statistics/base/src/port1.0/portinstall.tcl

    r105085 r107206  
    5555
    5656proc portinstall::install_start {args} {
    57     global UI_PREFIX subport version revision portvariants
    58     global prefix registry_open registry.path
     57    global UI_PREFIX subport version revision portvariants \
     58          prefix registry_open registry.path
    5959    ui_notice "$UI_PREFIX [format [msgcat::mc "Installing %s @%s_%s%s"] $subport $version $revision $portvariants]"
    6060   
     
    7575    # create any users and groups needed by the port
    7676    handle_add_users
    77 }
    78 
    79 # fake some info for a list of files to match the format
    80 # used for contents in the flat registry
    81 # This list is a 6-tuple of the form:
    82 # 0: file path
    83 # 1: uid
    84 # 2: gid
    85 # 3: mode
    86 # 4: size
    87 # 5: md5 checksum information
    88 proc portinstall::_fake_fileinfo_for_index {flist} {
    89     global
    90         set rval [list]
    91         foreach file $flist {
    92                 lappend rval [list $file [getuid] [getgid] 0644 0 "MD5 ($fname) NONE"]
    93         }
    94         return $rval
    9577}
    9678
     
    318300
    319301proc portinstall::extract_contents {location type} {
    320     set qflag ${portutil::autoconf::tar_q}
    321     switch -- $type {
    322         tbz -
    323         tbz2 {
    324             set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xOj${qflag}f $location ./+CONTENTS]
    325         }
    326         tgz {
    327             set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xOz${qflag}f $location ./+CONTENTS]
    328         }
    329         tar {
    330             set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $location ./+CONTENTS]
    331         }
    332         txz {
    333             set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $location --use-compress-program [findBinary xz ""] ./+CONTENTS]
    334         }
    335         tlz {
    336             set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $location --use-compress-program [findBinary lzma ""] ./+CONTENTS]
    337         }
    338         xar {
    339             system "cd ${workpath} && [findBinary xar ${portutil::autoconf::xar_path}] -xf $location +CONTENTS"
    340             set twostep 1
    341         }
    342         zip {
    343             set raw_contents [exec [findBinary unzip ${portutil::autoconf::unzip_path}] -p $location +CONTENTS]
    344         }
    345         cpgz {
    346             system "cd ${workpath} && [findBinary pax ${portutil::autoconf::pax_path}] -rzf $location +CONTENTS"
    347             set twostep 1
    348         }
    349         cpio {
    350             system "cd ${workpath} && [findBinary pax ${portutil::autoconf::pax_path}] -rf $location +CONTENTS"
    351             set twostep 1
    352         }
    353     }
    354     if {[info exists twostep]} {
    355         set fd [open "${workpath}/+CONTENTS"]
    356         set raw_contents [read $fd]
    357         close $fd
    358     }
    359     set contents {}
    360     set ignore 0
    361     set sep [file separator]
    362     foreach line [split $raw_contents \n] {
    363         if {$ignore} {
    364             set ignore 0
    365             continue
    366         }
    367         if {[string index $line 0] != "@"} {
    368             lappend contents "${sep}${line}"
    369         } elseif {$line == "@ignore"} {
    370             set ignore 1
    371         }
    372     }
    373     return $contents
     302    return [extract_archive_metadata $location $type contents]
    374303}
    375304
     
    455384    return 0
    456385}
    457 
    458 # apparent usage of pkg_uninstall variable in the (flat) registry
    459 # the Portfile needs to define a procedure
    460 # proc pkg_uninstall {portname portver} {
    461 #     body of proc
    462 # }
    463 # which gets stored above in the receipt's pkg_uninstall property
    464 # this is then called by the portuninstall procedure
    465 # note that the portuninstall procedure is not called within
    466 # the context of the portfile so many usual port variables do not exist
    467 # e.g. destroot/workpath/filespath
    468  
    469 # this procedure encodes the pkg_uninstall body so that it can be stored in the
    470 # the receipt file
    471 proc portinstall::proc_disasm {pname} {
    472     set p "proc "
    473     append p $pname " {"
    474     set space ""
    475     foreach arg [info args $pname] {
    476         if {[info default $pname $arg value]} {
    477             append p "$space{" [list $arg $value] "}"
    478         } else {
    479             append p $space $arg
    480         }
    481         set space " "
    482     }
    483     append p "} {" [string map { \n \\n } [info body $pname] ] " }"
    484     return $p
    485 }
  • branches/gsoc11-statistics/base/src/port1.0/portlivecheck.tcl

    r105085 r107206  
    6161
    6262proc portlivecheck::livecheck_main {args} {
    63     global livecheck.url livecheck.type livecheck.md5 livecheck.regex livecheck.name livecheck.distname livecheck.version
    64     global livecheck.ignore_sslcert
    65     global homepage portpath workpath
    66     global master_sites name subport distfiles
     63    global livecheck.url livecheck.type livecheck.md5 livecheck.regex livecheck.name livecheck.distname livecheck.version \
     64           livecheck.ignore_sslcert \
     65           homepage portpath workpath \
     66          master_sites name subport distfiles
    6767
    6868    set updated 0
  • branches/gsoc11-statistics/base/src/port1.0/portsandbox.tcl

    r105085 r107206  
    22# $Id$
    33#
    4 # Copyright (c) 2012 The MacPorts Project
     4# Copyright (c) 2012-2013 The MacPorts Project
    55#
    66# Redistribution and use in source and binary forms, with or without
     
    3434}
    3535
    36 options portsandbox_supported portsandbox_profile
     36options portsandbox_supported portsandbox_active portsandbox_profile
    3737default portsandbox_supported {[file executable $portutil::autoconf::sandbox_exec_path]}
     38default portsandbox_active {[expr $portsandbox_supported && $sandbox_enable]}
    3839default portsandbox_profile {}
    3940
  • branches/gsoc11-statistics/base/src/port1.0/portstartupitem.tcl

    r105085 r107206  
    6565#       - for systemstarter, generate log messages in our generated script
    6666#
     67#   startupitem.autostart   yes/no
     68#       Automatically load the startupitem after activating. Defaults to no.
     69#
    6770
    6871package provide portstartupitem 1.0
     
    7578
    7679proc portstartupitem::startupitem_create_rcng {args} {
    77     global prefix destroot os.platform
    78     global startupitem.name startupitem.requires
    79     global startupitem.start startupitem.stop startupitem.restart
    80     global startupitem.type
     80    global prefix destroot os.platform \
     81           startupitem.name startupitem.requires \
     82           startupitem.start startupitem.stop startupitem.restart \
     83          startupitem.type
    8184
    8285    set scriptdir ${destroot}${prefix}/etc/rc.d
     
    121124
    122125proc portstartupitem::startupitem_create_darwin_systemstarter {args} {
    123     global UI_PREFIX prefix destroot destroot.keepdirs subport os.platform
    124     global startupitem.name startupitem.requires startupitem.init
    125     global startupitem.start startupitem.stop startupitem.restart startupitem.executable
    126     global startupitem.pidfile startupitem.logfile startupitem.logevents
     126    global UI_PREFIX prefix destroot destroot.keepdirs subport os.platform \
     127           startupitem.name startupitem.requires startupitem.init \
     128           startupitem.start startupitem.stop startupitem.restart startupitem.executable \
     129           startupitem.pidfile startupitem.logfile startupitem.logevents \
     130           startupitem.autostart
    127131   
    128132    set scriptdir ${prefix}/etc/startup
     
    386390   
    387391    # Emit some information for the user
    388     ui_notice "###########################################################"
    389     ui_notice "# A startup item has been generated that will aid in"
    390     ui_notice "# starting ${subport} with SystemStarter. It is disabled"
    391     ui_notice "# by default. Add the following line to /etc/hostconfig"
    392     ui_notice "# or ${prefix}/etc/rc.conf to start it at startup:"
    393     ui_notice "#"
    394     ui_notice "# ${uppername}=-YES-"
    395     ui_notice "###########################################################"
     392    if {[tbool startupitem.autostart]} {
     393        ui_notice "###########################################################"
     394        ui_notice "# A startup item has been generated that will aid in"
     395        ui_notice "# starting ${subport} with SystemStarter. It will be"
     396        ui_notice "# started automatically on activation."
     397        ui_notice "###########################################################"
     398    } else {
     399        ui_notice "###########################################################"
     400        ui_notice "# A startup item has been generated that will aid in"
     401        ui_notice "# starting ${subport} with SystemStarter. It is disabled"
     402        ui_notice "# by default. Add the following line to /etc/hostconfig"
     403        ui_notice "# or ${prefix}/etc/rc.conf to start it at startup:"
     404        ui_notice "#"
     405        ui_notice "# ${uppername}=-YES-"
     406        ui_notice "###########################################################"
     407    }
    396408}
    397409
    398410proc portstartupitem::startupitem_create_darwin_launchd {args} {
    399     global UI_PREFIX prefix destroot destroot.keepdirs subport macosx_deployment_target
    400     global startupitem.name startupitem.uniquename startupitem.plist startupitem.location
    401     global startupitem.init startupitem.start startupitem.stop startupitem.restart startupitem.executable
    402     global startupitem.pidfile startupitem.logfile startupitem.logevents startupitem.netchange
    403     global startupitem.install
     411    global UI_PREFIX prefix destroot destroot.keepdirs subport macosx_deployment_target \
     412           startupitem.name startupitem.uniquename startupitem.plist startupitem.location \
     413           startupitem.init startupitem.start startupitem.stop startupitem.restart startupitem.executable \
     414           startupitem.pidfile startupitem.logfile startupitem.logevents startupitem.netchange \
     415           startupitem.install startupitem.autostart
    404416
    405417    set scriptdir ${prefix}/etc/startup
     
    622634   
    623635    # Emit some information for the user
    624     ui_notice "###########################################################"
    625     ui_notice "# A startup item has been generated that will aid in"
    626     ui_notice "# starting ${subport} with launchd. It is disabled"
    627     ui_notice "# by default. Execute the following command to start it,"
    628     ui_notice "# and to cause it to launch at startup:"
    629     ui_notice "#"
    630     ui_notice "# sudo port load ${subport}"
    631     ui_notice "###########################################################"
     636    if {[tbool startupitem.autostart]} {
     637        ui_notice "###########################################################"
     638        ui_notice "# A startup item has been generated that will aid in"
     639        ui_notice "# starting ${subport} with launchd. It will be enabled"
     640        ui_notice "# automatically on activation. Execute the following"
     641        ui_notice "# command to manually _disable_ it:"
     642        ui_notice "#"
     643        ui_notice "# sudo port unload ${subport}"
     644        ui_notice "###########################################################"
     645    } else {
     646        ui_notice "###########################################################"
     647        ui_notice "# A startup item has been generated that will aid in"
     648        ui_notice "# starting ${subport} with launchd. It is disabled"
     649        ui_notice "# by default. Execute the following command to start it,"
     650        ui_notice "# and to cause it to launch at startup:"
     651        ui_notice "#"
     652        ui_notice "# sudo port load ${subport}"
     653        ui_notice "###########################################################"
     654    }
    632655}
    633656
    634657proc portstartupitem::startupitem_create {args} {
    635     global UI_PREFIX
    636     global startupitem.type os.platform
     658    global UI_PREFIX startupitem.type os.platform
    637659   
    638660    set startupitem.type [string tolower ${startupitem.type}]
  • branches/gsoc11-statistics/base/src/port1.0/porttrace.tcl

    r105085 r107206  
    234234# Slave method to read a line from the trace.
    235235proc porttrace::slave_read_line {chan} {
    236     global ports_list trace_filemap sandbox_violation_list workpath
    237     global env
     236    global ports_list trace_filemap sandbox_violation_list workpath env
    238237
    239238    while 1 {
  • branches/gsoc11-statistics/base/src/port1.0/portutil.tcl

    r105085 r107206  
    11# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4
    2 # portutil.tcl
    32# $Id$
    43#
     
    259258
    260259##
    261 # Mark an option as deprecate
    262 # If it is set or accessed, it will be mapped it to the new option
     260# Mark an option as deprecated
     261# If it is set or accessed, it will be mapped to the new option
    263262#
    264263# @param option name of the option
     
    916915# Provides "sed in place" functionality
    917916proc reinplace {args}  {
    918     global env worksrcpath macosx_version
     917    global env workpath worksrcpath macosx_version
    919918    set extended 0
    920919    set suppress 0
     
    963962    set files [lrange $args 1 end]
    964963
     964    if {[file isdirectory ${workpath}/.tmp]} {
     965        set tempdir ${workpath}/.tmp
     966    } else {
     967        set tempdir /tmp
     968    }
     969
    965970    foreach file $files {
    966971        # if $file is an absolute path already, file join will just return the
     
    968973        set file [file join $dir $file]
    969974
    970         if {[catch {set tmpfile [mkstemp "/tmp/[file tail $file].sed.XXXXXXXX"]} error]} {
     975        if {[catch {set tmpfile [mkstemp "${tempdir}/[file tail $file].sed.XXXXXXXX"]} error]} {
    971976            global errorInfo
    972977            ui_debug "$errorInfo"
     
    18271832    puts $fd "$class: $name"
    18281833    flush $fd
     1834}
     1835
     1836# Change the value of an existing statefile key
     1837# caller must call open_statefile after this
     1838proc update_statefile {class name path} {
     1839    set fd [open $path r]
     1840    while {[gets $fd line] >= 0} {
     1841        if {[lindex $line 0] != "${class}:"} {
     1842            lappend lines $line
     1843        }
     1844    }
     1845    close $fd
     1846    # truncate
     1847    set fd [open $path w]
     1848    puts $fd "$class: $name"
     1849    foreach line $lines {
     1850        puts $fd $line
     1851    }
     1852    close $fd
    18291853}
    18301854
     
    22082232
    22092233proc handle_default_variants {option action {value ""}} {
    2210     global PortInfo
    2211     global variations
     2234    global PortInfo variations
    22122235    switch -regex $action {
    22132236        set|append {
     
    24472470# return path to a downloaded or installed archive for this port
    24482471proc find_portarchive_path {} {
    2449     global portdbpath subport version revision portvariants
     2472    global portdbpath subport version revision portvariants force_archive_refresh
    24502473    set installed 0
    24512474    if {[registry_exists $subport $version $revision $portvariants]} {
     
    24552478    foreach unarchive.type [supportedArchiveTypes] {
    24562479        set fullarchivename "${archiverootname}.${unarchive.type}"
    2457         if {$installed} {
     2480        if {$installed && ![tbool force_archive_refresh]} {
    24582481            set fullarchivepath [file join $portdbpath software $subport $fullarchivename]
    24592482        } else {
     
    25342557}
    25352558
     2559# return the specified piece of metadata from the +CONTENTS file in the given archive
     2560proc extract_archive_metadata {archive_location archive_type metadata_type} {
     2561    set qflag ${portutil::autoconf::tar_q}
     2562    set raw_contents ""
     2563
     2564    switch -- $archive_type {
     2565        xar -
     2566        cpgz -
     2567        cpio {
     2568            set twostep 1
     2569            global workpath
     2570            if {[file isdirectory ${workpath}/.tmp]} {
     2571                set tempdir [mkdtemp ${workpath}/.tmp/portarchiveXXXXXXXX]
     2572            } else {
     2573                set tempdir [mkdtemp /tmp/portarchiveXXXXXXXX]
     2574            }
     2575        }
     2576    }
     2577
     2578    switch -- $archive_type {
     2579        tbz -
     2580        tbz2 {
     2581            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xOj${qflag}f $archive_location ./+CONTENTS]
     2582        }
     2583        tgz {
     2584            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xOz${qflag}f $archive_location ./+CONTENTS]
     2585        }
     2586        tar {
     2587            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $archive_location ./+CONTENTS]
     2588        }
     2589        txz {
     2590            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $archive_location --use-compress-program [findBinary xz ""] ./+CONTENTS]
     2591        }
     2592        tlz {
     2593            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $archive_location --use-compress-program [findBinary lzma ""] ./+CONTENTS]
     2594        }
     2595        xar {
     2596            system -W ${tempdir} "[findBinary xar ${portutil::autoconf::xar_path}] -xf $archive_location +CONTENTS"
     2597        }
     2598        zip {
     2599            set raw_contents [exec [findBinary unzip ${portutil::autoconf::unzip_path}] -p $archive_location +CONTENTS]
     2600        }
     2601        cpgz {
     2602            system -W ${tempdir} "[findBinary pax ${portutil::autoconf::pax_path}] -rzf $archive_location +CONTENTS"
     2603        }
     2604        cpio {
     2605            system -W ${tempdir} "[findBinary pax ${portutil::autoconf::pax_path}] -rf $archive_location +CONTENTS"
     2606        }
     2607    }
     2608    if {[info exists twostep]} {
     2609        set fd [open "${tempdir}/+CONTENTS"]
     2610        set raw_contents [read $fd]
     2611        close $fd
     2612        file delete -force $tempdir
     2613    }
     2614    if {$metadata_type == "contents"} {
     2615        set contents {}
     2616        set ignore 0
     2617        set sep [file separator]
     2618        foreach line [split $raw_contents \n] {
     2619            if {$ignore} {
     2620                set ignore 0
     2621                continue
     2622            }
     2623            if {[string index $line 0] != "@"} {
     2624                lappend contents "${sep}${line}"
     2625            } elseif {$line == "@ignore"} {
     2626                set ignore 1
     2627            }
     2628        }
     2629        return $contents
     2630    } elseif {$metadata_type == "portname"} {
     2631        foreach line [split $raw_contents \n] {
     2632            if {[lindex $line 0] == "@portname"} {
     2633                return [lindex $line 1]
     2634            }
     2635        }
     2636        return ""
     2637    } else {
     2638        return -code error "unknown metadata_type: $metadata_type"
     2639    }
     2640}
     2641
    25362642#
    25372643# merge function for universal builds
     
    29533059                set min 4.1
    29543060                set ok 4.1
    2955                 set rec 4.5.2
     3061                set rec 4.6.2
    29563062            }
    29573063            default {
    29583064                set min 4.4
    29593065                set ok 4.4
    2960                 set rec 4.5.2
     3066                set rec 4.6.2
    29613067            }
    29623068        }
Note: See TracChangeset for help on using the changeset viewer.