2014-07-10 17:11:03 +02:00
|
|
|
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
|
|
|
*
|
|
|
|
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
|
|
|
|
*
|
|
|
|
* Calamares is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Calamares is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ProcessJobModule.h"
|
|
|
|
|
|
|
|
#include "ProcessJob.h"
|
|
|
|
|
|
|
|
#include <QDir>
|
|
|
|
|
|
|
|
#include <yaml-cpp/yaml.h>
|
|
|
|
|
|
|
|
namespace Calamares {
|
|
|
|
|
|
|
|
|
|
|
|
Module::Type
|
|
|
|
ProcessJobModule::type() const
|
|
|
|
{
|
|
|
|
return Job;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Module::Interface
|
|
|
|
ProcessJobModule::interface() const
|
|
|
|
{
|
|
|
|
return Process;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ProcessJobModule::loadSelf()
|
|
|
|
{
|
2014-07-14 12:08:41 +02:00
|
|
|
if ( m_loaded )
|
|
|
|
return;
|
|
|
|
|
2014-07-22 16:54:34 +02:00
|
|
|
m_job = Calamares::job_ptr( new ProcessJob( m_command,
|
|
|
|
m_workingPath,
|
2014-08-12 14:26:10 +02:00
|
|
|
m_runInChroot,
|
2014-07-22 16:54:34 +02:00
|
|
|
m_secondsTimeout ) );
|
2014-07-14 12:08:41 +02:00
|
|
|
m_loaded = true;
|
2014-07-10 17:11:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-22 16:54:34 +02:00
|
|
|
QList< job_ptr >
|
|
|
|
ProcessJobModule::jobs() const
|
|
|
|
{
|
|
|
|
return QList< job_ptr >() << m_job;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-10 17:11:03 +02:00
|
|
|
void
|
|
|
|
ProcessJobModule::initFrom( const YAML::Node& node )
|
|
|
|
{
|
|
|
|
Module::initFrom( node );
|
|
|
|
QDir directory( location() );
|
|
|
|
m_workingPath = directory.absolutePath();
|
|
|
|
|
|
|
|
if ( node[ "command" ] )
|
|
|
|
{
|
|
|
|
m_command = QString::fromStdString( node[ "command" ].as< std::string >() );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_secondsTimeout = 30;
|
|
|
|
if ( node[ "timeout" ] )
|
|
|
|
{
|
|
|
|
m_secondsTimeout = node[ "timeout" ].as< int >();
|
|
|
|
}
|
2014-08-12 14:26:10 +02:00
|
|
|
|
|
|
|
m_runInChroot = false;
|
|
|
|
if ( node[ "chroot" ] )
|
|
|
|
{
|
|
|
|
m_runInChroot = node[ "chroot" ].as< bool >();
|
|
|
|
}
|
2014-07-10 17:11:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ProcessJobModule::ProcessJobModule()
|
|
|
|
: Module()
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
ProcessJobModule::~ProcessJobModule()
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Calamares
|