From 638117efa0f58cf37f12f9294b1b798a49c81713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Fri, 15 Dec 2017 12:37:55 +0000 Subject: [PATCH 1/3] Cleanup unnecessary kpmcore includes. --- .../partition/jobs/DeletePartitionJob.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/modules/partition/jobs/DeletePartitionJob.cpp b/src/modules/partition/jobs/DeletePartitionJob.cpp index 1bed8739f..61743ed74 100644 --- a/src/modules/partition/jobs/DeletePartitionJob.cpp +++ b/src/modules/partition/jobs/DeletePartitionJob.cpp @@ -21,16 +21,12 @@ #include "jobs/DeletePartitionJob.h" // KPMcore -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include DeletePartitionJob::DeletePartitionJob( Device* device, Partition* partition ) : PartitionJob( partition ) From 1b3ce39ffb93f6d355c5be9fd7ae44cc4ffff280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Tue, 19 Dec 2017 18:27:49 +0000 Subject: [PATCH 2/3] Convert FormatPartitionJob to KPMcore's CreateFileSystemOperation. --- .../partition/jobs/FormatPartitionJob.cpp | 76 +++---------------- 1 file changed, 12 insertions(+), 64 deletions(-) diff --git a/src/modules/partition/jobs/FormatPartitionJob.cpp b/src/modules/partition/jobs/FormatPartitionJob.cpp index bc13946c6..76b806390 100644 --- a/src/modules/partition/jobs/FormatPartitionJob.cpp +++ b/src/modules/partition/jobs/FormatPartitionJob.cpp @@ -22,15 +22,12 @@ #include "utils/Logger.h" // KPMcore -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include // Qt #include @@ -78,62 +75,13 @@ Calamares::JobResult FormatPartitionJob::exec() { Report report( nullptr ); // Root of the report tree, no parent - QString partitionPath = m_partition->partitionPath(); - QString message = tr( "The installer failed to format partition %1 on disk '%2'." ).arg( partitionPath, m_device->name() ); + CreateFileSystemOperation op(*m_device, *m_partition, m_partition->fileSystem().type()); + op.setStatus(Operation::StatusRunning); - CoreBackend* backend = CoreBackendManager::self()->backend(); - QScopedPointer backendDevice( backend->openDevice( m_device->deviceNode() ) ); - if ( !backendDevice.data() ) - { - return Calamares::JobResult::error( - message, - tr( "Could not open device '%1'." ).arg( m_device->deviceNode() ) - ); - } + QString message = tr( "The installer failed to format partition %1 on disk '%2'." ).arg( m_partition->partitionPath(), m_device->name() ); - QScopedPointer backendPartitionTable( backendDevice->openPartitionTable() ); - if ( !backendPartitionTable.data() ) - { - return Calamares::JobResult::error( - message, - tr( "Could not open partition table." ) - ); - } + if (op.execute(report)) + return Calamares::JobResult::ok(); - FileSystem& fs = m_partition->fileSystem(); - - bool ok = fs.create( report, partitionPath ); - int retries = 0; - const int MAX_RETRIES = 10; - while ( !ok ) - { - cDebug() << "Partition" << m_partition->partitionPath() - << "might not be ready yet, retrying (" << ++retries - << "/" << MAX_RETRIES << ") ..."; - QThread::sleep( 2 /*seconds*/ ); - ok = fs.create( report, partitionPath ); - - if ( retries == MAX_RETRIES ) - break; - } - - if ( !ok ) - { - return Calamares::JobResult::error( - tr( "The installer failed to create file system on partition %1." ) - .arg( partitionPath ), - report.toText() - ); - } - - if ( !backendPartitionTable->setPartitionSystemType( report, *m_partition ) ) - { - return Calamares::JobResult::error( - tr( "The installer failed to update partition table on disk '%1'." ).arg( m_device->name() ), - report.toText() - ); - } - - backendPartitionTable->commit(); - return Calamares::JobResult::ok(); + return Calamares::JobResult::error(message, report.toText()); } From 806b84973aa3b364370fba223270a0a03ade6367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Fri, 22 Dec 2017 12:42:28 +0000 Subject: [PATCH 3/3] Convert CreatePartitionTableJob to KPMcore operation. --- .../jobs/CreatePartitionTableJob.cpp | 48 ++++++------------- .../partition/jobs/FillGlobalStorageJob.cpp | 10 ++-- 2 files changed, 19 insertions(+), 39 deletions(-) diff --git a/src/modules/partition/jobs/CreatePartitionTableJob.cpp b/src/modules/partition/jobs/CreatePartitionTableJob.cpp index 5d2df6bc9..e2f2ec7a9 100644 --- a/src/modules/partition/jobs/CreatePartitionTableJob.cpp +++ b/src/modules/partition/jobs/CreatePartitionTableJob.cpp @@ -23,15 +23,12 @@ #include "utils/Logger.h" // KPMcore -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include // Qt #include @@ -75,17 +72,7 @@ CreatePartitionTableJob::exec() Report report( nullptr ); QString message = tr( "The installer failed to create a partition table on %1." ).arg( m_device->name() ); - CoreBackend* backend = CoreBackendManager::self()->backend(); - QScopedPointer< CoreBackendDevice > backendDevice( backend->openDevice( m_device->deviceNode() ) ); - if ( !backendDevice.data() ) - { - return Calamares::JobResult::error( - message, - tr( "Could not open device %1." ).arg( m_device->deviceNode() ) - ); - } - - QScopedPointer< PartitionTable > table( createTable() ); + PartitionTable* table( createTable() ); cDebug() << "Creating new partition table of type" << table->typeName() << ", uncommitted yet:\n" << table; @@ -103,20 +90,13 @@ CreatePartitionTableJob::exec() mount.waitForFinished(); cDebug() << "mount:\n" << mount.readAllStandardOutput(); - bool ok = backendDevice->createPartitionTable( report, *table ); - if ( !ok ) - { - return Calamares::JobResult::error( - message, - QString( "Text: %1\nCommand: %2\nOutput: %3\nStatus: %4" ) - .arg( report.toText() ) - .arg( report.command() ) - .arg( report.output() ) - .arg( report.status() ) - ); - } - - return Calamares::JobResult::ok(); + CreatePartitionTableOperation op(*m_device, table); + op.setStatus(Operation::StatusRunning); + + if (op.execute(report)) + return Calamares::JobResult::ok(); + + return Calamares::JobResult::error(message, report.toText()); } void diff --git a/src/modules/partition/jobs/FillGlobalStorageJob.cpp b/src/modules/partition/jobs/FillGlobalStorageJob.cpp index a3d709b5b..a6c93a2c4 100644 --- a/src/modules/partition/jobs/FillGlobalStorageJob.cpp +++ b/src/modules/partition/jobs/FillGlobalStorageJob.cpp @@ -28,11 +28,11 @@ #include "Branding.h" #include "utils/Logger.h" -// CalaPM -#include -#include -#include -#include +// KPMcore +#include +#include +#include +#include // Qt #include