From fc973602e59ebebfbd532d1af6804d926f91082f Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Mon, 17 May 2010 01:13:26 +0200 Subject: [PATCH] Correctly propagate failing hooks back to xen-create-image --- bin/xen-create-image | 8 ++++++-- bin/xt-customize-image | 12 ++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/bin/xen-create-image b/bin/xen-create-image index 053bd2e..d6ea55c 100755 --- a/bin/xen-create-image +++ b/bin/xen-create-image @@ -3706,20 +3706,24 @@ sub runCommand # # Copy stderr to stdout, so we can see it, and make sure we log it. # - $cmd .= " 2>&1 | tee --append /var/log/xen-tools/$CONFIG{'hostname'}.log"; + $cmd .= " 2>&1"; # # Run it. # my $output = `$cmd`; + my $rc = $?; + logprint($output); $CONFIG{ 'verbose' } && print "Finished : $cmd\n"; - if ( $? != 0 ) + if ( $rc != 0 ) { logprint("Running command '$cmd' failed.\n"); logprint("Aborting\n"); + print "Running command '$cmd' failed.\n"; + print "See /var/log/xen-tools/$CONFIG{'hostname'}.log for details\n"; $FAIL = 1; exit 127; } diff --git a/bin/xt-customize-image b/bin/xt-customize-image index 573fef6..623a7ee 100755 --- a/bin/xt-customize-image +++ b/bin/xt-customize-image @@ -320,14 +320,22 @@ sub runDistributionHooks { print "Running hook $name ['$cmd']\n"; print "--\n"; - system($cmd ); + my $rc = system($cmd); + if ($rc != 0) { + print "hook $name failed: $?\n"; + exit 1; + } print "--\n"; print "Done\n\n"; } else { print "Running hook $name\n"; - system($cmd ); + my $rc = system($cmd); + if ($rc != 0) { + print "hook $name failed: $?\n"; + exit 1; + } print "hook $name: done.\n"; } }