Merge pull request #1519 from tintou/calamares
[partition] Fix regression in partition size assignment
This commit is contained in:
commit
ae09537bea
@ -166,14 +166,13 @@ PartitionLayout::execute( Device* dev,
|
|||||||
QList< Partition* > partList;
|
QList< Partition* > partList;
|
||||||
// Map each partition entry to its requested size (0 when calculated later)
|
// Map each partition entry to its requested size (0 when calculated later)
|
||||||
QMap< const PartitionLayout::PartitionEntry *, qint64 > partSizeMap;
|
QMap< const PartitionLayout::PartitionEntry *, qint64 > partSizeMap;
|
||||||
qint64 minSize, maxSize, end;
|
|
||||||
qint64 totalSize = lastSector - firstSector + 1;
|
qint64 totalSize = lastSector - firstSector + 1;
|
||||||
qint64 availableSize = totalSize;
|
qint64 availableSize = totalSize;
|
||||||
|
|
||||||
// Let's check if we have enough space for each partSize
|
// 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
|
// Calculate partition size
|
||||||
|
|
||||||
if ( part.partSize.isValid() )
|
if ( part.partSize.isValid() )
|
||||||
@ -201,7 +200,7 @@ PartitionLayout::execute( Device* dev,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
partSizeMap.insert (&part, size);
|
partSizeMap.insert(&part, size);
|
||||||
availableSize -= size;
|
availableSize -= size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,7 +208,7 @@ PartitionLayout::execute( Device* dev,
|
|||||||
if (availableSize < 0)
|
if (availableSize < 0)
|
||||||
{
|
{
|
||||||
availableSize = totalSize;
|
availableSize = totalSize;
|
||||||
for( const PartitionLayout::PartitionEntry& part : m_partLayout )
|
for( const auto& part : qAsConst(m_partLayout) )
|
||||||
{
|
{
|
||||||
qint64 size;
|
qint64 size;
|
||||||
|
|
||||||
@ -233,19 +232,18 @@ PartitionLayout::execute( Device* dev,
|
|||||||
size = 0;
|
size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
partSizeMap.insert (&part, size);
|
partSizeMap.insert(&part, size);
|
||||||
availableSize -= size;
|
availableSize -= size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign size for percentage-defined partitions
|
// 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)
|
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() );
|
size = part.partSize.toSectors( availableSize + size, dev->logicalSize() );
|
||||||
partSizeMap.insert (&part, size);
|
|
||||||
if ( part.partMinSize.isValid() )
|
if ( part.partMinSize.isValid() )
|
||||||
{
|
{
|
||||||
qint64 minSize = part.partMinSize.toSectors( totalSize, dev->logicalSize() );
|
qint64 minSize = part.partMinSize.toSectors( totalSize, dev->logicalSize() );
|
||||||
@ -262,6 +260,8 @@ PartitionLayout::execute( Device* dev,
|
|||||||
size = maxSize;
|
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
|
// TODO: Refine partition sizes to make sure there is room for every partition
|
||||||
// Use a default (200-500M ?) minimum size for partition without minSize
|
// 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;
|
Partition* currentPartition = nullptr;
|
||||||
|
|
||||||
// Adjust partition size based on user-defined boundaries and available space
|
size = partSizeMap.value(&part);
|
||||||
if ( size > maxSize )
|
|
||||||
{
|
// Adjust partition size based on available space
|
||||||
size = maxSize;
|
|
||||||
}
|
|
||||||
if ( size > availableSize )
|
if ( size > availableSize )
|
||||||
{
|
{
|
||||||
size = availableSize;
|
size = availableSize;
|
||||||
}
|
}
|
||||||
end = firstSector + size - 1;
|
|
||||||
|
end = firstSector + std::max(size - 1, Q_INT64_C(0));
|
||||||
|
|
||||||
if ( luksPassphrase.isEmpty() )
|
if ( luksPassphrase.isEmpty() )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user