mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-15 20:04:41 -04:00
[partition] Merge pull request #1808 from dalto8/zfs-delete-fix
Fix for zfs partition deletion
This commit is contained in:
commit
cd56bab622
1 changed files with 47 additions and 0 deletions
|
@ -10,6 +10,7 @@
|
|||
*/
|
||||
|
||||
#include "DeletePartitionJob.h"
|
||||
#include "utils/CalamaresUtilsSystem.h"
|
||||
|
||||
// KPMcore
|
||||
#include <kpmcore/core/device.h>
|
||||
|
@ -19,6 +20,45 @@
|
|||
#include <kpmcore/ops/deleteoperation.h>
|
||||
#include <kpmcore/util/report.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
/** @brief Determine if the given partition is of type Zfs
|
||||
*
|
||||
* Returns true if @p partition is of type Zfs
|
||||
*
|
||||
*/
|
||||
static bool
|
||||
isZfs( Partition* partition )
|
||||
{
|
||||
return partition->fileSystem().type() == FileSystem::Type::Zfs;
|
||||
}
|
||||
|
||||
/** @brief Remove the given partition manually
|
||||
*
|
||||
* Uses sfdisk to remove @p partition. This should only be used in cases
|
||||
* where using kpmcore to remove the partition would not be appropriate
|
||||
*
|
||||
*/
|
||||
static Calamares::JobResult
|
||||
removePartition( Partition* partition )
|
||||
{
|
||||
auto r = CalamaresUtils::System::instance()->runCommand(
|
||||
{ "sfdisk", "--delete", "--force", partition->devicePath(), QString::number( partition->number() ) },
|
||||
std::chrono::seconds( 5 ) );
|
||||
if ( r.getExitCode() !=0 || r.getOutput().contains("failed") )
|
||||
{
|
||||
return Calamares::JobResult::error(
|
||||
QCoreApplication::translate( DeletePartitionJob::staticMetaObject.className(), "Deletion Failed" ),
|
||||
QCoreApplication::translate( DeletePartitionJob::staticMetaObject.className(),
|
||||
"Failed to delete the partition with output: " )
|
||||
+ r.getOutput() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return Calamares::JobResult::ok();
|
||||
}
|
||||
}
|
||||
|
||||
DeletePartitionJob::DeletePartitionJob( Device* device, Partition* partition )
|
||||
: PartitionJob( partition )
|
||||
, m_device( device )
|
||||
|
@ -49,6 +89,13 @@ DeletePartitionJob::prettyStatusMessage() const
|
|||
Calamares::JobResult
|
||||
DeletePartitionJob::exec()
|
||||
{
|
||||
// The current implementation of remove() for zfs in kpmcore trys to destroy the zpool by label
|
||||
// This isn't what we want here so we delete the partition instead.
|
||||
if ( isZfs( m_partition ) )
|
||||
{
|
||||
return removePartition( m_partition );
|
||||
}
|
||||
|
||||
Report report( nullptr );
|
||||
DeleteOperation op( *m_device, m_partition );
|
||||
op.setStatus( Operation::StatusRunning );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue