mirror of https://github.com/cutefishos/calamares
[contextualprocess] Stub of a contextual-process job
This is meant to run one or more jobs based on specific global configuration values; if could also be done by a Python module with just some if's, but this one can be used with just the config file and covers a bunch of use-cases.main
parent
762ad54344
commit
c6ab4195c7
@ -0,0 +1,9 @@
|
|||||||
|
calamares_add_plugin( contextualprocess
|
||||||
|
TYPE job
|
||||||
|
EXPORT_MACRO PLUGINDLLEXPORT_PRO
|
||||||
|
SOURCES
|
||||||
|
ContextualProcessJob.cpp
|
||||||
|
LINK_PRIVATE_LIBRARIES
|
||||||
|
calamares
|
||||||
|
SHARED_LIB
|
||||||
|
)
|
@ -0,0 +1,64 @@
|
|||||||
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
|
*
|
||||||
|
* Copyright 2017, Adriaan de Groot <groot@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 "ContextualProcessJob.h"
|
||||||
|
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
|
#include "CalamaresVersion.h"
|
||||||
|
#include "JobQueue.h"
|
||||||
|
#include "GlobalStorage.h"
|
||||||
|
|
||||||
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
|
ContextualProcessJob::ContextualProcessJob( QObject* parent )
|
||||||
|
: Calamares::CppJob( parent )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ContextualProcessJob::~ContextualProcessJob()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
ContextualProcessJob::prettyName() const
|
||||||
|
{
|
||||||
|
return tr( "Contextual Processes Job" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Calamares::JobResult
|
||||||
|
ContextualProcessJob::exec()
|
||||||
|
{
|
||||||
|
QThread::sleep( 3 );
|
||||||
|
|
||||||
|
return Calamares::JobResult::ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ContextualProcessJob::setConfigurationMap( const QVariantMap& configurationMap )
|
||||||
|
{
|
||||||
|
m_configurationMap = configurationMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
CALAMARES_PLUGIN_FACTORY_DEFINITION( ContextualProcessJobFactory, registerPlugin<ContextualProcessJob>(); )
|
@ -0,0 +1,51 @@
|
|||||||
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
|
*
|
||||||
|
* Copyright 2017, Adriaan de Groot <groot@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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONTEXTUALPROCESSJOB_H
|
||||||
|
#define CONTEXTUALPROCESSJOB_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QVariantMap>
|
||||||
|
|
||||||
|
#include <CppJob.h>
|
||||||
|
|
||||||
|
#include <utils/PluginFactory.h>
|
||||||
|
|
||||||
|
#include <PluginDllMacro.h>
|
||||||
|
|
||||||
|
class PLUGINDLLEXPORT ContextualProcessJob : public Calamares::CppJob
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ContextualProcessJob( QObject* parent = nullptr );
|
||||||
|
virtual ~ContextualProcessJob() override;
|
||||||
|
|
||||||
|
QString prettyName() const override;
|
||||||
|
|
||||||
|
Calamares::JobResult exec() override;
|
||||||
|
|
||||||
|
void setConfigurationMap( const QVariantMap& configurationMap ) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QVariantMap m_configurationMap;
|
||||||
|
};
|
||||||
|
|
||||||
|
CALAMARES_PLUGIN_FACTORY_DECLARATION( ContextualProcessJobFactory )
|
||||||
|
|
||||||
|
#endif // CONTEXTUALPROCESSJOB_H
|
@ -0,0 +1,19 @@
|
|||||||
|
# Configuration for the contextual process job.
|
||||||
|
#
|
||||||
|
# Contextual processes are based on **global** configuration values.
|
||||||
|
# When a given global value (string) equals a given value, then
|
||||||
|
# the associated command is executed.
|
||||||
|
#
|
||||||
|
# Configuration consists of keys for global variable names,
|
||||||
|
# and the sub-keys are strings to compare to the variable's value.
|
||||||
|
# If the variable has that particular value, the corresponding
|
||||||
|
# value is executed as a shell command in the target environment.
|
||||||
|
#
|
||||||
|
# If a command starts with "-" (a single minus sign), then the
|
||||||
|
# return value of the command following the - is ignored; otherwise,
|
||||||
|
# a failing command will abort the installation. This is much like
|
||||||
|
# make's use of - in a command.
|
||||||
|
---
|
||||||
|
firmwareType:
|
||||||
|
efi: "-pkg remove efi-firmware"
|
||||||
|
bios: "-pkg remove bios-firmware"
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
type: "job"
|
||||||
|
name: "contextualprocess"
|
||||||
|
interface: "qtplugin"
|
||||||
|
load: "libcalamares_job_contextualprocess.so"
|
Loading…
Reference in New Issue