Create bootLoader.installPath in GlobalStorage

This commit is contained in:
Aurélien Gâteau 2014-07-23 18:16:55 +02:00
parent 06a13637b6
commit f2ab67b28b
3 changed files with 49 additions and 15 deletions

View File

@ -22,14 +22,28 @@
#include <JobQueue.h>
#include <PartitionInfo.h>
#include <PartitionIterator.h>
#include <PMUtils.h>
// CalaPM
#include <core/device.h>
#include <core/partition.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_bootLoaderPath( bootLoaderPath )
{
}
@ -42,20 +56,37 @@ FillGlobalStorageJob::prettyName() const
Calamares::JobResult
FillGlobalStorageJob::exec()
{
QVariantList lst;
for( auto device : m_devices )
for( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it)
lst << mapForPartition( *it );
Calamares::JobQueue::instance()->globalStorage()->insert( "partitions", lst );
Calamares::GlobalStorage* storage = Calamares::JobQueue::instance()->globalStorage();
storage->insert( "partitions", createPartitionList() );
QVariant var = createBootLoaderMap();
if ( !var.isValid() )
return Calamares::JobResult::error( tr( "Failed to find path for boot loader" ) );
storage->insert( "bootLoader", var );
return Calamares::JobResult::ok();
}
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;
map[ "device" ] = partition->partitionPath();
map[ "mountPoint" ] = PartitionInfo::mountPoint( partition );
map[ "fs" ] = partition->fileSystem().name();
QString path = m_bootLoaderPath;
if ( !path.startsWith( "/dev/" ) )
{
Partition* partition = PMUtils::findPartitionByMountPoint( m_devices, path );
if ( !partition )
return QVariant();
path = partition->partitionPath();
}
map[ "installPath" ] = path;
return map;
}

View File

@ -28,20 +28,23 @@ class Device;
class Partition;
/**
* Fills the "partitions" key of GlobalStorage. Doing it after partitioning
* makes it possible to access information such as the partition UUID.
* Fills the partitioning-related keys of GlobalStorage. Doing it after
* partitioning makes it possible to access information such as the partition
* device path.
*/
class FillGlobalStorageJob : public Calamares::Job
{
Q_OBJECT
public:
FillGlobalStorageJob( QList< Device* > devices );
FillGlobalStorageJob( QList< Device* > devices, const QString& bootLoaderPath );
QString prettyName() const override;
Calamares::JobResult exec() override;
private:
QList< Device* > m_devices;
QString m_bootLoaderPath;
QVariant mapForPartition( Partition* );
QVariant createPartitionList();
QVariant createBootLoaderMap();
};
#endif /* FILLGLOBALSTORAGEJOB_H */

View File

@ -225,7 +225,7 @@ PartitionCoreModule::jobs() const
lst << info->jobs;
devices << info->device.data();
}
lst << Calamares::job_ptr( new FillGlobalStorageJob( devices ) );
lst << Calamares::job_ptr( new FillGlobalStorageJob( devices, m_bootLoaderInstallPath ) );
return lst;
}