calamares/calamares-1.1.2-openmamba_autopartitioning.patch

91 lines
3.6 KiB
Diff

--- calamares-1.1.2.orig/src/modules/partition/gui/EraseDiskPage.cpp 2015-08-10 16:20:20.000000000 +0200
+++ calamares-1.1.2/src/modules/partition/gui/EraseDiskPage.cpp 2015-08-13 10:32:06.442017396 +0200
@@ -181,24 +181,35 @@
m_core->createPartitionTable( dev, PartitionTable::msdos );
}
+ qint64 suggestedRootSizeB =
+ ( Calamares::JobQueue::instance()->
+ globalStorage()->
+ value( "requiredStorageGB" ).toDouble() + 0.1 + 20.0 ) GiB;
+
bool shouldCreateSwap = false;
qint64 availableSpaceB = ( dev->totalSectors() - firstFreeSector ) * dev->logicalSectorSize();
qint64 suggestedSwapSizeB = swapSuggestion( availableSpaceB );
- qint64 requiredSpaceB =
- ( Calamares::JobQueue::instance()->
- globalStorage()->
- value( "requiredStorageGB" ).toDouble() + 0.1 + 2.0 ) GiB +
- suggestedSwapSizeB;
+ qint64 requiredSpaceB = suggestedRootSizeB + suggestedSwapSizeB;
// If there is enough room for ESP + root + swap, create swap, otherwise don't.
shouldCreateSwap = availableSpaceB > requiredSpaceB;
- qint64 lastSectorForRoot = dev->totalSectors() - 1; //last sector of the device
- if ( shouldCreateSwap )
- {
- lastSectorForRoot -= suggestedSwapSizeB / dev->logicalSectorSize() + 1;
+ bool shouldCreateHome = false;
+ if ( shouldCreateSwap ) {
+ availableSpaceB -= requiredSpaceB;
+ qint64 suggestedHomeSizeB = 30 GiB;
+ requiredSpaceB += suggestedHomeSizeB;
+
+ // If there is enough room for ESP + root + swap, create swap, otherwise don't.
+ shouldCreateHome = availableSpaceB > requiredSpaceB;
+ if ( !shouldCreateHome ) {
+ suggestedRootSizeB = availableSpaceB - suggestedSwapSizeB;
+ }
+ } else {
+ suggestedRootSizeB = availableSpaceB;
}
+ qint64 lastSectorForRoot = firstFreeSector + suggestedRootSizeB / dev->logicalSectorSize() - 1;
Partition* rootPartition = PMUtils::createNewPartition(
dev->partitionTable(),
*dev,
@@ -210,21 +221,40 @@
PartitionInfo::setFormat( rootPartition, true );
PartitionInfo::setMountPoint( rootPartition, "/" );
m_core->createPartition( dev, rootPartition );
+ firstFreeSector = firstFreeSector + suggestedRootSizeB / dev->logicalSectorSize();
if ( shouldCreateSwap )
{
+ qint64 lastSectorForSwap = firstFreeSector + suggestedSwapSizeB / dev->logicalSectorSize() - 1;
Partition* swapPartition = PMUtils::createNewPartition(
dev->partitionTable(),
*dev,
PartitionRole( PartitionRole::Primary ),
FileSystem::LinuxSwap,
- lastSectorForRoot + 1,
- dev->totalSectors() - 1
+ firstFreeSector,
+ lastSectorForSwap
);
PartitionInfo::setFormat( swapPartition, true );
m_core->createPartition( dev, swapPartition );
+ firstFreeSector = firstFreeSector + suggestedSwapSizeB / dev->logicalSectorSize();
}
+ if ( shouldCreateHome )
+ {
+ Partition* homePartition = PMUtils::createNewPartition(
+ dev->partitionTable(),
+ *dev,
+ PartitionRole( PartitionRole::Primary ),
+ FileSystem::Ext4,
+ firstFreeSector,
+ dev->totalSectors() - 1
+ );
+ PartitionInfo::setFormat( homePartition, true );
+ m_core->createPartition( dev, homePartition );
+ }
+
+ m_core->setBootLoaderInstallPath( dev->deviceNode() );
+
updatePreviews();
m_core->dumpQueue();