mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-24 19:05:46 -05:00
Add EFI System Partition scanning support to PartitionCoreModule.
This commit is contained in:
parent
67b96f750a
commit
f4a13b2041
2 changed files with 62 additions and 0 deletions
|
@ -47,6 +47,8 @@
|
|||
|
||||
// Qt
|
||||
#include <QStandardItemModel>
|
||||
#include <QDir>
|
||||
#include <QProcess>
|
||||
|
||||
static bool
|
||||
hasRootPartition( Device* device )
|
||||
|
@ -124,6 +126,10 @@ PartitionCoreModule::init()
|
|||
m_deviceModel->init( devices );
|
||||
|
||||
m_bootLoaderModel->init( devices );
|
||||
|
||||
if ( QDir( "/sys/firmware/efi/efivars" ).exists() )
|
||||
scanForEfiSystemPartitions(); //FIXME: this should be removed in favor of
|
||||
// proper KPM support for EFI
|
||||
}
|
||||
|
||||
PartitionCoreModule::~PartitionCoreModule()
|
||||
|
@ -327,6 +333,12 @@ PartitionCoreModule::hasRootMountPoint() const
|
|||
return m_hasRootMountPoint;
|
||||
}
|
||||
|
||||
QList< Partition* >
|
||||
PartitionCoreModule::efiSystemPartitions() const
|
||||
{
|
||||
return m_efiSystemPartitions;
|
||||
}
|
||||
|
||||
void
|
||||
PartitionCoreModule::dumpQueue() const
|
||||
{
|
||||
|
@ -384,6 +396,52 @@ PartitionCoreModule::updateIsDirty()
|
|||
isDirtyChanged( m_isDirty );
|
||||
}
|
||||
|
||||
void
|
||||
PartitionCoreModule::scanForEfiSystemPartitions()
|
||||
{
|
||||
m_efiSystemPartitions.clear();
|
||||
|
||||
QList< Device* > devices;
|
||||
for ( int row = 0; row < deviceModel()->rowCount(); ++row )
|
||||
{
|
||||
Device* device = deviceModel()->deviceForIndex(
|
||||
deviceModel()->index( row ) );
|
||||
devices.append( device );
|
||||
}
|
||||
|
||||
//FIXME: Unfortunately right now we have to call sgdisk manually because
|
||||
// the KPM submodule does not expose the ESP flag from libparted.
|
||||
// The following findPartitions call and lambda should be scrapped and
|
||||
// rewritten based on libKPM. -- Teo 5/2015
|
||||
QList< Partition* > efiSystemPartitions =
|
||||
PMUtils::findPartitions( devices,
|
||||
[]( Partition* partition ) -> bool
|
||||
{
|
||||
QProcess process;
|
||||
process.setProgram( "sgdisk" );
|
||||
process.setArguments( { "-i",
|
||||
QString::number( partition->number() ),
|
||||
partition->devicePath() } );
|
||||
process.setProcessChannelMode( QProcess::MergedChannels );
|
||||
process.start();
|
||||
if ( process.waitForFinished() )
|
||||
{
|
||||
if ( process.readAllStandardOutput()
|
||||
.contains( "C12A7328-F81F-11D2-BA4B-00A0C93EC93B" ) )
|
||||
{
|
||||
cDebug() << "Found EFI system partition at" << partition->partitionPath();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} );
|
||||
|
||||
if ( efiSystemPartitions.isEmpty() )
|
||||
cDebug() << "WARNING: system is EFI but no EFI system partitions found.";
|
||||
|
||||
m_efiSystemPartitions = efiSystemPartitions;
|
||||
}
|
||||
|
||||
PartitionCoreModule::DeviceInfo*
|
||||
PartitionCoreModule::infoForDevice( Device* device ) const
|
||||
{
|
||||
|
|
|
@ -91,6 +91,8 @@ public:
|
|||
|
||||
bool hasRootMountPoint() const;
|
||||
|
||||
QList< Partition* > efiSystemPartitions() const;
|
||||
|
||||
void revert();
|
||||
|
||||
void clearJobs();
|
||||
|
@ -134,6 +136,7 @@ private:
|
|||
bool isDirty() const;
|
||||
};
|
||||
QList< DeviceInfo* > m_deviceInfos;
|
||||
QList< Partition* > m_efiSystemPartitions;
|
||||
|
||||
DeviceModel* m_deviceModel;
|
||||
BootLoaderModel* m_bootLoaderModel;
|
||||
|
@ -144,6 +147,7 @@ private:
|
|||
void init();
|
||||
void updateHasRootMountPoint();
|
||||
void updateIsDirty();
|
||||
void scanForEfiSystemPartitions();
|
||||
|
||||
DeviceInfo* infoForDevice( Device* ) const;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue