[Merge] with upstream
This commit is contained in:
commit
978bc2a4ef
@ -130,6 +130,16 @@ if( ECM_FOUND )
|
||||
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH})
|
||||
endif()
|
||||
|
||||
# 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 )
|
||||
|
@ -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()
|
||||
|
@ -234,7 +234,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
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
explicit Helper( QObject* parent = nullptr );
|
||||
virtual ~Helper();
|
||||
|
||||
boost::python::object createCleanNamespace();
|
||||
boost::python::dict createCleanNamespace();
|
||||
|
||||
QString handleLastError();
|
||||
|
||||
|
@ -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() )
|
||||
|
@ -243,4 +243,10 @@ System::getTotalDiskB() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool
|
||||
System::doChroot() const
|
||||
{
|
||||
return m_doChroot;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -170,6 +170,8 @@ public:
|
||||
*/
|
||||
DLLEXPORT quint64 getTotalDiskB() const;
|
||||
|
||||
DLLEXPORT bool doChroot() const;
|
||||
|
||||
private:
|
||||
static System* s_instance;
|
||||
|
||||
|
@ -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)
|
||||
|
@ -4,7 +4,6 @@
|
||||
# === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
#
|
||||
# Copyright 2017, Ghiunhan Mamut <venerix@redcorelinux.org>
|
||||
# Copyright 2017, Philip Müller <philm@manjaro.org>
|
||||
#
|
||||
# Calamares is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -22,36 +21,38 @@
|
||||
import libcalamares
|
||||
import os.path
|
||||
|
||||
|
||||
def write_dmcrypt_conf(partitions, root_mount_point, dmcrypt_conf_path):
|
||||
crypto_target = ""
|
||||
crypto_source = ""
|
||||
|
||||
for partition in partitions:
|
||||
if partition["mountPoint"] == "/home" \
|
||||
and "luksMapperName" in partition:
|
||||
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"]))
|
||||
|
||||
if "luksMapperName" not in partition:
|
||||
return None
|
||||
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")
|
||||
|
||||
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")
|
||||
dmcrypt_file.close()
|
||||
if has_luks and skip_partitions:
|
||||
pass # root and swap partitions should be handled by initramfs generators
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def run():
|
||||
"""
|
||||
This module configures the OpenRC dmcrypt service for an encrypted
|
||||
/home partition.
|
||||
This module configures OpenRC dmcrypt service for LUKS encrypted partitions.
|
||||
:return:
|
||||
"""
|
||||
|
||||
@ -62,3 +63,4 @@ def run():
|
||||
dmcrypt_conf_path = dmcrypt_conf_path.lstrip('/')
|
||||
|
||||
return write_dmcrypt_conf(partitions, root_mount_point, dmcrypt_conf_path)
|
||||
|
||||
|
@ -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)
|
||||
@ -422,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"):
|
||||
libcalamares.utils.debug( "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()
|
||||
|
@ -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
|
||||
|
||||
#
|
||||
@ -29,9 +40,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 +61,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 +86,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
|
||||
#
|
||||
|
@ -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)
|
||||
|
19
src/modules/plasmalnf/CMakeLists.txt
Normal file
19
src/modules/plasmalnf/CMakeLists.txt
Normal file
@ -0,0 +1,19 @@
|
||||
find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE)
|
||||
|
||||
find_package( KF5 5.29 REQUIRED CoreAddons Plasma Package )
|
||||
|
||||
calamares_add_plugin( plasmalnf
|
||||
TYPE viewmodule
|
||||
EXPORT_MACRO PLUGINDLLEXPORT_PRO
|
||||
SOURCES
|
||||
PlasmaLnfViewStep.cpp
|
||||
PlasmaLnfPage.cpp
|
||||
PlasmaLnfJob.cpp
|
||||
UI
|
||||
page_plasmalnf.ui
|
||||
LINK_PRIVATE_LIBRARIES
|
||||
calamaresui
|
||||
KF5::Package
|
||||
KF5::Plasma
|
||||
SHARED_LIB
|
||||
)
|
78
src/modules/plasmalnf/PlasmaLnfJob.cpp
Normal file
78
src/modules/plasmalnf/PlasmaLnfJob.cpp
Normal file
@ -0,0 +1,78 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "PlasmaLnfJob.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 )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
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(
|
||||
{
|
||||
"sudo", "-E", "-H", "-u", gs->value( "username" ).toString(),
|
||||
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();
|
||||
}
|
||||
|
46
src/modules/plasmalnf/PlasmaLnfJob.h
Normal file
46
src/modules/plasmalnf/PlasmaLnfJob.h
Normal file
@ -0,0 +1,46 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PLASMALNFJOB_H
|
||||
#define PLASMALNFJOB_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QVariantMap>
|
||||
|
||||
#include <Job.h>
|
||||
|
||||
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
|
85
src/modules/plasmalnf/PlasmaLnfPage.cpp
Normal file
85
src/modules/plasmalnf/PlasmaLnfPage.cpp
Normal file
@ -0,0 +1,85 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "PlasmaLnfPage.h"
|
||||
|
||||
#include "ui_page_plasmalnf.h"
|
||||
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/Retranslator.h"
|
||||
|
||||
#include <KPackage/Package>
|
||||
#include <KPackage/PackageLoader>
|
||||
|
||||
static PlasmaLnfList plasma_themes()
|
||||
{
|
||||
PlasmaLnfList packages;
|
||||
|
||||
QList<KPluginMetaData> pkgs = KPackage::PackageLoader::self()->listPackages( "Plasma/LookAndFeel" );
|
||||
|
||||
for ( const KPluginMetaData& data : pkgs )
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
PlasmaLnfPage::PlasmaLnfPage( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, ui( new Ui::PlasmaLnfPage )
|
||||
{
|
||||
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<void( QComboBox::* )( int )>( ui->lnfCombo, &QComboBox::activated, this, &PlasmaLnfPage::activated );
|
||||
}
|
||||
|
||||
void
|
||||
PlasmaLnfPage::activated( int index )
|
||||
{
|
||||
if ( ( index < 0 ) || ( index > m_availableLnf.length() ) )
|
||||
{
|
||||
cDebug() << "Plasma LNF index" << index << "out of range.";
|
||||
return;
|
||||
}
|
||||
|
||||
const PlasmaLnfDescriptor& lnf = m_availableLnf.at( index );
|
||||
cDebug() << "Changed to" << index << lnf.id << lnf.name;
|
||||
emit plasmaThemeSelected( lnf.id );
|
||||
}
|
||||
|
||||
void
|
||||
PlasmaLnfPage::setLnfPath( const QString& path )
|
||||
{
|
||||
m_lnfPath = path;
|
||||
}
|
59
src/modules/plasmalnf/PlasmaLnfPage.h
Normal file
59
src/modules/plasmalnf/PlasmaLnfPage.h
Normal file
@ -0,0 +1,59 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PLASMALNFPAGE_H
|
||||
#define PLASMALNFPAGE_H
|
||||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class PlasmaLnfPage;
|
||||
}
|
||||
|
||||
struct PlasmaLnfDescriptor
|
||||
{
|
||||
QString id;
|
||||
QString name;
|
||||
} ;
|
||||
|
||||
using PlasmaLnfList = QList<PlasmaLnfDescriptor>;
|
||||
|
||||
class PlasmaLnfPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PlasmaLnfPage( QWidget* parent = nullptr );
|
||||
|
||||
void setLnfPath( const QString& path );
|
||||
|
||||
public slots:
|
||||
void activated( int index );
|
||||
|
||||
signals:
|
||||
void plasmaThemeSelected( const QString& id );
|
||||
|
||||
private:
|
||||
Ui::PlasmaLnfPage* ui;
|
||||
QString m_lnfPath;
|
||||
PlasmaLnfList m_availableLnf;
|
||||
};
|
||||
|
||||
#endif //PLASMALNFPAGE_H
|
156
src/modules/plasmalnf/PlasmaLnfViewStep.cpp
Normal file
156
src/modules/plasmalnf/PlasmaLnfViewStep.cpp
Normal file
@ -0,0 +1,156 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "PlasmaLnfViewStep.h"
|
||||
|
||||
#include "PlasmaLnfJob.h"
|
||||
#include "PlasmaLnfPage.h"
|
||||
|
||||
#include "utils/CalamaresUtils.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
#include <QProcess>
|
||||
#include <QVariantMap>
|
||||
|
||||
CALAMARES_PLUGIN_FACTORY_DEFINITION( PlasmaLnfViewStepFactory, registerPlugin<PlasmaLnfViewStep>(); )
|
||||
|
||||
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" );
|
||||
m_widget->setLnfPath( m_lnfPath );
|
||||
|
||||
if ( m_lnfPath.isEmpty() )
|
||||
cDebug() << "WARNING: no lnftool given for plasmalnf module.";
|
||||
|
||||
m_liveUser = CalamaresUtils::getString( configurationMap, "liveuser" );
|
||||
}
|
||||
|
||||
void
|
||||
PlasmaLnfViewStep::themeSelected( const QString& id )
|
||||
{
|
||||
m_themeId = id;
|
||||
|
||||
QProcess lnftool;
|
||||
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 ) )
|
||||
{
|
||||
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;
|
||||
}
|
71
src/modules/plasmalnf/PlasmaLnfViewStep.h
Normal file
71
src/modules/plasmalnf/PlasmaLnfViewStep.h
Normal file
@ -0,0 +1,71 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2017, Adriaan de Groot <groot@kde..org>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PLASMALNFVIEWSTEP_H
|
||||
#define PLASMALNFVIEWSTEP_H
|
||||
|
||||
#include <utils/PluginFactory.h>
|
||||
#include <viewpages/ViewStep.h>
|
||||
#include <PluginDllMacro.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QUrl>
|
||||
#include <QVariantMap>
|
||||
|
||||
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;
|
||||
QString m_liveUser;
|
||||
};
|
||||
|
||||
CALAMARES_PLUGIN_FACTORY_DECLARATION( PlasmaLnfViewStepFactory )
|
||||
|
||||
#endif // PLASMALNFVIEWSTEP_H
|
1
src/modules/plasmalnf/page_plasmalnf.qrc
Normal file
1
src/modules/plasmalnf/page_plasmalnf.qrc
Normal file
@ -0,0 +1 @@
|
||||
<RCC/>
|
53
src/modules/plasmalnf/page_plasmalnf.ui
Normal file
53
src/modules/plasmalnf/page_plasmalnf.ui
Normal file
@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PlasmaLnfPage</class>
|
||||
<widget class="QWidget" name="PlasmaLnfPage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>799</width>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0">
|
||||
<item>
|
||||
<widget class="QLabel" name="generalExplanation">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">margin-bottom: 1ex;
|
||||
margin-left: 2em;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Placeholder</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="lnfCombo"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="page_plasmalnf.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
20
src/modules/plasmalnf/plasmalnf.conf
Normal file
20
src/modules/plasmalnf/plasmalnf.conf
Normal file
@ -0,0 +1,20 @@
|
||||
# The Plasma Look-and-Feel module allows selecting a Plasma
|
||||
# Look-and-Feel in the live- or host-system and switches the
|
||||
# host Plasma session immediately to the chosen LnF; it
|
||||
# can also write a LnF configuration to the target user / on
|
||||
# the target system.
|
||||
#
|
||||
# This module should be used once in a view section (to get
|
||||
# the UI) and once in the exec section (to apply the selection
|
||||
# to the target user). It should come **after** the user module
|
||||
# in exec, so that the target user has been created alrady.
|
||||
---
|
||||
# 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 <liveuser>" instead of directly.
|
||||
liveuser: "live"
|
@ -19,14 +19,25 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
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)
|
||||
|
||||
|
||||
|
@ -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()
|
||||
|
||||
|
@ -218,12 +218,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;
|
||||
}
|
||||
@ -236,12 +240,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;
|
||||
}
|
||||
@ -253,7 +259,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;
|
||||
@ -261,8 +267,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;
|
||||
}
|
||||
@ -274,7 +281,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 )
|
||||
@ -283,18 +293,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;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user