Compare commits

...

8 Commits

Author SHA1 Message Date
Teo Mrnjavac
2f2a55a359 Do not assume dev->partitionTable() is not nullptr. 2015-09-30 17:28:41 +02:00
Teo Mrnjavac
07b6b1265b Better error reporting. 2015-09-29 15:54:11 +02:00
Teo Mrnjavac
973f6935e4 Make sure alongside is unavailable if no partitions can be created. 2015-09-29 15:53:39 +02:00
Teo Mrnjavac
825f657bc6 Bump version for 1.1.4. 2015-09-27 14:17:10 +02:00
Teo Mrnjavac
70ddfa25dd Disable Alongside if primary partition limit reached on all devices. 2015-09-27 12:38:35 +02:00
Teo Mrnjavac
eabe0c68d6 Filter from Alongside the root partitions on a device with 4 primaries. 2015-09-27 12:36:33 +02:00
Teo Mrnjavac
2ac1b29401 Obsolete comment is obsolete. 2015-09-27 12:35:52 +02:00
Teo Mrnjavac
34e686decb Keep UUID when clearing swap.
CAL-156
2015-09-27 12:04:45 +02:00
5 changed files with 106 additions and 8 deletions

View File

@@ -94,7 +94,7 @@ set( CALAMARES_TRANSLATION_LANGUAGES ar ast ca cs_CZ da de en en_GB es_MX es fi_
set( CALAMARES_VERSION_MAJOR 1 )
set( CALAMARES_VERSION_MINOR 1 )
set( CALAMARES_VERSION_PATCH 3 )
set( CALAMARES_VERSION_PATCH 4 )
set( CALAMARES_VERSION_RC 0 )
set( CALAMARES_VERSION ${CALAMARES_VERSION_MAJOR}.${CALAMARES_VERSION_MINOR}.${CALAMARES_VERSION_PATCH} )

View File

@@ -125,9 +125,44 @@ AlongsidePage::init( PartitionCoreModule* core , const OsproberEntryList& osprob
string( Calamares::Branding::ProductName ) ) );
} );
// TODO 2.0: move this to a Utils namespace.
// Iterate over devices in devicemodel, foreach device, if it's DOS MBR and limit is
// reached and we have an osprober entry inside it, then disable alongside.
QStringList pathsOfDevicesWithPrimariesLimitReached;
for ( int row = 0; row < m_core->deviceModel()->rowCount(); ++row )
{
const QModelIndex& deviceIndex = m_core->deviceModel()->index( row );
Device* dev = m_core->deviceModel()->deviceForIndex( deviceIndex );
if ( dev->partitionTable() &&
( dev->partitionTable()->type() == PartitionTable::msdos ||
dev->partitionTable()->type() == PartitionTable::msdos_sectorbased ) &&
dev->partitionTable()->numPrimaries() == dev->partitionTable()->maxPrimaries() )
{
// Primaries limit reached!
pathsOfDevicesWithPrimariesLimitReached.append( dev->deviceNode() );
}
}
// End MBR primary limit check.
cDebug() << "Devices with limit reached:" << pathsOfDevicesWithPrimariesLimitReached;
cDebug() << "Osprober entries:";
foreach ( const OsproberEntry& e, osproberEntries )
{
if ( e.canBeResized )
cDebug() << " *" << e.path << e.line;
// TODO 2.0: move this to a Utils namespace.
bool cantCreatePartitions = false;
foreach ( const QString& devicePath, pathsOfDevicesWithPrimariesLimitReached )
{
if ( e.path.startsWith( devicePath ) )
{
cantCreatePartitions = true;
break;
}
}
// End partition creatable check.
if ( e.canBeResized && !cantCreatePartitions )
m_partitionsComboBox->addItem( e.prettyName + " (" + e.path + ")", e.path );
}
setNextEnabled( true );

View File

@@ -22,6 +22,8 @@
#include "core/DeviceModel.h"
#include "core/PartitionModel.h"
#include "OsproberEntry.h"
#include "core/partitiontable.h"
#include "core/device.h"
#include "PrettyRadioButton.h"
@@ -111,6 +113,26 @@ ChoicePage::init( PartitionCoreModule* core, const OsproberEntryList& osproberEn
m_itemsLayout->addWidget( eraseButton );
m_itemsLayout->setSpacing( CalamaresUtils::defaultFontHeight() / 2 );
// TODO 2.0: move this to a Utils namespace.
// Iterate over devices in devicemodel, foreach device, if it's DOS MBR and limit is
// reached and we have an osprober entry inside it, then disable alongside.
QStringList pathsOfDevicesWithPrimariesLimitReached;
for ( int row = 0; row < m_core->deviceModel()->rowCount(); ++row )
{
const QModelIndex& deviceIndex = m_core->deviceModel()->index( row );
Device* dev = m_core->deviceModel()->deviceForIndex( deviceIndex );
if ( dev->partitionTable() &&
( dev->partitionTable()->type() == PartitionTable::msdos ||
dev->partitionTable()->type() == PartitionTable::msdos_sectorbased ) &&
dev->partitionTable()->numPrimaries() == dev->partitionTable()->maxPrimaries() )
{
// Primaries limit reached!
pathsOfDevicesWithPrimariesLimitReached.append( dev->deviceNode() );
}
}
cDebug() << "Devices with limit reached:" << pathsOfDevicesWithPrimariesLimitReached;
if ( osproberEntries.count() == 0 )
{
CALAMARES_RETRANSLATE(
@@ -137,6 +159,18 @@ ChoicePage::init( PartitionCoreModule* core, const OsproberEntryList& osproberEn
{
QString osName = osproberEntries.first().prettyName;
// Find out if our osprober entry (which is the shrink candidate) is on a
// device that can accommodate more partitions.
bool cantCreatePartitions = false;
foreach ( const QString& devicePath, pathsOfDevicesWithPrimariesLimitReached )
{
if ( osproberEntries.first().path.startsWith( devicePath ) )
{
cantCreatePartitions = true;
break;
}
}
if ( !osName.isEmpty() )
{
CALAMARES_RETRANSLATE(
@@ -207,6 +241,8 @@ ChoicePage::init( PartitionCoreModule* core, const OsproberEntryList& osproberEn
}
if ( !osproberEntries.first().canBeResized )
alongsideButton->hide();
if ( cantCreatePartitions )
alongsideButton->hide();
}
else
{
@@ -223,6 +259,27 @@ ChoicePage::init( PartitionCoreModule* core, const OsproberEntryList& osproberEn
}
}
// Find out if at least one of our osprober entries is on a
// device that can accommodate more partitions.
bool atLeastOneCanCreatePartitions = false;
foreach ( const OsproberEntry& entry, osproberEntries )
{
bool cantCreatePartitions = false;
foreach ( const QString& devicePath, pathsOfDevicesWithPrimariesLimitReached )
{
if ( entry.path.startsWith( devicePath ) )
{
cantCreatePartitions = true;
break;
}
}
if ( entry.canBeResized && !cantCreatePartitions )
{
atLeastOneCanCreatePartitions = true;
break;
}
}
CALAMARES_RETRANSLATE(
m_messageLabel->setText( tr( "This computer currently has multiple operating systems on it. "
"What would you like to do?" ) );
@@ -254,7 +311,7 @@ ChoicePage::init( PartitionCoreModule* core, const OsproberEntryList& osproberEn
string( Calamares::Branding::ShortVersionedName ) ) );
)
if ( !atLeastOneCanBeResized )
if ( !( atLeastOneCanBeResized && atLeastOneCanCreatePartitions ) )
alongsideButton->hide();
}

View File

@@ -458,7 +458,6 @@ 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/" ) )

View File

@@ -198,10 +198,17 @@ QString
ClearMountsJob::tryClearSwap( const QString& partPath )
{
QProcess process;
process.start( "mkswap", { partPath } );
process.start( "blkid", { "-s", "UUID", "-o", "value", partPath } );
process.waitForFinished();
if ( process.exitCode() == 0 )
return QString( "Successfully cleared swap %1." ).arg( partPath );
QString swapPartUuid = QString::fromLocal8Bit( process.readAllStandardOutput() ).simplified();
if ( process.exitCode() != 0 ||
swapPartUuid.isEmpty() )
return QString();
return QString();
process.start( "mkswap", { "-U", swapPartUuid, partPath } );
process.waitForFinished();
if ( process.exitCode() != 0 )
return QString();
return QString( "Successfully cleared swap %1." ).arg( partPath );
}