From 26e5500e33bc28d86a0d28d8f827e388904f9ab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20G=C3=A2teau?= Date: Fri, 1 Aug 2014 17:10:25 +0200 Subject: [PATCH] chrootCall: Log messages on failure, as well as command outputs --- .../utils/CalamaresUtilsSystem.cpp | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/libcalamares/utils/CalamaresUtilsSystem.cpp b/src/libcalamares/utils/CalamaresUtilsSystem.cpp index b2d9fcf9f..dc414c974 100644 --- a/src/libcalamares/utils/CalamaresUtilsSystem.cpp +++ b/src/libcalamares/utils/CalamaresUtilsSystem.cpp @@ -18,6 +18,7 @@ #include "CalamaresUtilsSystem.h" +#include "utils/Logger.h" #include "JobQueue.h" #include "GlobalStorage.h" @@ -61,11 +62,17 @@ int chrootCall( const QStringList& args, { Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); if ( !gs->contains( "rootMountPoint" ) ) + { + cLog() << "No rootMountPoint in global storage"; return -3; + } QString destDir = gs->value( "rootMountPoint" ).toString(); if ( !QDir( destDir ).exists() ) + { + cLog() << "rootMountPoint points to a dir which does not exist"; return -3; + } QString program( "chroot" ); QStringList arguments = { destDir }; @@ -74,10 +81,15 @@ int chrootCall( const QStringList& args, QProcess process; process.setProgram( program ); process.setArguments( arguments ); + process.setProcessChannelMode( QProcess::MergedChannels ); + cLog() << "Running" << program << arguments; process.start(); if ( !process.waitForStarted() ) + { + cLog() << "Process failed to start" << process.error(); return -2; + } if ( !stdInput.isEmpty() ) { @@ -86,11 +98,22 @@ int chrootCall( const QStringList& args, } if ( !process.waitForFinished( timeoutSec ? ( timeoutSec * 1000 ) : 30000 ) ) + { + cLog() << "Timed out. output so far:"; + cLog() << process.readAllStandardOutput(); return -4; + } + + cLog() << "Output:"; + cLog() << process.readAllStandardOutput(); if ( process.exitStatus() == QProcess::CrashExit ) + { + cLog() << "Process crashed"; return -1; + } + cLog() << "Finished. Exit code:" << process.exitCode(); return process.exitCode(); }