From ba673b17eec657323e4fd57cba18efc0a22a2905 Mon Sep 17 00:00:00 2001 From: Arnaud Ferraris Date: Mon, 7 Jan 2019 17:27:40 +0100 Subject: [PATCH] [partition] Add configuration option to disable manual partitioning In some cases where a custom partition layout is used, use of this layout is mandatory (this can be the case when using a read-only rootfs which is updated by block-cpying an image file to it). For these cases, the user must not be able to change the partition layout, therefore we have to disable manual partitioning. In order to stay consistent with current behaviour, manual partitioning is still enabled by default. It will only be disabled if the partition module's config file contains the corresponding option set to "false". Signed-off-by: Arnaud Ferraris --- src/modules/partition/gui/ChoicePage.cpp | 10 ++++++++-- src/modules/partition/gui/ChoicePage.h | 2 ++ src/modules/partition/gui/PartitionViewStep.cpp | 1 + src/modules/partition/partition.conf | 10 ++++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index 1b2cf5a69..6b703cb00 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -92,6 +92,7 @@ ChoicePage::ChoicePage( QWidget* parent ) , m_bootloaderComboBox( nullptr ) , m_lastSelectedDeviceIndex( -1 ) , m_enableEncryptionWidget( true ) + , m_allowManualPartitioning( true ) { setupUi( this ); @@ -101,6 +102,9 @@ ChoicePage::ChoicePage( QWidget* parent ) m_enableEncryptionWidget = Calamares::JobQueue::instance()-> globalStorage()-> value( "enableLuksAutomatedPartitioning" ).toBool(); + m_allowManualPartitioning = Calamares::JobQueue::instance()-> + globalStorage()-> + value( "allowManualPartitioning" ).toBool(); if ( FileSystem::typeForName( m_defaultFsType ) == FileSystem::Unknown ) m_defaultFsType = "ext4"; @@ -1214,8 +1218,10 @@ ChoicePage::setupActions() else m_deviceInfoWidget->setPartitionTableType( PartitionTable::unknownTableType ); - // Manual partitioning is always a possibility - m_somethingElseButton->show(); + if ( m_allowManualPartitioning ) + m_somethingElseButton->show(); + else + force_uncheck( m_grp, m_somethingElseButton ); bool atLeastOneCanBeResized = false; bool atLeastOneCanBeReplaced = false; diff --git a/src/modules/partition/gui/ChoicePage.h b/src/modules/partition/gui/ChoicePage.h index 07d052c2d..0def84bd4 100644 --- a/src/modules/partition/gui/ChoicePage.h +++ b/src/modules/partition/gui/ChoicePage.h @@ -165,6 +165,8 @@ private: QString m_defaultFsType; bool m_enableEncryptionWidget; + bool m_allowManualPartitioning; + QMutex m_coreMutex; }; diff --git a/src/modules/partition/gui/PartitionViewStep.cpp b/src/modules/partition/gui/PartitionViewStep.cpp index 9c94e87d7..1ad76ae17 100644 --- a/src/modules/partition/gui/PartitionViewStep.cpp +++ b/src/modules/partition/gui/PartitionViewStep.cpp @@ -570,6 +570,7 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap ) gs->insert( "drawNestedPartitions", CalamaresUtils::getBool( configurationMap, "drawNestedPartitions", false ) ); gs->insert( "alwaysShowPartitionLabels", CalamaresUtils::getBool( configurationMap, "alwaysShowPartitionLabels", true ) ); gs->insert( "enableLuksAutomatedPartitioning", CalamaresUtils::getBool( configurationMap, "enableLuksAutomatedPartitioning", true ) ); + gs->insert( "allowManualPartitioning", CalamaresUtils::getBool( configurationMap, "allowManualPartitioning", true ) ); QString defaultFS = CalamaresUtils::getString( configurationMap, "defaultFileSystemType" ); if ( defaultFS.isEmpty() ) diff --git a/src/modules/partition/partition.conf b/src/modules/partition/partition.conf index 1c5ece8f8..a7483f36f 100644 --- a/src/modules/partition/partition.conf +++ b/src/modules/partition/partition.conf @@ -78,6 +78,16 @@ defaultFileSystemType: "ext4" # If nothing is specified, LUKS is enabled in automated modes. #enableLuksAutomatedPartitioning: true +# Allow manual partitioning. +# +# When set to false, this option hides the "Manual partitioning" button, +# limiting the user's choice to "Erase", "Replace" or "Alongside". +# This can be useful when using a custom partition layout we don't want +# the user to modify. +# +# If nothing is specified, manual partitioning is enabled. +#allowManualPartitioning: true + # To apply a custom partition layout, it has to be defined this way : # # partitionLayout: