|
|
|
@ -27,32 +27,10 @@
|
|
|
|
|
#include <kpmcore/core/partition.h>
|
|
|
|
|
#include <kpmcore/fs/filesystem.h>
|
|
|
|
|
|
|
|
|
|
static FileSystem::Type
|
|
|
|
|
getDefaultFileSystemType()
|
|
|
|
|
{
|
|
|
|
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
|
|
|
|
FileSystem::Type defaultFS = FileSystem::Ext4;
|
|
|
|
|
|
|
|
|
|
if ( gs->contains( "defaultFileSystemType" ) )
|
|
|
|
|
{
|
|
|
|
|
PartUtils::findFS( gs->value( "defaultFileSystemType" ).toString(), &defaultFS );
|
|
|
|
|
if ( defaultFS == FileSystem::Unknown )
|
|
|
|
|
{
|
|
|
|
|
defaultFS = FileSystem::Ext4;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return defaultFS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PartitionLayout::PartitionLayout()
|
|
|
|
|
: m_defaultFsType( getDefaultFileSystemType() )
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
PartitionLayout::PartitionLayout() {}
|
|
|
|
|
|
|
|
|
|
PartitionLayout::PartitionLayout( const PartitionLayout& layout )
|
|
|
|
|
: m_defaultFsType( layout.m_defaultFsType )
|
|
|
|
|
, m_partLayout( layout.m_partLayout )
|
|
|
|
|
: m_partLayout( layout.m_partLayout )
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -63,10 +41,14 @@ PartitionLayout::PartitionEntry::PartitionEntry()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PartitionLayout::PartitionEntry::PartitionEntry( FileSystem::Type type, const QString& mountPoint, const QString& size, const QString& minSize, const QString& maxSize )
|
|
|
|
|
: partType( type )
|
|
|
|
|
, partAttributes( 0 )
|
|
|
|
|
PartitionLayout::PartitionEntry::PartitionEntry( FileSystem::Type fs,
|
|
|
|
|
const QString& mountPoint,
|
|
|
|
|
const QString& size,
|
|
|
|
|
const QString& minSize,
|
|
|
|
|
const QString& maxSize )
|
|
|
|
|
: partAttributes( 0 )
|
|
|
|
|
, partMountPoint( mountPoint )
|
|
|
|
|
, partFileSystem( fs )
|
|
|
|
|
, partSize( size )
|
|
|
|
|
, partMinSize( minSize )
|
|
|
|
|
, partMaxSize( maxSize )
|
|
|
|
@ -111,7 +93,7 @@ PartitionLayout::addEntry( const PartitionEntry& entry )
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
PartitionLayout::init( const QVariantList& config )
|
|
|
|
|
PartitionLayout::init( FileSystem::Type defaultFsType, const QVariantList& config )
|
|
|
|
|
{
|
|
|
|
|
bool ok;
|
|
|
|
|
|
|
|
|
@ -149,7 +131,7 @@ PartitionLayout::init( const QVariantList& config )
|
|
|
|
|
|
|
|
|
|
if ( !m_partLayout.count() )
|
|
|
|
|
{
|
|
|
|
|
addEntry( { m_defaultFsType, QString( "/" ), QString( "100%" ) } );
|
|
|
|
|
addEntry( { defaultFsType, QString( "/" ), QString( "100%" ) } );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -215,8 +197,8 @@ PartitionLayout::createPartitions( Device* dev,
|
|
|
|
|
{
|
|
|
|
|
if ( entry.partSize.unit() == CalamaresUtils::Partition::SizeUnit::Percent )
|
|
|
|
|
{
|
|
|
|
|
qint64 sectors = entry.partSize.toSectors( availableSectors + partSectorsMap.value( &entry ),
|
|
|
|
|
dev->logicalSize() );
|
|
|
|
|
qint64 sectors
|
|
|
|
|
= entry.partSize.toSectors( availableSectors + partSectorsMap.value( &entry ), dev->logicalSize() );
|
|
|
|
|
if ( entry.partMinSize.isValid() )
|
|
|
|
|
{
|
|
|
|
|
sectors = std::max( sectors, entry.partMinSize.toSectors( totalSectors, dev->logicalSize() ) );
|
|
|
|
@ -245,13 +227,24 @@ PartitionLayout::createPartitions( Device* dev,
|
|
|
|
|
Partition* part = nullptr;
|
|
|
|
|
if ( luksPassphrase.isEmpty() )
|
|
|
|
|
{
|
|
|
|
|
part = KPMHelpers::createNewPartition(
|
|
|
|
|
parent, *dev, role, entry.partFileSystem, currentSector, currentSector + sectors - 1, KPM_PARTITION_FLAG( None ) );
|
|
|
|
|
part = KPMHelpers::createNewPartition( parent,
|
|
|
|
|
*dev,
|
|
|
|
|
role,
|
|
|
|
|
entry.partFileSystem,
|
|
|
|
|
currentSector,
|
|
|
|
|
currentSector + sectors - 1,
|
|
|
|
|
KPM_PARTITION_FLAG( None ) );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
part = KPMHelpers::createNewEncryptedPartition(
|
|
|
|
|
parent, *dev, role, entry.partFileSystem, currentSector, currentSector + sectors - 1, luksPassphrase, KPM_PARTITION_FLAG( None ) );
|
|
|
|
|
part = KPMHelpers::createNewEncryptedPartition( parent,
|
|
|
|
|
*dev,
|
|
|
|
|
role,
|
|
|
|
|
entry.partFileSystem,
|
|
|
|
|
currentSector,
|
|
|
|
|
currentSector + sectors - 1,
|
|
|
|
|
luksPassphrase,
|
|
|
|
|
KPM_PARTITION_FLAG( None ) );
|
|
|
|
|
}
|
|
|
|
|
PartitionInfo::setFormat( part, true );
|
|
|
|
|
PartitionInfo::setMountPoint( part, entry.partMountPoint );
|
|
|
|
|