diff --git a/AUTHORS b/AUTHORS index f39b579f4..a1c1bae5b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,2 +1,24 @@ -Teo Mrnjavac -Adriaan de Groot +# MAINTAINER + +Teo Mrnjavac (maintainer -2017) +Adriaan de Groot (maintainer 2017-) + +# CONTRIBUTORS + +Alf Gaida +Allen Welkie +Andrius Štikonas +Bernhard Landauer +Bezzy1999 +bill-auger +crispg72 +demmm +Gabriel Craciunescu +Kai Dohmen +Kevin Kofler +Kyle Robertze +Lisa Vitolo +n3rdopolis +Philip Müller +Ramon Buldó +Rohan Garg diff --git a/CMakeModules/FindPythonQt.cmake b/CMakeModules/FindPythonQt.cmake index d016b57b1..8de40853f 100644 --- a/CMakeModules/FindPythonQt.cmake +++ b/CMakeModules/FindPythonQt.cmake @@ -9,6 +9,20 @@ if(NOT PYTHONLIBS_FOUND) message(FATAL_ERROR "error: Python is required to build PythonQt") endif() +# Cut X.Y[.Z] down to just X.Y +string(REGEX REPLACE + "^([0-9][0-9]*)\.([0-9][0-9]*)" + "\\1.\\2@" + _PYTHONLIBS_MAJMIN + ${PYTHONLIBS_VERSION_STRING} +) +string(REGEX REPLACE + "@.*" + "" + PYTHONLIBS_MAJMIN + ${_PYTHONLIBS_MAJMIN} +) + if(NOT EXISTS "${PYTHONQT_INSTALL_DIR}") find_path(PYTHONQT_INSTALL_DIR include/PythonQt/PythonQt.h DOC "Directory where PythonQt was installed.") endif() @@ -22,17 +36,58 @@ find_path(PYTHONQT_INCLUDE_DIR PythonQt.h "${PYTHONQT_INSTALL_DIR}/src" DOC "Path to the PythonQt include directory") -# Minimum v3.1 is needed -find_library(PYTHONQT_LIBRARY_RELEASE PythonQt PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "The PythonQt library.") -find_library(PYTHONQT_LIBRARY_DEBUG NAMES PythonQt${CTK_CMAKE_DEBUG_POSTFIX} PythonQt${CMAKE_DEBUG_POSTFIX} PythonQt PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "The PythonQt library.") -find_library(PYTHONQT_QTALL_LIBRARY_RELEASE PythonQt_QtAll PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "Full Qt bindings for the PythonQt library.") -find_library(PYTHONQT_QTALL_LIBRARY_DEBUG NAMES PythonQt_QtAll${CTK_CMAKE_DEBUG_POSTFIX} PythonQt_QtAll${CMAKE_DEBUG_POSTFIX} PythonQt_QtAll PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "Full Qt bindings for the PythonQt library.") +if ( NOT PythonQt_FIND_QUIETLY ) + message( STATUS "Searching for PythonQt (PythonLibs ${PYTHONLIBS_MAJMIN}) .." ) + if ( PYTHONQT_INCLUDE_DIR ) + message( STATUS " .. found include ${PYTHONQT_INCLUDE_DIR}" ) + endif() +endif() -# Also check for v3.2+ -find_library(PYTHONQT_LIBRARY_RELEASE PythonQt-Qt5-Python3 PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "The PythonQt library.") -find_library(PYTHONQT_LIBRARY_DEBUG NAMES PythonQt-Qt5-Python3${CTK_CMAKE_DEBUG_POSTFIX} PythonQt-Qt5-Python3${CMAKE_DEBUG_POSTFIX} PythonQt-Qt5-Python3 PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "The PythonQt library.") -find_library(PYTHONQT_QTALL_LIBRARY_RELEASE PythonQt_QtAll-Qt5-Python3 PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "Full Qt bindings for the PythonQt library.") -find_library(PYTHONQT_QTALL_LIBRARY_DEBUG NAMES PythonQt_QtAll-Qt5-Python3${CTK_CMAKE_DEBUG_POSTFIX} PythonQt_QtAll-Qt5-Python3${CMAKE_DEBUG_POSTFIX} PythonQt_QtAll-Qt5-Python3 PATHS "${PYTHONQT_INSTALL_DIR}/lib" DOC "Full Qt bindings for the PythonQt library.") +# Minimum v3.1 is needed +find_library(PYTHONQT_LIBRARY_RELEASE + NAMES + PythonQt-Qt5-Python${PYTHONLIBS_MAJMIN} + PythonQt-Qt5-Python3 + PythonQt + PATHS "${PYTHONQT_INSTALL_DIR}/lib" + DOC "The PythonQt library." +) +find_library(PYTHONQT_LIBRARY_DEBUG + NAMES + PythonQt-Qt5-Python${PYTHONLIBS_MAJMIN}JMIN${CTK_CMAKE_DEBUG_POSTFIX} + PythonQt-Qt5-Python${PYTHONLIBS_MAJMIN}${CMAKE_DEBUG_POSTFIX} + PythonQt-Qt5-Python${PYTHONLIBS_MAJMIN} + PythonQt-Qt5-Python3${CTK_CMAKE_DEBUG_POSTFIX} + PythonQt-Qt5-Python3${CMAKE_DEBUG_POSTFIX} + PythonQt-Qt5-Python3 + PythonQt${CTK_CMAKE_DEBUG_POSTFIX} + PythonQt${CMAKE_DEBUG_POSTFIX} + PythonQt + PATHS "${PYTHONQT_INSTALL_DIR}/lib" + DOC "The PythonQt library (debug build)." +) +find_library(PYTHONQT_QTALL_LIBRARY_RELEASE + NAMES + PythonQt_QtAll-Qt5-Python${PYTHONLIBS_MAJMIN} + PythonQt_QtAll-Qt5-Python3 + PythonQt_QtAll + PATHS "${PYTHONQT_INSTALL_DIR}/lib" + DOC "Full Qt bindings for the PythonQt library." +) +find_library(PYTHONQT_QTALL_LIBRARY_DEBUG + NAMES + PythonQt_QtAll-Qt5-Python${PYTHONLIBS_MAJMIN}${CTK_CMAKE_DEBUG_POSTFIX} + PythonQt_QtAll-Qt5-Python${PYTHONLIBS_MAJMIN}${CMAKE_DEBUG_POSTFIX} + PythonQt_QtAll-Qt5-Python${PYTHONLIBS_MAJMIN} + PythonQt_QtAll-Qt5-Python3${CTK_CMAKE_DEBUG_POSTFIX} + PythonQt_QtAll-Qt5-Python3${CMAKE_DEBUG_POSTFIX} + PythonQt_QtAll-Qt5-Python3 + PythonQt_QtAll${CTK_CMAKE_DEBUG_POSTFIX} + PythonQt_QtAll${CMAKE_DEBUG_POSTFIX} + PythonQt_QtAll + PATHS "${PYTHONQT_INSTALL_DIR}/lib" + DOC "Full Qt bindings for the PythonQt library (debug build)." +) set(PYTHONQT_LIBRARY) if(PYTHONQT_LIBRARY_RELEASE) @@ -50,6 +105,16 @@ if(PYTHONQT_QTALL_LIBRARY_DEBUG) list(APPEND PYTHONQT_QTALL_LIBRARY debug ${PYTHONQT_QTALL_LIBRARY_DEBUG}) endif() +if ( NOT PythonQt_FIND_QUIETLY ) + if ( PYTHONQT_LIBRARY ) + message( STATUS " .. found library ${PYTHONQT_LIBRARY}" ) + endif() + if ( PYTHONQT_QTALL_LIBRARY ) + message( STATUS " .. found qtall ${PYTHONQT_QTALL_LIBRARY}" ) + endif() +endif() + + mark_as_advanced(PYTHONQT_INSTALL_DIR) mark_as_advanced(PYTHONQT_INCLUDE_DIR) mark_as_advanced(PYTHONQT_LIBRARY_RELEASE) diff --git a/ci/HACKING.md b/ci/HACKING.md index 92d1a5a48..4d84fc33d 100644 --- a/ci/HACKING.md +++ b/ci/HACKING.md @@ -1,9 +1,15 @@ Hacking on Calamares ==================== +These are the guidelines for hacking on Calamares. Except for the licensing, +which **must** be GPLv3+, these are guidelines and -- like PEP8 -- the most +important thing is to know when you can ignore them. + + Licensing --------- -Calamares is released under the terms of the GNU GPL, version 3 or later. Every source file must have a license header, with a list of copyright holders and years. +Calamares is released under the terms of the GNU GPL, version 3 or later. +Every source file must have a license header, with a list of copyright holders and years. Example: ``` @@ -34,9 +40,9 @@ organization, etc. Please add your name to files you touch when making any contribution (even if it's just a typo-fix which might not be copyrightable in all jurisdictions). -Formatting ----------- +Formatting C++ +-------------- This formatting guide applies to C++ code only; for Python modules, we use [pycodestyle][https://github.com/PyCQA/pycodestyle] to apply a check of some PEP8 guidelines. @@ -48,10 +54,10 @@ some PEP8 guidelines. * No space before brackets, except for keywords, for example `function( argument )` but `if ( condition )`. * For pointer and reference variable declarations, put a space before the variable name - and no space between the type and the `*` or `&`. -* `for`, `if`, `else`, `while` and similar statements put the brackets on the next line, - although brackets are not needed for single statements. -* Function and class definitions have their brackets on separate lines. + and no space between the type and the `*` or `&`, e.g. `int* p`. +* `for`, `if`, `else`, `while` and similar statements put the braces on the next line, + if the following block is more than one statement. Use no braces for single statements. +* Function and class definitions have their braces on separate lines. * A function implementation's return type is on its own line. * `CamelCase.{cpp,h}` style file names. @@ -63,8 +69,9 @@ MyClass::myMethod( QStringList list, const QString& name ) if ( list.isEmpty() ) return false; + cDebug() << "Items in list .."; foreach ( const QString& string, list ) - cDebug() << "Current string is " << string; + cDebug() << " .." << string; switch ( m_enumValue ) { @@ -77,7 +84,7 @@ MyClass::myMethod( QStringList list, const QString& name ) } ``` -You can use the `hacking/calamaresstyle` script to run +You can use the `ci/calamaresstyle` script to run [astyle](http://astyle.sf.net) on your code and have it formatted the right way. @@ -85,6 +92,7 @@ way. order to take advantage of this functionality you will need to acquire the [EditorConfig](http://editorconfig.org/#download) plug-in for your editor. + Naming ------ * Use CamelCase for everything. @@ -97,6 +105,7 @@ Naming * If it's a getter for a boolean, prefix with 'is', so `isCondition()`. * A setter is `setVariable( arg )`. + Includes -------- Header includes should be listed in the following order: @@ -109,8 +118,9 @@ Header includes should be listed in the following order: They should also be sorted alphabetically for ease of locating them. -Includes in a header file should be kept to the absolute minimum, as to keep compile times short. This can be achieved by using forward declarations instead of includes, -like `class QListView;`. +Includes in a header file should be kept to the absolute minimum, as to keep +compile times short. This can be achieved by using forward declarations +instead of includes, like `class QListView;`. Example: ``` @@ -129,6 +139,7 @@ Example: Use include guards, not `#pragma once`. + C++ tips -------- All C++11 features are acceptable, and the use of new C++11 features is encouraged when @@ -141,8 +152,8 @@ range-based `for` syntax introduced with C++11 is preferred ([see this blog post When re-implementing a virtual method, always add the `override` keyword. -Try to keep your code const correct. Declare methods const if they don't mutate the -object, and use const variables. It improves safety, and also makes it easier to +Try to keep your code const correct. Declare methods const if they don't mutate the +object, and use const variables. It improves safety, and also makes it easier to understand the code. For the Qt signal-slot system, the new (Qt5) syntax is to be preferred because it allows @@ -160,10 +171,31 @@ connect( m_moduleManager, &Calamares::ModuleManager::modulesLoaded, [this] }); ``` +[1]: http://blog.qt.digia.com/blog/2011/05/26/cpp0x-in-qt/ +[2]: http://qt-project.org/wiki/New_Signal_Slot_Syntax + + Debugging --------- -Use `cDebug()` and `cLog()` from `utils/Logger.h`. +Use `cDebug()` and `cLog()` from `utils/Logger.h`. You can pass a debug-level to +either macro (1 is debugging, higher is less important). Use `cLog()` for warning +messages. It is recommended to add *WARNING* as the first part of a warning +message. +For log messages that are continued across multiple calls to `cDebug()`, +in particular listing things, conventional formatting is as follows: +* End the first debug message with ` ..` +* Indent following lines with ` ..` -[1]: http://blog.qt.digia.com/blog/2011/05/26/cpp0x-in-qt/ -[2]: http://qt-project.org/wiki/New_Signal_Slot_Syntax + +Commit Messages +--------------- +Keep commit messages short(-ish) and try to describe what is being changed +*as well as why*. Use the commit keywords for GitHub, especially *FIXES:* +to auto-close issues when they are resolved. + +For functional changes to Calamares modules or libraries, try to put +*[modulename]* in front of the first line of the commit message. + +For non-functional changes to infrastructure, try to label the change +with the kind of change, e.g. *CMake* or *i18n* or *Documentation*. diff --git a/src/libcalamares/JobQueue.cpp b/src/libcalamares/JobQueue.cpp index a1badcf86..86e33a0cd 100644 --- a/src/libcalamares/JobQueue.cpp +++ b/src/libcalamares/JobQueue.cpp @@ -46,7 +46,7 @@ public: #endif } - void setJobs( const QList< job_ptr >& jobs ) + void setJobs( const JobList& jobs ) { m_jobs = jobs; } @@ -73,7 +73,7 @@ public: } private: - QList< job_ptr > m_jobs; + JobList m_jobs; JobQueue* m_queue; int m_jobIndex; @@ -164,7 +164,7 @@ JobQueue::enqueue( const job_ptr& job ) void -JobQueue::enqueue( const QList< job_ptr >& jobs ) +JobQueue::enqueue( const JobList& jobs ) { Q_ASSERT( !m_thread->isRunning() ); m_jobs.append( jobs ); diff --git a/src/libcalamares/JobQueue.h b/src/libcalamares/JobQueue.h index 903783d53..2c1b85ed5 100644 --- a/src/libcalamares/JobQueue.h +++ b/src/libcalamares/JobQueue.h @@ -42,11 +42,11 @@ public: GlobalStorage* globalStorage() const; void enqueue( const job_ptr& job ); - void enqueue( const QList< job_ptr >& jobs ); + void enqueue( const JobList& jobs ); void start(); signals: - void queueChanged( const QList< job_ptr >& jobs ); + void queueChanged( const JobList& jobs ); void progress( qreal percent, const QString& prettyName ); void finished(); void failed( const QString& message, const QString& details ); @@ -54,7 +54,7 @@ signals: private: static JobQueue* s_instance; - QList< job_ptr > m_jobs; + JobList m_jobs; JobThread* m_thread; GlobalStorage* m_storage; }; diff --git a/src/libcalamares/Typedefs.h b/src/libcalamares/Typedefs.h index 8aefcd6af..4ff28e3d7 100644 --- a/src/libcalamares/Typedefs.h +++ b/src/libcalamares/Typedefs.h @@ -19,6 +19,7 @@ #ifndef TYPEDEFS_H #define TYPEDEFS_H +#include #include namespace Calamares @@ -26,6 +27,7 @@ namespace Calamares class Job; typedef QSharedPointer< Job > job_ptr; +using JobList = QList< job_ptr >; enum ModuleAction : char { diff --git a/src/libcalamares/utils/CalamaresUtils.cpp b/src/libcalamares/utils/CalamaresUtils.cpp index db748ec94..ae3a14497 100644 --- a/src/libcalamares/utils/CalamaresUtils.cpp +++ b/src/libcalamares/utils/CalamaresUtils.cpp @@ -326,5 +326,35 @@ crash() *a = 1; } +bool +getBool( const QVariantMap& map, const QString& key, bool d ) +{ + bool result = d; + if ( map.contains( key ) ) + { + auto v = map.value( key ); + if ( v.type() == QVariant::Bool ) + result = v.toBool(); + } + + return result; +} + +QVariantMap +getSubMap( const QVariantMap& map, const QString& key, bool& success ) +{ + success = false; + + if ( map.contains( key ) ) + { + auto v = map.value( key ); + if ( v.type() == QVariant::Map ) + { + success = true; + return v.toMap(); + } + } + return QVariantMap(); +} } diff --git a/src/libcalamares/utils/CalamaresUtils.h b/src/libcalamares/utils/CalamaresUtils.h index 66650ff57..651c6746a 100644 --- a/src/libcalamares/utils/CalamaresUtils.h +++ b/src/libcalamares/utils/CalamaresUtils.h @@ -97,6 +97,22 @@ namespace CalamaresUtils * @brief crash makes Calamares crash immediately. */ DLLEXPORT void crash(); + + /** + * Get a bool value from a mapping with a given key; returns the default + * if no value is stored in the map. + */ + DLLEXPORT bool getBool( const QVariantMap& map, const QString& key, bool d ); + + /** + * Returns a sub-map (i.e. a nested map) from the given mapping with the + * given key. @p success is set to true if the @p key exists + * in @p map and converts to a map, false otherwise. + * + * Returns an empty map if there is no such key or it is not a map-value. + * (e.g. if @p success is false). + */ + DLLEXPORT QVariantMap getSubMap( const QVariantMap& map, const QString& key, bool& success ); } #endif // CALAMARESUTILS_H diff --git a/src/libcalamaresui/ExecutionViewStep.cpp b/src/libcalamaresui/ExecutionViewStep.cpp index 37c2318d0..4c813bbca 100644 --- a/src/libcalamaresui/ExecutionViewStep.cpp +++ b/src/libcalamaresui/ExecutionViewStep.cpp @@ -148,10 +148,10 @@ ExecutionViewStep::onActivate() } -QList< Calamares::job_ptr > +JobList ExecutionViewStep::jobs() const { - return QList< Calamares::job_ptr >(); + return JobList(); } diff --git a/src/libcalamaresui/ExecutionViewStep.h b/src/libcalamaresui/ExecutionViewStep.h index 3101cf479..05b26a436 100644 --- a/src/libcalamaresui/ExecutionViewStep.h +++ b/src/libcalamaresui/ExecutionViewStep.h @@ -52,7 +52,7 @@ public: void onActivate() override; - QList< job_ptr > jobs() const override; + JobList jobs() const override; void appendJobModuleInstanceKey( const QString& instanceKey ); diff --git a/src/libcalamaresui/modulesystem/CppJobModule.cpp b/src/libcalamaresui/modulesystem/CppJobModule.cpp index 6ff846027..e6240b4c9 100644 --- a/src/libcalamaresui/modulesystem/CppJobModule.cpp +++ b/src/libcalamaresui/modulesystem/CppJobModule.cpp @@ -75,10 +75,10 @@ CppJobModule::loadSelf() } -QList< job_ptr > +JobList CppJobModule::jobs() const { - return QList< job_ptr >() << m_job; + return JobList() << m_job; } diff --git a/src/libcalamaresui/modulesystem/CppJobModule.h b/src/libcalamaresui/modulesystem/CppJobModule.h index 46d27bf8b..89cf19e06 100644 --- a/src/libcalamaresui/modulesystem/CppJobModule.h +++ b/src/libcalamaresui/modulesystem/CppJobModule.h @@ -36,7 +36,7 @@ public: Interface interface() const override; void loadSelf() override; - QList< job_ptr > jobs() const override; + JobList jobs() const override; protected: void initFrom( const QVariantMap& moduleDescriptor ) override; diff --git a/src/libcalamaresui/modulesystem/Module.h b/src/libcalamaresui/modulesystem/Module.h index 5f756938f..71390fa83 100644 --- a/src/libcalamaresui/modulesystem/Module.h +++ b/src/libcalamaresui/modulesystem/Module.h @@ -70,7 +70,6 @@ public: ProcessInterface, PythonQtInterface }; - virtual ~Module(); /** * @brief fromDescriptor creates a new Module object of the correct type. @@ -84,6 +83,7 @@ public: const QString& instanceId, const QString& configFileName, const QString& moduleDirectory ); + virtual ~Module(); /** * @brief name returns the name of this module. @@ -159,7 +159,7 @@ public: * @brief jobs returns any jobs exposed by this module. * @return a list of jobs (can be empty). */ - virtual QList< job_ptr > jobs() const = 0; + virtual JobList jobs() const = 0; /** * @brief configurationMap returns the contents of the configuration file for diff --git a/src/libcalamaresui/modulesystem/ProcessJobModule.cpp b/src/libcalamaresui/modulesystem/ProcessJobModule.cpp index aefcbf6f0..989385a18 100644 --- a/src/libcalamaresui/modulesystem/ProcessJobModule.cpp +++ b/src/libcalamaresui/modulesystem/ProcessJobModule.cpp @@ -53,10 +53,10 @@ ProcessJobModule::loadSelf() } -QList< job_ptr > +JobList ProcessJobModule::jobs() const { - return QList< job_ptr >() << m_job; + return JobList() << m_job; } diff --git a/src/libcalamaresui/modulesystem/ProcessJobModule.h b/src/libcalamaresui/modulesystem/ProcessJobModule.h index af9a46bd5..d2c8ba905 100644 --- a/src/libcalamaresui/modulesystem/ProcessJobModule.h +++ b/src/libcalamaresui/modulesystem/ProcessJobModule.h @@ -34,7 +34,7 @@ public: Interface interface() const override; void loadSelf() override; - QList< job_ptr > jobs() const override; + JobList jobs() const override; protected: void initFrom( const QVariantMap& moduleDescriptor ) override; diff --git a/src/libcalamaresui/modulesystem/PythonJobModule.cpp b/src/libcalamaresui/modulesystem/PythonJobModule.cpp index 544f27e1f..3c0a8234e 100644 --- a/src/libcalamaresui/modulesystem/PythonJobModule.cpp +++ b/src/libcalamaresui/modulesystem/PythonJobModule.cpp @@ -53,10 +53,10 @@ PythonJobModule::loadSelf() } -QList< job_ptr > +JobList PythonJobModule::jobs() const { - return QList< job_ptr >() << m_job; + return JobList() << m_job; } diff --git a/src/libcalamaresui/modulesystem/PythonJobModule.h b/src/libcalamaresui/modulesystem/PythonJobModule.h index c82137cb8..b5ae34c07 100644 --- a/src/libcalamaresui/modulesystem/PythonJobModule.h +++ b/src/libcalamaresui/modulesystem/PythonJobModule.h @@ -32,7 +32,7 @@ public: Interface interface() const override; void loadSelf() override; - QList< job_ptr > jobs() const override; + JobList jobs() const override; protected: void initFrom( const QVariantMap& moduleDescriptor ) override; diff --git a/src/libcalamaresui/modulesystem/PythonQtViewModule.cpp b/src/libcalamaresui/modulesystem/PythonQtViewModule.cpp index 96a1ce71c..f4fae4398 100644 --- a/src/libcalamaresui/modulesystem/PythonQtViewModule.cpp +++ b/src/libcalamaresui/modulesystem/PythonQtViewModule.cpp @@ -171,7 +171,7 @@ PythonQtViewModule::loadSelf() } -QList< job_ptr > +JobList PythonQtViewModule::jobs() const { return m_viewStep->jobs(); diff --git a/src/libcalamaresui/modulesystem/PythonQtViewModule.h b/src/libcalamaresui/modulesystem/PythonQtViewModule.h index ba18cfac6..06de7c6e9 100644 --- a/src/libcalamaresui/modulesystem/PythonQtViewModule.h +++ b/src/libcalamaresui/modulesystem/PythonQtViewModule.h @@ -33,7 +33,7 @@ public: Interface interface() const override; void loadSelf() override; - QList< job_ptr > jobs() const override; + JobList jobs() const override; protected: void initFrom( const QVariantMap& moduleDescriptor ) override; diff --git a/src/libcalamaresui/modulesystem/ViewModule.cpp b/src/libcalamaresui/modulesystem/ViewModule.cpp index ba054a8b1..419cad611 100644 --- a/src/libcalamaresui/modulesystem/ViewModule.cpp +++ b/src/libcalamaresui/modulesystem/ViewModule.cpp @@ -76,7 +76,7 @@ ViewModule::loadSelf() } -QList< job_ptr > +JobList ViewModule::jobs() const { return m_viewStep->jobs(); diff --git a/src/libcalamaresui/modulesystem/ViewModule.h b/src/libcalamaresui/modulesystem/ViewModule.h index 6b2e381a2..323315947 100644 --- a/src/libcalamaresui/modulesystem/ViewModule.h +++ b/src/libcalamaresui/modulesystem/ViewModule.h @@ -37,7 +37,7 @@ public: Interface interface() const override; void loadSelf() override; - QList< job_ptr > jobs() const override; + JobList jobs() const override; protected: void initFrom( const QVariantMap& moduleDescriptor ) override; diff --git a/src/libcalamaresui/utils/DebugWindow.cpp b/src/libcalamaresui/utils/DebugWindow.cpp index d4bc74f65..e00c2097b 100644 --- a/src/libcalamaresui/utils/DebugWindow.cpp +++ b/src/libcalamaresui/utils/DebugWindow.cpp @@ -62,7 +62,7 @@ DebugWindow::DebugWindow() // JobQueue page jobQueueText->setReadOnly( true ); connect( JobQueue::instance(), &JobQueue::queueChanged, - this, [ this ]( const QList< Calamares::job_ptr >& jobs ) + this, [ this ]( const JobList& jobs ) { QStringList text; for ( const auto &job : jobs ) diff --git a/src/libcalamaresui/viewpages/PythonQtViewStep.cpp b/src/libcalamaresui/viewpages/PythonQtViewStep.cpp index 78881e337..f5f84eadd 100644 --- a/src/libcalamaresui/viewpages/PythonQtViewStep.cpp +++ b/src/libcalamaresui/viewpages/PythonQtViewStep.cpp @@ -159,10 +159,10 @@ PythonQtViewStep::isAtEnd() const } -QList< Calamares::job_ptr > +JobList PythonQtViewStep::jobs() const { - QList< Calamares::job_ptr > jobs; + JobList jobs; PythonQtObjectPtr jobsCallable = PythonQt::self()->lookupCallable( m_obj, "jobs" ); if ( jobsCallable.isNull() ) diff --git a/src/libcalamaresui/viewpages/PythonQtViewStep.h b/src/libcalamaresui/viewpages/PythonQtViewStep.h index e1f8bd1e5..594af2817 100644 --- a/src/libcalamaresui/viewpages/PythonQtViewStep.h +++ b/src/libcalamaresui/viewpages/PythonQtViewStep.h @@ -46,7 +46,7 @@ public: bool isAtBeginning() const override; bool isAtEnd() const override; - QList< Calamares::job_ptr > jobs() const override; + JobList jobs() const override; void setConfigurationMap( const QVariantMap& configurationMap ) override; diff --git a/src/libcalamaresui/viewpages/ViewStep.h b/src/libcalamaresui/viewpages/ViewStep.h index 617d64fe1..f69f872e2 100644 --- a/src/libcalamaresui/viewpages/ViewStep.h +++ b/src/libcalamaresui/viewpages/ViewStep.h @@ -91,7 +91,7 @@ public: */ virtual void onLeave(); - virtual QList< job_ptr > jobs() const = 0; + virtual JobList jobs() const = 0; void setModuleInstanceKey( const QString& instanceKey ); QString moduleInstanceKey() const diff --git a/src/modules/CMakeLists.txt b/src/modules/CMakeLists.txt index d48ecd29f..680a9c12c 100644 --- a/src/modules/CMakeLists.txt +++ b/src/modules/CMakeLists.txt @@ -3,6 +3,7 @@ include( CMakeColors ) if( BUILD_TESTING ) add_executable( test_conf test_conf.cpp ) target_link_libraries( test_conf ${YAMLCPP_LIBRARY} ) + target_include_directories( test_conf PUBLIC ${YAMLCPP_INCLUDE_DIR} ) endif() file( GLOB SUBDIRECTORIES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*" ) diff --git a/src/modules/locale/LocaleViewStep.cpp b/src/modules/locale/LocaleViewStep.cpp index 4b4219751..73efc266f 100644 --- a/src/modules/locale/LocaleViewStep.cpp +++ b/src/modules/locale/LocaleViewStep.cpp @@ -120,7 +120,7 @@ LocaleViewStep::fetchGeoIpTimezone() try { - YAML::Node doc = YAML::Load( reply->readAll() ); + YAML::Node doc = YAML::Load( data ); QVariant var = CalamaresUtils::yamlToVariant( doc ); if ( !var.isNull() && diff --git a/src/modules/locale/locale.conf b/src/modules/locale/locale.conf index 824c8abeb..fdff51721 100644 --- a/src/modules/locale/locale.conf +++ b/src/modules/locale/locale.conf @@ -1,7 +1,27 @@ --- +# This settings are used to set your default system time zone. +# Time zones are usually located under /usr/share/zoneinfo and +# provided by the 'tzdata' package of your Distribution. +# +# Distributions using systemd can list available +# time zones by using the timedatectl command. +# timedatectl list-timezones region: "America" zone: "New_York" -# GeoIP settings. Leave commented out to disable GeoIP. -#localeGenPath: "/etc/locale.gen" + +# System locales are detected in the following order: +# +# /usr/share/i18n/SUPPORTED +# localeGenPath (defaults to /etc/locale.gen if not set) +# 'locale -a' output +# Enable only when your Distribution is using an +# custom path for locale.gen +#localeGenPath: "PATH_TO/locale.gen" + +# GeoIP based Language settings: +# GeoIP need an working Internet connecion. +# This can be managed from welcome.conf by adding +# internet to the list of required conditions. +# Leave commented out to disable GeoIP. #geoipUrl: "freegeoip.net" diff --git a/src/modules/netinstall/NetInstallPage.cpp b/src/modules/netinstall/NetInstallPage.cpp index 9c16433ec..28c836a79 100644 --- a/src/modules/netinstall/NetInstallPage.cpp +++ b/src/modules/netinstall/NetInstallPage.cpp @@ -57,14 +57,6 @@ NetInstallPage::NetInstallPage( QWidget* parent ) ui->setupUi( this ); } -bool -NetInstallPage::isReady() -{ - // nothing to wait for, the data are immediately ready - // if the user does not select any group nothing is installed - return true; -} - bool NetInstallPage::readGroups( const QByteArray& yamlData ) { @@ -92,10 +84,13 @@ NetInstallPage::readGroups( const QByteArray& yamlData ) void NetInstallPage::dataIsHere( QNetworkReply* reply ) { + // If m_required is *false* then we still say we're ready + // even if the reply is corrupt or missing. if ( reply->error() != QNetworkReply::NoError ) { cDebug() << reply->errorString(); ui->netinst_status->setText( tr( "Network Installation. (Disabled: Unable to fetch package lists, check your network connection)" ) ); + emit checkReady( !m_required ); return; } @@ -104,6 +99,7 @@ NetInstallPage::dataIsHere( QNetworkReply* reply ) cDebug() << "Netinstall groups data was received, but invalid."; ui->netinst_status->setText( tr( "Network Installation. (Disabled: Received invalid groups data)" ) ); reply->deleteLater(); + emit checkReady( !m_required ); return; } @@ -112,15 +108,23 @@ NetInstallPage::dataIsHere( QNetworkReply* reply ) ui->groupswidget->header()->setSectionResizeMode( 1, QHeaderView::Stretch ); reply->deleteLater(); - emit checkReady( isReady() ); + emit checkReady( true ); } -QList NetInstallPage::selectedPackages() const +PackageModel::PackageItemDataList +NetInstallPage::selectedPackages() const { - return m_groups->getPackages(); + if ( m_groups ) + return m_groups->getPackages(); + else + { + cDebug() << "WARNING: no netinstall groups are available."; + return PackageModel::PackageItemDataList(); + } } -void NetInstallPage::loadGroupList() +void +NetInstallPage::loadGroupList() { QString confUrl( Calamares::JobQueue::instance()->globalStorage()->value( @@ -139,7 +143,15 @@ void NetInstallPage::loadGroupList() m_networkManager.get( request ); } -void NetInstallPage::onActivate() +void +NetInstallPage::setRequired( bool b ) +{ + m_required = b; +} + + +void +NetInstallPage::onActivate() { ui->groupswidget->setFocus(); } diff --git a/src/modules/netinstall/NetInstallPage.h b/src/modules/netinstall/NetInstallPage.h index 423c16b8e..58308412d 100644 --- a/src/modules/netinstall/NetInstallPage.h +++ b/src/modules/netinstall/NetInstallPage.h @@ -46,17 +46,24 @@ public: void onActivate(); - bool isReady(); - // Retrieves the groups, with name, description and packages, from // the remote URL configured in the settings. Assumes the URL is already // in the global storage. This should be called before displaying the page. void loadGroupList(); + // Sets the "required" state of netinstall data. Influences whether + // corrupt or unavailable data causes checkReady() to be emitted + // true (not-required) or false. + void setRequired( bool ); + bool getRequired() const + { + return m_required; + } + // Returns the list of packages belonging to groups that are // selected in the view in this given moment. No data is cached here, so // this function does not have constant time. - QList selectedPackages() const; + PackageModel::PackageItemDataList selectedPackages() const; public slots: void dataIsHere( QNetworkReply* ); @@ -76,6 +83,7 @@ private: QNetworkAccessManager m_networkManager; PackageModel* m_groups; + bool m_required; }; #endif // NETINSTALLPAGE_H diff --git a/src/modules/netinstall/NetInstallViewStep.cpp b/src/modules/netinstall/NetInstallViewStep.cpp index 347b2bf27..50e08486b 100644 --- a/src/modules/netinstall/NetInstallViewStep.cpp +++ b/src/modules/netinstall/NetInstallViewStep.cpp @@ -2,6 +2,7 @@ * Copyright 2016, Luca Giambonini * Copyright 2016, Lisa Vitolo * Copyright 2017, Kyle Robbertze + * Copyright 2017, 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 @@ -30,11 +31,11 @@ CALAMARES_PLUGIN_FACTORY_DEFINITION( NetInstallViewStepFactory, registerPlugin packages = m_widget->selectedPackages(); + PackageModel::PackageItemDataList packages = m_widget->selectedPackages(); QVariantList installPackages; QVariantList tryInstallPackages; QVariantList packageOperations; @@ -138,7 +139,7 @@ NetInstallViewStep::onLeave() QVariant details( package.packageName ); // If it's a package with a pre- or post-script, replace // with the more complicated datastructure. - if (!package.preScript.isEmpty() || !package.postScript.isEmpty()) + if ( !package.preScript.isEmpty() || !package.postScript.isEmpty() ) { QMap sdetails; sdetails.insert( "pre-script", package.preScript ); @@ -156,14 +157,14 @@ NetInstallViewStep::onLeave() { QMap op; op.insert( "install", QVariant( installPackages ) ); - packageOperations.append(op); + packageOperations.append( op ); cDebug() << " .." << installPackages.length() << "critical packages."; } if ( !tryInstallPackages.empty() ) { QMap op; op.insert( "try_install", QVariant( tryInstallPackages ) ); - packageOperations.append(op); + packageOperations.append( op ); cDebug() << " .." << tryInstallPackages.length() << "non-critical packages."; } @@ -178,6 +179,11 @@ NetInstallViewStep::onLeave() void NetInstallViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { + m_widget->setRequired( + configurationMap.contains( "required" ) && + configurationMap.value( "required" ).type() == QVariant::Bool && + configurationMap.value( "required" ).toBool() ); + if ( configurationMap.contains( "groupsUrl" ) && configurationMap.value( "groupsUrl" ).type() == QVariant::String ) { @@ -186,3 +192,10 @@ NetInstallViewStep::setConfigurationMap( const QVariantMap& configurationMap ) m_widget->loadGroupList(); } } + +void +NetInstallViewStep::nextIsReady( bool b ) +{ + m_nextEnabled = b; + emit nextStatusChanged( b ); +} diff --git a/src/modules/netinstall/NetInstallViewStep.h b/src/modules/netinstall/NetInstallViewStep.h index d9853f26f..ee53f61ce 100644 --- a/src/modules/netinstall/NetInstallViewStep.h +++ b/src/modules/netinstall/NetInstallViewStep.h @@ -60,6 +60,9 @@ public: void setConfigurationMap( const QVariantMap& configurationMap ) override; +public slots: + void nextIsReady( bool ); + private: NetInstallPage* m_widget; bool m_nextEnabled; diff --git a/src/modules/netinstall/PackageModel.h b/src/modules/netinstall/PackageModel.h index 148bd99ab..06d6c0ca1 100644 --- a/src/modules/netinstall/PackageModel.h +++ b/src/modules/netinstall/PackageModel.h @@ -1,3 +1,4 @@ + /* === This file is part of Calamares - === * * Copyright (c) 2017, Kyle Robbertze @@ -28,14 +29,13 @@ #include -// Required forward declarations -class PackageTreeItem; - class PackageModel : public QAbstractItemModel { Q_OBJECT public: + using PackageItemDataList = QList< PackageTreeItem::ItemData >; + explicit PackageModel( const YAML::Node& data, QObject* parent = nullptr ); ~PackageModel() override; @@ -52,7 +52,7 @@ public: QModelIndex parent( const QModelIndex& index ) const override; int rowCount( const QModelIndex& parent = QModelIndex() ) const override; int columnCount( const QModelIndex& parent = QModelIndex() ) const override; - QList getPackages() const; + PackageItemDataList getPackages() const; QList getItemPackages( PackageTreeItem* item ) const; private: diff --git a/src/modules/netinstall/netinstall.conf b/src/modules/netinstall/netinstall.conf index b87aef43e..f5977a267 100644 --- a/src/modules/netinstall/netinstall.conf +++ b/src/modules/netinstall/netinstall.conf @@ -1,2 +1,13 @@ --- +# This is the URL that is retrieved to get the netinstall groups-and-packages +# data (which should be in the format described in netinstall.yaml). groupsUrl: http://chakraos.org/netinstall.php + +# If the installation can proceed without netinstall (e.g. the Live CD +# can create a working installed system, but netinstall is preferred +# to bring it up-to-date or extend functionality) leave this set to +# false (the default). If set to true, the netinstall data is required. +# +# This only has an effect if the netinstall data cannot be retrieved, +# or is corrupt: having "required" set, means the install cannot proceed. +required: false