Refactor check for EFI system.

The TODO stands, to delegate this to KPMCore.
This commit is contained in:
Adriaan de Groot 2017-08-28 05:36:21 -04:00 committed by Philip
parent e6e1324353
commit 3b15884f83
10 changed files with 31 additions and 21 deletions

View File

@ -151,7 +151,7 @@ canBeResized( PartitionCoreModule* core, const QString& partitionPath )
} }
FstabEntryList static FstabEntryList
lookForFstabEntries( const QString& partitionPath ) lookForFstabEntries( const QString& partitionPath )
{ {
FstabEntryList fstabEntries; FstabEntryList fstabEntries;
@ -195,7 +195,7 @@ lookForFstabEntries( const QString& partitionPath )
} }
QString static QString
findPartitionPathForMountPoint( const FstabEntryList& fstab, findPartitionPathForMountPoint( const FstabEntryList& fstab,
const QString& mountPoint ) const QString& mountPoint )
{ {
@ -328,4 +328,10 @@ runOsprober( PartitionCoreModule* core )
return osproberEntries; return osproberEntries;
} }
bool
isEfiSystem()
{
return QDir( "/sys/firmware/efi/efivars" ).exists();
}
} // nmamespace PartUtils } // nmamespace PartUtils

View File

@ -62,6 +62,11 @@ bool canBeResized( PartitionCoreModule* core, const QString& partitionPath );
*/ */
OsproberEntryList runOsprober( PartitionCoreModule* core ); OsproberEntryList runOsprober( PartitionCoreModule* core );
/**
* @brief Is this system EFI-enabled? Decides based on /sys/firmware/efi
*/
bool isEfiSystem();
} }
#endif // PARTUTILS_H #endif // PARTUTILS_H

View File

@ -22,6 +22,7 @@
#include "core/KPMHelpers.h" #include "core/KPMHelpers.h"
#include "core/PartitionInfo.h" #include "core/PartitionInfo.h"
#include "core/PartitionCoreModule.h" #include "core/PartitionCoreModule.h"
#include "core/PartUtils.h"
#include "utils/CalamaresUtilsSystem.h" #include "utils/CalamaresUtilsSystem.h"
#include "JobQueue.h" #include "JobQueue.h"
@ -118,9 +119,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, const QString& luksPass
{ {
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
bool isEfi = false; bool isEfi = PartUtils::isEfiSystem();
if ( QDir( "/sys/firmware/efi/efivars" ).exists() )
isEfi = true;
QString defaultFsType = gs->value( "defaultFileSystemType" ).toString(); QString defaultFsType = gs->value( "defaultFileSystemType" ).toString();
if ( FileSystem::typeForName( defaultFsType ) == FileSystem::Unknown ) if ( FileSystem::typeForName( defaultFsType ) == FileSystem::Unknown )

View File

@ -167,7 +167,7 @@ PartitionCoreModule::doInit()
//FIXME: this should be removed in favor of //FIXME: this should be removed in favor of
// proper KPM support for EFI // proper KPM support for EFI
if ( QDir( "/sys/firmware/efi/efivars" ).exists() ) if ( PartUtils::isEfiSystem() )
scanForEfiSystemPartitions(); scanForEfiSystemPartitions();
} }
@ -461,7 +461,7 @@ PartitionCoreModule::refresh()
//FIXME: this should be removed in favor of //FIXME: this should be removed in favor of
// proper KPM support for EFI // proper KPM support for EFI
if ( QDir( "/sys/firmware/efi/efivars" ).exists() ) if ( PartUtils::isEfiSystem() )
scanForEfiSystemPartitions(); scanForEfiSystemPartitions();
} }

View File

@ -18,8 +18,9 @@
#include "BootInfoWidget.h" #include "BootInfoWidget.h"
#include "core/PartUtils.h"
#include <utils/CalamaresUtilsGui.h> #include "utils/CalamaresUtilsGui.h"
#include <QDir> #include <QDir>
#include <QLabel> #include <QLabel>
@ -64,12 +65,8 @@ BootInfoWidget::BootInfoWidget( QWidget* parent )
"may also show up as BIOS if started in compatibility " "may also show up as BIOS if started in compatibility "
"mode." ) ); "mode." ) );
bool isEfi = false;
if ( QDir( "/sys/firmware/efi/efivars" ).exists() )
isEfi = true;
QString bootToolTip; QString bootToolTip;
if ( isEfi ) if ( PartUtils::isEfiSystem() )
{ {
m_bootLabel->setText( "EFI " ); m_bootLabel->setText( "EFI " );
bootToolTip = tr( "This system was started with an <strong>EFI</strong> " bootToolTip = tr( "This system was started with an <strong>EFI</strong> "

View File

@ -146,7 +146,7 @@ void
ChoicePage::init( PartitionCoreModule* core ) ChoicePage::init( PartitionCoreModule* core )
{ {
m_core = core; m_core = core;
m_isEfi = QDir( "/sys/firmware/efi/efivars" ).exists(); m_isEfi = PartUtils::isEfiSystem();
setupChoices(); setupChoices();
@ -680,7 +680,7 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current )
m_core->revertDevice( selectedDevice() ); m_core->revertDevice( selectedDevice() );
} }
// if the partition is unallocated(free space), we don't replace it but create new one // if the partition is unallocated(free space), we don't replace it but create new one
// with the same first and last sector // with the same first and last sector
Partition* selectedPartition = Partition* selectedPartition =
static_cast< Partition* >( current.data( PartitionModel::PartitionPtrRole ) static_cast< Partition* >( current.data( PartitionModel::PartitionPtrRole )
@ -1311,7 +1311,7 @@ ChoicePage::setupActions()
m_grp->setExclusive( true ); m_grp->setExclusive( true );
} }
bool isEfi = QDir( "/sys/firmware/efi/efivars" ).exists(); bool isEfi = PartUtils::isEfiSystem();
bool efiSystemPartitionFound = !m_core->efiSystemPartitions().isEmpty(); bool efiSystemPartitionFound = !m_core->efiSystemPartitions().isEmpty();
if ( isEfi && !efiSystemPartitionFound ) if ( isEfi && !efiSystemPartitionFound )

View File

@ -21,6 +21,7 @@
#include "core/ColorUtils.h" #include "core/ColorUtils.h"
#include "core/PartitionInfo.h" #include "core/PartitionInfo.h"
#include "core/PartUtils.h"
#include "core/KPMHelpers.h" #include "core/KPMHelpers.h"
#include "gui/PartitionSizeController.h" #include "gui/PartitionSizeController.h"
@ -66,12 +67,12 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* par
m_ui->encryptWidget->hide(); m_ui->encryptWidget->hide();
QStringList mountPoints = { "/", "/boot", "/home", "/opt", "/usr", "/var" }; QStringList mountPoints = { "/", "/boot", "/home", "/opt", "/usr", "/var" };
if ( QDir( "/sys/firmware/efi/efivars" ).exists() ) if ( PartUtils::isEfiSystem() )
mountPoints << Calamares::JobQueue::instance()->globalStorage()->value( "efiSystemPartition" ).toString(); mountPoints << Calamares::JobQueue::instance()->globalStorage()->value( "efiSystemPartition" ).toString();
mountPoints.removeDuplicates(); mountPoints.removeDuplicates();
mountPoints.sort(); mountPoints.sort();
m_ui->mountPointComboBox->addItems( mountPoints ); m_ui->mountPointComboBox->addItems( mountPoints );
if ( device->partitionTable()->type() == PartitionTable::msdos || if ( device->partitionTable()->type() == PartitionTable::msdos ||
device->partitionTable()->type() == PartitionTable::msdos_sectorbased ) device->partitionTable()->type() == PartitionTable::msdos_sectorbased )
initMbrPartitionTypeUi(); initMbrPartitionTypeUi();

View File

@ -26,6 +26,7 @@
#include <core/ColorUtils.h> #include <core/ColorUtils.h>
#include <core/PartitionCoreModule.h> #include <core/PartitionCoreModule.h>
#include <core/PartitionInfo.h> #include <core/PartitionInfo.h>
#include "core/PartUtils.h"
#include <core/KPMHelpers.h> #include <core/KPMHelpers.h>
#include <gui/PartitionSizeController.h> #include <gui/PartitionSizeController.h>
@ -56,7 +57,7 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, Partit
m_ui->setupUi( this ); m_ui->setupUi( this );
QStringList mountPoints = { "/", "/boot", "/home", "/opt", "/usr", "/var" }; QStringList mountPoints = { "/", "/boot", "/home", "/opt", "/usr", "/var" };
if ( QDir( "/sys/firmware/efi/efivars" ).exists() ) if ( PartUtils::isEfiSystem() )
mountPoints << Calamares::JobQueue::instance()->globalStorage()->value( "efiSystemPartition" ).toString(); mountPoints << Calamares::JobQueue::instance()->globalStorage()->value( "efiSystemPartition" ).toString();
mountPoints.removeDuplicates(); mountPoints.removeDuplicates();
mountPoints.sort(); mountPoints.sort();

View File

@ -25,6 +25,7 @@
#include "core/PartitionCoreModule.h" #include "core/PartitionCoreModule.h"
#include "core/PartitionInfo.h" #include "core/PartitionInfo.h"
#include "core/PartitionModel.h" #include "core/PartitionModel.h"
#include "core/PartUtils.h"
#include "core/KPMHelpers.h" #include "core/KPMHelpers.h"
#include "gui/CreatePartitionDialog.h" #include "gui/CreatePartitionDialog.h"
#include "gui/EditExistingPartitionDialog.h" #include "gui/EditExistingPartitionDialog.h"
@ -59,7 +60,7 @@ PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent )
, m_core( core ) , m_core( core )
, m_isEfi( false ) , m_isEfi( false )
{ {
m_isEfi = QDir( "/sys/firmware/efi/efivars" ).exists(); m_isEfi = PartUtils::isEfiSystem();
m_ui->setupUi( this ); m_ui->setupUi( this );
m_ui->partitionLabelsView->setVisible( m_ui->partitionLabelsView->setVisible(

View File

@ -386,7 +386,7 @@ PartitionViewStep::onLeave()
if ( m_widget->currentWidget() == m_manualPartitionPage ) if ( m_widget->currentWidget() == m_manualPartitionPage )
{ {
if ( QDir( "/sys/firmware/efi/efivars" ).exists() ) if ( PartUtils::isEfiSystem() )
{ {
QString espMountPoint = Calamares::JobQueue::instance()->globalStorage()-> QString espMountPoint = Calamares::JobQueue::instance()->globalStorage()->
value( "efiSystemPartition").toString(); value( "efiSystemPartition").toString();