[90355] trunk/base/src
raimue at macports.org
raimue at macports.org
Sat Mar 3 04:15:19 PST 2012
Revision: 90355
http://trac.macports.org/changeset/90355
Author: raimue at macports.org
Date: 2012-03-03 04:15:14 -0800 (Sat, 03 Mar 2012)
Log Message:
-----------
Try to improve error messages by making more clear which port failed.
Passing error codes to the calling proc allows a more verbose log file.
Modified Paths:
--------------
trunk/base/src/macports1.0/macports.tcl
trunk/base/src/pextlib1.0/system.c
trunk/base/src/port/port.tcl
trunk/base/src/port1.0/portutil.tcl
Modified: trunk/base/src/macports1.0/macports.tcl
===================================================================
--- trunk/base/src/macports1.0/macports.tcl 2012-03-03 11:01:20 UTC (rev 90354)
+++ trunk/base/src/macports1.0/macports.tcl 2012-03-03 12:15:14 UTC (rev 90355)
@@ -1863,7 +1863,7 @@
ui_error "Failed to install $portname"
ui_debug "$::errorInfo"
if {[info exists ::logenabled] && $::logenabled && [info exists ::debuglogname]} {
- ui_notice "Log for $portname is at: $::debuglogname"
+ ui_notice "Please see the log file for $portname for details:\n $::debuglogname"
}
macports::pop_log
return 1
@@ -1989,7 +1989,7 @@
global ::logenabled ::debuglogname
if {[info exists ::logenabled] && $::logenabled && [info exists ::debuglogname]} {
if {$result != 0} {
- ui_notice "Log for $portname is at: $::debuglogname"
+ ui_notice "Please see the log file for port $portname for details:\n $::debuglogname"
}
macports::pop_log
}
Modified: trunk/base/src/pextlib1.0/system.c
===================================================================
--- trunk/base/src/pextlib1.0/system.c 2012-03-03 11:01:20 UTC (rev 90354)
+++ trunk/base/src/pextlib1.0/system.c 2012-03-03 12:15:14 UTC (rev 90355)
@@ -251,6 +251,19 @@
} else {
char *errorstr;
size_t errorstrlen;
+
+ /* print error */
+ /* get buffer large enough for additional message or the error code */
+ errorstrlen = strlen(cmdstring) + strlen("Command failed: ") + 12;
+ errorstr = malloc(errorstrlen);
+ if (errorstr) {
+ snprintf(errorstr, errorstrlen, "Command failed: %s", cmdstring);
+ ui_info(interp, errorstr);
+ snprintf(errorstr, errorstrlen, "Exit code: %d", WEXITSTATUS(ret));
+ ui_info(interp, errorstr);
+ free(errorstr);
+ }
+
/* set errorCode [list CHILDSTATUS <pid> <code>] */
Tcl_Obj* errorCode = Tcl_NewListObj(0, NULL);
Tcl_ListObjAppendElement(interp, errorCode, Tcl_NewStringObj("CHILDSTATUS", -1));
@@ -258,16 +271,7 @@
Tcl_ListObjAppendElement(interp, errorCode, Tcl_NewIntObj(WEXITSTATUS(ret)));
Tcl_SetObjErrorCode(interp, errorCode);
- /* print error */
- errorstrlen = strlen("shell command \"")+strlen(cmdstring)+strlen("\" returned error ")+12;
- errorstr = malloc(errorstrlen);
- if (errorstr) {
- *errorstr = '\0';
- snprintf(errorstr, errorstrlen, "%s%s%s%d", "shell command \"", cmdstring, "\" returned error ", WEXITSTATUS(ret));
- ui_info(interp, errorstr);
- free(errorstr);
- }
- Tcl_SetObjResult(interp, Tcl_NewStringObj("shell command failed (see log for details)", -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("command execution failed", -1));
}
}
Modified: trunk/base/src/port/port.tcl
===================================================================
--- trunk/base/src/port/port.tcl 2012-03-03 11:01:20 UTC (rev 90354)
+++ trunk/base/src/port/port.tcl 2012-03-03 12:15:14 UTC (rev 90355)
@@ -237,7 +237,7 @@
# show the URL for the ticket reporting instructions
proc print_tickets_url {args} {
if {${macports::prefix} != "/usr/local" && ${macports::prefix} != "/usr"} {
- ui_notice "To report a bug, see <http://guide.macports.org/#project.tickets>"
+ ui_notice "To report a bug, follow the instructions in the guide:\n http://guide.macports.org/#project.tickets"
}
}
@@ -3925,13 +3925,12 @@
# Process any error that wasn't thrown and handled already
if {$result} {
- break_softcontinue "Status $result encountered during processing." 1 status
+ print_tickets_url
+ break_softcontinue "Processing of port $portname failed" 1 status
}
}
- if {$status != 0} {
- print_tickets_url
- } elseif {$action == "install"} {
+ if {$status == 0 && $action == "install"} {
array set options $opts
if {![info exists options(ports_nodeps)] && ![info exists options(ports_install_no-rev-upgrade)] && ${macports::revupgrade_autorun}} {
set status [action_revupgrade $action $portlist $opts]
Modified: trunk/base/src/port1.0/portutil.tcl
===================================================================
--- trunk/base/src/port1.0/portutil.tcl 2012-03-03 11:01:20 UTC (rev 90354)
+++ trunk/base/src/port1.0/portutil.tcl 2012-03-03 12:15:14 UTC (rev 90355)
@@ -433,6 +433,9 @@
set fullcmdstring "$command_prefix $cmdstring $command_suffix"
ui_debug "Executing command line: $fullcmdstring"
set code [catch {eval system $notty $nice \$fullcmdstring} result]
+ # Save variables in order to re-throw the same error code.
+ set errcode $::errorCode
+ set errinfo $::errorInfo
# Unset the command array until next time.
array unset ${varprefix}.env_array
@@ -445,7 +448,7 @@
array set env [array get saved_env]
# Return as if system had been called directly.
- return -code $code $result
+ return -code $code -errorcode $errcode -errorInfo $errinfo $result
}
# default
@@ -1324,6 +1327,9 @@
if {[ditem_contains $ditem init]} {
set result [catch {[ditem_key $ditem init] $targetname} errstr]
+ # Save variables in order to re-throw the same error code.
+ set errcode $::errorCode
+ set errinfo $::errorInfo
}
if {$result == 0} {
@@ -1355,6 +1361,9 @@
# Execute pre-run procedure
if {[ditem_contains $ditem prerun]} {
set result [catch {[ditem_key $ditem prerun] $targetname} errstr]
+ # Save variables in order to re-throw the same error code.
+ set errcode $::errorCode
+ set errinfo $::errorInfo
}
#start tracelib
@@ -1428,19 +1437,28 @@
foreach pre [ditem_key $ditem pre] {
ui_debug "Executing $pre"
set result [catch {$pre $targetname} errstr]
+ # Save variables in order to re-throw the same error code.
+ set errcode $::errorCode
+ set errinfo $::errorInfo
if {$result != 0} { break }
}
}
if {$result == 0} {
- ui_debug "Executing $targetname ($portname)"
- set result [catch {$procedure $targetname} errstr]
+ ui_debug "Executing $targetname ($portname)"
+ set result [catch {$procedure $targetname} errstr]
+ # Save variables in order to re-throw the same error code.
+ set errcode $::errorCode
+ set errinfo $::errorInfo
}
if {$result == 0} {
foreach post [ditem_key $ditem post] {
ui_debug "Executing $post"
set result [catch {$post $targetname} errstr]
+ # Save variables in order to re-throw the same error code.
+ set errcode $::errorCode
+ set errinfo $::errorInfo
if {$result != 0} { break }
}
}
@@ -1449,6 +1467,9 @@
set postrun [ditem_key $ditem postrun]
ui_debug "Executing $postrun"
set result [catch {$postrun $targetname} errstr]
+ # Save variables in order to re-throw the same error code.
+ set errcode $::errorCode
+ set errinfo $::errorInfo
}
# Check dependencies & file creations outside workpath.
@@ -1488,9 +1509,9 @@
write_statefile target $targetname $target_state_fd
}
} else {
- global errorInfo
- ui_error "Target $targetname returned: $errstr"
- ui_debug "Backtrace: $errorInfo"
+ ui_error "$targetname for port $portname returned: $errstr"
+ ui_debug "Error code: $errcode"
+ ui_debug "Backtrace: $errinfo"
set result 1
}
@@ -1594,7 +1615,7 @@
if {[llength $dlist] > 0} {
# somebody broke!
- set errstring "Warning: the following items did not execute (for $subport):"
+ set errstring "Warning: targets not executed for $subport:"
foreach ditem $dlist {
append errstring " [ditem_key $ditem name]"
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20120303/89934a86/attachment-0001.html>
More information about the macports-changes
mailing list