[partition] Remove initKPMCore() from KPMHelpers
- This is a job for KPMManager, from the partition service. - In tests, needs to be a little hackish.
This commit is contained in:
parent
a01539b664
commit
d039f9bbb8
@ -37,25 +37,6 @@ using CalamaresUtils::Partition::PartitionIterator;
|
|||||||
namespace KPMHelpers
|
namespace KPMHelpers
|
||||||
{
|
{
|
||||||
|
|
||||||
static bool s_KPMcoreInited = false;
|
|
||||||
|
|
||||||
bool
|
|
||||||
initKPMcore()
|
|
||||||
{
|
|
||||||
if ( s_KPMcoreInited )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
QByteArray backendName = qgetenv( "KPMCORE_BACKEND" );
|
|
||||||
if ( !CoreBackendManager::self()->load( backendName.isEmpty() ? CoreBackendManager::defaultBackendName() : backendName ) )
|
|
||||||
{
|
|
||||||
cWarning() << "Failed to load backend plugin" << backendName;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
s_KPMcoreInited = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Partition*
|
Partition*
|
||||||
findPartitionByMountPoint( const QList< Device* >& devices, const QString& mountPoint )
|
findPartitionByMountPoint( const QList< Device* >& devices, const QString& mountPoint )
|
||||||
{
|
{
|
||||||
|
@ -50,19 +50,6 @@ class PartitionRole;
|
|||||||
namespace KPMHelpers
|
namespace KPMHelpers
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* Thin wrapper on top of CoreBackendManager. Hides things like initializing the
|
|
||||||
* Config instance or instantiating the backend.
|
|
||||||
*
|
|
||||||
* Initialize PartitionManager Config object and load a PartitionManager
|
|
||||||
* backend. It loads the "libparted" plugin by default, but this can be
|
|
||||||
* overloaded by settings the environment variable KPMCORE_BACKEND. Setting it to
|
|
||||||
* "dummy" will load the dummy plugin instead.
|
|
||||||
*
|
|
||||||
* @return true if initialization was successful.
|
|
||||||
*/
|
|
||||||
bool initKPMcore();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates on all devices and return the first partition which is associated
|
* Iterates on all devices and return the first partition which is associated
|
||||||
* with mountPoint. This uses PartitionInfo::mountPoint(), not Partition::mountPoint()
|
* with mountPoint. This uses PartitionInfo::mountPoint(), not Partition::mountPoint()
|
||||||
|
@ -147,7 +147,7 @@ PartitionCoreModule::PartitionCoreModule( QObject* parent )
|
|||||||
, m_deviceModel( new DeviceModel( this ) )
|
, m_deviceModel( new DeviceModel( this ) )
|
||||||
, m_bootLoaderModel( new BootLoaderModel( this ) )
|
, m_bootLoaderModel( new BootLoaderModel( this ) )
|
||||||
{
|
{
|
||||||
if ( !KPMHelpers::initKPMcore() )
|
if ( !m_kpmcore )
|
||||||
qFatal( "Failed to initialize KPMcore backend" );
|
qFatal( "Failed to initialize KPMcore backend" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "core/PartitionModel.h"
|
#include "core/PartitionModel.h"
|
||||||
|
|
||||||
#include "Job.h"
|
#include "Job.h"
|
||||||
|
#include "partition/KPMManager.h"
|
||||||
|
|
||||||
// KPMcore
|
// KPMcore
|
||||||
#include <kpmcore/core/lvmdevice.h>
|
#include <kpmcore/core/lvmdevice.h>
|
||||||
@ -235,6 +236,8 @@ Q_SIGNALS:
|
|||||||
void deviceReverted( Device* device );
|
void deviceReverted( Device* device );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
CalamaresUtils::Partition::KPMManager m_kpmcore;
|
||||||
|
|
||||||
void refreshAfterModelChange();
|
void refreshAfterModelChange();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,7 +19,9 @@
|
|||||||
|
|
||||||
#include <PartitionJobTests.h>
|
#include <PartitionJobTests.h>
|
||||||
|
|
||||||
|
#include "partition/KPMManager.h"
|
||||||
#include "partition/PartitionQuery.h"
|
#include "partition/PartitionQuery.h"
|
||||||
|
#include "utils/Logger.h"
|
||||||
#include "utils/Units.h"
|
#include "utils/Units.h"
|
||||||
|
|
||||||
#include <jobs/CreatePartitionJob.h>
|
#include <jobs/CreatePartitionJob.h>
|
||||||
@ -163,6 +165,8 @@ QueueRunner::onFailed( const QString& message, const QString& details )
|
|||||||
QFAIL( qPrintable( msg ) );
|
QFAIL( qPrintable( msg ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CalamaresUtils::Partition::KPMManager* kpmcore = nullptr;
|
||||||
|
|
||||||
//- PartitionJobTests ------------------------------------------------------------------
|
//- PartitionJobTests ------------------------------------------------------------------
|
||||||
PartitionJobTests::PartitionJobTests()
|
PartitionJobTests::PartitionJobTests()
|
||||||
: m_runner( &m_queue )
|
: m_runner( &m_queue )
|
||||||
@ -178,12 +182,18 @@ PartitionJobTests::initTestCase()
|
|||||||
QSKIP( "Skipping test, CALAMARES_TEST_DISK is not set. It should point to a disk which can be safely formatted", 0 );
|
QSKIP( "Skipping test, CALAMARES_TEST_DISK is not set. It should point to a disk which can be safely formatted", 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
QVERIFY( KPMHelpers::initKPMcore() );
|
kpmcore = new CalamaresUtils::Partition::KPMManager();
|
||||||
FileSystemFactory::init();
|
FileSystemFactory::init();
|
||||||
|
|
||||||
refreshDevice();
|
refreshDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PartitionJobTests::cleanupTestCase()
|
||||||
|
{
|
||||||
|
delete kpmcore;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionJobTests::refreshDevice()
|
PartitionJobTests::refreshDevice()
|
||||||
{
|
{
|
||||||
|
@ -59,6 +59,7 @@ public:
|
|||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void initTestCase();
|
void initTestCase();
|
||||||
|
void cleanupTestCase();
|
||||||
void testPartitionTable();
|
void testPartitionTable();
|
||||||
void testCreatePartition();
|
void testCreatePartition();
|
||||||
void testCreatePartitionExtended();
|
void testCreatePartitionExtended();
|
||||||
|
Loading…
Reference in New Issue
Block a user