Move CalaPM init into PMUtils.
This commit is contained in:
parent
c2eef9ac30
commit
adc23b99b6
@ -25,10 +25,35 @@
|
|||||||
// KPMcore
|
// KPMcore
|
||||||
#include <kpmcore/core/partition.h>
|
#include <kpmcore/core/partition.h>
|
||||||
#include <kpmcore/fs/filesystemfactory.h>
|
#include <kpmcore/fs/filesystemfactory.h>
|
||||||
|
#include <kpmcore/backend/corebackendmanager.h>
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
namespace PMUtils
|
namespace PMUtils
|
||||||
{
|
{
|
||||||
|
|
||||||
|
static bool s_KPMcoreInited = false;
|
||||||
|
|
||||||
|
bool
|
||||||
|
initKPMcore()
|
||||||
|
{
|
||||||
|
if ( s_KPMcoreInited )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
QByteArray backendName = qgetenv( "KPMCORE_BACKEND" );
|
||||||
|
if ( backendName.isEmpty() )
|
||||||
|
backendName = "libparted";
|
||||||
|
|
||||||
|
if ( !CoreBackendManager::self()->load( backendName ) )
|
||||||
|
{
|
||||||
|
qWarning() << "Failed to load backend plugin" << backendName;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
s_KPMcoreInited = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isPartitionFreeSpace( Partition* partition )
|
isPartitionFreeSpace( Partition* partition )
|
||||||
@ -115,5 +140,4 @@ clonePartition( Device* device, Partition* partition )
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -38,6 +38,19 @@ class PartitionRole;
|
|||||||
namespace PMUtils
|
namespace PMUtils
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
|
||||||
bool isPartitionFreeSpace( Partition* );
|
bool isPartitionFreeSpace( Partition* );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,28 +17,27 @@
|
|||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <core/PartitionCoreModule.h>
|
#include "core/PartitionCoreModule.h"
|
||||||
|
|
||||||
#include <core/BootLoaderModel.h>
|
#include "core/BootLoaderModel.h"
|
||||||
#include <core/DeviceModel.h>
|
#include "core/DeviceModel.h"
|
||||||
#include <core/PartitionInfo.h>
|
#include "core/PartitionInfo.h"
|
||||||
#include <core/PartitionIterator.h>
|
#include "core/PartitionIterator.h"
|
||||||
#include <core/PartitionModel.h>
|
#include "core/PartitionModel.h"
|
||||||
#include <core/PMUtils.h>
|
#include "core/PMUtils.h"
|
||||||
#include <jobs/ClearMountsJob.h>
|
#include "jobs/ClearMountsJob.h"
|
||||||
#include <jobs/ClearTempMountsJob.h>
|
#include "jobs/ClearTempMountsJob.h"
|
||||||
#include <jobs/CreatePartitionJob.h>
|
#include "jobs/CreatePartitionJob.h"
|
||||||
#include <jobs/CreatePartitionTableJob.h>
|
#include "jobs/CreatePartitionTableJob.h"
|
||||||
#include <jobs/DeletePartitionJob.h>
|
#include "jobs/DeletePartitionJob.h"
|
||||||
#include <jobs/FillGlobalStorageJob.h>
|
#include "jobs/FillGlobalStorageJob.h"
|
||||||
#include <jobs/FormatPartitionJob.h>
|
#include "jobs/FormatPartitionJob.h"
|
||||||
#include <jobs/ResizePartitionJob.h>
|
#include "jobs/ResizePartitionJob.h"
|
||||||
|
|
||||||
#include <Typedefs.h>
|
#include "Typedefs.h"
|
||||||
#include <utils/Logger.h>
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
// KPMcore
|
// KPMcore
|
||||||
#include <CalaPM.h>
|
|
||||||
#include <kpmcore/core/device.h>
|
#include <kpmcore/core/device.h>
|
||||||
#include <kpmcore/core/partition.h>
|
#include <kpmcore/core/partition.h>
|
||||||
#include <kpmcore/backend/corebackend.h>
|
#include <kpmcore/backend/corebackend.h>
|
||||||
@ -97,8 +96,8 @@ 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 ( !CalaPM::init() )
|
if ( !PMUtils::initKPMcore() )
|
||||||
qFatal( "Failed to init CalaPM" );
|
qFatal( "Failed to initialize KPMcore backend" );
|
||||||
FileSystemFactory::init();
|
FileSystemFactory::init();
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user