[Merge] with upstream

This commit is contained in:
Philip 2017-12-07 16:49:55 -05:00
commit 978bc2a4ef
25 changed files with 751 additions and 70 deletions

View File

@ -130,6 +130,16 @@ if( ECM_FOUND )
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH}) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH})
endif() 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( INSTALL_CONFIG "Install configuration files" ON )
option( WITH_PYTHON "Enable Python modules API (requires Boost.Python)." 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 ) option( WITH_PYTHONQT "Enable next generation Python modules API (experimental, requires PythonQt)." OFF )

View File

@ -139,4 +139,16 @@ if(PYTHONQT_INCLUDE_DIR AND PYTHONQT_LIBRARY AND PYTHONQT_QTALL_LIBRARY)
set(PYTHONQT_FOUND 1) set(PYTHONQT_FOUND 1)
set(PythonQt_FOUND ${PYTHONQT_FOUND}) set(PythonQt_FOUND ${PYTHONQT_FOUND})
set(PYTHONQT_LIBRARIES ${PYTHONQT_LIBRARY} ${PYTHONQT_LIBUTIL} ${PYTHONQT_QTALL_LIBRARY}) 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() endif()

View File

@ -234,7 +234,7 @@ Helper::~Helper()
{} {}
boost::python::object boost::python::dict
Helper::createCleanNamespace() Helper::createCleanNamespace()
{ {
// To make sure we run each script with a clean namespace, we only fetch the // To make sure we run each script with a clean namespace, we only fetch the

View File

@ -51,7 +51,7 @@ public:
explicit Helper( QObject* parent = nullptr ); explicit Helper( QObject* parent = nullptr );
virtual ~Helper(); virtual ~Helper();
boost::python::object createCleanNamespace(); boost::python::dict createCleanNamespace();
QString handleLastError(); QString handleLastError();

View File

@ -296,7 +296,7 @@ PythonJob::exec()
try try
{ {
bp::object scriptNamespace = helper()->createCleanNamespace(); bp::dict scriptNamespace = helper()->createCleanNamespace();
bp::object calamaresModule = bp::import( "libcalamares" ); bp::object calamaresModule = bp::import( "libcalamares" );
bp::dict calamaresNamespace = bp::extract< bp::dict >( calamaresModule.attr( "__dict__" ) ); bp::dict calamaresNamespace = bp::extract< bp::dict >( calamaresModule.attr( "__dict__" ) );
@ -310,7 +310,7 @@ PythonJob::exec()
scriptNamespace ); scriptNamespace );
bp::object entryPoint = scriptNamespace[ "run" ]; 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(); cDebug() << "Job file" << scriptFI.absoluteFilePath();
if ( !prettyNameFunc.is_none() ) if ( !prettyNameFunc.is_none() )

View File

@ -243,4 +243,10 @@ System::getTotalDiskB() const
return 0; return 0;
} }
bool
System::doChroot() const
{
return m_doChroot;
}
} // namespace } // namespace

View File

@ -170,6 +170,8 @@ public:
*/ */
DLLEXPORT quint64 getTotalDiskB() const; DLLEXPORT quint64 getTotalDiskB() const;
DLLEXPORT bool doChroot() const;
private: private:
static System* s_instance; static System* s_instance;

View File

@ -1,5 +1,4 @@
find_package(ECM 5.10.0 REQUIRED NO_MODULE) find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH})
include(KDEInstallDirs) include(KDEInstallDirs)
include(GenerateExportHeader) include(GenerateExportHeader)

View File

@ -4,7 +4,6 @@
# === This file is part of Calamares - <http://github.com/calamares> === # === This file is part of Calamares - <http://github.com/calamares> ===
# #
# Copyright 2017, Ghiunhan Mamut <venerix@redcorelinux.org> # 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 # Calamares is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -22,36 +21,38 @@
import libcalamares import libcalamares
import os.path import os.path
def write_dmcrypt_conf(partitions, root_mount_point, dmcrypt_conf_path): def write_dmcrypt_conf(partitions, root_mount_point, dmcrypt_conf_path):
crypto_target = "" crypto_target = ""
crypto_source = "" crypto_source = ""
for partition in partitions: for partition in partitions:
if partition["mountPoint"] == "/home" \ has_luks = "luksMapperName" in partition
and "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_target = partition["luksMapperName"]
crypto_source = "/dev/disk/by-uuid/{!s}".format(partition["uuid"]) 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: with open(os.path.join(root_mount_point, dmcrypt_conf_path), 'a+') as dmcrypt_file:
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("\ntarget=" + crypto_target)
dmcrypt_file.write("\nsource=" + crypto_source) dmcrypt_file.write("\nsource=" + crypto_source)
dmcrypt_file.write("\nkey=/crypto_keyfile.bin") dmcrypt_file.write("\nkey=/crypto_keyfile.bin")
dmcrypt_file.write("\n") 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 return None
def run(): def run():
""" """
This module configures the OpenRC dmcrypt service for an encrypted This module configures OpenRC dmcrypt service for LUKS encrypted partitions.
/home partition.
:return: :return:
""" """
@ -62,3 +63,4 @@ def run():
dmcrypt_conf_path = dmcrypt_conf_path.lstrip('/') dmcrypt_conf_path = dmcrypt_conf_path.lstrip('/')
return write_dmcrypt_conf(partitions, root_mount_point, dmcrypt_conf_path) return write_dmcrypt_conf(partitions, root_mount_point, dmcrypt_conf_path)

View File

@ -55,8 +55,12 @@ def _change_mode(mode):
def pretty_name(): def pretty_name():
if not group_packages: if not group_packages:
if (total_packages > 0):
# Outside the context of an operation # Outside the context of an operation
s = _("Processing packages (%(count)d / %(total)d)") s = _("Processing packages (%(count)d / %(total)d)")
else:
s = _("Install packages.")
elif mode_packages is INSTALL: elif mode_packages is INSTALL:
s = _n("Installing one package.", s = _n("Installing one package.",
"Installing %(num)d packages.", group_packages) "Installing %(num)d packages.", group_packages)
@ -422,6 +426,11 @@ def run():
else: else:
return "Bad backend", "backend=\"{}\"".format(backend) 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) update_db = libcalamares.job.configuration.get("update_db", False)
if update_db and libcalamares.globalstorage.value("hasInternet"): if update_db and libcalamares.globalstorage.value("hasInternet"):
pkgman.update_db() pkgman.update_db()

View File

@ -14,9 +14,20 @@
# #
backend: dummy backend: dummy
# If set to true, a package-manager specific update procedure # Often package installation needs an internet connection.
# is run first (only if there is internet) to update the list # Since you may allow system installation without a connection
# of packages and dependencies. # 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 update_db: true
# #
@ -29,9 +40,10 @@ update_db: true
# packages that need to be installed or removed can run before # packages that need to be installed or removed can run before
# this one. Distro developers may want to install locale packages # this one. Distro developers may want to install locale packages
# or remove drivers not needed on the installed system. # or remove drivers not needed on the installed system.
# This job will populate a list of dictionaries in the global # Such a job would populate a list of dictionaries in the global
# storage called "packageOperations" and it is processed # storage called "packageOperations" and that list is processed
# after the static list in the job configuration. # after the static list in the job configuration (i.e. the list
# that is in this configuration file).
# #
# Allowed package operations are: # Allowed package operations are:
# - install, try_install: will call the package manager to # - 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 # while try_remove carries on. Packages may be listed as
# (localized) names. # (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 # which is an object notation providing package-name, as well as pre- and
# post-install scripts. # post-install scripts.
# #
@ -74,15 +86,16 @@ update_db: true
# #
# - if the system locale is English (generally US English; en_GB is a valid # - if the system locale is English (generally US English; en_GB is a valid
# localization), then the package is not installed at all, # localization), then the package is not installed at all,
# - otherwise LOCALE is replaced by the Bcp47 name of the selected system # - otherwise $LOCALE or ${LOCALE} is replaced by the Bcp47 name of the selected
# locale, e.g. nl_BE. # 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 # The following installs localizations for vi, if they are relevant; if
# there is no localization, installation continues normally. # there is no localization, installation continues normally.
# #
# - install # - install
# - vi-LOCALE # - vi-$LOCALE
# - package: vi-LOCALE # - package: vi-${LOCALE}
# pre-script: touch /tmp/installing-vi # pre-script: touch /tmp/installing-vi
# post-script: rm -f /tmp/installing-vi # post-script: rm -f /tmp/installing-vi
# #

View File

@ -1,5 +1,4 @@
find_package(ECM 5.10.0 REQUIRED NO_MODULE) find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH})
include(KDEInstallDirs) include(KDEInstallDirs)
include(GenerateExportHeader) include(GenerateExportHeader)

View 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
)

View 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();
}

View 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

View 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;
}

View 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

View 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;
}

View 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

View File

@ -0,0 +1 @@
<RCC/>

View 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>

View 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"

View File

@ -19,14 +19,25 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Calamares. If not, see <http://www.gnu.org/licenses/>. # along with Calamares. If not, see <http://www.gnu.org/licenses/>.
""" """
Testing tool to run a single Python module; optionally a Testing tool to run a single Python module; optionally a global configuration
global configuration and module configuration can be read and module configuration can be read from YAML files.
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.
""" """
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 argparse
import os import os
@ -34,14 +45,15 @@ import sys
import yaml import yaml
calamaresimporterror = ("Can not import libcalamares. Ensure the PYTHONPATH "
"environment variable includes the dir where libcalamares.so is "
"installed.")
try: try:
import libcalamares import libcalamares
except ImportError: except ImportError:
print("Failed to import libcalamares. Make sure then PYTHONPATH " print(calamaresimporterror)
"environment variable includes the dir where libcalamares.so is "
"installed.")
print() print()
raise libcalamares = None
class Job: class Job:
@ -114,18 +126,37 @@ def test_module(moduledir, globalconfigfilename, moduleconfigfilename, lang):
return 0 return 0
def munge_filename(filename): def munge_filename(filename, module=None):
""" """
Maps files "" (empty) and "-" (just a dash) to None, Maps files "" (empty) and "-" (just a dash) to None,
to simplify processing elsewhere. to simplify processing elsewhere.
""" """
if not filename or filename == "-": if not filename or filename == "-":
return None 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 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(): def main():
parser = argparse.ArgumentParser(description=globals()["__doc__"]) parser = argparse.ArgumentParser(description=globals()["__doc__"], epilog=argumentepilog, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument("moduledir", parser.add_argument("moduledir",
help="Dir containing the Python module.") help="Dir containing the Python module.")
parser.add_argument("globalstorage_yaml", nargs="?", parser.add_argument("globalstorage_yaml", nargs="?",
@ -136,9 +167,15 @@ def main():
help="Set translation language.") help="Set translation language.")
args = parser.parse_args() 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.globalstorage_yaml),
munge_filename(args.configuration_yaml), munge_filename(args.configuration_yaml, moduledir),
args.lang) args.lang)

View File

@ -1,6 +1,5 @@
find_package(ECM 5.10.0 NO_MODULE) find_package(ECM ${ECM_VERSION} NO_MODULE)
if( ECM_FOUND ) if( ECM_FOUND )
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH})
include( ECMAddTests ) include( ECMAddTests )
endif() endif()

View File

@ -218,12 +218,16 @@ RequirementsChecker::setConfigurationMap( const QVariantMap& configurationMap )
bool ok = false; bool ok = false;
m_requiredStorageGB = configurationMap.value( "requiredStorage" ).toDouble( &ok ); m_requiredStorageGB = configurationMap.value( "requiredStorage" ).toDouble( &ok );
if ( !ok ) if ( !ok )
{
cDebug() << "WARNING: RequirementsChecker entry 'requiredStorage' is invalid.";
m_requiredStorageGB = 3.; m_requiredStorageGB = 3.;
}
Calamares::JobQueue::instance()->globalStorage()->insert( "requiredStorageGB", m_requiredStorageGB ); Calamares::JobQueue::instance()->globalStorage()->insert( "requiredStorageGB", m_requiredStorageGB );
} }
else else
{ {
cDebug() << "WARNING: RequirementsChecker entry 'requiredStorage' is missing.";
m_requiredStorageGB = 3.; m_requiredStorageGB = 3.;
incompleteConfiguration = true; incompleteConfiguration = true;
} }
@ -236,12 +240,14 @@ RequirementsChecker::setConfigurationMap( const QVariantMap& configurationMap )
m_requiredRamGB = configurationMap.value( "requiredRam" ).toDouble( &ok ); m_requiredRamGB = configurationMap.value( "requiredRam" ).toDouble( &ok );
if ( !ok ) if ( !ok )
{ {
cDebug() << "WARNING: RequirementsChecker entry 'requiredRam' is invalid.";
m_requiredRamGB = 1.; m_requiredRamGB = 1.;
incompleteConfiguration = true; incompleteConfiguration = true;
} }
} }
else else
{ {
cDebug() << "WARNING: RequirementsChecker entry 'requiredRam' is missing.";
m_requiredRamGB = 1.; m_requiredRamGB = 1.;
incompleteConfiguration = true; incompleteConfiguration = true;
} }
@ -253,7 +259,7 @@ RequirementsChecker::setConfigurationMap( const QVariantMap& configurationMap )
if ( m_checkHasInternetUrl.isEmpty() || if ( m_checkHasInternetUrl.isEmpty() ||
!QUrl( m_checkHasInternetUrl ).isValid() ) !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)."; << "reverting to default (http://example.com).";
m_checkHasInternetUrl = "http://example.com"; m_checkHasInternetUrl = "http://example.com";
incompleteConfiguration = true; incompleteConfiguration = true;
@ -261,8 +267,9 @@ RequirementsChecker::setConfigurationMap( const QVariantMap& configurationMap )
} }
else else
{ {
cDebug() << "internetCheckUrl is undefined in welcome.conf, " cDebug() << "WARNING: RequirementsChecker entry 'internetCheckUrl' is undefined in welcome.conf,"
"reverting to default (http://example.com)."; "reverting to default (http://example.com).";
m_checkHasInternetUrl = "http://example.com"; m_checkHasInternetUrl = "http://example.com";
incompleteConfiguration = true; incompleteConfiguration = true;
} }
@ -274,7 +281,10 @@ RequirementsChecker::setConfigurationMap( const QVariantMap& configurationMap )
m_entriesToCheck.append( configurationMap.value( "check" ).toStringList() ); m_entriesToCheck.append( configurationMap.value( "check" ).toStringList() );
} }
else else
{
cDebug() << "WARNING: RequirementsChecker entry 'check' is incomplete.";
incompleteConfiguration = true; incompleteConfiguration = true;
}
if ( configurationMap.contains( "required" ) && if ( configurationMap.contains( "required" ) &&
configurationMap.value( "required" ).type() == QVariant::List ) configurationMap.value( "required" ).type() == QVariant::List )
@ -283,18 +293,13 @@ RequirementsChecker::setConfigurationMap( const QVariantMap& configurationMap )
m_entriesToRequire.append( configurationMap.value( "required" ).toStringList() ); m_entriesToRequire.append( configurationMap.value( "required" ).toStringList() );
} }
else else
{
cDebug() << "WARNING: RequirementsChecker entry 'required' is incomplete.";
incompleteConfiguration = true; incompleteConfiguration = true;
}
if ( incompleteConfiguration ) if ( incompleteConfiguration )
{ cDebug() << "WARNING: RequirementsChecker configuration map:\n" << configurationMap;
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;
}
} }