Merge branch 'master' of https://github.com/calamares/calamares into development

This commit is contained in:
Philip Müller 2019-02-22 22:47:35 +01:00
commit 54a7f31433
26 changed files with 270 additions and 116 deletions

14
CHANGES
View File

@ -3,6 +3,19 @@ contributors are listed. Note that Calamares does not have a historical
changelog -- this log starts with version 3.2.0. The release notes on the changelog -- this log starts with version 3.2.0. The release notes on the
website will have to do for older versions. website will have to do for older versions.
# 3.2.5 (unreleased) #
This release contains contributions from (alphabetically by first name):
## Core ##
## Modules ##
* Python modules: several modules have had translations added. This is
usually only visible when the module runs as part of the *exec* step,
when the module's *pretty name* is displayed. In addition, error
messages are now translated.
# 3.2.4 (2019-02-12) # # 3.2.4 (2019-02-12) #
This release contains contributions from (alphabetically by first name): This release contains contributions from (alphabetically by first name):
@ -66,6 +79,7 @@ This release contains contributions from (alphabetically by first name):
the installation media to the target stystem. This can be used, for instance, the installation media to the target stystem. This can be used, for instance,
for block-level-identical installations. for block-level-identical installations.
# 3.2.3 (2019-01-09) # # 3.2.3 (2019-01-09) #
This release contains contributions from (alphabetically by first name): This release contains contributions from (alphabetically by first name):

View File

@ -75,8 +75,8 @@ set( CALAMARES_DESCRIPTION_SUMMARY
set( CALAMARES_VERSION_MAJOR 3 ) set( CALAMARES_VERSION_MAJOR 3 )
set( CALAMARES_VERSION_MINOR 2 ) set( CALAMARES_VERSION_MINOR 2 )
set( CALAMARES_VERSION_PATCH 4 ) set( CALAMARES_VERSION_PATCH 5 )
set( CALAMARES_VERSION_RC 0 ) set( CALAMARES_VERSION_RC 1 )
### Transifex (languages) info ### Transifex (languages) info
@ -240,7 +240,7 @@ include( CMakeColors )
### DEPENDENCIES ### DEPENDENCIES
# #
find_package( Qt5 ${QT_VERSION} CONFIG REQUIRED Core Gui Widgets LinguistTools Svg Quick QuickWidgets ) find_package( Qt5 ${QT_VERSION} CONFIG REQUIRED Concurrent Core Gui Widgets LinguistTools Svg Quick QuickWidgets )
find_package( YAMLCPP ${YAMLCPP_VERSION} REQUIRED ) find_package( YAMLCPP ${YAMLCPP_VERSION} REQUIRED )
if( INSTALL_POLKIT ) if( INSTALL_POLKIT )
find_package( PolkitQt5-1 REQUIRED ) find_package( PolkitQt5-1 REQUIRED )

View File

@ -2,7 +2,7 @@
* *
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org> * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2014, Teo Mrnjavac <teo@kde.org> * Copyright 2014, Teo Mrnjavac <teo@kde.org>
* Copyright 2017-2018, Adriaan de Groot <groot@kde.org> * Copyright 2017-2019, Adriaan de Groot <groot@kde.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
@ -68,9 +68,9 @@ logLevel()
} }
static void static void
log( const char* msg, unsigned int debugLevel, bool toDisk = true ) log( const char* msg, unsigned int debugLevel )
{ {
if ( toDisk || debugLevel < s_threshold ) if ( true )
{ {
QMutexLocker lock( &s_mutex ); QMutexLocker lock( &s_mutex );

View File

@ -51,7 +51,7 @@ struct NamedEnumTable
* *
* static const NamedEnumTable<Colors> c{ {"red", Colors::Red } }; * static const NamedEnumTable<Colors> c{ {"red", Colors::Red } };
*/ */
NamedEnumTable( const std::initializer_list< pair_t >& v ) : table( v ) { /* static_assert( v.size() > 0 ); */ }; NamedEnumTable( const std::initializer_list< pair_t >& v ) : table( v ) { /* static_assert( v.size() > 0 ); */ }
/** @brief Find a name @p s in the table. /** @brief Find a name @p s in the table.
* *

View File

@ -768,11 +768,11 @@ def run():
displaymanagers.remove(dm) displaymanagers.remove(dm)
if not dm_impl: if not dm_impl:
return ( libcalamares.utils.warning(
_("No display managers selected for the displaymanager module."), "No display managers selected for the displaymanager module. "
_("The list is empty after checking for installed display managers.") "The list is empty after checking for installed display managers."
) )
return None
# Pick up remaining settings # Pick up remaining settings
if "defaultDesktopEnvironment" in libcalamares.job.configuration: if "defaultDesktopEnvironment" in libcalamares.job.configuration:

View File

@ -31,7 +31,7 @@ public:
explicit LocaleConfiguration(); explicit LocaleConfiguration();
/// @brief Create a locale with everything set to the given @p localeName /// @brief Create a locale with everything set to the given @p localeName
explicit LocaleConfiguration( const QString& localeName /* "en_US.UTF-8" */ ) explicit LocaleConfiguration( const QString& localeName /* "en_US.UTF-8" */ )
: LocaleConfiguration( localeName, localeName ) { }; : LocaleConfiguration( localeName, localeName ) { }
/// @brief Create a locale with language and formats separate /// @brief Create a locale with language and formats separate
explicit LocaleConfiguration( const QString& localeName, const QString& formatsName ); explicit LocaleConfiguration( const QString& localeName, const QString& formatsName );

View File

@ -6,6 +6,7 @@
# Copyright 2014, Kevin Kofler <kevin.kofler@chello.at> # Copyright 2014, Kevin Kofler <kevin.kofler@chello.at>
# Copyright 2016, Philip Müller <philm@manjaro.org> # Copyright 2016, Philip Müller <philm@manjaro.org>
# Copyright 2017, Alf Gaida <agaida@siduction.org> # Copyright 2017, Alf Gaida <agaida@siduction.org>
# Copyright 2019, Adriaan de Groot <groot@kde.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

View File

@ -408,6 +408,56 @@ isEfiBootable( const Partition* candidate )
flags.testFlag( PartitionTable::FlagBoot ); flags.testFlag( PartitionTable::FlagBoot );
} }
QString
findFS( QString fsName, FileSystem::Type* fsType )
{
QStringList fsLanguage { QLatin1Literal( "C" ) }; // Required language list to turn off localization
if ( fsName.isEmpty() )
fsName = QStringLiteral( "ext4" );
FileSystem::Type tmpType = FileSystem::typeForName( fsName, fsLanguage );
if ( tmpType != FileSystem::Unknown )
{
cDebug() << "Found filesystem" << fsName;
if ( fsType )
*fsType = tmpType;
return fsName;
}
// Second pass: try case-insensitive
const auto fstypes = FileSystem::types();
for ( FileSystem::Type t : fstypes )
{
if ( 0 == QString::compare( fsName, FileSystem::nameForType( t, fsLanguage ), Qt::CaseInsensitive ) )
{
QString fsRealName = FileSystem::nameForType( t, fsLanguage );
cDebug() << "Filesystem name" << fsName << "translated to" << fsRealName;
if ( fsType )
*fsType = t;
return fsRealName;
}
}
cDebug() << "Filesystem" << fsName << "not found, using ext4";
fsName = QStringLiteral( "ext4" );
// fsType can be used to check whether fsName was a valid filesystem.
if (fsType)
*fsType = FileSystem::Unknown;
#ifdef DEBUG_FILESYSTEMS
// This bit is for distro's debugging their settings, and shows
// all the strings that KPMCore is matching against for FS type.
{
Logger::CDebug d;
using TR = Logger::DebugRow< int, QString >;
const auto fstypes = FileSystem::types();
d << "Available types (" << fstypes.count() << ')';
for ( FileSystem::Type t : fstypes )
d << TR( static_cast<int>( t ), FileSystem::nameForType( t, fsLanguage ) );
}
#endif
return fsName;
}
} // nmamespace PartUtils } // nmamespace PartUtils
/* Implementation of methods for FstabEntry, from OsproberEntry.h */ /* Implementation of methods for FstabEntry, from OsproberEntry.h */

View File

@ -22,6 +22,10 @@
#include "OsproberEntry.h" #include "OsproberEntry.h"
// KPMcore
#include <kpmcore/fs/filesystem.h>
// Qt
#include <QString> #include <QString>
class PartitionCoreModule; class PartitionCoreModule;
@ -73,6 +77,15 @@ bool isEfiSystem();
* the partition table layout, this may mean different flags. * the partition table layout, this may mean different flags.
*/ */
bool isEfiBootable( const Partition* candidate ); bool isEfiBootable( const Partition* candidate );
/** @brief translate @p fsName into a recognized name and type
*
* Makes several attempts to translate the string into a
* name that KPMCore will recognize.
* The corresponding filesystem type is stored in @p fsType, and
* its value is FileSystem::Unknown if @p fsName is not recognized.
*/
QString findFS( QString fsName, FileSystem::Type* fsType );
} }
#endif // PARTUTILS_H #endif // PARTUTILS_H

View File

@ -18,27 +18,50 @@
* along with Calamares. If not, see <http://www.gnu.org/licenses/>. * along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "core/PartitionLayout.h" #include "core/PartitionLayout.h"
#include "core/KPMHelpers.h" #include "core/KPMHelpers.h"
#include "core/PartitionActions.h" #include "core/PartitionActions.h"
#include "core/PartitionInfo.h" #include "core/PartitionInfo.h"
#include "core/PartUtils.h"
#include <kpmcore/core/device.h> #include <kpmcore/core/device.h>
#include <kpmcore/core/partition.h> #include <kpmcore/core/partition.h>
#include <kpmcore/fs/filesystem.h> #include <kpmcore/fs/filesystem.h>
static FileSystem::Type
getDefaultFileSystemType()
{
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
FileSystem::Type defaultFS = FileSystem::Ext4;
if ( gs->contains( "defaultFileSystemType" ) )
{
PartUtils::findFS( gs->value( "defaultFileSystemType" ).toString(), &defaultFS);
if ( defaultFS == FileSystem::Unknown )
defaultFS = FileSystem::Ext4;
}
return defaultFS;
}
PartitionLayout::PartitionLayout() PartitionLayout::PartitionLayout()
{ {
m_defaultFsType = getDefaultFileSystemType();
} }
PartitionLayout::PartitionLayout( PartitionLayout::PartitionEntry entry ) PartitionLayout::PartitionLayout( PartitionLayout::PartitionEntry entry )
{ {
partLayout.append( entry ); m_defaultFsType = getDefaultFileSystemType();
m_partLayout.append( entry );
} }
PartitionLayout::PartitionLayout( const PartitionLayout& layout ) PartitionLayout::PartitionLayout( const PartitionLayout& layout )
: partLayout( layout.partLayout ) : m_partLayout( layout.m_partLayout )
, m_defaultFsType( layout.m_defaultFsType )
{ {
} }
@ -49,7 +72,7 @@ PartitionLayout::~PartitionLayout()
void void
PartitionLayout::addEntry( PartitionLayout::PartitionEntry entry ) PartitionLayout::addEntry( PartitionLayout::PartitionEntry entry )
{ {
partLayout.append( entry ); m_partLayout.append( entry );
} }
static double static double
@ -115,9 +138,9 @@ PartitionLayout::addEntry( const QString& mountPoint, const QString& size, const
PartitionLayout::PartitionEntry entry( size, min ); PartitionLayout::PartitionEntry entry( size, min );
entry.partMountPoint = mountPoint; entry.partMountPoint = mountPoint;
entry.partFileSystem = FileSystem::Ext4; entry.partFileSystem = m_defaultFsType;
partLayout.append( entry ); m_partLayout.append( entry );
} }
void void
@ -127,9 +150,11 @@ PartitionLayout::addEntry( const QString& label, const QString& mountPoint, cons
entry.partLabel = label; entry.partLabel = label;
entry.partMountPoint = mountPoint; entry.partMountPoint = mountPoint;
entry.partFileSystem = FileSystem::typeForName( fs ); PartUtils::findFS( fs, &entry.partFileSystem );
if ( entry.partFileSystem == FileSystem::Unknown )
entry.partFileSystem = m_defaultFsType;
partLayout.append( entry ); m_partLayout.append( entry );
} }
static qint64 static qint64
@ -175,7 +200,7 @@ PartitionLayout::execute( Device *dev, qint64 firstSector,
// TODO: Refine partition sizes to make sure there is room for every partition // TODO: Refine partition sizes to make sure there is room for every partition
// Use a default (200-500M ?) minimum size for partition without minSize // Use a default (200-500M ?) minimum size for partition without minSize
foreach( const PartitionLayout::PartitionEntry& part, partLayout ) foreach( const PartitionLayout::PartitionEntry& part, m_partLayout )
{ {
Partition *currentPartition = nullptr; Partition *currentPartition = nullptr;
@ -194,7 +219,7 @@ PartitionLayout::execute( Device *dev, qint64 firstSector,
parent, parent,
*dev, *dev,
role, role,
static_cast<FileSystem::Type>(part.partFileSystem), part.partFileSystem,
firstSector, firstSector,
end, end,
PartitionTable::FlagNone PartitionTable::FlagNone
@ -206,7 +231,7 @@ PartitionLayout::execute( Device *dev, qint64 firstSector,
parent, parent,
*dev, *dev,
role, role,
static_cast<FileSystem::Type>(part.partFileSystem), part.partFileSystem,
firstSector, firstSector,
end, end,
luksPassphrase, luksPassphrase,

View File

@ -24,6 +24,7 @@
// KPMcore // KPMcore
#include <kpmcore/core/partitiontable.h> #include <kpmcore/core/partitiontable.h>
#include <kpmcore/fs/filesystem.h>
// Qt // Qt
#include <QList> #include <QList>
@ -48,7 +49,7 @@ public:
{ {
QString partLabel; QString partLabel;
QString partMountPoint; QString partMountPoint;
int partFileSystem = 0; FileSystem::Type partFileSystem = FileSystem::Unknown;
double partSize = 0.0L; double partSize = 0.0L;
SizeUnit partSizeUnit = Percent; SizeUnit partSizeUnit = Percent;
double partMinSize = 0.0L; double partMinSize = 0.0L;
@ -76,7 +77,8 @@ public:
QList< Partition* > execute( Device *dev, qint64 firstSector, qint64 lastSector, QString luksPassphrase, PartitionNode* parent, const PartitionRole& role ); QList< Partition* > execute( Device *dev, qint64 firstSector, qint64 lastSector, QString luksPassphrase, PartitionNode* parent, const PartitionRole& role );
private: private:
QList< PartitionEntry > partLayout; FileSystem::Type m_defaultFsType;
QList< PartitionEntry > m_partLayout;
}; };
#endif /* PARTITIONLAYOUT_H */ #endif /* PARTITIONLAYOUT_H */

View File

@ -1248,7 +1248,7 @@ ChoicePage::setupActions()
} }
if ( PartUtils::canBeReplaced( *it ) ) if ( PartUtils::canBeReplaced( *it ) )
{ {
cDebug() << ".. contains replacable" << it; cDebug() << ".. contains replaceable" << it;
atLeastOneCanBeReplaced = true; atLeastOneCanBeReplaced = true;
} }
if ( (*it)->isMounted() ) if ( (*it)->isMounted() )

View File

@ -34,7 +34,7 @@ CreateVolumeGroupDialog::CreateVolumeGroupDialog( QString& vgName,
, m_selectedPVs( selectedPVs ) , m_selectedPVs( selectedPVs )
, m_peSize( pSize ) , m_peSize( pSize )
{ {
setWindowTitle( "Create Volume Group" ); setWindowTitle( tr( "Create Volume Group" ) );
peSize()->setValue( pSize ); peSize()->setValue( pSize );

View File

@ -44,7 +44,7 @@ void
standardMountPoints(QComboBox& combo) standardMountPoints(QComboBox& combo)
{ {
combo.clear(); combo.clear();
combo.addItem( combo.tr( "(no mount point)" ) ); combo.addItem( QObject::tr( "(no mount point)" ) );
combo.addItems( standardMountPoints() ); combo.addItems( standardMountPoints() );
} }

View File

@ -493,55 +493,6 @@ nameToChoice( QString name, bool& ok )
return names.find( name, ok ); return names.find( name, ok );
} }
/** @brief translate @p defaultFS into a recognized name
*
* Makes several attempts to translate the string into a
* name that KPMCore will recognize.
*/
static QString
findFS( QString defaultFS )
{
QStringList fsLanguage { QLatin1Literal( "C" ) }; // Required language list to turn off localization
if ( defaultFS.isEmpty() )
{
cWarning() << "Partition-module setting *defaultFileSystemType* is missing, using ext4";
defaultFS = QStringLiteral( "ext4" );
}
if ( FileSystem::typeForName( defaultFS, fsLanguage ) != FileSystem::Unknown )
{
cDebug() << "Partition-module setting *defaultFileSystemType*" << defaultFS;
return defaultFS;
}
// Second pass: try case-insensitive
const auto fstypes = FileSystem::types();
for ( FileSystem::Type t : fstypes )
{
if ( 0 == QString::compare( defaultFS, FileSystem::nameForType( t, fsLanguage ), Qt::CaseInsensitive ) )
{
defaultFS = FileSystem::nameForType( t, fsLanguage );
cWarning() << "Partition-module setting *defaultFileSystemType* changed" << defaultFS;
return defaultFS;
}
}
cWarning() << "Partition-module setting *defaultFileSystemType* is bad (" << defaultFS << ") using ext4.";
defaultFS = QStringLiteral( "ext4" );
#ifdef DEBUG_FILESYSTEMS
// This bit is for distro's debugging their settings, and shows
// all the strings that KPMCore is matching against for FS type.
{
Logger::CDebug d;
using TR = Logger::DebugRow< int, QString >;
const auto fstypes = FileSystem::types();
d << "Available types (" << fstypes.count() << ')';
for ( FileSystem::Type t : fstypes )
d << TR( static_cast<int>( t ), FileSystem::nameForType( t, fsLanguage ) );
}
#endif
return defaultFS;
}
void void
PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap ) PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{ {
@ -630,7 +581,21 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
gs->insert( "alwaysShowPartitionLabels", CalamaresUtils::getBool( configurationMap, "alwaysShowPartitionLabels", true ) ); gs->insert( "alwaysShowPartitionLabels", CalamaresUtils::getBool( configurationMap, "alwaysShowPartitionLabels", true ) );
gs->insert( "enableLuksAutomatedPartitioning", CalamaresUtils::getBool( configurationMap, "enableLuksAutomatedPartitioning", true ) ); gs->insert( "enableLuksAutomatedPartitioning", CalamaresUtils::getBool( configurationMap, "enableLuksAutomatedPartitioning", true ) );
gs->insert( "allowManualPartitioning", CalamaresUtils::getBool( configurationMap, "allowManualPartitioning", true ) ); gs->insert( "allowManualPartitioning", CalamaresUtils::getBool( configurationMap, "allowManualPartitioning", true ) );
gs->insert( "defaultFileSystemType", findFS( CalamaresUtils::getString( configurationMap, "defaultFileSystemType" ) ) );
// The defaultFileSystemType setting needs a bit more processing,
// as we want to cover various cases (such as different cases)
QString fsName = CalamaresUtils::getString( configurationMap, "defaultFileSystemType" );
FileSystem::Type fsType;
if ( fsName.isEmpty() )
cWarning() << "Partition-module setting *defaultFileSystemType* is missing, will use ext4";
QString fsRealName = PartUtils::findFS( fsName, &fsType );
if ( fsRealName == fsName )
cDebug() << "Partition-module setting *defaultFileSystemType*" << fsRealName;
else if ( fsType != FileSystem::Unknown )
cWarning() << "Partition-module setting *defaultFileSystemType* changed" << fsRealName;
else
cWarning() << "Partition-module setting *defaultFileSystemType* is bad (" << fsRealName << ") using ext4.";
gs->insert( "defaultFileSystemType", fsRealName );
// Now that we have the config, we load the PartitionCoreModule in the background // Now that we have the config, we load the PartitionCoreModule in the background

View File

@ -35,7 +35,7 @@ ResizeVolumeGroupDialog::ResizeVolumeGroupDialog( LvmDevice *device,
: VolumeGroupBaseDialog( device->name(), device->physicalVolumes(), parent ) : VolumeGroupBaseDialog( device->name(), device->physicalVolumes(), parent )
, m_selectedPVs( selectedPVs ) , m_selectedPVs( selectedPVs )
{ {
setWindowTitle( "Resize Volume Group" ); setWindowTitle( tr( "Resize Volume Group" ) );
for ( int i = 0; i < pvList()->count(); i++ ) for ( int i = 0; i < pvList()->count(); i++ )
pvList()->item(i)->setCheckState( Qt::Checked ); pvList()->item(i)->setCheckState( Qt::Checked );

View File

@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>VolumeGroupDialog</string> <string>Create Volume Group</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="0" column="0">

View File

@ -27,6 +27,7 @@
class CreateVolumeGroupJob : public Calamares::Job class CreateVolumeGroupJob : public Calamares::Job
{ {
Q_OBJECT
public: public:
CreateVolumeGroupJob( QString& vgName, QVector< const Partition* > pvList, const qint32 peSize ); CreateVolumeGroupJob( QString& vgName, QVector< const Partition* > pvList, const qint32 peSize );

View File

@ -25,6 +25,7 @@ class LvmDevice;
class DeactivateVolumeGroupJob : public Calamares::Job class DeactivateVolumeGroupJob : public Calamares::Job
{ {
Q_OBJECT
public: public:
DeactivateVolumeGroupJob( LvmDevice* device ); DeactivateVolumeGroupJob( LvmDevice* device );

View File

@ -25,6 +25,7 @@ class LvmDevice;
class RemoveVolumeGroupJob : public Calamares::Job class RemoveVolumeGroupJob : public Calamares::Job
{ {
Q_OBJECT
public: public:
RemoveVolumeGroupJob( LvmDevice* device ); RemoveVolumeGroupJob( LvmDevice* device );

View File

@ -28,6 +28,7 @@ class Partition;
class ResizeVolumeGroupJob : public Calamares::Job class ResizeVolumeGroupJob : public Calamares::Job
{ {
Q_OBJECT
public: public:
ResizeVolumeGroupJob( LvmDevice* device, QVector< const Partition* >& partitionList ); ResizeVolumeGroupJob( LvmDevice* device, QVector< const Partition* >& partitionList );

View File

@ -6,6 +6,7 @@
# Copyright 2016, Artoo <artoo@manjaro.org> # Copyright 2016, Artoo <artoo@manjaro.org>
# Copyright 2017, Alf Gaida <agaida@siduction.org> # Copyright 2017, Alf Gaida <agaida@siduction.org>
# Copyright 2018, Gabriel Craciunescu <crazy@frugalware.org> # Copyright 2018, Gabriel Craciunescu <crazy@frugalware.org>
# Copyright 2019, Adriaan de Groot <groot@kde.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
@ -24,6 +25,16 @@ import libcalamares
from libcalamares.utils import debug, target_env_call from libcalamares.utils import debug, target_env_call
import gettext
_ = gettext.translation("calamares-python",
localedir=libcalamares.utils.gettext_path(),
languages=libcalamares.utils.gettext_languages(),
fallback=True).gettext
def pretty_name():
return _("Configure Plymouth theme")
class PlymouthController: class PlymouthController:

View File

@ -5,6 +5,7 @@
# #
# Copyright 2015, Teo Mrnjavac <teo@kde.org> # Copyright 2015, Teo Mrnjavac <teo@kde.org>
# Copyright 2017. Alf Gaida <agaida@siduction.org> # Copyright 2017. Alf Gaida <agaida@siduction.org>
# Copyright 2019, Adriaan de Groot <groot@kde.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,6 +23,16 @@
import subprocess import subprocess
import libcalamares import libcalamares
import gettext
_ = gettext.translation("calamares-python",
localedir=libcalamares.utils.gettext_path(),
languages=libcalamares.utils.gettext_languages(),
fallback=True).gettext
def pretty_name():
return _("Remove live user from target system")
def run(): def run():
""" """

View File

@ -6,7 +6,7 @@
# Copyright 2016, Artoo <artoo@manjaro.org> # Copyright 2016, Artoo <artoo@manjaro.org>
# Copyright 2017, Philip Müller <philm@manjaro.org> # Copyright 2017, Philip Müller <philm@manjaro.org>
# Copyright 2018, Artoo <artoo@artixlinux.org> # Copyright 2018, Artoo <artoo@artixlinux.org>
# Copyright 2018, Adriaan de Groot <groot@kde.org> # Copyright 2018-2019, Adriaan de Groot <groot@kde.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
@ -27,6 +27,17 @@ from libcalamares.utils import target_env_call, warning
from os.path import exists, join from os.path import exists, join
import gettext
_ = gettext.translation("calamares-python",
localedir=libcalamares.utils.gettext_path(),
languages=libcalamares.utils.gettext_languages(),
fallback=True).gettext
def pretty_name():
return _("Configure OpenRC services")
class OpenrcController: class OpenrcController:
""" """
This is the openrc service controller. This is the openrc service controller.
@ -45,6 +56,22 @@ class OpenrcController:
self.initdDir = libcalamares.job.configuration['initdDir'] self.initdDir = libcalamares.job.configuration['initdDir']
self.runlevelsDir = libcalamares.job.configuration['runlevelsDir'] self.runlevelsDir = libcalamares.job.configuration['runlevelsDir']
def make_failure_description(self, state, name, runlevel):
"""
Returns a generic "could not <foo>" failure message, specialized
for the action @p state and the specific service @p name in @p runlevel.
"""
if state == "add":
description = _("Cannot add service {name!s} to run-level {level!s}.")
elif state == "del":
description = _("Cannot remove service {name!s} from run-level {level!s}.")
else:
description = _("Unknown service-action <code>{arg!s}</code> for service {name!s} in run-level {level!s}.")
return description.format(arg=state, name=name, level=runlevel)
def update(self, state): def update(self, state):
""" """
Call rc-update for each service listed Call rc-update for each service listed
@ -69,24 +96,31 @@ class OpenrcController:
if exists(runlevel_path): if exists(runlevel_path):
ec = target_env_call(["rc-update", state, name, runlevel]) ec = target_env_call(["rc-update", state, name, runlevel])
if ec != 0: if ec != 0:
warning("Cannot {} service {} to {}".format(state, name, runlevel))
warning("rc-update returned error code {!s}".format(ec))
if mandatory: if mandatory:
return ("Cannot {} service {} to {}".format(state, name, runlevel), title = _("Cannot modify service")
"rc-update {} call in chroot returned error code {}".format(state, ec) diagnostic = _("<code>rc-update {arg!s}</code> call in chroot returned error code {num!s}.").format(arg=state, num=ec)
return (title,
self.make_failure_description(state, name, runlevel) + " " + diagnostic
) )
else:
warning("Could not {} service {} in {}, error {!s}".format(state, name, runlevel, ec))
else: else:
warning("Target runlevel {} does not exist for {}.".format(runlevel, name))
if mandatory: if mandatory:
return ("Target runlevel {} does not exist for {}.".format(runlevel, name), title = _("Target runlevel does not exist")
"No {} found.".format(runlevel_path)) diagnostic = _("The path for runlevel {level!s} is <code>{path!s}</code>, which does not exist.").format(level=runlevel, path=runlevel_path)
else:
warning("Target runlevel {} does not exist for {}.".format(runlevel, name)) return (title,
self.make_failure_description(state, name, runlevel) + " " + diagnostic
)
else: else:
warning("Target service {} does not exist in {}.".format(name, self.initdDir))
if mandatory: if mandatory:
return ("Target service {} does not exist.".format(name), title = _("Target service does not exist")
"No {} found.".format(service_path)) diagnostic = _("The path for service {name!s} is <code>{path!s}</code>, which does not exist.").format(name=name, path=service_path)
else: return (title,
warning("Target service {} does not exist in {}.".format(name, self.initdDir)) self.make_failure_description(state, name, runlevel) + " " + diagnostic
)
def run(self): def run(self):

View File

@ -6,7 +6,7 @@
# Copyright 2014, Philip Müller <philm@manjaro.org> # Copyright 2014, Philip Müller <philm@manjaro.org>
# Copyright 2014, Teo Mrnjavac <teo@kde.org> # Copyright 2014, Teo Mrnjavac <teo@kde.org>
# Copyright 2017, Alf Gaida <agaida@siduction.org> # Copyright 2017, Alf Gaida <agaida@siduction.org>
# Copyright 2018, Adriaan de Groot <groot@kde.org> # Copyright 2018-2019, Adriaan de Groot <groot@kde.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
@ -24,6 +24,17 @@
import libcalamares import libcalamares
import gettext
_ = gettext.translation("calamares-python",
localedir=libcalamares.utils.gettext_path(),
languages=libcalamares.utils.gettext_languages(),
fallback=True).gettext
def pretty_name():
return _("Configure systemd services")
def systemctl(targets, command, suffix): def systemctl(targets, command, suffix):
""" """
For each entry in @p targets, run "systemctl <command> <thing>", For each entry in @p targets, run "systemctl <command> <thing>",
@ -47,17 +58,32 @@ def systemctl(targets, command, suffix):
) )
if ec != 0: if ec != 0:
libcalamares.utils.warning(
"Cannot {} systemd {} {}".format(command, suffix, name)
)
libcalamares.utils.warning(
"systemctl {} call in chroot returned error code {}".format(command, ec)
)
if mandatory: if mandatory:
return ("Cannot {} systemd {} {}".format(command, suffix, name), title = _("Cannot modify service")
"systemctl {} call in chroot returned error code {}".format(command, ec) diagnostic = _("<code>systemctl {arg!s}</code> call in chroot returned error code {num!s}.").format(arg=command, num=ec)
if command == "enable" and suffix == ".service":
description = _("Cannot enable systemd service <code>{name!s}</code>.")
elif command == "enable" and suffix == ".target":
description = _("Cannot enable systemd target <code>{name!s}</code>.")
elif command == "disable" and suffix == ".service":
description = _("Cannot enable systemd service <code>{name!s}</code>.")
elif command == "disable" and suffix == ".target":
description = _("Cannot disable systemd target <code>{name!s}</code>.")
elif command == "mask":
description = _("Cannot mask systemd unit <code>{name!s}</code>.")
else:
description = _("Unknown systemd commands <code>{command!s}</code> and <code>{suffix!s}</code> for unit {name!s}.")
return (title,
description.format(name=name, command=command, suffix=suffix) + " " + diagnostic
) )
else:
libcalamares.utils.warning(
"Cannot {} systemd {} {}".format(command, suffix, name)
)
libcalamares.utils.warning(
"systemctl {} call in chroot returned error code {}".format(command, ec)
)
return None return None
@ -92,6 +118,4 @@ def run():
if r is not None: if r is not None:
return r return r
# This could have just been return r
return None return None

View File

@ -154,29 +154,29 @@ CreateUserJob::exec()
useradd << "-c" << m_fullName; useradd << "-c" << m_fullName;
useradd << m_userName; useradd << m_userName;
auto pres = CalamaresUtils::System::instance()->targetEnvCommand( useradd ); auto commandResult = CalamaresUtils::System::instance()->targetEnvCommand( useradd );
if ( pres.getExitCode() ) if ( commandResult.getExitCode() )
{ {
cError() << "useradd failed" << pres.getExitCode(); cError() << "useradd failed" << commandResult.getExitCode();
return pres.explainProcess( useradd, 10 /* bogus timeout */ ); return commandResult.explainProcess( useradd, 10 /* bogus timeout */ );
} }
pres = CalamaresUtils::System::instance()->targetEnvCommand( commandResult = CalamaresUtils::System::instance()->targetEnvCommand(
{ "usermod", "-aG", defaultGroups, m_userName } ); { "usermod", "-aG", defaultGroups, m_userName } );
if ( pres.getExitCode() ) if ( commandResult.getExitCode() )
{ {
cError() << "usermod failed" << pres.getExitCode(); cError() << "usermod failed" << commandResult.getExitCode();
return pres.explainProcess( "usermod", 10 ); return commandResult.explainProcess( "usermod", 10 );
} }
QString userGroup = QString( "%1:%2" ).arg( m_userName ).arg( m_userName ); QString userGroup = QString( "%1:%2" ).arg( m_userName ).arg( m_userName );
QString homeDir = QString( "/home/%1" ).arg( m_userName ); QString homeDir = QString( "/home/%1" ).arg( m_userName );
pres = CalamaresUtils::System::instance()->targetEnvCommand( commandResult = CalamaresUtils::System::instance()->targetEnvCommand(
{ "chown", "-R", userGroup, homeDir } ); { "chown", "-R", userGroup, homeDir } );
if ( pres.getExitCode() ) if ( commandResult.getExitCode() )
{ {
cError() << "chown failed" << pres.getExitCode(); cError() << "chown failed" << commandResult.getExitCode();
return pres.explainProcess( "chown", 10 ); return commandResult.explainProcess( "chown", 10 );
} }
return Calamares::JobResult::ok(); return Calamares::JobResult::ok();