2017-12-20 14:39:09 +01:00
|
|
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
2014-07-18 15:06:56 +02:00
|
|
|
*
|
|
|
|
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
|
2016-06-21 17:20:45 +02:00
|
|
|
* Copyright 2015-2016, Teo Mrnjavac <teo@kde.org>
|
2020-02-13 13:54:04 +01:00
|
|
|
* Copyright 2020, Adriaan de Groot <groot@kde.org>
|
2014-07-18 15:06:56 +02:00
|
|
|
*
|
|
|
|
* Calamares is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Calamares is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-02-13 13:54:04 +01:00
|
|
|
#include "FormatPartitionJob.h"
|
2020-02-13 11:33:40 +01:00
|
|
|
|
2020-02-13 13:48:12 +01:00
|
|
|
#include "partition/FileSystem.h"
|
2015-07-02 13:49:21 +02:00
|
|
|
#include "utils/Logger.h"
|
|
|
|
|
2019-06-14 23:20:26 +02:00
|
|
|
#include <kpmcore/core/device.h>
|
|
|
|
#include <kpmcore/core/partition.h>
|
|
|
|
#include <kpmcore/core/partitiontable.h>
|
|
|
|
#include <kpmcore/fs/filesystem.h>
|
|
|
|
#include <kpmcore/ops/createfilesystemoperation.h>
|
|
|
|
#include <kpmcore/util/report.h>
|
2014-07-18 15:06:56 +02:00
|
|
|
|
2020-02-13 13:48:12 +01:00
|
|
|
using CalamaresUtils::Partition::untranslatedFS;
|
|
|
|
using CalamaresUtils::Partition::userVisibleFS;
|
2020-02-13 11:33:40 +01:00
|
|
|
|
2014-07-18 15:06:56 +02:00
|
|
|
FormatPartitionJob::FormatPartitionJob( Device* device, Partition* partition )
|
|
|
|
: PartitionJob( partition )
|
|
|
|
, m_device( device )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
QString
|
|
|
|
FormatPartitionJob::prettyName() const
|
|
|
|
{
|
2019-05-09 14:02:52 +02:00
|
|
|
return tr( "Format partition %1 (file system: %2, size: %3 MiB) on %4." )
|
2020-04-07 11:36:40 +02:00
|
|
|
.arg( m_partition->partitionPath() )
|
|
|
|
.arg( userVisibleFS( m_partition->fileSystem() ) )
|
|
|
|
.arg( m_partition->capacity() / 1024 / 1024 )
|
|
|
|
.arg( m_device->name() );
|
2015-04-09 15:16:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString
|
|
|
|
FormatPartitionJob::prettyDescription() const
|
|
|
|
{
|
2019-05-09 14:02:52 +02:00
|
|
|
return tr( "Format <strong>%3MiB</strong> partition <strong>%1</strong> with "
|
2015-04-10 13:07:14 +02:00
|
|
|
"file system <strong>%2</strong>." )
|
2020-04-07 11:36:40 +02:00
|
|
|
.arg( m_partition->partitionPath() )
|
|
|
|
.arg( userVisibleFS( m_partition->fileSystem() ) )
|
|
|
|
.arg( m_partition->capacity() / 1024 / 1024 );
|
2014-07-18 15:06:56 +02:00
|
|
|
}
|
|
|
|
|
2015-06-13 02:26:38 +02:00
|
|
|
|
|
|
|
QString
|
|
|
|
FormatPartitionJob::prettyStatusMessage() const
|
|
|
|
{
|
|
|
|
return tr( "Formatting partition %1 with "
|
|
|
|
"file system %2." )
|
2020-04-07 11:36:40 +02:00
|
|
|
.arg( m_partition->partitionPath() )
|
|
|
|
.arg( userVisibleFS( m_partition->fileSystem() ) );
|
2015-06-13 02:26:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-18 15:06:56 +02:00
|
|
|
Calamares::JobResult
|
|
|
|
FormatPartitionJob::exec()
|
|
|
|
{
|
2017-09-21 10:04:01 +02:00
|
|
|
Report report( nullptr ); // Root of the report tree, no parent
|
2020-04-07 11:36:40 +02:00
|
|
|
CreateFileSystemOperation op( *m_device, *m_partition, m_partition->fileSystem().type() );
|
|
|
|
op.setStatus( Operation::StatusRunning );
|
2016-06-21 17:20:45 +02:00
|
|
|
|
2020-04-07 11:36:40 +02:00
|
|
|
QString message = tr( "The installer failed to format partition %1 on disk '%2'." )
|
|
|
|
.arg( m_partition->partitionPath(), m_device->name() );
|
2014-07-18 15:06:56 +02:00
|
|
|
|
2020-04-07 11:36:40 +02:00
|
|
|
if ( op.execute( report ) )
|
|
|
|
{
|
2017-12-19 19:27:49 +01:00
|
|
|
return Calamares::JobResult::ok();
|
2020-04-07 11:36:40 +02:00
|
|
|
}
|
2014-07-18 15:06:56 +02:00
|
|
|
|
2020-04-07 11:36:40 +02:00
|
|
|
return Calamares::JobResult::error( message, report.toText() );
|
2014-07-18 15:06:56 +02:00
|
|
|
}
|