Compare commits
26 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
571724db83 | ||
![]() |
f9e036b0ae | ||
![]() |
a1be43c959 | ||
![]() |
7e67a2fc46 | ||
![]() |
53c1371895 | ||
![]() |
699b57016d | ||
![]() |
8d2d8d04fc | ||
![]() |
eca367b9c0 | ||
![]() |
57479d79a3 | ||
![]() |
f1ab1ca3dd | ||
![]() |
be8f310672 | ||
![]() |
c6e591c9c7 | ||
![]() |
62f94e5ce9 | ||
![]() |
9d15b61331 | ||
![]() |
32e05000f6 | ||
![]() |
165fe26996 | ||
![]() |
68dcbf95f3 | ||
![]() |
a672a4fdb9 | ||
![]() |
13507e81ad | ||
![]() |
f2fe7a83c6 | ||
![]() |
effc8b4496 | ||
![]() |
c0c51ad51d | ||
![]() |
9460e53233 | ||
![]() |
114bd6ae63 | ||
![]() |
77fb264129 | ||
![]() |
0c29233062 |
@@ -102,7 +102,7 @@ set( CALAMARES_TRANSLATION_LANGUAGES ar ast bg ca cs_CZ da de el en en_GB es_MX
|
||||
### Bump version here
|
||||
set( CALAMARES_VERSION_MAJOR 2 )
|
||||
set( CALAMARES_VERSION_MINOR 4 )
|
||||
set( CALAMARES_VERSION_PATCH 1 )
|
||||
set( CALAMARES_VERSION_PATCH 3 )
|
||||
set( CALAMARES_VERSION_RC 0 )
|
||||
|
||||
set( CALAMARES_VERSION ${CALAMARES_VERSION_MAJOR}.${CALAMARES_VERSION_MINOR}.${CALAMARES_VERSION_PATCH} )
|
||||
|
@@ -67,6 +67,7 @@ sequence:
|
||||
- users
|
||||
- summary
|
||||
- exec:
|
||||
# - dummycpp
|
||||
# - dummyprocess
|
||||
# - dummypython
|
||||
- partition
|
||||
@@ -79,6 +80,7 @@ sequence:
|
||||
- localecfg
|
||||
# - luksbootkeyfile
|
||||
# - luksopenswaphookcfg
|
||||
# - dracutlukscfg
|
||||
- initcpiocfg
|
||||
- initcpio
|
||||
- users
|
||||
|
@@ -11,6 +11,7 @@ configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/../calamares/CalamaresVersion.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/CalamaresVersion.h )
|
||||
|
||||
set( libSources
|
||||
CppJob.cpp
|
||||
GlobalStorage.cpp
|
||||
Job.cpp
|
||||
JobQueue.cpp
|
||||
@@ -24,6 +25,7 @@ set( libSources
|
||||
utils/CalamaresUtils.cpp
|
||||
utils/CalamaresUtilsSystem.cpp
|
||||
utils/Logger.cpp
|
||||
utils/PluginFactory.cpp
|
||||
utils/Retranslator.cpp
|
||||
)
|
||||
|
||||
|
45
src/libcalamares/CppJob.cpp
Normal file
45
src/libcalamares/CppJob.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
|
||||
* Copyright 2016, Kevin Kofler <kevin.kofler@chello.at>
|
||||
*
|
||||
* 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 "CppJob.h"
|
||||
|
||||
namespace Calamares
|
||||
{
|
||||
|
||||
CppJob::CppJob( QObject* parent )
|
||||
: Job( parent )
|
||||
{}
|
||||
|
||||
|
||||
CppJob::~CppJob()
|
||||
{}
|
||||
|
||||
|
||||
void
|
||||
CppJob::setModuleInstanceKey( const QString& instanceKey )
|
||||
{
|
||||
m_instanceKey = instanceKey;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CppJob::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
{}
|
||||
|
||||
}
|
51
src/libcalamares/CppJob.h
Normal file
51
src/libcalamares/CppJob.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
|
||||
* Copyright 2016, Kevin Kofler <kevin.kofler@chello.at>
|
||||
*
|
||||
* 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 CALAMARES_CPPJOB_H
|
||||
#define CALAMARES_CPPJOB_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
|
||||
#include "DllMacro.h"
|
||||
#include "Typedefs.h"
|
||||
#include "Job.h"
|
||||
|
||||
namespace Calamares
|
||||
{
|
||||
|
||||
class DLLEXPORT CppJob : public Job
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CppJob( QObject* parent = nullptr );
|
||||
virtual ~CppJob();
|
||||
|
||||
void setModuleInstanceKey( const QString& instanceKey );
|
||||
QString moduleInstanceKey() const { return m_instanceKey; }
|
||||
|
||||
virtual void setConfigurationMap( const QVariantMap& configurationMap );
|
||||
|
||||
protected:
|
||||
QString m_instanceKey;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // CALAMARES_CPPJOB_H
|
@@ -23,7 +23,7 @@
|
||||
#ifndef CALAMARESPLUGINFACTORY_H
|
||||
#define CALAMARESPLUGINFACTORY_H
|
||||
|
||||
#include "UiDllMacro.h"
|
||||
#include "DllMacro.h"
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QVariant>
|
||||
@@ -196,7 +196,7 @@ namespace Calamares
|
||||
* \author Matthias Kretz <kretz@kde.org>
|
||||
* \author Bernhard Loos <nhuh.put@web.de>
|
||||
*/
|
||||
class UIDLLEXPORT PluginFactory : public QObject
|
||||
class DLLEXPORT PluginFactory : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PRIVATE(PluginFactory)
|
@@ -1,6 +1,7 @@
|
||||
set( CALAMARESUI_LIBRARY_TARGET calamaresui )
|
||||
|
||||
list( APPEND ${CALAMARESUI_LIBRARY_TARGET}_SOURCES
|
||||
modulesystem/CppJobModule.cpp
|
||||
modulesystem/Module.cpp
|
||||
modulesystem/ModuleManager.cpp
|
||||
modulesystem/ProcessJobModule.cpp
|
||||
@@ -14,8 +15,6 @@ list( APPEND ${CALAMARESUI_LIBRARY_TARGET}_SOURCES
|
||||
utils/qjsonmodel.cpp
|
||||
utils/qjsonitem.cpp
|
||||
|
||||
utils/PluginFactory.cpp
|
||||
|
||||
viewpages/AbstractPage.cpp
|
||||
viewpages/ViewStep.cpp
|
||||
|
||||
|
128
src/libcalamaresui/modulesystem/CppJobModule.cpp
Normal file
128
src/libcalamaresui/modulesystem/CppJobModule.cpp
Normal file
@@ -0,0 +1,128 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
|
||||
* Copyright 2016, Kevin Kofler <kevin.kofler@chello.at>
|
||||
*
|
||||
* 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 "CppJobModule.h"
|
||||
|
||||
#include "utils/PluginFactory.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "CppJob.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QPluginLoader>
|
||||
|
||||
namespace Calamares {
|
||||
|
||||
|
||||
Module::Type
|
||||
CppJobModule::type() const
|
||||
{
|
||||
return Job;
|
||||
}
|
||||
|
||||
|
||||
Module::Interface
|
||||
CppJobModule::interface() const
|
||||
{
|
||||
return QtPlugin;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CppJobModule::loadSelf()
|
||||
{
|
||||
if ( m_loader )
|
||||
{
|
||||
PluginFactory* pf = qobject_cast< PluginFactory* >( m_loader->instance() );
|
||||
if ( !pf )
|
||||
{
|
||||
cDebug() << Q_FUNC_INFO << m_loader->errorString();
|
||||
return;
|
||||
}
|
||||
|
||||
CppJob *cppJob = pf->create< Calamares::CppJob >();
|
||||
if ( !cppJob )
|
||||
{
|
||||
cDebug() << Q_FUNC_INFO << m_loader->errorString();
|
||||
return;
|
||||
}
|
||||
// cDebug() << "CppJobModule loading self for instance" << instanceKey()
|
||||
// << "\nCppJobModule at address" << this
|
||||
// << "\nCalamares::PluginFactory at address" << pf
|
||||
// << "\nCppJob at address" << cppJob;
|
||||
|
||||
cppJob->setModuleInstanceKey( instanceKey() );
|
||||
cppJob->setConfigurationMap( m_configurationMap );
|
||||
m_job = Calamares::job_ptr( static_cast< Calamares::Job * >( cppJob ) );
|
||||
m_loaded = true;
|
||||
cDebug() << "CppJobModule" << instanceKey() << "loading complete.";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QList< job_ptr >
|
||||
CppJobModule::jobs() const
|
||||
{
|
||||
return QList< job_ptr >() << m_job;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CppJobModule::initFrom( const QVariantMap& moduleDescriptor )
|
||||
{
|
||||
Module::initFrom( moduleDescriptor );
|
||||
QDir directory( location() );
|
||||
QString load;
|
||||
if ( !moduleDescriptor.value( "load" ).toString().isEmpty() )
|
||||
{
|
||||
load = moduleDescriptor.value( "load" ).toString();
|
||||
load = directory.absoluteFilePath( load );
|
||||
}
|
||||
// If a load path is not specified, we look for a plugin to load in the directory.
|
||||
if ( load.isEmpty() || !QLibrary::isLibrary( load ) )
|
||||
{
|
||||
const QStringList ls = directory.entryList( QStringList{ "*.so" } );
|
||||
if ( !ls.isEmpty() )
|
||||
{
|
||||
for ( QString entry : ls )
|
||||
{
|
||||
entry = directory.absoluteFilePath( entry );
|
||||
if ( QLibrary::isLibrary( entry ) )
|
||||
{
|
||||
load = entry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_loader = new QPluginLoader( load );
|
||||
}
|
||||
|
||||
CppJobModule::CppJobModule()
|
||||
: Module()
|
||||
, m_loader( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
CppJobModule::~CppJobModule()
|
||||
{
|
||||
delete m_loader;
|
||||
}
|
||||
|
||||
} // namespace Calamares
|
53
src/libcalamaresui/modulesystem/CppJobModule.h
Normal file
53
src/libcalamaresui/modulesystem/CppJobModule.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
|
||||
* Copyright 2016, Kevin Kofler <kevin.kofler@chello.at>
|
||||
*
|
||||
* 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 CALAMARES_CPPJOBMODULE_H
|
||||
#define CALAMARES_CPPJOBMODULE_H
|
||||
|
||||
#include "UiDllMacro.h"
|
||||
#include "Module.h"
|
||||
|
||||
class QPluginLoader;
|
||||
|
||||
namespace Calamares {
|
||||
|
||||
class UIDLLEXPORT CppJobModule : public Module
|
||||
{
|
||||
public:
|
||||
Type type() const override;
|
||||
Interface interface() const override;
|
||||
|
||||
void loadSelf() override;
|
||||
QList< job_ptr > jobs() const override;
|
||||
|
||||
protected:
|
||||
void initFrom( const QVariantMap& moduleDescriptor ) override;
|
||||
|
||||
private:
|
||||
friend class Module; //so only the superclass can instantiate
|
||||
explicit CppJobModule();
|
||||
virtual ~CppJobModule();
|
||||
|
||||
QPluginLoader* m_loader;
|
||||
job_ptr m_job;
|
||||
};
|
||||
|
||||
} // namespace Calamares
|
||||
|
||||
#endif // CALAMARES_CPPJOBMODULE_H
|
@@ -19,6 +19,7 @@
|
||||
#include "Module.h"
|
||||
|
||||
#include "ProcessJobModule.h"
|
||||
#include "CppJobModule.h"
|
||||
#include "ViewModule.h"
|
||||
#include "utils/CalamaresUtils.h"
|
||||
#include "utils/YamlUtils.h"
|
||||
@@ -76,7 +77,11 @@ Module::fromDescriptor( const QVariantMap& moduleDescriptor,
|
||||
}
|
||||
else if ( typeString == "job" )
|
||||
{
|
||||
if ( intfString == "process" )
|
||||
if ( intfString == "qtplugin" )
|
||||
{
|
||||
m = new CppJobModule();
|
||||
}
|
||||
else if ( intfString == "process" )
|
||||
{
|
||||
m = new ProcessJobModule();
|
||||
}
|
||||
|
@@ -220,15 +220,14 @@ def install_grub(efi_directory, fw_type):
|
||||
"--force"])
|
||||
|
||||
# VFAT is weird, see issue CAL-385
|
||||
efi_directory_firmware = case_insensitive_subdir(efi_directory,
|
||||
["EFI", "Efi", "efi"])
|
||||
if not efi_directory_firmware:
|
||||
efi_directory_firmware = os.path.join(efi_directory, "EFI")
|
||||
efi_directory_firmware = os.path.join(efi_directory, "EFI")
|
||||
if os.path.exists(efi_directory_firmware):
|
||||
efi_directory_firmware = vfat_correct_case(efi_directory, "EFI")
|
||||
|
||||
efi_boot_directory = case_insensitive_subdir(efi_directory_firmware,
|
||||
["Boot", "boot", "BOOT"])
|
||||
if not efi_boot_directory:
|
||||
efi_boot_directory = os.path.join(efi_directory_firmware, "boot")
|
||||
efi_boot_directory = os.path.join(efi_directory_firmware, "boot")
|
||||
if os.path.exists(efi_boot_directory):
|
||||
efi_boot_directory = vfat_correct_case(efi_directory_firmware, "boot")
|
||||
else:
|
||||
check_target_env_call(["mkdir", "-p", efi_boot_directory])
|
||||
|
||||
# Workaround for some UEFI firmwares
|
||||
@@ -251,11 +250,11 @@ def install_grub(efi_directory, fw_type):
|
||||
libcalamares.job.configuration["grubCfg"]])
|
||||
|
||||
|
||||
def case_insensitive_subdir(parent, candidate_dirnames):
|
||||
for dirname in candidate_dirnames:
|
||||
if os.path.isdir(os.path.join(parent, dirname)):
|
||||
return os.path.join(parent, dirname)
|
||||
return ""
|
||||
def vfat_correct_case(parent, name):
|
||||
for candidate in os.listdir(parent):
|
||||
if name.lower() == candidate.lower():
|
||||
return candidate
|
||||
return os.path.join(parent, name)
|
||||
|
||||
|
||||
def prepare_bootloader(fw_type):
|
||||
|
@@ -3,7 +3,7 @@
|
||||
#
|
||||
# === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
#
|
||||
# Copyright 2014-2015, Philip Müller <philm@manjaro.org>
|
||||
# Copyright 2014-2016, Philip Müller <philm@manjaro.org>
|
||||
# Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
|
||||
# Copyright 2014, Kevin Kofler <kevin.kofler@chello.at>
|
||||
#
|
||||
@@ -44,6 +44,7 @@ desktop_environments = [
|
||||
DesktopEnvironment('/usr/bin/budgie-session', 'budgie-session'),
|
||||
DesktopEnvironment('/usr/bin/budgie-desktop', 'budgie-desktop'),
|
||||
DesktopEnvironment('/usr/bin/i3', 'i3'),
|
||||
DesktopEnvironment('/usr/bin/startdde', 'deepin'),
|
||||
DesktopEnvironment('/usr/bin/openbox-session', 'openbox')
|
||||
]
|
||||
|
||||
@@ -267,7 +268,7 @@ def set_autologin(username, displaymanagers, default_desktop_environment, root_m
|
||||
# User= line, possibly commented out
|
||||
if re.match('\\s*(?:#\\s*)?User=', line):
|
||||
if do_autologin:
|
||||
line = 'User={}\n'.format(username)
|
||||
line = 'User={!s}\n'.format(username)
|
||||
else:
|
||||
line = '#User=\n'
|
||||
|
||||
@@ -275,9 +276,9 @@ def set_autologin(username, displaymanagers, default_desktop_environment, root_m
|
||||
if re.match('\\s*#\\s*Session=|\\s*Session=$', line):
|
||||
if default_desktop_environment is not None:
|
||||
if do_autologin:
|
||||
line = 'Session={}.desktop\n'.format(default_desktop_environment.desktop_file)
|
||||
line = 'Session={!s}.desktop\n'.format(default_desktop_environment.desktop_file)
|
||||
else:
|
||||
line = '#Session={}.desktop\n'.format(default_desktop_environment.desktop_file)
|
||||
line = '#Session={!s}.desktop\n'.format(default_desktop_environment.desktop_file)
|
||||
|
||||
sddm_conf.write(line)
|
||||
|
||||
@@ -350,6 +351,11 @@ def run():
|
||||
if default_desktop_environment is not None:
|
||||
os.system("sed -i -e \"s/^.*user-session=.*/user-session={!s}/\" {!s}/etc/lightdm/lightdm.conf".format(
|
||||
default_desktop_environment.desktop_file, root_mount_point))
|
||||
|
||||
if default_desktop_environment.desktop_file == "deepin":
|
||||
os.system("sed -i -e \"s/^.greeter-session=.*/greeter-session=lightdm-deepin-greeter/\" {!s}/etc/lightdm/lightdm.conf".format(
|
||||
root_mount_point))
|
||||
|
||||
else:
|
||||
libcalamares.utils.debug("lightdm selected but not installed")
|
||||
displaymanagers.remove("lightdm")
|
||||
|
9
src/modules/dracutlukscfg/CMakeLists.txt
Normal file
9
src/modules/dracutlukscfg/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
calamares_add_plugin( dracutlukscfg
|
||||
TYPE job
|
||||
EXPORT_MACRO PLUGINDLLEXPORT_PRO
|
||||
SOURCES
|
||||
DracutLuksCfgJob.cpp
|
||||
LINK_LIBRARIES
|
||||
calamares
|
||||
SHARED_LIB
|
||||
)
|
143
src/modules/dracutlukscfg/DracutLuksCfgJob.cpp
Normal file
143
src/modules/dracutlukscfg/DracutLuksCfgJob.cpp
Normal file
@@ -0,0 +1,143 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2016, Kevin Kofler <kevin.kofler@chello.at>
|
||||
*
|
||||
* 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 "DracutLuksCfgJob.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QTextStream>
|
||||
|
||||
#include "CalamaresVersion.h"
|
||||
#include "JobQueue.h"
|
||||
#include "GlobalStorage.h"
|
||||
|
||||
#include "utils/Logger.h"
|
||||
|
||||
// static
|
||||
const QString DracutLuksCfgJob::CONFIG_FILE = QStringLiteral( "/etc/dracut.conf.d/calamares-luks.conf" );
|
||||
|
||||
// static
|
||||
const char *DracutLuksCfgJob::CONFIG_FILE_CONTENTS =
|
||||
"# Configuration file automatically written by the Calamares system installer\n"
|
||||
"# (This file is written once at install time and should be safe to edit.)\n"
|
||||
"# Enables support for LUKS full disk encryption with single sign on from GRUB.\n"
|
||||
"\n"
|
||||
"# force installing /etc/crypttab even if hostonly=\"no\", install the keyfile\n"
|
||||
"install_items+=\" /etc/crypttab /crypto_keyfile.bin \"\n";
|
||||
|
||||
// static
|
||||
const QString DracutLuksCfgJob::CONFIG_FILE_SWAPLINE = QStringLiteral( "# enable automatic resume from swap\nadd_device+=\" /dev/disk/by-uuid/%1 \"\n" );
|
||||
|
||||
// static
|
||||
QString
|
||||
DracutLuksCfgJob::rootMountPoint()
|
||||
{
|
||||
Calamares::GlobalStorage *globalStorage = Calamares::JobQueue::instance()->globalStorage();
|
||||
return globalStorage->value( QStringLiteral( "rootMountPoint" ) ).toString();
|
||||
}
|
||||
|
||||
// static
|
||||
QVariantList
|
||||
DracutLuksCfgJob::partitions()
|
||||
{
|
||||
Calamares::GlobalStorage *globalStorage = Calamares::JobQueue::instance()->globalStorage();
|
||||
return globalStorage->value( QStringLiteral( "partitions" ) ).toList();
|
||||
}
|
||||
|
||||
// static
|
||||
bool
|
||||
DracutLuksCfgJob::isRootEncrypted()
|
||||
{
|
||||
const QVariantList partitions = DracutLuksCfgJob::partitions();
|
||||
for ( const QVariant &partition : partitions )
|
||||
{
|
||||
QVariantMap partitionMap = partition.toMap();
|
||||
QString mountPoint = partitionMap.value( QStringLiteral( "mountPoint" ) ).toString();
|
||||
if ( mountPoint == QStringLiteral( "/" ) )
|
||||
return partitionMap.contains( QStringLiteral( "luksMapperName" ) );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// static
|
||||
QString
|
||||
DracutLuksCfgJob::swapOuterUuid()
|
||||
{
|
||||
const QVariantList partitions = DracutLuksCfgJob::partitions();
|
||||
for ( const QVariant &partition : partitions )
|
||||
{
|
||||
QVariantMap partitionMap = partition.toMap();
|
||||
QString fsType = partitionMap.value( QStringLiteral( "fs" ) ).toString();
|
||||
if ( fsType == QStringLiteral( "linuxswap" ) && partitionMap.contains( QStringLiteral( "luksMapperName" ) ) )
|
||||
return partitionMap.value( QStringLiteral( "luksUuid" ) ).toString();
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
DracutLuksCfgJob::DracutLuksCfgJob( QObject* parent )
|
||||
: Calamares::CppJob( parent )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DracutLuksCfgJob::~DracutLuksCfgJob()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
DracutLuksCfgJob::prettyName() const
|
||||
{
|
||||
if ( isRootEncrypted() )
|
||||
return tr( "Write LUKS configuration for Dracut to %1" ).arg( CONFIG_FILE );
|
||||
else
|
||||
return tr( "Skip writing LUKS configuration for Dracut: \"/\" partition is not encrypted" );
|
||||
}
|
||||
|
||||
|
||||
Calamares::JobResult
|
||||
DracutLuksCfgJob::exec()
|
||||
{
|
||||
if ( isRootEncrypted() )
|
||||
{
|
||||
const QString realConfigFilePath = rootMountPoint() + CONFIG_FILE;
|
||||
cDebug() << "[DRACUTLUKSCFG]: Writing" << realConfigFilePath;
|
||||
QDir( QStringLiteral( "/" ) ).mkpath( QFileInfo( realConfigFilePath ).absolutePath() );
|
||||
QFile configFile( realConfigFilePath );
|
||||
if ( ! configFile.open( QIODevice::WriteOnly | QIODevice::Text ) )
|
||||
{
|
||||
cDebug() << "[DRACUTLUKSCFG]: Failed to open" << realConfigFilePath;
|
||||
return Calamares::JobResult::error( tr( "Failed to open %1" ).arg( realConfigFilePath ) );
|
||||
}
|
||||
QTextStream outStream( &configFile );
|
||||
outStream << CONFIG_FILE_CONTENTS;
|
||||
const QString swapOuterUuid = DracutLuksCfgJob::swapOuterUuid();
|
||||
if ( ! swapOuterUuid.isEmpty() )
|
||||
{
|
||||
cDebug() << "[DRACUTLUKSCFG]: Swap outer UUID" << swapOuterUuid;
|
||||
outStream << CONFIG_FILE_SWAPLINE.arg( swapOuterUuid ).toLatin1();
|
||||
}
|
||||
cDebug() << "[DRACUTLUKSCFG]: Wrote config to" << realConfigFilePath;
|
||||
} else
|
||||
cDebug() << "[DRACUTLUKSCFG]: / not encrypted, skipping";
|
||||
|
||||
return Calamares::JobResult::ok();
|
||||
}
|
||||
|
||||
CALAMARES_PLUGIN_FACTORY_DEFINITION( DracutLuksCfgJobFactory, registerPlugin<DracutLuksCfgJob>(); )
|
56
src/modules/dracutlukscfg/DracutLuksCfgJob.h
Normal file
56
src/modules/dracutlukscfg/DracutLuksCfgJob.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2016, Kevin Kofler <kevin.kofler@chello.at>
|
||||
*
|
||||
* 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 DRACUTLUKSCFGJOB_H
|
||||
#define DRACUTLUKSCFGJOB_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QVariantMap>
|
||||
|
||||
#include <CppJob.h>
|
||||
|
||||
#include <utils/PluginFactory.h>
|
||||
|
||||
#include <PluginDllMacro.h>
|
||||
|
||||
class PLUGINDLLEXPORT DracutLuksCfgJob : public Calamares::CppJob
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DracutLuksCfgJob( QObject* parent = nullptr );
|
||||
virtual ~DracutLuksCfgJob();
|
||||
|
||||
QString prettyName() const override;
|
||||
|
||||
Calamares::JobResult exec() override;
|
||||
|
||||
private:
|
||||
static const QString CONFIG_FILE;
|
||||
static const char *CONFIG_FILE_CONTENTS;
|
||||
static const QString CONFIG_FILE_SWAPLINE;
|
||||
|
||||
static QString rootMountPoint();
|
||||
static QVariantList partitions();
|
||||
static bool isRootEncrypted();
|
||||
static QString swapOuterUuid();
|
||||
};
|
||||
|
||||
CALAMARES_PLUGIN_FACTORY_DECLARATION( DracutLuksCfgJobFactory )
|
||||
|
||||
#endif // DRACUTLUKSCFGJOB_H
|
7
src/modules/dracutlukscfg/module.desc
Normal file
7
src/modules/dracutlukscfg/module.desc
Normal file
@@ -0,0 +1,7 @@
|
||||
# Module metadata file for dracutlukscfg job
|
||||
# Syntax is YAML 1.2
|
||||
---
|
||||
type: "job"
|
||||
name: "dracutlukscfg"
|
||||
interface: "qtplugin"
|
||||
load: "libcalamares_job_dracutlukscfg.so"
|
9
src/modules/dummycpp/CMakeLists.txt
Normal file
9
src/modules/dummycpp/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
calamares_add_plugin( dummycpp
|
||||
TYPE job
|
||||
EXPORT_MACRO PLUGINDLLEXPORT_PRO
|
||||
SOURCES
|
||||
DummyCppJob.cpp
|
||||
LINK_LIBRARIES
|
||||
calamares
|
||||
SHARED_LIB
|
||||
)
|
144
src/modules/dummycpp/DummyCppJob.cpp
Normal file
144
src/modules/dummycpp/DummyCppJob.cpp
Normal file
@@ -0,0 +1,144 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014, Teo Mrnjavac <teo@kde.org> (original dummypython code)
|
||||
* Copyright 2016, Kevin Kofler <kevin.kofler@chello.at>
|
||||
*
|
||||
* 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 "DummyCppJob.h"
|
||||
|
||||
#include <QProcess>
|
||||
#include <QDateTime>
|
||||
#include <QThread>
|
||||
|
||||
#include "CalamaresVersion.h"
|
||||
#include "JobQueue.h"
|
||||
#include "GlobalStorage.h"
|
||||
|
||||
#include "utils/Logger.h"
|
||||
|
||||
DummyCppJob::DummyCppJob( QObject* parent )
|
||||
: Calamares::CppJob( parent )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DummyCppJob::~DummyCppJob()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
DummyCppJob::prettyName() const
|
||||
{
|
||||
return tr( "Dummy C++ Job" );
|
||||
}
|
||||
|
||||
|
||||
static QString variantListToString( const QVariantList& variantList );
|
||||
static QString variantMapToString( const QVariantMap& variantMap );
|
||||
static QString variantHashToString( const QVariantHash& variantHash );
|
||||
|
||||
|
||||
static QString
|
||||
variantToString( const QVariant& variant )
|
||||
{
|
||||
switch ( variant.type() )
|
||||
{
|
||||
case QVariant::Map:
|
||||
return variantMapToString( variant.toMap() );
|
||||
|
||||
case QVariant::Hash:
|
||||
return variantHashToString( variant.toHash() );
|
||||
|
||||
case QVariant::List:
|
||||
case QVariant::StringList:
|
||||
return variantListToString( variant.toList() );
|
||||
|
||||
default:
|
||||
return variant.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static QString
|
||||
variantListToString( const QVariantList& variantList )
|
||||
{
|
||||
QStringList result;
|
||||
for ( const QVariant& variant : variantList )
|
||||
result.append( variantToString( variant ) );
|
||||
return '{' + result.join(',') + '}';
|
||||
}
|
||||
|
||||
|
||||
static QString
|
||||
variantMapToString( const QVariantMap& variantMap )
|
||||
{
|
||||
QStringList result;
|
||||
for ( auto it = variantMap.constBegin(); it != variantMap.constEnd(); ++it )
|
||||
result.append( it.key() + '=' + variantToString( it.value() ) );
|
||||
return '[' + result.join(',') + ']';
|
||||
}
|
||||
|
||||
|
||||
static QString
|
||||
variantHashToString( const QVariantHash& variantHash )
|
||||
{
|
||||
QStringList result;
|
||||
for ( auto it = variantHash.constBegin(); it != variantHash.constEnd(); ++it )
|
||||
result.append( it.key() + '=' + variantToString( it.value() ) );
|
||||
return '<' + result.join(',') + '>';
|
||||
}
|
||||
|
||||
|
||||
Calamares::JobResult
|
||||
DummyCppJob::exec()
|
||||
{
|
||||
// Ported from dummypython
|
||||
QProcess::execute( "/bin/sh", QStringList() << "-c" << "touch ~/calamares-dummycpp" );
|
||||
QString accumulator = QDateTime::currentDateTimeUtc().toString( Qt::ISODate ) + '\n';
|
||||
accumulator += QStringLiteral( "Calamares version: " ) + CALAMARES_VERSION_SHORT + '\n';
|
||||
accumulator += QStringLiteral( "This job's name: " ) + prettyName() + '\n';
|
||||
accumulator += QStringLiteral( "Configuration map: %1\n" ).arg( variantMapToString( m_configurationMap ) );
|
||||
accumulator += QStringLiteral( " *** globalstorage test ***\n" );
|
||||
Calamares::GlobalStorage *globalStorage = Calamares::JobQueue::instance()->globalStorage();
|
||||
accumulator += QStringLiteral( "lala: " ) + (globalStorage->contains( "lala" ) ? QStringLiteral( "true" ) : QStringLiteral( "false" )) + '\n';
|
||||
accumulator += QStringLiteral( "foo: " ) + (globalStorage->contains( "foo" ) ? QStringLiteral( "true" ) : QStringLiteral( "false" )) + '\n';
|
||||
accumulator += QStringLiteral( "count: " ) + QString::number( globalStorage->count() ) + '\n';
|
||||
globalStorage->insert( "item2", "value2" );
|
||||
globalStorage->insert( "item3", 3 );
|
||||
accumulator += QStringLiteral( "keys: %1\n" ).arg( globalStorage->keys().join( ',' ) );
|
||||
accumulator += QStringLiteral( "remove: %1\n" ).arg( QString::number( globalStorage->remove( "item2" ) ) );
|
||||
accumulator += QStringLiteral( "values: %1 %2 %3\n" ).arg(
|
||||
globalStorage->value( "foo" ).toString(),
|
||||
globalStorage->value( "item2" ).toString(),
|
||||
globalStorage->value( "item3" ).toString() );
|
||||
|
||||
emit progress( 0.1 );
|
||||
cDebug() << "[DUMMYCPP]: " << accumulator;
|
||||
|
||||
QThread::sleep( 3 );
|
||||
|
||||
return Calamares::JobResult::ok();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DummyCppJob::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
{
|
||||
m_configurationMap = configurationMap;
|
||||
}
|
||||
|
||||
CALAMARES_PLUGIN_FACTORY_DEFINITION( DummyCppJobFactory, registerPlugin<DummyCppJob>(); )
|
51
src/modules/dummycpp/DummyCppJob.h
Normal file
51
src/modules/dummycpp/DummyCppJob.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2016, Kevin Kofler <kevin.kofler@chello.at>
|
||||
*
|
||||
* 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 DUMMYCPPJOB_H
|
||||
#define DUMMYCPPJOB_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QVariantMap>
|
||||
|
||||
#include <CppJob.h>
|
||||
|
||||
#include <utils/PluginFactory.h>
|
||||
|
||||
#include <PluginDllMacro.h>
|
||||
|
||||
class PLUGINDLLEXPORT DummyCppJob : public Calamares::CppJob
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DummyCppJob( QObject* parent = nullptr );
|
||||
virtual ~DummyCppJob();
|
||||
|
||||
QString prettyName() const override;
|
||||
|
||||
Calamares::JobResult exec() override;
|
||||
|
||||
void setConfigurationMap( const QVariantMap& configurationMap ) override;
|
||||
|
||||
private:
|
||||
QVariantMap m_configurationMap;
|
||||
};
|
||||
|
||||
CALAMARES_PLUGIN_FACTORY_DECLARATION( DummyCppJobFactory )
|
||||
|
||||
#endif // DUMMYCPPJOB_H
|
18
src/modules/dummycpp/dummycpp.conf
Normal file
18
src/modules/dummycpp/dummycpp.conf
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
syntax: "YAML map of anything"
|
||||
example:
|
||||
whats_this: "module-specific configuration"
|
||||
from_where: "dummycpp.conf"
|
||||
a_list:
|
||||
- "item1"
|
||||
- "item2"
|
||||
- "item3"
|
||||
- "item4"
|
||||
a_list_of_maps:
|
||||
- name: "an Item"
|
||||
contents:
|
||||
- "an element"
|
||||
- "another element"
|
||||
- name: "another item"
|
||||
contents:
|
||||
- "not much"
|
7
src/modules/dummycpp/module.desc
Normal file
7
src/modules/dummycpp/module.desc
Normal file
@@ -0,0 +1,7 @@
|
||||
# Module metadata file for dummycpp job
|
||||
# Syntax is YAML 1.2
|
||||
---
|
||||
type: "job"
|
||||
name: "dummycpp"
|
||||
interface: "qtplugin"
|
||||
load: "libcalamares_job_dummycpp.so"
|
@@ -8,3 +8,6 @@ ssdExtraMountOptions:
|
||||
xfs: discard
|
||||
swap: discard
|
||||
btrfs: discard,compress=lzo
|
||||
crypttabOptions: luks
|
||||
# For Debian and Debian-based distributions, change the above line to:
|
||||
# crypttabOptions: luks,keyscript=/bin/cat
|
||||
|
@@ -102,11 +102,13 @@ class FstabGenerator(object):
|
||||
:param mount_options:
|
||||
:param ssd_extra_mount_options:
|
||||
"""
|
||||
def __init__(self, partitions, root_mount_point, mount_options, ssd_extra_mount_options):
|
||||
def __init__(self, partitions, root_mount_point, mount_options,
|
||||
ssd_extra_mount_options, crypttab_options):
|
||||
self.partitions = partitions
|
||||
self.root_mount_point = root_mount_point
|
||||
self.mount_options = mount_options
|
||||
self.ssd_extra_mount_options = ssd_extra_mount_options
|
||||
self.crypttab_options = crypttab_options
|
||||
self.ssd_disks = set()
|
||||
self.root_is_ssd = False
|
||||
|
||||
@@ -152,21 +154,20 @@ class FstabGenerator(object):
|
||||
if not mapper_name or not luks_uuid:
|
||||
return None
|
||||
|
||||
if mount_point == "/":
|
||||
return None
|
||||
|
||||
return dict(
|
||||
name=mapper_name,
|
||||
device="UUID=" + luks_uuid,
|
||||
password="/crypto_keyfile.bin",
|
||||
options=self.crypttab_options,
|
||||
)
|
||||
|
||||
def print_crypttab_line(self, dct, file=None):
|
||||
""" Prints line to '/etc/crypttab' file. """
|
||||
line = "{:21} {:<45} {}".format(dct["name"],
|
||||
dct["device"],
|
||||
dct["password"],
|
||||
)
|
||||
line = "{:21} {:<45} {} {}".format(dct["name"],
|
||||
dct["device"],
|
||||
dct["password"],
|
||||
dct["options"],
|
||||
)
|
||||
|
||||
print(line, file=file)
|
||||
|
||||
@@ -258,9 +259,11 @@ def run():
|
||||
root_mount_point = global_storage.value("rootMountPoint")
|
||||
mount_options = conf["mountOptions"]
|
||||
ssd_extra_mount_options = conf.get("ssdExtraMountOptions", {})
|
||||
crypttab_options = conf.get("crypttabOptions", "luks")
|
||||
generator = FstabGenerator(partitions,
|
||||
root_mount_point,
|
||||
mount_options,
|
||||
ssd_extra_mount_options)
|
||||
ssd_extra_mount_options,
|
||||
crypttab_options)
|
||||
|
||||
return generator.run()
|
||||
|
@@ -36,8 +36,10 @@ def modify_grub_default(partitions, root_mount_point, distributor):
|
||||
default_grub = os.path.join(default_dir, "grub")
|
||||
distributor_replace = distributor.replace("'", "'\\''")
|
||||
plymouth_bin = libcalamares.utils.target_env_call(["sh", "-c", "which plymouth"])
|
||||
dracut_bin = libcalamares.utils.target_env_call(["sh", "-c", "which dracut"])
|
||||
use_splash = ""
|
||||
swap_uuid = ""
|
||||
swap_outer_uuid = ""
|
||||
|
||||
libcalamares.utils.debug("which plymouth exit code: {!s}".format(plymouth_bin))
|
||||
|
||||
@@ -46,15 +48,26 @@ def modify_grub_default(partitions, root_mount_point, distributor):
|
||||
|
||||
cryptdevice_params = []
|
||||
|
||||
for partition in partitions:
|
||||
if partition["fs"] == "linuxswap":
|
||||
swap_uuid = partition["uuid"]
|
||||
if dracut_bin == 0:
|
||||
for partition in partitions:
|
||||
if partition["fs"] == "linuxswap":
|
||||
swap_uuid = partition["uuid"]
|
||||
|
||||
if partition["mountPoint"] == "/" and "luksMapperName" in partition:
|
||||
cryptdevice_params = [
|
||||
"cryptdevice=UUID={!s}:{!s}".format(partition["luksUuid"],
|
||||
partition["luksMapperName"]),
|
||||
"root=/dev/mapper/{!s}".format(partition["luksMapperName"])
|
||||
if partition["fs"] == "linuxswap" and "luksMapperName" in partition:
|
||||
swap_outer_uuid = partition["luksUuid"]
|
||||
|
||||
if partition["mountPoint"] == "/" and "luksMapperName" in partition:
|
||||
cryptdevice_params = ["rd.luks.uuid={!s}".format(partition["luksUuid"])]
|
||||
else:
|
||||
for partition in partitions:
|
||||
if partition["fs"] == "linuxswap":
|
||||
swap_uuid = partition["uuid"]
|
||||
|
||||
if partition["mountPoint"] == "/" and "luksMapperName" in partition:
|
||||
cryptdevice_params = [
|
||||
"cryptdevice=UUID={!s}:{!s}".format(partition["luksUuid"],
|
||||
partition["luksMapperName"]),
|
||||
"root=/dev/mapper/{!s}".format(partition["luksMapperName"])
|
||||
]
|
||||
|
||||
kernel_params = ["quiet"]
|
||||
@@ -68,7 +81,10 @@ def modify_grub_default(partitions, root_mount_point, distributor):
|
||||
if swap_uuid:
|
||||
kernel_params.append("resume=UUID={!s}".format(swap_uuid))
|
||||
|
||||
distributor_line = "GRUB_DISTRIBUTOR=\"{!s}\"".format(distributor_replace)
|
||||
if dracut_bin == 0 and swap_outer_uuid:
|
||||
kernel_params.append("rd.luks.uuid={!s}".format(swap_outer_uuid))
|
||||
|
||||
distributor_line = "GRUB_DISTRIBUTOR='{!s}'".format(distributor_replace)
|
||||
|
||||
if not os.path.exists(default_dir):
|
||||
os.mkdir(default_dir)
|
||||
@@ -126,7 +142,7 @@ def modify_grub_default(partitions, root_mount_point, distributor):
|
||||
else:
|
||||
escaped_value = str(value).replace("'", "'\\''")
|
||||
|
||||
lines.append("{!s}=\"{!s}\"".format(key, escaped_value))
|
||||
lines.append("{!s}='{!s}'".format(key, escaped_value))
|
||||
|
||||
if not have_kernel_cmd:
|
||||
kernel_cmd = "GRUB_CMDLINE_LINUX_DEFAULT=\"{!s}\"".format(" ".join(kernel_params))
|
||||
|
26
src/modules/initramfscfg/encrypt_hook
Executable file
26
src/modules/initramfscfg/encrypt_hook
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
|
||||
PREREQ=""
|
||||
|
||||
prereqs()
|
||||
{
|
||||
echo "$PREREQ"
|
||||
}
|
||||
|
||||
case $1 in
|
||||
# get pre-requisites
|
||||
prereqs)
|
||||
prereqs
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
. /usr/share/initramfs-tools/hook-functions
|
||||
if [ -f /crypto_keyfile.bin ]
|
||||
then
|
||||
cp /crypto_keyfile.bin ${DESTDIR}
|
||||
fi
|
||||
if [ -f /etc/crypttab ]
|
||||
then
|
||||
cp /etc/crypttab ${DESTDIR}/etc/
|
||||
fi
|
52
src/modules/initramfscfg/main.py
Normal file
52
src/modules/initramfscfg/main.py
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
#
|
||||
# Copyright 2014, Rohan Garg <rohan@kde.org>
|
||||
# Copyright 2015, Philip Müller <philm@manjaro.org>
|
||||
# Copyright 2016, David McKinney <mckinney@subgraph.com>
|
||||
#
|
||||
# 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/>.
|
||||
|
||||
import libcalamares
|
||||
import os
|
||||
import shutil
|
||||
|
||||
def copy_initramfs_hooks(partitions, root_mount_point):
|
||||
""" Copies initramfs hooks so they are picked up by update-initramfs
|
||||
|
||||
:param partitions:
|
||||
:param root_mount_point:
|
||||
"""
|
||||
encrypt_hook = False
|
||||
|
||||
for partition in partitions:
|
||||
if partition["mountPoint"] == "/" and "luksMapperName" in partition:
|
||||
encrypt_hook = True
|
||||
|
||||
if encrypt_hook:
|
||||
shutil.copy2("/usr/lib/calamares/modules/initramfscfg/encrypt_hook", "{!s}/usr/share/initramfs-tools/hooks/".format(root_mount_point))
|
||||
os.chmod("{!s}/usr/share/initramfs-tools/hooks/encrypt_hook".format(root_mount_point), 0o755)
|
||||
|
||||
def run():
|
||||
""" Calls routine with given parameters to configure initramfs
|
||||
|
||||
:return:
|
||||
"""
|
||||
partitions = libcalamares.globalstorage.value("partitions")
|
||||
root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
|
||||
copy_initramfs_hooks(partitions, root_mount_point)
|
||||
|
||||
return None
|
5
src/modules/initramfscfg/module.desc
Normal file
5
src/modules/initramfscfg/module.desc
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
type: "job"
|
||||
name: "initramfscfg"
|
||||
interface: "python"
|
||||
script: "main.py"
|
@@ -202,7 +202,8 @@ KeyboardPage::prettyStatus() const
|
||||
|
||||
QList< Calamares::job_ptr >
|
||||
KeyboardPage::createJobs( const QString& xOrgConfFileName,
|
||||
const QString& convertedKeymapPath )
|
||||
const QString& convertedKeymapPath,
|
||||
bool writeEtcDefaultKeyboard )
|
||||
{
|
||||
QList< Calamares::job_ptr > list;
|
||||
QString selectedModel = m_models.value( ui->comboBoxModel->currentText(),
|
||||
@@ -212,7 +213,8 @@ KeyboardPage::createJobs( const QString& xOrgConfFileName,
|
||||
m_selectedLayout,
|
||||
m_selectedVariant,
|
||||
xOrgConfFileName,
|
||||
convertedKeymapPath );
|
||||
convertedKeymapPath,
|
||||
writeEtcDefaultKeyboard );
|
||||
list.append( Calamares::job_ptr( j ) );
|
||||
|
||||
return list;
|
||||
|
@@ -50,7 +50,8 @@ public:
|
||||
QString prettyStatus() const;
|
||||
|
||||
QList< Calamares::job_ptr > createJobs( const QString& xOrgConfFileName,
|
||||
const QString& convertedKeymapPath );
|
||||
const QString& convertedKeymapPath,
|
||||
bool writeEtcDefaultKeyboard );
|
||||
|
||||
void onActivate();
|
||||
void finalize();
|
||||
|
@@ -123,7 +123,9 @@ void
|
||||
KeyboardViewStep::onLeave()
|
||||
{
|
||||
m_widget->finalize();
|
||||
m_jobs = m_widget->createJobs( m_xOrgConfFileName, m_convertedKeymapPath );
|
||||
m_jobs = m_widget->createJobs( m_xOrgConfFileName,
|
||||
m_convertedKeymapPath,
|
||||
m_writeEtcDefaultKeyboard );
|
||||
m_prettyStatus = m_widget->prettyStatus();
|
||||
}
|
||||
|
||||
@@ -157,4 +159,14 @@ KeyboardViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
{
|
||||
m_convertedKeymapPath = QString();
|
||||
}
|
||||
|
||||
if ( configurationMap.contains( "writeEtcDefaultKeyboard" ) &&
|
||||
configurationMap.value( "writeEtcDefaultKeyboard" ).type() == QVariant::Bool )
|
||||
{
|
||||
m_writeEtcDefaultKeyboard = configurationMap.value( "writeEtcDefaultKeyboard" ).toBool();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_writeEtcDefaultKeyboard = true;
|
||||
}
|
||||
}
|
||||
|
@@ -64,6 +64,7 @@ private:
|
||||
|
||||
QString m_xOrgConfFileName;
|
||||
QString m_convertedKeymapPath;
|
||||
bool m_writeEtcDefaultKeyboard;
|
||||
|
||||
QList< Calamares::job_ptr > m_jobs;
|
||||
};
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
|
||||
* Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
|
||||
* Copyright 2014, Kevin Kofler <kevin.kofler@chello.at>
|
||||
*
|
||||
* Portions from systemd (localed.c):
|
||||
@@ -40,13 +40,15 @@ SetKeyboardLayoutJob::SetKeyboardLayoutJob( const QString& model,
|
||||
const QString& layout,
|
||||
const QString& variant,
|
||||
const QString& xOrgConfFileName,
|
||||
const QString& convertedKeymapPath )
|
||||
const QString& convertedKeymapPath,
|
||||
bool writeEtcDefaultKeyboard)
|
||||
: Calamares::Job()
|
||||
, m_model( model )
|
||||
, m_layout( layout )
|
||||
, m_variant( variant )
|
||||
, m_xOrgConfFileName( xOrgConfFileName )
|
||||
, m_convertedKeymapPath( convertedKeymapPath )
|
||||
, m_writeEtcDefaultKeyboard( writeEtcDefaultKeyboard )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -240,6 +242,34 @@ SetKeyboardLayoutJob::writeX11Data( const QString& keyboardConfPath ) const
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
SetKeyboardLayoutJob::writeDefaultKeyboardData( const QString& defaultKeyboardPath ) const
|
||||
{
|
||||
QFile file( defaultKeyboardPath );
|
||||
file.open( QIODevice::WriteOnly | QIODevice::Text );
|
||||
QTextStream stream( &file );
|
||||
|
||||
stream << "# KEYBOARD CONFIGURATION FILE\n\n"
|
||||
"# Consult the keyboard(5) manual page.\n\n";
|
||||
|
||||
stream << "XKBMODEL=\"" << m_model << "\"\n";
|
||||
stream << "XKBLAYOUT=\"" << m_layout << "\"\n";
|
||||
stream << "XKBVARIANT=\"" << m_variant << "\"\n";
|
||||
stream << "XKBOPTIONS=\"\"\n\n";
|
||||
stream << "BACKSPACE=\"guess\"\n";
|
||||
stream.flush();
|
||||
|
||||
file.close();
|
||||
|
||||
cDebug() << "Written XKBMODEL" << m_model <<
|
||||
"; XKBLAYOUT" << m_layout <<
|
||||
"; XKBVARIANT" << m_variant <<
|
||||
"to /etc/default/keyboard file" << defaultKeyboardPath;
|
||||
|
||||
return ( stream.status() == QTextStream::Ok );
|
||||
}
|
||||
|
||||
|
||||
Calamares::JobResult
|
||||
SetKeyboardLayoutJob::exec()
|
||||
{
|
||||
@@ -271,6 +301,12 @@ SetKeyboardLayoutJob::exec()
|
||||
}
|
||||
destDir.mkpath( xorgConfDPath );
|
||||
|
||||
QString defaultKeyboardPath;
|
||||
if ( QDir( destDir.absoluteFilePath( "etc/default" ) ).exists() )
|
||||
{
|
||||
defaultKeyboardPath = destDir.absoluteFilePath( "etc/default/keyboard" );
|
||||
}
|
||||
|
||||
// Get the path to the destination's path to the converted key mappings
|
||||
QString convertedKeymapPath = m_convertedKeymapPath;
|
||||
if ( !convertedKeymapPath.isEmpty() )
|
||||
@@ -288,5 +324,12 @@ SetKeyboardLayoutJob::exec()
|
||||
return Calamares::JobResult::error( tr( "Failed to write keyboard configuration for X11." ),
|
||||
tr( "Failed to write to %1" ).arg( keyboardConfPath ) );
|
||||
|
||||
if ( !defaultKeyboardPath.isEmpty() && m_writeEtcDefaultKeyboard )
|
||||
{
|
||||
if ( !writeDefaultKeyboardData( defaultKeyboardPath ) )
|
||||
return Calamares::JobResult::error( tr( "Failed to write keyboard configuration to existing /etc/default directory." ),
|
||||
tr( "Failed to write to %1" ).arg( keyboardConfPath ) );
|
||||
}
|
||||
|
||||
return Calamares::JobResult::ok();
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
|
||||
* Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
|
||||
* Copyright 2014, Kevin Kofler <kevin.kofler@chello.at>
|
||||
*
|
||||
* Calamares is free software: you can redistribute it and/or modify
|
||||
@@ -31,7 +31,8 @@ public:
|
||||
const QString& layout,
|
||||
const QString& variant,
|
||||
const QString& xOrgConfFileName,
|
||||
const QString& convertedKeymapPath );
|
||||
const QString& convertedKeymapPath,
|
||||
bool writeEtcDefaultKeyboard );
|
||||
|
||||
QString prettyName() const override;
|
||||
Calamares::JobResult exec() override;
|
||||
@@ -41,13 +42,15 @@ private:
|
||||
QString findLegacyKeymap() const;
|
||||
bool writeVConsoleData( const QString& vconsoleConfPath,
|
||||
const QString& convertedKeymapPath ) const;
|
||||
bool writeX11Data( const QString& keyboardConfPath ) const;
|
||||
bool writeX11Data( const QString& keyboardConfPath ) const;
|
||||
bool writeDefaultKeyboardData( const QString& defaultKeyboardPath ) const;
|
||||
|
||||
QString m_model;
|
||||
QString m_layout;
|
||||
QString m_variant;
|
||||
QString m_xOrgConfFileName;
|
||||
QString m_convertedKeymapPath;
|
||||
const bool m_writeEtcDefaultKeyboard;
|
||||
};
|
||||
|
||||
#endif /* SETKEYBOARDLAYOUTJOB_H */
|
||||
|
@@ -3,6 +3,12 @@
|
||||
# The default value is the name used by upstream systemd-localed.
|
||||
# Relative paths are assumed to be relative to /etc/X11/xorg.conf.d
|
||||
xOrgConfFileName: "/etc/X11/xorg.conf.d/00-keyboard.conf"
|
||||
|
||||
# The path to search for keymaps converted from X11 to kbd format
|
||||
# Leave this empty if the setting does not make sense on your distribution.
|
||||
convertedKeymapPath: "/lib/kbd/keymaps/xkb"
|
||||
|
||||
# Write keymap configuration to /etc/default/keyboard, usually
|
||||
# found on Debian-related systems.
|
||||
# Defaults to true if nothing is set.
|
||||
#writeEtcDefaultKeyboard: true
|
||||
|
@@ -60,7 +60,8 @@ LocaleConfiguration::fromLanguageAndLocation( const QString& languageLocale,
|
||||
// FIXME: this might be useless if we already filter out non-UTF8 locales
|
||||
foreach ( QString line, linesForLanguage )
|
||||
{
|
||||
if ( line.contains( "UTF-8" ) )
|
||||
if ( line.contains( "UTF-8", Qt::CaseInsensitive ) ||
|
||||
line.contains( "utf8", Qt::CaseInsensitive ) )
|
||||
linesForLanguageUtf.append( line );
|
||||
}
|
||||
|
||||
|
@@ -365,7 +365,8 @@ LocalePage::init( const QString& initialRegion,
|
||||
// because it's not 1995.
|
||||
for ( auto it = m_localeGenLines.begin(); it != m_localeGenLines.end(); )
|
||||
{
|
||||
if ( !it->contains( "UTF-8", Qt::CaseInsensitive ) )
|
||||
if ( !it->contains( "UTF-8", Qt::CaseInsensitive ) &&
|
||||
!it->contains( "utf8", Qt::CaseInsensitive ) )
|
||||
it = m_localeGenLines.erase( it );
|
||||
else
|
||||
++it;
|
||||
|
@@ -43,7 +43,8 @@ def run():
|
||||
if partition["mountPoint"] == "/" and "luksMapperName" in partition:
|
||||
luks_root_device = partition["device"]
|
||||
luks_root_passphrase = partition["luksPassphrase"]
|
||||
elif "luksMapperName" in partition:
|
||||
elif "luksMapperName" in partition and\
|
||||
(partition["mountPoint"] or partition["fs"] == "linuxswap"):
|
||||
additional_luks_devices.append((partition["device"],
|
||||
partition["luksPassphrase"]))
|
||||
|
||||
@@ -65,14 +66,16 @@ def run():
|
||||
"luksAddKey",
|
||||
luks_root_device,
|
||||
"/crypto_keyfile.bin"],
|
||||
luks_root_passphrase)
|
||||
luks_root_passphrase,
|
||||
15) # timeout 15s
|
||||
|
||||
for additional_device in additional_luks_devices:
|
||||
check_target_env_call(["cryptsetup",
|
||||
"luksAddKey",
|
||||
additional_device[0],
|
||||
"/crypto_keyfile.bin"],
|
||||
additional_device[1])
|
||||
additional_device[1],
|
||||
15) # timeout 15s
|
||||
|
||||
check_target_env_call(["chmod",
|
||||
"g-rwx,o-rwx",
|
||||
|
@@ -57,6 +57,10 @@ def run():
|
||||
source_resolv = "/etc/resolv.conf"
|
||||
target_resolv = os.path.join(root_mount_point, "etc/resolv.conf")
|
||||
if source_resolv != target_resolv and os.path.exists(source_resolv):
|
||||
try:
|
||||
os.remove(target_resolv)
|
||||
except FileNotFoundError:
|
||||
libcalamares.utils.debug("Couldn't remove {}".format(target_resolv))
|
||||
try:
|
||||
shutil.copy(source_resolv, target_resolv)
|
||||
except FileNotFoundError:
|
||||
|
@@ -82,12 +82,16 @@ ChoicePage::ChoicePage( QWidget* parent )
|
||||
, m_beforePartitionLabelsView( nullptr )
|
||||
, m_bootloaderComboBox( nullptr )
|
||||
, m_lastSelectedDeviceIndex( -1 )
|
||||
, m_enableEncryptionWidget( true )
|
||||
{
|
||||
setupUi( this );
|
||||
|
||||
m_defaultFsType = Calamares::JobQueue::instance()->
|
||||
globalStorage()->
|
||||
value( "defaultFileSystemType" ).toString();
|
||||
m_enableEncryptionWidget = Calamares::JobQueue::instance()->
|
||||
globalStorage()->
|
||||
value( "enableLuksAutomatedPartitioning" ).toBool();
|
||||
if ( FileSystem::typeForName( m_defaultFsType ) == FileSystem::Unknown )
|
||||
m_defaultFsType = "ext4";
|
||||
|
||||
@@ -884,7 +888,8 @@ ChoicePage::updateActionChoicePreview( ChoicePage::Choice choice )
|
||||
{
|
||||
case Alongside:
|
||||
{
|
||||
m_encryptWidget->show();
|
||||
if ( m_enableEncryptionWidget )
|
||||
m_encryptWidget->show();
|
||||
m_previewBeforeLabel->setText( tr( "Current:" ) );
|
||||
m_selectLabel->setText( tr( "<strong>Select a partition to shrink, "
|
||||
"then drag the bottom bar to resize</strong>" ) );
|
||||
@@ -930,7 +935,8 @@ ChoicePage::updateActionChoicePreview( ChoicePage::Choice choice )
|
||||
case Erase:
|
||||
case Replace:
|
||||
{
|
||||
m_encryptWidget->show();
|
||||
if ( m_enableEncryptionWidget )
|
||||
m_encryptWidget->show();
|
||||
m_previewBeforeLabel->setText( tr( "Current:" ) );
|
||||
m_afterPartitionBarsView = new PartitionBarsView( m_previewAfterFrame );
|
||||
m_afterPartitionBarsView->setNestedPartitionsMode( mode );
|
||||
|
@@ -123,6 +123,7 @@ private:
|
||||
int m_lastSelectedDeviceIndex;
|
||||
|
||||
QString m_defaultFsType;
|
||||
bool m_enableEncryptionWidget;
|
||||
|
||||
QMutex m_coreMutex;
|
||||
};
|
||||
|
@@ -250,6 +250,8 @@ PartitionViewStep::createSummaryWidget() const
|
||||
previewLabels->setModel( info.partitionModelAfter );
|
||||
preview->setSelectionMode( QAbstractItemView::NoSelection );
|
||||
previewLabels->setSelectionMode( QAbstractItemView::NoSelection );
|
||||
previewLabels->setCustomNewRootLabel( Calamares::Branding::instance()->
|
||||
string( Calamares::Branding::BootloaderEntryName ) );
|
||||
info.partitionModelAfter->setParent( widget );
|
||||
field = new QVBoxLayout;
|
||||
CalamaresUtils::unmarginLayout( field );
|
||||
@@ -508,6 +510,17 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
gs->insert( "defaultFileSystemType", QStringLiteral( "ext4" ) );
|
||||
}
|
||||
|
||||
if ( configurationMap.contains( "enableLuksAutomatedPartitioning" ) &&
|
||||
configurationMap.value( "enableLuksAutomatedPartitioning" ).type() == QVariant::Bool )
|
||||
{
|
||||
gs->insert( "enableLuksAutomatedPartitioning",
|
||||
configurationMap.value( "enableLuksAutomatedPartitioning" ).toBool() );
|
||||
}
|
||||
else
|
||||
{
|
||||
gs->insert( "enableLuksAutomatedPartitioning", true );
|
||||
}
|
||||
|
||||
|
||||
// Now that we have the config, we load the PartitionCoreModule in the background
|
||||
// because it could take a while. Then when it's done, we can set up the widgets
|
||||
|
@@ -18,3 +18,23 @@ alwaysShowPartitionLabels: true
|
||||
# Suggested values: ext2, ext3, ext4, reiser, xfs, jfs, btrfs
|
||||
# If nothing is specified, Calamares defaults to "ext4".
|
||||
defaultFileSystemType: "ext4"
|
||||
|
||||
# Show/hide LUKS related functionality in automated partitioning modes.
|
||||
# Disable this if you choose not to deploy early unlocking support in GRUB2
|
||||
# and/or your distribution's initramfs solution.
|
||||
#
|
||||
# BIG FAT WARNING:
|
||||
# This option is unsupported, as it cuts out a crucial security feature.
|
||||
# Disabling LUKS and shipping Calamares without a correctly configured GRUB2
|
||||
# and initramfs is considered suboptimal use of the Calamares software. The
|
||||
# Calamares team will not provide user support for any potential issue that
|
||||
# may arise as a consequence of setting this option to false.
|
||||
# It is strongly recommended that system integrators put in the work to support
|
||||
# LUKS unlocking support in GRUB2 and initramfs/dracut/mkinitcpio/etc.
|
||||
# Support is offered to system integrators that wish to do so, through the
|
||||
# Calamares bug tracker, as well as in #calamares on Freenode.
|
||||
# For more information on setting up GRUB2 for Calamares with LUKS, see
|
||||
# https://github.com/calamares/calamares/wiki/LUKS-Deployment
|
||||
#
|
||||
# If nothing is specified, LUKS is enabled in automated modes.
|
||||
#enableLuksAutomatedPartitioning: true
|
||||
|
@@ -153,8 +153,8 @@ CreateUserJob::exec()
|
||||
"-s",
|
||||
"/bin/bash",
|
||||
"-U",
|
||||
"-G",
|
||||
defaultGroups,
|
||||
"-c",
|
||||
m_fullName,
|
||||
m_userName } );
|
||||
if ( ec )
|
||||
return Calamares::JobResult::error( tr( "Cannot create user %1." )
|
||||
@@ -162,11 +162,16 @@ CreateUserJob::exec()
|
||||
tr( "useradd terminated with error code %1." )
|
||||
.arg( ec ) );
|
||||
|
||||
ec = CalamaresUtils::System::instance()->targetEnvCall( { "chfn", "-f", m_fullName, m_userName } );
|
||||
ec = CalamaresUtils::System::instance()->
|
||||
targetEnvCall( { "usermod",
|
||||
"-aG",
|
||||
defaultGroups,
|
||||
m_userName } );
|
||||
if ( ec )
|
||||
return Calamares::JobResult::error( tr( "Cannot set full name for user %1." )
|
||||
.arg( m_userName ),
|
||||
tr( "chfn terminated with error code %1." )
|
||||
return Calamares::JobResult::error( tr( "Cannot add user %1 to groups: %2." )
|
||||
.arg( m_userName )
|
||||
.arg( defaultGroups ),
|
||||
tr( "usermod terminated with error code %1." )
|
||||
.arg( ec ) );
|
||||
|
||||
ec = CalamaresUtils::System::instance()->
|
||||
|
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "WelcomePage.h"
|
||||
#include "checker/RequirementsChecker.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
|
||||
#include <QVariant>
|
||||
@@ -128,5 +129,8 @@ WelcomeViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
if ( configurationMap.contains( "requirements" ) &&
|
||||
configurationMap.value( "requirements" ).type() == QVariant::Map )
|
||||
m_requirementsChecker->setConfigurationMap( configurationMap.value( "requirements" ).toMap() );
|
||||
else
|
||||
cDebug() << "WARNING: no valid requirements map found in welcome "
|
||||
"module configuration.";
|
||||
}
|
||||
|
||||
|
@@ -185,6 +185,7 @@ RequirementsChecker::widget() const
|
||||
void
|
||||
RequirementsChecker::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
{
|
||||
bool incompleteConfiguration = false;
|
||||
if ( configurationMap.contains( "requiredStorage" ) &&
|
||||
( configurationMap.value( "requiredStorage" ).type() == QVariant::Double ||
|
||||
configurationMap.value( "requiredStorage" ).type() == QVariant::Int ) )
|
||||
@@ -199,6 +200,7 @@ RequirementsChecker::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
else
|
||||
{
|
||||
m_requiredStorageGB = 3.;
|
||||
incompleteConfiguration = true;
|
||||
}
|
||||
|
||||
if ( configurationMap.contains( "requiredRam" ) &&
|
||||
@@ -208,11 +210,15 @@ RequirementsChecker::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
bool ok = false;
|
||||
m_requiredRamGB = configurationMap.value( "requiredRam" ).toDouble( &ok );
|
||||
if ( !ok )
|
||||
{
|
||||
m_requiredRamGB = 1.;
|
||||
incompleteConfiguration = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_requiredRamGB = 1.;
|
||||
incompleteConfiguration = true;
|
||||
}
|
||||
|
||||
if ( configurationMap.contains( "check" ) &&
|
||||
@@ -221,6 +227,8 @@ RequirementsChecker::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
m_entriesToCheck.clear();
|
||||
m_entriesToCheck.append( configurationMap.value( "check" ).toStringList() );
|
||||
}
|
||||
else
|
||||
incompleteConfiguration = true;
|
||||
|
||||
if ( configurationMap.contains( "required" ) &&
|
||||
configurationMap.value( "required" ).type() == QVariant::List )
|
||||
@@ -228,6 +236,19 @@ RequirementsChecker::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
m_entriesToRequire.clear();
|
||||
m_entriesToRequire.append( configurationMap.value( "required" ).toStringList() );
|
||||
}
|
||||
else
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user