[libcalamares] runCommand doesn't need queue or settings

- JobQueue is only needed to get global settings, which are needed
   when running in the target; for host commands, allow running
   without a queue.
 - Settings is needed for the value of debugsettings; assume if
   there's no settings object, that we're in a test and should
   print debugging information.
This commit is contained in:
Adriaan de Groot 2019-06-07 15:53:27 +02:00
parent 5a835f32b8
commit 7be33b8196

View File

@ -156,13 +156,8 @@ System::runCommand(
{
QString output;
if ( !Calamares::JobQueue::instance() )
{
cError() << "No JobQueue";
return ProcessResult::Code::NoWorkingDirectory;
}
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance() ? Calamares::JobQueue::instance()->globalStorage() : nullptr;
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
if ( ( location == System::RunLocation::RunInTarget ) &&
( !gs || !gs->contains( "rootMountPoint" ) ) )
{
@ -239,7 +234,8 @@ System::runCommand(
auto r = process.exitCode();
cDebug() << "Finished. Exit code:" << r;
if ( ( r != 0 ) || Calamares::Settings::instance()->debugMode() )
bool showDebug = ( !Calamares::Settings::instance() ) || ( Calamares::Settings::instance()->debugMode() );
if ( ( r != 0 ) || showDebug )
{
cDebug() << "Target cmd:" << RedactedList( args );
cDebug().noquote().nospace() << "Target output:\n" << output;