Fix execution environment and error reporting in ProcessJob.

This commit is contained in:
Teo Mrnjavac 2015-02-25 13:44:55 +01:00
parent 5b49521201
commit b8b41bdfdd

View File

@ -1,6 +1,6 @@
/* === This file is part of Calamares - <http://github.com/calamares> === /* === This file is part of Calamares - <http://github.com/calamares> ===
* *
* Copyright 2014, Teo Mrnjavac <teo@kde.org> * Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -48,7 +48,9 @@ QString
ProcessJob::prettyName() const ProcessJob::prettyName() const
{ {
//TODO: show something more meaningful //TODO: show something more meaningful
return tr( "Run command %1" ).arg( m_command ); return tr( "Run command %1 %2" )
.arg( m_command )
.arg( m_runInChroot ? "in chroot" : "" );
} }
@ -114,7 +116,8 @@ ProcessJob::callOutput( const QString& command,
output.clear(); output.clear();
QProcess process; QProcess process;
process.setProgram( command ); process.setProgram( "/bin/sh" );
process.setArguments( { "-c", command } );
process.setProcessChannelMode( QProcess::MergedChannels ); process.setProcessChannelMode( QProcess::MergedChannels );
if ( !workingPath.isEmpty() ) if ( !workingPath.isEmpty() )
@ -122,8 +125,10 @@ ProcessJob::callOutput( const QString& command,
if ( QDir( workingPath ).exists() ) if ( QDir( workingPath ).exists() )
process.setWorkingDirectory( QDir( workingPath ).absolutePath() ); process.setWorkingDirectory( QDir( workingPath ).absolutePath() );
else else
{
cLog() << "Invalid working directory:" << workingPath; cLog() << "Invalid working directory:" << workingPath;
return -3; return -3;
}
} }
cLog() << "Running" << command; cLog() << "Running" << command;