mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-24 19:05:46 -05:00
[partition] Move initLayout logic to object PartitionLayout
- The logic of the method initLayout belongs to the object PartitionLayout. Move logic to that object. - Use a single method initLayout in object PartitionCoreModule. - Member m_partLayout in object PartitionCoreModule is no longer allocated.
This commit is contained in:
parent
eae1e90dce
commit
d6ea30b23e
5 changed files with 81 additions and 85 deletions
|
@ -860,82 +860,10 @@ PartitionCoreModule::setBootLoaderInstallPath( const QString& path )
|
||||||
m_bootLoaderInstallPath = path;
|
m_bootLoaderInstallPath = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
PartitionCoreModule::initLayout()
|
|
||||||
{
|
|
||||||
m_partLayout = new PartitionLayout();
|
|
||||||
|
|
||||||
m_partLayout->addEntry( QString( "/" ), QString( "100%" ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionCoreModule::initLayout( const QVariantList& config )
|
PartitionCoreModule::initLayout( const QVariantList& config )
|
||||||
{
|
{
|
||||||
bool ok;
|
m_partLayout.init( config );
|
||||||
QString sizeString;
|
|
||||||
QString minSizeString;
|
|
||||||
QString maxSizeString;
|
|
||||||
|
|
||||||
m_partLayout = new PartitionLayout();
|
|
||||||
|
|
||||||
for ( const auto& r : config )
|
|
||||||
{
|
|
||||||
QVariantMap pentry = r.toMap();
|
|
||||||
|
|
||||||
if ( !pentry.contains( "name" ) || !pentry.contains( "mountPoint" ) || !pentry.contains( "filesystem" )
|
|
||||||
|| !pentry.contains( "size" ) )
|
|
||||||
{
|
|
||||||
cError() << "Partition layout entry #" << config.indexOf( r )
|
|
||||||
<< "lacks mandatory attributes, switching to default layout.";
|
|
||||||
delete ( m_partLayout );
|
|
||||||
initLayout();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( pentry.contains( "size" ) && CalamaresUtils::getString( pentry, "size" ).isEmpty() )
|
|
||||||
{
|
|
||||||
sizeString.setNum( CalamaresUtils::getInteger( pentry, "size", 0 ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sizeString = CalamaresUtils::getString( pentry, "size" );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( pentry.contains( "minSize" ) && CalamaresUtils::getString( pentry, "minSize" ).isEmpty() )
|
|
||||||
{
|
|
||||||
minSizeString.setNum( CalamaresUtils::getInteger( pentry, "minSize", 0 ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
minSizeString = CalamaresUtils::getString( pentry, "minSize" );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( pentry.contains( "maxSize" ) && CalamaresUtils::getString( pentry, "maxSize" ).isEmpty() )
|
|
||||||
{
|
|
||||||
maxSizeString.setNum( CalamaresUtils::getInteger( pentry, "maxSize", 0 ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
maxSizeString = CalamaresUtils::getString( pentry, "maxSize" );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !m_partLayout->addEntry( CalamaresUtils::getString( pentry, "name" ),
|
|
||||||
CalamaresUtils::getString( pentry, "uuid" ),
|
|
||||||
CalamaresUtils::getString( pentry, "type" ),
|
|
||||||
CalamaresUtils::getUnsignedInteger( pentry, "attributes", 0 ),
|
|
||||||
CalamaresUtils::getString( pentry, "mountPoint" ),
|
|
||||||
CalamaresUtils::getString( pentry, "filesystem" ),
|
|
||||||
CalamaresUtils::getSubMap( pentry, "features", ok ),
|
|
||||||
sizeString,
|
|
||||||
minSizeString,
|
|
||||||
maxSizeString ) )
|
|
||||||
{
|
|
||||||
cError() << "Partition layout entry #" << config.indexOf( r ) << "is invalid, switching to default layout.";
|
|
||||||
delete ( m_partLayout );
|
|
||||||
initLayout();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -947,7 +875,7 @@ PartitionCoreModule::layoutApply( Device* dev,
|
||||||
const PartitionRole& role )
|
const PartitionRole& role )
|
||||||
{
|
{
|
||||||
bool isEfi = PartUtils::isEfiSystem();
|
bool isEfi = PartUtils::isEfiSystem();
|
||||||
QList< Partition* > partList = m_partLayout->execute( dev, firstSector, lastSector, luksPassphrase, parent, role );
|
QList< Partition* > partList = m_partLayout.execute( dev, firstSector, lastSector, luksPassphrase, parent, role );
|
||||||
|
|
||||||
// Partition::mountPoint() tells us where it is mounted **now**, while
|
// Partition::mountPoint() tells us where it is mounted **now**, while
|
||||||
// PartitionInfo::mountPoint() says where it will be mounted in the target system.
|
// PartitionInfo::mountPoint() says where it will be mounted in the target system.
|
||||||
|
|
|
@ -156,8 +156,7 @@ public:
|
||||||
/// @brief Set the path where the bootloader will be installed
|
/// @brief Set the path where the bootloader will be installed
|
||||||
void setBootLoaderInstallPath( const QString& path );
|
void setBootLoaderInstallPath( const QString& path );
|
||||||
|
|
||||||
void initLayout();
|
void initLayout( const QVariantList& config = QVariantList() );
|
||||||
void initLayout( const QVariantList& config );
|
|
||||||
|
|
||||||
void layoutApply( Device* dev, qint64 firstSector, qint64 lastSector, QString luksPassphrase );
|
void layoutApply( Device* dev, qint64 firstSector, qint64 lastSector, QString luksPassphrase );
|
||||||
void layoutApply( Device* dev,
|
void layoutApply( Device* dev,
|
||||||
|
@ -256,7 +255,7 @@ private:
|
||||||
bool m_hasRootMountPoint = false;
|
bool m_hasRootMountPoint = false;
|
||||||
bool m_isDirty = false;
|
bool m_isDirty = false;
|
||||||
QString m_bootLoaderInstallPath;
|
QString m_bootLoaderInstallPath;
|
||||||
PartitionLayout* m_partLayout;
|
PartitionLayout m_partLayout;
|
||||||
|
|
||||||
OsproberEntryList m_osproberLines;
|
OsproberEntryList m_osproberLines;
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
#include "core/PartitionActions.h"
|
#include "core/PartitionActions.h"
|
||||||
#include "core/PartitionInfo.h"
|
#include "core/PartitionInfo.h"
|
||||||
|
|
||||||
|
#include "utils/Variant.h"
|
||||||
|
|
||||||
#include <kpmcore/core/device.h>
|
#include <kpmcore/core/device.h>
|
||||||
#include <kpmcore/core/partition.h>
|
#include <kpmcore/core/partition.h>
|
||||||
#include <kpmcore/fs/filesystem.h>
|
#include <kpmcore/fs/filesystem.h>
|
||||||
|
@ -135,6 +137,79 @@ PartitionLayout::addEntry( const QString& label,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PartitionLayout::init( const QVariantList& config )
|
||||||
|
{
|
||||||
|
bool ok;
|
||||||
|
QString sizeString;
|
||||||
|
QString minSizeString;
|
||||||
|
QString maxSizeString;
|
||||||
|
|
||||||
|
m_partLayout.clear();
|
||||||
|
|
||||||
|
for ( const auto& r : config )
|
||||||
|
{
|
||||||
|
QVariantMap pentry = r.toMap();
|
||||||
|
|
||||||
|
if ( !pentry.contains( "name" ) || !pentry.contains( "mountPoint" ) || !pentry.contains( "filesystem" )
|
||||||
|
|| !pentry.contains( "size" ) )
|
||||||
|
{
|
||||||
|
cError() << "Partition layout entry #" << config.indexOf( r )
|
||||||
|
<< "lacks mandatory attributes, switching to default layout.";
|
||||||
|
m_partLayout.clear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( pentry.contains( "size" ) && CalamaresUtils::getString( pentry, "size" ).isEmpty() )
|
||||||
|
{
|
||||||
|
sizeString.setNum( CalamaresUtils::getInteger( pentry, "size", 0 ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sizeString = CalamaresUtils::getString( pentry, "size" );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( pentry.contains( "minSize" ) && CalamaresUtils::getString( pentry, "minSize" ).isEmpty() )
|
||||||
|
{
|
||||||
|
minSizeString.setNum( CalamaresUtils::getInteger( pentry, "minSize", 0 ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
minSizeString = CalamaresUtils::getString( pentry, "minSize" );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( pentry.contains( "maxSize" ) && CalamaresUtils::getString( pentry, "maxSize" ).isEmpty() )
|
||||||
|
{
|
||||||
|
maxSizeString.setNum( CalamaresUtils::getInteger( pentry, "maxSize", 0 ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
maxSizeString = CalamaresUtils::getString( pentry, "maxSize" );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !addEntry( CalamaresUtils::getString( pentry, "name" ),
|
||||||
|
CalamaresUtils::getString( pentry, "uuid" ),
|
||||||
|
CalamaresUtils::getString( pentry, "type" ),
|
||||||
|
CalamaresUtils::getUnsignedInteger( pentry, "attributes", 0 ),
|
||||||
|
CalamaresUtils::getString( pentry, "mountPoint" ),
|
||||||
|
CalamaresUtils::getString( pentry, "filesystem" ),
|
||||||
|
CalamaresUtils::getSubMap( pentry, "features", ok ),
|
||||||
|
sizeString,
|
||||||
|
minSizeString,
|
||||||
|
maxSizeString ) )
|
||||||
|
{
|
||||||
|
cError() << "Partition layout entry #" << config.indexOf( r ) << "is invalid, switching to default layout.";
|
||||||
|
m_partLayout.clear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !m_partLayout.count() )
|
||||||
|
{
|
||||||
|
addEntry( QString( "/" ), QString( "100%" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QList< Partition* >
|
QList< Partition* >
|
||||||
PartitionLayout::execute( Device* dev,
|
PartitionLayout::execute( Device* dev,
|
||||||
qint64 firstSector,
|
qint64 firstSector,
|
||||||
|
|
|
@ -62,6 +62,7 @@ public:
|
||||||
PartitionLayout( const PartitionLayout& layout );
|
PartitionLayout( const PartitionLayout& layout );
|
||||||
~PartitionLayout();
|
~PartitionLayout();
|
||||||
|
|
||||||
|
void init( const QVariantList& config );
|
||||||
bool addEntry( const QString& mountPoint,
|
bool addEntry( const QString& mountPoint,
|
||||||
const QString& size,
|
const QString& size,
|
||||||
const QString& min = QString(),
|
const QString& min = QString(),
|
||||||
|
|
|
@ -596,14 +596,7 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||||
QFuture< void > future = QtConcurrent::run( this, &PartitionViewStep::initPartitionCoreModule );
|
QFuture< void > future = QtConcurrent::run( this, &PartitionViewStep::initPartitionCoreModule );
|
||||||
m_future->setFuture( future );
|
m_future->setFuture( future );
|
||||||
|
|
||||||
if ( configurationMap.contains( "partitionLayout" ) )
|
m_core->initLayout( configurationMap.value( "partitionLayout" ).toList() );
|
||||||
{
|
|
||||||
m_core->initLayout( configurationMap.value( "partitionLayout" ).toList() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_core->initLayout();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue