From a7e1a1f9fcd003fc0e4afbe7d3eb61d6aaeb31f0 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 12 Jan 2020 11:37:22 +0100 Subject: [PATCH 01/22] [libcalamaresui] Refactor Module::initFrom() - generic initFrom() also sets the instance id - subclass-specific initFrom() now pure virtual in base - chase changes in subclasses --- .../modulesystem/CppJobModule.cpp | 1 - src/libcalamaresui/modulesystem/Module.cpp | 35 +++++++++---------- src/libcalamaresui/modulesystem/Module.h | 7 +++- .../modulesystem/ProcessJobModule.cpp | 1 - .../modulesystem/PythonJobModule.cpp | 1 - .../modulesystem/PythonQtViewModule.cpp | 1 - .../modulesystem/ViewModule.cpp | 1 - 7 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/libcalamaresui/modulesystem/CppJobModule.cpp b/src/libcalamaresui/modulesystem/CppJobModule.cpp index c6571dbf6..2eddeda86 100644 --- a/src/libcalamaresui/modulesystem/CppJobModule.cpp +++ b/src/libcalamaresui/modulesystem/CppJobModule.cpp @@ -86,7 +86,6 @@ CppJobModule::jobs() const void CppJobModule::initFrom( const QVariantMap& moduleDescriptor ) { - Module::initFrom( moduleDescriptor ); QDir directory( location() ); QString load; if ( !moduleDescriptor.value( "load" ).toString().isEmpty() ) diff --git a/src/libcalamaresui/modulesystem/Module.cpp b/src/libcalamaresui/modulesystem/Module.cpp index 799da941e..4bc759cb1 100644 --- a/src/libcalamaresui/modulesystem/Module.cpp +++ b/src/libcalamaresui/modulesystem/Module.cpp @@ -48,8 +48,24 @@ static const char EMERGENCY[] = "emergency"; namespace Calamares { +Module::Module() + : m_loaded( false ) +{ +} + Module::~Module() {} +void +Module::initFrom( const QVariantMap& moduleDescriptor, const QString& id ) +{ + m_name = moduleDescriptor.value( "name" ).toString(); + m_instanceId = id; + if ( moduleDescriptor.contains( EMERGENCY ) ) + { + m_maybe_emergency = moduleDescriptor[ EMERGENCY ].toBool(); + } +} + Module* Module::fromDescriptor( const QVariantMap& moduleDescriptor, const QString& instanceId, @@ -131,8 +147,7 @@ Module::fromDescriptor( const QVariantMap& moduleDescriptor, return nullptr; } - m->m_instanceId = instanceId; - + m->initFrom( moduleDescriptor, instanceId ); m->initFrom( moduleDescriptor ); try { @@ -290,22 +305,6 @@ Module::configurationMap() } -Module::Module() - : m_loaded( false ) -{ -} - - -void -Module::initFrom( const QVariantMap& moduleDescriptor ) -{ - m_name = moduleDescriptor.value( "name" ).toString(); - if ( moduleDescriptor.contains( EMERGENCY ) ) - { - m_maybe_emergency = moduleDescriptor[ EMERGENCY ].toBool(); - } -} - RequirementsList Module::checkRequirements() { diff --git a/src/libcalamaresui/modulesystem/Module.h b/src/libcalamaresui/modulesystem/Module.h index e4101b767..03eb09cb0 100644 --- a/src/libcalamaresui/modulesystem/Module.h +++ b/src/libcalamaresui/modulesystem/Module.h @@ -173,7 +173,12 @@ public: protected: explicit Module(); - virtual void initFrom( const QVariantMap& moduleDescriptor ); + + /// @brief For subclasses to read their part of the descriptor + virtual void initFrom( const QVariantMap& moduleDescriptor ) = 0; + /// @brief Generic part of descriptor reading (and instance id) + void initFrom( const QVariantMap& moduleDescriptor, const QString& id ); + QVariantMap m_configurationMap; bool m_loaded = false; diff --git a/src/libcalamaresui/modulesystem/ProcessJobModule.cpp b/src/libcalamaresui/modulesystem/ProcessJobModule.cpp index fc4b5f254..405d9efd8 100644 --- a/src/libcalamaresui/modulesystem/ProcessJobModule.cpp +++ b/src/libcalamaresui/modulesystem/ProcessJobModule.cpp @@ -63,7 +63,6 @@ ProcessJobModule::jobs() const void ProcessJobModule::initFrom( const QVariantMap& moduleDescriptor ) { - Module::initFrom( moduleDescriptor ); QDir directory( location() ); m_workingPath = directory.absolutePath(); diff --git a/src/libcalamaresui/modulesystem/PythonJobModule.cpp b/src/libcalamaresui/modulesystem/PythonJobModule.cpp index 46ec1dff1..c9e90a707 100644 --- a/src/libcalamaresui/modulesystem/PythonJobModule.cpp +++ b/src/libcalamaresui/modulesystem/PythonJobModule.cpp @@ -64,7 +64,6 @@ PythonJobModule::jobs() const void PythonJobModule::initFrom( const QVariantMap& moduleDescriptor ) { - Module::initFrom( moduleDescriptor ); QDir directory( location() ); m_workingPath = directory.absolutePath(); diff --git a/src/libcalamaresui/modulesystem/PythonQtViewModule.cpp b/src/libcalamaresui/modulesystem/PythonQtViewModule.cpp index 08e4c5c08..b59126eaa 100644 --- a/src/libcalamaresui/modulesystem/PythonQtViewModule.cpp +++ b/src/libcalamaresui/modulesystem/PythonQtViewModule.cpp @@ -174,7 +174,6 @@ PythonQtViewModule::jobs() const void PythonQtViewModule::initFrom( const QVariantMap& moduleDescriptor ) { - Module::initFrom( moduleDescriptor ); QDir directory( location() ); m_workingPath = directory.absolutePath(); diff --git a/src/libcalamaresui/modulesystem/ViewModule.cpp b/src/libcalamaresui/modulesystem/ViewModule.cpp index 7506e5348..02c771ee2 100644 --- a/src/libcalamaresui/modulesystem/ViewModule.cpp +++ b/src/libcalamaresui/modulesystem/ViewModule.cpp @@ -91,7 +91,6 @@ ViewModule::jobs() const void ViewModule::initFrom( const QVariantMap& moduleDescriptor ) { - Module::initFrom( moduleDescriptor ); QDir directory( location() ); QString load; if ( !moduleDescriptor.value( "load" ).toString().isEmpty() ) From f89c137c90f5b0904b914aa052f05882244550b6 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 12 Jan 2020 11:49:10 +0100 Subject: [PATCH 02/22] [libcalamaresui] Migrate module to using InstanceKey - Trying to get away from untyped strings with special meaning. - The "split identifier" branch tried the same thing, but was duplicating the existing InstanceKey.h work. --- src/libcalamaresui/modulesystem/Module.cpp | 34 ++++++---------------- src/libcalamaresui/modulesystem/Module.h | 11 +++---- 2 files changed, 15 insertions(+), 30 deletions(-) diff --git a/src/libcalamaresui/modulesystem/Module.cpp b/src/libcalamaresui/modulesystem/Module.cpp index 4bc759cb1..7608bd3ec 100644 --- a/src/libcalamaresui/modulesystem/Module.cpp +++ b/src/libcalamaresui/modulesystem/Module.cpp @@ -58,8 +58,7 @@ Module::~Module() {} void Module::initFrom( const QVariantMap& moduleDescriptor, const QString& id ) { - m_name = moduleDescriptor.value( "name" ).toString(); - m_instanceId = id; + m_key = ModuleSystem::InstanceKey( moduleDescriptor.value( "name" ).toString(), id ); if ( moduleDescriptor.contains( EMERGENCY ) ) { m_maybe_emergency = moduleDescriptor[ EMERGENCY ].toBool(); @@ -148,6 +147,12 @@ Module::fromDescriptor( const QVariantMap& moduleDescriptor, } m->initFrom( moduleDescriptor, instanceId ); + if ( !m->m_key.isValid() ) + { + cError() << "Module" << instanceId << "invalid ID"; + return nullptr; + } + m->initFrom( moduleDescriptor ); try { @@ -205,7 +210,7 @@ moduleConfigurationCandidates( bool assumeBuildDir, const QString& moduleName, c void Module::loadConfigurationFile( const QString& configFileName ) //throws YAML::Exception { QStringList configCandidates - = moduleConfigurationCandidates( Settings::instance()->debugMode(), m_name, configFileName ); + = moduleConfigurationCandidates( Settings::instance()->debugMode(), name(), configFileName ); for ( const QString& path : configCandidates ) { QFile configFile( path ); @@ -234,28 +239,7 @@ void Module::loadConfigurationFile( const QString& configFileName ) //throws YA return; } } - cDebug() << "No config file for" << m_name << "found anywhere at" << Logger::DebugList( configCandidates ); -} - - -QString -Module::name() const -{ - return m_name; -} - - -QString -Module::instanceId() const -{ - return m_instanceId; -} - - -QString -Module::instanceKey() const -{ - return QString( "%1@%2" ).arg( m_name ).arg( m_instanceId ); + cDebug() << "No config file for" << name() << "found anywhere at" << Logger::DebugList( configCandidates ); } diff --git a/src/libcalamaresui/modulesystem/Module.h b/src/libcalamaresui/modulesystem/Module.h index 03eb09cb0..d96ac152d 100644 --- a/src/libcalamaresui/modulesystem/Module.h +++ b/src/libcalamaresui/modulesystem/Module.h @@ -24,6 +24,8 @@ #include "Requirement.h" #include "UiDllMacro.h" +#include "modulesystem/InstanceKey.h" + #include #include @@ -83,13 +85,13 @@ public: * @brief name returns the name of this module. * @return a string with this module's name. */ - virtual QString name() const final; + QString name() const { return m_key.module(); } /** * @brief instanceId returns the instance id of this module. * @return a string with this module's instance id. */ - virtual QString instanceId() const final; + QString instanceId() const { return m_key.id(); } /** * @brief instanceKey returns the instance key of this module. @@ -98,7 +100,7 @@ public: * For instance, "partition\@partition" (default configuration) or * "locale\@someconfig" (custom configuration) */ - virtual QString instanceKey() const final; + QString instanceKey() const { return m_key.toString(); } /** * @brief location returns the full path of this module's directory. @@ -188,9 +190,8 @@ protected: private: void loadConfigurationFile( const QString& configFileName ); //throws YAML::Exception - QString m_name; QString m_directory; - QString m_instanceId; + ModuleSystem::InstanceKey m_key; }; } // namespace Calamares From ed4127f6616b4db5720d6a2a2b546a70c11d5ef1 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 12 Jan 2020 12:18:13 +0100 Subject: [PATCH 03/22] [libcalamaresui] Shuffle the module interface - introduce NamedEnum lookup tables for interface and type - drop "final" and "virtual" from methods that don't make sense as virtual - shuffle declaration order so the virtual API for modules sits together --- src/libcalamaresui/modulesystem/Module.cpp | 64 ++++++++++------- src/libcalamaresui/modulesystem/Module.h | 84 +++++++++++----------- 2 files changed, 81 insertions(+), 67 deletions(-) diff --git a/src/libcalamaresui/modulesystem/Module.cpp b/src/libcalamaresui/modulesystem/Module.cpp index 7608bd3ec..2d2ea3def 100644 --- a/src/libcalamaresui/modulesystem/Module.cpp +++ b/src/libcalamaresui/modulesystem/Module.cpp @@ -27,6 +27,7 @@ #include "utils/Dirs.h" #include "utils/Logger.h" +#include "utils/NamedEnum.h" #include "utils/Yaml.h" #ifdef WITH_PYTHON @@ -152,7 +153,7 @@ Module::fromDescriptor( const QVariantMap& moduleDescriptor, cError() << "Module" << instanceId << "invalid ID"; return nullptr; } - + m->initFrom( moduleDescriptor ); try { @@ -243,42 +244,55 @@ void Module::loadConfigurationFile( const QString& configFileName ) //throws YA } -QString -Module::location() const +static const NamedEnumTable< Module::Type >& +typeNames() { - return m_directory; + using Type = Module::Type; + // *INDENT-OFF* + // clang-format off + static const NamedEnumTable< Type > table{ + { QStringLiteral( "job" ), Type::Job }, + { QStringLiteral( "view" ), Type::View }, + { QStringLiteral( "viewmodule" ), Type::View }, + { QStringLiteral( "jobmodule" ), Type::Job } + }; + // *INDENT-ON* + // clang-format on + return table; } - QString Module::typeString() const { - switch ( type() ) - { - case Type::Job: - return "Job Module"; - case Type::View: - return "View Module"; - } - return QString(); + bool ok = false; + QString v = typeNames().find( type(), ok ); + return ok ? v : QString(); } +static const NamedEnumTable< Module::Interface >& +interfaceNames() +{ + using Interface = Module::Interface; + // *INDENT-OFF* + // clang-format off + static const NamedEnumTable< Interface > table { + { QStringLiteral("process"), Interface::Process }, + { QStringLiteral("qtplugin"), Interface::QtPlugin }, + { QStringLiteral("python"), Interface::Python }, + { QStringLiteral("pythonqt"), Interface::PythonQt } + }; + // *INDENT-ON* + // clang-format on + return table; +} + QString Module::interfaceString() const { - switch ( interface() ) - { - case Interface::Process: - return "External process"; - case Interface::Python: - return "Python (Boost.Python)"; - case Interface::PythonQt: - return "Python (experimental)"; - case Interface::QtPlugin: - return "Qt Plugin"; - } - return QString(); + bool ok = false; + QString v = interfaceNames().find( interface(), ok ); + return ok ? v : QString(); } diff --git a/src/libcalamaresui/modulesystem/Module.h b/src/libcalamaresui/modulesystem/Module.h index d96ac152d..88eba4dcf 100644 --- a/src/libcalamaresui/modulesystem/Module.h +++ b/src/libcalamaresui/modulesystem/Module.h @@ -106,43 +106,7 @@ public: * @brief location returns the full path of this module's directory. * @return the path. */ - virtual QString location() const final; - - /** - * @brief type returns the Type of this module object. - * @return the type enum value. - */ - virtual Type type() const = 0; - - /** - * @brief typeString returns a user-visible string for the module's type. - * @return the type string. - */ - virtual QString typeString() const; - - /** - * @brief interface the Interface used by this module. - * @return the interface enum value. - */ - virtual Interface interface() const = 0; - - /** - * @brief interface returns a user-visible string for the module's interface. - * @return the interface string. - */ - virtual QString interfaceString() const; - - /** - * @brief isLoaded reports on the loaded status of a module. - * @return true if the module's loading phase has finished, otherwise false. - */ - bool isLoaded() const { return m_loaded; } - - /** - * @brief loadSelf initialized the module. - * Subclasses must reimplement this depending on the module type and interface. - */ - virtual void loadSelf() = 0; + QString location() const { return m_directory; } /** * @brief Is this an emergency module? @@ -156,10 +120,10 @@ public: bool isEmergency() const { return m_emergency; } /** - * @brief jobs returns any jobs exposed by this module. - * @return a list of jobs (can be empty). + * @brief isLoaded reports on the loaded status of a module. + * @return true if the module's loading phase has finished, otherwise false. */ - virtual JobList jobs() const = 0; + bool isLoaded() const { return m_loaded; } /** * @brief configurationMap returns the contents of the configuration file for @@ -168,6 +132,42 @@ public: */ QVariantMap configurationMap(); + /** + * @brief typeString returns a user-visible string for the module's type. + * @return the type string. + */ + QString typeString() const; + + /** + * @brief interface returns a user-visible string for the module's interface. + * @return the interface string. + */ + QString interfaceString() const; + + /** + * @brief loadSelf initialized the module. + * Subclasses must reimplement this depending on the module type and interface. + */ + virtual void loadSelf() = 0; + + /** + * @brief jobs returns any jobs exposed by this module. + * @return a list of jobs (can be empty). + */ + virtual JobList jobs() const = 0; + + /** + * @brief type returns the Type of this module object. + * @return the type enum value. + */ + virtual Type type() const = 0; + + /** + * @brief interface the Interface used by this module. + * @return the interface enum value. + */ + virtual Interface interface() const = 0; + /** * @brief Check the requirements of this module. */ @@ -175,12 +175,12 @@ public: protected: explicit Module(); - + /// @brief For subclasses to read their part of the descriptor virtual void initFrom( const QVariantMap& moduleDescriptor ) = 0; /// @brief Generic part of descriptor reading (and instance id) void initFrom( const QVariantMap& moduleDescriptor, const QString& id ); - + QVariantMap m_configurationMap; bool m_loaded = false; From fed0c46612d56be96565e2160d7a49bd71ca76b1 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 19 Jan 2020 18:07:27 +0100 Subject: [PATCH 04/22] [libcalamaresui] Change return type of loadedInstanceKeys() - Replace stringlist with a stronger-typed list of InstanceKey objects - Move smashing-that-to-stringlist into consumers of the list (just one, the debug window) --- src/calamares/DebugWindow.cpp | 8 +++- .../modulesystem/ModuleManager.cpp | 42 +++++++------------ .../modulesystem/ModuleManager.h | 2 +- 3 files changed, 24 insertions(+), 28 deletions(-) diff --git a/src/calamares/DebugWindow.cpp b/src/calamares/DebugWindow.cpp index 6891851a7..82533a648 100644 --- a/src/calamares/DebugWindow.cpp +++ b/src/calamares/DebugWindow.cpp @@ -113,7 +113,13 @@ DebugWindow::DebugWindow() } ); // Modules page - QStringListModel* modulesModel = new QStringListModel( ModuleManager::instance()->loadedInstanceKeys() ); + QStringList modulesKeys; + for ( const auto& m : ModuleManager::instance()->loadedInstanceKeys() ) + { + modulesKeys << m.toString(); + } + + QStringListModel* modulesModel = new QStringListModel( modulesKeys ); m_ui->modulesListView->setModel( modulesModel ); m_ui->modulesListView->setSelectionMode( QAbstractItemView::SingleSelection ); diff --git a/src/libcalamaresui/modulesystem/ModuleManager.cpp b/src/libcalamaresui/modulesystem/ModuleManager.cpp index 33b638e64..0911fedc6 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.cpp +++ b/src/libcalamaresui/modulesystem/ModuleManager.cpp @@ -95,16 +95,12 @@ ModuleManager::doInit() QFileInfo descriptorFileInfo( currentDir.absoluteFilePath( QLatin1String( "module.desc" ) ) ); if ( !descriptorFileInfo.exists() ) { - cDebug() << bad_descriptor - << descriptorFileInfo.absoluteFilePath() - << "(missing)"; + cDebug() << bad_descriptor << descriptorFileInfo.absoluteFilePath() << "(missing)"; continue; } if ( !descriptorFileInfo.isReadable() ) { - cDebug() << bad_descriptor - << descriptorFileInfo.absoluteFilePath() - << "(unreadable)"; + cDebug() << bad_descriptor << descriptorFileInfo.absoluteFilePath() << "(unreadable)"; continue; } @@ -131,24 +127,18 @@ ModuleManager::doInit() cDebug() << "ModuleManager module search path does not exist:" << path; } } - // At this point m_availableDescriptorsByModuleName is filled with + // At this point m_availableDescriptorsByModuleName is filled with // the modules that were found in the search paths. - cDebug() << "Found" - << m_availableDescriptorsByModuleName.count() << "modules" - << m_moduleDirectoriesByModuleName.count() << "names"; + cDebug() << "Found" << m_availableDescriptorsByModuleName.count() << "modules" + << m_moduleDirectoriesByModuleName.count() << "names"; emit initDone(); } -QStringList +QList< ModuleSystem::InstanceKey > ModuleManager::loadedInstanceKeys() { - QStringList l; - for ( const auto& m : m_loadedModulesByInstanceKey.keys() ) - { - l << m.toString(); - } - return l; + return m_loadedModulesByInstanceKey.keys(); } @@ -188,15 +178,14 @@ findCustomInstance( const Settings::InstanceDescriptionList& customInstances, co void ModuleManager::loadModules() { - if (checkDependencies()) + if ( checkDependencies() ) { cWarning() << "Some installed modules have unmet dependencies."; } Settings::InstanceDescriptionList customInstances = Settings::instance()->customModuleInstances(); QStringList failedModules; - const auto modulesSequence - = Settings::instance()->modulesSequence() ; + const auto modulesSequence = Settings::instance()->modulesSequence(); for ( const auto& modulePhase : modulesSequence ) { ModuleSystem::Action currentAction = modulePhase.first; @@ -213,10 +202,10 @@ ModuleManager::loadModules() if ( !m_availableDescriptorsByModuleName.contains( instanceKey.module() ) - || m_availableDescriptorsByModuleName.value( instanceKey.module() ).isEmpty() ) + || m_availableDescriptorsByModuleName.value( instanceKey.module() ).isEmpty() ) { cError() << "Module" << instanceKey.toString() << "not found in module search paths." - << Logger::DebugList( m_paths ); + << Logger::DebugList( m_paths ); failedModules.append( instanceKey.toString() ); continue; } @@ -264,12 +253,13 @@ ModuleManager::loadModules() else { thisModule = Module::fromDescriptor( m_availableDescriptorsByModuleName.value( instanceKey.module() ), - instanceKey.id(), - configFileName, - m_moduleDirectoriesByModuleName.value( instanceKey.module() ) ); + instanceKey.id(), + configFileName, + m_moduleDirectoriesByModuleName.value( instanceKey.module() ) ); if ( !thisModule ) { - cError() << "Module" << instanceKey.toString() << "cannot be created from descriptor" << configFileName; + cError() << "Module" << instanceKey.toString() << "cannot be created from descriptor" + << configFileName; failedModules.append( instanceKey.toString() ); continue; } diff --git a/src/libcalamaresui/modulesystem/ModuleManager.h b/src/libcalamaresui/modulesystem/ModuleManager.h index 7adbb24e2..fca5d0ec9 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.h +++ b/src/libcalamaresui/modulesystem/ModuleManager.h @@ -62,7 +62,7 @@ public: * modules. * @return a QStringList with the instance keys. */ - QStringList loadedInstanceKeys(); + QList< ModuleSystem::InstanceKey > loadedInstanceKeys(); /** * @brief moduleDescriptor returns the module descriptor structure for a given module. From fbb452f9bfbca95c55fc21d5fdf8ecae565f8bb4 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 20 Jan 2020 19:27:34 +0100 Subject: [PATCH 05/22] CMake: add support for NO_CONFIG - A C++ module should set NO_CONFIG to flag that it doesn't have a config file (this is an error if it secretly **does** have one) --- CMakeModules/CalamaresAddPlugin.cmake | 13 ++++++++++++- src/modules/summary/CMakeLists.txt | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CMakeModules/CalamaresAddPlugin.cmake b/CMakeModules/CalamaresAddPlugin.cmake index 9c7b9d90e..ada95db51 100644 --- a/CMakeModules/CalamaresAddPlugin.cmake +++ b/CMakeModules/CalamaresAddPlugin.cmake @@ -38,6 +38,7 @@ # [RESOURCES resource-file] # [REQUIRES module-name...] # [NO_INSTALL] +# [NO_CONFIG] # [SHARED_LIB] # [EMERGENCY] # ) @@ -71,7 +72,7 @@ include( CMakeColors ) function( calamares_add_plugin ) # parse arguments ( name needs to be saved before passing ARGN into the macro ) set( NAME ${ARGV0} ) - set( options NO_INSTALL SHARED_LIB EMERGENCY ) + set( options NO_CONFIG NO_INSTALL SHARED_LIB EMERGENCY ) set( oneValueArgs NAME TYPE EXPORT_MACRO RESOURCES ) set( multiValueArgs SOURCES UI LINK_LIBRARIES LINK_PRIVATE_LIBRARIES COMPILE_DEFINITIONS REQUIRES ) cmake_parse_arguments( PLUGIN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) @@ -90,6 +91,9 @@ function( calamares_add_plugin ) message( " ${Green}LINK_PRIVATE_LIBRARIES:${ColorReset} ${PLUGIN_LINK_PRIVATE_LIBRARIES}" ) message( " ${Green}PLUGIN_DESTINATION:${ColorReset} ${PLUGIN_DESTINATION}" ) if( PLUGIN_CONFIG_FILES ) + if( PLUGIN_NO_CONFIG ) + message( FATAL_ERROR "${Red}NO_CONFIG${ColorReset} is set, with configuration ${Red}${PLUGIN_CONFIG_FILES}${ColorReset}" ) + endif() set( _destination "(unknown)" ) if ( INSTALL_CONFIG AND NOT PLUGIN_NO_INSTALL ) set( _destination "${PLUGIN_DATA_DESTINATION}" ) @@ -100,6 +104,10 @@ function( calamares_add_plugin ) set( _destination "[Skipping installation]" ) endif() message( " ${Green}CONFIGURATION_FILES:${ColorReset} ${PLUGIN_CONFIG_FILES} => ${_destination}" ) + else() + if( NOT PLUGIN_NO_CONFIG ) + message( " ${Red}NO_CONFIG${ColorReset} should be set." ) + endif() endif() if( PLUGIN_RESOURCES ) message( " ${Green}RESOURCES:${ColorReset} ${PLUGIN_RESOURCES}" ) @@ -170,6 +178,9 @@ function( calamares_add_plugin ) if ( PLUGIN_EMERGENCY ) file( APPEND ${_file} "emergency: true\n" ) endif() + if ( NO_CONFIG ) + file( APPEND ${_file} "noconfig: true\n" ) + endif() endif() if ( NOT PLUGIN_NO_INSTALL ) diff --git a/src/modules/summary/CMakeLists.txt b/src/modules/summary/CMakeLists.txt index 64b8d3c36..ce71357cd 100644 --- a/src/modules/summary/CMakeLists.txt +++ b/src/modules/summary/CMakeLists.txt @@ -9,4 +9,5 @@ calamares_add_plugin( summary LINK_PRIVATE_LIBRARIES calamaresui SHARED_LIB + NO_CONFIG ) From d1f162f92afb93278ecf521707f2b0e24f757e5e Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 21 Jan 2020 18:31:13 +0100 Subject: [PATCH 06/22] Docs: describe *noconfig* module option --- src/modules/README.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/modules/README.md b/src/modules/README.md index 5a7a16f37..2a9ef64c7 100644 --- a/src/modules/README.md +++ b/src/modules/README.md @@ -54,10 +54,12 @@ Module descriptors for Python and PythonQt modules **must** have the following k - *script* (the name of the Python script to load, nearly always `main.py`) Module descriptors **may** have the following keys: -- *requiredModules* (a list of modules which are required for this module - to operate properly) - *emergency* (a boolean value, set to true to mark the module as an emergency module) +- *noconfig* (a boolean value, set to true to state that the module + has no configuration file; defaults to false) +- *requiredModules* (a list of modules which are required for this module + to operate properly) ### Required Modules @@ -96,6 +98,12 @@ named `.conf`. If such a file is present in the module's directory, it can be shipped as a *default* configuration file. This only happens if the CMake-time option `INSTALL_CONFIG` is on. +Modules that have *noconfig* set to true will not attempt to +read a configuration file, and will not warn that one is missing; +conversely if *noconfig* is set to false (or is missing, since +the default value is false) if there is no configuration file, +a warning is printed during Calamares start-up. + The sample configuration files may work and may be suitable for your distribution, but no guarantee is given about their stability beyond syntactic correctness. @@ -122,7 +130,8 @@ to provide jobs. To add a Qt plugin module, put it in a subdirectory and make sure it has a `CMakeLists.txt` with a `calamares_add_plugin` call. It will be picked -up automatically by our CMake magic. The `module.desc` file is optional. +up automatically by our CMake magic. The `module.desc` file is not recommended: +nearly all cases can be described in CMake. From a403f1e8515faa51e2d37e04aac92215ccc79bdb Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 9 Jan 2020 15:25:30 +0100 Subject: [PATCH 07/22] CI: allow plain clang-format (Tumbleweed) --- ci/calamaresstyle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/calamaresstyle b/ci/calamaresstyle index 8b13b6f31..65dc83de7 100755 --- a/ci/calamaresstyle +++ b/ci/calamaresstyle @@ -8,7 +8,7 @@ # AS=$( which astyle ) -for _cf in clang-format-7 clang-format-8 clang-format70 clang-format80 +for _cf in clang-format-7 clang-format-8 clang-format70 clang-format80 clang-format do # Not an error if this particular clang-format isn't found CF=$( which $_cf || true ) From 8fbe676280f3e51ffff6f19bdcd731f21bf0ac29 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 21 Jan 2020 19:16:10 +0100 Subject: [PATCH 08/22] [libcalamaresui] Refactor finding config file name - check for broken custom instances earlier in the loop - make free function for finding the config file name --- .../modulesystem/ModuleManager.cpp | 59 ++++++++++++------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/src/libcalamaresui/modulesystem/ModuleManager.cpp b/src/libcalamaresui/modulesystem/ModuleManager.cpp index 0911fedc6..206193856 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.cpp +++ b/src/libcalamaresui/modulesystem/ModuleManager.cpp @@ -174,6 +174,33 @@ findCustomInstance( const Settings::InstanceDescriptionList& customInstances, co return -1; } +/** @brief Returns the config file name for the fiven @p instanceKey + * + * Custom instances have custom config files, non-custom ones + * have a .conf file. Returns an empty QString on + * errors. + */ +static QString +getConfigFileName( const Settings::InstanceDescriptionList& customInstances, + const ModuleSystem::InstanceKey& instanceKey ) +{ + if ( instanceKey.isCustom() ) + { + int found = findCustomInstance( customInstances, instanceKey ); + + if ( found < 0 ) + { + // This should already have been checked and failed the module already + return QString(); + } + + return customInstances[ found ].value( "config" ); + } + else + { + return QString( "%1.conf" ).arg( instanceKey.module() ); + } +} void ModuleManager::loadModules() @@ -199,7 +226,16 @@ ModuleManager::loadModules() failedModules.append( moduleEntry ); continue; } - + if ( instanceKey.isCustom() ) + { + int found = findCustomInstance( customInstances, instanceKey ); + if ( found < 0 ) + { + cError() << "Custom instance" << moduleEntry << "not found in custom instances section."; + failedModules.append( moduleEntry ); + continue; + } + } if ( !m_availableDescriptorsByModuleName.contains( instanceKey.module() ) || m_availableDescriptorsByModuleName.value( instanceKey.module() ).isEmpty() ) @@ -210,26 +246,7 @@ ModuleManager::loadModules() continue; } - QString configFileName; - if ( instanceKey.isCustom() ) - { - int found = findCustomInstance( customInstances, instanceKey ); - - if ( found > -1 ) - { - configFileName = customInstances[ found ].value( "config" ); - } - else //ought to be a custom instance, but cannot find instance entry - { - cError() << "Custom instance" << moduleEntry << "not found in custom instances section."; - failedModules.append( moduleEntry ); - continue; - } - } - else - { - configFileName = QString( "%1.conf" ).arg( instanceKey.module() ); - } + QString configFileName = getConfigFileName( customInstances, instanceKey ); // So now we can assume that the module entry is at least valid, // that we have a descriptor on hand (and therefore that the From 649eb94d24b7ca9960a7a8c07455ed08c60a13a3 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 21 Jan 2020 19:29:47 +0100 Subject: [PATCH 09/22] [libcalamaresui] Type-alias for module descriptors --- src/libcalamaresui/modulesystem/ModuleManager.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libcalamaresui/modulesystem/ModuleManager.h b/src/libcalamaresui/modulesystem/ModuleManager.h index fca5d0ec9..37fa6b60c 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.h +++ b/src/libcalamaresui/modulesystem/ModuleManager.h @@ -45,6 +45,8 @@ class ModuleManager : public QObject { Q_OBJECT public: + using ModuleDescriptor = QVariantMap; /// TODO: Should be strongly-typed instead + explicit ModuleManager( const QStringList& paths, QObject* parent = nullptr ); virtual ~ModuleManager() override; @@ -69,7 +71,7 @@ public: * @param name the name of the module for which to return the module descriptor. * @return the module descriptor, as a variant map already parsed from YAML. */ - QVariantMap moduleDescriptor( const QString& name ); + ModuleDescriptor moduleDescriptor( const QString& name ); /** * @brief moduleInstance returns a Module object for a given instance key. @@ -126,7 +128,7 @@ private: */ bool checkModuleDependencies( const Module& ); - QMap< QString, QVariantMap > m_availableDescriptorsByModuleName; + QMap< QString, ModuleDescriptor > m_availableDescriptorsByModuleName; QMap< QString, QString > m_moduleDirectoriesByModuleName; QMap< ModuleSystem::InstanceKey, Module* > m_loadedModulesByInstanceKey; const QStringList m_paths; From 58931d99fa554c03e031e8188b90dc53a13abed0 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 21 Jan 2020 19:45:47 +0100 Subject: [PATCH 10/22] [libcalamaresui] Support noconfig setting - look up the descriptor and use its noconfig value - return empty QString if noconfig is set; this does not apply to custom instances --- .../modulesystem/ModuleManager.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/libcalamaresui/modulesystem/ModuleManager.cpp b/src/libcalamaresui/modulesystem/ModuleManager.cpp index 206193856..62ade71d8 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.cpp +++ b/src/libcalamaresui/modulesystem/ModuleManager.cpp @@ -182,7 +182,8 @@ findCustomInstance( const Settings::InstanceDescriptionList& customInstances, co */ static QString getConfigFileName( const Settings::InstanceDescriptionList& customInstances, - const ModuleSystem::InstanceKey& instanceKey ) + const ModuleSystem::InstanceKey& instanceKey, + const ModuleManager::ModuleDescriptor& descriptor ) { if ( instanceKey.isCustom() ) { @@ -198,6 +199,14 @@ getConfigFileName( const Settings::InstanceDescriptionList& customInstances, } else { + if ( descriptor.value( "noconfig", false ).toBool() ) + { + // Explicitly set to no-configuration. This doesn't apply + // to custom instances (above) since the only reason to + // **have** a custom instance is to specify a different + // config file for more than one module. + return QString(); + } return QString( "%1.conf" ).arg( instanceKey.module() ); } } @@ -237,8 +246,9 @@ ModuleManager::loadModules() } } - if ( !m_availableDescriptorsByModuleName.contains( instanceKey.module() ) - || m_availableDescriptorsByModuleName.value( instanceKey.module() ).isEmpty() ) + ModuleDescriptor descriptor + = m_availableDescriptorsByModuleName.value( instanceKey.module(), ModuleDescriptor() ); + if ( descriptor.isEmpty() ) { cError() << "Module" << instanceKey.toString() << "not found in module search paths." << Logger::DebugList( m_paths ); @@ -246,7 +256,7 @@ ModuleManager::loadModules() continue; } - QString configFileName = getConfigFileName( customInstances, instanceKey ); + QString configFileName = getConfigFileName( customInstances, instanceKey, descriptor ); // So now we can assume that the module entry is at least valid, // that we have a descriptor on hand (and therefore that the From 974d79539078b70db05e5cfc077d4eae0d9b5cbd Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 21 Jan 2020 19:55:46 +0100 Subject: [PATCH 11/22] [libcalamares] Shuffle module-loading logic - group ifs by the state of thisModule --- .../modulesystem/ModuleManager.cpp | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/libcalamaresui/modulesystem/ModuleManager.cpp b/src/libcalamaresui/modulesystem/ModuleManager.cpp index 62ade71d8..028e80168 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.cpp +++ b/src/libcalamaresui/modulesystem/ModuleManager.cpp @@ -266,16 +266,22 @@ ModuleManager::loadModules() // exists and is valid, but that's the only thing that could fail // from this point on. -- Teo 8/2015 Module* thisModule = m_loadedModulesByInstanceKey.value( instanceKey, nullptr ); - if ( thisModule && !thisModule->isLoaded() ) + if ( thisModule ) { - cError() << "Module" << instanceKey.toString() << "exists but not loaded."; - failedModules.append( instanceKey.toString() ); - continue; - } - - if ( thisModule && thisModule->isLoaded() ) - { - cDebug() << "Module" << instanceKey.toString() << "already loaded."; + if ( thisModule->isLoaded() ) + { + // It's been listed before, don't bother loading again. + // This can happen for a module listed twice (e.g. with custom instances) + cDebug() << "Module" << instanceKey.toString() << "already loaded."; + } + else + { + // An attempt was made, earlier, and that failed. + // This can happen for a module listed twice (e.g. with custom instances) + cError() << "Module" << instanceKey.toString() << "exists but not loaded."; + failedModules.append( instanceKey.toString() ); + continue; + } } else { From 155db29ccf50633d52da7647e4fa9cabdf97e07a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 24 Jan 2020 12:59:35 +0100 Subject: [PATCH 12/22] [libcalamares] Add a ModuleSystem::Descriptor - this is currently just an alias for QVariantMap, which is the type already in use. - future plan is to tighten this up and have an actual Descriptor class that carries only the information actually needed for the module descriptor. --- src/libcalamares/modulesystem/Descriptor.h | 36 +++++++++++++++++++ src/libcalamaresui/modulesystem/Module.h | 4 ++- .../modulesystem/ModuleManager.cpp | 8 ++--- .../modulesystem/ModuleManager.h | 7 ++-- 4 files changed, 46 insertions(+), 9 deletions(-) create mode 100644 src/libcalamares/modulesystem/Descriptor.h diff --git a/src/libcalamares/modulesystem/Descriptor.h b/src/libcalamares/modulesystem/Descriptor.h new file mode 100644 index 000000000..77d69caf3 --- /dev/null +++ b/src/libcalamares/modulesystem/Descriptor.h @@ -0,0 +1,36 @@ +/* === This file is part of Calamares - === + * + * Copyright 2020, Adriaan de Groot + * + * 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 . + */ + +#ifndef MODULESYSTEM_DESCRIPTOR_H +#define MODULESYSTEM_DESCRIPTOR_H + +#include + +namespace Calamares +{ +namespace ModuleSystem +{ +/* While this isn't a useful *using* right now, the intention is + * to create a more strongly-typed Module Descriptor that carries + * only the necessary information and no variants. + */ +using Descriptor = QVariantMap; +} // namespace ModuleSystem +} // namespace Calamares + +#endif diff --git a/src/libcalamaresui/modulesystem/Module.h b/src/libcalamaresui/modulesystem/Module.h index e4101b767..d6e6407d1 100644 --- a/src/libcalamaresui/modulesystem/Module.h +++ b/src/libcalamaresui/modulesystem/Module.h @@ -24,6 +24,8 @@ #include "Requirement.h" #include "UiDllMacro.h" +#include "modulesystem/Descriptor.h" + #include #include @@ -73,7 +75,7 @@ public: * @param moduleDirectory the path to the directory with this module's files. * @return a pointer to an object of a subtype of Module. */ - static Module* fromDescriptor( const QVariantMap& moduleDescriptor, + static Module* fromDescriptor( const ModuleSystem::Descriptor& moduleDescriptor, const QString& instanceId, const QString& configFileName, const QString& moduleDirectory ); diff --git a/src/libcalamaresui/modulesystem/ModuleManager.cpp b/src/libcalamaresui/modulesystem/ModuleManager.cpp index 028e80168..7e3b45c7f 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.cpp +++ b/src/libcalamaresui/modulesystem/ModuleManager.cpp @@ -183,7 +183,7 @@ findCustomInstance( const Settings::InstanceDescriptionList& customInstances, co static QString getConfigFileName( const Settings::InstanceDescriptionList& customInstances, const ModuleSystem::InstanceKey& instanceKey, - const ModuleManager::ModuleDescriptor& descriptor ) + const ModuleSystem::Descriptor& descriptor ) { if ( instanceKey.isCustom() ) { @@ -246,8 +246,8 @@ ModuleManager::loadModules() } } - ModuleDescriptor descriptor - = m_availableDescriptorsByModuleName.value( instanceKey.module(), ModuleDescriptor() ); + ModuleSystem::Descriptor descriptor + = m_availableDescriptorsByModuleName.value( instanceKey.module(), ModuleSystem::Descriptor() ); if ( descriptor.isEmpty() ) { cError() << "Module" << instanceKey.toString() << "not found in module search paths." @@ -285,7 +285,7 @@ ModuleManager::loadModules() } else { - thisModule = Module::fromDescriptor( m_availableDescriptorsByModuleName.value( instanceKey.module() ), + thisModule = Module::fromDescriptor( descriptor, instanceKey.id(), configFileName, m_moduleDirectoriesByModuleName.value( instanceKey.module() ) ); diff --git a/src/libcalamaresui/modulesystem/ModuleManager.h b/src/libcalamaresui/modulesystem/ModuleManager.h index 37fa6b60c..be485c01d 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.h +++ b/src/libcalamaresui/modulesystem/ModuleManager.h @@ -20,6 +20,7 @@ #ifndef MODULELOADER_H #define MODULELOADER_H +#include "modulesystem/Descriptor.h" #include "modulesystem/InstanceKey.h" #include "Requirement.h" @@ -45,8 +46,6 @@ class ModuleManager : public QObject { Q_OBJECT public: - using ModuleDescriptor = QVariantMap; /// TODO: Should be strongly-typed instead - explicit ModuleManager( const QStringList& paths, QObject* parent = nullptr ); virtual ~ModuleManager() override; @@ -71,7 +70,7 @@ public: * @param name the name of the module for which to return the module descriptor. * @return the module descriptor, as a variant map already parsed from YAML. */ - ModuleDescriptor moduleDescriptor( const QString& name ); + ModuleSystem::Descriptor moduleDescriptor( const QString& name ); /** * @brief moduleInstance returns a Module object for a given instance key. @@ -128,7 +127,7 @@ private: */ bool checkModuleDependencies( const Module& ); - QMap< QString, ModuleDescriptor > m_availableDescriptorsByModuleName; + QMap< QString, ModuleSystem::Descriptor > m_availableDescriptorsByModuleName; QMap< QString, QString > m_moduleDirectoriesByModuleName; QMap< ModuleSystem::InstanceKey, Module* > m_loadedModulesByInstanceKey; const QStringList m_paths; From fd058302b8dda63dbbd1170855d021e7a66b5424 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 24 Jan 2020 13:08:25 +0100 Subject: [PATCH 13/22] [dracutlukscfg] set NO_CONFIG and coding style --- src/modules/dracutlukscfg/CMakeLists.txt | 1 + .../dracutlukscfg/DracutLuksCfgJob.cpp | 66 +++++++++++-------- src/modules/dracutlukscfg/DracutLuksCfgJob.h | 8 +-- 3 files changed, 43 insertions(+), 32 deletions(-) diff --git a/src/modules/dracutlukscfg/CMakeLists.txt b/src/modules/dracutlukscfg/CMakeLists.txt index 5504136c3..1a07b042d 100644 --- a/src/modules/dracutlukscfg/CMakeLists.txt +++ b/src/modules/dracutlukscfg/CMakeLists.txt @@ -6,4 +6,5 @@ calamares_add_plugin( dracutlukscfg LINK_PRIVATE_LIBRARIES calamares SHARED_LIB + NO_CONFIG ) diff --git a/src/modules/dracutlukscfg/DracutLuksCfgJob.cpp b/src/modules/dracutlukscfg/DracutLuksCfgJob.cpp index 97b2c9d55..e151acc0c 100644 --- a/src/modules/dracutlukscfg/DracutLuksCfgJob.cpp +++ b/src/modules/dracutlukscfg/DracutLuksCfgJob.cpp @@ -24,8 +24,8 @@ #include #include "CalamaresVersion.h" -#include "JobQueue.h" #include "GlobalStorage.h" +#include "JobQueue.h" #include "utils/Logger.h" @@ -33,30 +33,30 @@ const QLatin1String DracutLuksCfgJob::CONFIG_FILE( "/etc/dracut.conf.d/calamares-luks.conf" ); // static -const char *DracutLuksCfgJob::CONFIG_FILE_HEADER = - "# Configuration file automatically written by the Calamares system installer\n" - "# (This file is written once at install time and should be safe to edit.)\n" - "# Enables support for LUKS full disk encryption with single sign on from GRUB.\n" - "\n"; +const char* DracutLuksCfgJob::CONFIG_FILE_HEADER + = "# Configuration file automatically written by the Calamares system installer\n" + "# (This file is written once at install time and should be safe to edit.)\n" + "# Enables support for LUKS full disk encryption with single sign on from GRUB.\n" + "\n"; // static -const char *DracutLuksCfgJob::CONFIG_FILE_CRYPTTAB_KEYFILE_LINE = - "# force installing /etc/crypttab even if hostonly=\"no\", install the keyfile\n" - "install_items+=\" /etc/crypttab /crypto_keyfile.bin \"\n"; +const char* DracutLuksCfgJob::CONFIG_FILE_CRYPTTAB_KEYFILE_LINE + = "# force installing /etc/crypttab even if hostonly=\"no\", install the keyfile\n" + "install_items+=\" /etc/crypttab /crypto_keyfile.bin \"\n"; // static -const char *DracutLuksCfgJob::CONFIG_FILE_CRYPTTAB_LINE = - "# force installing /etc/crypttab even if hostonly=\"no\"\n" - "install_items+=\" /etc/crypttab \"\n"; +const char* DracutLuksCfgJob::CONFIG_FILE_CRYPTTAB_LINE = "# force installing /etc/crypttab even if hostonly=\"no\"\n" + "install_items+=\" /etc/crypttab \"\n"; // static -const QLatin1String DracutLuksCfgJob::CONFIG_FILE_SWAPLINE( "# enable automatic resume from swap\nadd_device+=\" /dev/disk/by-uuid/%1 \"\n" ); +const QLatin1String DracutLuksCfgJob::CONFIG_FILE_SWAPLINE( + "# enable automatic resume from swap\nadd_device+=\" /dev/disk/by-uuid/%1 \"\n" ); // static QString DracutLuksCfgJob::rootMountPoint() { - Calamares::GlobalStorage *globalStorage = Calamares::JobQueue::instance()->globalStorage(); + Calamares::GlobalStorage* globalStorage = Calamares::JobQueue::instance()->globalStorage(); return globalStorage->value( QStringLiteral( "rootMountPoint" ) ).toString(); } @@ -64,7 +64,7 @@ DracutLuksCfgJob::rootMountPoint() QVariantList DracutLuksCfgJob::partitions() { - Calamares::GlobalStorage *globalStorage = Calamares::JobQueue::instance()->globalStorage(); + Calamares::GlobalStorage* globalStorage = Calamares::JobQueue::instance()->globalStorage(); return globalStorage->value( QStringLiteral( "partitions" ) ).toList(); } @@ -73,12 +73,14 @@ bool DracutLuksCfgJob::isRootEncrypted() { const QVariantList partitions = DracutLuksCfgJob::partitions(); - for ( const QVariant &partition : partitions ) + for ( const QVariant& partition : partitions ) { QVariantMap partitionMap = partition.toMap(); QString mountPoint = partitionMap.value( QStringLiteral( "mountPoint" ) ).toString(); if ( mountPoint == QStringLiteral( "/" ) ) + { return partitionMap.contains( QStringLiteral( "luksMapperName" ) ); + } } return false; } @@ -88,12 +90,14 @@ bool DracutLuksCfgJob::hasUnencryptedSeparateBoot() { const QVariantList partitions = DracutLuksCfgJob::partitions(); - for ( const QVariant &partition : partitions ) + for ( const QVariant& partition : partitions ) { QVariantMap partitionMap = partition.toMap(); QString mountPoint = partitionMap.value( QStringLiteral( "mountPoint" ) ).toString(); if ( mountPoint == QStringLiteral( "/boot" ) ) + { return !partitionMap.contains( QStringLiteral( "luksMapperName" ) ); + } } return false; } @@ -103,12 +107,14 @@ QString DracutLuksCfgJob::swapOuterUuid() { const QVariantList partitions = DracutLuksCfgJob::partitions(); - for ( const QVariant &partition : partitions ) + for ( const QVariant& partition : partitions ) { QVariantMap partitionMap = partition.toMap(); QString fsType = partitionMap.value( QStringLiteral( "fs" ) ).toString(); if ( fsType == QStringLiteral( "linuxswap" ) && partitionMap.contains( QStringLiteral( "luksMapperName" ) ) ) + { return partitionMap.value( QStringLiteral( "luksUuid" ) ).toString(); + } } return QString(); } @@ -119,18 +125,20 @@ DracutLuksCfgJob::DracutLuksCfgJob( QObject* parent ) } -DracutLuksCfgJob::~DracutLuksCfgJob() -{ -} +DracutLuksCfgJob::~DracutLuksCfgJob() {} QString DracutLuksCfgJob::prettyName() const { if ( isRootEncrypted() ) + { return tr( "Write LUKS configuration for Dracut to %1" ).arg( CONFIG_FILE ); + } else + { return tr( "Skip writing LUKS configuration for Dracut: \"/\" partition is not encrypted" ); + } } @@ -143,26 +151,28 @@ DracutLuksCfgJob::exec() cDebug() << "[DRACUTLUKSCFG]: Writing" << realConfigFilePath; QDir( QStringLiteral( "/" ) ).mkpath( QFileInfo( realConfigFilePath ).absolutePath() ); QFile configFile( realConfigFilePath ); - if ( ! configFile.open( QIODevice::WriteOnly | QIODevice::Text ) ) + if ( !configFile.open( QIODevice::WriteOnly | QIODevice::Text ) ) { cDebug() << "[DRACUTLUKSCFG]: Failed to open" << realConfigFilePath; return Calamares::JobResult::error( tr( "Failed to open %1" ).arg( realConfigFilePath ) ); } QTextStream outStream( &configFile ); outStream << CONFIG_FILE_HEADER - << ( hasUnencryptedSeparateBoot() ? CONFIG_FILE_CRYPTTAB_LINE - : CONFIG_FILE_CRYPTTAB_KEYFILE_LINE ); + << ( hasUnencryptedSeparateBoot() ? CONFIG_FILE_CRYPTTAB_LINE : CONFIG_FILE_CRYPTTAB_KEYFILE_LINE ); const QString swapOuterUuid = DracutLuksCfgJob::swapOuterUuid(); - if ( ! swapOuterUuid.isEmpty() ) + if ( !swapOuterUuid.isEmpty() ) { cDebug() << "[DRACUTLUKSCFG]: Swap outer UUID" << swapOuterUuid; - outStream << QString(CONFIG_FILE_SWAPLINE).arg( swapOuterUuid ).toLatin1(); + outStream << QString( CONFIG_FILE_SWAPLINE ).arg( swapOuterUuid ).toLatin1(); } cDebug() << "[DRACUTLUKSCFG]: Wrote config to" << realConfigFilePath; - } else + } + else + { cDebug() << "[DRACUTLUKSCFG]: / not encrypted, skipping"; + } return Calamares::JobResult::ok(); } -CALAMARES_PLUGIN_FACTORY_DEFINITION( DracutLuksCfgJobFactory, registerPlugin(); ) +CALAMARES_PLUGIN_FACTORY_DEFINITION( DracutLuksCfgJobFactory, registerPlugin< DracutLuksCfgJob >(); ) diff --git a/src/modules/dracutlukscfg/DracutLuksCfgJob.h b/src/modules/dracutlukscfg/DracutLuksCfgJob.h index 5811c34a1..e9e5a54a2 100644 --- a/src/modules/dracutlukscfg/DracutLuksCfgJob.h +++ b/src/modules/dracutlukscfg/DracutLuksCfgJob.h @@ -43,9 +43,9 @@ public: private: static const QLatin1String CONFIG_FILE; - static const char *CONFIG_FILE_HEADER; - static const char *CONFIG_FILE_CRYPTTAB_KEYFILE_LINE; - static const char *CONFIG_FILE_CRYPTTAB_LINE; + static const char* CONFIG_FILE_HEADER; + static const char* CONFIG_FILE_CRYPTTAB_KEYFILE_LINE; + static const char* CONFIG_FILE_CRYPTTAB_LINE; static const QLatin1String CONFIG_FILE_SWAPLINE; static QString rootMountPoint(); @@ -57,4 +57,4 @@ private: CALAMARES_PLUGIN_FACTORY_DECLARATION( DracutLuksCfgJobFactory ) -#endif // DRACUTLUKSCFGJOB_H +#endif // DRACUTLUKSCFGJOB_H From 40f64f0c116620ced672be960bc39fde0693ab47 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 24 Jan 2020 13:12:25 +0100 Subject: [PATCH 14/22] [hostinfo] Set NO_CONFIG and remove unused configuration methods --- src/modules/hostinfo/CMakeLists.txt | 1 + src/modules/hostinfo/HostInfoJob.cpp | 5 ----- src/modules/hostinfo/HostInfoJob.h | 2 -- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/modules/hostinfo/CMakeLists.txt b/src/modules/hostinfo/CMakeLists.txt index cc9b0bbac..caf888625 100644 --- a/src/modules/hostinfo/CMakeLists.txt +++ b/src/modules/hostinfo/CMakeLists.txt @@ -25,6 +25,7 @@ calamares_add_plugin( hostinfo LINK_PRIVATE_LIBRARIES calamares SHARED_LIB + NO_CONFIG ) if ( KF5CoreAddons_FOUND AND KF5CoreAddons_VERSION VERSION_GREATER_EQUAL 5.58 ) diff --git a/src/modules/hostinfo/HostInfoJob.cpp b/src/modules/hostinfo/HostInfoJob.cpp index 999697a68..3e0e4258c 100644 --- a/src/modules/hostinfo/HostInfoJob.cpp +++ b/src/modules/hostinfo/HostInfoJob.cpp @@ -165,9 +165,4 @@ HostInfoJob::exec() return Calamares::JobResult::ok(); } -void -HostInfoJob::setConfigurationMap( const QVariantMap& ) -{ -} - CALAMARES_PLUGIN_FACTORY_DEFINITION( HostInfoJobFactory, registerPlugin< HostInfoJob >(); ) diff --git a/src/modules/hostinfo/HostInfoJob.h b/src/modules/hostinfo/HostInfoJob.h index 62cb0a796..fa3342192 100644 --- a/src/modules/hostinfo/HostInfoJob.h +++ b/src/modules/hostinfo/HostInfoJob.h @@ -57,8 +57,6 @@ public: QString prettyName() const override; Calamares::JobResult exec() override; - - void setConfigurationMap( const QVariantMap& configurationMap ) override; }; CALAMARES_PLUGIN_FACTORY_DECLARATION( HostInfoJobFactory ) From b5d0acdf81d241d1b9122fd05f2b0f88483ee680 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 24 Jan 2020 13:13:50 +0100 Subject: [PATCH 15/22] [luksbootkeyfile] Set NO_CONFIG --- src/modules/luksbootkeyfile/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/luksbootkeyfile/CMakeLists.txt b/src/modules/luksbootkeyfile/CMakeLists.txt index be0f0fa28..5e69d3acb 100644 --- a/src/modules/luksbootkeyfile/CMakeLists.txt +++ b/src/modules/luksbootkeyfile/CMakeLists.txt @@ -6,4 +6,5 @@ calamares_add_plugin( luksbootkeyfile LINK_PRIVATE_LIBRARIES calamares SHARED_LIB + NO_CONFIG ) From 00deeec8c88d1c28722d2d22ecffe98951d31674 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 24 Jan 2020 17:47:06 +0100 Subject: [PATCH 16/22] [libcalamaresui] Use InstanceKey instead of strings - Replace return type of Module::instanceKey() by the structured ModuleSystem::InstanceKey type - Chase API breakage --- src/calamares/progresstree/ViewStepItem.cpp | 2 +- src/libcalamares/CppJob.cpp | 2 +- src/libcalamares/CppJob.h | 15 +++++++----- src/libcalamaresui/modulesystem/Module.h | 2 +- src/libcalamaresui/viewpages/ViewStep.cpp | 2 +- src/libcalamaresui/viewpages/ViewStep.h | 23 ++++++++++--------- .../packagechooser/PackageChooserViewStep.cpp | 3 +-- 7 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/calamares/progresstree/ViewStepItem.cpp b/src/calamares/progresstree/ViewStepItem.cpp index 27e56ef55..885b81dfc 100644 --- a/src/calamares/progresstree/ViewStepItem.cpp +++ b/src/calamares/progresstree/ViewStepItem.cpp @@ -67,7 +67,7 @@ ViewStepItem::data( int role ) const toolTip.append( QString( "
Status:\t%1" ).arg( m_step->prettyStatus() ) ); toolTip.append( QString( "
Source:\t%1" ) - .arg( m_step->moduleInstanceKey().isEmpty() ? "built-in" : m_step->moduleInstanceKey() ) ); + .arg( m_step->moduleInstanceKey().isValid() ? m_step->moduleInstanceKey().toString() : QStringLiteral("built-in") ) ); } else { diff --git a/src/libcalamares/CppJob.cpp b/src/libcalamares/CppJob.cpp index 82af344dd..b6b18b1b7 100644 --- a/src/libcalamares/CppJob.cpp +++ b/src/libcalamares/CppJob.cpp @@ -32,7 +32,7 @@ CppJob::~CppJob() {} void -CppJob::setModuleInstanceKey( const QString& instanceKey ) +CppJob::setModuleInstanceKey( const Calamares::ModuleSystem::InstanceKey& instanceKey ) { m_instanceKey = instanceKey; } diff --git a/src/libcalamares/CppJob.h b/src/libcalamares/CppJob.h index 10ab71649..e4997733e 100644 --- a/src/libcalamares/CppJob.h +++ b/src/libcalamares/CppJob.h @@ -2,6 +2,7 @@ * * Copyright 2014-2015, Teo Mrnjavac * Copyright 2016, Kevin Kofler + * Copyright 2020, Adriaan de Groor * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,12 +21,14 @@ #ifndef CALAMARES_CPPJOB_H #define CALAMARES_CPPJOB_H -#include -#include - #include "DllMacro.h" #include "Job.h" +#include "modulesystem/InstanceKey.h" + +#include +#include + namespace Calamares { @@ -36,13 +39,13 @@ public: explicit CppJob( QObject* parent = nullptr ); virtual ~CppJob(); - void setModuleInstanceKey( const QString& instanceKey ); - QString moduleInstanceKey() const { return m_instanceKey; } + void setModuleInstanceKey( const Calamares::ModuleSystem::InstanceKey& instanceKey ); + Calamares::ModuleSystem::InstanceKey moduleInstanceKey() const { return m_instanceKey; } virtual void setConfigurationMap( const QVariantMap& configurationMap ); protected: - QString m_instanceKey; + Calamares::ModuleSystem::InstanceKey m_instanceKey; }; } // namespace Calamares diff --git a/src/libcalamaresui/modulesystem/Module.h b/src/libcalamaresui/modulesystem/Module.h index ec316bece..bf2f1cb5d 100644 --- a/src/libcalamaresui/modulesystem/Module.h +++ b/src/libcalamaresui/modulesystem/Module.h @@ -101,7 +101,7 @@ public: * For instance, "partition\@partition" (default configuration) or * "locale\@someconfig" (custom configuration) */ - QString instanceKey() const { return m_key.toString(); } + ModuleSystem::InstanceKey instanceKey() const { return m_key; } /** * @brief location returns the full path of this module's directory. diff --git a/src/libcalamaresui/viewpages/ViewStep.cpp b/src/libcalamaresui/viewpages/ViewStep.cpp index 7fe7ff88d..11cfa2beb 100644 --- a/src/libcalamaresui/viewpages/ViewStep.cpp +++ b/src/libcalamaresui/viewpages/ViewStep.cpp @@ -66,7 +66,7 @@ ViewStep::back() void -ViewStep::setModuleInstanceKey( const QString& instanceKey ) +ViewStep::setModuleInstanceKey( const Calamares::ModuleSystem::InstanceKey& instanceKey ) { m_instanceKey = instanceKey; } diff --git a/src/libcalamaresui/viewpages/ViewStep.h b/src/libcalamaresui/viewpages/ViewStep.h index 8c5020f83..c5903d6f5 100644 --- a/src/libcalamaresui/viewpages/ViewStep.h +++ b/src/libcalamaresui/viewpages/ViewStep.h @@ -1,7 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2015, Teo Mrnjavac - * Copyright 2017, Adriaan de Groot + * Copyright 2017, 2020, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,15 +20,16 @@ #ifndef VIEWSTEP_H #define VIEWSTEP_H -#include -#include -#include - #include "Job.h" #include "UiDllMacro.h" +#include "modulesystem/InstanceKey.h" #include "modulesystem/Requirement.h" +#include +#include +#include + namespace Calamares { @@ -36,9 +37,9 @@ namespace Calamares * @brief The ViewStep class is the base class for all view modules. * A view module is a Calamares module which has at least one UI page (exposed as * ViewStep::widget), and can optionally create Calamares jobs at runtime. - * As of early 2017, a view module can be implemented by deriving from ViewStep - * in C++ (as a Qt Plugin) or in Python with the PythonQt interface (which also - * mimics the ViewStep class). + * As of early 2020, a view module can be implemented by deriving from ViewStep + * in C++ (as a Qt Plugin or a Qml ViewStep) or in Python with the PythonQt interface + * (which also mimics the ViewStep class). * * A ViewStep can describe itself in human-readable format for the SummaryPage * (which shows all of the things which have been collected to be done in the @@ -129,8 +130,8 @@ public: */ virtual JobList jobs() const = 0; - void setModuleInstanceKey( const QString& instanceKey ); - QString moduleInstanceKey() const { return m_instanceKey; } + void setModuleInstanceKey( const Calamares::ModuleSystem::InstanceKey& instanceKey ); + Calamares::ModuleSystem::InstanceKey moduleInstanceKey() const { return m_instanceKey; } virtual void setConfigurationMap( const QVariantMap& configurationMap ); @@ -154,7 +155,7 @@ signals: void enlarge( QSize enlarge ) const; protected: - QString m_instanceKey; + Calamares::ModuleSystem::InstanceKey m_instanceKey; }; using ViewStepList = QList< ViewStep* >; diff --git a/src/modules/packagechooser/PackageChooserViewStep.cpp b/src/modules/packagechooser/PackageChooserViewStep.cpp index c933147ee..759c6eeab 100644 --- a/src/modules/packagechooser/PackageChooserViewStep.cpp +++ b/src/modules/packagechooser/PackageChooserViewStep.cpp @@ -192,8 +192,7 @@ PackageChooserViewStep::setConfigurationMap( const QVariantMap& configurationMap if ( m_id.isEmpty() ) { // Not set, so use the instance id - // TODO: use a stronger type than QString for structured IDs - m_id = moduleInstanceKey().split( '@' ).last(); + m_id = moduleInstanceKey().id(); } bool labels_ok = false; From 5ad73681c2e00599cf298aa54e78e665573dc0cf Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 24 Jan 2020 20:58:23 +0100 Subject: [PATCH 17/22] CMake: actually write the NO_CONFIG setting --- CMakeModules/CalamaresAddPlugin.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeModules/CalamaresAddPlugin.cmake b/CMakeModules/CalamaresAddPlugin.cmake index ada95db51..c8f81e684 100644 --- a/CMakeModules/CalamaresAddPlugin.cmake +++ b/CMakeModules/CalamaresAddPlugin.cmake @@ -178,7 +178,7 @@ function( calamares_add_plugin ) if ( PLUGIN_EMERGENCY ) file( APPEND ${_file} "emergency: true\n" ) endif() - if ( NO_CONFIG ) + if ( PLUGIN_NO_CONFIG ) file( APPEND ${_file} "noconfig: true\n" ) endif() endif() From f366e3840f47abf71fa4b4f7cfe08a4647509db8 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 24 Jan 2020 21:46:18 +0100 Subject: [PATCH 18/22] [libcalamaresui] Chase stronger typing of ModuleDescriptor --- src/libcalamaresui/modulesystem/Module.cpp | 4 ++-- src/libcalamaresui/modulesystem/ModuleManager.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcalamaresui/modulesystem/Module.cpp b/src/libcalamaresui/modulesystem/Module.cpp index 2d2ea3def..227e25a2d 100644 --- a/src/libcalamaresui/modulesystem/Module.cpp +++ b/src/libcalamaresui/modulesystem/Module.cpp @@ -57,7 +57,7 @@ Module::Module() Module::~Module() {} void -Module::initFrom( const QVariantMap& moduleDescriptor, const QString& id ) +Module::initFrom( const Calamares::ModuleSystem::Descriptor& moduleDescriptor, const QString& id ) { m_key = ModuleSystem::InstanceKey( moduleDescriptor.value( "name" ).toString(), id ); if ( moduleDescriptor.contains( EMERGENCY ) ) @@ -67,7 +67,7 @@ Module::initFrom( const QVariantMap& moduleDescriptor, const QString& id ) } Module* -Module::fromDescriptor( const QVariantMap& moduleDescriptor, +Module::fromDescriptor( const Calamares::ModuleSystem::Descriptor& moduleDescriptor, const QString& instanceId, const QString& configFileName, const QString& moduleDirectory ) diff --git a/src/libcalamaresui/modulesystem/ModuleManager.cpp b/src/libcalamaresui/modulesystem/ModuleManager.cpp index 7e3b45c7f..c3e9569ef 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.cpp +++ b/src/libcalamaresui/modulesystem/ModuleManager.cpp @@ -142,7 +142,7 @@ ModuleManager::loadedInstanceKeys() } -QVariantMap +Calamares::ModuleSystem::Descriptor ModuleManager::moduleDescriptor( const QString& name ) { return m_availableDescriptorsByModuleName.value( name ); From 83ffbd5126b2e8c2c763aa0acf35d41e54127bb7 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 24 Jan 2020 21:47:54 +0100 Subject: [PATCH 19/22] [libcalamaresui] Only load config file if there is one - finally, no more warnings for modules that are NO_CONFIG (or noconfig: true) and don't have a config file. --- src/libcalamaresui/modulesystem/Module.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/libcalamaresui/modulesystem/Module.cpp b/src/libcalamaresui/modulesystem/Module.cpp index 227e25a2d..8fe3f2ac6 100644 --- a/src/libcalamaresui/modulesystem/Module.cpp +++ b/src/libcalamaresui/modulesystem/Module.cpp @@ -155,14 +155,17 @@ Module::fromDescriptor( const Calamares::ModuleSystem::Descriptor& moduleDescrip } m->initFrom( moduleDescriptor ); - try + if ( !configFileName.isEmpty() ) { - m->loadConfigurationFile( configFileName ); - } - catch ( YAML::Exception& e ) - { - cError() << "YAML parser error " << e.what(); - return nullptr; + try + { + m->loadConfigurationFile( configFileName ); + } + catch ( YAML::Exception& e ) + { + cError() << "YAML parser error " << e.what(); + return nullptr; + } } return m.release(); } From 8d47751cb25f3ff151de2643b20a3fdd95290139 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 24 Jan 2020 22:53:14 +0100 Subject: [PATCH 20/22] [libcalamares] Beautify debug output for InstanceKey --- src/libcalamares/CMakeLists.txt | 3 ++ src/libcalamares/modulesystem/InstanceKey.cpp | 46 +++++++++++++++++++ src/libcalamares/modulesystem/InstanceKey.h | 22 ++------- 3 files changed, 54 insertions(+), 17 deletions(-) create mode 100644 src/libcalamares/modulesystem/InstanceKey.cpp diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index ffc2e20b6..8b4233659 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -37,6 +37,9 @@ set( libSources locale/TimeZone.cpp locale/TranslatableConfiguration.cpp + # Modules + modulesystem/InstanceKey.cpp + # Network service network/Manager.cpp diff --git a/src/libcalamares/modulesystem/InstanceKey.cpp b/src/libcalamares/modulesystem/InstanceKey.cpp new file mode 100644 index 000000000..cde921b40 --- /dev/null +++ b/src/libcalamares/modulesystem/InstanceKey.cpp @@ -0,0 +1,46 @@ +/* === This file is part of Calamares - === + * + * Copyright 2014-2015, Teo Mrnjavac + * Copyright 2018-2019, Adriaan de Groot + * + * 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 . + */ +#include "InstanceKey.h" + +namespace Calamares +{ +namespace ModuleSystem +{ + +InstanceKey +InstanceKey::fromString( const QString& s ) +{ + QStringList moduleEntrySplit = s.split( '@' ); + if ( moduleEntrySplit.length() < 1 || moduleEntrySplit.length() > 2 ) + { + return InstanceKey(); + } + // For length 1, first == last + return InstanceKey( moduleEntrySplit.first(), moduleEntrySplit.last() ); +} + + +QDebug& +operator<<( QDebug& s, const Calamares::ModuleSystem::InstanceKey& i ) +{ + return s << i.toString(); +} + +} // namespace ModuleSystem +} // namespace Calamares diff --git a/src/libcalamares/modulesystem/InstanceKey.h b/src/libcalamares/modulesystem/InstanceKey.h index ad0fae0e7..495401903 100644 --- a/src/libcalamares/modulesystem/InstanceKey.h +++ b/src/libcalamares/modulesystem/InstanceKey.h @@ -19,15 +19,9 @@ #ifndef MODULESYSTEM_INSTANCEKEY_H #define MODULESYSTEM_INSTANCEKEY_H -#include +#include #include #include -#include - -namespace Logger -{ -class CLog; -} namespace Calamares { @@ -77,16 +71,7 @@ public: QString id() const { return second; } /// @brief Create instance key from stringified version - static InstanceKey fromString( const QString& s ) - { - QStringList moduleEntrySplit = s.split( '@' ); - if ( moduleEntrySplit.length() < 1 || moduleEntrySplit.length() > 2 ) - { - return InstanceKey(); - } - // For length 1, first == last - return InstanceKey( moduleEntrySplit.first(), moduleEntrySplit.last() ); - } + static InstanceKey fromString( const QString& s ); QString toString() const { @@ -109,6 +94,9 @@ private: } }; +QDebug& +operator <<( QDebug& s, const Calamares::ModuleSystem::InstanceKey& i ); + } // namespace ModuleSystem } // namespace Calamares From cdd2b9cc799eee0e9b7474dfcb1a80bae6b1fa24 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 24 Jan 2020 23:10:41 +0100 Subject: [PATCH 21/22] Modules: set noconfig:true on Python modules - hwclock, initramfs, localecfg and networkcfg don't have any config file to work with, so set that explicitly in the module.desc --- src/modules/hwclock/module.desc | 1 + src/modules/initramfscfg/module.desc | 1 + src/modules/localecfg/module.desc | 1 + src/modules/networkcfg/module.desc | 1 + 4 files changed, 4 insertions(+) diff --git a/src/modules/hwclock/module.desc b/src/modules/hwclock/module.desc index dd0e1b2d4..47d1b6c14 100644 --- a/src/modules/hwclock/module.desc +++ b/src/modules/hwclock/module.desc @@ -4,3 +4,4 @@ name: "hwclock" interface: "python" requires: [] script: "main.py" +noconfig: true diff --git a/src/modules/initramfscfg/module.desc b/src/modules/initramfscfg/module.desc index 6227c2e25..c00e8170f 100644 --- a/src/modules/initramfscfg/module.desc +++ b/src/modules/initramfscfg/module.desc @@ -3,3 +3,4 @@ type: "job" name: "initramfscfg" interface: "python" script: "main.py" +noconfig: true diff --git a/src/modules/localecfg/module.desc b/src/modules/localecfg/module.desc index 815480562..4b8cd9e6d 100644 --- a/src/modules/localecfg/module.desc +++ b/src/modules/localecfg/module.desc @@ -6,3 +6,4 @@ type: "job" name: "localecfg" interface: "python" script: "main.py" +noconfig: true diff --git a/src/modules/networkcfg/module.desc b/src/modules/networkcfg/module.desc index 2377972b8..c02305db2 100644 --- a/src/modules/networkcfg/module.desc +++ b/src/modules/networkcfg/module.desc @@ -4,3 +4,4 @@ name: "networkcfg" interface: "python" requires: [] script: "main.py" +noconfig: true From c555369766e929a4dc71ac1c12f0bf2e145d33a8 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 24 Jan 2020 23:18:46 +0100 Subject: [PATCH 22/22] Changes: document new *noconfig* behavior --- CHANGES | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES b/CHANGES index 42a0b8c51..b0dfea3bb 100644 --- a/CHANGES +++ b/CHANGES @@ -18,6 +18,11 @@ This release contains contributions from (alphabetically by first name): `branding.desc` specifies *center* or *free* placement. ## Modules ## + - All modules can now set a new key in `module.desc` called *noconfig*. + If this key is set to `true` (the default is `false), no configuration + file is searched-for or loaded, and no warning is printed if the + configuration is missing. This should tidy up some unnecessary warnings + on startup. #1302 #1301 - The *license* module has seen a significant change to its looks. Actions are now labeled more clearly, and the URL (or filename) for each license is displayed.