Create bootLoader.installPath in GlobalStorage
This commit is contained in:
parent
06a13637b6
commit
f2ab67b28b
@ -22,14 +22,28 @@
|
|||||||
#include <JobQueue.h>
|
#include <JobQueue.h>
|
||||||
#include <PartitionInfo.h>
|
#include <PartitionInfo.h>
|
||||||
#include <PartitionIterator.h>
|
#include <PartitionIterator.h>
|
||||||
|
#include <PMUtils.h>
|
||||||
|
|
||||||
// CalaPM
|
// CalaPM
|
||||||
#include <core/device.h>
|
#include <core/device.h>
|
||||||
#include <core/partition.h>
|
#include <core/partition.h>
|
||||||
#include <fs/filesystem.h>
|
#include <fs/filesystem.h>
|
||||||
|
|
||||||
FillGlobalStorageJob::FillGlobalStorageJob( QList< Device* > devices )
|
#include <QDebug>
|
||||||
|
|
||||||
|
static QVariant
|
||||||
|
mapForPartition( Partition* partition )
|
||||||
|
{
|
||||||
|
QVariantMap map;
|
||||||
|
map[ "device" ] = partition->partitionPath();
|
||||||
|
map[ "mountPoint" ] = PartitionInfo::mountPoint( partition );
|
||||||
|
map[ "fs" ] = partition->fileSystem().name();
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
FillGlobalStorageJob::FillGlobalStorageJob( QList< Device* > devices, const QString& bootLoaderPath )
|
||||||
: m_devices( devices )
|
: m_devices( devices )
|
||||||
|
, m_bootLoaderPath( bootLoaderPath )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,20 +56,37 @@ FillGlobalStorageJob::prettyName() const
|
|||||||
Calamares::JobResult
|
Calamares::JobResult
|
||||||
FillGlobalStorageJob::exec()
|
FillGlobalStorageJob::exec()
|
||||||
{
|
{
|
||||||
QVariantList lst;
|
Calamares::GlobalStorage* storage = Calamares::JobQueue::instance()->globalStorage();
|
||||||
for( auto device : m_devices )
|
storage->insert( "partitions", createPartitionList() );
|
||||||
for( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it)
|
QVariant var = createBootLoaderMap();
|
||||||
lst << mapForPartition( *it );
|
if ( !var.isValid() )
|
||||||
Calamares::JobQueue::instance()->globalStorage()->insert( "partitions", lst );
|
return Calamares::JobResult::error( tr( "Failed to find path for boot loader" ) );
|
||||||
|
storage->insert( "bootLoader", var );
|
||||||
return Calamares::JobResult::ok();
|
return Calamares::JobResult::ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant
|
QVariant
|
||||||
FillGlobalStorageJob::mapForPartition( Partition* partition )
|
FillGlobalStorageJob::createPartitionList()
|
||||||
|
{
|
||||||
|
QVariantList lst;
|
||||||
|
for( auto device : m_devices )
|
||||||
|
for( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it)
|
||||||
|
lst << mapForPartition( *it );
|
||||||
|
return lst;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant
|
||||||
|
FillGlobalStorageJob::createBootLoaderMap()
|
||||||
{
|
{
|
||||||
QVariantMap map;
|
QVariantMap map;
|
||||||
map[ "device" ] = partition->partitionPath();
|
QString path = m_bootLoaderPath;
|
||||||
map[ "mountPoint" ] = PartitionInfo::mountPoint( partition );
|
if ( !path.startsWith( "/dev/" ) )
|
||||||
map[ "fs" ] = partition->fileSystem().name();
|
{
|
||||||
|
Partition* partition = PMUtils::findPartitionByMountPoint( m_devices, path );
|
||||||
|
if ( !partition )
|
||||||
|
return QVariant();
|
||||||
|
path = partition->partitionPath();
|
||||||
|
}
|
||||||
|
map[ "installPath" ] = path;
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
@ -28,20 +28,23 @@ class Device;
|
|||||||
class Partition;
|
class Partition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills the "partitions" key of GlobalStorage. Doing it after partitioning
|
* Fills the partitioning-related keys of GlobalStorage. Doing it after
|
||||||
* makes it possible to access information such as the partition UUID.
|
* partitioning makes it possible to access information such as the partition
|
||||||
|
* device path.
|
||||||
*/
|
*/
|
||||||
class FillGlobalStorageJob : public Calamares::Job
|
class FillGlobalStorageJob : public Calamares::Job
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
FillGlobalStorageJob( QList< Device* > devices );
|
FillGlobalStorageJob( QList< Device* > devices, const QString& bootLoaderPath );
|
||||||
QString prettyName() const override;
|
QString prettyName() const override;
|
||||||
Calamares::JobResult exec() override;
|
Calamares::JobResult exec() override;
|
||||||
private:
|
private:
|
||||||
QList< Device* > m_devices;
|
QList< Device* > m_devices;
|
||||||
|
QString m_bootLoaderPath;
|
||||||
|
|
||||||
QVariant mapForPartition( Partition* );
|
QVariant createPartitionList();
|
||||||
|
QVariant createBootLoaderMap();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FILLGLOBALSTORAGEJOB_H */
|
#endif /* FILLGLOBALSTORAGEJOB_H */
|
||||||
|
@ -225,7 +225,7 @@ PartitionCoreModule::jobs() const
|
|||||||
lst << info->jobs;
|
lst << info->jobs;
|
||||||
devices << info->device.data();
|
devices << info->device.data();
|
||||||
}
|
}
|
||||||
lst << Calamares::job_ptr( new FillGlobalStorageJob( devices ) );
|
lst << Calamares::job_ptr( new FillGlobalStorageJob( devices, m_bootLoaderInstallPath ) );
|
||||||
return lst;
|
return lst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user