From 9302ad14682d4aaf274835a73b6e7d929d39237d Mon Sep 17 00:00:00 2001 From: Artem Grinev Date: Wed, 31 Mar 2021 20:15:02 +0400 Subject: [PATCH 01/54] [partition] Erase disk FS choice --- src/modules/partition/core/Config.cpp | 20 +++++++++++++++++++ src/modules/partition/core/Config.h | 10 ++++++++++ .../partition/core/PartitionActions.cpp | 4 ++++ .../partition/core/PartitionCoreModule.cpp | 1 + src/modules/partition/gui/ChoicePage.cpp | 11 ++++++++-- src/modules/partition/gui/ChoicePage.h | 2 ++ src/modules/partition/partition.conf | 2 +- 7 files changed, 47 insertions(+), 3 deletions(-) diff --git a/src/modules/partition/core/Config.cpp b/src/modules/partition/core/Config.cpp index 0afcee83d..a603cedd0 100644 --- a/src/modules/partition/core/Config.cpp +++ b/src/modules/partition/core/Config.cpp @@ -207,6 +207,15 @@ Config::setSwapChoice( Config::SwapChoice c ) } } +void +Config::setEraseFsTypeChoice(const QString& choice) +{ + if(choice != m_eraseFsTypeChoice){ + m_eraseFsTypeChoice = choice; + } +} + + bool Config::allowManualPartitioning() const { @@ -240,6 +249,17 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) gs->insert( "allowManualPartitioning", CalamaresUtils::getBool( configurationMap, "allowManualPartitioning", true ) ); + if ( configurationMap.contains( "availableFileSystemTypes" ) ) { + if(configurationMap.value( "availableFileSystemTypes" ).type() == QVariant::List ){ + m_eraseFsTypes.clear(); + m_eraseFsTypes.append(configurationMap.value( "availableFileSystemTypes" ).toStringList()); + m_eraseFsTypeChoice = m_eraseFsTypes[0]; + } else if ( configurationMap.value( "availableFileSystemTypes" ).type() == QVariant::String ){ + m_eraseFsTypes.append(configurationMap.value( "availableFileSystemTypes" ).toString()); + m_eraseFsTypeChoice = m_eraseFsTypes[0]; + } + } + if ( configurationMap.contains( "requiredPartitionTableType" ) && configurationMap.value( "requiredPartitionTableType" ).type() == QVariant::List ) { diff --git a/src/modules/partition/core/Config.h b/src/modules/partition/core/Config.h index 57230b6e8..5cdd14c9d 100644 --- a/src/modules/partition/core/Config.h +++ b/src/modules/partition/core/Config.h @@ -54,6 +54,8 @@ public: static const NamedEnumTable< SwapChoice >& swapChoiceNames(); using SwapChoiceSet = QSet< SwapChoice >; + using EraseFsTypesSet = QStringList; + void setConfigurationMap( const QVariantMap& ); void updateGlobalStorage() const; @@ -94,6 +96,11 @@ public: */ SwapChoice swapChoice() const { return m_swapChoice; } + EraseFsTypesSet eraseFsTypes() const {return m_eraseFsTypes; } + + QString eraseFsType() const {return m_eraseFsTypeChoice; } + + ///@brief Is manual partitioning allowed (not explicitly disnabled in the config file)? bool allowManualPartitioning() const; @@ -102,6 +109,7 @@ public Q_SLOTS: void setInstallChoice( InstallChoice ); void setSwapChoice( int ); ///< Translates a button ID or so to SwapChoice void setSwapChoice( SwapChoice ); + void setEraseFsTypeChoice( const QString& ); Q_SIGNALS: void installChoiceChanged( InstallChoice ); @@ -109,6 +117,8 @@ Q_SIGNALS: private: SwapChoiceSet m_swapChoices; + EraseFsTypesSet m_eraseFsTypes; + QString m_eraseFsTypeChoice; SwapChoice m_initialSwapChoice = NoSwap; SwapChoice m_swapChoice = NoSwap; InstallChoice m_initialInstallChoice = NoChoice; diff --git a/src/modules/partition/core/PartitionActions.cpp b/src/modules/partition/core/PartitionActions.cpp index 1a3f6246b..0dab5747f 100644 --- a/src/modules/partition/core/PartitionActions.cpp +++ b/src/modules/partition/core/PartitionActions.cpp @@ -109,6 +109,10 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO partType = isEfi ? PartitionTable::gpt : PartitionTable::msdos; } + FileSystem::Type type; + PartUtils::findFS(o.defaultFsType, &type); + core->initLayout( type == FileSystem::Unknown ? FileSystem::Ext4 : type); + core->createPartitionTable( dev, partType ); if ( isEfi ) diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp index 058c10d18..4370ffa0d 100644 --- a/src/modules/partition/core/PartitionCoreModule.cpp +++ b/src/modules/partition/core/PartitionCoreModule.cpp @@ -381,6 +381,7 @@ PartitionCoreModule::createPartitionTable( Device* device, PartitionTable::Table OperationHelper helper( partitionModelForDevice( device ), this ); deviceInfo->makeJob< CreatePartitionTableJob >( type ); + } } diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index f6b49cb2f..a8f31d416 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -246,6 +246,14 @@ ChoicePage::setupChoices() m_eraseButton->addOptionsComboBox( m_eraseSwapChoiceComboBox ); } + if ( m_config->eraseFsTypes().count() > 1) + { + m_eraseFsTypesChoiceComboBox = new QComboBox; + m_eraseFsTypesChoiceComboBox->addItems(m_config->eraseFsTypes()); + connect(m_eraseFsTypesChoiceComboBox, &QComboBox::currentTextChanged, [this](const auto& currentString){m_config->setEraseFsTypeChoice(currentString); onActionChanged();}); + m_eraseButton->addOptionsComboBox( m_eraseFsTypesChoiceComboBox ); + } + m_itemsLayout->addWidget( m_alongsideButton ); m_itemsLayout->addWidget( m_replaceButton ); m_itemsLayout->addWidget( m_eraseButton ); @@ -442,9 +450,8 @@ ChoicePage::applyActionChoice( InstallChoice choice ) case InstallChoice::Erase: { auto gs = Calamares::JobQueue::instance()->globalStorage(); - PartitionActions::Choices::AutoPartitionOptions options { gs->value( "defaultPartitionTableType" ).toString(), - gs->value( "defaultFileSystemType" ).toString(), + m_config->eraseFsType(), m_encryptWidget->passphrase(), gs->value( "efiSystemPartition" ).toString(), CalamaresUtils::GiBtoBytes( diff --git a/src/modules/partition/gui/ChoicePage.h b/src/modules/partition/gui/ChoicePage.h index 89bd775d7..f43578ba5 100644 --- a/src/modules/partition/gui/ChoicePage.h +++ b/src/modules/partition/gui/ChoicePage.h @@ -139,6 +139,8 @@ private: Calamares::PrettyRadioButton* m_replaceButton; Calamares::PrettyRadioButton* m_somethingElseButton; QComboBox* m_eraseSwapChoiceComboBox; // UI, see also m_eraseSwapChoice + QComboBox* m_eraseFsTypesChoiceComboBox; // UI, see also m_eraseSwapChoice + DeviceInfoWidget* m_deviceInfoWidget; diff --git a/src/modules/partition/partition.conf b/src/modules/partition/partition.conf index e5de69659..19d3e1745 100644 --- a/src/modules/partition/partition.conf +++ b/src/modules/partition/partition.conf @@ -137,7 +137,7 @@ initialSwapChoice: none # If nothing is specified, Calamares defaults to "ext4". # # Names are case-sensitive and defined by KPMCore. -defaultFileSystemType: "ext4" +availableFileSystemTypes: ["ext4", "btrfs", "f2fs"] # Show/hide LUKS related functionality in automated partitioning modes. # Disable this if you choose not to deploy early unlocking support in GRUB2 From 546253d750aa8f93be7aca016d87635f9cd299dd Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 18 Jun 2021 11:00:15 +0200 Subject: [PATCH 02/54] [partition] Apply coding style --- src/modules/partition/core/PartitionActions.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/modules/partition/core/PartitionActions.cpp b/src/modules/partition/core/PartitionActions.cpp index 0dab5747f..728eda767 100644 --- a/src/modules/partition/core/PartitionActions.cpp +++ b/src/modules/partition/core/PartitionActions.cpp @@ -16,13 +16,12 @@ #include "core/PartitionCoreModule.h" #include "core/PartitionInfo.h" -#include "utils/CalamaresUtilsSystem.h" -#include "utils/NamedEnum.h" -#include "utils/Units.h" - #include "GlobalStorage.h" #include "JobQueue.h" +#include "utils/CalamaresUtilsSystem.h" #include "utils/Logger.h" +#include "utils/NamedEnum.h" +#include "utils/Units.h" #include #include @@ -110,8 +109,8 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO } FileSystem::Type type; - PartUtils::findFS(o.defaultFsType, &type); - core->initLayout( type == FileSystem::Unknown ? FileSystem::Ext4 : type); + PartUtils::findFS( o.defaultFsType, &type ); + core->initLayout( type == FileSystem::Unknown ? FileSystem::Ext4 : type ); core->createPartitionTable( dev, partType ); From f9659989b18efb0e4e8eed268f5d6b85ac2ebb08 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 18 Jun 2021 11:06:02 +0200 Subject: [PATCH 03/54] [partition] rename findFS Rename findFS -> canonicalFilesystemName because that's what it actually does. While here, apply coding style to the files that are affected. --- src/modules/partition/core/PartUtils.cpp | 2 +- src/modules/partition/core/PartUtils.h | 6 ++++-- src/modules/partition/core/PartitionActions.cpp | 6 ++++-- src/modules/partition/core/PartitionLayout.cpp | 2 +- src/modules/partition/gui/CreatePartitionDialog.cpp | 2 +- .../partition/gui/EditExistingPartitionDialog.cpp | 2 +- src/modules/partition/gui/PartitionViewStep.cpp | 9 ++++----- 7 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/modules/partition/core/PartUtils.cpp b/src/modules/partition/core/PartUtils.cpp index 368d04af2..8d048b297 100644 --- a/src/modules/partition/core/PartUtils.cpp +++ b/src/modules/partition/core/PartUtils.cpp @@ -472,7 +472,7 @@ isEfiBootable( const Partition* candidate ) } QString -findFS( QString fsName, FileSystem::Type* fsType ) +canonicalFilesystemName( const QString& fsName, FileSystem::Type* fsType ) { QStringList fsLanguage { QLatin1String( "C" ) }; // Required language list to turn off localization if ( fsName.isEmpty() ) diff --git a/src/modules/partition/core/PartUtils.h b/src/modules/partition/core/PartUtils.h index aec345882..89d2c5e1a 100644 --- a/src/modules/partition/core/PartUtils.h +++ b/src/modules/partition/core/PartUtils.h @@ -91,11 +91,13 @@ 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. + * name that KPMCore will recognize. Returns the canonical + * filesystem name (e.g. asking for "EXT4" will return "ext4"). + * * 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 ); +QString canonicalFilesystemName( const QString& fsName, FileSystem::Type* fsType ); } // namespace PartUtils diff --git a/src/modules/partition/core/PartitionActions.cpp b/src/modules/partition/core/PartitionActions.cpp index 728eda767..422c1d38f 100644 --- a/src/modules/partition/core/PartitionActions.cpp +++ b/src/modules/partition/core/PartitionActions.cpp @@ -108,8 +108,10 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO partType = isEfi ? PartitionTable::gpt : PartitionTable::msdos; } - FileSystem::Type type; - PartUtils::findFS( o.defaultFsType, &type ); + // Looking up the defaultFsType (which should name a filesystem type) + // will log an error and set the type to Unknown if there's something wrong. + FileSystem::Type type = FileSystem::Unknown; + PartUtils::canonicalFilesystemName( o.defaultFsType, &type ); core->initLayout( type == FileSystem::Unknown ? FileSystem::Ext4 : type ); core->createPartitionTable( dev, partType ); diff --git a/src/modules/partition/core/PartitionLayout.cpp b/src/modules/partition/core/PartitionLayout.cpp index 23eaeda62..c828fce69 100644 --- a/src/modules/partition/core/PartitionLayout.cpp +++ b/src/modules/partition/core/PartitionLayout.cpp @@ -75,7 +75,7 @@ PartitionLayout::PartitionEntry::PartitionEntry( const QString& label, , partMinSize( minSize ) , partMaxSize( maxSize ) { - PartUtils::findFS( fs, &partFileSystem ); + PartUtils::canonicalFilesystemName( fs, &partFileSystem ); } diff --git a/src/modules/partition/gui/CreatePartitionDialog.cpp b/src/modules/partition/gui/CreatePartitionDialog.cpp index c765bf1f7..4236022be 100644 --- a/src/modules/partition/gui/CreatePartitionDialog.cpp +++ b/src/modules/partition/gui/CreatePartitionDialog.cpp @@ -96,7 +96,7 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, // File system; the config value is translated (best-effort) to a type FileSystem::Type defaultFSType; - QString untranslatedFSName = PartUtils::findFS( + QString untranslatedFSName = PartUtils::canonicalFilesystemName( Calamares::JobQueue::instance()->globalStorage()->value( "defaultFileSystemType" ).toString(), &defaultFSType ); if ( defaultFSType == FileSystem::Type::Unknown ) { diff --git a/src/modules/partition/gui/EditExistingPartitionDialog.cpp b/src/modules/partition/gui/EditExistingPartitionDialog.cpp index e2d7ac5ba..411d6d0dc 100644 --- a/src/modules/partition/gui/EditExistingPartitionDialog.cpp +++ b/src/modules/partition/gui/EditExistingPartitionDialog.cpp @@ -97,7 +97,7 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, m_ui->fileSystemComboBox->addItems( fsNames ); FileSystem::Type defaultFSType; - QString untranslatedFSName = PartUtils::findFS( + QString untranslatedFSName = PartUtils::canonicalFilesystemName( Calamares::JobQueue::instance()->globalStorage()->value( "defaultFileSystemType" ).toString(), &defaultFSType ); if ( defaultFSType == FileSystem::Type::Unknown ) { diff --git a/src/modules/partition/gui/PartitionViewStep.cpp b/src/modules/partition/gui/PartitionViewStep.cpp index b4eefb3b0..52bf1fc3b 100644 --- a/src/modules/partition/gui/PartitionViewStep.cpp +++ b/src/modules/partition/gui/PartitionViewStep.cpp @@ -388,7 +388,7 @@ shouldWarnForGPTOnBIOS( const PartitionCoreModule* core ) } auto [ r, device ] = core->bootLoaderModel()->findBootLoader( core->bootLoaderInstallPath() ); - Q_UNUSED(r); + Q_UNUSED( r ); if ( device ) { auto* table = device->partitionTable(); @@ -403,8 +403,7 @@ shouldWarnForGPTOnBIOS( const PartitionCoreModule* core ) && ( partition->fileSystem().type() == FileSystem::Unformatted ) && ( partition->capacity() >= 8_MiB ) ) { - cDebug() << Logger::SubEntry << "Partition" << partition->devicePath() - << partition->partitionPath() + cDebug() << Logger::SubEntry << "Partition" << partition->devicePath() << partition->partitionPath() << "is a suitable bios_grub partition"; return false; } @@ -591,7 +590,7 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { cWarning() << "Partition-module setting *defaultFileSystemType* is missing, will use ext4"; } - QString fsRealName = PartUtils::findFS( fsName, &fsType ); + QString fsRealName = PartUtils::canonicalFilesystemName( fsName, &fsType ); if ( fsRealName == fsName ) { cDebug() << o << "Partition-module setting *defaultFileSystemType*" << fsRealName; @@ -619,7 +618,7 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap ) // because it could take a while. Then when it's done, we can set up the widgets // and remove the spinner. m_future = new QFutureWatcher< void >(); - connect( m_future, &QFutureWatcher< void >::finished, this, [ this ] { + connect( m_future, &QFutureWatcher< void >::finished, this, [this] { continueLoading(); this->m_future->deleteLater(); this->m_future = nullptr; From 9fa5ab04e56a4253da7ef39e29e38ec2cc7d0cc7 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 18 Jun 2021 11:23:27 +0200 Subject: [PATCH 04/54] [partition] Apply coding style to core/ --- src/modules/partition/core/Config.cpp | 23 +++++++++++-------- src/modules/partition/core/Config.h | 4 ++-- src/modules/partition/core/DeviceList.cpp | 8 +++---- src/modules/partition/core/PartUtils.cpp | 13 ++++++++--- src/modules/partition/core/PartUtils.h | 2 +- .../partition/core/PartitionCoreModule.cpp | 3 +-- 6 files changed, 32 insertions(+), 21 deletions(-) diff --git a/src/modules/partition/core/Config.cpp b/src/modules/partition/core/Config.cpp index a603cedd0..47951321e 100644 --- a/src/modules/partition/core/Config.cpp +++ b/src/modules/partition/core/Config.cpp @@ -208,9 +208,10 @@ Config::setSwapChoice( Config::SwapChoice c ) } void -Config::setEraseFsTypeChoice(const QString& choice) +Config::setEraseFsTypeChoice( const QString& choice ) { - if(choice != m_eraseFsTypeChoice){ + if ( choice != m_eraseFsTypeChoice ) + { m_eraseFsTypeChoice = choice; } } @@ -249,14 +250,18 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) gs->insert( "allowManualPartitioning", CalamaresUtils::getBool( configurationMap, "allowManualPartitioning", true ) ); - if ( configurationMap.contains( "availableFileSystemTypes" ) ) { - if(configurationMap.value( "availableFileSystemTypes" ).type() == QVariant::List ){ + if ( configurationMap.contains( "availableFileSystemTypes" ) ) + { + if ( configurationMap.value( "availableFileSystemTypes" ).type() == QVariant::List ) + { m_eraseFsTypes.clear(); - m_eraseFsTypes.append(configurationMap.value( "availableFileSystemTypes" ).toStringList()); - m_eraseFsTypeChoice = m_eraseFsTypes[0]; - } else if ( configurationMap.value( "availableFileSystemTypes" ).type() == QVariant::String ){ - m_eraseFsTypes.append(configurationMap.value( "availableFileSystemTypes" ).toString()); - m_eraseFsTypeChoice = m_eraseFsTypes[0]; + m_eraseFsTypes.append( configurationMap.value( "availableFileSystemTypes" ).toStringList() ); + m_eraseFsTypeChoice = m_eraseFsTypes[ 0 ]; + } + else if ( configurationMap.value( "availableFileSystemTypes" ).type() == QVariant::String ) + { + m_eraseFsTypes.append( configurationMap.value( "availableFileSystemTypes" ).toString() ); + m_eraseFsTypeChoice = m_eraseFsTypes[ 0 ]; } } diff --git a/src/modules/partition/core/Config.h b/src/modules/partition/core/Config.h index 5cdd14c9d..a4f5e68f6 100644 --- a/src/modules/partition/core/Config.h +++ b/src/modules/partition/core/Config.h @@ -96,9 +96,9 @@ public: */ SwapChoice swapChoice() const { return m_swapChoice; } - EraseFsTypesSet eraseFsTypes() const {return m_eraseFsTypes; } + EraseFsTypesSet eraseFsTypes() const { return m_eraseFsTypes; } - QString eraseFsType() const {return m_eraseFsTypeChoice; } + QString eraseFsType() const { return m_eraseFsTypeChoice; } ///@brief Is manual partitioning allowed (not explicitly disnabled in the config file)? diff --git a/src/modules/partition/core/DeviceList.cpp b/src/modules/partition/core/DeviceList.cpp index d58b22868..6b770a982 100644 --- a/src/modules/partition/core/DeviceList.cpp +++ b/src/modules/partition/core/DeviceList.cpp @@ -10,8 +10,8 @@ #include "DeviceList.h" -#include "utils/Logger.h" #include "partition/PartitionIterator.h" +#include "utils/Logger.h" #include #include @@ -133,11 +133,11 @@ getDevices( DeviceType which ) #endif // Unsafe partitioning - auto removeInAllModes = []( DeviceList& l, DeviceList::iterator& it) { return erase(l, it); }; - auto removeInSafeMode = []( DeviceList&, DeviceList::iterator& it) { return ++it; }; + auto removeInAllModes = []( DeviceList& l, DeviceList::iterator& it ) { return erase( l, it ); }; + auto removeInSafeMode = []( DeviceList&, DeviceList::iterator& it ) { return ++it; }; #else // Safe partitioning - auto removeInAllModes = []( DeviceList& l, DeviceList::iterator& it) { return erase(l, it); }; + auto removeInAllModes = []( DeviceList& l, DeviceList::iterator& it ) { return erase( l, it ); }; auto& removeInSafeMode = removeInAllModes; #endif diff --git a/src/modules/partition/core/PartUtils.cpp b/src/modules/partition/core/PartUtils.cpp index 8d048b297..8bff2c95f 100644 --- a/src/modules/partition/core/PartUtils.cpp +++ b/src/modules/partition/core/PartUtils.cpp @@ -177,7 +177,8 @@ canBeResized( Partition* candidate, const Logger::Once& o ) if ( availableStorageB > advisedStorageB ) { - cDebug() << o << "Partition" << convenienceName( candidate ) << "authorized for resize + autopartition install."; + cDebug() << o << "Partition" << convenienceName( candidate ) + << "authorized for resize + autopartition install."; return true; } else @@ -412,8 +413,14 @@ runOsprober( DeviceModel* dm ) FstabEntryList fstabEntries = lookForFstabEntries( path ); QString homePath = findPartitionPathForMountPoint( fstabEntries, "/home" ); - osproberEntries.append( - { prettyName, path, file, QString(), canBeResized( dm, path, o ), lineColumns, fstabEntries, homePath } ); + osproberEntries.append( { prettyName, + path, + file, + QString(), + canBeResized( dm, path, o ), + lineColumns, + fstabEntries, + homePath } ); osproberCleanLines.append( line ); } } diff --git a/src/modules/partition/core/PartUtils.h b/src/modules/partition/core/PartUtils.h index 89d2c5e1a..5e84e379b 100644 --- a/src/modules/partition/core/PartUtils.h +++ b/src/modules/partition/core/PartUtils.h @@ -26,7 +26,7 @@ class DeviceModel; class Partition; namespace Logger { - class Once; +class Once; } namespace PartUtils diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp index c8b17b1cb..363d9daef 100644 --- a/src/modules/partition/core/PartitionCoreModule.cpp +++ b/src/modules/partition/core/PartitionCoreModule.cpp @@ -258,7 +258,7 @@ PartitionCoreModule::doInit() cDebug() << Logger::SubEntry << "node\tcapacity\tname\tprettyName"; for ( auto device : devices ) { - cDebug() << Logger::SubEntry << Logger::Pointer(device); + cDebug() << Logger::SubEntry << Logger::Pointer( device ); if ( device ) { // Gives ownership of the Device* to the DeviceInfo object @@ -390,7 +390,6 @@ PartitionCoreModule::createPartitionTable( Device* device, PartitionTable::Table OperationHelper helper( partitionModelForDevice( device ), this ); deviceInfo->makeJob< CreatePartitionTableJob >( type ); - } } From 4fa61249a83a4c0bb5a246bc016ad54cde3b66a2 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 18 Jun 2021 11:29:36 +0200 Subject: [PATCH 05/54] [partition] Make the fs type used for erase, a config property --- src/modules/partition/core/Config.cpp | 2 ++ src/modules/partition/core/Config.h | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/modules/partition/core/Config.cpp b/src/modules/partition/core/Config.cpp index 47951321e..cfe9458cc 100644 --- a/src/modules/partition/core/Config.cpp +++ b/src/modules/partition/core/Config.cpp @@ -212,7 +212,9 @@ Config::setEraseFsTypeChoice( const QString& choice ) { if ( choice != m_eraseFsTypeChoice ) { + // FIXME: shouldn't this be a canonical fs name? m_eraseFsTypeChoice = choice; + Q_EMIT eraseModeFilesystemChanged( choice ); } } diff --git a/src/modules/partition/core/Config.h b/src/modules/partition/core/Config.h index a4f5e68f6..8b420a8d0 100644 --- a/src/modules/partition/core/Config.h +++ b/src/modules/partition/core/Config.h @@ -24,6 +24,9 @@ class Config : public QObject ///@brief The swap choice (None, Small, Hibernate, ...) which only makes sense when Erase is chosen Q_PROPERTY( SwapChoice swapChoice READ swapChoice WRITE setSwapChoice NOTIFY swapChoiceChanged ) + ///@brief Name of the FS that will be used when erasing type disk (e.g. "default filesystem") + Q_PROPERTY( QString eraseModeFilesystem READ eraseFsType WRITE setEraseFsTypeChoice NOTIFY eraseModeFilesystemChanged ) + Q_PROPERTY( bool allowManualPartitioning READ allowManualPartitioning CONSTANT FINAL ) public: @@ -109,11 +112,12 @@ public Q_SLOTS: void setInstallChoice( InstallChoice ); void setSwapChoice( int ); ///< Translates a button ID or so to SwapChoice void setSwapChoice( SwapChoice ); - void setEraseFsTypeChoice( const QString& ); + void setEraseFsTypeChoice( const QString& filesystemName ); ///< See property eraseModeFilesystem Q_SIGNALS: void installChoiceChanged( InstallChoice ); void swapChoiceChanged( SwapChoice ); + void eraseModeFilesystemChanged( const QString& ); private: SwapChoiceSet m_swapChoices; From d8a862ec82d0fb96e6c9ca10ef6eb3f87385a9cc Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 18 Jun 2021 11:31:53 +0200 Subject: [PATCH 06/54] [partition] Use Q_EMIT --- src/modules/partition/core/Config.cpp | 4 ++-- src/modules/partition/core/DeviceModel.cpp | 2 +- src/modules/partition/core/PartitionCoreModule.cpp | 6 +++--- src/modules/partition/core/PartitionModel.cpp | 2 +- src/modules/partition/core/PartitionModel.h | 2 +- src/modules/partition/gui/ChoicePage.cpp | 14 +++++++------- src/modules/partition/gui/EncryptWidget.cpp | 2 +- .../partition/gui/PartitionSplitterWidget.cpp | 4 ++-- src/modules/partition/gui/PartitionViewStep.cpp | 2 +- src/modules/partition/gui/ReplaceWidget.cpp | 2 +- src/modules/partition/gui/ScanningDialog.cpp | 2 +- src/modules/partition/jobs/PartitionJob.cpp | 2 +- 12 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/modules/partition/core/Config.cpp b/src/modules/partition/core/Config.cpp index cfe9458cc..78296018a 100644 --- a/src/modules/partition/core/Config.cpp +++ b/src/modules/partition/core/Config.cpp @@ -180,7 +180,7 @@ Config::setInstallChoice( InstallChoice c ) if ( c != m_installChoice ) { m_installChoice = c; - emit installChoiceChanged( c ); + Q_EMIT installChoiceChanged( c ); ::updateGlobalStorage( c, m_swapChoice ); } } @@ -202,7 +202,7 @@ Config::setSwapChoice( Config::SwapChoice c ) if ( c != m_swapChoice ) { m_swapChoice = c; - emit swapChoiceChanged( c ); + Q_EMIT swapChoiceChanged( c ); ::updateGlobalStorage( m_installChoice, c ); } } diff --git a/src/modules/partition/core/DeviceModel.cpp b/src/modules/partition/core/DeviceModel.cpp index 46a181b33..33aae20c0 100644 --- a/src/modules/partition/core/DeviceModel.cpp +++ b/src/modules/partition/core/DeviceModel.cpp @@ -132,7 +132,7 @@ DeviceModel::swapDevice( Device* oldDevice, Device* newDevice ) m_devices[ indexOfOldDevice ] = newDevice; - emit dataChanged( index( indexOfOldDevice ), index( indexOfOldDevice ) ); + Q_EMIT dataChanged( index( indexOfOldDevice ), index( indexOfOldDevice ) ); } void diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp index 363d9daef..e2c91fbee 100644 --- a/src/modules/partition/core/PartitionCoreModule.cpp +++ b/src/modules/partition/core/PartitionCoreModule.cpp @@ -687,7 +687,7 @@ void PartitionCoreModule::refreshPartition( Device* device, Partition* ) { // Keep it simple for now: reset the model. This can be improved to cause - // the model to emit dataChanged() for the affected row instead, avoiding + // the model to Q_EMIT dataChanged() for the affected row instead, avoiding // the loss of the current selection. auto model = partitionModelForDevice( device ); Q_ASSERT( model ); @@ -966,7 +966,7 @@ PartitionCoreModule::revert() m_deviceInfos.clear(); doInit(); updateIsDirty(); - emit reverted(); + Q_EMIT reverted(); } @@ -1040,7 +1040,7 @@ PartitionCoreModule::revertDevice( Device* dev, bool individualRevert ) { refreshAfterModelChange(); } - emit deviceReverted( newDev ); + Q_EMIT deviceReverted( newDev ); } diff --git a/src/modules/partition/core/PartitionModel.cpp b/src/modules/partition/core/PartitionModel.cpp index b4ea57adb..e310eee5e 100644 --- a/src/modules/partition/core/PartitionModel.cpp +++ b/src/modules/partition/core/PartitionModel.cpp @@ -327,5 +327,5 @@ PartitionModel::partitionForIndex( const QModelIndex& index ) const void PartitionModel::update() { - emit dataChanged( index( 0, 0 ), index( rowCount() - 1, columnCount() - 1 ) ); + Q_EMIT dataChanged( index( 0, 0 ), index( rowCount() - 1, columnCount() - 1 ) ); } diff --git a/src/modules/partition/core/PartitionModel.h b/src/modules/partition/core/PartitionModel.h index 433fa0620..ba5e258a3 100644 --- a/src/modules/partition/core/PartitionModel.h +++ b/src/modules/partition/core/PartitionModel.h @@ -41,7 +41,7 @@ public: /** * This helper class must be instantiated on the stack *before* making * changes to the device represented by this model. It will cause the model - * to emit modelAboutToBeReset() when instantiated and modelReset() when + * to Q_EMIT modelAboutToBeReset() when instantiated and modelReset() when * destructed. */ class ResetHelper diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index 5ae62a87e..e6c7ea91f 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -300,7 +300,7 @@ ChoicePage::setupChoices() m_config->setInstallChoice( id ); updateNextEnabled(); - emit actionChosen(); + Q_EMIT actionChosen(); } else // An action was unpicked, either on its own or because of another selection. { @@ -310,7 +310,7 @@ ChoicePage::setupChoices() m_config->setInstallChoice( InstallChoice::NoChoice ); updateNextEnabled(); - emit actionChosen(); + Q_EMIT actionChosen(); } } } ); @@ -433,8 +433,8 @@ ChoicePage::continueApplyDeviceChoice() checkInstallChoiceRadioButton( m_config->installChoice() ); } - emit actionChosen(); - emit deviceChosen(); + Q_EMIT actionChosen(); + Q_EMIT deviceChosen(); } @@ -489,14 +489,14 @@ ChoicePage::applyActionChoice( InstallChoice choice ) } ), [=] { PartitionActions::doAutopartition( m_core, selectedDevice(), options ); - emit deviceChosen(); + Q_EMIT deviceChosen(); }, this ); } else { PartitionActions::doAutopartition( m_core, selectedDevice(), options ); - emit deviceChosen(); + Q_EMIT deviceChosen(); } } break; @@ -1599,7 +1599,7 @@ ChoicePage::updateNextEnabled() if ( enabled != m_nextEnabled ) { m_nextEnabled = enabled; - emit nextStatusChanged( enabled ); + Q_EMIT nextStatusChanged( enabled ); } } diff --git a/src/modules/partition/gui/EncryptWidget.cpp b/src/modules/partition/gui/EncryptWidget.cpp index 7f648491a..ee50e7d66 100644 --- a/src/modules/partition/gui/EncryptWidget.cpp +++ b/src/modules/partition/gui/EncryptWidget.cpp @@ -136,7 +136,7 @@ EncryptWidget::updateState() if ( newState != m_state ) { m_state = newState; - emit stateChanged( m_state ); + Q_EMIT stateChanged( m_state ); } } diff --git a/src/modules/partition/gui/PartitionSplitterWidget.cpp b/src/modules/partition/gui/PartitionSplitterWidget.cpp index 93c77bb69..0cafe7814 100644 --- a/src/modules/partition/gui/PartitionSplitterWidget.cpp +++ b/src/modules/partition/gui/PartitionSplitterWidget.cpp @@ -225,7 +225,7 @@ PartitionSplitterWidget::setSplitPartition( const QString& path, qint64 minSize, } } - emit partitionResized( m_itemToResize.itemPath, m_itemToResize.size, m_itemToResizeNext.size ); + Q_EMIT partitionResized( m_itemToResize.itemPath, m_itemToResize.size, m_itemToResizeNext.size ); cDebug() << "Items updated. Status:"; foreach ( const PartitionSplitterItem& item, m_items ) @@ -374,7 +374,7 @@ PartitionSplitterWidget::mouseMoveEvent( QMouseEvent* event ) repaint(); - emit partitionResized( itemPath, m_itemToResize.size, m_itemToResizeNext.size ); + Q_EMIT partitionResized( itemPath, m_itemToResize.size, m_itemToResizeNext.size ); } else { diff --git a/src/modules/partition/gui/PartitionViewStep.cpp b/src/modules/partition/gui/PartitionViewStep.cpp index 52bf1fc3b..cc06ba967 100644 --- a/src/modules/partition/gui/PartitionViewStep.cpp +++ b/src/modules/partition/gui/PartitionViewStep.cpp @@ -327,7 +327,7 @@ PartitionViewStep::isNextEnabled() const void PartitionViewStep::nextPossiblyChanged( bool ) { - emit nextStatusChanged( isNextEnabled() ); + Q_EMIT nextStatusChanged( isNextEnabled() ); } bool diff --git a/src/modules/partition/gui/ReplaceWidget.cpp b/src/modules/partition/gui/ReplaceWidget.cpp index 078eb4de7..94f527646 100644 --- a/src/modules/partition/gui/ReplaceWidget.cpp +++ b/src/modules/partition/gui/ReplaceWidget.cpp @@ -311,7 +311,7 @@ ReplaceWidget::setNextEnabled( bool enabled ) } m_nextEnabled = enabled; - emit nextStatusChanged( enabled ); + Q_EMIT nextStatusChanged( enabled ); } diff --git a/src/modules/partition/gui/ScanningDialog.cpp b/src/modules/partition/gui/ScanningDialog.cpp index cd22bb861..4dffa922b 100644 --- a/src/modules/partition/gui/ScanningDialog.cpp +++ b/src/modules/partition/gui/ScanningDialog.cpp @@ -68,5 +68,5 @@ void ScanningDialog::setVisible( bool visible ) { QDialog::setVisible( visible ); - emit visibilityChanged(); + Q_EMIT visibilityChanged(); } diff --git a/src/modules/partition/jobs/PartitionJob.cpp b/src/modules/partition/jobs/PartitionJob.cpp index 3bdb05ebd..ca9b00944 100644 --- a/src/modules/partition/jobs/PartitionJob.cpp +++ b/src/modules/partition/jobs/PartitionJob.cpp @@ -25,5 +25,5 @@ PartitionJob::iprogress( int percent ) { percent = 100; } - emit progress( qreal( percent / 100.0 ) ); + Q_EMIT progress( qreal( percent / 100.0 ) ); } From cd804470b57556f49e2484b9d54d49c33bca61dc Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 18 Jun 2021 11:51:33 +0200 Subject: [PATCH 07/54] [partition] Canonicalize the FS choice for erase --- src/modules/partition/core/Config.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/modules/partition/core/Config.cpp b/src/modules/partition/core/Config.cpp index 78296018a..b09f1424d 100644 --- a/src/modules/partition/core/Config.cpp +++ b/src/modules/partition/core/Config.cpp @@ -9,6 +9,8 @@ #include "Config.h" +#include "PartUtils.h" + #include "GlobalStorage.h" #include "JobQueue.h" #include "utils/Logger.h" @@ -210,11 +212,11 @@ Config::setSwapChoice( Config::SwapChoice c ) void Config::setEraseFsTypeChoice( const QString& choice ) { - if ( choice != m_eraseFsTypeChoice ) + QString canonicalChoice = PartUtils::canonicalFilesystemName( choice, nullptr ); + if ( canonicalChoice != m_eraseFsTypeChoice ) { - // FIXME: shouldn't this be a canonical fs name? - m_eraseFsTypeChoice = choice; - Q_EMIT eraseModeFilesystemChanged( choice ); + m_eraseFsTypeChoice = canonicalChoice; + Q_EMIT eraseModeFilesystemChanged( canonicalChoice ); } } From 26cabbb3e410e6dff1ab3c361df0013699be35ac Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 18 Jun 2021 12:18:04 +0200 Subject: [PATCH 08/54] [partition] refactor config-reading from availableFileSystemTypes --- src/modules/partition/core/Config.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/modules/partition/core/Config.cpp b/src/modules/partition/core/Config.cpp index b09f1424d..69dbe17d3 100644 --- a/src/modules/partition/core/Config.cpp +++ b/src/modules/partition/core/Config.cpp @@ -256,16 +256,22 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) if ( configurationMap.contains( "availableFileSystemTypes" ) ) { + QStringList fsTypes; + if ( configurationMap.value( "availableFileSystemTypes" ).type() == QVariant::List ) { - m_eraseFsTypes.clear(); - m_eraseFsTypes.append( configurationMap.value( "availableFileSystemTypes" ).toStringList() ); - m_eraseFsTypeChoice = m_eraseFsTypes[ 0 ]; + fsTypes = CalamaresUtils::getStringList( configurationMap, "availableFileSystemTypes" ); } else if ( configurationMap.value( "availableFileSystemTypes" ).type() == QVariant::String ) { - m_eraseFsTypes.append( configurationMap.value( "availableFileSystemTypes" ).toString() ); - m_eraseFsTypeChoice = m_eraseFsTypes[ 0 ]; + fsTypes = QStringList { CalamaresUtils::getString( configurationMap, "availableFileSystemTypes" ) }; + } + + m_eraseFsTypes = fsTypes; + if ( !fsTypes.empty() ) + { + m_eraseFsTypeChoice = m_eraseFsTypes.first(); + Q_EMIT eraseModeFilesystemChanged( m_eraseFsTypeChoice ); } } From 2a0d4e5a2356837633395d7a692b46e9e2df717d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 18 Jun 2021 12:35:15 +0200 Subject: [PATCH 09/54] [partition] Initialize pointers in declaration --- src/modules/partition/gui/ChoicePage.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/partition/gui/ChoicePage.h b/src/modules/partition/gui/ChoicePage.h index f43578ba5..30de05cb9 100644 --- a/src/modules/partition/gui/ChoicePage.h +++ b/src/modules/partition/gui/ChoicePage.h @@ -138,8 +138,8 @@ private: Calamares::PrettyRadioButton* m_eraseButton; Calamares::PrettyRadioButton* m_replaceButton; Calamares::PrettyRadioButton* m_somethingElseButton; - QComboBox* m_eraseSwapChoiceComboBox; // UI, see also m_eraseSwapChoice - QComboBox* m_eraseFsTypesChoiceComboBox; // UI, see also m_eraseSwapChoice + QComboBox* m_eraseSwapChoiceComboBox = nullptr; // UI, see also Config's swap choice + QComboBox* m_eraseFsTypesChoiceComboBox = nullptr; // UI, see also Config's erase-mode FS DeviceInfoWidget* m_deviceInfoWidget; From ef436ac4d73edf6c9346894ebfad7fe1ae29e135 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 18 Jun 2021 13:49:08 +0200 Subject: [PATCH 10/54] [libcalamares] add a convenience optional-setter for use with pointers --- src/libcalamares/utils/RAII.h | 17 ++++++++++++ src/libcalamares/utils/Tests.cpp | 45 ++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/src/libcalamares/utils/RAII.h b/src/libcalamares/utils/RAII.h index 1cbead4a2..f3adb90f6 100644 --- a/src/libcalamares/utils/RAII.h +++ b/src/libcalamares/utils/RAII.h @@ -14,6 +14,7 @@ #include #include +#include #include /** @brief Convenience to zero out and deleteLater of any QObject-derived-class @@ -58,4 +59,20 @@ struct cBoolSetter /// @brief Blocks signals on a QObject until destruction using cSignalBlocker = QSignalBlocker; +/** @brief Writes a value on destruction to a pointed-to location. + * + * If the pointer is non-null, write the last-given-value if there + * is one to the pointed-to object. + */ +template < typename T > +struct cPointerSetter +{ + std::optional< T > m_value; + T* m_pointer; + + cPointerSetter( T* p ) : m_pointer(p) {} + ~cPointerSetter() { if ( m_pointer && m_value.has_value() ) { *m_pointer = m_value.value(); } } + + const T& operator=(const T& v) { m_value = v; return v; } +}; #endif diff --git a/src/libcalamares/utils/Tests.cpp b/src/libcalamares/utils/Tests.cpp index cdb37f20d..7a6d52623 100644 --- a/src/libcalamares/utils/Tests.cpp +++ b/src/libcalamares/utils/Tests.cpp @@ -56,6 +56,7 @@ private Q_SLOTS: /** @brief Tests the RAII bits. */ void testBoolSetter(); + void testPointerSetter(); /** @brief Tests the Traits bits. */ void testTraits(); @@ -360,6 +361,50 @@ LibCalamaresTests::testBoolSetter() QVERIFY( b ); } +void +LibCalamaresTests::testPointerSetter() +{ + int special = 17; + + QCOMPARE( special, 17 ); + { + cPointerSetter p( &special ); + } + QCOMPARE( special, 17 ); + { + cPointerSetter p( &special ); + p = 18; + } + QCOMPARE( special, 18 ); + { + cPointerSetter p( &special ); + p = 20; + p = 3; + } + QCOMPARE( special, 3 ); + { + cPointerSetter p( nullptr ); + } + QCOMPARE( special, 3 ); + { + // "don't do this" .. order of destructors is important + cPointerSetter p( &special ); + cPointerSetter q( &special ); + p = 17; + } + QCOMPARE( special, 17 ); + { + // "don't do this" .. order of destructors is important + cPointerSetter p( &special ); + cPointerSetter q( &special ); + p = 34; + q = 2; + // q destroyed first, then p + } + QCOMPARE( special, 34 ); +} + + /* Demonstration of Traits support for has-a-method or not. * * We have two classes, c1 and c2; one has a method do_the_thing() and the From 7ce2a876448ea33b371ec379a3259a9f7f6d16da Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 18 Jun 2021 13:49:31 +0200 Subject: [PATCH 11/54] [partition] Fix build - fsName was a QString (a copy) so it could be modified; - the modification isn't really necessary. - While here, pick up new PointerSetter convenience class. --- src/modules/partition/core/PartUtils.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/modules/partition/core/PartUtils.cpp b/src/modules/partition/core/PartUtils.cpp index 8bff2c95f..2f269d37f 100644 --- a/src/modules/partition/core/PartUtils.cpp +++ b/src/modules/partition/core/PartUtils.cpp @@ -22,6 +22,7 @@ #include "partition/PartitionQuery.h" #include "utils/CalamaresUtilsSystem.h" #include "utils/Logger.h" +#include "utils/RAII.h" #include #include @@ -481,19 +482,17 @@ isEfiBootable( const Partition* candidate ) QString canonicalFilesystemName( const QString& fsName, FileSystem::Type* fsType ) { - QStringList fsLanguage { QLatin1String( "C" ) }; // Required language list to turn off localization + cPointerSetter type( fsType ); if ( fsName.isEmpty() ) { - fsName = QStringLiteral( "ext4" ); + type = FileSystem::Ext4; + return QStringLiteral( "ext4" ); } - FileSystem::Type tmpType = FileSystem::typeForName( fsName, fsLanguage ); - if ( tmpType != FileSystem::Unknown ) + QStringList fsLanguage { QLatin1String( "C" ) }; // Required language list to turn off localization + + if ( ( type = FileSystem::typeForName( fsName, fsLanguage ) ) != FileSystem::Unknown ) { - if ( fsType ) - { - *fsType = tmpType; - } return fsName; } @@ -513,7 +512,6 @@ canonicalFilesystemName( const QString& fsName, FileSystem::Type* fsType ) } cWarning() << "Filesystem" << fsName << "not found, using ext4"; - fsName = QStringLiteral( "ext4" ); // fsType can be used to check whether fsName was a valid filesystem. if ( fsType ) { @@ -533,7 +531,8 @@ canonicalFilesystemName( const QString& fsName, FileSystem::Type* fsType ) } } #endif - return fsName; + type = FileSystem::Unknown; + return QStringLiteral( "ext4" ); } } // namespace PartUtils From fb7e6101ffd47e89618effd715d078bec5157c9e Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 18 Jun 2021 13:53:47 +0200 Subject: [PATCH 12/54] [partition] Hook erase-fs-type changes to the config-object --- src/modules/partition/gui/ChoicePage.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index e6c7ea91f..0c86fd718 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -272,7 +272,8 @@ ChoicePage::setupChoices() { m_eraseFsTypesChoiceComboBox = new QComboBox; m_eraseFsTypesChoiceComboBox->addItems(m_config->eraseFsTypes()); - connect(m_eraseFsTypesChoiceComboBox, &QComboBox::currentTextChanged, [this](const auto& currentString){m_config->setEraseFsTypeChoice(currentString); onActionChanged();}); + connect( m_eraseFsTypesChoiceComboBox, &QComboBox::currentTextChanged, m_config, &Config::setEraseFsTypeChoice ); + connect( m_config, &Config::eraseModeFilesystemChanged, this, &ChoicePage::onActionChanged ); m_eraseButton->addOptionsComboBox( m_eraseFsTypesChoiceComboBox ); } From bf7eed934235eb0d67a9024d4384437a6525b993 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 18 Jun 2021 15:50:13 +0200 Subject: [PATCH 13/54] [partition] Tidy debug output when creating table --- src/modules/partition/jobs/CreatePartitionTableJob.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/partition/jobs/CreatePartitionTableJob.cpp b/src/modules/partition/jobs/CreatePartitionTableJob.cpp index 0913a1cfc..76c0ab9ee 100644 --- a/src/modules/partition/jobs/CreatePartitionTableJob.cpp +++ b/src/modules/partition/jobs/CreatePartitionTableJob.cpp @@ -75,13 +75,13 @@ CreatePartitionTableJob::exec() QString message = tr( "The installer failed to create a partition table on %1." ).arg( m_device->name() ); PartitionTable* table = m_device->partitionTable(); - cDebug() << "Creating new partition table of type" << table->typeName() << ", uncommitted yet:"; if ( Logger::logLevelEnabled( Logger::LOGDEBUG ) ) { + cDebug() << "Creating new partition table of type" << table->typeName() << ", uncommitted partitions:"; for ( auto it = PartitionIterator::begin( table ); it != PartitionIterator::end( table ); ++it ) { - cDebug() << it; + cDebug() << Logger::SubEntry << it; } QProcess lsblk; @@ -89,14 +89,14 @@ CreatePartitionTableJob::exec() lsblk.setProcessChannelMode( QProcess::MergedChannels ); lsblk.start(); lsblk.waitForFinished(); - cDebug() << "lsblk:\n" << lsblk.readAllStandardOutput(); + cDebug() << Logger::SubEntry << "lsblk output:\n" << Logger::NoQuote << lsblk.readAllStandardOutput(); QProcess mount; mount.setProgram( "mount" ); // Debug output only, not mounting something mount.setProcessChannelMode( QProcess::MergedChannels ); mount.start(); mount.waitForFinished(); - cDebug() << "mount:\n" << mount.readAllStandardOutput(); + cDebug() << Logger::SubEntry << "mount output:\n" << Logger::NoQuote << mount.readAllStandardOutput(); } CreatePartitionTableOperation op( *m_device, table ); From 17cc0470da1f8e64c411b4b82f78aa66b582b695 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 18 Jun 2021 15:54:51 +0200 Subject: [PATCH 14/54] [partition] Log names of partition flags, not just a number --- src/modules/partition/jobs/SetPartitionFlagsJob.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/partition/jobs/SetPartitionFlagsJob.cpp b/src/modules/partition/jobs/SetPartitionFlagsJob.cpp index 7b6101241..de77d86f8 100644 --- a/src/modules/partition/jobs/SetPartitionFlagsJob.cpp +++ b/src/modules/partition/jobs/SetPartitionFlagsJob.cpp @@ -144,8 +144,9 @@ SetPartFlagsJob::prettyStatusMessage() const Calamares::JobResult SetPartFlagsJob::exec() { - cDebug() << "Setting flags on" << m_device->deviceNode() << "partition" << partition()->deviceNode() << "to" - << m_flags; + QStringList flagsList = PartitionTable::flagNames( m_flags ); + cDebug() << "Setting flags on" << m_device->deviceNode() << "partition" << partition()->deviceNode() + << Logger::DebugList( flagsList ); Report report( nullptr ); SetPartFlagsOperation op( *m_device, *partition(), m_flags ); From 66f96e339ca9e00498e1fed79af4e0403abeec4d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 18 Jun 2021 16:01:04 +0200 Subject: [PATCH 15/54] [libcalamares] Introduce cVerbose() convenience macro (like cDebug()) --- src/libcalamares/utils/Logger.h | 1 + src/modules/partition/jobs/AutoMountManagementJob.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libcalamares/utils/Logger.h b/src/libcalamares/utils/Logger.h index fb49248e1..8ef0edaf9 100644 --- a/src/libcalamares/utils/Logger.h +++ b/src/libcalamares/utils/Logger.h @@ -327,6 +327,7 @@ operator<<( CDebug&& s, const Once& o ) } // namespace Logger +#define cVerbose() Logger::CDebug( Logger::LOGVERBOSE, Q_FUNC_INFO ) #define cDebug() Logger::CDebug( Logger::LOGDEBUG, Q_FUNC_INFO ) #define cWarning() Logger::CDebug( Logger::LOGWARNING, Q_FUNC_INFO ) #define cError() Logger::CDebug( Logger::LOGERROR, Q_FUNC_INFO ) diff --git a/src/modules/partition/jobs/AutoMountManagementJob.cpp b/src/modules/partition/jobs/AutoMountManagementJob.cpp index 9472eae9c..e276447db 100644 --- a/src/modules/partition/jobs/AutoMountManagementJob.cpp +++ b/src/modules/partition/jobs/AutoMountManagementJob.cpp @@ -25,8 +25,8 @@ AutoMountManagementJob::prettyName() const Calamares::JobResult AutoMountManagementJob::exec() { - Logger::CDebug( Logger::LOGVERBOSE ) << "this" << Logger::Pointer( this ) << "value" << Logger::Pointer( m_stored ) - << ( m_stored ? "restore" : m_disable ? "disable" : "enable" ); + cVerbose() << "this" << Logger::Pointer( this ) << "value" << Logger::Pointer( m_stored ) + << ( m_stored ? "restore" : m_disable ? "disable" : "enable" ); if ( m_stored ) { CalamaresUtils::Partition::automountRestore( m_stored ); From 432154e50ac8d51598a2d6507b097f18468892e0 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 18 Jun 2021 16:10:13 +0200 Subject: [PATCH 16/54] [libcalamares] Improve Once-logging Sending a Once to a logger that isn't enabled should not "consume" that Once; it's still available for a subsequent logger that **is** enabled (useful if you're using more than one log-level in a function). --- src/libcalamares/utils/Logger.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libcalamares/utils/Logger.h b/src/libcalamares/utils/Logger.h index 8ef0edaf9..871cc6fb3 100644 --- a/src/libcalamares/utils/Logger.h +++ b/src/libcalamares/utils/Logger.h @@ -60,6 +60,8 @@ public: friend CDebug& operator<<( CDebug&&, const FuncSuppressor& ); friend CDebug& operator<<( CDebug&&, const Once& ); + inline unsigned int level() const { return m_debugLevel; } + private: QString m_msg; unsigned int m_debugLevel; @@ -315,6 +317,12 @@ private: inline CDebug& operator<<( CDebug&& s, const Once& o ) { + if ( !logLevelEnabled( s.level() ) ) + { + // This won't print, so it's not using the "onceness" + return s; + } + if ( o.m ) { o.m = false; From 7deb6c0e9efdd7241fb0ec77d5fd38d52aadf5f8 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 18 Jun 2021 16:18:06 +0200 Subject: [PATCH 17/54] [partition] Improve logging in clearmounts job --- .../partition/jobs/ClearTempMountsJob.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/modules/partition/jobs/ClearTempMountsJob.cpp b/src/modules/partition/jobs/ClearTempMountsJob.cpp index 2f90278fe..ffbc35044 100644 --- a/src/modules/partition/jobs/ClearTempMountsJob.cpp +++ b/src/modules/partition/jobs/ClearTempMountsJob.cpp @@ -43,6 +43,7 @@ ClearTempMountsJob::prettyStatusMessage() const Calamares::JobResult ClearTempMountsJob::exec() { + Logger::Once o; // Fetch a list of current mounts to Calamares temporary directories. QList< QPair< QString, QString > > lst; QFile mtab( "/etc/mtab" ); @@ -51,23 +52,27 @@ ClearTempMountsJob::exec() return Calamares::JobResult::error( tr( "Cannot get list of temporary mounts." ) ); } - cDebug() << "Opened mtab. Lines:"; + cVerbose() << o << "Opened mtab. Lines:"; QTextStream in( &mtab ); QString lineIn = in.readLine(); while ( !lineIn.isNull() ) { QStringList line = lineIn.split( ' ', SplitSkipEmptyParts ); - cDebug() << line.join( ' ' ); + cVerbose() << o << line.join( ' ' ); QString device = line.at( 0 ); QString mountPoint = line.at( 1 ); if ( mountPoint.startsWith( "/tmp/calamares-" ) ) { - cDebug() << "INSERTING pair (device, mountPoint)" << device << mountPoint; lst.append( qMakePair( device, mountPoint ) ); } lineIn = in.readLine(); } + if ( lst.empty() ) + { + return Calamares::JobResult::ok(); + } + std::sort( lst.begin(), lst.end(), []( const QPair< QString, QString >& a, const QPair< QString, QString >& b ) -> bool { return a.first > b.first; @@ -76,10 +81,10 @@ ClearTempMountsJob::exec() QStringList goodNews; QProcess process; - foreach ( auto line, lst ) + for ( const auto& line : qAsConst( lst ) ) { QString partPath = line.second; - cDebug() << "Will try to umount path" << partPath; + cDebug() << o << "Will try to umount path" << partPath; process.start( "umount", { "-lv", partPath } ); process.waitForFinished(); if ( process.exitCode() == 0 ) @@ -92,7 +97,7 @@ ClearTempMountsJob::exec() ok.setMessage( tr( "Cleared all temporary mounts." ) ); ok.setDetails( goodNews.join( "\n" ) ); - cDebug() << "ClearTempMountsJob finished. Here's what was done:\n" << goodNews.join( "\n" ); + cDebug() << o << "ClearTempMountsJob finished. Here's what was done:\n" << Logger::DebugList( goodNews ); return ok; } From 6936915dd641e4f6cf4f8a3bd13134f0da8262ae Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 18 Jun 2021 17:41:22 +0200 Subject: [PATCH 18/54] [partition] Fix logging (type of debug stream changed) --- src/modules/partition/jobs/CreatePartitionTableJob.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/modules/partition/jobs/CreatePartitionTableJob.cpp b/src/modules/partition/jobs/CreatePartitionTableJob.cpp index 76c0ab9ee..118ec8823 100644 --- a/src/modules/partition/jobs/CreatePartitionTableJob.cpp +++ b/src/modules/partition/jobs/CreatePartitionTableJob.cpp @@ -60,14 +60,6 @@ CreatePartitionTableJob::prettyStatusMessage() const } -static inline QDebug& -operator<<( QDebug&& s, PartitionIterator& it ) -{ - s << ( ( *it ) ? ( *it )->deviceNode() : QString( "" ) ); - return s; -} - - Calamares::JobResult CreatePartitionTableJob::exec() { @@ -81,7 +73,7 @@ CreatePartitionTableJob::exec() cDebug() << "Creating new partition table of type" << table->typeName() << ", uncommitted partitions:"; for ( auto it = PartitionIterator::begin( table ); it != PartitionIterator::end( table ); ++it ) { - cDebug() << Logger::SubEntry << it; + cDebug() << Logger::SubEntry << ( ( *it ) ? ( *it )->deviceNode() : QString( "" ) ); } QProcess lsblk; From 60f8a7c5fb276cac4b9c802f5d3fcedb54e56668 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 18 Jun 2021 22:20:11 +0200 Subject: [PATCH 19/54] [partition] Don't offer /boot if EFI wants something else - Don't leave /boot in the list always; EFI might be configured for /boot/efi on this system - While here, apply coding style. --- src/modules/partition/gui/PartitionDialogHelpers.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/modules/partition/gui/PartitionDialogHelpers.cpp b/src/modules/partition/gui/PartitionDialogHelpers.cpp index c5c35279d..0d25c3c8d 100644 --- a/src/modules/partition/gui/PartitionDialogHelpers.cpp +++ b/src/modules/partition/gui/PartitionDialogHelpers.cpp @@ -23,11 +23,15 @@ QStringList standardMountPoints() { - QStringList mountPoints { "/", "/boot", "/home", "/opt", "/srv", "/usr", "/var" }; + QStringList mountPoints { "/", "/home", "/opt", "/srv", "/usr", "/var" }; if ( PartUtils::isEfiSystem() ) { mountPoints << Calamares::JobQueue::instance()->globalStorage()->value( "efiSystemPartition" ).toString(); } + else + { + mountPoints << QStringLiteral( "/boot" ); + } mountPoints.removeDuplicates(); mountPoints.sort(); return mountPoints; @@ -68,11 +72,13 @@ setSelectedMountPoint( QComboBox& combo, const QString& selected ) else { for ( int i = 0; i < combo.count(); ++i ) + { if ( selected == combo.itemText( i ) ) { combo.setCurrentIndex( i ); return; } + } combo.addItem( selected ); combo.setCurrentIndex( combo.count() - 1 ); } @@ -85,10 +91,12 @@ flagsFromList( const QListWidget& list ) PartitionTable::Flags flags; for ( int i = 0; i < list.count(); i++ ) + { if ( list.item( i )->checkState() == Qt::Checked ) { flags |= static_cast< PartitionTable::Flag >( list.item( i )->data( Qt::UserRole ).toInt() ); } + } return flags; } From 54e66ff1c0577bf36ee2b1336c73b3dbf4de1a31 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 21 Jun 2021 10:09:44 +0200 Subject: [PATCH 20/54] [calamares] Python pre-script only if Python is enabled If Python support isn't enabled, you can include the PythonJob header, but the symbols aren't in libcalamares so fails at link time. FIXES #1729 --- src/calamares/testmain.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/calamares/testmain.cpp b/src/calamares/testmain.cpp index 6dae0af68..250b047eb 100644 --- a/src/calamares/testmain.cpp +++ b/src/calamares/testmain.cpp @@ -18,18 +18,25 @@ #include "GlobalStorage.h" #include "Job.h" #include "JobQueue.h" -#include "PythonJob.h" #include "Settings.h" #include "ViewManager.h" #include "modulesystem/Module.h" #include "modulesystem/ModuleManager.h" #include "modulesystem/ViewModule.h" #include "utils/Logger.h" +#include "utils/Yaml.h" +#include "viewpages/ExecutionViewStep.h" + +// Optional features of Calamares +// - Python support +// - QML support +#ifdef WITH_PYTHON +#include "PythonJob.h" +#endif #ifdef WITH_QML #include "utils/Qml.h" #endif -#include "utils/Yaml.h" -#include "viewpages/ExecutionViewStep.h" + #include #include @@ -366,10 +373,15 @@ createApplication( int& argc, char* argv[] ) return new QCoreApplication( argc, argv ); } +#ifdef WITH_PYTHON static const char pythonPreScript[] = R"( # This is Python code executed by Python modules *before* the # script file (e.g. main.py) is executed. Beware " before ) # because it's a C++ raw-string. +# +# Calls to suprocess methods that execute something are +# suppressed and logged -- scripts should really be using libcalamares +# methods instead. _calamares_subprocess = __import__("subprocess", globals(), locals(), [], 0) import sys import libcalamares @@ -386,6 +398,7 @@ sys.modules["subprocess"] = fake_subprocess libcalamares.utils.debug('pre-script for testing purposes injected') )"; +#endif int main( int argc, char* argv[] ) @@ -416,10 +429,12 @@ main( int argc, char* argv[] ) gs->insert( "localeConf", vm ); } +#ifdef WITH_PYTHON + Calamares::PythonJob::setInjectedPreScript(pythonPreScript); +#endif #ifdef WITH_QML CalamaresUtils::initQmlModulesDir(); // don't care if failed #endif - Calamares::PythonJob::setInjectedPreScript(pythonPreScript); cDebug() << "Calamares module-loader testing" << module.moduleName(); Calamares::Module* m = load_module( module ); From acb731d8237ce638decaa32514215b2c05048d0a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 21 Jun 2021 22:21:06 +0200 Subject: [PATCH 21/54] [libcalamaresui] Provide the logFile path This is intended for consumption by QML; the ViewManager object acts as a proxy for a handful of global Settings values already, so throw in global Logger values as well. A QML module that would like to read the log file (e.g. for tailing it as part of a slide-show) can get the path via this property. --- src/libcalamaresui/ViewManager.cpp | 6 ++++++ src/libcalamaresui/ViewManager.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index c55b5dd67..f6edbfc2a 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -613,4 +613,10 @@ ViewManager::isSetupMode() const return s ? s->isSetupMode() : false; } +QString +ViewManager::logFilePath() const +{ + return Logger::logFile(); +} + } // namespace Calamares diff --git a/src/libcalamaresui/ViewManager.h b/src/libcalamaresui/ViewManager.h index 9a77cbb5a..5a449a153 100644 --- a/src/libcalamaresui/ViewManager.h +++ b/src/libcalamaresui/ViewManager.h @@ -54,6 +54,7 @@ class UIDLLEXPORT ViewManager : public QAbstractListModel Q_PROPERTY( bool isDebugMode READ isDebugMode CONSTANT FINAL ) Q_PROPERTY( bool isChrootMode READ isChrootMode CONSTANT FINAL ) Q_PROPERTY( bool isSetupMode READ isSetupMode CONSTANT FINAL ) + Q_PROPERTY( QString logFilePath READ logFilePath CONSTANT FINAL ) public: /** @@ -208,6 +209,8 @@ public Q_SLOTS: bool isChrootMode() const; /// @brief Proxy to Settings::isSetupMode() default @c false bool isSetupMode() const; + /// @brief Proxy to Logger::logFile(), default empty + QString logFilePath() const; signals: void currentStepChanged(); From f06766085ab0d52e00e8f75bdfda288880501201 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 21 Jun 2021 23:20:32 +0200 Subject: [PATCH 22/54] [partition] Rename function, to track down consumers --- src/modules/partition/gui/CreatePartitionDialog.cpp | 2 +- src/modules/partition/gui/CreatePartitionDialog.h | 2 +- src/modules/partition/gui/PartitionPage.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/partition/gui/CreatePartitionDialog.cpp b/src/modules/partition/gui/CreatePartitionDialog.cpp index c765bf1f7..e7aab89cd 100644 --- a/src/modules/partition/gui/CreatePartitionDialog.cpp +++ b/src/modules/partition/gui/CreatePartitionDialog.cpp @@ -188,7 +188,7 @@ CreatePartitionDialog::initGptPartitionTypeUi() } Partition* -CreatePartitionDialog::createPartition() +CreatePartitionDialog::getNewlyCreatedPartition() { if ( m_role.roles() == PartitionRole::None ) { diff --git a/src/modules/partition/gui/CreatePartitionDialog.h b/src/modules/partition/gui/CreatePartitionDialog.h index bee70f61b..45e3f7cf4 100644 --- a/src/modules/partition/gui/CreatePartitionDialog.h +++ b/src/modules/partition/gui/CreatePartitionDialog.h @@ -57,7 +57,7 @@ public: * Must be called when user wants to edit a to-be-created partition. */ void initFromPartitionToCreate( Partition* partition ); - Partition* createPartition(); + Partition* getNewlyCreatedPartition(); PartitionTable::Flags newFlags() const; diff --git a/src/modules/partition/gui/PartitionPage.cpp b/src/modules/partition/gui/PartitionPage.cpp index f5a3b0f43..d9ff65f88 100644 --- a/src/modules/partition/gui/PartitionPage.cpp +++ b/src/modules/partition/gui/PartitionPage.cpp @@ -395,7 +395,7 @@ PartitionPage::onCreateClicked() dlg.initFromFreeSpace( partition ); if ( dlg.exec() == QDialog::Accepted ) { - Partition* newPart = dlg.createPartition(); + Partition* newPart = dlg.getNewlyCreatedPartition(); m_core->createPartition( model->device(), newPart, dlg.newFlags() ); } } @@ -496,7 +496,7 @@ PartitionPage::updatePartitionToCreate( Device* device, Partition* partition ) dlg->initFromPartitionToCreate( partition ); if ( dlg->exec() == QDialog::Accepted ) { - Partition* newPartition = dlg->createPartition(); + Partition* newPartition = dlg->getNewlyCreatedPartition(); m_core->deletePartition( device, partition ); m_core->createPartition( device, newPartition, dlg->newFlags() ); } From dbfd8bea030b9513a8f088723de5f0c9f1c37e01 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 21 Jun 2021 23:22:40 +0200 Subject: [PATCH 23/54] [partition] Newly-created (fresh) partitions don't have flags yet When a partition is set as "freshly created", the dialog was passing in newFlags() as the **already-active** flags on the partition; then the caller was setting those same flags as "set these in the future", so that afterwards, no flags would actually be set (because they're already active -- see the first sentence). Now, fresh partitions have no flags. --- src/modules/partition/gui/CreatePartitionDialog.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/modules/partition/gui/CreatePartitionDialog.cpp b/src/modules/partition/gui/CreatePartitionDialog.cpp index e7aab89cd..37547ef8c 100644 --- a/src/modules/partition/gui/CreatePartitionDialog.cpp +++ b/src/modules/partition/gui/CreatePartitionDialog.cpp @@ -204,17 +204,21 @@ CreatePartitionDialog::getNewlyCreatedPartition() : FileSystem::typeForName( m_ui->fsComboBox->currentText() ); const QString fsLabel = m_ui->filesystemLabelEdit->text(); + // The newly-created partitions have no flags set (no **active** flags), + // because they're new. The desired flags can be retrieved from + // newFlags() and the consumer (see PartitionPage::onCreateClicked) + // does so, to set up the partition for create-and-then-set-flags. Partition* partition = nullptr; QString luksPassphrase = m_ui->encryptWidget->passphrase(); if ( m_ui->encryptWidget->state() == EncryptWidget::Encryption::Confirmed && !luksPassphrase.isEmpty() ) { partition = KPMHelpers::createNewEncryptedPartition( - m_parent, *m_device, m_role, fsType, fsLabel, first, last, luksPassphrase, newFlags() ); + m_parent, *m_device, m_role, fsType, fsLabel, first, last, luksPassphrase, PartitionTable::Flags() ); } else { partition - = KPMHelpers::createNewPartition( m_parent, *m_device, m_role, fsType, fsLabel, first, last, newFlags() ); + = KPMHelpers::createNewPartition( m_parent, *m_device, m_role, fsType, fsLabel, first, last, PartitionTable::Flags() ); } if ( m_device->type() == Device::Type::LVM_Device ) From e2bf717ea0c9f820c7cb6d08ebc409bec70e9295 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 22 Jun 2021 00:06:17 +0200 Subject: [PATCH 24/54] [partition] Rewrite new-partition API The existing API required calling the one constructor with specific pointers (nullptr for a partition-from-free-space) followed by calling one of the initFrom*() functions. This is fragile design. Use tag-classes to distinguish create-from-free-space and edit-another-freshly-created-partition cases, refactor to merge the initFrom*() methods into the constructors and factor out the shared UI creation. Callers can now use the tag-class to distinguish. While here, adjust both callers to use QPointer, avoiding some very specific dialog-on-the-stack crash possibilities. --- .../partition/gui/CreatePartitionDialog.cpp | 76 +++++++++---------- .../partition/gui/CreatePartitionDialog.h | 45 ++++++----- src/modules/partition/gui/PartitionPage.cpp | 14 ++-- 3 files changed, 73 insertions(+), 62 deletions(-) diff --git a/src/modules/partition/gui/CreatePartitionDialog.cpp b/src/modules/partition/gui/CreatePartitionDialog.cpp index 37547ef8c..c09724463 100644 --- a/src/modules/partition/gui/CreatePartitionDialog.cpp +++ b/src/modules/partition/gui/CreatePartitionDialog.cpp @@ -52,7 +52,6 @@ static QSet< FileSystem::Type > s_unmountableFS( { FileSystem::Unformatted, CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* parentPartition, - Partition* partition, const QStringList& usedMountPoints, QWidget* parentWidget ) : QDialog( parentWidget ) @@ -81,9 +80,6 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, m_ui->lvNameLineEdit->setValidator( validator ); } - standardMountPoints( *( m_ui->mountPointComboBox ), - partition ? PartitionInfo::mountPoint( partition ) : QString() ); - if ( device->partitionTable()->type() == PartitionTable::msdos || device->partitionTable()->type() == PartitionTable::msdos_sectorbased ) { @@ -132,13 +128,48 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, // Select a default m_ui->fsComboBox->setCurrentIndex( defaultFsIndex ); updateMountPointUi(); + checkMountPointSelection(); +} +CreatePartitionDialog::CreatePartitionDialog( Device* device, + const FreeSpace& freeSpacePartition, + const QStringList& usedMountPoints, + QWidget* parentWidget ) + : CreatePartitionDialog(device, freeSpacePartition.p->parent(), usedMountPoints, parentWidget ) +{ + standardMountPoints( *( m_ui->mountPointComboBox ), QString() ); setFlagList( *( m_ui->m_listFlags ), static_cast< PartitionTable::Flags >( ~PartitionTable::Flags::Int( 0 ) ), - partition ? PartitionInfo::flags( partition ) : PartitionTable::Flags() ); + PartitionTable::Flags() ); + initPartResizerWidget( freeSpacePartition.p ); +} - // Checks the initial selection. - checkMountPointSelection(); +CreatePartitionDialog::CreatePartitionDialog( Device* device, + const FreshPartition& existingNewPartition, + const QStringList& usedMountPoints, + QWidget* parentWidget ) + : CreatePartitionDialog(device, existingNewPartition.p->parent(), usedMountPoints, parentWidget ) +{ + standardMountPoints( *( m_ui->mountPointComboBox ), + PartitionInfo::mountPoint( existingNewPartition.p ) ); + setFlagList( *( m_ui->m_listFlags ), + static_cast< PartitionTable::Flags >( ~PartitionTable::Flags::Int( 0 ) ), + PartitionInfo::flags( existingNewPartition.p ) ); + + const bool isExtended = existingNewPartition.p->roles().has( PartitionRole::Extended ); + if ( isExtended ) + { + cDebug() << "Editing extended partitions is not supported."; + return; + } + + initPartResizerWidget( existingNewPartition.p ); + + FileSystem::Type fsType = existingNewPartition.p->fileSystem().type(); + m_ui->fsComboBox->setCurrentText( FileSystem::nameForType( fsType ) ); + + setSelectedMountPoint( m_ui->mountPointComboBox, PartitionInfo::mountPoint( existingNewPartition.p ) ); + updateMountPointUi(); } CreatePartitionDialog::~CreatePartitionDialog() {} @@ -288,34 +319,3 @@ CreatePartitionDialog::initPartResizerWidget( Partition* partition ) m_partitionSizeController->setPartResizerWidget( m_ui->partResizerWidget ); m_partitionSizeController->setSpinBox( m_ui->sizeSpinBox ); } - -void -CreatePartitionDialog::initFromFreeSpace( Partition* freeSpacePartition ) -{ - initPartResizerWidget( freeSpacePartition ); -} - -void -CreatePartitionDialog::initFromPartitionToCreate( Partition* partition ) -{ - Q_ASSERT( partition ); - - bool isExtended = partition->roles().has( PartitionRole::Extended ); - Q_ASSERT( !isExtended ); - if ( isExtended ) - { - cDebug() << "Editing extended partitions is not supported for now"; - return; - } - - initPartResizerWidget( partition ); - - // File System - FileSystem::Type fsType = partition->fileSystem().type(); - m_ui->fsComboBox->setCurrentText( FileSystem::nameForType( fsType ) ); - - // Mount point - setSelectedMountPoint( m_ui->mountPointComboBox, PartitionInfo::mountPoint( partition ) ); - - updateMountPointUi(); -} diff --git a/src/modules/partition/gui/CreatePartitionDialog.h b/src/modules/partition/gui/CreatePartitionDialog.h index 45e3f7cf4..e18840564 100644 --- a/src/modules/partition/gui/CreatePartitionDialog.h +++ b/src/modules/partition/gui/CreatePartitionDialog.h @@ -33,30 +33,41 @@ class Ui_CreatePartitionDialog; class CreatePartitionDialog : public QDialog { Q_OBJECT -public: - /** - * @brief Dialog for editing a new partition. + +private: + /** @brief Delegated constructor * - * For the (unlikely) case that a newly created partition is being re-edited, - * pass a pointer to that @p partition, otherwise pass nullptr. + * This does all the shared UI setup. */ CreatePartitionDialog( Device* device, - PartitionNode* parentPartition, - Partition* partition, + PartitionNode* parentPartition, + const QStringList& usedMountPoints, + QWidget* parentWidget ); + +public: + struct FreeSpace { Partition* p; }; + struct FreshPartition { Partition* p; }; + + /** @brief Dialog for editing a new partition based on free space. + * + * Creating from free space makes a wholly new partition with + * no flags set at all. + */ + CreatePartitionDialog( Device* device, + const FreeSpace& freeSpacePartition, + const QStringList& usedMountPoints, + QWidget* parentWidget = nullptr ); + /** @brief Dialog for editing a newly-created partition. + * + * A partition previously newly created (e.g. via this dialog + * and the constructor above) can be re-edited. + */ + CreatePartitionDialog( Device* device, + const FreshPartition& existingNewPartition, const QStringList& usedMountPoints, QWidget* parentWidget = nullptr ); ~CreatePartitionDialog() override; - /** - * Must be called when user wants to create a partition in - * freeSpacePartition. - */ - void initFromFreeSpace( Partition* freeSpacePartition ); - - /** - * Must be called when user wants to edit a to-be-created partition. - */ - void initFromPartitionToCreate( Partition* partition ); Partition* getNewlyCreatedPartition(); PartitionTable::Flags newFlags() const; diff --git a/src/modules/partition/gui/PartitionPage.cpp b/src/modules/partition/gui/PartitionPage.cpp index d9ff65f88..06aa7b1a8 100644 --- a/src/modules/partition/gui/PartitionPage.cpp +++ b/src/modules/partition/gui/PartitionPage.cpp @@ -391,13 +391,14 @@ PartitionPage::onCreateClicked() return; } - CreatePartitionDialog dlg( model->device(), partition->parent(), nullptr, getCurrentUsedMountpoints(), this ); - dlg.initFromFreeSpace( partition ); - if ( dlg.exec() == QDialog::Accepted ) + QPointer< CreatePartitionDialog > dlg = new + CreatePartitionDialog ( model->device(), CreatePartitionDialog::FreeSpace{ partition }, getCurrentUsedMountpoints(), this ); + if ( dlg->exec() == QDialog::Accepted ) { - Partition* newPart = dlg.getNewlyCreatedPartition(); - m_core->createPartition( model->device(), newPart, dlg.newFlags() ); + Partition* newPart = dlg->getNewlyCreatedPartition(); + m_core->createPartition( model->device(), newPart, dlg->newFlags() ); } + delete dlg; } void @@ -492,8 +493,7 @@ PartitionPage::updatePartitionToCreate( Device* device, Partition* partition ) mountPoints.removeOne( PartitionInfo::mountPoint( partition ) ); QPointer< CreatePartitionDialog > dlg - = new CreatePartitionDialog( device, partition->parent(), partition, mountPoints, this ); - dlg->initFromPartitionToCreate( partition ); + = new CreatePartitionDialog( device, CreatePartitionDialog::FreshPartition{ partition }, mountPoints, this ); if ( dlg->exec() == QDialog::Accepted ) { Partition* newPartition = dlg->getNewlyCreatedPartition(); From 131352ca03884dc8c0ace700b5dc41534e35affc Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 22 Jun 2021 00:21:01 +0200 Subject: [PATCH 25/54] [partition] Apply coding style --- src/modules/partition/core/DeviceList.cpp | 8 ++++---- src/modules/partition/core/PartUtils.cpp | 13 ++++++++++--- src/modules/partition/core/PartUtils.h | 2 +- .../partition/core/PartitionCoreModule.cpp | 2 +- src/modules/partition/gui/ChoicePage.cpp | 11 +++++++---- .../partition/gui/CreatePartitionDialog.cpp | 11 +++++------ .../partition/gui/CreatePartitionDialog.h | 16 +++++++++++----- src/modules/partition/gui/PartitionPage.cpp | 6 +++--- src/modules/partition/gui/PartitionViewStep.cpp | 7 +++---- 9 files changed, 45 insertions(+), 31 deletions(-) diff --git a/src/modules/partition/core/DeviceList.cpp b/src/modules/partition/core/DeviceList.cpp index d58b22868..6b770a982 100644 --- a/src/modules/partition/core/DeviceList.cpp +++ b/src/modules/partition/core/DeviceList.cpp @@ -10,8 +10,8 @@ #include "DeviceList.h" -#include "utils/Logger.h" #include "partition/PartitionIterator.h" +#include "utils/Logger.h" #include #include @@ -133,11 +133,11 @@ getDevices( DeviceType which ) #endif // Unsafe partitioning - auto removeInAllModes = []( DeviceList& l, DeviceList::iterator& it) { return erase(l, it); }; - auto removeInSafeMode = []( DeviceList&, DeviceList::iterator& it) { return ++it; }; + auto removeInAllModes = []( DeviceList& l, DeviceList::iterator& it ) { return erase( l, it ); }; + auto removeInSafeMode = []( DeviceList&, DeviceList::iterator& it ) { return ++it; }; #else // Safe partitioning - auto removeInAllModes = []( DeviceList& l, DeviceList::iterator& it) { return erase(l, it); }; + auto removeInAllModes = []( DeviceList& l, DeviceList::iterator& it ) { return erase( l, it ); }; auto& removeInSafeMode = removeInAllModes; #endif diff --git a/src/modules/partition/core/PartUtils.cpp b/src/modules/partition/core/PartUtils.cpp index 368d04af2..47654a2be 100644 --- a/src/modules/partition/core/PartUtils.cpp +++ b/src/modules/partition/core/PartUtils.cpp @@ -177,7 +177,8 @@ canBeResized( Partition* candidate, const Logger::Once& o ) if ( availableStorageB > advisedStorageB ) { - cDebug() << o << "Partition" << convenienceName( candidate ) << "authorized for resize + autopartition install."; + cDebug() << o << "Partition" << convenienceName( candidate ) + << "authorized for resize + autopartition install."; return true; } else @@ -412,8 +413,14 @@ runOsprober( DeviceModel* dm ) FstabEntryList fstabEntries = lookForFstabEntries( path ); QString homePath = findPartitionPathForMountPoint( fstabEntries, "/home" ); - osproberEntries.append( - { prettyName, path, file, QString(), canBeResized( dm, path, o ), lineColumns, fstabEntries, homePath } ); + osproberEntries.append( { prettyName, + path, + file, + QString(), + canBeResized( dm, path, o ), + lineColumns, + fstabEntries, + homePath } ); osproberCleanLines.append( line ); } } diff --git a/src/modules/partition/core/PartUtils.h b/src/modules/partition/core/PartUtils.h index aec345882..404dd5a77 100644 --- a/src/modules/partition/core/PartUtils.h +++ b/src/modules/partition/core/PartUtils.h @@ -26,7 +26,7 @@ class DeviceModel; class Partition; namespace Logger { - class Once; +class Once; } namespace PartUtils diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp index 912d46546..363d9daef 100644 --- a/src/modules/partition/core/PartitionCoreModule.cpp +++ b/src/modules/partition/core/PartitionCoreModule.cpp @@ -258,7 +258,7 @@ PartitionCoreModule::doInit() cDebug() << Logger::SubEntry << "node\tcapacity\tname\tprettyName"; for ( auto device : devices ) { - cDebug() << Logger::SubEntry << Logger::Pointer(device); + cDebug() << Logger::SubEntry << Logger::Pointer( device ); if ( device ) { // Gives ownership of the Device* to the DeviceInfo object diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index 245ee0b92..d2f5c99e7 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -144,14 +144,15 @@ ChoicePage::~ChoicePage() {} * this avoids cases where the popup would truncate data being drawn * because the overall box is sized too narrow. */ -void setModelToComboBox( QComboBox* box, QAbstractItemModel* model ) +void +setModelToComboBox( QComboBox* box, QAbstractItemModel* model ) { box->setModel( model ); if ( model->rowCount() > 0 ) { QStyleOptionViewItem options; options.initFrom( box ); - auto delegateSize = box->itemDelegate()->sizeHint(options, model->index(0, 0) ); + auto delegateSize = box->itemDelegate()->sizeHint( options, model->index( 0, 0 ) ); box->setMinimumWidth( delegateSize.width() ); } } @@ -1005,7 +1006,8 @@ ChoicePage::updateActionChoicePreview( InstallChoice choice ) SelectionFilter filter = []( const QModelIndex& index ) { return PartUtils::canBeResized( - static_cast< Partition* >( index.data( PartitionModel::PartitionPtrRole ).value< void* >() ), Logger::Once() ); + static_cast< Partition* >( index.data( PartitionModel::PartitionPtrRole ).value< void* >() ), + Logger::Once() ); }; m_beforePartitionBarsView->setSelectionFilter( filter ); m_beforePartitionLabelsView->setSelectionFilter( filter ); @@ -1094,7 +1096,8 @@ ChoicePage::updateActionChoicePreview( InstallChoice choice ) { SelectionFilter filter = []( const QModelIndex& index ) { return PartUtils::canBeReplaced( - static_cast< Partition* >( index.data( PartitionModel::PartitionPtrRole ).value< void* >() ), Logger::Once() ); + static_cast< Partition* >( index.data( PartitionModel::PartitionPtrRole ).value< void* >() ), + Logger::Once() ); }; m_beforePartitionBarsView->setSelectionFilter( filter ); m_beforePartitionLabelsView->setSelectionFilter( filter ); diff --git a/src/modules/partition/gui/CreatePartitionDialog.cpp b/src/modules/partition/gui/CreatePartitionDialog.cpp index c09724463..5ebe15336 100644 --- a/src/modules/partition/gui/CreatePartitionDialog.cpp +++ b/src/modules/partition/gui/CreatePartitionDialog.cpp @@ -135,7 +135,7 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, const FreeSpace& freeSpacePartition, const QStringList& usedMountPoints, QWidget* parentWidget ) - : CreatePartitionDialog(device, freeSpacePartition.p->parent(), usedMountPoints, parentWidget ) + : CreatePartitionDialog( device, freeSpacePartition.p->parent(), usedMountPoints, parentWidget ) { standardMountPoints( *( m_ui->mountPointComboBox ), QString() ); setFlagList( *( m_ui->m_listFlags ), @@ -148,10 +148,9 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, const FreshPartition& existingNewPartition, const QStringList& usedMountPoints, QWidget* parentWidget ) - : CreatePartitionDialog(device, existingNewPartition.p->parent(), usedMountPoints, parentWidget ) + : CreatePartitionDialog( device, existingNewPartition.p->parent(), usedMountPoints, parentWidget ) { - standardMountPoints( *( m_ui->mountPointComboBox ), - PartitionInfo::mountPoint( existingNewPartition.p ) ); + standardMountPoints( *( m_ui->mountPointComboBox ), PartitionInfo::mountPoint( existingNewPartition.p ) ); setFlagList( *( m_ui->m_listFlags ), static_cast< PartitionTable::Flags >( ~PartitionTable::Flags::Int( 0 ) ), PartitionInfo::flags( existingNewPartition.p ) ); @@ -248,8 +247,8 @@ CreatePartitionDialog::getNewlyCreatedPartition() } else { - partition - = KPMHelpers::createNewPartition( m_parent, *m_device, m_role, fsType, fsLabel, first, last, PartitionTable::Flags() ); + partition = KPMHelpers::createNewPartition( + m_parent, *m_device, m_role, fsType, fsLabel, first, last, PartitionTable::Flags() ); } if ( m_device->type() == Device::Type::LVM_Device ) diff --git a/src/modules/partition/gui/CreatePartitionDialog.h b/src/modules/partition/gui/CreatePartitionDialog.h index e18840564..38c65aaf6 100644 --- a/src/modules/partition/gui/CreatePartitionDialog.h +++ b/src/modules/partition/gui/CreatePartitionDialog.h @@ -40,13 +40,19 @@ private: * This does all the shared UI setup. */ CreatePartitionDialog( Device* device, - PartitionNode* parentPartition, - const QStringList& usedMountPoints, - QWidget* parentWidget ); + PartitionNode* parentPartition, + const QStringList& usedMountPoints, + QWidget* parentWidget ); public: - struct FreeSpace { Partition* p; }; - struct FreshPartition { Partition* p; }; + struct FreeSpace + { + Partition* p; + }; + struct FreshPartition + { + Partition* p; + }; /** @brief Dialog for editing a new partition based on free space. * diff --git a/src/modules/partition/gui/PartitionPage.cpp b/src/modules/partition/gui/PartitionPage.cpp index 06aa7b1a8..8444b9ddb 100644 --- a/src/modules/partition/gui/PartitionPage.cpp +++ b/src/modules/partition/gui/PartitionPage.cpp @@ -391,8 +391,8 @@ PartitionPage::onCreateClicked() return; } - QPointer< CreatePartitionDialog > dlg = new - CreatePartitionDialog ( model->device(), CreatePartitionDialog::FreeSpace{ partition }, getCurrentUsedMountpoints(), this ); + QPointer< CreatePartitionDialog > dlg = new CreatePartitionDialog( + model->device(), CreatePartitionDialog::FreeSpace { partition }, getCurrentUsedMountpoints(), this ); if ( dlg->exec() == QDialog::Accepted ) { Partition* newPart = dlg->getNewlyCreatedPartition(); @@ -493,7 +493,7 @@ PartitionPage::updatePartitionToCreate( Device* device, Partition* partition ) mountPoints.removeOne( PartitionInfo::mountPoint( partition ) ); QPointer< CreatePartitionDialog > dlg - = new CreatePartitionDialog( device, CreatePartitionDialog::FreshPartition{ partition }, mountPoints, this ); + = new CreatePartitionDialog( device, CreatePartitionDialog::FreshPartition { partition }, mountPoints, this ); if ( dlg->exec() == QDialog::Accepted ) { Partition* newPartition = dlg->getNewlyCreatedPartition(); diff --git a/src/modules/partition/gui/PartitionViewStep.cpp b/src/modules/partition/gui/PartitionViewStep.cpp index b4eefb3b0..bbb865f30 100644 --- a/src/modules/partition/gui/PartitionViewStep.cpp +++ b/src/modules/partition/gui/PartitionViewStep.cpp @@ -388,7 +388,7 @@ shouldWarnForGPTOnBIOS( const PartitionCoreModule* core ) } auto [ r, device ] = core->bootLoaderModel()->findBootLoader( core->bootLoaderInstallPath() ); - Q_UNUSED(r); + Q_UNUSED( r ); if ( device ) { auto* table = device->partitionTable(); @@ -403,8 +403,7 @@ shouldWarnForGPTOnBIOS( const PartitionCoreModule* core ) && ( partition->fileSystem().type() == FileSystem::Unformatted ) && ( partition->capacity() >= 8_MiB ) ) { - cDebug() << Logger::SubEntry << "Partition" << partition->devicePath() - << partition->partitionPath() + cDebug() << Logger::SubEntry << "Partition" << partition->devicePath() << partition->partitionPath() << "is a suitable bios_grub partition"; return false; } @@ -619,7 +618,7 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap ) // because it could take a while. Then when it's done, we can set up the widgets // and remove the spinner. m_future = new QFutureWatcher< void >(); - connect( m_future, &QFutureWatcher< void >::finished, this, [ this ] { + connect( m_future, &QFutureWatcher< void >::finished, this, [this] { continueLoading(); this->m_future->deleteLater(); this->m_future = nullptr; From 2b37c41b08fdf852c902a0b98c5162a02c50e7ad Mon Sep 17 00:00:00 2001 From: Calamares CI Date: Tue, 22 Jun 2021 00:31:58 +0200 Subject: [PATCH 26/54] i18n: [python] Automatic merge of Transifex translations --- lang/python/ko/LC_MESSAGES/python.po | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lang/python/ko/LC_MESSAGES/python.po b/lang/python/ko/LC_MESSAGES/python.po index b6165a387..ed244e03d 100644 --- a/lang/python/ko/LC_MESSAGES/python.po +++ b/lang/python/ko/LC_MESSAGES/python.po @@ -5,7 +5,7 @@ # # Translators: # Ji-Hyeon Gim , 2018 -# Jung Hee Lee , 2020 +# JungHee Lee , 2020 # #, fuzzy msgid "" @@ -14,7 +14,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-03-19 14:27+0100\n" "PO-Revision-Date: 2017-08-09 10:34+0000\n" -"Last-Translator: Jung Hee Lee , 2020\n" +"Last-Translator: JungHee Lee , 2020\n" "Language-Team: Korean (https://www.transifex.com/calamares/teams/20061/ko/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" From e1bf7ae96fdadb9906ae180617aecd73a8a8f071 Mon Sep 17 00:00:00 2001 From: "Omer I.S" <66558205+omeritzics@users.noreply.github.com> Date: Thu, 24 Jun 2021 14:13:30 +0300 Subject: [PATCH 27/54] Add Hebrew and Arabic --- src/modules/keyboard/non-ascii-layouts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/keyboard/non-ascii-layouts b/src/modules/keyboard/non-ascii-layouts index fe3f285a2..ef2e42787 100644 --- a/src/modules/keyboard/non-ascii-layouts +++ b/src/modules/keyboard/non-ascii-layouts @@ -7,3 +7,5 @@ ru us - ruwin_alt_sh-UTF-8 ua us - ua-utf gr us - gr +he us - he +ar us - ar From 3dce393dcc7a9fd3f05d91c7705111d107ee2ac3 Mon Sep 17 00:00:00 2001 From: Jia Chao Date: Fri, 25 Jun 2021 17:42:36 +0800 Subject: [PATCH 28/54] bootloader: add-support_for_aarch64 --- src/modules/bootloader/main.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/modules/bootloader/main.py b/src/modules/bootloader/main.py index 3e384a018..7d6a05045 100644 --- a/src/modules/bootloader/main.py +++ b/src/modules/bootloader/main.py @@ -24,6 +24,8 @@ import os import shutil import subprocess +import platform + import libcalamares from libcalamares.utils import check_target_env_call @@ -299,14 +301,21 @@ def install_grub(efi_directory, fw_type): efi_bootloader_id = efi_label() efi_bitness = efi_word_size() + cpu_type = platform.machine() + if efi_bitness == "32": efi_target = "i386-efi" efi_grub_file = "grubia32.efi" efi_boot_file = "bootia32.efi" elif efi_bitness == "64": - efi_target = "x86_64-efi" - efi_grub_file = "grubx64.efi" - efi_boot_file = "bootx64.efi" + if cpu_type == "aarch64": + efi_target = "arm64-efi" + efi_grub_file = "grubaa64.efi" + efi_boot_file = "bootaa64.efi" + else: + efi_target = "x86_64-efi" + efi_grub_file = "grubx64.efi" + efi_boot_file = "bootx64.efi" check_target_env_call([libcalamares.job.configuration["grubInstall"], "--target=" + efi_target, From e5aa90d3a88345e40efdd2645f7580c5f44094da Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 25 Jun 2021 23:57:59 +0200 Subject: [PATCH 29/54] Changes: credit for patch --- CHANGES | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES b/CHANGES index 4e38c24eb..5422168a2 100644 --- a/CHANGES +++ b/CHANGES @@ -16,6 +16,7 @@ This release contains contributions from (alphabetically by first name): - Jerrod Frost (new contributor! welcome!) - Joe Kamprad - Lisa Vitolo (blast from the past!) + - Omer I.S. In project news, chat (instant-messaging) communications has largely moved to Matrix and Libera.Chat. CI notifications -- issues and build @@ -36,6 +37,8 @@ results -- are sent to Matrix only. - *displaymanager* example configuration has been shuffled around a bit, for better results when the live image is running XFCE. Also lists more potential display managers. #1205 (Thanks Erik) + - *keyboard* now switches on an alternate `en_US` keyboard layout when + Arabic or Hebrew is selected as primary layout. (Thanks Omer) - The *netinstall* module can now fall back to alternative URLs when loading groups data. The first URL to yield a non-empty groups collection is accepted. No changes are needed in the configuration. #1673 From 989d08c70aae9496788842143b1550379c281b64 Mon Sep 17 00:00:00 2001 From: demmm Date: Sat, 26 Jun 2021 18:14:19 +0200 Subject: [PATCH 30/54] [usersq] add inline messages, adjust layout warning messages implemented for user & host names move root password option box inline with password section adjust background color according to text.length hardcode color instead of kirigami colors usersq is now usable, sets user, hostname & password correctly on install warning messages & color changes not fully done yet --- src/modules/usersq/usersq.qml | 123 +++++++++++++++------------------- 1 file changed, 53 insertions(+), 70 deletions(-) diff --git a/src/modules/usersq/usersq.qml b/src/modules/usersq/usersq.qml index 0886bba1b..2e70adff0 100644 --- a/src/modules/usersq/usersq.qml +++ b/src/modules/usersq/usersq.qml @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * - * SPDX-FileCopyrightText: 2020 Anke Boersma + * SPDX-FileCopyrightText: 2020 - 2021 Anke Boersma + * SPDX-FileCopyrightText: 2021 Adriaan de Groot * SPDX-License-Identifier: GPL-3.0-or-later * * Calamares is Free Software: see the License-Identifier above. @@ -25,8 +26,7 @@ Kirigami.ScrollablePage { Kirigami.Theme.backgroundColor: "#EFF0F1" Kirigami.Theme.textColor: "#1F1F1F" - header: Kirigami.Heading { - + header: Kirigami.Heading { Layout.fillWidth: true height: 50 horizontalAlignment: Qt.AlignHCenter @@ -37,23 +37,19 @@ Kirigami.ScrollablePage { } ColumnLayout { - id: _formLayout spacing: Kirigami.Units.smallSpacing Column { - Layout.fillWidth: true spacing: Kirigami.Units.smallSpacing Label { - width: parent.width text: qsTr("What is your name?") } TextField { - id: _userNameField width: parent.width enabled: config.isEditable("fullName") @@ -62,46 +58,39 @@ Kirigami.ScrollablePage { onTextChanged: config.setFullName(text); background: Rectangle { - color: "#FBFBFB" // Kirigami.Theme.backgroundColor radius: 2 opacity: 0.9 //border.color: _userNameField.text === "" ? Kirigami.Theme.backgroundColor : ( config.fullNameReady ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - border.color: _userNameField.text === "" ? "#FBFBFB" : ( config.fullNameChanged ? "#FBFBFB" : Kirigami.Theme.negativeTextColor) + color: _userNameField.text.length ? "#FBFBFB" : ( config.fullNameChanged ? "#f0fff0" : "#ffdae0") } } } Column { - Layout.fillWidth: true spacing: Kirigami.Units.smallSpacing Label { - width: parent.width text: qsTr("What name do you want to use to log in?") } TextField { - id: _userLoginField width: parent.width enabled: config.isEditable("loginName") placeholderText: qsTr("Login Name") text: config.loginName - onTextChanged: config.setLoginName(text) + onTextChanged: config.loginNameStatusChanged ? ( config.setLoginName(text),userMessage.visible = false ) : ( userMessage.visible = true,console.log("Invalid") ) background: Rectangle { - - color: "#FBFBFB" // Kirigami.Theme.backgroundColor opacity: 0.9 //border.color: _userLoginField.text === "" ? Kirigami.Theme.backgroundColor : ( config.userNameReady ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - border.color: _userLoginField.text === "" ? "#FBFBFB" : ( config.loginNameStatusChanged ? "#FBFBFB" : Kirigami.Theme.negativeTextColor) + color: _userLoginField.text.length ? "#FBFBFB" : ( config.loginNameStatusChanged ? "#f0fff0" : "#ffdae0") } } Label { - width: parent.width text: qsTr("If more than one person will use this computer, you can create multiple accounts after installation.") font.weight: Font.Thin @@ -110,36 +99,38 @@ Kirigami.ScrollablePage { } } - Column { + Kirigami.InlineMessage { + id: userMessage + Layout.fillWidth: true + visible: false + type: Kirigami.MessageType.Error + text: qsTr("Your username must start with a lowercase letter or underscore.") + } + Column { Layout.fillWidth: true spacing: Kirigami.Units.smallSpacing Label { - width: parent.width text: qsTr("What is the name of this computer?") } TextField { - id: _hostName width: parent.width placeholderText: qsTr("Computer Name") text: config.hostName - onTextChanged: config.setHostName(text) + onTextChanged: config.hostNameStatusChanged ? ( config.setHostName(text),hostMessage.visible = false ) : hostMessage.visible = true background: Rectangle { - - color: "#FBFBFB" // Kirigami.Theme.backgroundColor opacity: 0.9 //border.color: _hostName.text === "" ? Kirigami.Theme.backgroundColor : ( config.hostNameStatusChanged ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - border.color: _hostName.text === "" ? "#FBFBFB" : ( config.hostNameStatusChanged ? "#FBFBFB" : Kirigami.Theme.negativeTextColor) + color: _hostName.text.length ? "#FBFBFB" : ( config.hostNameStatusChanged ? "#f0fff0" : "#ffdae0") } } Label { - width: parent.width text: qsTr("This name will be used if you make the computer visible to others on a network.") font.weight: Font.Thin @@ -148,13 +139,19 @@ Kirigami.ScrollablePage { } } - Column { + Kirigami.InlineMessage { + id: hostMessage + Layout.fillWidth: true + visible: false + type: Kirigami.MessageType.Error + text: qsTr("Only letter, numbers, underscore and hyphen are allowed.") + } + Column { Layout.fillWidth: true spacing: Kirigami.Units.smallSpacing Label { - width: parent.width text: qsTr("Choose a password to keep your account safe.") } @@ -164,7 +161,6 @@ Kirigami.ScrollablePage { spacing: 20 TextField { - id: _passwordField width: parent.width / 2 - 10 placeholderText: qsTr("Password") @@ -176,16 +172,13 @@ Kirigami.ScrollablePage { inputMethodHints: Qt.ImhNoAutoUppercase background: Rectangle { - - color: "#FBFBFB" // Kirigami.Theme.backgroundColor opacity: 0.9 //border.color: _passwordField.text === "" ? Kirigami.Theme.backgroundColor : ( config.passwordReady ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - border.color: _passwordField.text === "" ? "#FBFBFB" : ( config.userPasswordStatusChanged ? "#FBFBFB" : Kirigami.Theme.negativeTextColor) + color: _passwordField.text.length ? "#FBFBFB" : ( config.userPasswordStatusChanged ? "#f0fff0" : "#ffdae0") } } TextField { - id: _verificationPasswordField width: parent.width / 2 - 10 placeholderText: qsTr("Repeat Password") @@ -197,17 +190,14 @@ Kirigami.ScrollablePage { inputMethodHints: Qt.ImhNoAutoUppercase background: Rectangle { - - color: "#FBFBFB" //Kirigami.Theme.backgroundColor opacity: 0.9 //border.color: _verificationpasswordField.text === "" ? Kirigami.Theme.backgroundColor : ( config.passwordReady ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - border.color: _verificationPasswordField.text === "" ? "#FBFBFB" : ( config.userPasswordSecondaryChanged ? "#FBFBFB" : Kirigami.Theme.negativeTextColor) + color: _verificationPasswordField.text.length ? "#FBFBFB" : ( config.userPasswordSecondaryChanged ? "#f0fff0" : "#ffdae0") } } } Label { - width: parent.width text: qsTr("Enter the same password twice, so that it can be checked for typing errors. A good password will contain a mixture of letters, numbers and punctuation, should be at least eight characters long, and should be changed at regular intervals.") font.weight: Font.Thin @@ -217,29 +207,6 @@ Kirigami.ScrollablePage { } } - CheckBox { - - visible: config.permitWeakPasswords - text: qsTr("Validate passwords quality") - checked: config.requireStrongPasswords - onCheckedChanged: config.setRequireStrongPasswords(checked) - } - - Label { - visible: config.permitWeakPasswords - width: parent.width - text: qsTr("When this box is checked, password-strength checking is done and you will not be able to use a weak password.") - font.weight: Font.Thin - font.pointSize: 8 - color: "#6D6D6D" - } - - CheckBox { - text: qsTr("Log in automatically without asking for the password") - checked: config.doAutoLogin - onCheckedChanged: config.setAutoLogin(checked) - } - CheckBox { id: root visible: config.writeRootPassword @@ -258,13 +225,11 @@ Kirigami.ScrollablePage { } Column { - visible: ! root.checked Layout.fillWidth: true spacing: Kirigami.Units.smallSpacing Label { - width: parent.width text: qsTr("Choose a root password to keep your account safe.") } @@ -274,7 +239,6 @@ Kirigami.ScrollablePage { spacing: 20 TextField { - id: _rootPasswordField width: parent.width / 2 -10 placeholderText: qsTr("Root Password") @@ -286,16 +250,13 @@ Kirigami.ScrollablePage { inputMethodHints: Qt.ImhNoAutoUppercase background: Rectangle { - - color: "#FBFBFB" // Kirigami.Theme.backgroundColor opacity: 0.9 //border.color: _rootPasswordField.text === "" ? Kirigami.Theme.backgroundColor : ( config.rootPasswordReady ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - border.color: _rootPasswordField.text === "" ? "#FBFBFB" : ( config.rootPasswordReady ? "#FBFBFB" : Kirigami.Theme.negativeTextColor) + color: _rootPasswordField.text.length ? "#FBFBFB" : ( config.rootPasswordReady ? "#f0fff0" : "#ffdae0") } } TextField { - id: _verificationRootPasswordField width: parent.width / 2 -10 placeholderText: qsTr("Repeat Root Password") @@ -307,17 +268,14 @@ Kirigami.ScrollablePage { inputMethodHints: Qt.ImhNoAutoUppercase background: Rectangle { - - color: "#FBFBFB" // Kirigami.Theme.backgroundColor opacity: 0.9 //border.color: _verificationRootPasswordField.text === "" ? Kirigami.Theme.backgroundColor : ( config.rootPasswordReady ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - border.color: _verificationRootPasswordField.text === "" ? "#FBFBFB" : ( config.rootPasswordReady ? "#FBFBFB" : Kirigami.Theme.negativeTextColor) + color: _verificationRootPasswordField.text.length ? "#FBFBFB" : ( config.rootPasswordReady ? "#f0fff0" : "#ffdae0") } } } Label { - visible: ! root.checked width: parent.width text: qsTr("Enter the same password twice, so that it can be checked for typing errors.") @@ -326,5 +284,30 @@ Kirigami.ScrollablePage { color: "#6D6D6D" } } + + CheckBox { + Layout.alignment: Qt.AlignCenter + text: qsTr("Log in automatically without asking for the password") + checked: config.doAutoLogin + onCheckedChanged: config.setAutoLogin(checked) + } + + CheckBox { + visible: config.permitWeakPasswords + Layout.alignment: Qt.AlignCenter + text: qsTr("Validate passwords quality") + checked: config.requireStrongPasswords + onCheckedChanged: config.setRequireStrongPasswords(checked) + } + + Label { + visible: config.permitWeakPasswords + width: parent.width + Layout.alignment: Qt.AlignCenter + text: qsTr("When this box is checked, password-strength checking is done and you will not be able to use a weak password.") + font.weight: Font.Thin + font.pointSize: 8 + color: "#6D6D6D" + } } } From 1554646a386fa94886aa9d7711609543202d7328 Mon Sep 17 00:00:00 2001 From: demmm Date: Sat, 26 Jun 2021 18:29:22 +0200 Subject: [PATCH 31/54] Changes: add QML modules changes --- CHANGES | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES b/CHANGES index 5422168a2..e7063fde4 100644 --- a/CHANGES +++ b/CHANGES @@ -10,6 +10,7 @@ website will have to do for older versions. # 3.2.40 (unreleased) # This release contains contributions from (alphabetically by first name): + - Anke Boersma - Anubhav Choudhary (SoK success!) - Emmanuel Arias (new contributor! welcome!) - Erik Dubois @@ -39,6 +40,8 @@ results -- are sent to Matrix only. more potential display managers. #1205 (Thanks Erik) - *keyboard* now switches on an alternate `en_US` keyboard layout when Arabic or Hebrew is selected as primary layout. (Thanks Omer) + - *localeq* now has a fully functional offline option (alongside the default + interactive map option, which requires internet). - The *netinstall* module can now fall back to alternative URLs when loading groups data. The first URL to yield a non-empty groups collection is accepted. No changes are needed in the configuration. #1673 @@ -53,6 +56,8 @@ results -- are sent to Matrix only. - The *partition* manager has had a long-standing bug with partition-flags and manual partitioning resolved. This may help resolve some installation issues on UEFI systems. #1724 + - *usersq* is further implemented and can now be used for a successful install. + Not all warning messages available in the regular users module are implemented. # 3.2.39.3 (2021-04-14) # From 2f7d251000c0d0b4649a23150fc405c33872b9ae Mon Sep 17 00:00:00 2001 From: demmm Date: Sun, 27 Jun 2021 12:05:44 +0200 Subject: [PATCH 32/54] [usersq] empty length is starting color --- src/modules/usersq/usersq.qml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/modules/usersq/usersq.qml b/src/modules/usersq/usersq.qml index 2e70adff0..2199ac676 100644 --- a/src/modules/usersq/usersq.qml +++ b/src/modules/usersq/usersq.qml @@ -61,7 +61,7 @@ Kirigami.ScrollablePage { radius: 2 opacity: 0.9 //border.color: _userNameField.text === "" ? Kirigami.Theme.backgroundColor : ( config.fullNameReady ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - color: _userNameField.text.length ? "#FBFBFB" : ( config.fullNameChanged ? "#f0fff0" : "#ffdae0") + color: _userNameField.text.length ? ( config.fullNameChanged ? "#f0fff0" : "#ffdae0") : "#FBFBFB" } } } @@ -81,12 +81,13 @@ Kirigami.ScrollablePage { enabled: config.isEditable("loginName") placeholderText: qsTr("Login Name") text: config.loginName - onTextChanged: config.loginNameStatusChanged ? ( config.setLoginName(text),userMessage.visible = false ) : ( userMessage.visible = true,console.log("Invalid") ) + //onTextChanged: config.setLoginName(text) + onTextChanged: config.loginNameStatusChanged ? ( config.setLoginName(text),userMessage.visible = false ) : ( userMessage.visible = true ) background: Rectangle { opacity: 0.9 //border.color: _userLoginField.text === "" ? Kirigami.Theme.backgroundColor : ( config.userNameReady ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - color: _userLoginField.text.length ? "#FBFBFB" : ( config.loginNameStatusChanged ? "#f0fff0" : "#ffdae0") + color: _userLoginField.text.length ? ( config.loginNameStatusChanged ? "#f0fff0" : "#ffdae0") : "#FBFBFB" } } @@ -121,12 +122,12 @@ Kirigami.ScrollablePage { width: parent.width placeholderText: qsTr("Computer Name") text: config.hostName - onTextChanged: config.hostNameStatusChanged ? ( config.setHostName(text),hostMessage.visible = false ) : hostMessage.visible = true + onTextChanged: config.hostNameStatusChanged ? (config.setHostName(text),hostMessage.visible = false) : hostMessage.visible = true background: Rectangle { opacity: 0.9 //border.color: _hostName.text === "" ? Kirigami.Theme.backgroundColor : ( config.hostNameStatusChanged ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - color: _hostName.text.length ? "#FBFBFB" : ( config.hostNameStatusChanged ? "#f0fff0" : "#ffdae0") + color: _hostName.text.length ? ( config.hostNameStatusChanged ? "#f0fff0" : "#ffdae0") : "#FBFBFB" } } @@ -174,7 +175,7 @@ Kirigami.ScrollablePage { background: Rectangle { opacity: 0.9 //border.color: _passwordField.text === "" ? Kirigami.Theme.backgroundColor : ( config.passwordReady ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - color: _passwordField.text.length ? "#FBFBFB" : ( config.userPasswordStatusChanged ? "#f0fff0" : "#ffdae0") + color: _passwordField.text.length ? ( config.userPasswordStatusChanged ? "#f0fff0" : "#ffdae0") : "#FBFBFB" } } @@ -192,7 +193,7 @@ Kirigami.ScrollablePage { background: Rectangle { opacity: 0.9 //border.color: _verificationpasswordField.text === "" ? Kirigami.Theme.backgroundColor : ( config.passwordReady ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - color: _verificationPasswordField.text.length ? "#FBFBFB" : ( config.userPasswordSecondaryChanged ? "#f0fff0" : "#ffdae0") + color: _verificationPasswordField.text.length ? ( config.userPasswordSecondaryChanged ? "#f0fff0" : "#ffdae0") : "#FBFBFB" } } } @@ -252,7 +253,7 @@ Kirigami.ScrollablePage { background: Rectangle { opacity: 0.9 //border.color: _rootPasswordField.text === "" ? Kirigami.Theme.backgroundColor : ( config.rootPasswordReady ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - color: _rootPasswordField.text.length ? "#FBFBFB" : ( config.rootPasswordReady ? "#f0fff0" : "#ffdae0") + color: _rootPasswordField.text.length ? ( config.rootPasswordReady ? "#f0fff0" : "#ffdae0") : "#FBFBFB" } } @@ -270,7 +271,7 @@ Kirigami.ScrollablePage { background: Rectangle { opacity: 0.9 //border.color: _verificationRootPasswordField.text === "" ? Kirigami.Theme.backgroundColor : ( config.rootPasswordReady ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - color: _verificationRootPasswordField.text.length ? "#FBFBFB" : ( config.rootPasswordReady ? "#f0fff0" : "#ffdae0") + color: _verificationRootPasswordField.text.length ? ( config.rootPasswordReady ? "#f0fff0" : "#ffdae0") : "#FBFBFB" } } } From a86ffd105a6c4db7bbda0a88fe7f112e8ae75610 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 28 Jun 2021 17:05:58 +0200 Subject: [PATCH 33/54] [bootloader] factor out GRUB EFI determinations --- src/modules/bootloader/main.py | 46 +++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/src/modules/bootloader/main.py b/src/modules/bootloader/main.py index 7d6a05045..7192df75c 100644 --- a/src/modules/bootloader/main.py +++ b/src/modules/bootloader/main.py @@ -24,8 +24,6 @@ import os import shutil import subprocess -import platform - import libcalamares from libcalamares.utils import check_target_env_call @@ -283,6 +281,33 @@ def install_systemd_boot(efi_directory): create_loader(loader_path, distribution_translated) +def get_grub_efi_parameters(): + """ + Returns a 3-tuple of suitable parameters for GRUB EFI installation, + depending on the host machine architecture. The return is + - target name + - grub.efi name + - boot.efi name + all three are strings. May return None if there is no suitable + set for the current machine. May return unsuitable values if the + host architecture is unknown (e.g. defaults to x86_64). + """ + import platform + efi_bitness = efi_word_size() + cpu_type = platform.machine() + + if efi_bitness == "32": + # Assume all 32-bitters are legacy x86 + return ("i386-efi", "grubia32.efi", "bootia32.efi") + elif efi_bitness == "64" and cpu_type == "aarch64": + return ("arm64-efi", "grubaa64.efi", "bootaa64.efi") + elif efi_bitness == "64": + # If it's not ARM, must by AMD64 + return ("x86_64-efi", "grubx64.efi", "bootx64.efi") + libcalamares.utils.warning("Could not find GRUB parameters for bits {b} and cpu {c}".format(b=repr(efi_bitness), c=repr(cpu_type))) + return None + + def install_grub(efi_directory, fw_type): """ Installs grub as bootloader, either in pc or efi mode. @@ -299,23 +324,8 @@ def install_grub(efi_directory, fw_type): os.makedirs(install_efi_directory) efi_bootloader_id = efi_label() - efi_bitness = efi_word_size() - cpu_type = platform.machine() - - if efi_bitness == "32": - efi_target = "i386-efi" - efi_grub_file = "grubia32.efi" - efi_boot_file = "bootia32.efi" - elif efi_bitness == "64": - if cpu_type == "aarch64": - efi_target = "arm64-efi" - efi_grub_file = "grubaa64.efi" - efi_boot_file = "bootaa64.efi" - else: - efi_target = "x86_64-efi" - efi_grub_file = "grubx64.efi" - efi_boot_file = "bootx64.efi" + efi_target, efi_grub_file, efi_boot_file = get_grub_efi_parameters() check_target_env_call([libcalamares.job.configuration["grubInstall"], "--target=" + efi_target, From 5d54a08581ad1f42722c96d997f646ae653108e3 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 28 Jun 2021 17:17:19 +0200 Subject: [PATCH 34/54] [calamares] Allow disabling the Python pre-script The test-application injects a script into Python code to render harmless functions in the subprocess module (eg to avoid Python code from running the package manager for real). There are cases, though, where that injection should be skipped (eg because the whole point of test- loading some Python is to check commands that are run). Add a -P option to the test-application to do that. --- src/calamares/testmain.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/calamares/testmain.cpp b/src/calamares/testmain.cpp index 250b047eb..2ce75d919 100644 --- a/src/calamares/testmain.cpp +++ b/src/calamares/testmain.cpp @@ -62,6 +62,7 @@ struct ModuleConfig QString m_language; QString m_branding; bool m_ui; + bool m_pythonInjection; }; static ModuleConfig @@ -86,7 +87,6 @@ handle_args( QCoreApplication& a ) QStringLiteral( "Enable UI" ) ); QCommandLineOption slideshowOption( QStringList() << QStringLiteral( "s" ) << QStringLiteral( "slideshow" ), QStringLiteral( "Run slideshow module" ) ); - QCommandLineParser parser; parser.setApplicationDescription( "Calamares module tester" ); parser.addHelpOption(); @@ -99,6 +99,12 @@ handle_args( QCoreApplication& a ) parser.addOption( brandOption ); parser.addOption( uiOption ); parser.addOption( slideshowOption ); +#ifdef WITH_PYTHON + QCommandLineOption pythonOption( QStringList() << QStringLiteral( "P" ) << QStringLiteral( "no-injected-python" ), + QStringLiteral( "Do not disable potentially-harmful Python commands" ) ); + parser.addOption( pythonOption ); +#endif + parser.addPositionalArgument( "module", "Path or name of module to run." ); parser.addPositionalArgument( "job.yaml", "Path of job settings document to use.", "[job.yaml]" ); @@ -123,12 +129,21 @@ handle_args( QCoreApplication& a ) jobSettings = args.at( 1 ); } + bool pythonInjection = true; +#ifdef WITH_PYTHON + if ( parser.isSet( pythonOption ) ) + { + pythonInjection = false; + } +#endif return ModuleConfig { parser.isSet( slideshowOption ) ? QStringLiteral( "-" ) : args.first(), jobSettings, parser.value( globalOption ), parser.value( langOption ), parser.value( brandOption ), - parser.isSet( slideshowOption ) || parser.isSet( uiOption ) }; + parser.isSet( slideshowOption ) || parser.isSet( uiOption ), + pythonInjection + }; } } @@ -430,7 +445,10 @@ main( int argc, char* argv[] ) } #ifdef WITH_PYTHON - Calamares::PythonJob::setInjectedPreScript(pythonPreScript); + if ( module.m_pythonInjection ) + { + Calamares::PythonJob::setInjectedPreScript(pythonPreScript); + } #endif #ifdef WITH_QML CalamaresUtils::initQmlModulesDir(); // don't care if failed From 015f644acf42f4e6b08978d549dfb70f505a58ac Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 28 Jun 2021 21:56:49 +0200 Subject: [PATCH 35/54] [calamares] More attributes in injected Python script Fake a little more of the subprocess module. --- src/calamares/testmain.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/calamares/testmain.cpp b/src/calamares/testmain.cpp index 2ce75d919..aa7492236 100644 --- a/src/calamares/testmain.cpp +++ b/src/calamares/testmain.cpp @@ -409,6 +409,8 @@ class fake_subprocess(object): def check_call(*args, **kwargs): libcalamares.utils.debug("subprocess.check_call(%r,%r) X subverted to call" % (args, kwargs)) return 0 +for attr in ("CalledProcessError",): + setattr(fake_subprocess,attr,getattr(_calamares_subprocess,attr)) sys.modules["subprocess"] = fake_subprocess libcalamares.utils.debug('pre-script for testing purposes injected') From e5f93d3563468d3b7a5e4b979c58c1fdbceea479 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 28 Jun 2021 21:59:13 +0200 Subject: [PATCH 36/54] Changes: credits for recent PRs --- CHANGES | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index e7063fde4..829be924f 100644 --- a/CHANGES +++ b/CHANGES @@ -15,9 +15,10 @@ This release contains contributions from (alphabetically by first name): - Emmanuel Arias (new contributor! welcome!) - Erik Dubois - Jerrod Frost (new contributor! welcome!) + - Jia Chao (new contributor! welcome!) - Joe Kamprad - Lisa Vitolo (blast from the past!) - - Omer I.S. + - Omer I.S. (new contributor! welcome!) In project news, chat (instant-messaging) communications has largely moved to Matrix and Libera.Chat. CI notifications -- issues and build @@ -35,6 +36,7 @@ results -- are sent to Matrix only. - The "upload log file" now has a configurable log-file-size. (Thanks Anubhav) ## Modules ## + - *bootloader* can now install an aarch64 (ARM) compatible EFI GRUB. (Thanks Jia) - *displaymanager* example configuration has been shuffled around a bit, for better results when the live image is running XFCE. Also lists more potential display managers. #1205 (Thanks Erik) From cba5b9e4fb00e8c8fec7e60a7d24180bb4251a79 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 21 Jun 2021 22:56:23 +0200 Subject: [PATCH 37/54] [partition]: restore defaultFileSystemType in config Add the old key back, document the new key, expand schema. --- src/modules/partition/partition.conf | 8 ++++++++ src/modules/partition/partition.schema.yaml | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/modules/partition/partition.conf b/src/modules/partition/partition.conf index c9a72655b..a900bdf48 100644 --- a/src/modules/partition/partition.conf +++ b/src/modules/partition/partition.conf @@ -137,6 +137,14 @@ initialSwapChoice: none # If nothing is specified, Calamares defaults to "ext4". # # Names are case-sensitive and defined by KPMCore. +defaultFileSystemType: "ext4" + +# Selectable filesystem type, used when "erase" is done. +# +# When erasing the disk, the *defaultFileSystemType* is used (see +# above), but it is also possible to give users a choice: +# list suitable filesystems here. A drop-down is provided +# to pick which is the filesystems will be used. availableFileSystemTypes: ["ext4", "btrfs", "f2fs"] # Show/hide LUKS related functionality in automated partitioning modes. diff --git a/src/modules/partition/partition.schema.yaml b/src/modules/partition/partition.schema.yaml index 16cc08319..6c65e8ae7 100644 --- a/src/modules/partition/partition.schema.yaml +++ b/src/modules/partition/partition.schema.yaml @@ -18,6 +18,8 @@ properties: alwaysShowPartitionLabels: { type: boolean, default: true } defaultFileSystemType: { type: string } + availableFileSystemTypes: { type: array, items: { type: string } } + enableLuksAutomatedPartitioning: { type: boolean, default: false } allowManualPartitioning: { type: boolean, default: true } partitionLayout: { type: array } # TODO: specify items From c3bc305bb6ccefd7604e39d491a625d090150ec7 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 29 Jun 2021 11:22:47 +0200 Subject: [PATCH 38/54] [partition] Shuffle Config and ViewStep to top Modules nearly always have a Config and either a Job or ViewStep as their "top level" components. Everything else is implementation- detail. The *partition* module was unusual in that those two "top level" components were tucked away in subdirectories. Shuffle them to the top: this makes it more clear that these two files are there to coordinate the module. --- src/modules/partition/CMakeLists.txt | 5 +++-- src/modules/partition/{core => }/Config.cpp | 2 +- src/modules/partition/{core => }/Config.h | 0 .../partition/{gui => }/PartitionViewStep.cpp | 4 ++-- .../partition/{gui => }/PartitionViewStep.h | 0 src/modules/partition/core/PartitionActions.h | 2 +- src/modules/partition/gui/ChoicePage.cpp | 17 +++++++++-------- src/modules/partition/gui/ChoicePage.h | 2 +- 8 files changed, 17 insertions(+), 15 deletions(-) rename src/modules/partition/{core => }/Config.cpp (99%) rename src/modules/partition/{core => }/Config.h (100%) rename src/modules/partition/{gui => }/PartitionViewStep.cpp (99%) rename src/modules/partition/{gui => }/PartitionViewStep.h (100%) diff --git a/src/modules/partition/CMakeLists.txt b/src/modules/partition/CMakeLists.txt index bffb2128c..26d4ffae7 100644 --- a/src/modules/partition/CMakeLists.txt +++ b/src/modules/partition/CMakeLists.txt @@ -49,9 +49,11 @@ if ( KPMcore_FOUND AND Qt5DBus_FOUND AND KF5CoreAddons_FOUND AND KF5Config_FOUND TYPE viewmodule EXPORT_MACRO PLUGINDLLEXPORT_PRO SOURCES + Config.cpp + PartitionViewStep.cpp + core/BootLoaderModel.cpp core/ColorUtils.cpp - core/Config.cpp core/DeviceList.cpp core/DeviceModel.cpp core/KPMHelpers.cpp @@ -75,7 +77,6 @@ if ( KPMcore_FOUND AND Qt5DBus_FOUND AND KF5CoreAddons_FOUND AND KF5Config_FOUND gui/PartitionLabelsView.cpp gui/PartitionSizeController.cpp gui/PartitionSplitterWidget.cpp - gui/PartitionViewStep.cpp gui/ResizeVolumeGroupDialog.cpp gui/ScanningDialog.cpp gui/ReplaceWidget.cpp diff --git a/src/modules/partition/core/Config.cpp b/src/modules/partition/Config.cpp similarity index 99% rename from src/modules/partition/core/Config.cpp rename to src/modules/partition/Config.cpp index 69dbe17d3..c24fdea20 100644 --- a/src/modules/partition/core/Config.cpp +++ b/src/modules/partition/Config.cpp @@ -9,7 +9,7 @@ #include "Config.h" -#include "PartUtils.h" +#include "core/PartUtils.h" #include "GlobalStorage.h" #include "JobQueue.h" diff --git a/src/modules/partition/core/Config.h b/src/modules/partition/Config.h similarity index 100% rename from src/modules/partition/core/Config.h rename to src/modules/partition/Config.h diff --git a/src/modules/partition/gui/PartitionViewStep.cpp b/src/modules/partition/PartitionViewStep.cpp similarity index 99% rename from src/modules/partition/gui/PartitionViewStep.cpp rename to src/modules/partition/PartitionViewStep.cpp index cc06ba967..c75706972 100644 --- a/src/modules/partition/gui/PartitionViewStep.cpp +++ b/src/modules/partition/PartitionViewStep.cpp @@ -11,10 +11,10 @@ * */ -#include "gui/PartitionViewStep.h" +#include "PartitionViewStep.h" +#include "Config.h" #include "core/BootLoaderModel.h" -#include "core/Config.h" #include "core/DeviceModel.h" #include "core/PartitionCoreModule.h" #include "gui/ChoicePage.h" diff --git a/src/modules/partition/gui/PartitionViewStep.h b/src/modules/partition/PartitionViewStep.h similarity index 100% rename from src/modules/partition/gui/PartitionViewStep.h rename to src/modules/partition/PartitionViewStep.h diff --git a/src/modules/partition/core/PartitionActions.h b/src/modules/partition/core/PartitionActions.h index 3a345dc4e..4a60f4735 100644 --- a/src/modules/partition/core/PartitionActions.h +++ b/src/modules/partition/core/PartitionActions.h @@ -10,7 +10,7 @@ #ifndef PARTITIONACTIONS_H #define PARTITIONACTIONS_H -#include "core/Config.h" +#include "Config.h" #include #include diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index 0c86fd718..6bbb852be 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -11,15 +11,9 @@ #include "ChoicePage.h" -#include "BootInfoWidget.h" -#include "DeviceInfoWidget.h" -#include "PartitionBarsView.h" -#include "PartitionLabelsView.h" -#include "PartitionSplitterWidget.h" -#include "ReplaceWidget.h" -#include "ScanningDialog.h" +#include "Config.h" + #include "core/BootLoaderModel.h" -#include "core/Config.h" #include "core/DeviceModel.h" #include "core/KPMHelpers.h" #include "core/OsproberEntry.h" @@ -28,6 +22,13 @@ #include "core/PartitionCoreModule.h" #include "core/PartitionInfo.h" #include "core/PartitionModel.h" +#include "gui/BootInfoWidget.h" +#include "gui/DeviceInfoWidget.h" +#include "gui/PartitionBarsView.h" +#include "gui/PartitionLabelsView.h" +#include "gui/PartitionSplitterWidget.h" +#include "gui/ReplaceWidget.h" +#include "gui/ScanningDialog.h" #include "Branding.h" #include "GlobalStorage.h" diff --git a/src/modules/partition/gui/ChoicePage.h b/src/modules/partition/gui/ChoicePage.h index 30de05cb9..5e0a24d43 100644 --- a/src/modules/partition/gui/ChoicePage.h +++ b/src/modules/partition/gui/ChoicePage.h @@ -15,7 +15,7 @@ #include "ui_ChoicePage.h" -#include "core/Config.h" +#include "Config.h" #include "core/OsproberEntry.h" #include From 5f7cfefed7407e9fbf61b9b0b82e044e9c532f05 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 29 Jun 2021 11:43:20 +0200 Subject: [PATCH 39/54] [partition] Migrate EFI settings-setting to Config object --- src/modules/partition/Config.cpp | 24 +++++++++++++++++++++ src/modules/partition/PartitionViewStep.cpp | 19 ---------------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/modules/partition/Config.cpp b/src/modules/partition/Config.cpp index c24fdea20..1e0a1ce84 100644 --- a/src/modules/partition/Config.cpp +++ b/src/modules/partition/Config.cpp @@ -228,6 +228,28 @@ Config::allowManualPartitioning() const return gs->value( "allowManualPartitioning" ).toBool(); } +static void +fillGSConfigurationEFI( Calamares::GlobalStorage* gs, const QVariantMap& configurationMap ) +{ + // Set up firmwareType global storage entry. This is used, e.g. by the bootloader module. + QString firmwareType( PartUtils::isEfiSystem() ? QStringLiteral( "efi" ) : QStringLiteral( "bios" ) ); + gs->insert( "firmwareType", firmwareType ); + + gs->insert( "efiSystemPartition", CalamaresUtils::getString( configurationMap, "efiSystemPartition", QStringLiteral( "/boot/efi" ) ) ); + + // Read and parse key efiSystemPartitionSize + if ( configurationMap.contains( "efiSystemPartitionSize" ) ) + { + gs->insert( "efiSystemPartitionSize", CalamaresUtils::getString( configurationMap, "efiSystemPartitionSize" ) ); + } + + // Read and parse key efiSystemPartitionName + if ( configurationMap.contains( "efiSystemPartitionName" ) ) + { + gs->insert( "efiSystemPartitionName", CalamaresUtils::getString( configurationMap, "efiSystemPartitionName" ) ); + } +} + void Config::setConfigurationMap( const QVariantMap& configurationMap ) @@ -288,6 +310,8 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) m_requiredPartitionTableType.append( configurationMap.value( "requiredPartitionTableType" ).toString() ); } gs->insert( "requiredPartitionTableType", m_requiredPartitionTableType ); + + fillGSConfigurationEFI(gs, configurationMap); } void diff --git a/src/modules/partition/PartitionViewStep.cpp b/src/modules/partition/PartitionViewStep.cpp index c75706972..cea1df023 100644 --- a/src/modules/partition/PartitionViewStep.cpp +++ b/src/modules/partition/PartitionViewStep.cpp @@ -548,25 +548,6 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap ) // Copy the efiSystemPartition setting to the global storage. It is needed not only in // the EraseDiskPage, but also in the bootloader configuration modules (grub, bootloader). Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); - QString efiSP = CalamaresUtils::getString( configurationMap, "efiSystemPartition", QStringLiteral( "/boot/efi" ) ); - gs->insert( "efiSystemPartition", efiSP ); - - // Set up firmwareType global storage entry. This is used, e.g. by the bootloader module. - QString firmwareType( PartUtils::isEfiSystem() ? QStringLiteral( "efi" ) : QStringLiteral( "bios" ) ); - cDebug() << o << "Setting firmwareType to" << firmwareType; - gs->insert( "firmwareType", firmwareType ); - - // Read and parse key efiSystemPartitionSize - if ( configurationMap.contains( "efiSystemPartitionSize" ) ) - { - gs->insert( "efiSystemPartitionSize", CalamaresUtils::getString( configurationMap, "efiSystemPartitionSize" ) ); - } - - // Read and parse key efiSystemPartitionName - if ( configurationMap.contains( "efiSystemPartitionName" ) ) - { - gs->insert( "efiSystemPartitionName", CalamaresUtils::getString( configurationMap, "efiSystemPartitionName" ) ); - } // Read and parse key swapPartitionName if ( configurationMap.contains( "swapPartitionName" ) ) From 46f2d72b4c081da88747c73475ed25079421d3d9 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 29 Jun 2021 11:48:53 +0200 Subject: [PATCH 40/54] [partition] requiredPartitionTableType: improve docs --- src/modules/partition/partition.conf | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/modules/partition/partition.conf b/src/modules/partition/partition.conf index a900bdf48..23f1f12b6 100644 --- a/src/modules/partition/partition.conf +++ b/src/modules/partition/partition.conf @@ -113,12 +113,11 @@ initialSwapChoice: none # Restrict the installation on disks that match the type of partition # tables that are specified. # -# Suggested values: msdos, gpt -# If nothing is specified, Calamares defaults to both "msdos" and "mbr". +# Possible values: msdos, gpt. Names are case-sensitive and defined by KPMCore. +# +# If nothing is specified, Calamares defaults to both "msdos" and "gpt". # -# Names are case-sensitive and defined by KPMCore. # requiredPartitionTableType: gpt -# or, # requiredPartitionTableType: # - msdos # - gpt From 88be947f6c0f5cc3aacef4908e6ef8121fdcc78e Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 29 Jun 2021 12:13:37 +0200 Subject: [PATCH 41/54] [libcalamares] Expand tests for Variant access - document that getStringList() also handles strings as 1-element lists --- src/libcalamares/utils/Tests.cpp | 33 +++++++++++++++++++++++--------- src/libcalamares/utils/Variant.h | 12 ++++++++---- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/src/libcalamares/utils/Tests.cpp b/src/libcalamares/utils/Tests.cpp index 7a6d52623..a689505e9 100644 --- a/src/libcalamares/utils/Tests.cpp +++ b/src/libcalamares/utils/Tests.cpp @@ -46,26 +46,27 @@ private Q_SLOTS: void testCommands(); - /** @brief Test that all the UMask objects work correctly. */ + /** @section Test that all the UMask objects work correctly. */ void testUmask(); - /** @brief Tests the entropy functions. */ + /** @section Tests the entropy functions. */ void testEntropy(); void testPrintableEntropy(); void testOddSizedPrintable(); - /** @brief Tests the RAII bits. */ + /** @section Tests the RAII bits. */ void testBoolSetter(); void testPointerSetter(); - /** @brief Tests the Traits bits. */ + /** @section Tests the Traits bits. */ void testTraits(); + /** @section Testing the variants-methods */ void testVariantStringListCode(); void testVariantStringListYAMLDashed(); void testVariantStringListYAMLBracketed(); - /** @brief Test smart string truncation. */ + /** @section Test smart string truncation. */ void testStringTruncation(); void testStringTruncationShorter(); void testStringTruncationDegenerate(); @@ -476,17 +477,31 @@ LibCalamaresTests::testVariantStringListCode() QCOMPARE( getStringList( m, key ), QStringList {} ); m.insert( key, 17 ); QCOMPARE( getStringList( m, key ), QStringList {} ); - m.insert( key, QString( "more strings" ) ); - QCOMPARE( getStringList( m, key ), - QStringList { "more strings" } ); // A single string **can** be considered a stringlist! m.insert( key, QVariant {} ); QCOMPARE( getStringList( m, key ), QStringList {} ); } { - // Things that are stringlists + // Things that are **like** stringlists + QVariantMap m; + m.insert( key, QString( "astring" ) ); + QCOMPARE( getStringList( m, key ).count(), 1 ); + QCOMPARE( getStringList( m, key ), + QStringList { "astring" } ); // A single string **can** be considered a stringlist! + m.insert( key, QString( "more strings" ) ); + QCOMPARE( getStringList( m, key ).count(), 1 ); + QCOMPARE( getStringList( m, key ), + QStringList { "more strings" } ); + m.insert( key, QString() ); + QCOMPARE( getStringList( m, key ).count(), 1 ); + QCOMPARE( getStringList( m, key ), QStringList { QString() } ); + } + + { + // Things that are definitely stringlists QVariantMap m; m.insert( key, QStringList { "aap", "noot" } ); + QCOMPARE( getStringList( m, key ).count(), 2 ); QVERIFY( getStringList( m, key ).contains( "aap" ) ); QVERIFY( !getStringList( m, key ).contains( "mies" ) ); } diff --git a/src/libcalamares/utils/Variant.h b/src/libcalamares/utils/Variant.h index e1261f877..ab9e73f90 100644 --- a/src/libcalamares/utils/Variant.h +++ b/src/libcalamares/utils/Variant.h @@ -25,13 +25,17 @@ namespace CalamaresUtils */ DLLEXPORT bool getBool( const QVariantMap& map, const QString& key, bool d = false ); -/** - * Get a string value from a mapping with a given key; returns @p d if no value. +/** @brief Get a string value from a mapping with a given key; returns @p d if no value. + * + * The value must be an actual string; numbers are not automatically converted to strings, + * nor are lists flattened or converted. */ DLLEXPORT QString getString( const QVariantMap& map, const QString& key, const QString& d = QString() ); -/** - * Get a string list from a mapping with a given key; returns @p d if no value. +/** @brief Get a string list from a mapping with a given key; returns @p d if no value. + * + * This is slightly more lenient that getString(), and a single-string value will + * be returned as a 1-item list. */ DLLEXPORT QStringList getStringList( const QVariantMap& map, const QString& key, const QStringList& d = QStringList() ); From ebecfb9f8b368bd913dba3d6fe1b4ddc1efaa285 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 29 Jun 2021 12:21:14 +0200 Subject: [PATCH 42/54] [partition] Simplify config-reading (now the variant-docs are better) --- src/modules/partition/Config.cpp | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/src/modules/partition/Config.cpp b/src/modules/partition/Config.cpp index 1e0a1ce84..7de7dbbe3 100644 --- a/src/modules/partition/Config.cpp +++ b/src/modules/partition/Config.cpp @@ -278,16 +278,7 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) if ( configurationMap.contains( "availableFileSystemTypes" ) ) { - QStringList fsTypes; - - if ( configurationMap.value( "availableFileSystemTypes" ).type() == QVariant::List ) - { - fsTypes = CalamaresUtils::getStringList( configurationMap, "availableFileSystemTypes" ); - } - else if ( configurationMap.value( "availableFileSystemTypes" ).type() == QVariant::String ) - { - fsTypes = QStringList { CalamaresUtils::getString( configurationMap, "availableFileSystemTypes" ) }; - } + QStringList fsTypes = CalamaresUtils::getStringList( configurationMap, "availableFileSystemTypes" ); m_eraseFsTypes = fsTypes; if ( !fsTypes.empty() ) @@ -297,18 +288,7 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) } } - if ( configurationMap.contains( "requiredPartitionTableType" ) - && configurationMap.value( "requiredPartitionTableType" ).type() == QVariant::List ) - { - m_requiredPartitionTableType.clear(); - m_requiredPartitionTableType.append( configurationMap.value( "requiredPartitionTableType" ).toStringList() ); - } - else if ( configurationMap.contains( "requiredPartitionTableType" ) - && configurationMap.value( "requiredPartitionTableType" ).type() == QVariant::String ) - { - m_requiredPartitionTableType.clear(); - m_requiredPartitionTableType.append( configurationMap.value( "requiredPartitionTableType" ).toString() ); - } + m_requiredPartitionTableType = CalamaresUtils::getStringList( configurationMap, "requiredPartitionTableType" ); gs->insert( "requiredPartitionTableType", m_requiredPartitionTableType ); fillGSConfigurationEFI(gs, configurationMap); From 5e3a0eda7315be86a97729cace504a2fe6862103 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 29 Jun 2021 13:01:21 +0200 Subject: [PATCH 43/54] [partition] Reduce confused naming --- src/modules/packagechooser/Config.h | 2 +- src/modules/partition/Config.cpp | 2 +- src/modules/partition/Config.h | 11 ++++++++++- src/modules/partition/PartitionViewStep.cpp | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/modules/packagechooser/Config.h b/src/modules/packagechooser/Config.h index 4cb545cb8..5959e3ea4 100644 --- a/src/modules/packagechooser/Config.h +++ b/src/modules/packagechooser/Config.h @@ -72,7 +72,7 @@ public: */ void updateGlobalStorage( const QStringList& selected ) const; /// As updateGlobalStorage() with an empty selection list - void updateGlobalStorage() const { updateGlobalStorage( QStringList() ); } + void fillGSSecondaryConfiguration() const { updateGlobalStorage( QStringList() ); } private: PackageListModel* m_model = nullptr; diff --git a/src/modules/partition/Config.cpp b/src/modules/partition/Config.cpp index 7de7dbbe3..a47bf90f8 100644 --- a/src/modules/partition/Config.cpp +++ b/src/modules/partition/Config.cpp @@ -295,7 +295,7 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) } void -Config::updateGlobalStorage() const +Config::fillGSSecondaryConfiguration() const { // If there's no setting (e.g. from the welcome page) for required storage // then use ours, if it was set. diff --git a/src/modules/partition/Config.h b/src/modules/partition/Config.h index 8b420a8d0..826cc73b5 100644 --- a/src/modules/partition/Config.h +++ b/src/modules/partition/Config.h @@ -60,7 +60,16 @@ public: using EraseFsTypesSet = QStringList; void setConfigurationMap( const QVariantMap& ); - void updateGlobalStorage() const; + /** @brief Set GS values where other modules configuration has priority + * + * Some "required" values are duplicated between modules; if some + * othe module hasn't already set the GS value, take a value from + * the partitioning configuration. + * + * Applicable GS keys: + * - requiredStorageGiB + */ + void fillGSSecondaryConfiguration() const; /** @brief What kind of installation (partitioning) is requested **initially**? * diff --git a/src/modules/partition/PartitionViewStep.cpp b/src/modules/partition/PartitionViewStep.cpp index cea1df023..47315e6a0 100644 --- a/src/modules/partition/PartitionViewStep.cpp +++ b/src/modules/partition/PartitionViewStep.cpp @@ -368,7 +368,7 @@ PartitionViewStep::isAtEnd() const void PartitionViewStep::onActivate() { - m_config->updateGlobalStorage(); + m_config->fillGSSecondaryConfiguration(); // if we're coming back to PVS from the next VS if ( m_widget->currentWidget() == m_choicePage && m_config->installChoice() == Config::InstallChoice::Alongside ) From f4944408955918527cce1d39f9622aa0373cf5fa Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 29 Jun 2021 13:21:46 +0200 Subject: [PATCH 44/54] [partition] Don't run bool allowManualPartitioning through GS It's a bit over-wrought to store a bool in a QVariant in GS for consumption **only** by ChoicePage, so drop that GS key and store it locally. --- src/modules/partition/Config.cpp | 13 ++----------- src/modules/partition/Config.h | 7 ++++--- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/modules/partition/Config.cpp b/src/modules/partition/Config.cpp index a47bf90f8..deb75d2a4 100644 --- a/src/modules/partition/Config.cpp +++ b/src/modules/partition/Config.cpp @@ -220,14 +220,6 @@ Config::setEraseFsTypeChoice( const QString& choice ) } } - -bool -Config::allowManualPartitioning() const -{ - Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); - return gs->value( "allowManualPartitioning" ).toBool(); -} - static void fillGSConfigurationEFI( Calamares::GlobalStorage* gs, const QVariantMap& configurationMap ) { @@ -272,9 +264,7 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) } setSwapChoice( m_initialSwapChoice ); - Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); - gs->insert( "allowManualPartitioning", - CalamaresUtils::getBool( configurationMap, "allowManualPartitioning", true ) ); + m_allowManualPartitioning = CalamaresUtils::getBool( configurationMap, "allowManualPartitioning", true ); if ( configurationMap.contains( "availableFileSystemTypes" ) ) { @@ -288,6 +278,7 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) } } + Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); m_requiredPartitionTableType = CalamaresUtils::getStringList( configurationMap, "requiredPartitionTableType" ); gs->insert( "requiredPartitionTableType", m_requiredPartitionTableType ); diff --git a/src/modules/partition/Config.h b/src/modules/partition/Config.h index 826cc73b5..309bb4a49 100644 --- a/src/modules/partition/Config.h +++ b/src/modules/partition/Config.h @@ -112,9 +112,8 @@ public: QString eraseFsType() const { return m_eraseFsTypeChoice; } - - ///@brief Is manual partitioning allowed (not explicitly disnabled in the config file)? - bool allowManualPartitioning() const; + ///@brief Is manual partitioning allowed (not explicitly disabled in the config file)? + bool allowManualPartitioning() const { return m_allowManualPartitioning; } public Q_SLOTS: void setInstallChoice( int ); ///< Translates a button ID or so to InstallChoice @@ -138,6 +137,8 @@ private: InstallChoice m_installChoice = NoChoice; qreal m_requiredStorageGiB = 0.0; // May duplicate setting in the welcome module QStringList m_requiredPartitionTableType; + + bool m_allowManualPartitioning = true; }; /** @brief Given a set of swap choices, return a sensible value from it. From 67fafa04ac9452e95766165b373b068222839de9 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 29 Jun 2021 14:47:09 +0200 Subject: [PATCH 45/54] [partition] Move fs-type handling into Config - the defaultFileSystemType interacts with availableFileSystemTypes so set them together. --- src/modules/partition/Config.cpp | 68 +++++++++++++++++---- src/modules/partition/Config.h | 20 +++++- src/modules/partition/PartitionViewStep.cpp | 28 +-------- 3 files changed, 76 insertions(+), 40 deletions(-) diff --git a/src/modules/partition/Config.cpp b/src/modules/partition/Config.cpp index deb75d2a4..7a931b9be 100644 --- a/src/modules/partition/Config.cpp +++ b/src/modules/partition/Config.cpp @@ -242,6 +242,61 @@ fillGSConfigurationEFI( Calamares::GlobalStorage* gs, const QVariantMap& configu } } +void +Config::fillConfigurationFSTypes(const QVariantMap& configurationMap) +{ + Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); + + + // 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" ); + QString fsRealName; + FileSystem::Type fsType = FileSystem::Type::Unknown; + if ( fsName.isEmpty() ) + { + cWarning() << "Partition-module setting *defaultFileSystemType* is missing, will use ext4"; + fsRealName = PartUtils::canonicalFilesystemName( QStringLiteral("ext4"), &fsType ); + } + else + { + fsRealName = PartUtils::canonicalFilesystemName( fsName, &fsType ); + if ( fsType == FileSystem::Type::Unknown ) + { + cWarning() << "Partition-module setting *defaultFileSystemType* is bad (" << fsName << ") using ext4 instead"; + fsRealName = PartUtils::canonicalFilesystemName( QStringLiteral("ext4"), &fsType ); + } + else if ( fsRealName != fsName ) + { + cWarning() << "Partition-module setting *defaultFileSystemType* changed to" << fsRealName; + } + } + Q_ASSERT( fsType != FileSystem::Type::Unknown ); + m_defaultFsType = fsType; + gs->insert( "defaultFileSystemType", fsRealName ); + + // TODO: canonicalize the names? How is translation supposed to work? + m_eraseFsTypes = CalamaresUtils::getStringList( configurationMap, "availableFileSystemTypes" ); + if ( !m_eraseFsTypes.contains( fsRealName ) ) + { + if ( !m_eraseFsTypes.isEmpty() ) + { + // Explicitly set, and doesn't include the default + cWarning() << "Partition-module *availableFileSystemTypes* does not contain the default" << fsRealName; + m_eraseFsTypes.prepend( fsRealName ); + } + else + { + // Not explicitly set, so it's empty; don't complain + m_eraseFsTypes = QStringList { fsRealName }; + } + } + + Q_ASSERT( !m_eraseFsTypes.isEmpty() ); + m_eraseFsTypeChoice = m_eraseFsTypes.first(); + Q_EMIT eraseModeFilesystemChanged( m_eraseFsTypeChoice ); +} + void Config::setConfigurationMap( const QVariantMap& configurationMap ) @@ -266,23 +321,12 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) m_allowManualPartitioning = CalamaresUtils::getBool( configurationMap, "allowManualPartitioning", true ); - if ( configurationMap.contains( "availableFileSystemTypes" ) ) - { - QStringList fsTypes = CalamaresUtils::getStringList( configurationMap, "availableFileSystemTypes" ); - - m_eraseFsTypes = fsTypes; - if ( !fsTypes.empty() ) - { - m_eraseFsTypeChoice = m_eraseFsTypes.first(); - Q_EMIT eraseModeFilesystemChanged( m_eraseFsTypeChoice ); - } - } - Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); m_requiredPartitionTableType = CalamaresUtils::getStringList( configurationMap, "requiredPartitionTableType" ); gs->insert( "requiredPartitionTableType", m_requiredPartitionTableType ); fillGSConfigurationEFI(gs, configurationMap); + fillConfigurationFSTypes( configurationMap ); } void diff --git a/src/modules/partition/Config.h b/src/modules/partition/Config.h index 309bb4a49..3365403fa 100644 --- a/src/modules/partition/Config.h +++ b/src/modules/partition/Config.h @@ -12,6 +12,8 @@ #include "utils/NamedEnum.h" +#include + #include #include @@ -108,10 +110,22 @@ public: */ SwapChoice swapChoice() const { return m_swapChoice; } + /** @brief Get the list of configured FS types to use with *erase* mode + * + * This list is not empty. + */ EraseFsTypesSet eraseFsTypes() const { return m_eraseFsTypes; } + /** @brief Currently-selected FS type for *erase* mode + */ QString eraseFsType() const { return m_eraseFsTypeChoice; } + /** @brief Configured default FS type (for other modes than erase) + * + * This is not "Unknown" or "Unformatted" + */ + FileSystem::Type defaultFsType() const { return m_defaultFsType; } + ///@brief Is manual partitioning allowed (not explicitly disabled in the config file)? bool allowManualPartitioning() const { return m_allowManualPartitioning; } @@ -128,9 +142,13 @@ Q_SIGNALS: void eraseModeFilesystemChanged( const QString& ); private: - SwapChoiceSet m_swapChoices; + /** @brief Handle FS-type configuration, for erase and default */ + void fillConfigurationFSTypes( const QVariantMap& configurationMap ); EraseFsTypesSet m_eraseFsTypes; QString m_eraseFsTypeChoice; + FileSystem::Type m_defaultFsType; + + SwapChoiceSet m_swapChoices; SwapChoice m_initialSwapChoice = NoSwap; SwapChoice m_swapChoice = NoSwap; InstallChoice m_initialInstallChoice = NoChoice; diff --git a/src/modules/partition/PartitionViewStep.cpp b/src/modules/partition/PartitionViewStep.cpp index 47315e6a0..fc6b3e50c 100644 --- a/src/modules/partition/PartitionViewStep.cpp +++ b/src/modules/partition/PartitionViewStep.cpp @@ -541,8 +541,6 @@ PartitionViewStep::onLeave() void PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { - Logger::Once o; - m_config->setConfigurationMap( configurationMap ); // Copy the efiSystemPartition setting to the global storage. It is needed not only in @@ -563,30 +561,6 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap ) gs->insert( "enableLuksAutomatedPartitioning", CalamaresUtils::getBool( configurationMap, "enableLuksAutomatedPartitioning", true ) ); - // 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::canonicalFilesystemName( fsName, &fsType ); - if ( fsRealName == fsName ) - { - cDebug() << o << "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 (" << fsName << ") using" << fsRealName - << "instead."; - } - gs->insert( "defaultFileSystemType", fsRealName ); - QString partitionTableName = CalamaresUtils::getString( configurationMap, "defaultPartitionTableType" ); if ( partitionTableName.isEmpty() ) { @@ -608,7 +582,7 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap ) QFuture< void > future = QtConcurrent::run( this, &PartitionViewStep::initPartitionCoreModule ); m_future->setFuture( future ); - m_core->initLayout( fsType == FileSystem::Unknown ? FileSystem::Ext4 : fsType, + m_core->initLayout( m_config->defaultFsType(), configurationMap.value( "partitionLayout" ).toList() ); } From c3528e4e40aac264d0eb081b87d220c905f3af92 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 29 Jun 2021 14:52:16 +0200 Subject: [PATCH 46/54] [partition] Document that the default FS is used, also when erasing --- src/modules/partition/Config.cpp | 3 ++- src/modules/partition/partition.conf | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/partition/Config.cpp b/src/modules/partition/Config.cpp index 7a931b9be..82c0ad846 100644 --- a/src/modules/partition/Config.cpp +++ b/src/modules/partition/Config.cpp @@ -293,7 +293,8 @@ Config::fillConfigurationFSTypes(const QVariantMap& configurationMap) } Q_ASSERT( !m_eraseFsTypes.isEmpty() ); - m_eraseFsTypeChoice = m_eraseFsTypes.first(); + Q_ASSERT( m_eraseFsTypes.contains( fsRealName ) ); + m_eraseFsTypeChoice = fsRealName; Q_EMIT eraseModeFilesystemChanged( m_eraseFsTypeChoice ); } diff --git a/src/modules/partition/partition.conf b/src/modules/partition/partition.conf index 23f1f12b6..61e955375 100644 --- a/src/modules/partition/partition.conf +++ b/src/modules/partition/partition.conf @@ -144,6 +144,9 @@ defaultFileSystemType: "ext4" # above), but it is also possible to give users a choice: # list suitable filesystems here. A drop-down is provided # to pick which is the filesystems will be used. +# +# The value *defaultFileSystemType* is added to this list (with a warning) +# if not present; the default pick is the *defaultFileSystemType*. availableFileSystemTypes: ["ext4", "btrfs", "f2fs"] # Show/hide LUKS related functionality in automated partitioning modes. From 70df0b0bc8ea2764ab0073ccf49c43a7903338b1 Mon Sep 17 00:00:00 2001 From: demmm Date: Tue, 29 Jun 2021 17:41:07 +0200 Subject: [PATCH 47/54] [localeq] prevent MouseArea from stealing all map interaction bug introduced with Qt 5.15 KDE patches makes near impossible to set location adding - 5 seems to fix, otherwise the coordinates label will have to be removed --- src/modules/localeq/Map.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/localeq/Map.qml b/src/modules/localeq/Map.qml index 845f16ea3..5972b5c15 100644 --- a/src/modules/localeq/Map.qml +++ b/src/modules/localeq/Map.qml @@ -168,7 +168,7 @@ Column { hoverEnabled: true property var coordinate: map.toCoordinate(Qt.point(mouseX, mouseY)) Label { - x: parent.mouseX - width + x: parent.mouseX - width -5 y: parent.mouseY - height - 5 text: "%1, %2".arg( parent.coordinate.latitude).arg(parent.coordinate.longitude) From 453d533d2c852fa412d097612c0feb249551e002 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 29 Jun 2021 23:47:33 +0200 Subject: [PATCH 48/54] [partition] Use default FS for layout items with type Unknown --- .../partition/core/PartitionLayout.cpp | 74 ++++++++++++++++++- src/modules/partition/core/PartitionLayout.h | 20 ++++- 2 files changed, 89 insertions(+), 5 deletions(-) diff --git a/src/modules/partition/core/PartitionLayout.cpp b/src/modules/partition/core/PartitionLayout.cpp index c828fce69..a8ed206d8 100644 --- a/src/modules/partition/core/PartitionLayout.cpp +++ b/src/modules/partition/core/PartitionLayout.cpp @@ -95,7 +95,7 @@ PartitionLayout::addEntry( const PartitionEntry& entry ) void PartitionLayout::init( FileSystem::Type defaultFsType, const QVariantList& config ) { - bool ok; + bool ok = true; // bogus argument to getSubMap() m_partLayout.clear(); @@ -130,10 +130,71 @@ PartitionLayout::init( FileSystem::Type defaultFsType, const QVariantList& confi if ( !m_partLayout.count() ) { - addEntry( { defaultFsType, QString( "/" ), QString( "100%" ) } ); + // Unknown will be translated to defaultFsType at apply-time + addEntry( { FileSystem::Type::Unknown, QString( "/" ), QString( "100%" ) } ); } + + setDefaultFsType( defaultFsType ); } +void +PartitionLayout::setDefaultFsType(FileSystem::Type defaultFsType) +{ + using T = FileSystem::Type; + switch ( defaultFsType ) + { + case T::Unknown: + case T::Unformatted: + case T::Extended: + case T::LinuxSwap: + case T::Luks: + case T::Ocfs2: + case T::Lvm2_PV: + case T::Udf: + case T::Iso9660: + case T::Luks2: + case T::LinuxRaidMember: + case T::BitLocker: + // bad bad + cWarning() << "The selected default FS" << defaultFsType << "is not suitable." << "Using ext4 instead."; + defaultFsType = T::Ext4; + break; + case T::Ext2: + case T::Ext3: + case T::Ext4: + case T::Fat32: + case T::Ntfs: + case T::Reiser4: + case T::ReiserFS: + case T::Xfs: + case T::Jfs: + case T::Btrfs: + case T::Exfat: + case T::F2fs: + // ok + break; + case T::Fat12: + case T::Fat16: + case T::Hfs: + case T::HfsPlus: + case T::Ufs: + case T::Hpfs: + case T::Zfs: + case T::Nilfs2: + case T::Apfs: + case T::Minix: + // weird + cWarning() << "The selected default FS" << defaultFsType << "is unusual, but not wrong."; + break; + default: + cWarning() << "The selected default FS" << defaultFsType << "is not known to Calamares." << "Using ext4 instead."; + defaultFsType = T::Ext4; + } + + m_defaultFsType = defaultFsType; +} + + QList< Partition* > PartitionLayout::createPartitions( Device* dev, qint64 firstSector, @@ -142,6 +203,9 @@ PartitionLayout::createPartitions( Device* dev, PartitionNode* parent, const PartitionRole& role ) { + // Make sure the default FS is sensible; warn and use ext4 if not + setDefaultFsType( m_defaultFsType ); + QList< Partition* > partList; // Map each partition entry to its requested size (0 when calculated later) QMap< const PartitionLayout::PartitionEntry*, qint64 > partSectorsMap; @@ -210,6 +274,8 @@ PartitionLayout::createPartitions( Device* dev, } } + auto correctFS = [d=m_defaultFsType]( FileSystem::Type t ) { return t == FileSystem::Type::Unknown ? d : t; }; + // Create the partitions. currentSector = firstSector; availableSectors = totalSectors; @@ -229,7 +295,7 @@ PartitionLayout::createPartitions( Device* dev, part = KPMHelpers::createNewPartition( parent, *dev, role, - entry.partFileSystem, + correctFS( entry.partFileSystem ), entry.partLabel, currentSector, currentSector + sectors - 1, @@ -240,7 +306,7 @@ PartitionLayout::createPartitions( Device* dev, part = KPMHelpers::createNewEncryptedPartition( parent, *dev, role, - entry.partFileSystem, + correctFS( entry.partFileSystem ), entry.partLabel, currentSector, currentSector + sectors - 1, diff --git a/src/modules/partition/core/PartitionLayout.h b/src/modules/partition/core/PartitionLayout.h index 6e0c73f8f..c4c26d9f1 100644 --- a/src/modules/partition/core/PartitionLayout.h +++ b/src/modules/partition/core/PartitionLayout.h @@ -87,11 +87,28 @@ public: * * @p config is a list of partition entries (in QVariant form, * read from YAML). If no entries are given, then a single - * partition is created with the given @p defaultFsType + * partition is created with type Unkown. + * + * Any partitions with FS type Unknown will get the default filesystem + * that is set at **apply** time (e.g. when createPartitions() is + * called as well. + * + * @see setDefaultFsType() */ void init( FileSystem::Type defaultFsType, const QVariantList& config ); + /** @brief add an entry as if it had been listed in the config + * + * The same comments about filesystem type apply. + */ bool addEntry( const PartitionEntry& entry ); + /** @brief set the default filesystem type + * + * Any partitions in the layout with type Unknown will get + * the default type when createPartitions() is called. + */ + void setDefaultFsType( FileSystem::Type defaultFsType ); + /** * @brief Apply the current partition layout to the selected drive space. * @return A list of Partition objects. @@ -105,6 +122,7 @@ public: private: QList< PartitionEntry > m_partLayout; + FileSystem::Type m_defaultFsType = FileSystem::Type::Unknown; }; #endif /* PARTITIONLAYOUT_H */ From 00b6694073ce66b0a157eeb3696cd34e647ece64 Mon Sep 17 00:00:00 2001 From: demmm Date: Wed, 30 Jun 2021 18:29:32 +0200 Subject: [PATCH 49/54] [usersq] use validator for login & hostname pallette for colors inline warning messages now work, password fields checks included left to implement are password validation inline messages --- src/modules/usersq/usersq.qml | 90 ++++++++++++++++------------------- 1 file changed, 41 insertions(+), 49 deletions(-) diff --git a/src/modules/usersq/usersq.qml b/src/modules/usersq/usersq.qml index 2199ac676..fbd748f11 100644 --- a/src/modules/usersq/usersq.qml +++ b/src/modules/usersq/usersq.qml @@ -11,7 +11,7 @@ import io.calamares.core 1.0 import io.calamares.ui 1.0 -import QtQuick 2.10 +import QtQuick 2.15 import QtQuick.Controls 2.10 import QtQuick.Layouts 1.3 import org.kde.kirigami 2.7 as Kirigami @@ -56,13 +56,8 @@ Kirigami.ScrollablePage { placeholderText: qsTr("Your Full Name") text: config.fullName onTextChanged: config.setFullName(text); - - background: Rectangle { - radius: 2 - opacity: 0.9 - //border.color: _userNameField.text === "" ? Kirigami.Theme.backgroundColor : ( config.fullNameReady ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - color: _userNameField.text.length ? ( config.fullNameChanged ? "#f0fff0" : "#ffdae0") : "#FBFBFB" - } + palette.base: _userNameField.text.length ? "#f0fff0" : "#FBFBFB" + palette.highlight : _userNameField.text.length ? "#dcffdc" : "#FBFBFB" } } @@ -81,14 +76,11 @@ Kirigami.ScrollablePage { enabled: config.isEditable("loginName") placeholderText: qsTr("Login Name") text: config.loginName - //onTextChanged: config.setLoginName(text) - onTextChanged: config.loginNameStatusChanged ? ( config.setLoginName(text),userMessage.visible = false ) : ( userMessage.visible = true ) + validator: RegularExpressionValidator { regularExpression: /[a-z_][a-z0-9_-]*[$]?$/ } + onTextChanged: acceptableInput ? ( config.setLoginName(text),userMessage.visible = false ) : ( userMessage.visible = true,console.log("Invalid") ) - background: Rectangle { - opacity: 0.9 - //border.color: _userLoginField.text === "" ? Kirigami.Theme.backgroundColor : ( config.userNameReady ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - color: _userLoginField.text.length ? ( config.loginNameStatusChanged ? "#f0fff0" : "#ffdae0") : "#FBFBFB" - } + palette.base: _userLoginField.text.length ? "#f0fff0" : "#FBFBFB" + palette.highlight : _userLoginField.text.length ? "#dcffdc" : "#FBFBFB" } Label { @@ -105,7 +97,7 @@ Kirigami.ScrollablePage { Layout.fillWidth: true visible: false type: Kirigami.MessageType.Error - text: qsTr("Your username must start with a lowercase letter or underscore.") + text: qsTr("Your username must start with a lowercase letter or underscore, minimal of two characters.") } Column { @@ -122,13 +114,11 @@ Kirigami.ScrollablePage { width: parent.width placeholderText: qsTr("Computer Name") text: config.hostName - onTextChanged: config.hostNameStatusChanged ? (config.setHostName(text),hostMessage.visible = false) : hostMessage.visible = true + validator: RegularExpressionValidator { regularExpression: /[a-zA-Z0-9][-a-zA-Z0-9_]+/ } + onTextChanged: acceptableInput ? (config.setHostName(text),hostMessage.visible = false) : hostMessage.visible = true - background: Rectangle { - opacity: 0.9 - //border.color: _hostName.text === "" ? Kirigami.Theme.backgroundColor : ( config.hostNameStatusChanged ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - color: _hostName.text.length ? ( config.hostNameStatusChanged ? "#f0fff0" : "#ffdae0") : "#FBFBFB" - } + palette.base: _hostName.text.length ? ( acceptableInput ? "#f0fff0" : "#ffdae0") : "#FBFBFB" + palette.highlight : _hostName.text.length ? "#dcffdc" : "#FBFBFB" } Label { @@ -145,7 +135,7 @@ Kirigami.ScrollablePage { Layout.fillWidth: true visible: false type: Kirigami.MessageType.Error - text: qsTr("Only letter, numbers, underscore and hyphen are allowed.") + text: qsTr("Only letter, numbers, underscore and hyphen are allowed, minimal of two characters.") } Column { @@ -167,16 +157,12 @@ Kirigami.ScrollablePage { placeholderText: qsTr("Password") text: config.userPassword onTextChanged: config.setUserPassword(text) + palette.base: _passwordField.text.length ? "#f0fff0" : "#FBFBFB" + palette.highlight : _passwordField.text.length ? "#dcffdc" : "#FBFBFB" echoMode: TextInput.Password passwordMaskDelay: 300 inputMethodHints: Qt.ImhNoAutoUppercase - - background: Rectangle { - opacity: 0.9 - //border.color: _passwordField.text === "" ? Kirigami.Theme.backgroundColor : ( config.passwordReady ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - color: _passwordField.text.length ? ( config.userPasswordStatusChanged ? "#f0fff0" : "#ffdae0") : "#FBFBFB" - } } TextField { @@ -184,17 +170,14 @@ Kirigami.ScrollablePage { width: parent.width / 2 - 10 placeholderText: qsTr("Repeat Password") text: config.userPasswordSecondary - onTextChanged: config.setUserPasswordSecondary(text) + onTextChanged: _passwordField.text === _verificationPasswordField.text ? (config.setUserPasswordSecondary(text),passMessage.visible = false) : passMessage.visible = true + + palette.base: _verificationPasswordField.text.length ? ( _passwordField.text === _verificationPasswordField.text ? "#f0fff0" : "#ffdae0") : "#FBFBFB" + palette.highlight : _verificationPasswordField.text.length ? "#dcffdc" : "#FBFBFB" echoMode: TextInput.Password passwordMaskDelay: 300 inputMethodHints: Qt.ImhNoAutoUppercase - - background: Rectangle { - opacity: 0.9 - //border.color: _verificationpasswordField.text === "" ? Kirigami.Theme.backgroundColor : ( config.passwordReady ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - color: _verificationPasswordField.text.length ? ( config.userPasswordSecondaryChanged ? "#f0fff0" : "#ffdae0") : "#FBFBFB" - } } } @@ -208,6 +191,14 @@ Kirigami.ScrollablePage { } } + Kirigami.InlineMessage { + id: passMessage + Layout.fillWidth: true + visible: false + type: Kirigami.MessageType.Error + text: qsTr("Your passwords do not match!") + } + CheckBox { id: root visible: config.writeRootPassword @@ -245,16 +236,12 @@ Kirigami.ScrollablePage { placeholderText: qsTr("Root Password") text: config.rootPassword onTextChanged: config.setRootPassword(text) + palette.base: _rootPasswordField.text.length ? "#f0fff0" : "#FBFBFB" + palette.highlight : _rootPasswordField.text.length ? "#dcffdc" : "#FBFBFB" echoMode: TextInput.Password passwordMaskDelay: 300 inputMethodHints: Qt.ImhNoAutoUppercase - - background: Rectangle { - opacity: 0.9 - //border.color: _rootPasswordField.text === "" ? Kirigami.Theme.backgroundColor : ( config.rootPasswordReady ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - color: _rootPasswordField.text.length ? ( config.rootPasswordReady ? "#f0fff0" : "#ffdae0") : "#FBFBFB" - } } TextField { @@ -262,17 +249,14 @@ Kirigami.ScrollablePage { width: parent.width / 2 -10 placeholderText: qsTr("Repeat Root Password") text: config.rootPasswordSecondary - onTextChanged: config.setRootPasswordSecondary(text) + //onTextChanged: config.setRootPasswordSecondary(text) + onTextChanged: _rootPasswordField.text === _verificationRootPasswordField.text ? (config.setRootPasswordSecondary(text),rootPassMessage.visible = false) : rootPassMessage.visible = true + palette.base: _verificationRootPasswordField.text.length ? ( _rootPasswordField.text === _verificationRootPasswordField.text ? "#f0fff0" : "#ffdae0") : "#FBFBFB" + palette.highlight : _verificationRootPasswordField.text.length ? "#dcffdc" : "#FBFBFB" echoMode: TextInput.Password passwordMaskDelay: 300 inputMethodHints: Qt.ImhNoAutoUppercase - - background: Rectangle { - opacity: 0.9 - //border.color: _verificationRootPasswordField.text === "" ? Kirigami.Theme.backgroundColor : ( config.rootPasswordReady ? Kirigami.Theme.backgroundColor : Kirigami.Theme.negativeTextColor) - color: _verificationRootPasswordField.text.length ? ( config.rootPasswordReady ? "#f0fff0" : "#ffdae0") : "#FBFBFB" - } } } @@ -286,6 +270,14 @@ Kirigami.ScrollablePage { } } + Kirigami.InlineMessage { + id: rootPassMessage + Layout.fillWidth: true + visible: false + type: Kirigami.MessageType.Error + text: qsTr("Your passwords do not match!") + } + CheckBox { Layout.alignment: Qt.AlignCenter text: qsTr("Log in automatically without asking for the password") From ce699d8e3d4d88079ca205fac1ab3a261ca8fde7 Mon Sep 17 00:00:00 2001 From: demmm Date: Wed, 30 Jun 2021 22:29:32 +0200 Subject: [PATCH 50/54] [usersq] add warnings for forbidden names root & localhost set as forbidden in loginname & hostname --- src/modules/usersq/usersq.qml | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/modules/usersq/usersq.qml b/src/modules/usersq/usersq.qml index fbd748f11..064ffcc34 100644 --- a/src/modules/usersq/usersq.qml +++ b/src/modules/usersq/usersq.qml @@ -77,9 +77,9 @@ Kirigami.ScrollablePage { placeholderText: qsTr("Login Name") text: config.loginName validator: RegularExpressionValidator { regularExpression: /[a-z_][a-z0-9_-]*[$]?$/ } - onTextChanged: acceptableInput ? ( config.setLoginName(text),userMessage.visible = false ) : ( userMessage.visible = true,console.log("Invalid") ) + onTextChanged: acceptableInput ? ( _userLoginField.text === "root" ? forbiddenMessage.visible=true : ( config.setLoginName(text),userMessage.visible = false,forbiddenMessage.visible=false ) ) : ( userMessage.visible = true,console.log("Invalid") ) - palette.base: _userLoginField.text.length ? "#f0fff0" : "#FBFBFB" + palette.base: _userLoginField.text.length ? ( acceptableInput ? ( _userLoginField.text === "root" ? "#ffdae0" : "#f0fff0" ) : "#ffdae0") : "#FBFBFB" palette.highlight : _userLoginField.text.length ? "#dcffdc" : "#FBFBFB" } @@ -97,7 +97,15 @@ Kirigami.ScrollablePage { Layout.fillWidth: true visible: false type: Kirigami.MessageType.Error - text: qsTr("Your username must start with a lowercase letter or underscore, minimal of two characters.") + text: qsTr("Only lowercase letters, numbers, underscore and hyphen are allowed.") + } + + Kirigami.InlineMessage { + id: forbiddenMessage + Layout.fillWidth: true + visible: false + type: Kirigami.MessageType.Error + text: qsTr("root is not allowed as username.") } Column { @@ -115,9 +123,9 @@ Kirigami.ScrollablePage { placeholderText: qsTr("Computer Name") text: config.hostName validator: RegularExpressionValidator { regularExpression: /[a-zA-Z0-9][-a-zA-Z0-9_]+/ } - onTextChanged: acceptableInput ? (config.setHostName(text),hostMessage.visible = false) : hostMessage.visible = true + onTextChanged: acceptableInput ? ( _hostName.text === "localhost" ? forbiddenHost.visible=true : (config.setHostName(text),hostMessage.visible = false,forbiddenHost.visible = false) ) : hostMessage.visible = true - palette.base: _hostName.text.length ? ( acceptableInput ? "#f0fff0" : "#ffdae0") : "#FBFBFB" + palette.base: _hostName.text.length ? ( acceptableInput ? ( _hostName.text === "localhost" ? "#ffdae0" : "#f0fff0" ) : "#ffdae0") : "#FBFBFB" palette.highlight : _hostName.text.length ? "#dcffdc" : "#FBFBFB" } @@ -138,6 +146,14 @@ Kirigami.ScrollablePage { text: qsTr("Only letter, numbers, underscore and hyphen are allowed, minimal of two characters.") } + Kirigami.InlineMessage { + id: forbiddenHost + Layout.fillWidth: true + visible: false + type: Kirigami.MessageType.Error + text: qsTr("localhost is not allowed as hostname.") + } + Column { Layout.fillWidth: true spacing: Kirigami.Units.smallSpacing @@ -251,6 +267,7 @@ Kirigami.ScrollablePage { text: config.rootPasswordSecondary //onTextChanged: config.setRootPasswordSecondary(text) onTextChanged: _rootPasswordField.text === _verificationRootPasswordField.text ? (config.setRootPasswordSecondary(text),rootPassMessage.visible = false) : rootPassMessage.visible = true + palette.base: _verificationRootPasswordField.text.length ? ( _rootPasswordField.text === _verificationRootPasswordField.text ? "#f0fff0" : "#ffdae0") : "#FBFBFB" palette.highlight : _verificationRootPasswordField.text.length ? "#dcffdc" : "#FBFBFB" From a156d2e63ff54215da74c2558c8b58d8adb14b7e Mon Sep 17 00:00:00 2001 From: demmm Date: Sat, 3 Jul 2021 00:10:31 +0200 Subject: [PATCH 51/54] [usersq] working password validity check kirigami inlinemessages adjusted for password fields coding style, break lines in variables add closing button for root password inline message, needed bc of re-use root password option does not remove all messages --- src/modules/usersq/usersq.qml | 89 ++++++++++++++++++++++++++++++----- 1 file changed, 76 insertions(+), 13 deletions(-) diff --git a/src/modules/usersq/usersq.qml b/src/modules/usersq/usersq.qml index 064ffcc34..0654c4619 100644 --- a/src/modules/usersq/usersq.qml +++ b/src/modules/usersq/usersq.qml @@ -55,7 +55,8 @@ Kirigami.ScrollablePage { enabled: config.isEditable("fullName") placeholderText: qsTr("Your Full Name") text: config.fullName - onTextChanged: config.setFullName(text); + onTextChanged: config.setFullName(text) + palette.base: _userNameField.text.length ? "#f0fff0" : "#FBFBFB" palette.highlight : _userNameField.text.length ? "#dcffdc" : "#FBFBFB" } @@ -77,9 +78,18 @@ Kirigami.ScrollablePage { placeholderText: qsTr("Login Name") text: config.loginName validator: RegularExpressionValidator { regularExpression: /[a-z_][a-z0-9_-]*[$]?$/ } - onTextChanged: acceptableInput ? ( _userLoginField.text === "root" ? forbiddenMessage.visible=true : ( config.setLoginName(text),userMessage.visible = false,forbiddenMessage.visible=false ) ) : ( userMessage.visible = true,console.log("Invalid") ) - palette.base: _userLoginField.text.length ? ( acceptableInput ? ( _userLoginField.text === "root" ? "#ffdae0" : "#f0fff0" ) : "#ffdae0") : "#FBFBFB" + onTextChanged: acceptableInput + ? ( _userLoginField.text === "root" + ? forbiddenMessage.visible=true + : ( config.setLoginName(text), + userMessage.visible = false,forbiddenMessage.visible=false ) ) + : ( userMessage.visible = true,console.log("Invalid") ) + + palette.base: _userLoginField.text.length + ? ( acceptableInput + ? ( _userLoginField.text === "root" + ? "#ffdae0" : "#f0fff0" ) : "#ffdae0" ) : "#FBFBFB" palette.highlight : _userLoginField.text.length ? "#dcffdc" : "#FBFBFB" } @@ -123,9 +133,19 @@ Kirigami.ScrollablePage { placeholderText: qsTr("Computer Name") text: config.hostName validator: RegularExpressionValidator { regularExpression: /[a-zA-Z0-9][-a-zA-Z0-9_]+/ } - onTextChanged: acceptableInput ? ( _hostName.text === "localhost" ? forbiddenHost.visible=true : (config.setHostName(text),hostMessage.visible = false,forbiddenHost.visible = false) ) : hostMessage.visible = true - palette.base: _hostName.text.length ? ( acceptableInput ? ( _hostName.text === "localhost" ? "#ffdae0" : "#f0fff0" ) : "#ffdae0") : "#FBFBFB" + onTextChanged: acceptableInput + ? ( _hostName.text === "localhost" + ? forbiddenHost.visible=true + : ( config.setHostName(text), + hostMessage.visible = false,forbiddenHost.visible = false ) ) + : hostMessage.visible = true + + palette.base: _hostName.text.length + ? ( acceptableInput + ? ( _hostName.text === "localhost" ? "#ffdae0" : "#f0fff0" ) + : "#ffdae0") + : "#FBFBFB" palette.highlight : _hostName.text.length ? "#dcffdc" : "#FBFBFB" } @@ -173,6 +193,7 @@ Kirigami.ScrollablePage { placeholderText: qsTr("Password") text: config.userPassword onTextChanged: config.setUserPassword(text) + palette.base: _passwordField.text.length ? "#f0fff0" : "#FBFBFB" palette.highlight : _passwordField.text.length ? "#dcffdc" : "#FBFBFB" @@ -186,9 +207,18 @@ Kirigami.ScrollablePage { width: parent.width / 2 - 10 placeholderText: qsTr("Repeat Password") text: config.userPasswordSecondary - onTextChanged: _passwordField.text === _verificationPasswordField.text ? (config.setUserPasswordSecondary(text),passMessage.visible = false) : passMessage.visible = true - palette.base: _verificationPasswordField.text.length ? ( _passwordField.text === _verificationPasswordField.text ? "#f0fff0" : "#ffdae0") : "#FBFBFB" + onTextChanged: _passwordField.text === _verificationPasswordField.text + ? ( config.setUserPasswordSecondary(text), + passMessage.visible = false, + validityMessage.visible = true ) + : ( passMessage.visible = true, + validityMessage.visible = false ) + + palette.base: _verificationPasswordField.text.length + ? ( _passwordField.text === _verificationPasswordField.text + ? "#f0fff0" : "#ffdae0" ) + : "#FBFBFB" palette.highlight : _verificationPasswordField.text.length ? "#dcffdc" : "#FBFBFB" echoMode: TextInput.Password @@ -212,7 +242,18 @@ Kirigami.ScrollablePage { Layout.fillWidth: true visible: false type: Kirigami.MessageType.Error - text: qsTr("Your passwords do not match!") + text: config.userPasswordMessage + } + + Kirigami.InlineMessage { + id: validityMessage + Layout.fillWidth: true + visible: false + type: config.userPasswordValidity + ? ( config.requireStrongPasswords + ? Kirigami.MessageType.Error : Kirigami.MessageType.Warning ) + : Kirigami.MessageType.Positive + text: config.userPasswordMessage } CheckBox { @@ -251,7 +292,9 @@ Kirigami.ScrollablePage { width: parent.width / 2 -10 placeholderText: qsTr("Root Password") text: config.rootPassword + onTextChanged: config.setRootPassword(text) + palette.base: _rootPasswordField.text.length ? "#f0fff0" : "#FBFBFB" palette.highlight : _rootPasswordField.text.length ? "#dcffdc" : "#FBFBFB" @@ -265,10 +308,17 @@ Kirigami.ScrollablePage { width: parent.width / 2 -10 placeholderText: qsTr("Repeat Root Password") text: config.rootPasswordSecondary - //onTextChanged: config.setRootPasswordSecondary(text) - onTextChanged: _rootPasswordField.text === _verificationRootPasswordField.text ? (config.setRootPasswordSecondary(text),rootPassMessage.visible = false) : rootPassMessage.visible = true - palette.base: _verificationRootPasswordField.text.length ? ( _rootPasswordField.text === _verificationRootPasswordField.text ? "#f0fff0" : "#ffdae0") : "#FBFBFB" + onTextChanged: _rootPasswordField.text === _verificationRootPasswordField.text + ? ( config.setRootPasswordSecondary(text), + rootPassMessage.visible = false, + rootValidityMessage.visible = true ) + : ( rootPassMessage.visible = true, + rootValidityMessage.visible = false ) + + palette.base: _verificationRootPasswordField.text.length + ? ( _rootPasswordField.text === _verificationRootPasswordField.text + ? "#f0fff0" : "#ffdae0") : "#FBFBFB" palette.highlight : _verificationRootPasswordField.text.length ? "#dcffdc" : "#FBFBFB" echoMode: TextInput.Password @@ -292,7 +342,19 @@ Kirigami.ScrollablePage { Layout.fillWidth: true visible: false type: Kirigami.MessageType.Error - text: qsTr("Your passwords do not match!") + text: config.rootPasswordMessage + } + + Kirigami.InlineMessage { + id: rootValidityMessage + Layout.fillWidth: true + showCloseButton: true + visible: false + type: config.rootPasswordValidity + ? ( config.requireStrongPasswords + ? Kirigami.MessageType.Error : Kirigami.MessageType.Warning ) + : Kirigami.MessageType.Positive + text: config.rootPasswordMessage } CheckBox { @@ -307,7 +369,8 @@ Kirigami.ScrollablePage { Layout.alignment: Qt.AlignCenter text: qsTr("Validate passwords quality") checked: config.requireStrongPasswords - onCheckedChanged: config.setRequireStrongPasswords(checked) + onCheckedChanged: config.setRequireStrongPasswords(checked), + rootPassMessage.visible = false } Label { From fce798dadf74bfb4d2e7c2e6270bbdfe47b1140a Mon Sep 17 00:00:00 2001 From: demmm Date: Sat, 3 Jul 2021 14:21:07 +0200 Subject: [PATCH 52/54] [users] add an OK message to password message fields empty text box on all good status in usersq is confusing --- src/modules/users/Config.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/users/Config.cpp b/src/modules/users/Config.cpp index 6560d06ac..b19d29e6a 100644 --- a/src/modules/users/Config.cpp +++ b/src/modules/users/Config.cpp @@ -545,7 +545,7 @@ Config::passwordStatus( const QString& pw1, const QString& pw2 ) const } } - return qMakePair( PasswordValidity::Valid, QString() ); + return qMakePair( PasswordValidity::Valid, tr( "OK!" ) ); } From 8b561a29f51cdaf1e9f048449d2b79ffb3e14a86 Mon Sep 17 00:00:00 2001 From: demmm Date: Sat, 3 Jul 2021 14:23:01 +0200 Subject: [PATCH 53/54] [usersq] add close button to all password message fields --- src/modules/usersq/usersq.qml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/modules/usersq/usersq.qml b/src/modules/usersq/usersq.qml index 0654c4619..2eb4be1e1 100644 --- a/src/modules/usersq/usersq.qml +++ b/src/modules/usersq/usersq.qml @@ -240,6 +240,7 @@ Kirigami.ScrollablePage { Kirigami.InlineMessage { id: passMessage Layout.fillWidth: true + showCloseButton: true visible: false type: Kirigami.MessageType.Error text: config.userPasswordMessage @@ -248,6 +249,7 @@ Kirigami.ScrollablePage { Kirigami.InlineMessage { id: validityMessage Layout.fillWidth: true + showCloseButton: true visible: false type: config.userPasswordValidity ? ( config.requireStrongPasswords @@ -340,6 +342,7 @@ Kirigami.ScrollablePage { Kirigami.InlineMessage { id: rootPassMessage Layout.fillWidth: true + showCloseButton: true visible: false type: Kirigami.MessageType.Error text: config.rootPasswordMessage From 6a7a486b8cf43462ad717378a2e61a184e048732 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 5 Jul 2021 12:28:17 +0200 Subject: [PATCH 54/54] [partition] Document interactions between defaultFS and layout --- src/modules/partition/partition.conf | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/modules/partition/partition.conf b/src/modules/partition/partition.conf index 61e955375..3213e0d33 100644 --- a/src/modules/partition/partition.conf +++ b/src/modules/partition/partition.conf @@ -215,7 +215,12 @@ availableFileSystemTypes: ["ext4", "btrfs", "f2fs"] # - uuid: partition uuid (optional parameter; gpt only; requires KPMCore >= 4.2.0) # - type: partition type (optional parameter; gpt only; requires KPMCore >= 4.2.0) # - attributes: partition attributes (optional parameter; gpt only; requires KPMCore >= 4.2.0) -# - filesystem: filesystem type (optional parameter; fs not created if "unformatted" or unset) +# - filesystem: filesystem type (optional parameter) +# - if not set at all, treat as "unformatted" +# - if "unformatted", no filesystem will be created +# - if "unknown" (or an unknown FS name, like "elephant") then the +# default filesystem type, or the user's choice, will be applied instead +# of "unknown" (e.g. the user might pick ext4, or xfs). # - mountPoint: partition mount point (optional parameter; not mounted if unset) # - size: partition size in bytes (append 'K', 'M' or 'G' for KiB, MiB or GiB) # or