partition: simplify Arm code
- introduce a helper function for accessing the globalstorage value - add consts and calculate the initial gap in a single expression
This commit is contained in:
parent
baf580f0ac
commit
e7161443d6
@ -441,17 +441,16 @@ runOsprober( DeviceModel* dm )
|
||||
}
|
||||
|
||||
bool
|
||||
isEfiSystem()
|
||||
isArmSystem()
|
||||
{
|
||||
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||
if ( gs->contains( "armInstall" ) && gs->value( "armInstall" ).toBool() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return QDir( "/sys/firmware/efi/efivars" ).exists();
|
||||
}
|
||||
return gs->contains( "armInstall" ) && gs->value( "armInstall" ).toBool() );
|
||||
}
|
||||
|
||||
bool
|
||||
isEfiSystem()
|
||||
{
|
||||
return isArmSystem() || QDir( "/sys/firmware/efi/efivars" ).exists();
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -77,6 +77,11 @@ bool canBeResized( DeviceModel* dm, const QString& partitionPath, const Logger::
|
||||
*/
|
||||
OsproberEntryList runOsprober( DeviceModel* dm );
|
||||
|
||||
/**
|
||||
* @brief Is this an ARM-based system? Set in the configuration file
|
||||
*/
|
||||
bool isArmSystem();
|
||||
|
||||
/**
|
||||
* @brief Is this system EFI-enabled? Decides based on /sys/firmware/efi
|
||||
*/
|
||||
|
@ -89,22 +89,15 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO
|
||||
{
|
||||
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||
|
||||
bool isEfi = PartUtils::isEfiSystem();
|
||||
const bool isEfi = PartUtils::isEfiSystem();
|
||||
|
||||
// Partition sizes are expressed in MiB, should be multiples of
|
||||
// the logical sector size (usually 512B). EFI starts with 2MiB
|
||||
// empty and a EFI boot partition, while BIOS starts at
|
||||
// the 1MiB boundary (usually sector 2048).
|
||||
// ARM empty sectors are 16 MiB in size.
|
||||
int empty_space_sizeB;
|
||||
if ( gs->contains( "armInstall" ) && gs->value( "armInstall" ).toBool() )
|
||||
{
|
||||
empty_space_sizeB = 16_MiB;
|
||||
}
|
||||
else
|
||||
{
|
||||
empty_space_sizeB = isEfi ? 2_MiB : 1_MiB;
|
||||
}
|
||||
const int empty_space_sizeB = PartUtils::isArmSystem() ? 16_MiB : ( isEfi ? 2_MiB : 1_MiB );
|
||||
|
||||
// Since sectors count from 0, if the space is 2048 sectors in size,
|
||||
// the first free sector has number 2048 (and there are 2048 sectors
|
||||
// before that one, numbered 0..2047).
|
||||
|
Loading…
Reference in New Issue
Block a user