[libcalamares] Add a module-weight to the module descriptor
This commit is contained in:
parent
14875259c7
commit
c19866f887
@ -41,6 +41,7 @@
|
|||||||
# [NO_CONFIG]
|
# [NO_CONFIG]
|
||||||
# [SHARED_LIB]
|
# [SHARED_LIB]
|
||||||
# [EMERGENCY]
|
# [EMERGENCY]
|
||||||
|
# [WEIGHT w]
|
||||||
# )
|
# )
|
||||||
#
|
#
|
||||||
# Function parameters:
|
# Function parameters:
|
||||||
@ -63,6 +64,9 @@
|
|||||||
# - EMERGENCY
|
# - EMERGENCY
|
||||||
# If this is set, the module is marked as an *emergency* module in the
|
# If this is set, the module is marked as an *emergency* module in the
|
||||||
# descriptor. See *Emergency Modules* in the module documentation.
|
# descriptor. See *Emergency Modules* in the module documentation.
|
||||||
|
# - WEIGHT
|
||||||
|
# If this is set, writes an explicit weight into the module.desc;
|
||||||
|
# module weights are used in progress reporting.
|
||||||
#
|
#
|
||||||
|
|
||||||
include( CMakeParseArguments )
|
include( CMakeParseArguments )
|
||||||
@ -73,7 +77,7 @@ function( calamares_add_plugin )
|
|||||||
# parse arguments ( name needs to be saved before passing ARGN into the macro )
|
# parse arguments ( name needs to be saved before passing ARGN into the macro )
|
||||||
set( NAME ${ARGV0} )
|
set( NAME ${ARGV0} )
|
||||||
set( options NO_CONFIG NO_INSTALL SHARED_LIB EMERGENCY )
|
set( options NO_CONFIG NO_INSTALL SHARED_LIB EMERGENCY )
|
||||||
set( oneValueArgs NAME TYPE EXPORT_MACRO RESOURCES )
|
set( oneValueArgs NAME TYPE EXPORT_MACRO RESOURCES WEIGHT )
|
||||||
set( multiValueArgs SOURCES UI LINK_LIBRARIES LINK_PRIVATE_LIBRARIES COMPILE_DEFINITIONS REQUIRES )
|
set( multiValueArgs SOURCES UI LINK_LIBRARIES LINK_PRIVATE_LIBRARIES COMPILE_DEFINITIONS REQUIRES )
|
||||||
cmake_parse_arguments( PLUGIN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
|
cmake_parse_arguments( PLUGIN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
|
||||||
set( PLUGIN_NAME ${NAME} )
|
set( PLUGIN_NAME ${NAME} )
|
||||||
@ -181,6 +185,9 @@ function( calamares_add_plugin )
|
|||||||
if ( PLUGIN_NO_CONFIG )
|
if ( PLUGIN_NO_CONFIG )
|
||||||
file( APPEND ${_file} "noconfig: true\n" )
|
file( APPEND ${_file} "noconfig: true\n" )
|
||||||
endif()
|
endif()
|
||||||
|
if ( PLUGIN_WEIGHT )
|
||||||
|
file( APPEND ${_file} "weight: ${PLUGIN_WEIGHT}\n" )
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if ( NOT PLUGIN_NO_INSTALL )
|
if ( NOT PLUGIN_NO_INSTALL )
|
||||||
|
@ -87,8 +87,9 @@ Descriptor::fromDescriptorData( const QVariantMap& moduleDesc )
|
|||||||
d.m_isEmergeny = CalamaresUtils::getBool( moduleDesc, "emergency", false );
|
d.m_isEmergeny = CalamaresUtils::getBool( moduleDesc, "emergency", false );
|
||||||
d.m_hasConfig = !CalamaresUtils::getBool( moduleDesc, "noconfig", false ); // Inverted logic during load
|
d.m_hasConfig = !CalamaresUtils::getBool( moduleDesc, "noconfig", false ); // Inverted logic during load
|
||||||
d.m_requiredModules = CalamaresUtils::getStringList( moduleDesc, "requiredModules" );
|
d.m_requiredModules = CalamaresUtils::getStringList( moduleDesc, "requiredModules" );
|
||||||
|
d.m_weight = int( CalamaresUtils::getInteger( moduleDesc, "weight", -1 ) );
|
||||||
|
|
||||||
QStringList consumedKeys { "type", "interface", "name", "emergency", "noconfig", "requiredModules" };
|
QStringList consumedKeys { "type", "interface", "name", "emergency", "noconfig", "requiredModules", "weight" };
|
||||||
|
|
||||||
switch ( d.interface() )
|
switch ( d.interface() )
|
||||||
{
|
{
|
||||||
@ -99,23 +100,37 @@ Descriptor::fromDescriptorData( const QVariantMap& moduleDesc )
|
|||||||
case Interface::Python:
|
case Interface::Python:
|
||||||
case Interface::PythonQt:
|
case Interface::PythonQt:
|
||||||
d.m_script = CalamaresUtils::getString( moduleDesc, "script" );
|
d.m_script = CalamaresUtils::getString( moduleDesc, "script" );
|
||||||
|
if ( d.m_script.isEmpty() )
|
||||||
|
{
|
||||||
|
cWarning() << "Module descriptor contains no *script*" << d.name();
|
||||||
|
d.m_isValid = false;
|
||||||
|
}
|
||||||
consumedKeys << "script";
|
consumedKeys << "script";
|
||||||
break;
|
break;
|
||||||
case Interface::Process:
|
case Interface::Process:
|
||||||
d.m_script = CalamaresUtils::getString( moduleDesc, "command" );
|
d.m_script = CalamaresUtils::getString( moduleDesc, "command" );
|
||||||
d.m_processTimeout = CalamaresUtils::getInteger( moduleDesc, "timeout", 30 );
|
d.m_processTimeout = int( CalamaresUtils::getInteger( moduleDesc, "timeout", 30 ) );
|
||||||
d.m_processChroot = CalamaresUtils::getBool( moduleDesc, "chroot", false );
|
d.m_processChroot = CalamaresUtils::getBool( moduleDesc, "chroot", false );
|
||||||
consumedKeys << "command"
|
|
||||||
<< "timeout"
|
|
||||||
<< "chroot";
|
|
||||||
|
|
||||||
if ( d.m_processTimeout < 0 )
|
if ( d.m_processTimeout < 0 )
|
||||||
{
|
{
|
||||||
d.m_processTimeout = 0;
|
d.m_processTimeout = 0;
|
||||||
}
|
}
|
||||||
|
if ( d.m_script.isEmpty() )
|
||||||
|
{
|
||||||
|
cWarning() << "Module descriptor contains no *script*" << d.name();
|
||||||
|
d.m_isValid = false;
|
||||||
|
}
|
||||||
|
consumedKeys << "command"
|
||||||
|
<< "timeout"
|
||||||
|
<< "chroot";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !d.m_isValid )
|
||||||
|
{
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
QStringList superfluousKeys;
|
QStringList superfluousKeys;
|
||||||
for ( auto kv = moduleDesc.keyBegin(); kv != moduleDesc.keyEnd(); ++kv )
|
for ( auto kv = moduleDesc.keyBegin(); kv != moduleDesc.keyEnd(); ++kv )
|
||||||
{
|
{
|
||||||
|
@ -80,6 +80,9 @@ public:
|
|||||||
|
|
||||||
bool isEmergency() const { return m_isEmergeny; }
|
bool isEmergency() const { return m_isEmergeny; }
|
||||||
bool hasConfig() const { return m_hasConfig; }
|
bool hasConfig() const { return m_hasConfig; }
|
||||||
|
int weight() const { return m_weight < 1 ? 1 : m_weight; }
|
||||||
|
bool explicitWeight() const { return m_weight > 0; }
|
||||||
|
|
||||||
|
|
||||||
/// @brief The directory where the module.desc lives
|
/// @brief The directory where the module.desc lives
|
||||||
QString directory() const { return m_directory; }
|
QString directory() const { return m_directory; }
|
||||||
@ -125,6 +128,7 @@ private:
|
|||||||
QString m_name;
|
QString m_name;
|
||||||
QString m_directory;
|
QString m_directory;
|
||||||
QStringList m_requiredModules;
|
QStringList m_requiredModules;
|
||||||
|
int m_weight = -1;
|
||||||
Type m_type;
|
Type m_type;
|
||||||
Interface m_interface;
|
Interface m_interface;
|
||||||
bool m_isValid = false;
|
bool m_isValid = false;
|
||||||
|
@ -46,9 +46,19 @@ Module descriptors **must** have the following keys:
|
|||||||
- *interface* (see below for the different interfaces; generally we
|
- *interface* (see below for the different interfaces; generally we
|
||||||
refer to the kinds of modules by their interface)
|
refer to the kinds of modules by their interface)
|
||||||
|
|
||||||
|
Module descriptors for C++ modules **may** have the following key:
|
||||||
|
- *load* (the name of the shared library to load; if empty, uses a
|
||||||
|
standard library name derived from the module name)
|
||||||
|
|
||||||
Module descriptors for Python modules **must** have the following key:
|
Module descriptors for Python modules **must** have the following key:
|
||||||
- *script* (the name of the Python script to load, nearly always `main.py`)
|
- *script* (the name of the Python script to load, nearly always `main.py`)
|
||||||
|
|
||||||
|
Module descriptors for process modules **must** have the following key:
|
||||||
|
- *command* (the command to run)
|
||||||
|
Module descriptors for process modules **may** have the following keys:
|
||||||
|
- *timeout* (how long, in seconds, to wait for the command to run)
|
||||||
|
- *chroos* (if true, run the command in the target system rather than the host)
|
||||||
|
|
||||||
Module descriptors **may** have the following keys:
|
Module descriptors **may** have the following keys:
|
||||||
- *emergency* (a boolean value, set to true to mark the module
|
- *emergency* (a boolean value, set to true to mark the module
|
||||||
as an emergency module)
|
as an emergency module)
|
||||||
@ -56,6 +66,8 @@ Module descriptors **may** have the following keys:
|
|||||||
has no configuration file; defaults to false)
|
has no configuration file; defaults to false)
|
||||||
- *requiredModules* (a list of modules which are required for this module
|
- *requiredModules* (a list of modules which are required for this module
|
||||||
to operate properly)
|
to operate properly)
|
||||||
|
- *weight* (a relative module weight, used to scale progress reporting)
|
||||||
|
|
||||||
|
|
||||||
### Required Modules
|
### Required Modules
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user