PMUtils is now KPMHelpers. Also fixup after PartUtils refactor.

main
Teo Mrnjavac 9 years ago
parent 95e87391a4
commit 5f54a56513

@ -24,11 +24,12 @@ calamares_add_plugin( partition
core/BootLoaderModel.cpp core/BootLoaderModel.cpp
core/ColorUtils.cpp core/ColorUtils.cpp
core/DeviceModel.cpp core/DeviceModel.cpp
core/KPMHelpers.cpp
core/PartitionCoreModule.cpp core/PartitionCoreModule.cpp
core/PartitionInfo.cpp core/PartitionInfo.cpp
core/PartitionIterator.cpp core/PartitionIterator.cpp
core/PartitionModel.cpp core/PartitionModel.cpp
core/PMUtils.cpp core/PartUtils.cpp
gui/ChoicePage.cpp gui/ChoicePage.cpp
gui/CreatePartitionDialog.cpp gui/CreatePartitionDialog.cpp
gui/EditExistingPartitionDialog.cpp gui/EditExistingPartitionDialog.cpp

@ -20,7 +20,7 @@
#include "core/BootLoaderModel.h" #include "core/BootLoaderModel.h"
#include "core/PartitionInfo.h" #include "core/PartitionInfo.h"
#include "core/PMUtils.h" #include "core/KPMHelpers.h"
// KPMcore // KPMcore
#include <kpmcore/core/device.h> #include <kpmcore/core/device.h>
@ -71,12 +71,12 @@ BootLoaderModel::update()
createMbrItems(); createMbrItems();
QString partitionText; QString partitionText;
Partition* partition = PMUtils::findPartitionByMountPoint( m_devices, "/boot" ); Partition* partition = KPMHelpers::findPartitionByMountPoint( m_devices, "/boot" );
if ( partition ) if ( partition )
partitionText = tr( "Boot Partition" ); partitionText = tr( "Boot Partition" );
else else
{ {
partition = PMUtils::findPartitionByMountPoint( m_devices, "/" ); partition = KPMHelpers::findPartitionByMountPoint( m_devices, "/" );
if ( partition ) if ( partition )
partitionText = tr( "System Partition" ); partitionText = tr( "System Partition" );
} }

@ -19,7 +19,7 @@
#include "core/ColorUtils.h" #include "core/ColorUtils.h"
#include "core/PMUtils.h" #include "core/KPMHelpers.h"
#include "core/PartitionIterator.h" #include "core/PartitionIterator.h"
// KPMcore // KPMcore
@ -74,7 +74,7 @@ _findRootForPartition( PartitionNode* partition )
QColor QColor
colorForPartition( Partition* partition ) colorForPartition( Partition* partition )
{ {
if ( PMUtils::isPartitionFreeSpace( partition ) ) if ( KPMHelpers::isPartitionFreeSpace( partition ) )
return FREE_SPACE_COLOR; return FREE_SPACE_COLOR;
if ( partition->roles().has( PartitionRole::Extended ) ) if ( partition->roles().has( PartitionRole::Extended ) )
return EXTENDED_COLOR; return EXTENDED_COLOR;
@ -96,17 +96,17 @@ colorForPartition( Partition* partition )
Partition* child = *it; Partition* child = *it;
if ( child == partition ) if ( child == partition )
break; break;
if ( !PMUtils::isPartitionFreeSpace( child ) && if ( !KPMHelpers::isPartitionFreeSpace( child ) &&
!child->hasChildren() ) !child->hasChildren() )
{ {
if ( PMUtils::isPartitionNew( child ) ) if ( KPMHelpers::isPartitionNew( child ) )
++newColorIdx; ++newColorIdx;
else else
++colorIdx; ++colorIdx;
} }
} }
if ( PMUtils::isPartitionNew( partition ) ) if ( KPMHelpers::isPartitionNew( partition ) )
return NEW_PARTITION_COLORS[ newColorIdx % NUM_NEW_PARTITION_COLORS ]; return NEW_PARTITION_COLORS[ newColorIdx % NUM_NEW_PARTITION_COLORS ];
s_partitionColorsCache.insert( partition->partitionPath(), s_partitionColorsCache.insert( partition->partitionPath(),
@ -129,9 +129,9 @@ colorForPartitionInFreeSpace( Partition* partition )
Partition* child = *it; Partition* child = *it;
if ( child == partition ) if ( child == partition )
break; break;
if ( !PMUtils::isPartitionFreeSpace( child ) && if ( !KPMHelpers::isPartitionFreeSpace( child ) &&
!child->hasChildren() && !child->hasChildren() &&
PMUtils::isPartitionNew( child ) ) KPMHelpers::isPartitionNew( child ) )
++newColorIdx; ++newColorIdx;
} }
return NEW_PARTITION_COLORS[ newColorIdx % NUM_NEW_PARTITION_COLORS ]; return NEW_PARTITION_COLORS[ newColorIdx % NUM_NEW_PARTITION_COLORS ];

@ -17,7 +17,7 @@
* along with Calamares. If not, see <http://www.gnu.org/licenses/>. * along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "core/PMUtils.h" #include "core/KPMHelpers.h"
#include "core/PartitionInfo.h" #include "core/PartitionInfo.h"
#include "core/PartitionIterator.h" #include "core/PartitionIterator.h"
@ -30,7 +30,7 @@
#include <QDebug> #include <QDebug>
namespace PMUtils namespace KPMHelpers
{ {
static bool s_KPMcoreInited = false; static bool s_KPMcoreInited = false;

@ -16,8 +16,8 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>. * along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PMUTILS_H #ifndef KPMHELPERS_H
#define PMUTILS_H #define KPMHELPERS_H
// KPMcore // KPMcore
#include <kpmcore/fs/filesystem.h> #include <kpmcore/fs/filesystem.h>
@ -35,7 +35,7 @@ class PartitionRole;
/** /**
* Helper functions to manipulate partitions * Helper functions to manipulate partitions
*/ */
namespace PMUtils namespace KPMHelpers
{ {
/** /**
@ -87,4 +87,4 @@ Partition* createNewPartition( PartitionNode* parent, const Device& device, cons
Partition* clonePartition( Device* device, Partition* partition ); Partition* clonePartition( Device* device, Partition* partition );
} }
#endif /* PMUTILS_H */ #endif /* KPMHELPERS_H */

@ -24,7 +24,7 @@
#include "core/PartitionInfo.h" #include "core/PartitionInfo.h"
#include "core/PartitionIterator.h" #include "core/PartitionIterator.h"
#include "core/PartitionModel.h" #include "core/PartitionModel.h"
#include "core/PMUtils.h" #include "core/KPMHelpers.h"
#include "jobs/ClearMountsJob.h" #include "jobs/ClearMountsJob.h"
#include "jobs/ClearTempMountsJob.h" #include "jobs/ClearTempMountsJob.h"
#include "jobs/CreatePartitionJob.h" #include "jobs/CreatePartitionJob.h"
@ -96,7 +96,7 @@ PartitionCoreModule::PartitionCoreModule( QObject* parent )
, m_deviceModel( new DeviceModel( this ) ) , m_deviceModel( new DeviceModel( this ) )
, m_bootLoaderModel( new BootLoaderModel( this ) ) , m_bootLoaderModel( new BootLoaderModel( this ) )
{ {
if ( !PMUtils::initKPMcore() ) if ( !KPMHelpers::initKPMcore() )
qFatal( "Failed to initialize KPMcore backend" ); qFatal( "Failed to initialize KPMcore backend" );
FileSystemFactory::init(); FileSystemFactory::init();
init(); init();
@ -216,7 +216,7 @@ PartitionCoreModule::deletePartition( Device* device, Partition* partition )
// deleting them, so let's play it safe and keep our own list. // deleting them, so let's play it safe and keep our own list.
QList< Partition* > lst; QList< Partition* > lst;
for ( auto childPartition : partition->children() ) for ( auto childPartition : partition->children() )
if ( !PMUtils::isPartitionFreeSpace( childPartition ) ) if ( !KPMHelpers::isPartitionFreeSpace( childPartition ) )
lst << childPartition; lst << childPartition;
for ( auto partition : lst ) for ( auto partition : lst )
@ -416,7 +416,7 @@ PartitionCoreModule::scanForEfiSystemPartitions()
// The following findPartitions call and lambda should be scrapped and // The following findPartitions call and lambda should be scrapped and
// rewritten based on libKPM. -- Teo 5/2015 // rewritten based on libKPM. -- Teo 5/2015
QList< Partition* > efiSystemPartitions = QList< Partition* > efiSystemPartitions =
PMUtils::findPartitions( devices, KPMHelpers::findPartitions( devices,
[]( Partition* partition ) -> bool []( Partition* partition ) -> bool
{ {
QProcess process; QProcess process;

@ -20,7 +20,7 @@
#include "core/ColorUtils.h" #include "core/ColorUtils.h"
#include "core/PartitionInfo.h" #include "core/PartitionInfo.h"
#include "core/PMUtils.h" #include "core/KPMHelpers.h"
#include "utils/Logger.h" #include "utils/Logger.h"
// CalaPM // CalaPM
@ -132,11 +132,11 @@ PartitionModel::data( const QModelIndex& index, int role ) const
int col = index.column(); int col = index.column();
if ( col == NameColumn ) if ( col == NameColumn )
{ {
if ( PMUtils::isPartitionFreeSpace( partition ) ) if ( KPMHelpers::isPartitionFreeSpace( partition ) )
return tr( "Free Space" ); return tr( "Free Space" );
else else
{ {
return PMUtils::isPartitionNew( partition ) return KPMHelpers::isPartitionNew( partition )
? tr( "New partition" ) ? tr( "New partition" )
: partition->partitionPath(); : partition->partitionPath();
} }
@ -161,7 +161,7 @@ PartitionModel::data( const QModelIndex& index, int role ) const
case SizeRole: case SizeRole:
return ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSectorSize(); return ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSectorSize();
case IsFreeSpaceRole: case IsFreeSpaceRole:
return PMUtils::isPartitionFreeSpace( partition ); return KPMHelpers::isPartitionFreeSpace( partition );
default: default:
return QVariant(); return QVariant();
} }

@ -21,7 +21,7 @@
#include "core/ColorUtils.h" #include "core/ColorUtils.h"
#include "core/PartitionCoreModule.h" #include "core/PartitionCoreModule.h"
#include "core/DeviceModel.h" #include "core/DeviceModel.h"
#include "core/PMUtils.h" #include "core/KPMHelpers.h"
#include "core/PartitionInfo.h" #include "core/PartitionInfo.h"
#include "core/PartitionIterator.h" #include "core/PartitionIterator.h"
#include "gui/PartitionSplitterWidget.h" #include "gui/PartitionSplitterWidget.h"
@ -146,7 +146,7 @@ AlongsidePage::onPartitionSelected( int comboBoxIndex )
for ( int i = 0; i < dm->rowCount(); ++i ) for ( int i = 0; i < dm->rowCount(); ++i )
{ {
Device* dev = dm->deviceForIndex( dm->index( i ) ); Device* dev = dm->deviceForIndex( dm->index( i ) );
Partition* candidate = PMUtils::findPartitionByPath( { dev }, path ); Partition* candidate = KPMHelpers::findPartitionByPath( { dev }, path );
if ( candidate ) if ( candidate )
{ {
// store candidate->partitionPath() here! // store candidate->partitionPath() here!
@ -280,7 +280,7 @@ AlongsidePage::applyChanges()
for ( int i = 0; i < dm->rowCount(); ++i ) for ( int i = 0; i < dm->rowCount(); ++i )
{ {
Device* dev = dm->deviceForIndex( dm->index( i ) ); Device* dev = dm->deviceForIndex( dm->index( i ) );
Partition* candidate = PMUtils::findPartitionByPath( { dev }, path ); Partition* candidate = KPMHelpers::findPartitionByPath( { dev }, path );
if ( candidate ) if ( candidate )
{ {
qint64 firstSector = candidate->firstSector(); qint64 firstSector = candidate->firstSector();
@ -289,7 +289,7 @@ AlongsidePage::applyChanges()
dev->logicalSectorSize(); dev->logicalSectorSize();
m_core->resizePartition( dev, candidate, firstSector, newLastSector ); m_core->resizePartition( dev, candidate, firstSector, newLastSector );
Partition* newPartition = PMUtils::createNewPartition( Partition* newPartition = KPMHelpers::createNewPartition(
candidate->parent(), candidate->parent(),
*dev, *dev,
candidate->roles(), candidate->roles(),

@ -21,7 +21,7 @@
#include <QWidget> #include <QWidget>
#include "OsproberEntry.h" #include "core/OsproberEntry.h"
class QComboBox; class QComboBox;
class QLabel; class QLabel;

@ -21,7 +21,7 @@
#include "core/PartitionCoreModule.h" #include "core/PartitionCoreModule.h"
#include "core/DeviceModel.h" #include "core/DeviceModel.h"
#include "core/PartitionModel.h" #include "core/PartitionModel.h"
#include "OsproberEntry.h" #include "core/OsproberEntry.h"
#include "PrettyRadioButton.h" #include "PrettyRadioButton.h"

@ -21,7 +21,7 @@
#include <QWidget> #include <QWidget>
#include "OsproberEntry.h" #include "core/OsproberEntry.h"
class QBoxLayout; class QBoxLayout;
class QLabel; class QLabel;

@ -20,7 +20,7 @@
#include "core/ColorUtils.h" #include "core/ColorUtils.h"
#include "core/PartitionInfo.h" #include "core/PartitionInfo.h"
#include "core/PMUtils.h" #include "core/KPMHelpers.h"
#include "gui/PartitionSizeController.h" #include "gui/PartitionSizeController.h"
#include "ui_CreatePartitionDialog.h" #include "ui_CreatePartitionDialog.h"
@ -141,7 +141,7 @@ CreatePartitionDialog::createPartition()
FileSystem::Type fsType = m_role.has( PartitionRole::Extended ) FileSystem::Type fsType = m_role.has( PartitionRole::Extended )
? FileSystem::Extended ? FileSystem::Extended
: FileSystem::typeForName( m_ui->fsComboBox->currentText() ); : FileSystem::typeForName( m_ui->fsComboBox->currentText() );
Partition* partition = PMUtils::createNewPartition( Partition* partition = KPMHelpers::createNewPartition(
m_parent, m_parent,
*m_device, *m_device,
m_role, m_role,
@ -170,7 +170,7 @@ CreatePartitionDialog::updateMountPointUi()
void void
CreatePartitionDialog::initPartResizerWidget( Partition* partition ) CreatePartitionDialog::initPartResizerWidget( Partition* partition )
{ {
QColor color = PMUtils::isPartitionFreeSpace( partition ) QColor color = KPMHelpers::isPartitionFreeSpace( partition )
? ColorUtils::colorForPartitionInFreeSpace( partition ) ? ColorUtils::colorForPartitionInFreeSpace( partition )
: ColorUtils::colorForPartition( partition ); : ColorUtils::colorForPartition( partition );
m_partitionSizeController->init( m_device, partition, color ); m_partitionSizeController->init( m_device, partition, color );

@ -21,7 +21,7 @@
#include <core/ColorUtils.h> #include <core/ColorUtils.h>
#include <core/PartitionCoreModule.h> #include <core/PartitionCoreModule.h>
#include <core/PartitionInfo.h> #include <core/PartitionInfo.h>
#include <core/PMUtils.h> #include <core/KPMHelpers.h>
#include <gui/PartitionSizeController.h> #include <gui/PartitionSizeController.h>
#include <ui_EditExistingPartitionDialog.h> #include <ui_EditExistingPartitionDialog.h>
@ -125,7 +125,7 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
{ {
if ( m_ui->formatRadioButton->isChecked() ) if ( m_ui->formatRadioButton->isChecked() )
{ {
Partition* newPartition = PMUtils::createNewPartition( Partition* newPartition = KPMHelpers::createNewPartition(
m_partition->parent(), m_partition->parent(),
*m_device, *m_device,
m_partition->roles(), m_partition->roles(),
@ -158,7 +158,7 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
} }
else // otherwise, we delete and recreate the partition with new fs type else // otherwise, we delete and recreate the partition with new fs type
{ {
Partition* newPartition = PMUtils::createNewPartition( Partition* newPartition = KPMHelpers::createNewPartition(
m_partition->parent(), m_partition->parent(),
*m_device, *m_device,
m_partition->roles(), m_partition->roles(),

@ -20,7 +20,7 @@
#include "core/DeviceModel.h" #include "core/DeviceModel.h"
#include "core/PartitionCoreModule.h" #include "core/PartitionCoreModule.h"
#include "core/PMUtils.h" #include "core/KPMHelpers.h"
#include "core/PartitionInfo.h" #include "core/PartitionInfo.h"
#include "gui/PartitionPreview.h" #include "gui/PartitionPreview.h"
@ -162,7 +162,7 @@ EraseDiskPage::doAutopartition( Device* dev )
{ {
qint64 lastSector = firstFreeSector + ( uefisys_part_size MiB / dev->logicalSectorSize() ); qint64 lastSector = firstFreeSector + ( uefisys_part_size MiB / dev->logicalSectorSize() );
m_core->createPartitionTable( dev, PartitionTable::gpt ); m_core->createPartitionTable( dev, PartitionTable::gpt );
Partition* efiPartition = PMUtils::createNewPartition( Partition* efiPartition = KPMHelpers::createNewPartition(
dev->partitionTable(), dev->partitionTable(),
*dev, *dev,
PartitionRole( PartitionRole::Primary ), PartitionRole( PartitionRole::Primary ),
@ -201,7 +201,7 @@ EraseDiskPage::doAutopartition( Device* dev )
lastSectorForRoot -= suggestedSwapSizeB / dev->logicalSectorSize() + 1; lastSectorForRoot -= suggestedSwapSizeB / dev->logicalSectorSize() + 1;
} }
Partition* rootPartition = PMUtils::createNewPartition( Partition* rootPartition = KPMHelpers::createNewPartition(
dev->partitionTable(), dev->partitionTable(),
*dev, *dev,
PartitionRole( PartitionRole::Primary ), PartitionRole( PartitionRole::Primary ),
@ -215,7 +215,7 @@ EraseDiskPage::doAutopartition( Device* dev )
if ( shouldCreateSwap ) if ( shouldCreateSwap )
{ {
Partition* swapPartition = PMUtils::createNewPartition( Partition* swapPartition = KPMHelpers::createNewPartition(
dev->partitionTable(), dev->partitionTable(),
*dev, *dev,
PartitionRole( PartitionRole::Primary ), PartitionRole( PartitionRole::Primary ),

@ -23,7 +23,7 @@
#include "core/DeviceModel.h" #include "core/DeviceModel.h"
#include "core/PartitionCoreModule.h" #include "core/PartitionCoreModule.h"
#include "core/PartitionModel.h" #include "core/PartitionModel.h"
#include "core/PMUtils.h" #include "core/KPMHelpers.h"
#include "gui/CreatePartitionDialog.h" #include "gui/CreatePartitionDialog.h"
#include "gui/EditExistingPartitionDialog.h" #include "gui/EditExistingPartitionDialog.h"
@ -102,7 +102,7 @@ PartitionPage::updateButtons()
Q_ASSERT( model ); Q_ASSERT( model );
Partition* partition = model->partitionForIndex( index ); Partition* partition = model->partitionForIndex( index );
Q_ASSERT( partition ); Q_ASSERT( partition );
bool isFree = PMUtils::isPartitionFreeSpace( partition ); bool isFree = KPMHelpers::isPartitionFreeSpace( partition );
bool isExtended = partition->roles().has( PartitionRole::Extended ); bool isExtended = partition->roles().has( PartitionRole::Extended );
create = isFree; create = isFree;
@ -169,7 +169,7 @@ PartitionPage::onEditClicked()
Partition* partition = model->partitionForIndex( index ); Partition* partition = model->partitionForIndex( index );
Q_ASSERT( partition ); Q_ASSERT( partition );
if ( PMUtils::isPartitionNew( partition ) ) if ( KPMHelpers::isPartitionNew( partition ) )
updatePartitionToCreate( model->device(), partition ); updatePartitionToCreate( model->device(), partition );
else else
editExistingPartition( model->device(), partition ); editExistingPartition( model->device(), partition );
@ -214,7 +214,7 @@ PartitionPage::onPartitionViewActivated()
// but I don't expect there will be other occurences of triggering the same // but I don't expect there will be other occurences of triggering the same
// action from multiple UI elements in this page, so it does not feel worth // action from multiple UI elements in this page, so it does not feel worth
// the price. // the price.
if ( PMUtils::isPartitionFreeSpace( partition ) ) if ( KPMHelpers::isPartitionFreeSpace( partition ) )
m_ui->createButton->click(); m_ui->createButton->click();
else else
m_ui->editButton->click(); m_ui->editButton->click();

@ -19,7 +19,7 @@
#include "gui/PartitionSizeController.h" #include "gui/PartitionSizeController.h"
#include "core/ColorUtils.h" #include "core/ColorUtils.h"
#include "core/PMUtils.h" #include "core/KPMHelpers.h"
// Qt // Qt
#include <QSpinBox> #include <QSpinBox>
@ -45,7 +45,7 @@ PartitionSizeController::init( Device* device, Partition* partition, const QColo
// because it means we would have to revert them if the user cancel the // because it means we would have to revert them if the user cancel the
// dialog the widget is in. Therefore we init PartResizerWidget with a clone // dialog the widget is in. Therefore we init PartResizerWidget with a clone
// of the original partition. // of the original partition.
m_partition.reset( PMUtils::clonePartition( m_device, partition ) ); m_partition.reset( KPMHelpers::clonePartition( m_device, partition ) );
m_partitionColor = color; m_partitionColor = color;
} }

@ -22,7 +22,9 @@
#include "core/DeviceModel.h" #include "core/DeviceModel.h"
#include "core/PartitionCoreModule.h" #include "core/PartitionCoreModule.h"
#include "core/PartitionModel.h" #include "core/PartitionModel.h"
#include "core/PMUtils.h" #include "core/KPMHelpers.h"
#include "core/OsproberEntry.h"
#include "core/PartUtils.h"
#include "gui/ChoicePage.h" #include "gui/ChoicePage.h"
#include "gui/EraseDiskPage.h" #include "gui/EraseDiskPage.h"
#include "gui/AlongsidePage.h" #include "gui/AlongsidePage.h"
@ -72,7 +74,7 @@ PartitionViewStep::PartitionViewStep( QObject* parent )
connect( timer, &QTimer::timeout, connect( timer, &QTimer::timeout,
[=]() [=]()
{ {
OsproberEntryList osproberEntries = runOsprober(); OsproberEntryList osproberEntries = PartUtils::runOsprober( m_core );
m_choicePage->init( m_core, osproberEntries ); m_choicePage->init( m_core, osproberEntries );
m_erasePage->init( m_core ); m_erasePage->init( m_core );
@ -112,60 +114,6 @@ PartitionViewStep::~PartitionViewStep()
} }
OsproberEntryList
PartitionViewStep::runOsprober()
{
QString osproberOutput;
QProcess osprober;
osprober.setProgram( "os-prober" );
osprober.setProcessChannelMode( QProcess::SeparateChannels );
osprober.start();
if ( !osprober.waitForStarted() )
{
cDebug() << "ERROR: os-prober cannot start.";
}
else if ( !osprober.waitForFinished( 60000 ) )
{
cDebug() << "ERROR: os-prober timed out.";
}
else
{
osproberOutput.append(
QString::fromLocal8Bit(
osprober.readAllStandardOutput() ).trimmed() );
}
QString osProberReport( "Osprober lines, clean:\n" );
QStringList osproberCleanLines;
OsproberEntryList osproberEntries;
foreach ( const QString& line, osproberOutput.split( '\n' ) )
{
if ( !line.simplified().isEmpty() )
{
QStringList lineColumns = line.split( ':' );
QString prettyName;
if ( !lineColumns.value( 1 ).simplified().isEmpty() )
prettyName = lineColumns.value( 1 ).simplified();
else if ( !lineColumns.value( 2 ).simplified().isEmpty() )
prettyName = lineColumns.value( 2 ).simplified();
QString path = lineColumns.value( 0 ).simplified();
if ( !path.startsWith( "/dev/" ) ) //basic sanity check
continue;
osproberEntries.append( { prettyName, path, canBeResized( path ), lineColumns } );
osproberCleanLines.append( line );
}
}
osProberReport.append( osproberCleanLines.join( '\n' ) );
cDebug() << osProberReport;
Calamares::JobQueue::instance()->globalStorage()->insert( "osproberLines", osproberCleanLines );
return osproberEntries;
}
QString QString
PartitionViewStep::prettyName() const PartitionViewStep::prettyName() const
{ {
@ -456,57 +404,4 @@ PartitionViewStep::jobs() const
} }
bool
PartitionViewStep::canBeResized( const QString& partitionPath )
{
//FIXME: check for max partitions count on DOS MBR
cDebug() << "checking if" << partitionPath << "can be resized.";
QString partitionWithOs = partitionPath;
if ( partitionWithOs.startsWith( "/dev/" ) )
{
cDebug() << partitionWithOs << "seems like a good path";
bool canResize = false;
DeviceModel* dm = m_core->deviceModel();
for ( int i = 0; i < dm->rowCount(); ++i )
{
Device* dev = dm->deviceForIndex( dm->index( i ) );
Partition* candidate = PMUtils::findPartitionByPath( { dev }, partitionWithOs );
if ( candidate )
{
cDebug() << "found Partition* for" << partitionWithOs;
if ( !candidate->fileSystem().supportGrow() ||
!candidate->fileSystem().supportShrink() )
return false;
bool ok = false;
double requiredStorageGB = Calamares::JobQueue::instance()
->globalStorage()
->value( "requiredStorageGB" )
.toDouble( &ok );
qint64 availableStorageB = candidate->available();
// We require a little more for partitioning overhead and swap file
// TODO: maybe make this configurable?
qint64 requiredStorageB = ( requiredStorageGB + 0.1 + 2.0 ) * 1024 * 1024 * 1024;
cDebug() << "Required storage B:" << requiredStorageB
<< QString( "(%1GB)" ).arg( requiredStorageB / 1024 / 1024 / 1024 );
cDebug() << "Available storage B:" << availableStorageB
<< QString( "(%1GB)" ).arg( availableStorageB / 1024 / 1024 / 1024 );
if ( ok &&
availableStorageB > requiredStorageB )
{
cDebug() << "Partition" << partitionWithOs << "authorized for resize + autopartition install.";
return true;
}
}
}
}
cDebug() << "Partition" << partitionWithOs << "CANNOT BE RESIZED FOR AUTOINSTALL.";
return false;
}
CALAMARES_PLUGIN_FACTORY_DEFINITION( PartitionViewStepFactory, registerPlugin<PartitionViewStep>(); ) CALAMARES_PLUGIN_FACTORY_DEFINITION( PartitionViewStepFactory, registerPlugin<PartitionViewStep>(); )

@ -20,8 +20,6 @@
#ifndef PARTITIONVIEWSTEP_H #ifndef PARTITIONVIEWSTEP_H
#define PARTITIONVIEWSTEP_H #define PARTITIONVIEWSTEP_H
#include "OsproberEntry.h"
#include <utils/PluginFactory.h> #include <utils/PluginFactory.h>
#include <viewpages/ViewStep.h> #include <viewpages/ViewStep.h>
@ -71,9 +69,6 @@ public:
QList< Calamares::job_ptr > jobs() const override; QList< Calamares::job_ptr > jobs() const override;
private: private:
OsproberEntryList runOsprober();
bool canBeResized( const QString& partitionPath );
PartitionCoreModule* m_core; PartitionCoreModule* m_core;
QStackedWidget* m_widget; QStackedWidget* m_widget;
ChoicePage* m_choicePage; ChoicePage* m_choicePage;

@ -21,7 +21,7 @@
#include "ui_ReplacePage.h" #include "ui_ReplacePage.h"
#include "core/PartitionCoreModule.h" #include "core/PartitionCoreModule.h"
#include "core/PMUtils.h" #include "core/KPMHelpers.h"
#include "core/PartitionInfo.h" #include "core/PartitionInfo.h"
#include "core/DeviceModel.h" #include "core/DeviceModel.h"
@ -109,7 +109,7 @@ ReplacePage::applyChanges()
if ( partition ) if ( partition )
{ {
Device* dev = model->device(); Device* dev = model->device();
Partition* newPartition = PMUtils::createNewPartition( Partition* newPartition = KPMHelpers::createNewPartition(
partition->parent(), partition->parent(),
*dev, *dev,
partition->roles(), partition->roles(),

@ -23,7 +23,7 @@
#include "JobQueue.h" #include "JobQueue.h"
#include "core/PartitionInfo.h" #include "core/PartitionInfo.h"
#include "core/PartitionIterator.h" #include "core/PartitionIterator.h"
#include "core/PMUtils.h" #include "core/KPMHelpers.h"
#include "Branding.h" #include "Branding.h"
#include "utils/Logger.h" #include "utils/Logger.h"
@ -195,7 +195,7 @@ FillGlobalStorageJob::createBootLoaderMap() const
QString path = m_bootLoaderPath; QString path = m_bootLoaderPath;
if ( !path.startsWith( "/dev/" ) ) if ( !path.startsWith( "/dev/" ) )
{ {
Partition* partition = PMUtils::findPartitionByMountPoint( m_devices, path ); Partition* partition = KPMHelpers::findPartitionByMountPoint( m_devices, path );
if ( !partition ) if ( !partition )
return QVariant(); return QVariant();
path = partition->partitionPath(); path = partition->partitionPath();

@ -4,7 +4,7 @@ include( ECMAddTests )
set( PartitionModule_SOURCE_DIR .. ) set( PartitionModule_SOURCE_DIR .. )
set( partitionjobtests_SRCS set( partitionjobtests_SRCS
${PartitionModule_SOURCE_DIR}/core/PMUtils.cpp ${PartitionModule_SOURCE_DIR}/core/KPMHelpers.cpp
${PartitionModule_SOURCE_DIR}/core/PartitionInfo.cpp ${PartitionModule_SOURCE_DIR}/core/PartitionInfo.cpp
${PartitionModule_SOURCE_DIR}/core/PartitionIterator.cpp ${PartitionModule_SOURCE_DIR}/core/PartitionIterator.cpp
${PartitionModule_SOURCE_DIR}/jobs/CheckFileSystemJob.cpp ${PartitionModule_SOURCE_DIR}/jobs/CheckFileSystemJob.cpp

@ -21,7 +21,7 @@
#include <jobs/CreatePartitionJob.h> #include <jobs/CreatePartitionJob.h>
#include <jobs/CreatePartitionTableJob.h> #include <jobs/CreatePartitionTableJob.h>
#include <jobs/ResizePartitionJob.h> #include <jobs/ResizePartitionJob.h>
#include <core/PMUtils.h> #include <core/KPMHelpers.h>
// CalaPM // CalaPM
#include <CalaPM.h> #include <CalaPM.h>
@ -113,7 +113,7 @@ static Partition*
firstFreePartition( PartitionNode* parent ) firstFreePartition( PartitionNode* parent )
{ {
for( auto child : parent->children() ) for( auto child : parent->children() )
if ( PMUtils::isPartitionFreeSpace( child ) ) if ( KPMHelpers::isPartitionFreeSpace( child ) )
return child; return child;
return nullptr; return nullptr;
} }
@ -353,7 +353,7 @@ PartitionJobTests::testResizePartition()
Partition* freePartition = firstFreePartition( m_device->partitionTable() ); Partition* freePartition = firstFreePartition( m_device->partitionTable() );
QVERIFY( freePartition ); QVERIFY( freePartition );
Partition* partition = PMUtils::createNewPartition( freePartition->parent(), *m_device, PartitionRole( PartitionRole::Primary ), FileSystem::Ext4, oldFirst, oldLast ); Partition* partition = KPMHelpers::createNewPartition( freePartition->parent(), *m_device, PartitionRole( PartitionRole::Primary ), FileSystem::Ext4, oldFirst, oldLast );
CreatePartitionJob* job = new CreatePartitionJob( m_device.data(), partition ); CreatePartitionJob* job = new CreatePartitionJob( m_device.data(), partition );
job->updatePreview(); job->updatePreview();
m_queue.enqueue( job_ptr( job ) ); m_queue.enqueue( job_ptr( job ) );

Loading…
Cancel
Save