From 105e06798e974141ed2c9e343a23704e635671b2 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 31 Oct 2017 08:25:57 -0400 Subject: [PATCH 01/35] CMake: look for ECM at top-level, add to search path if found. --- CMakeLists.txt | 10 ++++++++++ src/modules/interactiveterminal/CMakeLists.txt | 3 +-- src/modules/partition/CMakeLists.txt | 3 +-- src/modules/users/CMakeLists.txt | 3 +-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aa0d9016b..fccecb539 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,6 +114,16 @@ find_package( Qt5 ${QT_VERSION} CONFIG REQUIRED Core Gui Widgets LinguistTools S find_package( YAMLCPP 0.5.1 REQUIRED ) find_package( PolkitQt5-1 REQUIRED ) +# Find ECM once, and add it to the module search path; Calamares +# modules that need ECM can do +# find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE), +# no need to mess with the module path after. +set( ECM_VERSION 5.10.0 ) +find_package(ECM ${ECM_VERSION} NO_MODULE) +if( ECM_FOUND ) + set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH}) +endif() + option( INSTALL_CONFIG "Install configuration files" ON ) option( WITH_PYTHON "Enable Python modules API (requires Boost.Python)." ON ) option( WITH_PYTHONQT "Enable next generation Python modules API (experimental, requires PythonQt)." OFF ) diff --git a/src/modules/interactiveterminal/CMakeLists.txt b/src/modules/interactiveterminal/CMakeLists.txt index 04c5406ce..d419a22a7 100644 --- a/src/modules/interactiveterminal/CMakeLists.txt +++ b/src/modules/interactiveterminal/CMakeLists.txt @@ -1,5 +1,4 @@ -find_package(ECM 5.10.0 REQUIRED NO_MODULE) -set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH}) +find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE) include(KDEInstallDirs) include(GenerateExportHeader) diff --git a/src/modules/partition/CMakeLists.txt b/src/modules/partition/CMakeLists.txt index a60801531..9c67e6aca 100644 --- a/src/modules/partition/CMakeLists.txt +++ b/src/modules/partition/CMakeLists.txt @@ -1,5 +1,4 @@ -find_package(ECM 5.10.0 REQUIRED NO_MODULE) -set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH}) +find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE) include(KDEInstallDirs) include(GenerateExportHeader) diff --git a/src/modules/users/CMakeLists.txt b/src/modules/users/CMakeLists.txt index 074118d54..ebff9df8c 100644 --- a/src/modules/users/CMakeLists.txt +++ b/src/modules/users/CMakeLists.txt @@ -1,6 +1,5 @@ -find_package(ECM 5.10.0 NO_MODULE) +find_package(ECM ${ECM_VERSION} NO_MODULE) if( ECM_FOUND ) - set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH}) include( ECMAddTests ) endif() From 6c873f0b703144267f6236a4096ca4fe56a5c002 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 31 Oct 2017 08:26:23 -0400 Subject: [PATCH 02/35] [plasmalnf] Initial stub module --- src/modules/plasmalnf/CMakeLists.txt | 13 ++++++ src/modules/plasmalnf/PlasmaLnfJob.cpp | 64 ++++++++++++++++++++++++++ src/modules/plasmalnf/PlasmaLnfJob.h | 51 ++++++++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 src/modules/plasmalnf/CMakeLists.txt create mode 100644 src/modules/plasmalnf/PlasmaLnfJob.cpp create mode 100644 src/modules/plasmalnf/PlasmaLnfJob.h diff --git a/src/modules/plasmalnf/CMakeLists.txt b/src/modules/plasmalnf/CMakeLists.txt new file mode 100644 index 000000000..3a6c0324f --- /dev/null +++ b/src/modules/plasmalnf/CMakeLists.txt @@ -0,0 +1,13 @@ +find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE) + +find_package( KF5 REQUIRED CoreAddons Service ) + +calamares_add_plugin( plasmalnf + TYPE job + EXPORT_MACRO PLUGINDLLEXPORT_PRO + SOURCES + PlasmaLnfJob.cpp + LINK_PRIVATE_LIBRARIES + calamares + SHARED_LIB +) diff --git a/src/modules/plasmalnf/PlasmaLnfJob.cpp b/src/modules/plasmalnf/PlasmaLnfJob.cpp new file mode 100644 index 000000000..15b4e39ce --- /dev/null +++ b/src/modules/plasmalnf/PlasmaLnfJob.cpp @@ -0,0 +1,64 @@ +/* === This file is part of Calamares - === + * + * 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 + * 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 "PlasmaLnfJob.h" + +#include +#include +#include + +#include "CalamaresVersion.h" +#include "JobQueue.h" +#include "GlobalStorage.h" + +#include "utils/Logger.h" + +PlasmaLnfJob::PlasmaLnfJob( QObject* parent ) + : Calamares::CppJob( parent ) +{ +} + + +PlasmaLnfJob::~PlasmaLnfJob() +{ +} + + +QString +PlasmaLnfJob::prettyName() const +{ + return tr( "Plasma Look-and-Feel Job" ); +} + + +Calamares::JobResult +PlasmaLnfJob::exec() +{ + cDebug() << "Plasma Look-and-Feel Job"; + + return Calamares::JobResult::ok(); +} + + +void +PlasmaLnfJob::setConfigurationMap( const QVariantMap& configurationMap ) +{ + m_configurationMap = configurationMap; +} + +CALAMARES_PLUGIN_FACTORY_DEFINITION( PlasmaLnfJobFactory, registerPlugin(); ) diff --git a/src/modules/plasmalnf/PlasmaLnfJob.h b/src/modules/plasmalnf/PlasmaLnfJob.h new file mode 100644 index 000000000..db56d8be9 --- /dev/null +++ b/src/modules/plasmalnf/PlasmaLnfJob.h @@ -0,0 +1,51 @@ +/* === This file is part of Calamares - === + * + * 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 + * 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 PLASMALNFJOB_H +#define PLASMALNFJOB_H + +#include +#include + +#include + +#include + +#include + +class PLUGINDLLEXPORT PlasmaLnfJob : public Calamares::CppJob +{ + Q_OBJECT + +public: + explicit PlasmaLnfJob( QObject* parent = nullptr ); + virtual ~PlasmaLnfJob() override; + + QString prettyName() const override; + + Calamares::JobResult exec() override; + + void setConfigurationMap( const QVariantMap& configurationMap ) override; + +private: + QVariantMap m_configurationMap; +}; + +CALAMARES_PLUGIN_FACTORY_DECLARATION( PlasmaLnfJobFactory ) + +#endif // PLASMALNFJOB_H From 41e8fdd362a7fe888afac203d4b1204e991d86b8 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 31 Oct 2017 09:49:16 -0400 Subject: [PATCH 03/35] [plasmalnf] Search for LNF themes like the KCM does --- src/modules/plasmalnf/CMakeLists.txt | 4 +- src/modules/plasmalnf/PlasmaLnfJob.cpp | 52 +++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/src/modules/plasmalnf/CMakeLists.txt b/src/modules/plasmalnf/CMakeLists.txt index 3a6c0324f..b78aac6b8 100644 --- a/src/modules/plasmalnf/CMakeLists.txt +++ b/src/modules/plasmalnf/CMakeLists.txt @@ -1,6 +1,6 @@ find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE) -find_package( KF5 REQUIRED CoreAddons Service ) +find_package( KF5 5.29 REQUIRED CoreAddons Plasma Service ) calamares_add_plugin( plasmalnf TYPE job @@ -9,5 +9,7 @@ calamares_add_plugin( plasmalnf PlasmaLnfJob.cpp LINK_PRIVATE_LIBRARIES calamares + KF5::Plasma + KF5::Service SHARED_LIB ) diff --git a/src/modules/plasmalnf/PlasmaLnfJob.cpp b/src/modules/plasmalnf/PlasmaLnfJob.cpp index 15b4e39ce..0aa7314cf 100644 --- a/src/modules/plasmalnf/PlasmaLnfJob.cpp +++ b/src/modules/plasmalnf/PlasmaLnfJob.cpp @@ -18,10 +18,18 @@ #include "PlasmaLnfJob.h" -#include #include +#include +#include +#include #include +#include +#include +#include // Future + +#include // TODO: port to KPluginLoader + #include "CalamaresVersion.h" #include "JobQueue.h" #include "GlobalStorage.h" @@ -45,12 +53,54 @@ PlasmaLnfJob::prettyName() const return tr( "Plasma Look-and-Feel Job" ); } +static void _themes_by_service() +{ + KService::List services; + KServiceTypeTrader* trader = KServiceTypeTrader::self(); + + services = trader->query("Plasma/Theme"); + int c = 0; + for ( const auto s : services ) + { + cDebug() << "Plasma theme '" << s->name() << '\''; + c++; + } + cDebug() << "Plasma themes by service found" << c; +} + +static void _themes_by_kcm() +{ + QString component; + QList packages; + QStringList paths; + const QStringList dataPaths = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); + + for (const QString &path : dataPaths) { + QDir dir(path + "/plasma/look-and-feel"); + paths << dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); + } + + for (const QString &path : paths) { + Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); + pkg.setPath(path); + pkg.setFallbackPackage(Plasma::Package()); + if (component.isEmpty() || !pkg.filePath(component.toUtf8()).isEmpty()) { + packages << pkg; + cDebug() << "Plasma theme '" << pkg.metadata().pluginName() << '\''; + } + } + cDebug() << "Plasma themes by kcm found" << packages.length(); +} + Calamares::JobResult PlasmaLnfJob::exec() { cDebug() << "Plasma Look-and-Feel Job"; + _themes_by_service(); + _themes_by_kcm(); + return Calamares::JobResult::ok(); } From fe61925f31379a17de498248ff60ab9d9f80b952 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 1 Dec 2017 13:46:59 -0500 Subject: [PATCH 04/35] [packages] Update module documentation --- src/modules/packages/packages.conf | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/modules/packages/packages.conf b/src/modules/packages/packages.conf index 6e3af05a8..6cccfc490 100644 --- a/src/modules/packages/packages.conf +++ b/src/modules/packages/packages.conf @@ -29,9 +29,10 @@ update_db: true # packages that need to be installed or removed can run before # this one. Distro developers may want to install locale packages # or remove drivers not needed on the installed system. -# This job will populate a list of dictionaries in the global -# storage called "packageOperations" and it is processed -# after the static list in the job configuration. +# Such a job would populate a list of dictionaries in the global +# storage called "packageOperations" and that list is processed +# after the static list in the job configuration (i.e. the list +# that is in this configuration file). # # Allowed package operations are: # - install, try_install: will call the package manager to @@ -49,7 +50,7 @@ update_db: true # while try_remove carries on. Packages may be listed as # (localized) names. # -# There are two formats for naming packages: as a name # or as package-data, +# There are two formats for naming packages: as a name or as package-data, # which is an object notation providing package-name, as well as pre- and # post-install scripts. # @@ -74,15 +75,16 @@ update_db: true # # - if the system locale is English (generally US English; en_GB is a valid # localization), then the package is not installed at all, -# - otherwise LOCALE is replaced by the Bcp47 name of the selected system -# locale, e.g. nl_BE. +# - otherwise $LOCALE or ${LOCALE} is replaced by the Bcp47 name of the selected +# system locale, e.g. nl_BE. Note that just plain LOCALE will not be replaced, +# so foo-LOCALE will be unchanged, while foo-$LOCALE will be changed. # # The following installs localizations for vi, if they are relevant; if # there is no localization, installation continues normally. # # - install -# - vi-LOCALE -# - package: vi-LOCALE +# - vi-$LOCALE +# - package: vi-${LOCALE} # pre-script: touch /tmp/installing-vi # post-script: rm -f /tmp/installing-vi # From 517dbfab06cd78838e1f504fbe05369bd2989009 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 1 Dec 2017 16:42:56 -0500 Subject: [PATCH 05/35] [libcalamares] The script namespace is actually a dict Use dict methods, in particular d.get(k, v), to retrieve the pretty_name() function (or None if it isn't there). Using getattr() on a dict will not return values in the dict. --- src/libcalamares/PythonHelper.cpp | 2 +- src/libcalamares/PythonHelper.h | 2 +- src/libcalamares/PythonJob.cpp | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libcalamares/PythonHelper.cpp b/src/libcalamares/PythonHelper.cpp index bb698ba55..ab5802076 100644 --- a/src/libcalamares/PythonHelper.cpp +++ b/src/libcalamares/PythonHelper.cpp @@ -233,7 +233,7 @@ Helper::~Helper() {} -boost::python::object +boost::python::dict Helper::createCleanNamespace() { // To make sure we run each script with a clean namespace, we only fetch the diff --git a/src/libcalamares/PythonHelper.h b/src/libcalamares/PythonHelper.h index a77ab80b2..be1ab8544 100644 --- a/src/libcalamares/PythonHelper.h +++ b/src/libcalamares/PythonHelper.h @@ -51,7 +51,7 @@ public: explicit Helper( QObject* parent = nullptr ); virtual ~Helper(); - boost::python::object createCleanNamespace(); + boost::python::dict createCleanNamespace(); QString handleLastError(); diff --git a/src/libcalamares/PythonJob.cpp b/src/libcalamares/PythonJob.cpp index 1a8a9701a..006fd86b6 100644 --- a/src/libcalamares/PythonJob.cpp +++ b/src/libcalamares/PythonJob.cpp @@ -216,10 +216,10 @@ BOOST_PYTHON_MODULE( libcalamares ) "in the original string." ); - - bp::def( - "gettext_languages", - &CalamaresPython::gettext_languages, + + bp::def( + "gettext_languages", + &CalamaresPython::gettext_languages, "Returns list of languages (most to least-specific) for gettext." ); @@ -296,7 +296,7 @@ PythonJob::exec() try { - bp::object scriptNamespace = helper()->createCleanNamespace(); + bp::dict scriptNamespace = helper()->createCleanNamespace(); bp::object calamaresModule = bp::import( "libcalamares" ); bp::dict calamaresNamespace = bp::extract< bp::dict >( calamaresModule.attr( "__dict__" ) ); @@ -310,7 +310,7 @@ PythonJob::exec() scriptNamespace ); bp::object entryPoint = scriptNamespace[ "run" ]; - bp::object prettyNameFunc = bp::getattr(scriptNamespace, "pretty_name", bp::object()); + bp::object prettyNameFunc = scriptNamespace.get("pretty_name", bp::object()); cDebug() << "Job file" << scriptFI.absoluteFilePath(); if ( !prettyNameFunc.is_none() ) From 7b145c2a36b0185877bdde243b05cc5b177d7494 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 1 Dec 2017 16:48:02 -0500 Subject: [PATCH 06/35] [packages] Improve message when no packages are processed at all. --- src/modules/packages/main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/modules/packages/main.py b/src/modules/packages/main.py index bbee9c32d..9555a0433 100644 --- a/src/modules/packages/main.py +++ b/src/modules/packages/main.py @@ -55,8 +55,12 @@ def _change_mode(mode): def pretty_name(): if not group_packages: - # Outside the context of an operation - s = _("Processing packages (%(count)d / %(total)d)") + if (total_packages > 0): + # Outside the context of an operation + s = _("Processing packages (%(count)d / %(total)d)") + else: + s = _("Install packages.") + elif mode_packages is INSTALL: s = _n("Installing one package.", "Installing %(num)d packages.", group_packages) From 150007c138aa7fcaadfdedfa635d9a8681240018 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 2 Dec 2017 05:04:30 -0500 Subject: [PATCH 07/35] [packages] Feature: skip if no internet. Update documentation, add a new key *skip_if_no_internet* to support systems that **recommend** having an internet connection (but don't require it), and which also use the packages module. This prevents a long delay while the package manager tries to access the internet and times out (repeatedly). Existing configurations are unchanged. --- src/modules/packages/main.py | 5 +++++ src/modules/packages/packages.conf | 17 ++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/modules/packages/main.py b/src/modules/packages/main.py index 9555a0433..49f3ea2ff 100644 --- a/src/modules/packages/main.py +++ b/src/modules/packages/main.py @@ -426,6 +426,11 @@ def run(): else: return "Bad backend", "backend=\"{}\"".format(backend) + skip_this = libcalamares.job.configuration.get("skip_if_no_internet", false) + if skip_this and not libcalamares.globalstorage.value("hasInternet"): + cDebug() << "WARNING: packages installation has been skipped: no internet"; + return None + update_db = libcalamares.job.configuration.get("update_db", False) if update_db and libcalamares.globalstorage.value("hasInternet"): pkgman.update_db() diff --git a/src/modules/packages/packages.conf b/src/modules/packages/packages.conf index 6cccfc490..2d6ca116f 100644 --- a/src/modules/packages/packages.conf +++ b/src/modules/packages/packages.conf @@ -14,9 +14,20 @@ # backend: dummy -# If set to true, a package-manager specific update procedure -# is run first (only if there is internet) to update the list -# of packages and dependencies. +# Often package installation needs an internet connection. +# Since you may allow system installation without a connection +# and want to offer **optional** package installation, it's +# possible to have no internet, yet have this packages module +# enabled in settings. +# +# You can skip the whole module when there is no internet +# by setting *skip_if_no_internet* to true. +# +# You can run a package-manager specific update procedure +# before installing packages (for instance, to update the +# list of packages and dependencies); this is done only if there +# is an internet connection. Set *update_db* to true to do so. +skip_if_no_internet: false update_db: true # From 3e3cd08ff355394f3638b8ca0ffeb45405a901b0 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 2 Dec 2017 05:20:13 -0500 Subject: [PATCH 08/35] [packages] Fix previous (false vs False) --- src/modules/packages/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/packages/main.py b/src/modules/packages/main.py index 49f3ea2ff..64560082d 100644 --- a/src/modules/packages/main.py +++ b/src/modules/packages/main.py @@ -426,7 +426,7 @@ def run(): else: return "Bad backend", "backend=\"{}\"".format(backend) - skip_this = libcalamares.job.configuration.get("skip_if_no_internet", false) + skip_this = libcalamares.job.configuration.get("skip_if_no_internet", False) if skip_this and not libcalamares.globalstorage.value("hasInternet"): cDebug() << "WARNING: packages installation has been skipped: no internet"; return None From 65a236cd6037e555b01689292efe0796bca1c4a3 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 2 Dec 2017 06:14:17 -0500 Subject: [PATCH 09/35] [packages] Fix previous. This, kids, is why you don't switch writing C++ and Python too often. The C++ code isn't a syntax error in Python, although this would fail at runtime. --- src/modules/packages/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/packages/main.py b/src/modules/packages/main.py index 64560082d..60ede34fa 100644 --- a/src/modules/packages/main.py +++ b/src/modules/packages/main.py @@ -428,7 +428,7 @@ def run(): skip_this = libcalamares.job.configuration.get("skip_if_no_internet", False) if skip_this and not libcalamares.globalstorage.value("hasInternet"): - cDebug() << "WARNING: packages installation has been skipped: no internet"; + libcalamares.utils.debug( "WARNING: packages installation has been skipped: no internet" ) return None update_db = libcalamares.job.configuration.get("update_db", False) From c8a6ebe404d76152ea48ea22d405fcc6459482ea Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 2 Dec 2017 06:43:12 -0500 Subject: [PATCH 10/35] Testing: expand the testmodule script. Do a better job determining what the arguments could mean; this supports lazy devlopers who don't want to pass in full paths to all kinds of things. Simple invocation can now be: testmodule.py - + to read .conf from src/modules// --- src/modules/testmodule.py | 67 ++++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 15 deletions(-) diff --git a/src/modules/testmodule.py b/src/modules/testmodule.py index a25c7bc5d..3d67826bd 100755 --- a/src/modules/testmodule.py +++ b/src/modules/testmodule.py @@ -19,14 +19,25 @@ # You should have received a copy of the GNU General Public License # along with Calamares. If not, see . """ -Testing tool to run a single Python module; optionally a -global configuration and module configuration can be read -from YAML files. Give a full path to the module-directory, -and also full paths to the configuration files. An empty -configuration file name, or "-" (a single dash) is used -to indicate that no file should be read -- useful to load -a module configuratioon file without a global configuration. +Testing tool to run a single Python module; optionally a global configuration +and module configuration can be read from YAML files. """ +argumentepilog = """ +moduledir may be a module name (e.g. "welcome") or a full path to the + module (e.g. "src/modules/welcome"). In the former case, an attempt + is made to find the module in several sensible places. +globalstorage_yaml may be given as a full path to a YAML file containing + the global configuration, or as "" or "-" which will leave the + global storage empty. +configuration_yaml may be given as a full path to a YAML file with the + module configuration, as "" or "-" to leave the configuration + empty, or as "+" to load the standard configuration from the + module-directory (e.g. welcome.conf if the welcome module is given). + +The simplest invocation to test a module, with its default configuration, is +to call this program as follows (for, e.g., the welcome module): + + testmodule.py welcome - +""" import argparse import os @@ -34,14 +45,15 @@ import sys import yaml +calamaresimporterror = ("Can not import libcalamares. Ensure the PYTHONPATH " + "environment variable includes the dir where libcalamares.so is " + "installed.") try: import libcalamares except ImportError: - print("Failed to import libcalamares. Make sure then PYTHONPATH " - "environment variable includes the dir where libcalamares.so is " - "installed.") + print(calamaresimporterror) print() - raise + libcalamares = None class Job: @@ -114,18 +126,37 @@ def test_module(moduledir, globalconfigfilename, moduleconfigfilename, lang): return 0 -def munge_filename(filename): +def munge_filename(filename, module=None): """ Maps files "" (empty) and "-" (just a dash) to None, to simplify processing elsewhere. """ if not filename or filename == "-": return None + if filename == "+" and module is not None: + d, name = os.path.split(module) + if d and not name: + # Ended in a / + d, name = os.path.split(module) + if name: + return os.path.join(module, name + ".conf") + return filename +def find_module(modulename): + if "/" in modulename: + return modulename + else: + for prefix in ("src/modules", "build/src/modules", "../src/modules"): + mp = os.path.join( prefix, modulename ) + if os.path.exists( mp ): + return mp + # Not found? Bail out elsewhere + return modulename + def main(): - parser = argparse.ArgumentParser(description=globals()["__doc__"]) + parser = argparse.ArgumentParser(description=globals()["__doc__"], epilog=argumentepilog, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument("moduledir", help="Dir containing the Python module.") parser.add_argument("globalstorage_yaml", nargs="?", @@ -136,9 +167,15 @@ def main(): help="Set translation language.") args = parser.parse_args() - return test_module(args.moduledir, + # If we get here, it wasn't a --help invocation, so complain + # if libcalamares wasn't found. + if not libcalamares: + parser.error(calamaresimporterror) + + moduledir = find_module(args.moduledir) + return test_module(moduledir, munge_filename(args.globalstorage_yaml), - munge_filename(args.configuration_yaml), + munge_filename(args.configuration_yaml, moduledir), args.lang) From 84c28e9efa595353dede17c2a0b8cfff3e171d83 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 2 Dec 2017 07:00:43 -0500 Subject: [PATCH 11/35] CMake: explain better why PythonQt isn't found --- CMakeModules/FindPythonQt.cmake | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CMakeModules/FindPythonQt.cmake b/CMakeModules/FindPythonQt.cmake index 8de40853f..f0f4b8a73 100644 --- a/CMakeModules/FindPythonQt.cmake +++ b/CMakeModules/FindPythonQt.cmake @@ -139,4 +139,16 @@ if(PYTHONQT_INCLUDE_DIR AND PYTHONQT_LIBRARY AND PYTHONQT_QTALL_LIBRARY) set(PYTHONQT_FOUND 1) set(PythonQt_FOUND ${PYTHONQT_FOUND}) set(PYTHONQT_LIBRARIES ${PYTHONQT_LIBRARY} ${PYTHONQT_LIBUTIL} ${PYTHONQT_QTALL_LIBRARY}) +elseif(NOT PythonQt_FIND_QUIETLY) + set(_missing "") + if (NOT PYTHONQT_INCLUDE_DIR) + list(APPEND _missing "includes") + endif() + if (NOT PYTHONQT_LIBRARY) + list(APPEND _missing "library") + endif() + if (NOT PYTHONQT_QTALL_LIBRARY) + list(APPEND _missing "qtall") + endif() + message(STATUS "PythonQt not found, missing components ${_missing}") endif() From 7cecfceaa7533e536939ff12ef37fecc02bab271 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sat, 2 Dec 2017 19:47:34 +0000 Subject: [PATCH 12/35] add openrcdmcryptcfg module --- src/modules/openrcdmcryptcfg/main.py | 65 +++++++++++++++++++ src/modules/openrcdmcryptcfg/module.desc | 5 ++ .../openrcdmcryptcfg/openrcdmcryptcfg.conf | 2 + 3 files changed, 72 insertions(+) create mode 100644 src/modules/openrcdmcryptcfg/main.py create mode 100644 src/modules/openrcdmcryptcfg/module.desc create mode 100644 src/modules/openrcdmcryptcfg/openrcdmcryptcfg.conf diff --git a/src/modules/openrcdmcryptcfg/main.py b/src/modules/openrcdmcryptcfg/main.py new file mode 100644 index 000000000..785f2d03d --- /dev/null +++ b/src/modules/openrcdmcryptcfg/main.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# === This file is part of Calamares - === +# +# Copyright 2017, Ghiunhan Mamut +# +# 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 . + +import libcalamares +import os.path + +def write_dmcrypt_conf(partitions, root_mount_point, dmcrypt_conf_path): + crypto_target = "" + crypto_source = "" + + for partition in partitions: + has_luks = "luksMapperName" in partition + skip_partitions = partition["mountPoint"] == "/" or partition["fs"] == "linuxswap" + + if not has_luks and not skip_partitions: + libcalamares.utils.debug( + "Skip writing OpenRC LUKS configuration for partition {!s}".format(partition["mountPoint"])) + + if has_luks and not skip_partitions: + crypto_target = partition["luksMapperName"] + crypto_source = "/dev/disk/by-uuid/{!s}".format(partition["uuid"]) + libcalamares.utils.debug( + "Writing OpenRC LUKS configuration for partition {!s}".format(partition["mountPoint"])) + + with open(os.path.join(root_mount_point, dmcrypt_conf_path), 'a+') as dmcrypt_file: + dmcrypt_file.write("\ntarget=" + crypto_target) + dmcrypt_file.write("\nsource=" + crypto_source) + dmcrypt_file.write("\nkey=/crypto_keyfile.bin") + dmcrypt_file.write("\n") + + if has_luks and skip_partitions: + pass # root and swap partitions should be handled by initramfs generators + + return None + +def run(): + """ + This module configures OpenRC dmcrypt service for LUKS encrypted partitions. + :return: + """ + + root_mount_point = libcalamares.globalstorage.value("rootMountPoint") + dmcrypt_conf_path = libcalamares.job.configuration["configFilePath"] + partitions = libcalamares.globalstorage.value("partitions") + + dmcrypt_conf_path = dmcrypt_conf_path.lstrip('/') + + return write_dmcrypt_conf(partitions, root_mount_point, dmcrypt_conf_path) diff --git a/src/modules/openrcdmcryptcfg/module.desc b/src/modules/openrcdmcryptcfg/module.desc new file mode 100644 index 000000000..283adfdac --- /dev/null +++ b/src/modules/openrcdmcryptcfg/module.desc @@ -0,0 +1,5 @@ +--- +type: "job" +name: "openrcdmcryptcfg" +interface: "python" +script: "main.py" diff --git a/src/modules/openrcdmcryptcfg/openrcdmcryptcfg.conf b/src/modules/openrcdmcryptcfg/openrcdmcryptcfg.conf new file mode 100644 index 000000000..57ee2dc31 --- /dev/null +++ b/src/modules/openrcdmcryptcfg/openrcdmcryptcfg.conf @@ -0,0 +1,2 @@ +--- +configFilePath: /etc/conf.d/dmcrypt From 98d758b4bed05ad37dc7e33a840d7eb57bf6c095 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 3 Dec 2017 07:08:54 -0500 Subject: [PATCH 13/35] [plasmalnf] Hammer out the most primitive UI --- src/modules/plasmalnf/CMakeLists.txt | 11 +- src/modules/plasmalnf/PlasmaLnfPage.cpp | 47 ++++++++ src/modules/plasmalnf/PlasmaLnfPage.h | 40 +++++++ src/modules/plasmalnf/PlasmaLnfViewStep.cpp | 121 ++++++++++++++++++++ src/modules/plasmalnf/PlasmaLnfViewStep.h | 65 +++++++++++ src/modules/plasmalnf/page_plasmalnf.qrc | 1 + src/modules/plasmalnf/page_plasmalnf.ui | 50 ++++++++ src/modules/plasmalnf/plasmalnf.conf | 2 + 8 files changed, 332 insertions(+), 5 deletions(-) create mode 100644 src/modules/plasmalnf/PlasmaLnfPage.cpp create mode 100644 src/modules/plasmalnf/PlasmaLnfPage.h create mode 100644 src/modules/plasmalnf/PlasmaLnfViewStep.cpp create mode 100644 src/modules/plasmalnf/PlasmaLnfViewStep.h create mode 100644 src/modules/plasmalnf/page_plasmalnf.qrc create mode 100644 src/modules/plasmalnf/page_plasmalnf.ui create mode 100644 src/modules/plasmalnf/plasmalnf.conf diff --git a/src/modules/plasmalnf/CMakeLists.txt b/src/modules/plasmalnf/CMakeLists.txt index b78aac6b8..e3dee1c61 100644 --- a/src/modules/plasmalnf/CMakeLists.txt +++ b/src/modules/plasmalnf/CMakeLists.txt @@ -3,13 +3,14 @@ find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE) find_package( KF5 5.29 REQUIRED CoreAddons Plasma Service ) calamares_add_plugin( plasmalnf - TYPE job + TYPE viewmodule EXPORT_MACRO PLUGINDLLEXPORT_PRO SOURCES - PlasmaLnfJob.cpp + PlasmaLnfViewStep.cpp + PlasmaLnfPage.cpp + UI + page_plasmalnf.ui LINK_PRIVATE_LIBRARIES - calamares - KF5::Plasma - KF5::Service + calamaresui SHARED_LIB ) diff --git a/src/modules/plasmalnf/PlasmaLnfPage.cpp b/src/modules/plasmalnf/PlasmaLnfPage.cpp new file mode 100644 index 000000000..d83a845bc --- /dev/null +++ b/src/modules/plasmalnf/PlasmaLnfPage.cpp @@ -0,0 +1,47 @@ +/* === This file is part of Calamares - === + * + * 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 + * 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 "PlasmaLnfPage.h" + +#include "ui_page_plasmalnf.h" + +#include "Branding.h" +#include "JobQueue.h" +#include "GlobalStorage.h" +#include "utils/Logger.h" +#include "utils/CalamaresUtilsGui.h" +#include "utils/Retranslator.h" +#include "ViewManager.h" + +#include +#include +#include + +PlasmaLnfPage::PlasmaLnfPage(QWidget *parent) + : QWidget( parent ) + , ui( new Ui::PlasmaLnfPage ) +{ + using StringEntry = Calamares::Branding::StringEntry; + + ui->setupUi( this ); + CALAMARES_RETRANSLATE( + ui->retranslateUi( this ); + ui->generalExplanation->setText( tr( "Please choose a look-and-feel for the KDE Plasma Desktop, below." ) ); + ) +} + diff --git a/src/modules/plasmalnf/PlasmaLnfPage.h b/src/modules/plasmalnf/PlasmaLnfPage.h new file mode 100644 index 000000000..f7a17720a --- /dev/null +++ b/src/modules/plasmalnf/PlasmaLnfPage.h @@ -0,0 +1,40 @@ +/* === This file is part of Calamares - === + * + * 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 + * 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 PLASMALNFPAGE_H +#define PLASMALNFPAGE_H + +#include +#include + +namespace Ui +{ +class PlasmaLnfPage; +} + +class PlasmaLnfPage : public QWidget +{ + Q_OBJECT +public: + explicit PlasmaLnfPage( QWidget* parent = nullptr ); + +private: + Ui::PlasmaLnfPage* ui; +}; + +#endif //PLASMALNFPAGE_H diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp new file mode 100644 index 000000000..eac93a6e1 --- /dev/null +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp @@ -0,0 +1,121 @@ +/* === This file is part of Calamares - === + * + * 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 + * 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 "JobQueue.h" +#include "GlobalStorage.h" +#include "utils/Logger.h" +#include "utils/CalamaresUtils.h" +#include "utils/CalamaresUtilsSystem.h" + +#include "PlasmaLnfJob.h" +#include "PlasmaLnfPage.h" +#include "PlasmaLnfViewStep.h" + +#include +#include + +CALAMARES_PLUGIN_FACTORY_DEFINITION( PlasmaLnfViewStepFactory, registerPlugin(); ) + +PlasmaLnfViewStep::PlasmaLnfViewStep( QObject* parent ) + : Calamares::ViewStep( parent ) + , m_widget( new PlasmaLnfPage ) +{ + emit nextStatusChanged( false ); +} + + +PlasmaLnfViewStep::~PlasmaLnfViewStep() +{ + if ( m_widget && m_widget->parent() == nullptr ) + m_widget->deleteLater(); +} + + +QString +PlasmaLnfViewStep::prettyName() const +{ + return tr( "Look-and-Feel" ); +} + + +QWidget* +PlasmaLnfViewStep::widget() +{ + return m_widget; +} + + +void +PlasmaLnfViewStep::next() +{ + emit done(); +} + + +void +PlasmaLnfViewStep::back() +{} + + +bool +PlasmaLnfViewStep::isNextEnabled() const +{ + return true; +} + + +bool +PlasmaLnfViewStep::isBackEnabled() const +{ + return true; +} + + +bool +PlasmaLnfViewStep::isAtBeginning() const +{ + return true; +} + + +bool +PlasmaLnfViewStep::isAtEnd() const +{ + return true; +} + + +void PlasmaLnfViewStep::onLeave() +{ +} + + +Calamares::JobList +PlasmaLnfViewStep::jobs() const +{ + Calamares::JobList l; + + cDebug() << "Creating Plasma LNF jobs .."; + return l; +} + + +void +PlasmaLnfViewStep::setConfigurationMap( const QVariantMap& configurationMap ) +{ +} diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.h b/src/modules/plasmalnf/PlasmaLnfViewStep.h new file mode 100644 index 000000000..99a48b79c --- /dev/null +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.h @@ -0,0 +1,65 @@ +/* === This file is part of Calamares - === + * + * 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 + * 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 PLASMALNFVIEWSTEP_H +#define PLASMALNFVIEWSTEP_H + +#include +#include +#include + +#include +#include +#include + +class PlasmaLnfPage; + +class PLUGINDLLEXPORT PlasmaLnfViewStep : public Calamares::ViewStep +{ + Q_OBJECT + +public: + explicit PlasmaLnfViewStep( QObject* parent = nullptr ); + virtual ~PlasmaLnfViewStep() override; + + QString prettyName() const override; + + QWidget* widget() override; + + void next() override; + void back() override; + + bool isNextEnabled() const override; + bool isBackEnabled() const override; + + bool isAtBeginning() const override; + bool isAtEnd() const override; + + void onLeave() override; + + Calamares::JobList jobs() const override; + + void setConfigurationMap( const QVariantMap& configurationMap ) override; + +private: + PlasmaLnfPage* m_widget; +}; + +CALAMARES_PLUGIN_FACTORY_DECLARATION( PlasmaLnfViewStepFactory ) + +#endif // PLASMALNFVIEWSTEP_H diff --git a/src/modules/plasmalnf/page_plasmalnf.qrc b/src/modules/plasmalnf/page_plasmalnf.qrc new file mode 100644 index 000000000..7646d2b36 --- /dev/null +++ b/src/modules/plasmalnf/page_plasmalnf.qrc @@ -0,0 +1 @@ + diff --git a/src/modules/plasmalnf/page_plasmalnf.ui b/src/modules/plasmalnf/page_plasmalnf.ui new file mode 100644 index 000000000..dfb906c22 --- /dev/null +++ b/src/modules/plasmalnf/page_plasmalnf.ui @@ -0,0 +1,50 @@ + + + PlasmaLnfPage + + + + 0 + 0 + 799 + 400 + + + + Form + + + + + + margin-bottom: 1ex; +margin-left: 2em; + + + Placeholder + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + diff --git a/src/modules/plasmalnf/plasmalnf.conf b/src/modules/plasmalnf/plasmalnf.conf new file mode 100644 index 000000000..54fff14c1 --- /dev/null +++ b/src/modules/plasmalnf/plasmalnf.conf @@ -0,0 +1,2 @@ +-- +# PlasmaLnf module has no configuration From 8c65ee54814e8c8e79f84087e1823d61e3d7bf93 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 3 Dec 2017 08:48:41 -0500 Subject: [PATCH 14/35] [plasmalnf] Get available LNF - Implement various ways of getting the LNF; the process-based one uses a recent CLI-tool from the Plasma developers. - Fill the UI with (meaningless) LNF package IDs. --- src/modules/plasmalnf/CMakeLists.txt | 3 + src/modules/plasmalnf/PlasmaLnfInfo.cpp | 99 +++++++++++++++++++++++++ src/modules/plasmalnf/PlasmaLnfInfo.h | 33 +++++++++ src/modules/plasmalnf/PlasmaLnfPage.cpp | 4 + src/modules/plasmalnf/page_plasmalnf.ui | 5 +- 5 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 src/modules/plasmalnf/PlasmaLnfInfo.cpp create mode 100644 src/modules/plasmalnf/PlasmaLnfInfo.h diff --git a/src/modules/plasmalnf/CMakeLists.txt b/src/modules/plasmalnf/CMakeLists.txt index e3dee1c61..727c9e7df 100644 --- a/src/modules/plasmalnf/CMakeLists.txt +++ b/src/modules/plasmalnf/CMakeLists.txt @@ -8,9 +8,12 @@ calamares_add_plugin( plasmalnf SOURCES PlasmaLnfViewStep.cpp PlasmaLnfPage.cpp + PlasmaLnfInfo.cpp UI page_plasmalnf.ui LINK_PRIVATE_LIBRARIES calamaresui + KF5::Plasma + KF5::Service SHARED_LIB ) diff --git a/src/modules/plasmalnf/PlasmaLnfInfo.cpp b/src/modules/plasmalnf/PlasmaLnfInfo.cpp new file mode 100644 index 000000000..420c57919 --- /dev/null +++ b/src/modules/plasmalnf/PlasmaLnfInfo.cpp @@ -0,0 +1,99 @@ +/* === This file is part of Calamares - === + * + * 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 + * 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 "PlasmaLnfInfo.h" + +#include +#include +#include +#include +#include + +#include +#include +#include // Future + +#include // TODO: port to KPluginLoader + +#include "utils/Logger.h" + + +namespace Calamares +{ + +QStringList themes_by_service() +{ + KService::List services; + KServiceTypeTrader* trader = KServiceTypeTrader::self(); + + cDebug() << "Plasma themes by service:"; + QStringList packages; + services = trader->query("Plasma/Theme"); + int c = 0; + for ( const auto s : services ) + { + cDebug() << " .. Plasma theme" << s->name(); + packages << s->name(); + c++; + } + + return packages; +} + +QStringList themes_by_kcm() +{ + QString component; + QList packages; + QStringList paths; + QStringList packageNames; + const QStringList dataPaths = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); + + for (const QString &path : dataPaths) { + QDir dir(path + "/plasma/look-and-feel"); + paths << dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); + } + + cDebug() << "Plasma themes by kcm:"; + for (const QString &path : paths) { + Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); + pkg.setPath(path); + pkg.setFallbackPackage(Plasma::Package()); + if (component.isEmpty() || !pkg.filePath(component.toUtf8()).isEmpty()) { + packages << pkg; + packageNames << pkg.metadata().pluginName(); + cDebug() << " .. Plasma theme" << pkg.metadata().pluginName(); + } + } + + return packageNames; +} + +QStringList themes_by_lnftool() +{ + QStringList packages; + + QProcess lnftool; + lnftool.start( "lookandfeeltool", {"--list"} ); + if ( lnftool.waitForStarted(1000) && lnftool.waitForFinished( 1000 ) && (lnftool.exitCode() == 0) && (lnftool.exitStatus() == QProcess::NormalExit ) ) + { + packages = QString::fromLocal8Bit( lnftool.readAllStandardOutput() ).trimmed().split('\n'); + } + return packages; +} + +} // namespace Calamares diff --git a/src/modules/plasmalnf/PlasmaLnfInfo.h b/src/modules/plasmalnf/PlasmaLnfInfo.h new file mode 100644 index 000000000..1ee2cd2ac --- /dev/null +++ b/src/modules/plasmalnf/PlasmaLnfInfo.h @@ -0,0 +1,33 @@ +/* === This file is part of Calamares - === + * + * 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 + * 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 PLASMALNFINFO_H +#define PLASMALNFINFO_H + +#include + +namespace Calamares +{ + +QStringList themes_by_service(); +QStringList themes_by_kcm(); +QStringList themes_by_lnftool(); + +} + +#endif // PLASMALNFINFO_H diff --git a/src/modules/plasmalnf/PlasmaLnfPage.cpp b/src/modules/plasmalnf/PlasmaLnfPage.cpp index d83a845bc..eee9534c4 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.cpp +++ b/src/modules/plasmalnf/PlasmaLnfPage.cpp @@ -17,6 +17,7 @@ */ #include "PlasmaLnfPage.h" +#include "PlasmaLnfInfo.h" #include "ui_page_plasmalnf.h" @@ -43,5 +44,8 @@ PlasmaLnfPage::PlasmaLnfPage(QWidget *parent) ui->retranslateUi( this ); ui->generalExplanation->setText( tr( "Please choose a look-and-feel for the KDE Plasma Desktop, below." ) ); ) + + Calamares::themes_by_service(); + ui->lnfCombo->addItems( Calamares::themes_by_lnftool() ); } diff --git a/src/modules/plasmalnf/page_plasmalnf.ui b/src/modules/plasmalnf/page_plasmalnf.ui index dfb906c22..340527ad0 100644 --- a/src/modules/plasmalnf/page_plasmalnf.ui +++ b/src/modules/plasmalnf/page_plasmalnf.ui @@ -13,7 +13,7 @@ Form - + @@ -28,6 +28,9 @@ margin-left: 2em; + + + From 2d3defcca3ef8a9e82f373ebf00a60311380e4f9 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 3 Dec 2017 09:18:18 -0500 Subject: [PATCH 15/35] [plasmalnf] Hammer in theme-changing - Tool is currently a hard-coded path. --- src/modules/plasmalnf/CMakeLists.txt | 3 ++- src/modules/plasmalnf/PlasmaLnfInfo.cpp | 31 ++++++++++++++++++++++++- src/modules/plasmalnf/PlasmaLnfInfo.h | 4 ++++ src/modules/plasmalnf/PlasmaLnfPage.cpp | 20 ++++++++++++++-- src/modules/plasmalnf/PlasmaLnfPage.h | 3 +++ 5 files changed, 57 insertions(+), 4 deletions(-) diff --git a/src/modules/plasmalnf/CMakeLists.txt b/src/modules/plasmalnf/CMakeLists.txt index 727c9e7df..4eeb0f7af 100644 --- a/src/modules/plasmalnf/CMakeLists.txt +++ b/src/modules/plasmalnf/CMakeLists.txt @@ -1,6 +1,6 @@ find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE) -find_package( KF5 5.29 REQUIRED CoreAddons Plasma Service ) +find_package( KF5 5.29 REQUIRED CoreAddons Plasma Service Package ) calamares_add_plugin( plasmalnf TYPE viewmodule @@ -13,6 +13,7 @@ calamares_add_plugin( plasmalnf page_plasmalnf.ui LINK_PRIVATE_LIBRARIES calamaresui + KF5::Package KF5::Plasma KF5::Service SHARED_LIB diff --git a/src/modules/plasmalnf/PlasmaLnfInfo.cpp b/src/modules/plasmalnf/PlasmaLnfInfo.cpp index 420c57919..27655b841 100644 --- a/src/modules/plasmalnf/PlasmaLnfInfo.cpp +++ b/src/modules/plasmalnf/PlasmaLnfInfo.cpp @@ -29,6 +29,8 @@ #include // Future #include // TODO: port to KPluginLoader +#include +#include #include "utils/Logger.h" @@ -36,6 +38,20 @@ namespace Calamares { +QStringList themes_by_package() +{ + QStringList packages; + + QList pkgs = KPackage::PackageLoader::self()->listPackages("Plasma/LookAndFeel"); + + for (const KPluginMetaData &data : pkgs) { + packages << data.pluginId(); + } + + return packages; +} + + QStringList themes_by_service() { KService::List services; @@ -88,7 +104,7 @@ QStringList themes_by_lnftool() QStringList packages; QProcess lnftool; - lnftool.start( "lookandfeeltool", {"--list"} ); + lnftool.start( Calamares::lnftool(), {"--list"} ); if ( lnftool.waitForStarted(1000) && lnftool.waitForFinished( 1000 ) && (lnftool.exitCode() == 0) && (lnftool.exitStatus() == QProcess::NormalExit ) ) { packages = QString::fromLocal8Bit( lnftool.readAllStandardOutput() ).trimmed().split('\n'); @@ -96,4 +112,17 @@ QStringList themes_by_lnftool() return packages; } +QStringList plasma_themes() +{ + QStringList l( themes_by_package() ); + if (l.isEmpty()) + return themes_by_lnftool(); + return l; +} + +QString lnftool() +{ + return "/home/adridg/bin/lookandfeeltool"; +} + } // namespace Calamares diff --git a/src/modules/plasmalnf/PlasmaLnfInfo.h b/src/modules/plasmalnf/PlasmaLnfInfo.h index 1ee2cd2ac..a35f8d1e6 100644 --- a/src/modules/plasmalnf/PlasmaLnfInfo.h +++ b/src/modules/plasmalnf/PlasmaLnfInfo.h @@ -23,11 +23,15 @@ namespace Calamares { +QString lnftool(); + /* Internal */ +QStringList themes_by_package(); QStringList themes_by_service(); QStringList themes_by_kcm(); QStringList themes_by_lnftool(); +QStringList plasma_themes(); } #endif // PLASMALNFINFO_H diff --git a/src/modules/plasmalnf/PlasmaLnfPage.cpp b/src/modules/plasmalnf/PlasmaLnfPage.cpp index eee9534c4..0d09026a2 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.cpp +++ b/src/modules/plasmalnf/PlasmaLnfPage.cpp @@ -32,6 +32,7 @@ #include #include #include +#include PlasmaLnfPage::PlasmaLnfPage(QWidget *parent) : QWidget( parent ) @@ -45,7 +46,22 @@ PlasmaLnfPage::PlasmaLnfPage(QWidget *parent) ui->generalExplanation->setText( tr( "Please choose a look-and-feel for the KDE Plasma Desktop, below." ) ); ) - Calamares::themes_by_service(); - ui->lnfCombo->addItems( Calamares::themes_by_lnftool() ); + Calamares::themes_by_package(); + ui->lnfCombo->addItems( Calamares::plasma_themes() ); + + QObject::connect(ui->lnfCombo, &QComboBox::activated, this, &PlasmaLnfPage::activated); } +void +PlasmaLnfPage::activated(const QString& name) +{ + cDebug() << "Changed to" << name; + + QProcess lnftool; + lnftool.start( Calamares::lnftool(), {"--apply", name} ); + + if ( lnftool.waitForStarted(1000) && lnftool.waitForFinished( 1000 ) && (lnftool.exitCode() == 0) && (lnftool.exitStatus() == QProcess::NormalExit ) ) + ; // OK + else + cDebug() << "WARNING: could not apply look-and-feel" << name; +} diff --git a/src/modules/plasmalnf/PlasmaLnfPage.h b/src/modules/plasmalnf/PlasmaLnfPage.h index f7a17720a..753911bbb 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.h +++ b/src/modules/plasmalnf/PlasmaLnfPage.h @@ -33,6 +33,9 @@ class PlasmaLnfPage : public QWidget public: explicit PlasmaLnfPage( QWidget* parent = nullptr ); +public slots: + void activated(const QString& name); + private: Ui::PlasmaLnfPage* ui; }; From 62623a23760a57e268c039a91b900c480caeb9ff Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 3 Dec 2017 09:26:59 -0500 Subject: [PATCH 16/35] [plasmalnf] Make an actual job of setting the theme - Job doesn't actually run lookandfeeltool in the target system yet. --- src/modules/plasmalnf/CMakeLists.txt | 1 + src/modules/plasmalnf/PlasmaLnfJob.cpp | 53 +++------------------ src/modules/plasmalnf/PlasmaLnfJob.h | 18 +++---- src/modules/plasmalnf/PlasmaLnfPage.cpp | 3 ++ src/modules/plasmalnf/PlasmaLnfPage.h | 3 ++ src/modules/plasmalnf/PlasmaLnfViewStep.cpp | 11 +++++ src/modules/plasmalnf/PlasmaLnfViewStep.h | 4 ++ 7 files changed, 35 insertions(+), 58 deletions(-) diff --git a/src/modules/plasmalnf/CMakeLists.txt b/src/modules/plasmalnf/CMakeLists.txt index 4eeb0f7af..9b3ccf716 100644 --- a/src/modules/plasmalnf/CMakeLists.txt +++ b/src/modules/plasmalnf/CMakeLists.txt @@ -8,6 +8,7 @@ calamares_add_plugin( plasmalnf SOURCES PlasmaLnfViewStep.cpp PlasmaLnfPage.cpp + PlasmaLnfJob.cpp PlasmaLnfInfo.cpp UI page_plasmalnf.ui diff --git a/src/modules/plasmalnf/PlasmaLnfJob.cpp b/src/modules/plasmalnf/PlasmaLnfJob.cpp index 0aa7314cf..696995abe 100644 --- a/src/modules/plasmalnf/PlasmaLnfJob.cpp +++ b/src/modules/plasmalnf/PlasmaLnfJob.cpp @@ -36,8 +36,8 @@ #include "utils/Logger.h" -PlasmaLnfJob::PlasmaLnfJob( QObject* parent ) - : Calamares::CppJob( parent ) +PlasmaLnfJob::PlasmaLnfJob( const QString& id ) + : m_id(id) { } @@ -53,43 +53,15 @@ PlasmaLnfJob::prettyName() const return tr( "Plasma Look-and-Feel Job" ); } -static void _themes_by_service() +QString +PlasmaLnfJob::prettyDescription() const { - KService::List services; - KServiceTypeTrader* trader = KServiceTypeTrader::self(); - - services = trader->query("Plasma/Theme"); - int c = 0; - for ( const auto s : services ) - { - cDebug() << "Plasma theme '" << s->name() << '\''; - c++; - } - cDebug() << "Plasma themes by service found" << c; + return prettyName(); } -static void _themes_by_kcm() +QString PlasmaLnfJob::prettyStatusMessage() const { - QString component; - QList packages; - QStringList paths; - const QStringList dataPaths = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); - - for (const QString &path : dataPaths) { - QDir dir(path + "/plasma/look-and-feel"); - paths << dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); - } - - for (const QString &path : paths) { - Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); - pkg.setPath(path); - pkg.setFallbackPackage(Plasma::Package()); - if (component.isEmpty() || !pkg.filePath(component.toUtf8()).isEmpty()) { - packages << pkg; - cDebug() << "Plasma theme '" << pkg.metadata().pluginName() << '\''; - } - } - cDebug() << "Plasma themes by kcm found" << packages.length(); + return prettyName(); } @@ -98,17 +70,6 @@ PlasmaLnfJob::exec() { cDebug() << "Plasma Look-and-Feel Job"; - _themes_by_service(); - _themes_by_kcm(); - return Calamares::JobResult::ok(); } - -void -PlasmaLnfJob::setConfigurationMap( const QVariantMap& configurationMap ) -{ - m_configurationMap = configurationMap; -} - -CALAMARES_PLUGIN_FACTORY_DEFINITION( PlasmaLnfJobFactory, registerPlugin(); ) diff --git a/src/modules/plasmalnf/PlasmaLnfJob.h b/src/modules/plasmalnf/PlasmaLnfJob.h index db56d8be9..a9fa29282 100644 --- a/src/modules/plasmalnf/PlasmaLnfJob.h +++ b/src/modules/plasmalnf/PlasmaLnfJob.h @@ -22,30 +22,24 @@ #include #include -#include +#include -#include - -#include - -class PLUGINDLLEXPORT PlasmaLnfJob : public Calamares::CppJob +class PlasmaLnfJob : public Calamares::Job { Q_OBJECT public: - explicit PlasmaLnfJob( QObject* parent = nullptr ); + explicit PlasmaLnfJob( const QString& id ); virtual ~PlasmaLnfJob() override; QString prettyName() const override; + QString prettyDescription() const override; + QString prettyStatusMessage() const override; Calamares::JobResult exec() override; - void setConfigurationMap( const QVariantMap& configurationMap ) override; - private: - QVariantMap m_configurationMap; + QString m_id; }; -CALAMARES_PLUGIN_FACTORY_DECLARATION( PlasmaLnfJobFactory ) - #endif // PLASMALNFJOB_H diff --git a/src/modules/plasmalnf/PlasmaLnfPage.cpp b/src/modules/plasmalnf/PlasmaLnfPage.cpp index 0d09026a2..4989bbbcd 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.cpp +++ b/src/modules/plasmalnf/PlasmaLnfPage.cpp @@ -64,4 +64,7 @@ PlasmaLnfPage::activated(const QString& name) ; // OK else cDebug() << "WARNING: could not apply look-and-feel" << name; + + + emit plasmaThemeSelected( name ); } diff --git a/src/modules/plasmalnf/PlasmaLnfPage.h b/src/modules/plasmalnf/PlasmaLnfPage.h index 753911bbb..ceed37044 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.h +++ b/src/modules/plasmalnf/PlasmaLnfPage.h @@ -36,6 +36,9 @@ public: public slots: void activated(const QString& name); +signals: + void plasmaThemeSelected( const QString &id ); + private: Ui::PlasmaLnfPage* ui; }; diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp index eac93a6e1..0b824fc46 100644 --- a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp @@ -35,6 +35,7 @@ PlasmaLnfViewStep::PlasmaLnfViewStep( QObject* parent ) : Calamares::ViewStep( parent ) , m_widget( new PlasmaLnfPage ) { + connect( m_widget, &PlasmaLnfPage::plasmaThemeSelected, this, &PlasmaLnfViewStep::themeSelected ); emit nextStatusChanged( false ); } @@ -111,6 +112,10 @@ PlasmaLnfViewStep::jobs() const Calamares::JobList l; cDebug() << "Creating Plasma LNF jobs .."; + if ( !m_themeId.isEmpty() ) + { + l.append( Calamares::job_ptr( new PlasmaLnfJob( m_themeId ) ) ); + } return l; } @@ -119,3 +124,9 @@ void PlasmaLnfViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { } + +void +PlasmaLnfViewStep::themeSelected( const QString& id ) +{ + m_themeId = id; +} diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.h b/src/modules/plasmalnf/PlasmaLnfViewStep.h index 99a48b79c..cdc447b7e 100644 --- a/src/modules/plasmalnf/PlasmaLnfViewStep.h +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.h @@ -56,8 +56,12 @@ public: void setConfigurationMap( const QVariantMap& configurationMap ) override; +public slots: + void themeSelected( const QString &id ); + private: PlasmaLnfPage* m_widget; + QString m_themeId; }; CALAMARES_PLUGIN_FACTORY_DECLARATION( PlasmaLnfViewStepFactory ) From b3d299bbf150e3b9cfbd1b73ae2be78c45abd4fc Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 3 Dec 2017 09:44:29 -0500 Subject: [PATCH 17/35] [plasmalnf] Replace hard-coded path with configurable one --- src/modules/plasmalnf/PlasmaLnfInfo.cpp | 14 +++++++++++++- src/modules/plasmalnf/PlasmaLnfInfo.h | 2 ++ src/modules/plasmalnf/PlasmaLnfJob.cpp | 5 +++-- src/modules/plasmalnf/PlasmaLnfJob.h | 3 ++- src/modules/plasmalnf/PlasmaLnfViewStep.cpp | 10 ++++++++-- src/modules/plasmalnf/PlasmaLnfViewStep.h | 1 + src/modules/plasmalnf/plasmalnf.conf | 6 ++++-- 7 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/modules/plasmalnf/PlasmaLnfInfo.cpp b/src/modules/plasmalnf/PlasmaLnfInfo.cpp index 27655b841..6e9249825 100644 --- a/src/modules/plasmalnf/PlasmaLnfInfo.cpp +++ b/src/modules/plasmalnf/PlasmaLnfInfo.cpp @@ -120,9 +120,21 @@ QStringList plasma_themes() return l; } +static QString *p_lnfPath = nullptr; + QString lnftool() { - return "/home/adridg/bin/lookandfeeltool"; + if ( !p_lnfPath ) + p_lnfPath = new QString("/usr/bin/lookandfeeltool"); + + return *p_lnfPath; +} + +void set_lnftool( const QString& lnfPath ) +{ + if (p_lnfPath) + delete p_lnfPath; + p_lnfPath = new QString( lnfPath ); } } // namespace Calamares diff --git a/src/modules/plasmalnf/PlasmaLnfInfo.h b/src/modules/plasmalnf/PlasmaLnfInfo.h index a35f8d1e6..27adc224c 100644 --- a/src/modules/plasmalnf/PlasmaLnfInfo.h +++ b/src/modules/plasmalnf/PlasmaLnfInfo.h @@ -19,11 +19,13 @@ #ifndef PLASMALNFINFO_H #define PLASMALNFINFO_H +#include #include namespace Calamares { QString lnftool(); +void set_lnftool( const QString& ); /* Internal */ QStringList themes_by_package(); diff --git a/src/modules/plasmalnf/PlasmaLnfJob.cpp b/src/modules/plasmalnf/PlasmaLnfJob.cpp index 696995abe..c98dc7587 100644 --- a/src/modules/plasmalnf/PlasmaLnfJob.cpp +++ b/src/modules/plasmalnf/PlasmaLnfJob.cpp @@ -36,8 +36,9 @@ #include "utils/Logger.h" -PlasmaLnfJob::PlasmaLnfJob( const QString& id ) - : m_id(id) +PlasmaLnfJob::PlasmaLnfJob( const QString& lnfPath, const QString& id ) + : m_lnfPath( lnfPath ) + , m_id(id) { } diff --git a/src/modules/plasmalnf/PlasmaLnfJob.h b/src/modules/plasmalnf/PlasmaLnfJob.h index a9fa29282..c7a7726ed 100644 --- a/src/modules/plasmalnf/PlasmaLnfJob.h +++ b/src/modules/plasmalnf/PlasmaLnfJob.h @@ -29,7 +29,7 @@ class PlasmaLnfJob : public Calamares::Job Q_OBJECT public: - explicit PlasmaLnfJob( const QString& id ); + explicit PlasmaLnfJob( const QString& lnfPath, const QString& id ); virtual ~PlasmaLnfJob() override; QString prettyName() const override; @@ -39,6 +39,7 @@ public: Calamares::JobResult exec() override; private: + QString m_lnfPath; QString m_id; }; diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp index 0b824fc46..73f89091b 100644 --- a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp @@ -22,6 +22,7 @@ #include "utils/CalamaresUtils.h" #include "utils/CalamaresUtilsSystem.h" +#include "PlasmaLnfInfo.h" #include "PlasmaLnfJob.h" #include "PlasmaLnfPage.h" #include "PlasmaLnfViewStep.h" @@ -112,9 +113,9 @@ PlasmaLnfViewStep::jobs() const Calamares::JobList l; cDebug() << "Creating Plasma LNF jobs .."; - if ( !m_themeId.isEmpty() ) + if ( !m_themeId.isEmpty() && !m_lnfPath.isEmpty() ) { - l.append( Calamares::job_ptr( new PlasmaLnfJob( m_themeId ) ) ); + l.append( Calamares::job_ptr( new PlasmaLnfJob( m_lnfPath, m_themeId ) ) ); } return l; } @@ -123,6 +124,11 @@ PlasmaLnfViewStep::jobs() const void PlasmaLnfViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { + m_lnfPath = CalamaresUtils::getString( configurationMap, "lnftool" ); + Calamares::set_lnftool( m_lnfPath ); + + if (m_lnfPath.isEmpty()) + cDebug() << "WARNING: no lnftool given for plasmalnf module."; } void diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.h b/src/modules/plasmalnf/PlasmaLnfViewStep.h index cdc447b7e..c2bcce2c0 100644 --- a/src/modules/plasmalnf/PlasmaLnfViewStep.h +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.h @@ -61,6 +61,7 @@ public slots: private: PlasmaLnfPage* m_widget; + QString m_lnfPath; QString m_themeId; }; diff --git a/src/modules/plasmalnf/plasmalnf.conf b/src/modules/plasmalnf/plasmalnf.conf index 54fff14c1..d9817ecbc 100644 --- a/src/modules/plasmalnf/plasmalnf.conf +++ b/src/modules/plasmalnf/plasmalnf.conf @@ -1,2 +1,4 @@ --- -# PlasmaLnf module has no configuration +--- +# Full path to the Plasma look-and-feel tool (CLI program +# for querying and applying Plasma themes). +lnftool: "/usr/bin/lookandfeeltool" From 8a053f3c9b28c291e8bd2e934f97bb0ae741df4f Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 3 Dec 2017 10:09:00 -0500 Subject: [PATCH 18/35] [libcalamares] Allow retrieving chroot mode from system (as well as settings) --- src/libcalamares/utils/CalamaresUtilsSystem.cpp | 6 ++++++ src/libcalamares/utils/CalamaresUtilsSystem.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/libcalamares/utils/CalamaresUtilsSystem.cpp b/src/libcalamares/utils/CalamaresUtilsSystem.cpp index ca981459c..09f6e1f95 100644 --- a/src/libcalamares/utils/CalamaresUtilsSystem.cpp +++ b/src/libcalamares/utils/CalamaresUtilsSystem.cpp @@ -243,4 +243,10 @@ System::getTotalDiskB() const return 0; } +bool +System::doChroot() const +{ + return m_doChroot; +} + } // namespace diff --git a/src/libcalamares/utils/CalamaresUtilsSystem.h b/src/libcalamares/utils/CalamaresUtilsSystem.h index be2da28ae..a4160ccd2 100644 --- a/src/libcalamares/utils/CalamaresUtilsSystem.h +++ b/src/libcalamares/utils/CalamaresUtilsSystem.h @@ -170,6 +170,8 @@ public: */ DLLEXPORT quint64 getTotalDiskB() const; + DLLEXPORT bool doChroot() const; + private: static System* s_instance; From d3ef6b07d58254be5dc49676e61af750ae1a22f0 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 3 Dec 2017 10:22:46 -0500 Subject: [PATCH 19/35] [plasmalnf] Run the lnftool in the target (user|system) --- src/modules/plasmalnf/PlasmaLnfJob.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/modules/plasmalnf/PlasmaLnfJob.cpp b/src/modules/plasmalnf/PlasmaLnfJob.cpp index c98dc7587..6c97e85e6 100644 --- a/src/modules/plasmalnf/PlasmaLnfJob.cpp +++ b/src/modules/plasmalnf/PlasmaLnfJob.cpp @@ -34,6 +34,7 @@ #include "JobQueue.h" #include "GlobalStorage.h" +#include "utils/CalamaresUtilsSystem.h" #include "utils/Logger.h" PlasmaLnfJob::PlasmaLnfJob( const QString& lnfPath, const QString& id ) @@ -71,6 +72,24 @@ PlasmaLnfJob::exec() { cDebug() << "Plasma Look-and-Feel Job"; + int r = 0; + auto system = CalamaresUtils::System::instance(); + Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); + + if ( system->doChroot() ) + { + r = system->targetEnvCall( QStringList( { m_lnfPath, "-a", m_id } ) ); + } + else + { + r = system->targetEnvCall( QStringList( + { "sudo", "-u", gs->value("username").toString(), m_lnfPath, "-a", m_id } ) ); + } + + if (r) + return Calamares::JobResult::error( + tr( "Could not select KDE Plasma Look-and-Feel package" ), + tr( "Could not select KDE Plasma Look-and-Feel package" ) ); return Calamares::JobResult::ok(); } From 3bdfa63a799311d391098e4352245860a5766c81 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 3 Dec 2017 10:38:32 -0500 Subject: [PATCH 20/35] [plasmalnf] Preserve environment, so that DISPLAY gets to the tool --- src/modules/plasmalnf/PlasmaLnfJob.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/plasmalnf/PlasmaLnfJob.cpp b/src/modules/plasmalnf/PlasmaLnfJob.cpp index 6c97e85e6..a6df3e976 100644 --- a/src/modules/plasmalnf/PlasmaLnfJob.cpp +++ b/src/modules/plasmalnf/PlasmaLnfJob.cpp @@ -83,7 +83,7 @@ PlasmaLnfJob::exec() else { r = system->targetEnvCall( QStringList( - { "sudo", "-u", gs->value("username").toString(), m_lnfPath, "-a", m_id } ) ); + { "sudo", "-E", "-u", gs->value("username").toString(), m_lnfPath, "-a", m_id } ) ); } if (r) From 81128923e6efce2b206a20949505e59e2f1371d8 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 3 Dec 2017 10:56:39 -0500 Subject: [PATCH 21/35] [plasmalnf] Disable applying in the target (user|system) for now. --- src/modules/plasmalnf/PlasmaLnfJob.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/plasmalnf/PlasmaLnfJob.cpp b/src/modules/plasmalnf/PlasmaLnfJob.cpp index a6df3e976..56b50bf45 100644 --- a/src/modules/plasmalnf/PlasmaLnfJob.cpp +++ b/src/modules/plasmalnf/PlasmaLnfJob.cpp @@ -72,6 +72,7 @@ PlasmaLnfJob::exec() { cDebug() << "Plasma Look-and-Feel Job"; +#if 0 int r = 0; auto system = CalamaresUtils::System::instance(); Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); @@ -90,6 +91,7 @@ PlasmaLnfJob::exec() return Calamares::JobResult::error( tr( "Could not select KDE Plasma Look-and-Feel package" ), tr( "Could not select KDE Plasma Look-and-Feel package" ) ); +#endif return Calamares::JobResult::ok(); } From 7e5970324ffc941f3151590d9695439ee7b82d0e Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 3 Dec 2017 11:05:14 -0500 Subject: [PATCH 22/35] [plasmalnf] Reset layout along with theme --- src/modules/plasmalnf/PlasmaLnfJob.cpp | 2 +- src/modules/plasmalnf/PlasmaLnfPage.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/plasmalnf/PlasmaLnfJob.cpp b/src/modules/plasmalnf/PlasmaLnfJob.cpp index 56b50bf45..9bc586719 100644 --- a/src/modules/plasmalnf/PlasmaLnfJob.cpp +++ b/src/modules/plasmalnf/PlasmaLnfJob.cpp @@ -79,7 +79,7 @@ PlasmaLnfJob::exec() if ( system->doChroot() ) { - r = system->targetEnvCall( QStringList( { m_lnfPath, "-a", m_id } ) ); + r = system->targetEnvCall( QStringList( { m_lnfPath, "--resetlayout", "--apply", m_id } ) ); } else { diff --git a/src/modules/plasmalnf/PlasmaLnfPage.cpp b/src/modules/plasmalnf/PlasmaLnfPage.cpp index 4989bbbcd..cff182e99 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.cpp +++ b/src/modules/plasmalnf/PlasmaLnfPage.cpp @@ -58,7 +58,7 @@ PlasmaLnfPage::activated(const QString& name) cDebug() << "Changed to" << name; QProcess lnftool; - lnftool.start( Calamares::lnftool(), {"--apply", name} ); + lnftool.start( Calamares::lnftool(), {"--resetlayout", "--apply", name} ); if ( lnftool.waitForStarted(1000) && lnftool.waitForFinished( 1000 ) && (lnftool.exitCode() == 0) && (lnftool.exitStatus() == QProcess::NormalExit ) ) ; // OK From 388399f256b158634c7b7aed24955d4053a531f4 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 3 Dec 2017 12:42:44 -0500 Subject: [PATCH 23/35] [plasmalnf] Fix command-line options, run in target user environment --- src/modules/plasmalnf/PlasmaLnfJob.cpp | 20 ++++++++------------ src/modules/plasmalnf/PlasmaLnfPage.cpp | 2 +- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/modules/plasmalnf/PlasmaLnfJob.cpp b/src/modules/plasmalnf/PlasmaLnfJob.cpp index 9bc586719..e6a4fbe10 100644 --- a/src/modules/plasmalnf/PlasmaLnfJob.cpp +++ b/src/modules/plasmalnf/PlasmaLnfJob.cpp @@ -72,26 +72,22 @@ PlasmaLnfJob::exec() { cDebug() << "Plasma Look-and-Feel Job"; -#if 0 - int r = 0; auto system = CalamaresUtils::System::instance(); Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); - if ( system->doChroot() ) - { - r = system->targetEnvCall( QStringList( { m_lnfPath, "--resetlayout", "--apply", m_id } ) ); - } - else - { - r = system->targetEnvCall( QStringList( - { "sudo", "-E", "-u", gs->value("username").toString(), m_lnfPath, "-a", m_id } ) ); - } + QStringList command; + if ( !system->doChroot() ) + command << "sudo" << "-E" << "-H" << "-u" << gs->value("username").toString(); + + command << m_lnfPath << "-platform" << "minimal" << "--resetLayout" << "--apply" << m_id; + + int r = system->targetEnvCall( command ); if (r) return Calamares::JobResult::error( tr( "Could not select KDE Plasma Look-and-Feel package" ), tr( "Could not select KDE Plasma Look-and-Feel package" ) ); -#endif + return Calamares::JobResult::ok(); } diff --git a/src/modules/plasmalnf/PlasmaLnfPage.cpp b/src/modules/plasmalnf/PlasmaLnfPage.cpp index cff182e99..632b9f13a 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.cpp +++ b/src/modules/plasmalnf/PlasmaLnfPage.cpp @@ -58,7 +58,7 @@ PlasmaLnfPage::activated(const QString& name) cDebug() << "Changed to" << name; QProcess lnftool; - lnftool.start( Calamares::lnftool(), {"--resetlayout", "--apply", name} ); + lnftool.start( Calamares::lnftool(), {"--resetLayout", "--apply", name} ); if ( lnftool.waitForStarted(1000) && lnftool.waitForFinished( 1000 ) && (lnftool.exitCode() == 0) && (lnftool.exitStatus() == QProcess::NormalExit ) ) ; // OK From 1f49f764a6328d557d623bc80ea4311e3eb3bd52 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 3 Dec 2017 10:09:00 -0500 Subject: [PATCH 24/35] [libcalamares] Allow retrieving chroot mode from system (as well as settings) --- src/libcalamares/utils/CalamaresUtilsSystem.cpp | 7 ++++++- src/libcalamares/utils/CalamaresUtilsSystem.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libcalamares/utils/CalamaresUtilsSystem.cpp b/src/libcalamares/utils/CalamaresUtilsSystem.cpp index 656a57c10..1f910230d 100644 --- a/src/libcalamares/utils/CalamaresUtilsSystem.cpp +++ b/src/libcalamares/utils/CalamaresUtilsSystem.cpp @@ -256,5 +256,10 @@ System::getTotalMemoryB() #endif } - +bool +System::doChroot() const +{ + return m_doChroot; } + +} // namespace diff --git a/src/libcalamares/utils/CalamaresUtilsSystem.h b/src/libcalamares/utils/CalamaresUtilsSystem.h index 1ccdfb516..8eeff4ef9 100644 --- a/src/libcalamares/utils/CalamaresUtilsSystem.h +++ b/src/libcalamares/utils/CalamaresUtilsSystem.h @@ -114,6 +114,8 @@ public: */ DLLEXPORT QPair getTotalMemoryB(); + DLLEXPORT bool doChroot() const; + private: static System* s_instance; From cddc4699aa6b53e3a161d2aeb762a4d2ad660942 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 3 Dec 2017 12:47:41 -0500 Subject: [PATCH 25/35] [plasmalnf] Import Plasma Look-and-Feel module independently --- src/modules/plasmalnf/CMakeLists.txt | 21 +++ src/modules/plasmalnf/PlasmaLnfInfo.cpp | 140 ++++++++++++++++++++ src/modules/plasmalnf/PlasmaLnfInfo.h | 39 ++++++ src/modules/plasmalnf/PlasmaLnfJob.cpp | 93 +++++++++++++ src/modules/plasmalnf/PlasmaLnfJob.h | 46 +++++++ src/modules/plasmalnf/PlasmaLnfPage.cpp | 70 ++++++++++ src/modules/plasmalnf/PlasmaLnfPage.h | 46 +++++++ src/modules/plasmalnf/PlasmaLnfViewStep.cpp | 138 +++++++++++++++++++ src/modules/plasmalnf/PlasmaLnfViewStep.h | 70 ++++++++++ src/modules/plasmalnf/page_plasmalnf.qrc | 1 + src/modules/plasmalnf/page_plasmalnf.ui | 53 ++++++++ src/modules/plasmalnf/plasmalnf.conf | 4 + 12 files changed, 721 insertions(+) create mode 100644 src/modules/plasmalnf/CMakeLists.txt create mode 100644 src/modules/plasmalnf/PlasmaLnfInfo.cpp create mode 100644 src/modules/plasmalnf/PlasmaLnfInfo.h create mode 100644 src/modules/plasmalnf/PlasmaLnfJob.cpp create mode 100644 src/modules/plasmalnf/PlasmaLnfJob.h create mode 100644 src/modules/plasmalnf/PlasmaLnfPage.cpp create mode 100644 src/modules/plasmalnf/PlasmaLnfPage.h create mode 100644 src/modules/plasmalnf/PlasmaLnfViewStep.cpp create mode 100644 src/modules/plasmalnf/PlasmaLnfViewStep.h create mode 100644 src/modules/plasmalnf/page_plasmalnf.qrc create mode 100644 src/modules/plasmalnf/page_plasmalnf.ui create mode 100644 src/modules/plasmalnf/plasmalnf.conf diff --git a/src/modules/plasmalnf/CMakeLists.txt b/src/modules/plasmalnf/CMakeLists.txt new file mode 100644 index 000000000..9b3ccf716 --- /dev/null +++ b/src/modules/plasmalnf/CMakeLists.txt @@ -0,0 +1,21 @@ +find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE) + +find_package( KF5 5.29 REQUIRED CoreAddons Plasma Service Package ) + +calamares_add_plugin( plasmalnf + TYPE viewmodule + EXPORT_MACRO PLUGINDLLEXPORT_PRO + SOURCES + PlasmaLnfViewStep.cpp + PlasmaLnfPage.cpp + PlasmaLnfJob.cpp + PlasmaLnfInfo.cpp + UI + page_plasmalnf.ui + LINK_PRIVATE_LIBRARIES + calamaresui + KF5::Package + KF5::Plasma + KF5::Service + SHARED_LIB +) diff --git a/src/modules/plasmalnf/PlasmaLnfInfo.cpp b/src/modules/plasmalnf/PlasmaLnfInfo.cpp new file mode 100644 index 000000000..6e9249825 --- /dev/null +++ b/src/modules/plasmalnf/PlasmaLnfInfo.cpp @@ -0,0 +1,140 @@ +/* === This file is part of Calamares - === + * + * 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 + * 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 "PlasmaLnfInfo.h" + +#include +#include +#include +#include +#include + +#include +#include +#include // Future + +#include // TODO: port to KPluginLoader +#include +#include + +#include "utils/Logger.h" + + +namespace Calamares +{ + +QStringList themes_by_package() +{ + QStringList packages; + + QList pkgs = KPackage::PackageLoader::self()->listPackages("Plasma/LookAndFeel"); + + for (const KPluginMetaData &data : pkgs) { + packages << data.pluginId(); + } + + return packages; +} + + +QStringList themes_by_service() +{ + KService::List services; + KServiceTypeTrader* trader = KServiceTypeTrader::self(); + + cDebug() << "Plasma themes by service:"; + QStringList packages; + services = trader->query("Plasma/Theme"); + int c = 0; + for ( const auto s : services ) + { + cDebug() << " .. Plasma theme" << s->name(); + packages << s->name(); + c++; + } + + return packages; +} + +QStringList themes_by_kcm() +{ + QString component; + QList packages; + QStringList paths; + QStringList packageNames; + const QStringList dataPaths = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); + + for (const QString &path : dataPaths) { + QDir dir(path + "/plasma/look-and-feel"); + paths << dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); + } + + cDebug() << "Plasma themes by kcm:"; + for (const QString &path : paths) { + Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); + pkg.setPath(path); + pkg.setFallbackPackage(Plasma::Package()); + if (component.isEmpty() || !pkg.filePath(component.toUtf8()).isEmpty()) { + packages << pkg; + packageNames << pkg.metadata().pluginName(); + cDebug() << " .. Plasma theme" << pkg.metadata().pluginName(); + } + } + + return packageNames; +} + +QStringList themes_by_lnftool() +{ + QStringList packages; + + QProcess lnftool; + lnftool.start( Calamares::lnftool(), {"--list"} ); + if ( lnftool.waitForStarted(1000) && lnftool.waitForFinished( 1000 ) && (lnftool.exitCode() == 0) && (lnftool.exitStatus() == QProcess::NormalExit ) ) + { + packages = QString::fromLocal8Bit( lnftool.readAllStandardOutput() ).trimmed().split('\n'); + } + return packages; +} + +QStringList plasma_themes() +{ + QStringList l( themes_by_package() ); + if (l.isEmpty()) + return themes_by_lnftool(); + return l; +} + +static QString *p_lnfPath = nullptr; + +QString lnftool() +{ + if ( !p_lnfPath ) + p_lnfPath = new QString("/usr/bin/lookandfeeltool"); + + return *p_lnfPath; +} + +void set_lnftool( const QString& lnfPath ) +{ + if (p_lnfPath) + delete p_lnfPath; + p_lnfPath = new QString( lnfPath ); +} + +} // namespace Calamares diff --git a/src/modules/plasmalnf/PlasmaLnfInfo.h b/src/modules/plasmalnf/PlasmaLnfInfo.h new file mode 100644 index 000000000..27adc224c --- /dev/null +++ b/src/modules/plasmalnf/PlasmaLnfInfo.h @@ -0,0 +1,39 @@ +/* === This file is part of Calamares - === + * + * 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 + * 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 PLASMALNFINFO_H +#define PLASMALNFINFO_H + +#include +#include + +namespace Calamares +{ +QString lnftool(); +void set_lnftool( const QString& ); + + /* Internal */ +QStringList themes_by_package(); +QStringList themes_by_service(); +QStringList themes_by_kcm(); +QStringList themes_by_lnftool(); + +QStringList plasma_themes(); +} + +#endif // PLASMALNFINFO_H diff --git a/src/modules/plasmalnf/PlasmaLnfJob.cpp b/src/modules/plasmalnf/PlasmaLnfJob.cpp new file mode 100644 index 000000000..e6a4fbe10 --- /dev/null +++ b/src/modules/plasmalnf/PlasmaLnfJob.cpp @@ -0,0 +1,93 @@ +/* === This file is part of Calamares - === + * + * 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 + * 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 "PlasmaLnfJob.h" + +#include +#include +#include +#include +#include + +#include +#include +#include // Future + +#include // TODO: port to KPluginLoader + +#include "CalamaresVersion.h" +#include "JobQueue.h" +#include "GlobalStorage.h" + +#include "utils/CalamaresUtilsSystem.h" +#include "utils/Logger.h" + +PlasmaLnfJob::PlasmaLnfJob( const QString& lnfPath, const QString& id ) + : m_lnfPath( lnfPath ) + , m_id(id) +{ +} + + +PlasmaLnfJob::~PlasmaLnfJob() +{ +} + + +QString +PlasmaLnfJob::prettyName() const +{ + return tr( "Plasma Look-and-Feel Job" ); +} + +QString +PlasmaLnfJob::prettyDescription() const +{ + return prettyName(); +} + +QString PlasmaLnfJob::prettyStatusMessage() const +{ + return prettyName(); +} + + +Calamares::JobResult +PlasmaLnfJob::exec() +{ + cDebug() << "Plasma Look-and-Feel Job"; + + auto system = CalamaresUtils::System::instance(); + Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); + + QStringList command; + + if ( !system->doChroot() ) + command << "sudo" << "-E" << "-H" << "-u" << gs->value("username").toString(); + + command << m_lnfPath << "-platform" << "minimal" << "--resetLayout" << "--apply" << m_id; + + int r = system->targetEnvCall( command ); + if (r) + return Calamares::JobResult::error( + tr( "Could not select KDE Plasma Look-and-Feel package" ), + tr( "Could not select KDE Plasma Look-and-Feel package" ) ); + + return Calamares::JobResult::ok(); +} + diff --git a/src/modules/plasmalnf/PlasmaLnfJob.h b/src/modules/plasmalnf/PlasmaLnfJob.h new file mode 100644 index 000000000..c7a7726ed --- /dev/null +++ b/src/modules/plasmalnf/PlasmaLnfJob.h @@ -0,0 +1,46 @@ +/* === This file is part of Calamares - === + * + * 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 + * 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 PLASMALNFJOB_H +#define PLASMALNFJOB_H + +#include +#include + +#include + +class PlasmaLnfJob : public Calamares::Job +{ + Q_OBJECT + +public: + explicit PlasmaLnfJob( const QString& lnfPath, const QString& id ); + virtual ~PlasmaLnfJob() override; + + QString prettyName() const override; + QString prettyDescription() const override; + QString prettyStatusMessage() const override; + + Calamares::JobResult exec() override; + +private: + QString m_lnfPath; + QString m_id; +}; + +#endif // PLASMALNFJOB_H diff --git a/src/modules/plasmalnf/PlasmaLnfPage.cpp b/src/modules/plasmalnf/PlasmaLnfPage.cpp new file mode 100644 index 000000000..632b9f13a --- /dev/null +++ b/src/modules/plasmalnf/PlasmaLnfPage.cpp @@ -0,0 +1,70 @@ +/* === This file is part of Calamares - === + * + * 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 + * 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 "PlasmaLnfPage.h" +#include "PlasmaLnfInfo.h" + +#include "ui_page_plasmalnf.h" + +#include "Branding.h" +#include "JobQueue.h" +#include "GlobalStorage.h" +#include "utils/Logger.h" +#include "utils/CalamaresUtilsGui.h" +#include "utils/Retranslator.h" +#include "ViewManager.h" + +#include +#include +#include +#include + +PlasmaLnfPage::PlasmaLnfPage(QWidget *parent) + : QWidget( parent ) + , ui( new Ui::PlasmaLnfPage ) +{ + using StringEntry = Calamares::Branding::StringEntry; + + ui->setupUi( this ); + CALAMARES_RETRANSLATE( + ui->retranslateUi( this ); + ui->generalExplanation->setText( tr( "Please choose a look-and-feel for the KDE Plasma Desktop, below." ) ); + ) + + Calamares::themes_by_package(); + ui->lnfCombo->addItems( Calamares::plasma_themes() ); + + QObject::connect(ui->lnfCombo, &QComboBox::activated, this, &PlasmaLnfPage::activated); +} + +void +PlasmaLnfPage::activated(const QString& name) +{ + cDebug() << "Changed to" << name; + + QProcess lnftool; + lnftool.start( Calamares::lnftool(), {"--resetLayout", "--apply", name} ); + + if ( lnftool.waitForStarted(1000) && lnftool.waitForFinished( 1000 ) && (lnftool.exitCode() == 0) && (lnftool.exitStatus() == QProcess::NormalExit ) ) + ; // OK + else + cDebug() << "WARNING: could not apply look-and-feel" << name; + + + emit plasmaThemeSelected( name ); +} diff --git a/src/modules/plasmalnf/PlasmaLnfPage.h b/src/modules/plasmalnf/PlasmaLnfPage.h new file mode 100644 index 000000000..ceed37044 --- /dev/null +++ b/src/modules/plasmalnf/PlasmaLnfPage.h @@ -0,0 +1,46 @@ +/* === This file is part of Calamares - === + * + * 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 + * 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 PLASMALNFPAGE_H +#define PLASMALNFPAGE_H + +#include +#include + +namespace Ui +{ +class PlasmaLnfPage; +} + +class PlasmaLnfPage : public QWidget +{ + Q_OBJECT +public: + explicit PlasmaLnfPage( QWidget* parent = nullptr ); + +public slots: + void activated(const QString& name); + +signals: + void plasmaThemeSelected( const QString &id ); + +private: + Ui::PlasmaLnfPage* ui; +}; + +#endif //PLASMALNFPAGE_H diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp new file mode 100644 index 000000000..73f89091b --- /dev/null +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp @@ -0,0 +1,138 @@ +/* === This file is part of Calamares - === + * + * 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 + * 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 "JobQueue.h" +#include "GlobalStorage.h" +#include "utils/Logger.h" +#include "utils/CalamaresUtils.h" +#include "utils/CalamaresUtilsSystem.h" + +#include "PlasmaLnfInfo.h" +#include "PlasmaLnfJob.h" +#include "PlasmaLnfPage.h" +#include "PlasmaLnfViewStep.h" + +#include +#include + +CALAMARES_PLUGIN_FACTORY_DEFINITION( PlasmaLnfViewStepFactory, registerPlugin(); ) + +PlasmaLnfViewStep::PlasmaLnfViewStep( QObject* parent ) + : Calamares::ViewStep( parent ) + , m_widget( new PlasmaLnfPage ) +{ + connect( m_widget, &PlasmaLnfPage::plasmaThemeSelected, this, &PlasmaLnfViewStep::themeSelected ); + emit nextStatusChanged( false ); +} + + +PlasmaLnfViewStep::~PlasmaLnfViewStep() +{ + if ( m_widget && m_widget->parent() == nullptr ) + m_widget->deleteLater(); +} + + +QString +PlasmaLnfViewStep::prettyName() const +{ + return tr( "Look-and-Feel" ); +} + + +QWidget* +PlasmaLnfViewStep::widget() +{ + return m_widget; +} + + +void +PlasmaLnfViewStep::next() +{ + emit done(); +} + + +void +PlasmaLnfViewStep::back() +{} + + +bool +PlasmaLnfViewStep::isNextEnabled() const +{ + return true; +} + + +bool +PlasmaLnfViewStep::isBackEnabled() const +{ + return true; +} + + +bool +PlasmaLnfViewStep::isAtBeginning() const +{ + return true; +} + + +bool +PlasmaLnfViewStep::isAtEnd() const +{ + return true; +} + + +void PlasmaLnfViewStep::onLeave() +{ +} + + +Calamares::JobList +PlasmaLnfViewStep::jobs() const +{ + Calamares::JobList l; + + cDebug() << "Creating Plasma LNF jobs .."; + if ( !m_themeId.isEmpty() && !m_lnfPath.isEmpty() ) + { + l.append( Calamares::job_ptr( new PlasmaLnfJob( m_lnfPath, m_themeId ) ) ); + } + return l; +} + + +void +PlasmaLnfViewStep::setConfigurationMap( const QVariantMap& configurationMap ) +{ + m_lnfPath = CalamaresUtils::getString( configurationMap, "lnftool" ); + Calamares::set_lnftool( m_lnfPath ); + + if (m_lnfPath.isEmpty()) + cDebug() << "WARNING: no lnftool given for plasmalnf module."; +} + +void +PlasmaLnfViewStep::themeSelected( const QString& id ) +{ + m_themeId = id; +} diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.h b/src/modules/plasmalnf/PlasmaLnfViewStep.h new file mode 100644 index 000000000..c2bcce2c0 --- /dev/null +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.h @@ -0,0 +1,70 @@ +/* === This file is part of Calamares - === + * + * 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 + * 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 PLASMALNFVIEWSTEP_H +#define PLASMALNFVIEWSTEP_H + +#include +#include +#include + +#include +#include +#include + +class PlasmaLnfPage; + +class PLUGINDLLEXPORT PlasmaLnfViewStep : public Calamares::ViewStep +{ + Q_OBJECT + +public: + explicit PlasmaLnfViewStep( QObject* parent = nullptr ); + virtual ~PlasmaLnfViewStep() override; + + QString prettyName() const override; + + QWidget* widget() override; + + void next() override; + void back() override; + + bool isNextEnabled() const override; + bool isBackEnabled() const override; + + bool isAtBeginning() const override; + bool isAtEnd() const override; + + void onLeave() override; + + Calamares::JobList jobs() const override; + + void setConfigurationMap( const QVariantMap& configurationMap ) override; + +public slots: + void themeSelected( const QString &id ); + +private: + PlasmaLnfPage* m_widget; + QString m_lnfPath; + QString m_themeId; +}; + +CALAMARES_PLUGIN_FACTORY_DECLARATION( PlasmaLnfViewStepFactory ) + +#endif // PLASMALNFVIEWSTEP_H diff --git a/src/modules/plasmalnf/page_plasmalnf.qrc b/src/modules/plasmalnf/page_plasmalnf.qrc new file mode 100644 index 000000000..7646d2b36 --- /dev/null +++ b/src/modules/plasmalnf/page_plasmalnf.qrc @@ -0,0 +1 @@ + diff --git a/src/modules/plasmalnf/page_plasmalnf.ui b/src/modules/plasmalnf/page_plasmalnf.ui new file mode 100644 index 000000000..340527ad0 --- /dev/null +++ b/src/modules/plasmalnf/page_plasmalnf.ui @@ -0,0 +1,53 @@ + + + PlasmaLnfPage + + + + 0 + 0 + 799 + 400 + + + + Form + + + + + + margin-bottom: 1ex; +margin-left: 2em; + + + Placeholder + + + true + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + diff --git a/src/modules/plasmalnf/plasmalnf.conf b/src/modules/plasmalnf/plasmalnf.conf new file mode 100644 index 000000000..d9817ecbc --- /dev/null +++ b/src/modules/plasmalnf/plasmalnf.conf @@ -0,0 +1,4 @@ +--- +# Full path to the Plasma look-and-feel tool (CLI program +# for querying and applying Plasma themes). +lnftool: "/usr/bin/lookandfeeltool" From 3a94f02547b2b39884680ac7e185ddab489a03f7 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 31 Oct 2017 08:25:57 -0400 Subject: [PATCH 26/35] CMake: look for ECM at top-level, add to search path if found. --- CMakeLists.txt | 10 ++++++++++ src/modules/interactiveterminal/CMakeLists.txt | 3 +-- src/modules/partition/CMakeLists.txt | 3 +-- src/modules/users/CMakeLists.txt | 3 +-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dce53b416..ad579be2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,6 +114,16 @@ find_package( Qt5 ${QT_VERSION} CONFIG REQUIRED Core Gui Widgets LinguistTools S find_package( YAMLCPP 0.5.1 REQUIRED ) find_package( PolkitQt5-1 REQUIRED ) +# Find ECM once, and add it to the module search path; Calamares +# modules that need ECM can do +# find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE), +# no need to mess with the module path after. +set( ECM_VERSION 5.10.0 ) +find_package(ECM ${ECM_VERSION} NO_MODULE) +if( ECM_FOUND ) + set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH}) +endif() + option( INSTALL_CONFIG "Install configuration files" ON ) option( WITH_PYTHON "Enable Python modules API (requires Boost.Python)." ON ) option( WITH_PYTHONQT "Enable next generation Python modules API (experimental, requires PythonQt)." OFF ) diff --git a/src/modules/interactiveterminal/CMakeLists.txt b/src/modules/interactiveterminal/CMakeLists.txt index 7b35fae0d..71f6bae14 100644 --- a/src/modules/interactiveterminal/CMakeLists.txt +++ b/src/modules/interactiveterminal/CMakeLists.txt @@ -1,5 +1,4 @@ -find_package(ECM 5.10.0 REQUIRED NO_MODULE) -set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH}) +find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE) include(KDEInstallDirs) include(GenerateExportHeader) diff --git a/src/modules/partition/CMakeLists.txt b/src/modules/partition/CMakeLists.txt index ee96c4275..c58eb1d69 100644 --- a/src/modules/partition/CMakeLists.txt +++ b/src/modules/partition/CMakeLists.txt @@ -1,5 +1,4 @@ -find_package(ECM 5.10.0 REQUIRED NO_MODULE) -set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH}) +find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE) include(KDEInstallDirs) include(GenerateExportHeader) diff --git a/src/modules/users/CMakeLists.txt b/src/modules/users/CMakeLists.txt index 074118d54..ebff9df8c 100644 --- a/src/modules/users/CMakeLists.txt +++ b/src/modules/users/CMakeLists.txt @@ -1,6 +1,5 @@ -find_package(ECM 5.10.0 NO_MODULE) +find_package(ECM ${ECM_VERSION} NO_MODULE) if( ECM_FOUND ) - set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH}) include( ECMAddTests ) endif() From ac92d4911d4f52add6ccd40710653ccecf5116f2 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 3 Dec 2017 12:58:54 -0500 Subject: [PATCH 27/35] Compatibility: revert conveniences from master --- src/modules/plasmalnf/PlasmaLnfViewStep.cpp | 9 ++++++--- src/modules/plasmalnf/PlasmaLnfViewStep.h | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp index 73f89091b..1beb71d2e 100644 --- a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp @@ -107,10 +107,10 @@ void PlasmaLnfViewStep::onLeave() } -Calamares::JobList +QList PlasmaLnfViewStep::jobs() const { - Calamares::JobList l; + QList l; cDebug() << "Creating Plasma LNF jobs .."; if ( !m_themeId.isEmpty() && !m_lnfPath.isEmpty() ) @@ -124,7 +124,10 @@ PlasmaLnfViewStep::jobs() const void PlasmaLnfViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { - m_lnfPath = CalamaresUtils::getString( configurationMap, "lnftool" ); + QString lnfPath; + if ( configurationMap.contains( "lnftool" ) && configurationMap.value( "lnftool" ).type() == QVariant::String ) + lnfPath = configurationMap.value( "lnftool" ).toString(); + m_lnfPath = lnfPath; Calamares::set_lnftool( m_lnfPath ); if (m_lnfPath.isEmpty()) diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.h b/src/modules/plasmalnf/PlasmaLnfViewStep.h index c2bcce2c0..4d2598ccc 100644 --- a/src/modules/plasmalnf/PlasmaLnfViewStep.h +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.h @@ -52,7 +52,7 @@ public: void onLeave() override; - Calamares::JobList jobs() const override; + QList jobs() const override; void setConfigurationMap( const QVariantMap& configurationMap ) override; From 4e2e55a93503faefc304ab2676db341f132e3766 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 3 Dec 2017 15:24:39 -0500 Subject: [PATCH 28/35] [plasmalnf] Needs to run as target user in all cases --- src/modules/plasmalnf/PlasmaLnfJob.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/modules/plasmalnf/PlasmaLnfJob.cpp b/src/modules/plasmalnf/PlasmaLnfJob.cpp index e6a4fbe10..a06716a89 100644 --- a/src/modules/plasmalnf/PlasmaLnfJob.cpp +++ b/src/modules/plasmalnf/PlasmaLnfJob.cpp @@ -75,12 +75,9 @@ PlasmaLnfJob::exec() auto system = CalamaresUtils::System::instance(); Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); - QStringList command; - - if ( !system->doChroot() ) - command << "sudo" << "-E" << "-H" << "-u" << gs->value("username").toString(); - - command << m_lnfPath << "-platform" << "minimal" << "--resetLayout" << "--apply" << m_id; + QStringList command( { + "sudo", "-E", "-H", "-u", gs->value("username").toString(), + m_lnfPath, "-platform", "minimal", "--resetLayout", "--apply", m_id } ); int r = system->targetEnvCall( command ); if (r) From fe8ff3ab05d8fd9ae3c85a931d7313514f9d55c7 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 3 Dec 2017 15:34:06 -0500 Subject: [PATCH 29/35] [plasmalnf] Simplify code, remove redundant implementations --- src/modules/plasmalnf/CMakeLists.txt | 3 +- src/modules/plasmalnf/PlasmaLnfInfo.cpp | 82 ------------------------- src/modules/plasmalnf/PlasmaLnfInfo.h | 8 --- src/modules/plasmalnf/PlasmaLnfPage.cpp | 20 +++++- 4 files changed, 19 insertions(+), 94 deletions(-) diff --git a/src/modules/plasmalnf/CMakeLists.txt b/src/modules/plasmalnf/CMakeLists.txt index 9b3ccf716..1bbc555c8 100644 --- a/src/modules/plasmalnf/CMakeLists.txt +++ b/src/modules/plasmalnf/CMakeLists.txt @@ -1,6 +1,6 @@ find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE) -find_package( KF5 5.29 REQUIRED CoreAddons Plasma Service Package ) +find_package( KF5 5.29 REQUIRED CoreAddons Plasma Package ) calamares_add_plugin( plasmalnf TYPE viewmodule @@ -16,6 +16,5 @@ calamares_add_plugin( plasmalnf calamaresui KF5::Package KF5::Plasma - KF5::Service SHARED_LIB ) diff --git a/src/modules/plasmalnf/PlasmaLnfInfo.cpp b/src/modules/plasmalnf/PlasmaLnfInfo.cpp index 6e9249825..1112ee18a 100644 --- a/src/modules/plasmalnf/PlasmaLnfInfo.cpp +++ b/src/modules/plasmalnf/PlasmaLnfInfo.cpp @@ -38,88 +38,6 @@ namespace Calamares { -QStringList themes_by_package() -{ - QStringList packages; - - QList pkgs = KPackage::PackageLoader::self()->listPackages("Plasma/LookAndFeel"); - - for (const KPluginMetaData &data : pkgs) { - packages << data.pluginId(); - } - - return packages; -} - - -QStringList themes_by_service() -{ - KService::List services; - KServiceTypeTrader* trader = KServiceTypeTrader::self(); - - cDebug() << "Plasma themes by service:"; - QStringList packages; - services = trader->query("Plasma/Theme"); - int c = 0; - for ( const auto s : services ) - { - cDebug() << " .. Plasma theme" << s->name(); - packages << s->name(); - c++; - } - - return packages; -} - -QStringList themes_by_kcm() -{ - QString component; - QList packages; - QStringList paths; - QStringList packageNames; - const QStringList dataPaths = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); - - for (const QString &path : dataPaths) { - QDir dir(path + "/plasma/look-and-feel"); - paths << dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); - } - - cDebug() << "Plasma themes by kcm:"; - for (const QString &path : paths) { - Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); - pkg.setPath(path); - pkg.setFallbackPackage(Plasma::Package()); - if (component.isEmpty() || !pkg.filePath(component.toUtf8()).isEmpty()) { - packages << pkg; - packageNames << pkg.metadata().pluginName(); - cDebug() << " .. Plasma theme" << pkg.metadata().pluginName(); - } - } - - return packageNames; -} - -QStringList themes_by_lnftool() -{ - QStringList packages; - - QProcess lnftool; - lnftool.start( Calamares::lnftool(), {"--list"} ); - if ( lnftool.waitForStarted(1000) && lnftool.waitForFinished( 1000 ) && (lnftool.exitCode() == 0) && (lnftool.exitStatus() == QProcess::NormalExit ) ) - { - packages = QString::fromLocal8Bit( lnftool.readAllStandardOutput() ).trimmed().split('\n'); - } - return packages; -} - -QStringList plasma_themes() -{ - QStringList l( themes_by_package() ); - if (l.isEmpty()) - return themes_by_lnftool(); - return l; -} - static QString *p_lnfPath = nullptr; QString lnftool() diff --git a/src/modules/plasmalnf/PlasmaLnfInfo.h b/src/modules/plasmalnf/PlasmaLnfInfo.h index 27adc224c..f1ed43b72 100644 --- a/src/modules/plasmalnf/PlasmaLnfInfo.h +++ b/src/modules/plasmalnf/PlasmaLnfInfo.h @@ -26,14 +26,6 @@ namespace Calamares { QString lnftool(); void set_lnftool( const QString& ); - - /* Internal */ -QStringList themes_by_package(); -QStringList themes_by_service(); -QStringList themes_by_kcm(); -QStringList themes_by_lnftool(); - -QStringList plasma_themes(); } #endif // PLASMALNFINFO_H diff --git a/src/modules/plasmalnf/PlasmaLnfPage.cpp b/src/modules/plasmalnf/PlasmaLnfPage.cpp index 632b9f13a..5a94ac789 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.cpp +++ b/src/modules/plasmalnf/PlasmaLnfPage.cpp @@ -29,11 +29,28 @@ #include "utils/Retranslator.h" #include "ViewManager.h" +#include +#include + #include #include #include #include +static QStringList plasma_themes() +{ + QStringList packages; + + QList pkgs = KPackage::PackageLoader::self()->listPackages("Plasma/LookAndFeel"); + + for (const KPluginMetaData &data : pkgs) { + packages << data.pluginId(); + } + + return packages; +} + + PlasmaLnfPage::PlasmaLnfPage(QWidget *parent) : QWidget( parent ) , ui( new Ui::PlasmaLnfPage ) @@ -46,8 +63,7 @@ PlasmaLnfPage::PlasmaLnfPage(QWidget *parent) ui->generalExplanation->setText( tr( "Please choose a look-and-feel for the KDE Plasma Desktop, below." ) ); ) - Calamares::themes_by_package(); - ui->lnfCombo->addItems( Calamares::plasma_themes() ); + ui->lnfCombo->addItems( plasma_themes() ); QObject::connect(ui->lnfCombo, &QComboBox::activated, this, &PlasmaLnfPage::activated); } From 1de2e94fd098e12908411eb19af611e65b199e46 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 3 Dec 2017 15:41:52 -0500 Subject: [PATCH 30/35] [plasmalnf] Simplify code, reduce copies of lnftool setting --- src/modules/plasmalnf/CMakeLists.txt | 1 - src/modules/plasmalnf/PlasmaLnfInfo.cpp | 58 --------------------- src/modules/plasmalnf/PlasmaLnfInfo.h | 31 ----------- src/modules/plasmalnf/PlasmaLnfPage.cpp | 9 +++- src/modules/plasmalnf/PlasmaLnfPage.h | 3 ++ src/modules/plasmalnf/PlasmaLnfViewStep.cpp | 3 +- 6 files changed, 11 insertions(+), 94 deletions(-) delete mode 100644 src/modules/plasmalnf/PlasmaLnfInfo.cpp delete mode 100644 src/modules/plasmalnf/PlasmaLnfInfo.h diff --git a/src/modules/plasmalnf/CMakeLists.txt b/src/modules/plasmalnf/CMakeLists.txt index 1bbc555c8..61b44862f 100644 --- a/src/modules/plasmalnf/CMakeLists.txt +++ b/src/modules/plasmalnf/CMakeLists.txt @@ -9,7 +9,6 @@ calamares_add_plugin( plasmalnf PlasmaLnfViewStep.cpp PlasmaLnfPage.cpp PlasmaLnfJob.cpp - PlasmaLnfInfo.cpp UI page_plasmalnf.ui LINK_PRIVATE_LIBRARIES diff --git a/src/modules/plasmalnf/PlasmaLnfInfo.cpp b/src/modules/plasmalnf/PlasmaLnfInfo.cpp deleted file mode 100644 index 1112ee18a..000000000 --- a/src/modules/plasmalnf/PlasmaLnfInfo.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* === This file is part of Calamares - === - * - * 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 - * 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 "PlasmaLnfInfo.h" - -#include -#include -#include -#include -#include - -#include -#include -#include // Future - -#include // TODO: port to KPluginLoader -#include -#include - -#include "utils/Logger.h" - - -namespace Calamares -{ - -static QString *p_lnfPath = nullptr; - -QString lnftool() -{ - if ( !p_lnfPath ) - p_lnfPath = new QString("/usr/bin/lookandfeeltool"); - - return *p_lnfPath; -} - -void set_lnftool( const QString& lnfPath ) -{ - if (p_lnfPath) - delete p_lnfPath; - p_lnfPath = new QString( lnfPath ); -} - -} // namespace Calamares diff --git a/src/modules/plasmalnf/PlasmaLnfInfo.h b/src/modules/plasmalnf/PlasmaLnfInfo.h deleted file mode 100644 index f1ed43b72..000000000 --- a/src/modules/plasmalnf/PlasmaLnfInfo.h +++ /dev/null @@ -1,31 +0,0 @@ -/* === This file is part of Calamares - === - * - * 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 - * 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 PLASMALNFINFO_H -#define PLASMALNFINFO_H - -#include -#include - -namespace Calamares -{ -QString lnftool(); -void set_lnftool( const QString& ); -} - -#endif // PLASMALNFINFO_H diff --git a/src/modules/plasmalnf/PlasmaLnfPage.cpp b/src/modules/plasmalnf/PlasmaLnfPage.cpp index 5a94ac789..65675949f 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.cpp +++ b/src/modules/plasmalnf/PlasmaLnfPage.cpp @@ -17,7 +17,6 @@ */ #include "PlasmaLnfPage.h" -#include "PlasmaLnfInfo.h" #include "ui_page_plasmalnf.h" @@ -74,7 +73,7 @@ PlasmaLnfPage::activated(const QString& name) cDebug() << "Changed to" << name; QProcess lnftool; - lnftool.start( Calamares::lnftool(), {"--resetLayout", "--apply", name} ); + lnftool.start( m_lnfPath, {"--resetLayout", "--apply", name} ); if ( lnftool.waitForStarted(1000) && lnftool.waitForFinished( 1000 ) && (lnftool.exitCode() == 0) && (lnftool.exitStatus() == QProcess::NormalExit ) ) ; // OK @@ -84,3 +83,9 @@ PlasmaLnfPage::activated(const QString& name) emit plasmaThemeSelected( name ); } + +void +PlasmaLnfPage::setLnfPath(const QString& path) +{ + m_lnfPath = path; +} diff --git a/src/modules/plasmalnf/PlasmaLnfPage.h b/src/modules/plasmalnf/PlasmaLnfPage.h index ceed37044..d146cbb95 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.h +++ b/src/modules/plasmalnf/PlasmaLnfPage.h @@ -33,6 +33,8 @@ class PlasmaLnfPage : public QWidget public: explicit PlasmaLnfPage( QWidget* parent = nullptr ); + void setLnfPath( const QString& path ); + public slots: void activated(const QString& name); @@ -41,6 +43,7 @@ signals: private: Ui::PlasmaLnfPage* ui; + QString m_lnfPath; }; #endif //PLASMALNFPAGE_H diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp index 1beb71d2e..f754c82fe 100644 --- a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp @@ -22,7 +22,6 @@ #include "utils/CalamaresUtils.h" #include "utils/CalamaresUtilsSystem.h" -#include "PlasmaLnfInfo.h" #include "PlasmaLnfJob.h" #include "PlasmaLnfPage.h" #include "PlasmaLnfViewStep.h" @@ -128,7 +127,7 @@ PlasmaLnfViewStep::setConfigurationMap( const QVariantMap& configurationMap ) if ( configurationMap.contains( "lnftool" ) && configurationMap.value( "lnftool" ).type() == QVariant::String ) lnfPath = configurationMap.value( "lnftool" ).toString(); m_lnfPath = lnfPath; - Calamares::set_lnftool( m_lnfPath ); + m_widget->setLnfPath( m_lnfPath ); if (m_lnfPath.isEmpty()) cDebug() << "WARNING: no lnftool given for plasmalnf module."; From 71966b533052344bd61d6f3513cb4f07c0952199 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 3 Dec 2017 16:09:34 -0500 Subject: [PATCH 31/35] [plasmalnf] Wait longer for the tool to finish --- src/modules/plasmalnf/PlasmaLnfPage.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/modules/plasmalnf/PlasmaLnfPage.cpp b/src/modules/plasmalnf/PlasmaLnfPage.cpp index 65675949f..14d8e9e36 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.cpp +++ b/src/modules/plasmalnf/PlasmaLnfPage.cpp @@ -75,13 +75,21 @@ PlasmaLnfPage::activated(const QString& name) QProcess lnftool; lnftool.start( m_lnfPath, {"--resetLayout", "--apply", name} ); - if ( lnftool.waitForStarted(1000) && lnftool.waitForFinished( 1000 ) && (lnftool.exitCode() == 0) && (lnftool.exitStatus() == QProcess::NormalExit ) ) - ; // OK + if ( !lnftool.waitForStarted( 1000 ) ) + { + cDebug() << "WARNING: could not start look-and-feel" << m_lnfPath; + return; + } + if ( !lnftool.waitForFinished() ) + { + cDebug() << "WARNING:" << m_lnfPath << "timed out."; + return; + } + + if ( (lnftool.exitCode() == 0) && (lnftool.exitStatus() == QProcess::NormalExit ) ) + emit plasmaThemeSelected( name ); else cDebug() << "WARNING: could not apply look-and-feel" << name; - - - emit plasmaThemeSelected( name ); } void From eb92755b0a418cfaa3b8386145a419efe95d7c55 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 4 Dec 2017 06:40:13 -0500 Subject: [PATCH 32/35] [plasmalnf] Enable translations - Move tool-running to the view-step - Enable translations by showing name instead of theme-id - More verbose logging --- src/modules/plasmalnf/PlasmaLnfPage.cpp | 41 +++++++++------------ src/modules/plasmalnf/PlasmaLnfPage.h | 13 ++++++- src/modules/plasmalnf/PlasmaLnfViewStep.cpp | 20 ++++++++++ 3 files changed, 49 insertions(+), 25 deletions(-) diff --git a/src/modules/plasmalnf/PlasmaLnfPage.cpp b/src/modules/plasmalnf/PlasmaLnfPage.cpp index 14d8e9e36..1ea20a75e 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.cpp +++ b/src/modules/plasmalnf/PlasmaLnfPage.cpp @@ -34,16 +34,19 @@ #include #include #include -#include -static QStringList plasma_themes() +static PlasmaLnfList plasma_themes() { - QStringList packages; + PlasmaLnfList packages; QList pkgs = KPackage::PackageLoader::self()->listPackages("Plasma/LookAndFeel"); for (const KPluginMetaData &data : pkgs) { - packages << data.pluginId(); + packages << PlasmaLnfDescriptor{ data.pluginId(), data.name() }; + cDebug() << "LNF Package" << data.pluginId(); + cDebug() << " .." << data.name(); + cDebug() << " .." << data.description(); + cDebug() << " .." << 'V' << data.isValid() << 'H' << data.isHidden() << 'D' << data.isEnabledByDefault(); } return packages; @@ -60,36 +63,28 @@ PlasmaLnfPage::PlasmaLnfPage(QWidget *parent) CALAMARES_RETRANSLATE( ui->retranslateUi( this ); ui->generalExplanation->setText( tr( "Please choose a look-and-feel for the KDE Plasma Desktop, below." ) ); + m_availableLnf = plasma_themes(); + ui->lnfCombo->clear(); + for ( const auto& p : m_availableLnf ) + ui->lnfCombo->addItem( p.name ); ) - ui->lnfCombo->addItems( plasma_themes() ); - QObject::connect(ui->lnfCombo, &QComboBox::activated, this, &PlasmaLnfPage::activated); + QObject::connect(ui->lnfCombo, &QComboBox::activated, this, &PlasmaLnfPage::activated); } void -PlasmaLnfPage::activated(const QString& name) +PlasmaLnfPage::activated( int index ) { - cDebug() << "Changed to" << name; - - QProcess lnftool; - lnftool.start( m_lnfPath, {"--resetLayout", "--apply", name} ); - - if ( !lnftool.waitForStarted( 1000 ) ) + if ( (index < 0) || (index > m_availableLnf.length()) ) { - cDebug() << "WARNING: could not start look-and-feel" << m_lnfPath; - return; - } - if ( !lnftool.waitForFinished() ) - { - cDebug() << "WARNING:" << m_lnfPath << "timed out."; + cDebug() << "Plasma LNF index" << index << "out of range."; return; } - if ( (lnftool.exitCode() == 0) && (lnftool.exitStatus() == QProcess::NormalExit ) ) - emit plasmaThemeSelected( name ); - else - cDebug() << "WARNING: could not apply look-and-feel" << name; + const PlasmaLnfDescriptor& lnf = m_availableLnf.at( index ); + cDebug() << "Changed to" << index << lnf.id << lnf.name; + emit plasmaThemeSelected( lnf.id ); } void diff --git a/src/modules/plasmalnf/PlasmaLnfPage.h b/src/modules/plasmalnf/PlasmaLnfPage.h index d146cbb95..e115fb649 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.h +++ b/src/modules/plasmalnf/PlasmaLnfPage.h @@ -27,6 +27,14 @@ namespace Ui class PlasmaLnfPage; } +struct PlasmaLnfDescriptor +{ + QString id; + QString name; +} ; + +using PlasmaLnfList = QList; + class PlasmaLnfPage : public QWidget { Q_OBJECT @@ -36,14 +44,15 @@ public: void setLnfPath( const QString& path ); public slots: - void activated(const QString& name); + void activated( int index ); signals: - void plasmaThemeSelected( const QString &id ); + void plasmaThemeSelected( const QString& id ); private: Ui::PlasmaLnfPage* ui; QString m_lnfPath; + PlasmaLnfList m_availableLnf; }; #endif //PLASMALNFPAGE_H diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp index f754c82fe..b9337e263 100644 --- a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp @@ -27,6 +27,7 @@ #include "PlasmaLnfViewStep.h" #include +#include #include CALAMARES_PLUGIN_FACTORY_DEFINITION( PlasmaLnfViewStepFactory, registerPlugin(); ) @@ -137,4 +138,23 @@ void PlasmaLnfViewStep::themeSelected( const QString& id ) { m_themeId = id; + + QProcess lnftool; + lnftool.start( m_lnfPath, {"--resetLayout", "--apply", id} ); + + if ( !lnftool.waitForStarted( 1000 ) ) + { + cDebug() << "WARNING: could not start look-and-feel" << m_lnfPath; + return; + } + if ( !lnftool.waitForFinished() ) + { + cDebug() << "WARNING:" << m_lnfPath << "timed out."; + return; + } + + if ( (lnftool.exitCode() == 0) && (lnftool.exitStatus() == QProcess::NormalExit ) ) + cDebug() << "Plasma look-and-feel applied" << id; + else + cDebug() << "WARNING: could not apply look-and-feel" << id; } From b10b19e9ee5a704fac051f0186f6b1bdd86d0fcc Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 4 Dec 2017 06:44:37 -0500 Subject: [PATCH 33/35] [plasmalnf] C++ style and reduce includes --- src/modules/plasmalnf/PlasmaLnfJob.cpp | 32 +++++++-------------- src/modules/plasmalnf/PlasmaLnfPage.cpp | 27 ++++++----------- src/modules/plasmalnf/PlasmaLnfPage.h | 3 +- src/modules/plasmalnf/PlasmaLnfViewStep.cpp | 17 ++++------- src/modules/plasmalnf/PlasmaLnfViewStep.h | 2 +- 5 files changed, 27 insertions(+), 54 deletions(-) diff --git a/src/modules/plasmalnf/PlasmaLnfJob.cpp b/src/modules/plasmalnf/PlasmaLnfJob.cpp index a06716a89..82d55f609 100644 --- a/src/modules/plasmalnf/PlasmaLnfJob.cpp +++ b/src/modules/plasmalnf/PlasmaLnfJob.cpp @@ -18,28 +18,14 @@ #include "PlasmaLnfJob.h" -#include -#include -#include -#include -#include - -#include -#include -#include // Future - -#include // TODO: port to KPluginLoader - -#include "CalamaresVersion.h" -#include "JobQueue.h" #include "GlobalStorage.h" - +#include "JobQueue.h" #include "utils/CalamaresUtilsSystem.h" #include "utils/Logger.h" PlasmaLnfJob::PlasmaLnfJob( const QString& lnfPath, const QString& id ) : m_lnfPath( lnfPath ) - , m_id(id) + , m_id( id ) { } @@ -75,15 +61,17 @@ PlasmaLnfJob::exec() auto system = CalamaresUtils::System::instance(); Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); - QStringList command( { - "sudo", "-E", "-H", "-u", gs->value("username").toString(), - m_lnfPath, "-platform", "minimal", "--resetLayout", "--apply", m_id } ); + QStringList command( + { + "sudo", "-E", "-H", "-u", gs->value( "username" ).toString(), + m_lnfPath, "-platform", "minimal", "--resetLayout", "--apply", m_id + } ); int r = system->targetEnvCall( command ); - if (r) + if ( r ) return Calamares::JobResult::error( - tr( "Could not select KDE Plasma Look-and-Feel package" ), - tr( "Could not select KDE Plasma Look-and-Feel package" ) ); + tr( "Could not select KDE Plasma Look-and-Feel package" ), + tr( "Could not select KDE Plasma Look-and-Feel package" ) ); return Calamares::JobResult::ok(); } diff --git a/src/modules/plasmalnf/PlasmaLnfPage.cpp b/src/modules/plasmalnf/PlasmaLnfPage.cpp index 1ea20a75e..01759ba32 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.cpp +++ b/src/modules/plasmalnf/PlasmaLnfPage.cpp @@ -20,28 +20,20 @@ #include "ui_page_plasmalnf.h" -#include "Branding.h" -#include "JobQueue.h" -#include "GlobalStorage.h" #include "utils/Logger.h" -#include "utils/CalamaresUtilsGui.h" #include "utils/Retranslator.h" -#include "ViewManager.h" #include #include -#include -#include -#include - static PlasmaLnfList plasma_themes() { PlasmaLnfList packages; - QList pkgs = KPackage::PackageLoader::self()->listPackages("Plasma/LookAndFeel"); + QList pkgs = KPackage::PackageLoader::self()->listPackages( "Plasma/LookAndFeel" ); - for (const KPluginMetaData &data : pkgs) { + for ( const KPluginMetaData& data : pkgs ) + { packages << PlasmaLnfDescriptor{ data.pluginId(), data.name() }; cDebug() << "LNF Package" << data.pluginId(); cDebug() << " .." << data.name(); @@ -53,30 +45,29 @@ static PlasmaLnfList plasma_themes() } -PlasmaLnfPage::PlasmaLnfPage(QWidget *parent) +PlasmaLnfPage::PlasmaLnfPage( QWidget* parent ) : QWidget( parent ) , ui( new Ui::PlasmaLnfPage ) { - using StringEntry = Calamares::Branding::StringEntry; - ui->setupUi( this ); CALAMARES_RETRANSLATE( + { ui->retranslateUi( this ); ui->generalExplanation->setText( tr( "Please choose a look-and-feel for the KDE Plasma Desktop, below." ) ); m_availableLnf = plasma_themes(); ui->lnfCombo->clear(); for ( const auto& p : m_availableLnf ) ui->lnfCombo->addItem( p.name ); + } ) - - QObject::connect(ui->lnfCombo, &QComboBox::activated, this, &PlasmaLnfPage::activated); + QObject::connect( ui->lnfCombo, &QComboBox::activated, this, &PlasmaLnfPage::activated ); } void PlasmaLnfPage::activated( int index ) { - if ( (index < 0) || (index > m_availableLnf.length()) ) + if ( ( index < 0 ) || ( index > m_availableLnf.length() ) ) { cDebug() << "Plasma LNF index" << index << "out of range."; return; @@ -88,7 +79,7 @@ PlasmaLnfPage::activated( int index ) } void -PlasmaLnfPage::setLnfPath(const QString& path) +PlasmaLnfPage::setLnfPath( const QString& path ) { m_lnfPath = path; } diff --git a/src/modules/plasmalnf/PlasmaLnfPage.h b/src/modules/plasmalnf/PlasmaLnfPage.h index e115fb649..31731eb0d 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.h +++ b/src/modules/plasmalnf/PlasmaLnfPage.h @@ -19,8 +19,9 @@ #ifndef PLASMALNFPAGE_H #define PLASMALNFPAGE_H +#include +#include #include -#include namespace Ui { diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp index b9337e263..1ac3226b1 100644 --- a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp @@ -15,18 +15,13 @@ * You should have received a copy of the GNU General Public License * along with Calamares. If not, see . */ - -#include "JobQueue.h" -#include "GlobalStorage.h" -#include "utils/Logger.h" -#include "utils/CalamaresUtils.h" -#include "utils/CalamaresUtilsSystem.h" +#include "PlasmaLnfViewStep.h" #include "PlasmaLnfJob.h" #include "PlasmaLnfPage.h" -#include "PlasmaLnfViewStep.h" -#include +#include "utils/Logger.h" + #include #include @@ -114,9 +109,7 @@ PlasmaLnfViewStep::jobs() const cDebug() << "Creating Plasma LNF jobs .."; if ( !m_themeId.isEmpty() && !m_lnfPath.isEmpty() ) - { l.append( Calamares::job_ptr( new PlasmaLnfJob( m_lnfPath, m_themeId ) ) ); - } return l; } @@ -130,7 +123,7 @@ PlasmaLnfViewStep::setConfigurationMap( const QVariantMap& configurationMap ) m_lnfPath = lnfPath; m_widget->setLnfPath( m_lnfPath ); - if (m_lnfPath.isEmpty()) + if ( m_lnfPath.isEmpty() ) cDebug() << "WARNING: no lnftool given for plasmalnf module."; } @@ -153,7 +146,7 @@ PlasmaLnfViewStep::themeSelected( const QString& id ) return; } - if ( (lnftool.exitCode() == 0) && (lnftool.exitStatus() == QProcess::NormalExit ) ) + if ( ( lnftool.exitCode() == 0 ) && ( lnftool.exitStatus() == QProcess::NormalExit ) ) cDebug() << "Plasma look-and-feel applied" << id; else cDebug() << "WARNING: could not apply look-and-feel" << id; diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.h b/src/modules/plasmalnf/PlasmaLnfViewStep.h index 4d2598ccc..e65b59b93 100644 --- a/src/modules/plasmalnf/PlasmaLnfViewStep.h +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.h @@ -57,7 +57,7 @@ public: void setConfigurationMap( const QVariantMap& configurationMap ) override; public slots: - void themeSelected( const QString &id ); + void themeSelected( const QString& id ); private: PlasmaLnfPage* m_widget; From e628ddfdbfbf83b9052b099cfd00abac3ba0143a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 4 Dec 2017 09:37:34 -0500 Subject: [PATCH 34/35] [plasmalnf] Try to get back to the live user before changing themes --- src/modules/plasmalnf/PlasmaLnfViewStep.cpp | 10 +++++++++- src/modules/plasmalnf/PlasmaLnfViewStep.h | 1 + src/modules/plasmalnf/plasmalnf.conf | 6 ++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp index 1ac3226b1..fd6eab78d 100644 --- a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp @@ -125,6 +125,11 @@ PlasmaLnfViewStep::setConfigurationMap( const QVariantMap& configurationMap ) if ( m_lnfPath.isEmpty() ) cDebug() << "WARNING: no lnftool given for plasmalnf module."; + + QString liveUser; + if ( configurationMap.contains( "liveuser" ) && configurationMap.value( "liveuser" ).type() == QVariant::String ) + liveUser = configurationMap.value( "liveuser" ).toString(); + m_liveUser = liveUser; } void @@ -133,7 +138,10 @@ PlasmaLnfViewStep::themeSelected( const QString& id ) m_themeId = id; QProcess lnftool; - lnftool.start( m_lnfPath, {"--resetLayout", "--apply", id} ); + if ( !m_liveUser.isEmpty() ) + lnftool.start( "sudo", {"-E", "-H", "-u", m_liveUser, m_lnfPath, "--resetLayout", "--apply", id} ); + else + lnftool.start( m_lnfPath, {"--resetLayout", "--apply", id} ); if ( !lnftool.waitForStarted( 1000 ) ) { diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.h b/src/modules/plasmalnf/PlasmaLnfViewStep.h index e65b59b93..7fcfc50cc 100644 --- a/src/modules/plasmalnf/PlasmaLnfViewStep.h +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.h @@ -63,6 +63,7 @@ private: PlasmaLnfPage* m_widget; QString m_lnfPath; QString m_themeId; + QString m_liveUser; }; CALAMARES_PLUGIN_FACTORY_DECLARATION( PlasmaLnfViewStepFactory ) diff --git a/src/modules/plasmalnf/plasmalnf.conf b/src/modules/plasmalnf/plasmalnf.conf index d9817ecbc..059ed9e36 100644 --- a/src/modules/plasmalnf/plasmalnf.conf +++ b/src/modules/plasmalnf/plasmalnf.conf @@ -2,3 +2,9 @@ # Full path to the Plasma look-and-feel tool (CLI program # for querying and applying Plasma themes). lnftool: "/usr/bin/lookandfeeltool" + +# For systems where the user Calamares runs as (usually root, +# via either sudo or pkexec) has a clean environment, set this +# to the originating username; the lnftool will be run through +# "sudo -H -u " instead of directly. +liveuser: "live" From 02dfe51d55dc1443d43019b133665d40fde979b6 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 4 Dec 2017 10:47:26 -0500 Subject: [PATCH 35/35] [welcome] Improve error reporting from requirements checker --- .../welcome/checker/RequirementsChecker.cpp | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/modules/welcome/checker/RequirementsChecker.cpp b/src/modules/welcome/checker/RequirementsChecker.cpp index 3d4e394c4..e56e88a4c 100644 --- a/src/modules/welcome/checker/RequirementsChecker.cpp +++ b/src/modules/welcome/checker/RequirementsChecker.cpp @@ -213,12 +213,16 @@ RequirementsChecker::setConfigurationMap( const QVariantMap& configurationMap ) bool ok = false; m_requiredStorageGB = configurationMap.value( "requiredStorage" ).toDouble( &ok ); if ( !ok ) + { + cDebug() << "WARNING: RequirementsChecker entry 'requiredStorage' is invalid."; m_requiredStorageGB = 3.; + } Calamares::JobQueue::instance()->globalStorage()->insert( "requiredStorageGB", m_requiredStorageGB ); } else { + cDebug() << "WARNING: RequirementsChecker entry 'requiredStorage' is missing."; m_requiredStorageGB = 3.; incompleteConfiguration = true; } @@ -231,12 +235,14 @@ RequirementsChecker::setConfigurationMap( const QVariantMap& configurationMap ) m_requiredRamGB = configurationMap.value( "requiredRam" ).toDouble( &ok ); if ( !ok ) { + cDebug() << "WARNING: RequirementsChecker entry 'requiredRam' is invalid."; m_requiredRamGB = 1.; incompleteConfiguration = true; } } else { + cDebug() << "WARNING: RequirementsChecker entry 'requiredRam' is missing."; m_requiredRamGB = 1.; incompleteConfiguration = true; } @@ -248,7 +254,7 @@ RequirementsChecker::setConfigurationMap( const QVariantMap& configurationMap ) if ( m_checkHasInternetUrl.isEmpty() || !QUrl( m_checkHasInternetUrl ).isValid() ) { - cDebug() << "Invalid internetCheckUrl in welcome.conf" << m_checkHasInternetUrl + cDebug() << "WARNING: RequirementsChecker entry 'internetCheckUrl' is invalid in welcome.conf" << m_checkHasInternetUrl << "reverting to default (http://example.com)."; m_checkHasInternetUrl = "http://example.com"; incompleteConfiguration = true; @@ -256,8 +262,9 @@ RequirementsChecker::setConfigurationMap( const QVariantMap& configurationMap ) } else { - cDebug() << "internetCheckUrl is undefined in welcome.conf, " + cDebug() << "WARNING: RequirementsChecker entry 'internetCheckUrl' is undefined in welcome.conf," "reverting to default (http://example.com)."; + m_checkHasInternetUrl = "http://example.com"; incompleteConfiguration = true; } @@ -269,7 +276,10 @@ RequirementsChecker::setConfigurationMap( const QVariantMap& configurationMap ) m_entriesToCheck.append( configurationMap.value( "check" ).toStringList() ); } else + { + cDebug() << "WARNING: RequirementsChecker entry 'check' is incomplete."; incompleteConfiguration = true; + } if ( configurationMap.contains( "required" ) && configurationMap.value( "required" ).type() == QVariant::List ) @@ -278,18 +288,13 @@ RequirementsChecker::setConfigurationMap( const QVariantMap& configurationMap ) m_entriesToRequire.append( configurationMap.value( "required" ).toStringList() ); } else + { + cDebug() << "WARNING: RequirementsChecker entry 'required' is incomplete."; incompleteConfiguration = true; + } if ( incompleteConfiguration ) - { - cDebug() << "WARNING: The RequirementsChecker configuration map provided by " - "the welcome module configuration file is incomplete or " - "incorrect.\n" - "Startup will continue for debugging purposes, but one or " - "more checks might not function correctly.\n" - "RequirementsChecker configuration map:\n" - << configurationMap; - } + cDebug() << "WARNING: RequirementsChecker configuration map:\n" << configurationMap; }