[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 <arnaud.ferraris@collabora.com>
This commit is contained in:
Arnaud Ferraris 2019-01-07 17:27:40 +01:00
parent 2f14a21456
commit ba673b17ee
4 changed files with 21 additions and 2 deletions

View File

@ -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;

View File

@ -165,6 +165,8 @@ private:
QString m_defaultFsType;
bool m_enableEncryptionWidget;
bool m_allowManualPartitioning;
QMutex m_coreMutex;
};

View File

@ -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() )

View File

@ -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: