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

View File

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

View File

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

View File

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

View File

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

View File

@ -146,7 +146,7 @@ void
ChoicePage::init( PartitionCoreModule* core )
{
m_core = core;
m_isEfi = QDir( "/sys/firmware/efi/efivars" ).exists();
m_isEfi = PartUtils::isEfiSystem();
setupChoices();
@ -1311,7 +1311,7 @@ ChoicePage::setupActions()
m_grp->setExclusive( true );
}
bool isEfi = QDir( "/sys/firmware/efi/efivars" ).exists();
bool isEfi = PartUtils::isEfiSystem();
bool efiSystemPartitionFound = !m_core->efiSystemPartitions().isEmpty();
if ( isEfi && !efiSystemPartitionFound )

View File

@ -21,6 +21,7 @@
#include "core/ColorUtils.h"
#include "core/PartitionInfo.h"
#include "core/PartUtils.h"
#include "core/KPMHelpers.h"
#include "gui/PartitionSizeController.h"
@ -66,7 +67,7 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* par
m_ui->encryptWidget->hide();
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.removeDuplicates();
mountPoints.sort();

View File

@ -26,6 +26,7 @@
#include <core/ColorUtils.h>
#include <core/PartitionCoreModule.h>
#include <core/PartitionInfo.h>
#include "core/PartUtils.h"
#include <core/KPMHelpers.h>
#include <gui/PartitionSizeController.h>
@ -56,7 +57,7 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, Partit
m_ui->setupUi( this );
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.removeDuplicates();
mountPoints.sort();

View File

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

View File

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