[libcalamares] Implement the interface-specific fields for descriptor
This commit is contained in:
parent
c8b96c278b
commit
efd7145f76
@ -54,8 +54,6 @@ Descriptor::fromDescriptorData( const QVariantMap& moduleDesc )
|
|||||||
{
|
{
|
||||||
Descriptor d;
|
Descriptor d;
|
||||||
|
|
||||||
cDebug() << moduleDesc;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
bool typeOk = false;
|
bool typeOk = false;
|
||||||
QString typeValue = moduleDesc.value( "type" ).toString();
|
QString typeValue = moduleDesc.value( "type" ).toString();
|
||||||
@ -92,6 +90,32 @@ Descriptor::fromDescriptorData( const QVariantMap& moduleDesc )
|
|||||||
|
|
||||||
QStringList consumedKeys { "type", "interface", "name", "emergency", "noconfig", "requiredModules" };
|
QStringList consumedKeys { "type", "interface", "name", "emergency", "noconfig", "requiredModules" };
|
||||||
|
|
||||||
|
switch ( d.interface() )
|
||||||
|
{
|
||||||
|
case Interface::QtPlugin:
|
||||||
|
d.m_script = CalamaresUtils::getString( moduleDesc, "load" );
|
||||||
|
consumedKeys << "load";
|
||||||
|
break;
|
||||||
|
case Interface::Python:
|
||||||
|
case Interface::PythonQt:
|
||||||
|
d.m_script = CalamaresUtils::getString( moduleDesc, "script" );
|
||||||
|
consumedKeys << "script";
|
||||||
|
break;
|
||||||
|
case Interface::Process:
|
||||||
|
d.m_script = CalamaresUtils::getString( moduleDesc, "command" );
|
||||||
|
d.m_processTimeout = CalamaresUtils::getInteger( moduleDesc, "timeout", 30 );
|
||||||
|
d.m_processChroot = CalamaresUtils::getBool( moduleDesc, "chroot", false );
|
||||||
|
consumedKeys << "command"
|
||||||
|
<< "timeout"
|
||||||
|
<< "chroot";
|
||||||
|
|
||||||
|
if ( d.m_processTimeout < 0 )
|
||||||
|
{
|
||||||
|
d.m_processTimeout = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
QStringList superfluousKeys;
|
QStringList superfluousKeys;
|
||||||
for ( auto kv = moduleDesc.keyBegin(); kv != moduleDesc.keyEnd(); ++kv )
|
for ( auto kv = moduleDesc.keyBegin(); kv != moduleDesc.keyEnd(); ++kv )
|
||||||
{
|
{
|
||||||
|
@ -95,7 +95,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/// @brief Short path to the shared-library; no extension.
|
/// @brief Short path to the shared-library; no extension.
|
||||||
QString load() const { return QString(); }
|
QString load() const { return m_interface == Interface::QtPlugin ? m_script : QString(); }
|
||||||
|
|
||||||
/** @section Process Job modules
|
/** @section Process Job modules
|
||||||
*
|
*
|
||||||
@ -106,17 +106,20 @@ public:
|
|||||||
* Process Jobs execute one command.
|
* Process Jobs execute one command.
|
||||||
*/
|
*/
|
||||||
/// @brief The command to execute; passed to the shell
|
/// @brief The command to execute; passed to the shell
|
||||||
QString command() const { return QString(); }
|
QString command() const { return m_interface == Interface::Process ? m_script : QString(); }
|
||||||
/// @brief Timeout in seconds
|
/// @brief Timeout in seconds
|
||||||
int timeout() const { return 30; }
|
int timeout() const { return m_processTimeout; }
|
||||||
/// @brief Run command in chroot?
|
/// @brief Run command in chroot?
|
||||||
bool chroot() const { return false; }
|
bool chroot() const { return m_processChroot; }
|
||||||
|
|
||||||
/** @section Python Job modules
|
/** @section Python Job modules
|
||||||
*
|
*
|
||||||
* Python job modules have one specific script to load and run.
|
* Python job modules have one specific script to load and run.
|
||||||
*/
|
*/
|
||||||
QString script() const { return QString(); }
|
QString script() const
|
||||||
|
{
|
||||||
|
return ( m_interface == Interface::Python || m_interface == Interface::PythonQt ) ? m_script : QString();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_name;
|
QString m_name;
|
||||||
@ -127,6 +130,20 @@ private:
|
|||||||
bool m_isValid = false;
|
bool m_isValid = false;
|
||||||
bool m_isEmergeny = false;
|
bool m_isEmergeny = false;
|
||||||
bool m_hasConfig = true;
|
bool m_hasConfig = true;
|
||||||
|
|
||||||
|
/** @brief The name of the thing to load
|
||||||
|
*
|
||||||
|
* - A C++ module loads a shared library (via key *load*),
|
||||||
|
* - A Python module loads a Python script (via key *script*),
|
||||||
|
* - A process runs a specific command (via key *command*)
|
||||||
|
*
|
||||||
|
* This name-of-the-thing is stored here, regardless of which
|
||||||
|
* interface is being used.
|
||||||
|
*/
|
||||||
|
QString m_script;
|
||||||
|
|
||||||
|
int m_processTimeout = 30;
|
||||||
|
bool m_processChroot = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ModuleSystem
|
} // namespace ModuleSystem
|
||||||
|
Loading…
Reference in New Issue
Block a user