|
|
|
@ -166,14 +166,13 @@ PartitionLayout::execute( Device* dev,
|
|
|
|
|
QList< Partition* > partList;
|
|
|
|
|
// Map each partition entry to its requested size (0 when calculated later)
|
|
|
|
|
QMap< const PartitionLayout::PartitionEntry *, qint64 > partSizeMap;
|
|
|
|
|
qint64 minSize, maxSize, end;
|
|
|
|
|
qint64 totalSize = lastSector - firstSector + 1;
|
|
|
|
|
qint64 availableSize = totalSize;
|
|
|
|
|
|
|
|
|
|
// Let's check if we have enough space for each partSize
|
|
|
|
|
for( const PartitionLayout::PartitionEntry& part : m_partLayout )
|
|
|
|
|
for( const auto& part : qAsConst(m_partLayout) )
|
|
|
|
|
{
|
|
|
|
|
qint64 size = -1;
|
|
|
|
|
qint64 size;
|
|
|
|
|
// Calculate partition size
|
|
|
|
|
|
|
|
|
|
if ( part.partSize.isValid() )
|
|
|
|
@ -201,7 +200,7 @@ PartitionLayout::execute( Device* dev,
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
partSizeMap.insert (&part, size);
|
|
|
|
|
partSizeMap.insert(&part, size);
|
|
|
|
|
availableSize -= size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -209,7 +208,7 @@ PartitionLayout::execute( Device* dev,
|
|
|
|
|
if (availableSize < 0)
|
|
|
|
|
{
|
|
|
|
|
availableSize = totalSize;
|
|
|
|
|
for( const PartitionLayout::PartitionEntry& part : m_partLayout )
|
|
|
|
|
for( const auto& part : qAsConst(m_partLayout) )
|
|
|
|
|
{
|
|
|
|
|
qint64 size;
|
|
|
|
|
|
|
|
|
@ -233,19 +232,18 @@ PartitionLayout::execute( Device* dev,
|
|
|
|
|
size = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
partSizeMap.insert (&part, size);
|
|
|
|
|
partSizeMap.insert(&part, size);
|
|
|
|
|
availableSize -= size;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Assign size for percentage-defined partitions
|
|
|
|
|
for( const PartitionLayout::PartitionEntry& part : m_partLayout )
|
|
|
|
|
for( const auto& part : qAsConst(m_partLayout) )
|
|
|
|
|
{
|
|
|
|
|
if ( part.partSize.unit() == CalamaresUtils::Partition::SizeUnit::Percent)
|
|
|
|
|
{
|
|
|
|
|
qint64 size = partSizeMap.value (&part);
|
|
|
|
|
qint64 size = partSizeMap.value(&part);
|
|
|
|
|
size = part.partSize.toSectors( availableSize + size, dev->logicalSize() );
|
|
|
|
|
partSizeMap.insert (&part, size);
|
|
|
|
|
if ( part.partMinSize.isValid() )
|
|
|
|
|
{
|
|
|
|
|
qint64 minSize = part.partMinSize.toSectors( totalSize, dev->logicalSize() );
|
|
|
|
@ -262,6 +260,8 @@ PartitionLayout::execute( Device* dev,
|
|
|
|
|
size = maxSize;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
partSizeMap.insert(&part, size);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -270,21 +270,20 @@ PartitionLayout::execute( Device* dev,
|
|
|
|
|
// TODO: Refine partition sizes to make sure there is room for every partition
|
|
|
|
|
// Use a default (200-500M ?) minimum size for partition without minSize
|
|
|
|
|
|
|
|
|
|
for( const PartitionLayout::PartitionEntry& part : m_partLayout )
|
|
|
|
|
for( const auto& part : qAsConst(m_partLayout) )
|
|
|
|
|
{
|
|
|
|
|
qint64 size = partSizeMap.value (&part);
|
|
|
|
|
qint64 size, end;
|
|
|
|
|
Partition* currentPartition = nullptr;
|
|
|
|
|
|
|
|
|
|
// Adjust partition size based on user-defined boundaries and available space
|
|
|
|
|
if ( size > maxSize )
|
|
|
|
|
{
|
|
|
|
|
size = maxSize;
|
|
|
|
|
}
|
|
|
|
|
size = partSizeMap.value(&part);
|
|
|
|
|
|
|
|
|
|
// Adjust partition size based on available space
|
|
|
|
|
if ( size > availableSize )
|
|
|
|
|
{
|
|
|
|
|
size = availableSize;
|
|
|
|
|
}
|
|
|
|
|
end = firstSector + size - 1;
|
|
|
|
|
|
|
|
|
|
end = firstSector + std::max(size - 1, Q_INT64_C(0));
|
|
|
|
|
|
|
|
|
|
if ( luksPassphrase.isEmpty() )
|
|
|
|
|
{
|
|
|
|
|