<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[146674] trunk/base/src/macports1.0/macports.tcl</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="https://trac.macports.org/changeset/146674">146674</a></dd>
<dt>Author</dt> <dd>petr@macports.org</dd>
<dt>Date</dt> <dd>2016-03-15 05:27:00 -0700 (Tue, 15 Mar 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>base: avoid signals swallowing in try/catch for some occurences in macports.tcl</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbasesrcmacports10macportstcl">trunk/base/src/macports1.0/macports.tcl</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbasesrcmacports10macportstcl"></a>
<div class="modfile"><h4>Modified: trunk/base/src/macports1.0/macports.tcl (146673 => 146674)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/base/src/macports1.0/macports.tcl        2016-03-15 12:11:29 UTC (rev 146673)
+++ trunk/base/src/macports1.0/macports.tcl        2016-03-15 12:27:00 UTC (rev 146674)
</span><span class="lines">@@ -354,10 +354,11 @@
</span><span class="cx"> if {$autoconf_hint ne "" && [file executable $autoconf_hint]} {
</span><span class="cx"> return $autoconf_hint
</span><span class="cx"> } else {
</span><del>- if {[catch {set cmd_path [macports::binaryInPath $prog]} result] == 0} {
</del><ins>+ try -pass_signal {
+ set cmd_path [macports::binaryInPath $prog]
</ins><span class="cx"> return $cmd_path
</span><del>- } else {
- return -code error "$result or at its MacPorts configuration time location, did you move it?"
</del><ins>+ } catch {{*} eCode eMessage} {
+ error "$eMessage or at its MacPorts configuration time location, did you move it?"
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -387,11 +388,13 @@
</span><span class="cx"> trace remove variable macports::xcodeversion read macports::setxcodeinfo
</span><span class="cx"> trace remove variable macports::xcodebuildcmd read macports::setxcodeinfo
</span><span class="cx">
</span><del>- if {![catch {findBinary xcodebuild $macports::autoconf::xcodebuild_path} xcodebuild]} {
</del><ins>+ try -pass_signal {
+ findBinary xcodebuild $macports::autoconf::xcodebuild_path
</ins><span class="cx"> if {![info exists xcodeversion]} {
</span><span class="cx"> # Determine xcode version
</span><span class="cx"> set macports::xcodeversion 2.0orlower
</span><del>- if {[catch {set xcodebuildversion [exec -- $xcodebuild -version 2> /dev/null]}] == 0} {
</del><ins>+ try -pass_signal {
+ set xcodebuildversion [exec -- $xcodebuild -version 2> /dev/null]
</ins><span class="cx"> if {[regexp {Xcode ([0-9.]+)} $xcodebuildversion - xcode_v] == 1} {
</span><span class="cx"> set macports::xcodeversion $xcode_v
</span><span class="cx"> } elseif {[regexp {DevToolsCore-(.*);} $xcodebuildversion - devtoolscore_v] == 1} {
</span><span class="lines">@@ -421,7 +424,7 @@
</span><span class="cx"> set macports::xcodeversion 2.1
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>- } else {
</del><ins>+ } catch {*} {
</ins><span class="cx"> ui_warn "xcodebuild exists but failed to execute"
</span><span class="cx"> set macports::xcodeversion none
</span><span class="cx"> }
</span><span class="lines">@@ -429,7 +432,7 @@
</span><span class="cx"> if {![info exists xcodebuildcmd]} {
</span><span class="cx"> set macports::xcodebuildcmd $xcodebuild
</span><span class="cx"> }
</span><del>- } else {
</del><ins>+ } catch {*} {
</ins><span class="cx"> if {![info exists xcodeversion]} {
</span><span class="cx"> set macports::xcodeversion none
</span><span class="cx"> }
</span><span class="lines">@@ -446,24 +449,29 @@
</span><span class="cx"> trace remove variable macports::developer_dir read macports::set_developer_dir
</span><span class="cx">
</span><span class="cx"> # Look for xcodeselect, and make sure it has a valid value
</span><del>- if {![catch {findBinary xcode-select $macports::autoconf::xcode_select_path} xcodeselect]} {
</del><ins>+ try -pass_signal {
+ findBinary xcode-select $macports::autoconf::xcode_select_path
</ins><span class="cx">
</span><span class="cx"> # We have xcode-select: ask it where xcode is and check if it's valid.
</span><span class="cx"> # If no xcode is selected, xcode-select will fail, so catch that
</span><del>- if {![catch {exec $xcodeselect -print-path 2> /dev/null} devdir] &&
- [_is_valid_developer_dir $devdir]} {
- set macports::developer_dir $devdir
- return
- }
</del><ins>+ try -pass_signal {
+ set devdir [exec $xcodeselect -print-path 2> /dev/null]
+ if {[_is_valid_developer_dir $devdir]} {
+ set macports::developer_dir $devdir
+ return
+ }
+ } catch {*} {}
</ins><span class="cx">
</span><span class="cx"> # The directory from xcode-select isn't correct.
</span><span class="cx">
</span><span class="cx"> # Ask mdfind where Xcode is and make some suggestions for the user,
</span><span class="cx"> # searching by bundle identifier for various Xcode versions (3.x and 4.x)
</span><span class="cx"> set installed_xcodes {}
</span><del>- if {![catch {findBinary mdfind $macports::autoconf::mdfind_path} mdfind]} {
</del><ins>+
+ try -pass_signal {
+ findBinary mdfind $macports::autoconf::mdfind_path
</ins><span class="cx"> set installed_xcodes [exec $mdfind "kMDItemCFBundleIdentifier == 'com.apple.Xcode' || kMDItemCFBundleIdentifier == 'com.apple.dt.Xcode'"]
</span><del>- }
</del><ins>+ } catch {*} {}
</ins><span class="cx">
</span><span class="cx"> # In case mdfind metadata wasn't complete, also look in two well-known locations for Xcode.app
</span><span class="cx"> foreach app {/Applications/Xcode.app /Developer/Applications/Xcode.app} {
</span><span class="lines">@@ -477,7 +485,13 @@
</span><span class="cx">
</span><span class="cx"> # Present instructions to the user
</span><span class="cx"> ui_error
</span><del>- if {[llength $installed_xcodes] > 0 && ![catch {findBinary mdls $macports::autoconf::mdls_path} mdls]} {
</del><ins>+ try -pass_signal {
+ if {[llength $installed_xcodes] == 0} {
+ error "No Xcode installation was found."
+ }
+
+ findBinary mdls $macports::autoconf::mdls_path
+
</ins><span class="cx"> # One, or more than one, Xcode installations found
</span><span class="cx"> ui_error "No valid Xcode installation is properly selected."
</span><span class="cx"> ui_error "Please use xcode-select to select an Xcode installation:"
</span><span class="lines">@@ -499,12 +513,12 @@
</span><span class="cx"> ui_error " # malformed Xcode at ${xcode}, version $vers"
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>- } else {
</del><ins>+ } catch {*} {
</ins><span class="cx"> ui_error "No Xcode installation was found."
</span><span class="cx"> ui_error "Please install Xcode and/or run xcode-select to specify its location."
</span><span class="cx"> }
</span><span class="cx"> ui_error
</span><del>- }
</del><ins>+ } catch {*} {}
</ins><span class="cx">
</span><span class="cx"> # Try the default
</span><span class="cx"> if {$os_major >= 11 && [vercmp $xcodeversion 4.3] >= 0} {
</span><span class="lines">@@ -627,9 +641,10 @@
</span><span class="cx"> set os_endian [string range $tcl_platform(byteOrder) 0 end-6]
</span><span class="cx"> set macosx_version {}
</span><span class="cx"> if {$os_platform eq "darwin" && [file executable /usr/bin/sw_vers]} {
</span><del>- if {![catch {exec /usr/bin/sw_vers -productVersion | cut -f1,2 -d.} result]} {
- set macosx_version $result
- } else {
</del><ins>+
+ try -pass_signal {
+ set macosx_version [exec /usr/bin/sw_vers -productVersion | cut -f1,2 -d.]
+ } catch {*} {
</ins><span class="cx"> ui_debug "sw_vers exists but running it failed: $result"
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -1053,8 +1068,10 @@
</span><span class="cx"> # might slow builds down considerably. You can avoid this by touching
</span><span class="cx"> # $portdbpath/.nohide.
</span><span class="cx"> 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} {
</span><del>- if {[catch {file attributes $portdbpath -hidden yes} result]} {
- ui_debug "error setting hidden flag for $portdbpath: $result"
</del><ins>+ try -pass_signal {
+ file attributes $portdbpath -hidden yes
+ } catch {{*} eCode eMessage} {
+ ui_debug "error setting hidden flag for $portdbpath: $eMessage"
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1159,11 +1176,17 @@
</span><span class="cx"> set env(CCACHE_DIR) $macports::ccache_dir
</span><span class="cx">
</span><span class="cx"> # load cached ping times
</span><del>- if {[catch {
</del><ins>+ try -pass_signal {
+ set pingfile -1
</ins><span class="cx"> set pingfile [open ${macports::portdbpath}/pingtimes r]
</span><span class="cx"> array set macports::ping_cache [gets $pingfile]
</span><del>- close $pingfile
- }]} {array set macports::ping_cache {}}
</del><ins>+ } catch {*} {
+ array set macports::ping_cache {}
+ } finally {
+ if {$pingfile != -1} {
+ close $pingfile
+ }
+ }
</ins><span class="cx"> # set up arrays of blacklisted and preferred hosts
</span><span class="cx"> if {[info exists macports::host_blacklist]} {
</span><span class="cx"> foreach host $macports::host_blacklist {
</span><span class="lines">@@ -1199,6 +1222,7 @@
</span><span class="cx"> # convert any flat receipts if we just created a new db
</span><span class="cx"> if {$db_exists == 0 && [file exists ${registry.path}/receipts] && [file writable $db_path]} {
</span><span class="cx"> ui_warn "Converting your registry to sqlite format, this might take a while..."
</span><ins>+ # XXX: catch, leave unfixed, code should go away.
</ins><span class="cx"> if {[catch {registry::convert_to_sqlite}]} {
</span><span class="cx"> ui_debug $::errorInfo
</span><span class="cx"> file delete -force $db_path
</span><span class="lines">@@ -2869,7 +2893,7 @@
</span><span class="cx"> if {[catch {set fd [open [macports::getindex $source] r]} result]} {
</span><span class="cx"> ui_warn "Can't open index file for source: $source"
</span><span class="cx"> } else {
</span><del>- try {
</del><ins>+ try -pass_signal {
</ins><span class="cx"> seek $fd $offset
</span><span class="cx"> gets $fd line
</span><span class="cx"> set name [lindex $line 0]
</span><span class="lines">@@ -2896,14 +2920,10 @@
</span><span class="cx"> }
</span><span class="cx"> lappend matches $name
</span><span class="cx"> lappend matches $line
</span><del>- close $fd
- set fd -1
</del><span class="cx"> } catch * {
</span><span class="cx"> ui_warn "It looks like your PortIndex file for $source may be corrupt."
</span><span class="cx"> } finally {
</span><del>- if {$fd != -1} {
- close $fd
- }
</del><ins>+ close $fd
</ins><span class="cx"> }
</span><span class="cx"> if {[llength $matches] > 0} {
</span><span class="cx"> # if we have a match, exit. If we don't, continue with the next
</span><span class="lines">@@ -2933,7 +2953,7 @@
</span><span class="cx"> set source [lindex $source 0]
</span><span class="cx"> set protocol [macports::getprotocol $source]
</span><span class="cx"> if {![catch {set fd [open [macports::getindex $source] r]} result]} {
</span><del>- try {
</del><ins>+ try -pass_signal {
</ins><span class="cx"> incr found 1
</span><span class="cx"> while {[gets $fd line] >= 0} {
</span><span class="cx"> array unset portinfo
</span><span class="lines">@@ -4550,12 +4570,26 @@
</span><span class="cx"> ui_debug "Updating binary flag for file $i of ${files_count}: $fpath"
</span><span class="cx"> incr i
</span><span class="cx">
</span><del>- if {0 != [catch {$f binary [fileIsBinary $fpath]} fileIsBinaryError]} {
- # handle errors (e.g. file not found, permission denied) gracefully
</del><ins>+ try {
+ $f binary [fileIsBinary $fpath]
+ } catch {{POSIX SIG SIGINT} eCode eMessage} {
</ins><span class="cx"> if {$fancy_output} {
</span><span class="cx"> $revupgrade_progress intermission
</span><span class="cx"> }
</span><del>- ui_warn "Error determining file type of `$fpath': $fileIsBinaryError"
</del><ins>+ ui_debug [msgcat::mc "Aborted: SIGINT signal received"]
+ throw
+ } catch {{POSIX SIG SIGTERM} eCode eMessage} {
+ if {$fancy_output} {
+ $revupgrade_progress intermission
+ }
+ ui_debug [msgcat::mc "Aborted: SIGTERM signal received"]
+ throw
+ } catch {{*} eCode eMessage} {
+ if {$fancy_output} {
+ $revupgrade_progress intermission
+ }
+ # handle errors (e.g. file not found, permission denied) gracefully
+ ui_warn "Error determining file type of `$fpath': $eMessage"
</ins><span class="cx"> ui_warn "A file belonging to the `[[registry::entry owner $fpath] name]' port is missing or unreadable. Consider reinstalling it."
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -4624,7 +4658,9 @@
</span><span class="cx"> if {[$architecture cget -mat_install_name] ne "NULL" && [$architecture cget -mat_install_name] ne ""} {
</span><span class="cx"> # check if this lib's install name actually refers to this file itself
</span><span class="cx"> # if this is not the case software linking against this library might have erroneous load commands
</span><del>- if {0 == [catch {set idloadcmdpath [revupgrade_handle_special_paths $bpath [$architecture cget -mat_install_name]]}]} {
</del><ins>+
+ try {
+ set idloadcmdpath [revupgrade_handle_special_paths $bpath [$architecture cget -mat_install_name]]
</ins><span class="cx"> if {[string index $idloadcmdpath 0] ne "/"} {
</span><span class="cx"> set port [registry::entry owner $bpath]
</span><span class="cx"> if {$port ne ""} {
</span><span class="lines">@@ -4666,7 +4702,19 @@
</span><span class="cx"> ui_warn "This is probably a bug in the $portname port and might cause problems in libraries linking against this file"
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>- }
</del><ins>+ } catch {{POSIX SIG SIGINT} eCode eMessage} {
+ if {$fancy_output} {
+ $revupgrade_progress intermission
+ }
+ ui_debug [msgcat::mc "Aborted: SIGINT signal received"]
+ throw
+ } catch {{POSIX SIG SIGTERM} eCode eMessage} {
+ if {$fancy_output} {
+ $revupgrade_progress intermission
+ }
+ ui_debug [msgcat::mc "Aborted: SIGTERM signal received"]
+ throw
+ } catch {*} {}
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -4680,7 +4728,21 @@
</span><span class="cx"> set loadcommand [$architecture cget -mat_loadcmds]
</span><span class="cx">
</span><span class="cx"> while {$loadcommand ne "NULL"} {
</span><del>- if {0 != [catch {set filepath [revupgrade_handle_special_paths $bpath [$loadcommand cget -mlt_install_name]]}]} {
</del><ins>+ try {
+ set filepath [revupgrade_handle_special_paths $bpath [$loadcommand cget -mlt_install_name]]
+ } catch {{POSIX SIG SIGINT} eCode eMessage} {
+ if {$fancy_output} {
+ $revupgrade_progress intermission
+ }
+ ui_debug [msgcat::mc "Aborted: SIGINT signal received"]
+ throw
+ } catch {{POSIX SIG SIGTERM} eCode eMessage} {
+ if {$fancy_output} {
+ $revupgrade_progress intermission
+ }
+ ui_debug [msgcat::mc "Aborted: SIGTERM signal received"]
+ throw
+ } catch {*} {
</ins><span class="cx"> set loadcommand [$loadcommand cget -next]
</span><span class="cx"> continue;
</span><span class="cx"> }
</span></span></pre>
</div>
</div>
</body>
</html>