Changeset 146674 for trunk/base


Ignore:
Timestamp:
Mar 15, 2016, 12:27:00 PM (4 years ago)
Author:
petr@…
Message:

base: avoid signals swallowing in try/catch for some occurences in macports.tcl

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/macports1.0/macports.tcl

    r146634 r146674  
    355355        return $autoconf_hint
    356356    } else {
    357         if {[catch {set cmd_path [macports::binaryInPath $prog]} result] == 0} {
     357        try -pass_signal {
     358            set cmd_path [macports::binaryInPath $prog]
    358359            return $cmd_path
    359         } else {
    360             return -code error "$result or at its MacPorts configuration time location, did you move it?"
     360        } catch {{*} eCode eMessage} {
     361            error "$eMessage or at its MacPorts configuration time location, did you move it?"
    361362        }
    362363    }
     
    388389    trace remove variable macports::xcodebuildcmd read macports::setxcodeinfo
    389390
    390     if {![catch {findBinary xcodebuild $macports::autoconf::xcodebuild_path} xcodebuild]} {
     391    try -pass_signal {
     392        findBinary xcodebuild $macports::autoconf::xcodebuild_path
    391393        if {![info exists xcodeversion]} {
    392394            # Determine xcode version
    393395            set macports::xcodeversion 2.0orlower
    394             if {[catch {set xcodebuildversion [exec -- $xcodebuild -version 2> /dev/null]}] == 0} {
     396            try -pass_signal {
     397                set xcodebuildversion [exec -- $xcodebuild -version 2> /dev/null]
    395398                if {[regexp {Xcode ([0-9.]+)} $xcodebuildversion - xcode_v] == 1} {
    396399                    set macports::xcodeversion $xcode_v
     
    422425                    }
    423426                }
    424             } else {
     427            } catch {*} {
    425428                ui_warn "xcodebuild exists but failed to execute"
    426429                set macports::xcodeversion none
     
    430433            set macports::xcodebuildcmd $xcodebuild
    431434        }
    432     } else {
     435    } catch {*} {
    433436        if {![info exists xcodeversion]} {
    434437            set macports::xcodeversion none
     
    447450
    448451    # Look for xcodeselect, and make sure it has a valid value
    449     if {![catch {findBinary xcode-select $macports::autoconf::xcode_select_path} xcodeselect]} {
     452    try -pass_signal {
     453        findBinary xcode-select $macports::autoconf::xcode_select_path
    450454
    451455        # We have xcode-select: ask it where xcode is and check if it's valid.
    452456        # If no xcode is selected, xcode-select will fail, so catch that
    453         if {![catch {exec $xcodeselect -print-path 2> /dev/null} devdir] &&
    454             [_is_valid_developer_dir $devdir]} {
    455             set macports::developer_dir $devdir
    456             return
    457         }
     457        try -pass_signal {
     458            set devdir [exec $xcodeselect -print-path 2> /dev/null]
     459            if {[_is_valid_developer_dir $devdir]} {
     460                set macports::developer_dir $devdir
     461                return
     462            }
     463        } catch {*} {}
    458464
    459465        # The directory from xcode-select isn't correct.
     
    462468        # searching by bundle identifier for various Xcode versions (3.x and 4.x)
    463469        set installed_xcodes {}
    464         if {![catch {findBinary mdfind $macports::autoconf::mdfind_path} mdfind]} {
     470
     471        try -pass_signal {
     472            findBinary mdfind $macports::autoconf::mdfind_path
    465473            set installed_xcodes [exec $mdfind "kMDItemCFBundleIdentifier == 'com.apple.Xcode' || kMDItemCFBundleIdentifier == 'com.apple.dt.Xcode'"]
    466         }
     474        } catch {*} {}
    467475
    468476        # In case mdfind metadata wasn't complete, also look in two well-known locations for Xcode.app
     
    478486        # Present instructions to the user
    479487        ui_error
    480         if {[llength $installed_xcodes] > 0 && ![catch {findBinary mdls $macports::autoconf::mdls_path} mdls]} {
     488        try -pass_signal {
     489            if {[llength $installed_xcodes] == 0} {
     490                error "No Xcode installation was found."
     491            }
     492
     493            findBinary mdls $macports::autoconf::mdls_path
     494
    481495            # One, or more than one, Xcode installations found
    482496            ui_error "No valid Xcode installation is properly selected."
     
    500514                }
    501515            }
    502         } else {
     516        } catch {*} {
    503517            ui_error "No Xcode installation was found."
    504518            ui_error "Please install Xcode and/or run xcode-select to specify its location."
    505519        }
    506520        ui_error
    507     }
     521    } catch {*} {}
    508522
    509523    # Try the default
     
    628642    set macosx_version {}
    629643    if {$os_platform eq "darwin" && [file executable /usr/bin/sw_vers]} {
    630         if {![catch {exec /usr/bin/sw_vers -productVersion | cut -f1,2 -d.} result]} {
    631             set macosx_version $result
    632         } else {
     644
     645        try -pass_signal {
     646            set macosx_version [exec /usr/bin/sw_vers -productVersion | cut -f1,2 -d.]
     647        } catch {*} {
    633648            ui_debug "sw_vers exists but running it failed: $result"
    634649        }
     
    10541069    # $portdbpath/.nohide.
    10551070    if {$os_platform eq "darwin" && [vercmp [info tclversion] 8.5] >= 0 && ![file exists [file join $portdbpath .nohide]] && [file writable $portdbpath] && [file attributes $portdbpath -hidden] == 0} {
    1056         if {[catch {file attributes $portdbpath -hidden yes} result]} {
    1057             ui_debug "error setting hidden flag for $portdbpath: $result"
     1071        try -pass_signal {
     1072            file attributes $portdbpath -hidden yes
     1073        } catch {{*} eCode eMessage} {
     1074            ui_debug "error setting hidden flag for $portdbpath: $eMessage"
    10581075        }
    10591076    }
     
    11601177
    11611178    # load cached ping times
    1162     if {[catch {
     1179    try -pass_signal {
     1180        set pingfile -1
    11631181        set pingfile [open ${macports::portdbpath}/pingtimes r]
    11641182        array set macports::ping_cache [gets $pingfile]
    1165         close $pingfile
    1166     }]} {array set macports::ping_cache {}}
     1183    } catch {*} {
     1184        array set macports::ping_cache {}
     1185    } finally {
     1186        if {$pingfile != -1} {
     1187            close $pingfile
     1188        }
     1189    }
    11671190    # set up arrays of blacklisted and preferred hosts
    11681191    if {[info exists macports::host_blacklist]} {
     
    12001223    if {$db_exists == 0 && [file exists ${registry.path}/receipts] && [file writable $db_path]} {
    12011224        ui_warn "Converting your registry to sqlite format, this might take a while..."
     1225        # XXX: catch, leave unfixed, code should go away.
    12021226        if {[catch {registry::convert_to_sqlite}]} {
    12031227            ui_debug $::errorInfo
     
    28702894            ui_warn "Can't open index file for source: $source"
    28712895        } else {
    2872             try {
     2896            try -pass_signal {
    28732897                seek $fd $offset
    28742898                gets $fd line
     
    28972921                lappend matches $name
    28982922                lappend matches $line
    2899                 close $fd
    2900                 set fd -1
    29012923            } catch * {
    29022924                ui_warn "It looks like your PortIndex file for $source may be corrupt."
    29032925            } finally {
    2904                 if {$fd != -1} {
    2905                     close $fd
    2906                 }
     2926                close $fd
    29072927            }
    29082928            if {[llength $matches] > 0} {
     
    29342954        set protocol [macports::getprotocol $source]
    29352955        if {![catch {set fd [open [macports::getindex $source] r]} result]} {
    2936             try {
     2956            try -pass_signal {
    29372957                incr found 1
    29382958                while {[gets $fd line] >= 0} {
     
    45514571                    incr i
    45524572
    4553                     if {0 != [catch {$f binary [fileIsBinary $fpath]} fileIsBinaryError]} {
    4554                         # handle errors (e.g. file not found, permission denied) gracefully
     4573                    try {
     4574                        $f binary [fileIsBinary $fpath]
     4575                    } catch {{POSIX SIG SIGINT} eCode eMessage} {
    45554576                        if {$fancy_output} {
    45564577                            $revupgrade_progress intermission
    45574578                        }
    4558                         ui_warn "Error determining file type of `$fpath': $fileIsBinaryError"
     4579                        ui_debug [msgcat::mc "Aborted: SIGINT signal received"]
     4580                        throw
     4581                    } catch {{POSIX SIG SIGTERM} eCode eMessage} {
     4582                        if {$fancy_output} {
     4583                            $revupgrade_progress intermission
     4584                        }
     4585                        ui_debug [msgcat::mc "Aborted: SIGTERM signal received"]
     4586                        throw
     4587                    } catch {{*} eCode eMessage} {
     4588                        if {$fancy_output} {
     4589                            $revupgrade_progress intermission
     4590                        }
     4591                        # handle errors (e.g. file not found, permission denied) gracefully
     4592                        ui_warn "Error determining file type of `$fpath': $eMessage"
    45594593                        ui_warn "A file belonging to the `[[registry::entry owner $fpath] name]' port is missing or unreadable. Consider reinstalling it."
    45604594                    }
     
    46254659                            # check if this lib's install name actually refers to this file itself
    46264660                            # if this is not the case software linking against this library might have erroneous load commands
    4627                             if {0 == [catch {set idloadcmdpath [revupgrade_handle_special_paths $bpath [$architecture cget -mat_install_name]]}]} {
     4661
     4662                            try {
     4663                                set idloadcmdpath [revupgrade_handle_special_paths $bpath [$architecture cget -mat_install_name]]
    46284664                                if {[string index $idloadcmdpath 0] ne "/"} {
    46294665                                    set port [registry::entry owner $bpath]
     
    46674703                                    }
    46684704                                }
    4669                             }
     4705                            } catch {{POSIX SIG SIGINT} eCode eMessage} {
     4706                                if {$fancy_output} {
     4707                                    $revupgrade_progress intermission
     4708                                }
     4709                                ui_debug [msgcat::mc "Aborted: SIGINT signal received"]
     4710                                throw
     4711                            } catch {{POSIX SIG SIGTERM} eCode eMessage} {
     4712                                if {$fancy_output} {
     4713                                    $revupgrade_progress intermission
     4714                                }
     4715                                ui_debug [msgcat::mc "Aborted: SIGTERM signal received"]
     4716                                throw
     4717                            } catch {*} {}
    46704718                        }
    46714719                    }
     
    46814729
    46824730                    while {$loadcommand ne "NULL"} {
    4683                         if {0 != [catch {set filepath [revupgrade_handle_special_paths $bpath [$loadcommand cget -mlt_install_name]]}]} {
     4731                        try {
     4732                            set filepath [revupgrade_handle_special_paths $bpath [$loadcommand cget -mlt_install_name]]
     4733                        } catch {{POSIX SIG SIGINT} eCode eMessage} {
     4734                            if {$fancy_output} {
     4735                                $revupgrade_progress intermission
     4736                            }
     4737                            ui_debug [msgcat::mc "Aborted: SIGINT signal received"]
     4738                            throw
     4739                        } catch {{POSIX SIG SIGTERM} eCode eMessage} {
     4740                            if {$fancy_output} {
     4741                                $revupgrade_progress intermission
     4742                            }
     4743                            ui_debug [msgcat::mc "Aborted: SIGTERM signal received"]
     4744                            throw
     4745                        } catch {*} {
    46844746                            set loadcommand [$loadcommand cget -next]
    46854747                            continue;
Note: See TracChangeset for help on using the changeset viewer.