[partition] Initialize partition layout from config file

In order to keep the partition layout during calamares' execution, we
add a PartitionLayout object instance to PartitionCoreModule. This class
will therefore be used to initialize the PartitionLayout object and
interact with it thoughout the program's execution.

When no partition layout is present in the config file, we initialize
the layout with a single ext4 partition mounted on '/', as it was
previously done.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
This commit is contained in:
Arnaud Ferraris 2019-01-07 17:25:39 +01:00
parent f1ead5193d
commit b2bf873ede
3 changed files with 41 additions and 0 deletions

View file

@ -43,6 +43,7 @@
#include "jobs/ResizePartitionJob.h"
#include "jobs/ResizeVolumeGroupJob.h"
#include "jobs/SetPartitionFlagsJob.h"
#include "utils/CalamaresUtils.h"
#include "Typedefs.h"
#include "utils/Logger.h"
@ -760,6 +761,32 @@ PartitionCoreModule::setBootLoaderInstallPath( const QString& path )
m_bootLoaderInstallPath = path;
}
void
PartitionCoreModule::initLayout()
{
m_partLayout = new PartitionLayout();
m_partLayout->addEntry( QString("/"), QString("100%") );
}
void
PartitionCoreModule::initLayout( const QVariantList& config )
{
m_partLayout = new PartitionLayout();
for ( const auto& r : config )
{
QVariantMap pentry = r.toMap();
m_partLayout->addEntry( CalamaresUtils::getString( pentry, "name" ),
CalamaresUtils::getString( pentry, "mountPoint" ),
CalamaresUtils::getString( pentry, "filesystem" ),
CalamaresUtils::getString( pentry, "size" ),
CalamaresUtils::getString( pentry, "minSize" )
);
}
}
void
PartitionCoreModule::revert()
{

View file

@ -20,6 +20,7 @@
#ifndef PARTITIONCOREMODULE_H
#define PARTITIONCOREMODULE_H
#include "core/PartitionLayout.h"
#include "core/PartitionModel.h"
#include "Typedefs.h"
@ -155,6 +156,9 @@ public:
void setBootLoaderInstallPath( const QString& path );
void initLayout();
void initLayout( const QVariantList& config );
/**
* @brief jobs creates and returns a list of jobs which can then apply the changes
* requested by the user.
@ -246,6 +250,7 @@ private:
bool m_hasRootMountPoint = false;
bool m_isDirty = false;
QString m_bootLoaderInstallPath;
PartitionLayout* m_partLayout;
void doInit();
void updateHasRootMountPoint();

View file

@ -610,6 +610,15 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
QFuture< void > future =
QtConcurrent::run( this, &PartitionViewStep::initPartitionCoreModule );
watcher->setFuture( future );
if ( configurationMap.contains( "partitionLayout" ) )
{
m_core->initLayout( configurationMap.values( "partitionLayout" ).at(0).toList() );
}
else
{
m_core->initLayout();
}
}