Merge branch 'issue-1175'

This commit is contained in:
Adriaan de Groot 2020-04-07 21:37:35 +02:00
commit eb6270982f
27 changed files with 280 additions and 220 deletions

View file

@ -910,9 +910,23 @@ PartitionCoreModule::layoutApply( Device* dev,
bool isEfi = PartUtils::isEfiSystem(); bool isEfi = PartUtils::isEfiSystem();
QList< Partition* > partList = m_partLayout->execute( dev, firstSector, lastSector, luksPassphrase, parent, role ); QList< Partition* > partList = m_partLayout->execute( dev, firstSector, lastSector, luksPassphrase, parent, role );
foreach ( Partition* part, partList ) // Partition::mountPoint() tells us where it is mounted **now**, while
// PartitionInfo::mountPoint() says where it will be mounted in the target system.
// .. the latter is more interesting.
//
// If we have a separate /boot, mark that one as bootable, otherwise mark
// the root / as bootable.
//
// TODO: perhaps the partition that holds the bootloader?
const QString boot = QStringLiteral( "/boot" );
const QString root = QStringLiteral( "/" );
const auto is_boot = [&](Partition*p) -> bool {return PartitionInfo::mountPoint(p) == boot || p->mountPoint() == boot;};
const auto is_root = [&](Partition*p) -> bool {return PartitionInfo::mountPoint(p) == root || p->mountPoint() == root;};
const bool separate_boot_partition = std::find_if(partList.constBegin(), partList.constEnd(), is_boot) != partList.constEnd();
for( Partition* part : partList )
{ {
if ( part->mountPoint() == "/" ) if ( ( separate_boot_partition && is_boot(part)) || (!separate_boot_partition && is_root(part)))
{ {
createPartition( createPartition(
dev, part, part->activeFlags() | ( isEfi ? KPM_PARTITION_FLAG( None ) : KPM_PARTITION_FLAG( Boot ) ) ); dev, part, part->activeFlags() | ( isEfi ? KPM_PARTITION_FLAG( None ) : KPM_PARTITION_FLAG( Boot ) ) );

View file

@ -22,8 +22,8 @@
#include "core/PartitionInfo.h" #include "core/PartitionInfo.h"
#include "partition/Sync.h"
#include "partition/PartitionIterator.h" #include "partition/PartitionIterator.h"
#include "partition/Sync.h"
#include "utils/Logger.h" #include "utils/Logger.h"
// KPMcore // KPMcore
@ -47,16 +47,14 @@ ClearMountsJob::ClearMountsJob( Device* device )
QString QString
ClearMountsJob::prettyName() const ClearMountsJob::prettyName() const
{ {
return tr( "Clear mounts for partitioning operations on %1" ) return tr( "Clear mounts for partitioning operations on %1" ).arg( m_device->deviceNode() );
.arg( m_device->deviceNode() );
} }
QString QString
ClearMountsJob::prettyStatusMessage() const ClearMountsJob::prettyStatusMessage() const
{ {
return tr( "Clearing mounts for partitioning operations on %1." ) return tr( "Clearing mounts for partitioning operations on %1." ).arg( m_device->deviceNode() );
.arg( m_device->deviceNode() );
} }
@ -70,15 +68,16 @@ getPartitionsForDevice( const QString& deviceName )
{ {
cDebug() << "Reading from" << dev_partitions.fileName(); cDebug() << "Reading from" << dev_partitions.fileName();
QTextStream in( &dev_partitions ); QTextStream in( &dev_partitions );
(void) in.readLine(); // That's the header line, skip it (void)in.readLine(); // That's the header line, skip it
while ( !in.atEnd() ) while ( !in.atEnd() )
{ {
// The fourth column (index from 0, so index 3) is the name of the device; // The fourth column (index from 0, so index 3) is the name of the device;
// keep it if it is followed by something. // keep it if it is followed by something.
QStringList columns = in.readLine().split( ' ', QString::SkipEmptyParts ); QStringList columns = in.readLine().split( ' ', QString::SkipEmptyParts );
if ( ( columns.count() >= 4 ) && ( columns[3].startsWith( deviceName ) ) && ( columns[3] != deviceName ) ) if ( ( columns.count() >= 4 ) && ( columns[ 3 ].startsWith( deviceName ) )
&& ( columns[ 3 ] != deviceName ) )
{ {
partitions.append( columns[3] ); partitions.append( columns[ 3 ] );
} }
} }
} }
@ -118,50 +117,54 @@ ClearMountsJob::exec()
// /dev/sda1 : start= 63, size= 29329345, type=83, bootable // /dev/sda1 : start= 63, size= 29329345, type=83, bootable
// /dev/sda2 : start= 29331456, size= 2125824, type=82 // /dev/sda2 : start= 29331456, size= 2125824, type=82
swapPartitions = QString::fromLocal8Bit( process.readAllStandardOutput() ) swapPartitions = QString::fromLocal8Bit( process.readAllStandardOutput() ).split( '\n' );
.split( '\n' );
swapPartitions = swapPartitions.filter( "type=82" ); swapPartitions = swapPartitions.filter( "type=82" );
for ( QStringList::iterator it = swapPartitions.begin(); for ( QStringList::iterator it = swapPartitions.begin(); it != swapPartitions.end(); ++it )
it != swapPartitions.end(); ++it )
{ {
*it = (*it).simplified().split( ' ' ).first(); *it = ( *it ).simplified().split( ' ' ).first();
} }
const QStringList cryptoDevices = getCryptoDevices(); const QStringList cryptoDevices = getCryptoDevices();
for ( const QString &mapperPath : cryptoDevices ) for ( const QString& mapperPath : cryptoDevices )
{ {
tryUmount( mapperPath ); tryUmount( mapperPath );
QString news = tryCryptoClose( mapperPath ); QString news = tryCryptoClose( mapperPath );
if ( !news.isEmpty() ) if ( !news.isEmpty() )
{
goodNews.append( news ); goodNews.append( news );
}
} }
// First we umount all LVM logical volumes we can find // First we umount all LVM logical volumes we can find
process.start( "lvscan", { "-a" } ); process.start( "lvscan", { "-a" } );
process.waitForFinished(); process.waitForFinished();
if ( process.exitCode() == 0 ) //means LVM2 tools are installed if ( process.exitCode() == 0 ) //means LVM2 tools are installed
{ {
const QStringList lvscanLines = QString::fromLocal8Bit( process.readAllStandardOutput() ).split( '\n' ); const QStringList lvscanLines = QString::fromLocal8Bit( process.readAllStandardOutput() ).split( '\n' );
for ( const QString& lvscanLine : lvscanLines ) for ( const QString& lvscanLine : lvscanLines )
{ {
QString lvPath = lvscanLine.simplified().split( ' ' ).value( 1 ); //second column QString lvPath = lvscanLine.simplified().split( ' ' ).value( 1 ); //second column
lvPath = lvPath.replace( '\'', "" ); lvPath = lvPath.replace( '\'', "" );
QString news = tryUmount( lvPath ); QString news = tryUmount( lvPath );
if ( !news.isEmpty() ) if ( !news.isEmpty() )
{
goodNews.append( news ); goodNews.append( news );
}
} }
} }
else else
{
cWarning() << "this system does not seem to have LVM2 tools."; cWarning() << "this system does not seem to have LVM2 tools.";
}
// Then we go looking for volume groups that use this device for physical volumes // Then we go looking for volume groups that use this device for physical volumes
process.start( "pvdisplay", { "-C", "--noheadings" } ); process.start( "pvdisplay", { "-C", "--noheadings" } );
process.waitForFinished(); process.waitForFinished();
if ( process.exitCode() == 0 ) //means LVM2 tools are installed if ( process.exitCode() == 0 ) //means LVM2 tools are installed
{ {
QString pvdisplayOutput = process.readAllStandardOutput(); QString pvdisplayOutput = process.readAllStandardOutput();
if ( !pvdisplayOutput.simplified().isEmpty() ) //means there is at least one LVM PV if ( !pvdisplayOutput.simplified().isEmpty() ) //means there is at least one LVM PV
{ {
QSet< QString > vgSet; QSet< QString > vgSet;
@ -171,7 +174,9 @@ ClearMountsJob::exec()
QString pvPath = pvdisplayLine.simplified().split( ' ' ).value( 0 ); QString pvPath = pvdisplayLine.simplified().split( ' ' ).value( 0 );
QString vgName = pvdisplayLine.simplified().split( ' ' ).value( 1 ); QString vgName = pvdisplayLine.simplified().split( ' ' ).value( 1 );
if ( !pvPath.contains( deviceName ) ) if ( !pvPath.contains( deviceName ) )
{
continue; continue;
}
vgSet.insert( vgName ); vgSet.insert( vgName );
} }
@ -181,41 +186,50 @@ ClearMountsJob::exec()
process.start( "vgchange", { "-an", vgName } ); process.start( "vgchange", { "-an", vgName } );
process.waitForFinished(); process.waitForFinished();
if ( process.exitCode() == 0 ) if ( process.exitCode() == 0 )
{
goodNews.append( QString( "Successfully disabled volume group %1." ).arg( vgName ) ); goodNews.append( QString( "Successfully disabled volume group %1." ).arg( vgName ) );
}
} }
} }
} }
else else
{
cWarning() << "this system does not seem to have LVM2 tools."; cWarning() << "this system does not seem to have LVM2 tools.";
}
const QStringList cryptoDevices2 = getCryptoDevices(); const QStringList cryptoDevices2 = getCryptoDevices();
for ( const QString &mapperPath : cryptoDevices2 ) for ( const QString& mapperPath : cryptoDevices2 )
{ {
tryUmount( mapperPath ); tryUmount( mapperPath );
QString news = tryCryptoClose( mapperPath ); QString news = tryCryptoClose( mapperPath );
if ( !news.isEmpty() ) if ( !news.isEmpty() )
{
goodNews.append( news ); goodNews.append( news );
}
} }
for ( const QString &p : partitionsList ) for ( const QString& p : partitionsList )
{ {
QString partPath = QString( "/dev/%1" ).arg( p ); QString partPath = QString( "/dev/%1" ).arg( p );
QString news = tryUmount( partPath ); QString news = tryUmount( partPath );
if ( !news.isEmpty() ) if ( !news.isEmpty() )
{
goodNews.append( news ); goodNews.append( news );
}
} }
foreach ( QString p, swapPartitions ) foreach ( QString p, swapPartitions )
{ {
QString news = tryClearSwap( p ); QString news = tryClearSwap( p );
if ( !news.isEmpty() ) if ( !news.isEmpty() )
{
goodNews.append( news ); goodNews.append( news );
}
} }
Calamares::JobResult ok = Calamares::JobResult::ok(); Calamares::JobResult ok = Calamares::JobResult::ok();
ok.setMessage( tr( "Cleared all mounts for %1" ) ok.setMessage( tr( "Cleared all mounts for %1" ).arg( m_device->deviceNode() ) );
.arg( m_device->deviceNode() ) );
ok.setDetails( goodNews.join( "\n" ) ); ok.setDetails( goodNews.join( "\n" ) );
cDebug() << "ClearMountsJob finished. Here's what was done:\n" << goodNews.join( "\n" ); cDebug() << "ClearMountsJob finished. Here's what was done:\n" << goodNews.join( "\n" );
@ -231,12 +245,16 @@ ClearMountsJob::tryUmount( const QString& partPath )
process.start( "umount", { partPath } ); process.start( "umount", { partPath } );
process.waitForFinished(); process.waitForFinished();
if ( process.exitCode() == 0 ) if ( process.exitCode() == 0 )
{
return QString( "Successfully unmounted %1." ).arg( partPath ); return QString( "Successfully unmounted %1." ).arg( partPath );
}
process.start( "swapoff", { partPath } ); process.start( "swapoff", { partPath } );
process.waitForFinished(); process.waitForFinished();
if ( process.exitCode() == 0 ) if ( process.exitCode() == 0 )
{
return QString( "Successfully disabled swap %1." ).arg( partPath ); return QString( "Successfully disabled swap %1." ).arg( partPath );
}
return QString(); return QString();
} }
@ -249,14 +267,17 @@ ClearMountsJob::tryClearSwap( const QString& partPath )
process.start( "blkid", { "-s", "UUID", "-o", "value", partPath } ); process.start( "blkid", { "-s", "UUID", "-o", "value", partPath } );
process.waitForFinished(); process.waitForFinished();
QString swapPartUuid = QString::fromLocal8Bit( process.readAllStandardOutput() ).simplified(); QString swapPartUuid = QString::fromLocal8Bit( process.readAllStandardOutput() ).simplified();
if ( process.exitCode() != 0 || if ( process.exitCode() != 0 || swapPartUuid.isEmpty() )
swapPartUuid.isEmpty() ) {
return QString(); return QString();
}
process.start( "mkswap", { "-U", swapPartUuid, partPath } ); process.start( "mkswap", { "-U", swapPartUuid, partPath } );
process.waitForFinished(); process.waitForFinished();
if ( process.exitCode() != 0 ) if ( process.exitCode() != 0 )
{
return QString(); return QString();
}
return QString( "Successfully cleared swap %1." ).arg( partPath ); return QString( "Successfully cleared swap %1." ).arg( partPath );
} }
@ -269,7 +290,9 @@ ClearMountsJob::tryCryptoClose( const QString& mapperPath )
process.start( "cryptsetup", { "close", mapperPath } ); process.start( "cryptsetup", { "close", mapperPath } );
process.waitForFinished(); process.waitForFinished();
if ( process.exitCode() == 0 ) if ( process.exitCode() == 0 )
{
return QString( "Successfully closed mapper device %1." ).arg( mapperPath ); return QString( "Successfully closed mapper device %1." ).arg( mapperPath );
}
return QString(); return QString();
} }
@ -282,14 +305,16 @@ ClearMountsJob::getCryptoDevices() const
const QFileInfoList fiList = mapperDir.entryInfoList( QDir::Files ); const QFileInfoList fiList = mapperDir.entryInfoList( QDir::Files );
QStringList list; QStringList list;
QProcess process; QProcess process;
for ( const QFileInfo &fi : fiList ) for ( const QFileInfo& fi : fiList )
{ {
QString baseName = fi.baseName(); QString baseName = fi.baseName();
// Fedora live images use /dev/mapper/live-* internally. We must not // Fedora live images use /dev/mapper/live-* internally. We must not
// unmount those devices, because they are used by the live image and // unmount those devices, because they are used by the live image and
// because we need /dev/mapper/live-base in the unpackfs module. // because we need /dev/mapper/live-base in the unpackfs module.
if ( baseName == "control" || baseName.startsWith( "live-" ) ) if ( baseName == "control" || baseName.startsWith( "live-" ) )
{
continue; continue;
}
list.append( fi.absoluteFilePath() ); list.append( fi.absoluteFilePath() );
} }
return list; return list;

View file

@ -35,6 +35,7 @@ public:
QString prettyName() const override; QString prettyName() const override;
QString prettyStatusMessage() const override; QString prettyStatusMessage() const override;
Calamares::JobResult exec() override; Calamares::JobResult exec() override;
private: private:
QString tryUmount( const QString& partPath ); QString tryUmount( const QString& partPath );
QString tryClearSwap( const QString& partPath ); QString tryClearSwap( const QString& partPath );
@ -43,4 +44,4 @@ private:
Device* m_device; Device* m_device;
}; };
#endif // CLEARMOUNTSJOB_H #endif // CLEARMOUNTSJOB_H

View file

@ -54,13 +54,15 @@ Calamares::JobResult
ClearTempMountsJob::exec() ClearTempMountsJob::exec()
{ {
// Fetch a list of current mounts to Calamares temporary directories. // Fetch a list of current mounts to Calamares temporary directories.
QList< QPair < QString, QString > > lst; QList< QPair< QString, QString > > lst;
QFile mtab( "/etc/mtab" ); QFile mtab( "/etc/mtab" );
if ( !mtab.open( QFile::ReadOnly | QFile::Text ) ) if ( !mtab.open( QFile::ReadOnly | QFile::Text ) )
{
return Calamares::JobResult::error( tr( "Cannot get list of temporary mounts." ) ); return Calamares::JobResult::error( tr( "Cannot get list of temporary mounts." ) );
}
cDebug() << "Opened mtab. Lines:"; cDebug() << "Opened mtab. Lines:";
QTextStream in(&mtab); QTextStream in( &mtab );
QString lineIn = in.readLine(); QString lineIn = in.readLine();
while ( !lineIn.isNull() ) while ( !lineIn.isNull() )
{ {
@ -76,11 +78,10 @@ ClearTempMountsJob::exec()
lineIn = in.readLine(); lineIn = in.readLine();
} }
std::sort ( lst.begin(), lst.end(), []( const QPair< QString, QString >& a, std::sort(
const QPair< QString, QString >& b ) -> bool lst.begin(), lst.end(), []( const QPair< QString, QString >& a, const QPair< QString, QString >& b ) -> bool {
{ return a.first > b.first;
return a.first > b.first; } );
} );
QStringList goodNews; QStringList goodNews;
QProcess process; QProcess process;
@ -92,7 +93,9 @@ ClearTempMountsJob::exec()
process.start( "umount", { "-lv", partPath } ); process.start( "umount", { "-lv", partPath } );
process.waitForFinished(); process.waitForFinished();
if ( process.exitCode() == 0 ) if ( process.exitCode() == 0 )
{
goodNews.append( QString( "Successfully unmounted %1." ).arg( partPath ) ); goodNews.append( QString( "Successfully unmounted %1." ).arg( partPath ) );
}
} }
Calamares::JobResult ok = Calamares::JobResult::ok(); Calamares::JobResult ok = Calamares::JobResult::ok();

View file

@ -37,4 +37,4 @@ public:
Calamares::JobResult exec() override; Calamares::JobResult exec() override;
}; };
#endif // CLEARTEMPMOUNTSJOB_H #endif // CLEARTEMPMOUNTSJOB_H

View file

@ -45,10 +45,10 @@ QString
CreatePartitionJob::prettyName() const CreatePartitionJob::prettyName() const
{ {
return tr( "Create new %2MiB partition on %4 (%3) with file system %1." ) return tr( "Create new %2MiB partition on %4 (%3) with file system %1." )
.arg( userVisibleFS( m_partition->fileSystem() ) ) .arg( userVisibleFS( m_partition->fileSystem() ) )
.arg( CalamaresUtils::BytesToMiB( m_partition->capacity() ) ) .arg( CalamaresUtils::BytesToMiB( m_partition->capacity() ) )
.arg( m_device->name() ) .arg( m_device->name() )
.arg( m_device->deviceNode() ); .arg( m_device->deviceNode() );
} }
@ -57,10 +57,10 @@ CreatePartitionJob::prettyDescription() const
{ {
return tr( "Create new <strong>%2MiB</strong> partition on <strong>%4</strong> " return tr( "Create new <strong>%2MiB</strong> partition on <strong>%4</strong> "
"(%3) with file system <strong>%1</strong>." ) "(%3) with file system <strong>%1</strong>." )
.arg( userVisibleFS( m_partition->fileSystem() ) ) .arg( userVisibleFS( m_partition->fileSystem() ) )
.arg( CalamaresUtils::BytesToMiB( m_partition->capacity() ) ) .arg( CalamaresUtils::BytesToMiB( m_partition->capacity() ) )
.arg( m_device->name() ) .arg( m_device->name() )
.arg( m_device->deviceNode() ); .arg( m_device->deviceNode() );
} }
@ -68,22 +68,24 @@ QString
CreatePartitionJob::prettyStatusMessage() const CreatePartitionJob::prettyStatusMessage() const
{ {
return tr( "Creating new %1 partition on %2." ) return tr( "Creating new %1 partition on %2." )
.arg( userVisibleFS( m_partition->fileSystem() ) ) .arg( userVisibleFS( m_partition->fileSystem() ) )
.arg( m_device->deviceNode() ); .arg( m_device->deviceNode() );
} }
Calamares::JobResult Calamares::JobResult
CreatePartitionJob::exec() CreatePartitionJob::exec()
{ {
Report report( nullptr ); Report report( nullptr );
NewOperation op(*m_device, m_partition); NewOperation op( *m_device, m_partition );
op.setStatus(Operation::StatusRunning); op.setStatus( Operation::StatusRunning );
QString message = tr( "The installer failed to create partition on disk '%1'." ).arg( m_device->name() ); QString message = tr( "The installer failed to create partition on disk '%1'." ).arg( m_device->name() );
if (op.execute(report)) if ( op.execute( report ) )
{
return Calamares::JobResult::ok(); return Calamares::JobResult::ok();
}
return Calamares::JobResult::error(message, report.toText()); return Calamares::JobResult::error( message, report.toText() );
} }
void void

View file

@ -44,10 +44,7 @@ public:
Calamares::JobResult exec() override; Calamares::JobResult exec() override;
void updatePreview(); void updatePreview();
Device* device() const Device* device() const { return m_device; }
{
return m_device;
}
private: private:
Device* m_device; Device* m_device;

View file

@ -18,7 +18,7 @@
* along with Calamares. If not, see <http://www.gnu.org/licenses/>. * along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "jobs/CreatePartitionTableJob.h" #include "CreatePartitionTableJob.h"
#include "partition/PartitionIterator.h" #include "partition/PartitionIterator.h"
#include "utils/Logger.h" #include "utils/Logger.h"
@ -46,16 +46,17 @@ QString
CreatePartitionTableJob::prettyName() const CreatePartitionTableJob::prettyName() const
{ {
return tr( "Create new %1 partition table on %2." ) return tr( "Create new %1 partition table on %2." )
.arg( PartitionTable::tableTypeToName( m_type ) ) .arg( PartitionTable::tableTypeToName( m_type ) )
.arg( m_device->deviceNode() ); .arg( m_device->deviceNode() );
} }
QString CreatePartitionTableJob::prettyDescription() const QString
CreatePartitionTableJob::prettyDescription() const
{ {
return tr( "Create new <strong>%1</strong> partition table on <strong>%2</strong> (%3)." ) return tr( "Create new <strong>%1</strong> partition table on <strong>%2</strong> (%3)." )
.arg( PartitionTable::tableTypeToName( m_type ).toUpper() ) .arg( PartitionTable::tableTypeToName( m_type ).toUpper() )
.arg( m_device->deviceNode() ) .arg( m_device->deviceNode() )
.arg( m_device->name() ); .arg( m_device->name() );
} }
@ -63,13 +64,13 @@ QString
CreatePartitionTableJob::prettyStatusMessage() const CreatePartitionTableJob::prettyStatusMessage() const
{ {
return tr( "Creating new %1 partition table on %2." ) return tr( "Creating new %1 partition table on %2." )
.arg( PartitionTable::tableTypeToName( m_type ).toUpper() ) .arg( PartitionTable::tableTypeToName( m_type ).toUpper() )
.arg( m_device->deviceNode() ); .arg( m_device->deviceNode() );
} }
static inline QDebug& static inline QDebug&
operator <<( QDebug&& s, PartitionIterator& it ) operator<<( QDebug&& s, PartitionIterator& it )
{ {
s << ( ( *it ) ? ( *it )->deviceNode() : QString( "<null device>" ) ); s << ( ( *it ) ? ( *it )->deviceNode() : QString( "<null device>" ) );
return s; return s;
@ -83,14 +84,14 @@ CreatePartitionTableJob::exec()
QString message = tr( "The installer failed to create a partition table on %1." ).arg( m_device->name() ); QString message = tr( "The installer failed to create a partition table on %1." ).arg( m_device->name() );
PartitionTable* table = m_device->partitionTable(); PartitionTable* table = m_device->partitionTable();
cDebug() << "Creating new partition table of type" << table->typeName() cDebug() << "Creating new partition table of type" << table->typeName() << ", uncommitted yet:";
<< ", uncommitted yet:";
if ( Logger::logLevelEnabled( Logger::LOGDEBUG ) ) if ( Logger::logLevelEnabled( Logger::LOGDEBUG ) )
{ {
for ( auto it = PartitionIterator::begin( table ); for ( auto it = PartitionIterator::begin( table ); it != PartitionIterator::end( table ); ++it )
it != PartitionIterator::end( table ); ++it ) {
cDebug() << it; cDebug() << it;
}
QProcess lsblk; QProcess lsblk;
lsblk.setProgram( "lsblk" ); lsblk.setProgram( "lsblk" );
@ -107,13 +108,15 @@ CreatePartitionTableJob::exec()
cDebug() << "mount:\n" << mount.readAllStandardOutput(); cDebug() << "mount:\n" << mount.readAllStandardOutput();
} }
CreatePartitionTableOperation op(*m_device, table); CreatePartitionTableOperation op( *m_device, table );
op.setStatus(Operation::StatusRunning); op.setStatus( Operation::StatusRunning );
if (op.execute(report)) if ( op.execute( report ) )
{
return Calamares::JobResult::ok(); return Calamares::JobResult::ok();
}
return Calamares::JobResult::error(message, report.toText()); return Calamares::JobResult::error( message, report.toText() );
} }
void void
@ -129,10 +132,8 @@ CreatePartitionTableJob::updatePreview()
PartitionTable* PartitionTable*
CreatePartitionTableJob::createTable() CreatePartitionTableJob::createTable()
{ {
cDebug() << "CreatePartitionTableJob::createTable trying to make table for device" cDebug() << "CreatePartitionTableJob::createTable trying to make table for device" << m_device->deviceNode();
<< m_device->deviceNode();
return new PartitionTable( m_type, return new PartitionTable( m_type,
PartitionTable::defaultFirstUsable( *m_device, m_type ), PartitionTable::defaultFirstUsable( *m_device, m_type ),
PartitionTable::defaultLastUsable( *m_device, m_type ) PartitionTable::defaultLastUsable( *m_device, m_type ) );
);
} }

View file

@ -45,10 +45,7 @@ public:
Calamares::JobResult exec() override; Calamares::JobResult exec() override;
void updatePreview(); void updatePreview();
Device* device() const Device* device() const { return m_device; }
{
return m_device;
}
private: private:
CalamaresUtils::Partition::KPMManager m_kpmcore; CalamaresUtils::Partition::KPMManager m_kpmcore;

View file

@ -25,32 +25,28 @@
#include <kpmcore/util/report.h> #include <kpmcore/util/report.h>
CreateVolumeGroupJob::CreateVolumeGroupJob( QString& vgName, QVector< const Partition* > pvList, const qint32 peSize ) CreateVolumeGroupJob::CreateVolumeGroupJob( QString& vgName, QVector< const Partition* > pvList, const qint32 peSize )
: m_vgName(vgName) : m_vgName( vgName )
, m_pvList(pvList) , m_pvList( pvList )
, m_peSize(peSize) , m_peSize( peSize )
{ {
} }
QString QString
CreateVolumeGroupJob::prettyName() const CreateVolumeGroupJob::prettyName() const
{ {
return tr( "Create new volume group named %1." ) return tr( "Create new volume group named %1." ).arg( m_vgName );
.arg( m_vgName );
} }
QString QString
CreateVolumeGroupJob::prettyDescription() const CreateVolumeGroupJob::prettyDescription() const
{ {
return tr( "Create new volume group named <strong>%1</strong>." ) return tr( "Create new volume group named <strong>%1</strong>." ).arg( m_vgName );
.arg( m_vgName );
} }
QString QString
CreateVolumeGroupJob::prettyStatusMessage() const CreateVolumeGroupJob::prettyStatusMessage() const
{ {
return tr( "Creating new volume group named %1." ) return tr( "Creating new volume group named %1." ).arg( m_vgName );
.arg( m_vgName );
} }
Calamares::JobResult Calamares::JobResult
@ -62,11 +58,13 @@ CreateVolumeGroupJob::exec()
op.setStatus( Operation::StatusRunning ); op.setStatus( Operation::StatusRunning );
QString message = tr( "The installer failed to create a volume group named '%1'.").arg( m_vgName ); QString message = tr( "The installer failed to create a volume group named '%1'." ).arg( m_vgName );
if (op.execute(report)) if ( op.execute( report ) )
{
return Calamares::JobResult::ok(); return Calamares::JobResult::ok();
}
return Calamares::JobResult::error(message, report.toText()); return Calamares::JobResult::error( message, report.toText() );
} }
void void
@ -79,6 +77,10 @@ void
CreateVolumeGroupJob::undoPreview() CreateVolumeGroupJob::undoPreview()
{ {
for ( const auto& pv : m_pvList ) for ( const auto& pv : m_pvList )
if ( LvmDevice::s_DirtyPVs.contains( pv )) {
if ( LvmDevice::s_DirtyPVs.contains( pv ) )
{
LvmDevice::s_DirtyPVs.removeAll( pv ); LvmDevice::s_DirtyPVs.removeAll( pv );
}
}
} }

View file

@ -47,4 +47,4 @@ private:
qint32 m_peSize; qint32 m_peSize;
}; };
#endif // CREATEVOLUMEGROUPJOB_H #endif // CREATEVOLUMEGROUPJOB_H

View file

@ -25,28 +25,24 @@
DeactivateVolumeGroupJob::DeactivateVolumeGroupJob( LvmDevice* device ) DeactivateVolumeGroupJob::DeactivateVolumeGroupJob( LvmDevice* device )
: m_device( device ) : m_device( device )
{ {
} }
QString QString
DeactivateVolumeGroupJob::prettyName() const DeactivateVolumeGroupJob::prettyName() const
{ {
return tr( "Deactivate volume group named %1." ) return tr( "Deactivate volume group named %1." ).arg( m_device->name() );
.arg( m_device->name() );
} }
QString QString
DeactivateVolumeGroupJob::prettyDescription() const DeactivateVolumeGroupJob::prettyDescription() const
{ {
return tr( "Deactivate volume group named <strong>%1</strong>." ) return tr( "Deactivate volume group named <strong>%1</strong>." ).arg( m_device->name() );
.arg( m_device->name() );
} }
QString QString
DeactivateVolumeGroupJob::prettyStatusMessage() const DeactivateVolumeGroupJob::prettyStatusMessage() const
{ {
return tr( "Deactivate volume group named %1." ) return tr( "Deactivate volume group named %1." ).arg( m_device->name() );
.arg( m_device->name() );
} }
Calamares::JobResult Calamares::JobResult
@ -65,5 +61,5 @@ DeactivateVolumeGroupJob::exec()
return Calamares::JobResult::ok(); return Calamares::JobResult::ok();
} }
return Calamares::JobResult::error(message, report.toText()); return Calamares::JobResult::error( message, report.toText() );
} }

View file

@ -40,4 +40,4 @@ private:
LvmDevice* m_device; LvmDevice* m_device;
}; };
#endif // DEACTIVATEVOLUMEGROUPJOB_H #endif // DEACTIVATEVOLUMEGROUPJOB_H

View file

@ -18,7 +18,7 @@
* along with Calamares. If not, see <http://www.gnu.org/licenses/>. * along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "jobs/DeletePartitionJob.h" #include "DeletePartitionJob.h"
// KPMcore // KPMcore
#include <kpmcore/core/device.h> #include <kpmcore/core/device.h>
@ -37,24 +37,21 @@ DeletePartitionJob::DeletePartitionJob( Device* device, Partition* partition )
QString QString
DeletePartitionJob::prettyName() const DeletePartitionJob::prettyName() const
{ {
return tr( "Delete partition %1." ) return tr( "Delete partition %1." ).arg( m_partition->partitionPath() );
.arg( m_partition->partitionPath() );
} }
QString QString
DeletePartitionJob::prettyDescription() const DeletePartitionJob::prettyDescription() const
{ {
return tr( "Delete partition <strong>%1</strong>." ) return tr( "Delete partition <strong>%1</strong>." ).arg( m_partition->partitionPath() );
.arg( m_partition->partitionPath() );
} }
QString QString
DeletePartitionJob::prettyStatusMessage() const DeletePartitionJob::prettyStatusMessage() const
{ {
return tr( "Deleting partition %1." ) return tr( "Deleting partition %1." ).arg( m_partition->partitionPath() );
.arg( m_partition->partitionPath() );
} }
@ -62,14 +59,16 @@ Calamares::JobResult
DeletePartitionJob::exec() DeletePartitionJob::exec()
{ {
Report report( nullptr ); Report report( nullptr );
DeleteOperation op(*m_device, m_partition); DeleteOperation op( *m_device, m_partition );
op.setStatus(Operation::StatusRunning); op.setStatus( Operation::StatusRunning );
QString message = tr( "The installer failed to delete partition %1." ).arg( m_partition->devicePath() ); QString message = tr( "The installer failed to delete partition %1." ).arg( m_partition->devicePath() );
if (op.execute(report)) if ( op.execute( report ) )
{
return Calamares::JobResult::ok(); return Calamares::JobResult::ok();
}
return Calamares::JobResult::error(message, report.toText()); return Calamares::JobResult::error( message, report.toText() );
} }
void void
@ -87,5 +86,7 @@ DeletePartitionJob::updatePreview()
// become sda5, sda6, sda7 // become sda5, sda6, sda7
Partition* parentPartition = dynamic_cast< Partition* >( m_partition->parent() ); Partition* parentPartition = dynamic_cast< Partition* >( m_partition->parent() );
if ( parentPartition && parentPartition->roles().has( PartitionRole::Extended ) ) if ( parentPartition && parentPartition->roles().has( PartitionRole::Extended ) )
{
parentPartition->adjustLogicalNumbers( m_partition->number(), -1 ); parentPartition->adjustLogicalNumbers( m_partition->number(), -1 );
}
} }

View file

@ -44,10 +44,7 @@ public:
Calamares::JobResult exec() override; Calamares::JobResult exec() override;
void updatePreview(); void updatePreview();
Device* device() const Device* device() const { return m_device; }
{
return m_device;
}
private: private:
Device* m_device; Device* m_device;

View file

@ -44,6 +44,7 @@ public:
QString prettyDescription() const override; QString prettyDescription() const override;
QString prettyStatusMessage() const override; QString prettyStatusMessage() const override;
Calamares::JobResult exec() override; Calamares::JobResult exec() override;
private: private:
QList< Device* > m_devices; QList< Device* > m_devices;
QString m_bootLoaderPath; QString m_bootLoaderPath;

View file

@ -43,10 +43,10 @@ QString
FormatPartitionJob::prettyName() const FormatPartitionJob::prettyName() const
{ {
return tr( "Format partition %1 (file system: %2, size: %3 MiB) on %4." ) return tr( "Format partition %1 (file system: %2, size: %3 MiB) on %4." )
.arg( m_partition->partitionPath() ) .arg( m_partition->partitionPath() )
.arg( userVisibleFS( m_partition->fileSystem() ) ) .arg( userVisibleFS( m_partition->fileSystem() ) )
.arg( m_partition->capacity() / 1024 / 1024 ) .arg( m_partition->capacity() / 1024 / 1024 )
.arg( m_device->name() ); .arg( m_device->name() );
} }
@ -55,9 +55,9 @@ FormatPartitionJob::prettyDescription() const
{ {
return tr( "Format <strong>%3MiB</strong> partition <strong>%1</strong> with " return tr( "Format <strong>%3MiB</strong> partition <strong>%1</strong> with "
"file system <strong>%2</strong>." ) "file system <strong>%2</strong>." )
.arg( m_partition->partitionPath() ) .arg( m_partition->partitionPath() )
.arg( userVisibleFS( m_partition->fileSystem() ) ) .arg( userVisibleFS( m_partition->fileSystem() ) )
.arg( m_partition->capacity() / 1024 / 1024 ); .arg( m_partition->capacity() / 1024 / 1024 );
} }
@ -66,8 +66,8 @@ FormatPartitionJob::prettyStatusMessage() const
{ {
return tr( "Formatting partition %1 with " return tr( "Formatting partition %1 with "
"file system %2." ) "file system %2." )
.arg( m_partition->partitionPath() ) .arg( m_partition->partitionPath() )
.arg( userVisibleFS( m_partition->fileSystem() ) ); .arg( userVisibleFS( m_partition->fileSystem() ) );
} }
@ -75,13 +75,16 @@ Calamares::JobResult
FormatPartitionJob::exec() FormatPartitionJob::exec()
{ {
Report report( nullptr ); // Root of the report tree, no parent Report report( nullptr ); // Root of the report tree, no parent
CreateFileSystemOperation op(*m_device, *m_partition, m_partition->fileSystem().type()); CreateFileSystemOperation op( *m_device, *m_partition, m_partition->fileSystem().type() );
op.setStatus(Operation::StatusRunning); op.setStatus( Operation::StatusRunning );
QString message = tr( "The installer failed to format partition %1 on disk '%2'." ).arg( m_partition->partitionPath(), m_device->name() ); QString message = tr( "The installer failed to format partition %1 on disk '%2'." )
.arg( m_partition->partitionPath(), m_device->name() );
if (op.execute(report)) if ( op.execute( report ) )
{
return Calamares::JobResult::ok(); return Calamares::JobResult::ok();
}
return Calamares::JobResult::error(message, report.toText()); return Calamares::JobResult::error( message, report.toText() );
} }

View file

@ -42,10 +42,7 @@ public:
QString prettyStatusMessage() const override; QString prettyStatusMessage() const override;
Calamares::JobResult exec() override; Calamares::JobResult exec() override;
Device* device() const Device* device() const { return m_device; }
{
return m_device;
}
private: private:
Device* m_device; Device* m_device;

View file

@ -20,13 +20,19 @@
PartitionJob::PartitionJob( Partition* partition ) PartitionJob::PartitionJob( Partition* partition )
: m_partition( partition ) : m_partition( partition )
{} {
}
void PartitionJob::iprogress(int percent) void
PartitionJob::iprogress( int percent )
{ {
if ( percent < 0 ) if ( percent < 0 )
{
percent = 0; percent = 0;
}
if ( percent > 100 ) if ( percent > 100 )
{
percent = 100; percent = 100;
}
emit progress( qreal( percent / 100.0 ) ); emit progress( qreal( percent / 100.0 ) );
} }

View file

@ -34,10 +34,7 @@ class PartitionJob : public Calamares::Job
public: public:
PartitionJob( Partition* partition ); PartitionJob( Partition* partition );
Partition* partition() const Partition* partition() const { return m_partition; }
{
return m_partition;
}
public slots: public slots:
/** @brief Translate from KPMCore to Calamares progress. /** @brief Translate from KPMCore to Calamares progress.

View file

@ -25,28 +25,24 @@
RemoveVolumeGroupJob::RemoveVolumeGroupJob( LvmDevice* device ) RemoveVolumeGroupJob::RemoveVolumeGroupJob( LvmDevice* device )
: m_device( device ) : m_device( device )
{ {
} }
QString QString
RemoveVolumeGroupJob::prettyName() const RemoveVolumeGroupJob::prettyName() const
{ {
return tr( "Remove Volume Group named %1." ) return tr( "Remove Volume Group named %1." ).arg( m_device->name() );
.arg( m_device->name() );
} }
QString QString
RemoveVolumeGroupJob::prettyDescription() const RemoveVolumeGroupJob::prettyDescription() const
{ {
return tr( "Remove Volume Group named <strong>%1</strong>.") return tr( "Remove Volume Group named <strong>%1</strong>." ).arg( m_device->name() );
.arg( m_device->name() );
} }
QString QString
RemoveVolumeGroupJob::prettyStatusMessage() const RemoveVolumeGroupJob::prettyStatusMessage() const
{ {
return tr( "Remove Volume Group named %1." ) return tr( "Remove Volume Group named %1." ).arg( m_device->name() );
.arg( m_device->name() );
} }
Calamares::JobResult Calamares::JobResult
@ -60,7 +56,9 @@ RemoveVolumeGroupJob::exec()
QString message = tr( "The installer failed to remove a volume group named '%1'." ).arg( m_device->name() ); QString message = tr( "The installer failed to remove a volume group named '%1'." ).arg( m_device->name() );
if ( op.execute( report ) ) if ( op.execute( report ) )
{
return Calamares::JobResult::ok(); return Calamares::JobResult::ok();
}
return Calamares::JobResult::error(message, report.toText()); return Calamares::JobResult::error( message, report.toText() );
} }

View file

@ -40,4 +40,4 @@ private:
LvmDevice* m_device; LvmDevice* m_device;
}; };
#endif // REMOVEVOLUMEGROUPJOB_H #endif // REMOVEVOLUMEGROUPJOB_H

View file

@ -18,7 +18,7 @@
* along with Calamares. If not, see <http://www.gnu.org/licenses/>. * along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "jobs/ResizePartitionJob.h" #include "ResizePartitionJob.h"
#include "utils/Units.h" #include "utils/Units.h"
@ -33,7 +33,8 @@ using CalamaresUtils::BytesToMiB;
ResizePartitionJob::ResizePartitionJob( Device* device, Partition* partition, qint64 firstSector, qint64 lastSector ) ResizePartitionJob::ResizePartitionJob( Device* device, Partition* partition, qint64 firstSector, qint64 lastSector )
: PartitionJob( partition ) : PartitionJob( partition )
, m_device( device ) , m_device( device )
, m_oldFirstSector( partition->firstSector() ) // Keep a copy of old sectors because they will be overwritten in updatePreview() , m_oldFirstSector(
partition->firstSector() ) // Keep a copy of old sectors because they will be overwritten in updatePreview()
, m_oldLastSector( partition->lastSector() ) , m_oldLastSector( partition->lastSector() )
, m_newFirstSector( firstSector ) , m_newFirstSector( firstSector )
, m_newLastSector( lastSector ) , m_newLastSector( lastSector )
@ -54,9 +55,9 @@ ResizePartitionJob::prettyDescription() const
{ {
return tr( "Resize <strong>%2MiB</strong> partition <strong>%1</strong> to " return tr( "Resize <strong>%2MiB</strong> partition <strong>%1</strong> to "
"<strong>%3MiB</strong>." ) "<strong>%3MiB</strong>." )
.arg( partition()->partitionPath() ) .arg( partition()->partitionPath() )
.arg( ( BytesToMiB( m_oldLastSector - m_oldFirstSector + 1 ) * partition()->sectorSize() ) ) .arg( ( BytesToMiB( m_oldLastSector - m_oldFirstSector + 1 ) * partition()->sectorSize() ) )
.arg( ( BytesToMiB( m_newLastSector - m_newFirstSector + 1 ) * partition()->sectorSize() ) ); .arg( ( BytesToMiB( m_newLastSector - m_newFirstSector + 1 ) * partition()->sectorSize() ) );
} }
@ -65,30 +66,32 @@ ResizePartitionJob::prettyStatusMessage() const
{ {
return tr( "Resizing %2MiB partition %1 to " return tr( "Resizing %2MiB partition %1 to "
"%3MiB." ) "%3MiB." )
.arg( partition()->partitionPath() ) .arg( partition()->partitionPath() )
.arg( ( BytesToMiB( m_oldLastSector - m_oldFirstSector + 1 ) * partition()->sectorSize() ) ) .arg( ( BytesToMiB( m_oldLastSector - m_oldFirstSector + 1 ) * partition()->sectorSize() ) )
.arg( ( BytesToMiB( m_newLastSector - m_newFirstSector + 1 ) * partition()->sectorSize() ) ); .arg( ( BytesToMiB( m_newLastSector - m_newFirstSector + 1 ) * partition()->sectorSize() ) );
} }
Calamares::JobResult Calamares::JobResult
ResizePartitionJob::exec() ResizePartitionJob::exec()
{ {
Report report (nullptr); Report report( nullptr );
// Restore partition sectors that were modified for preview // Restore partition sectors that were modified for preview
m_partition->setFirstSector( m_oldFirstSector ); m_partition->setFirstSector( m_oldFirstSector );
m_partition->setLastSector( m_oldLastSector ); m_partition->setLastSector( m_oldLastSector );
ResizeOperation op(*m_device, *m_partition, m_newFirstSector, m_newLastSector); ResizeOperation op( *m_device, *m_partition, m_newFirstSector, m_newLastSector );
op.setStatus(Operation::StatusRunning); op.setStatus( Operation::StatusRunning );
connect(&op, &Operation::progress, this, &ResizePartitionJob::iprogress ); connect( &op, &Operation::progress, this, &ResizePartitionJob::iprogress );
QString errorMessage = tr( "The installer failed to resize partition %1 on disk '%2'." ) QString errorMessage = tr( "The installer failed to resize partition %1 on disk '%2'." )
.arg( m_partition->partitionPath() ) .arg( m_partition->partitionPath() )
.arg( m_device->name() ); .arg( m_device->name() );
if (op.execute(report)) if ( op.execute( report ) )
{
return Calamares::JobResult::ok(); return Calamares::JobResult::ok();
}
return Calamares::JobResult::error(errorMessage, report.toText()); return Calamares::JobResult::error( errorMessage, report.toText() );
} }
void void

View file

@ -28,34 +28,33 @@ ResizeVolumeGroupJob::ResizeVolumeGroupJob( LvmDevice* device, QVector< const Pa
: m_device( device ) : m_device( device )
, m_partitionList( partitionList ) , m_partitionList( partitionList )
{ {
} }
QString QString
ResizeVolumeGroupJob::prettyName() const ResizeVolumeGroupJob::prettyName() const
{ {
return tr( "Resize volume group named %1 from %2 to %3." ) return tr( "Resize volume group named %1 from %2 to %3." )
.arg( m_device->name() ) .arg( m_device->name() )
.arg( currentPartitions() ) .arg( currentPartitions() )
.arg( targetPartitions() ); .arg( targetPartitions() );
} }
QString QString
ResizeVolumeGroupJob::prettyDescription() const ResizeVolumeGroupJob::prettyDescription() const
{ {
return tr( "Resize volume group named <strong>%1</strong> from <strong>%2</strong> to <strong>%3</strong>." ) return tr( "Resize volume group named <strong>%1</strong> from <strong>%2</strong> to <strong>%3</strong>." )
.arg( m_device->name() ) .arg( m_device->name() )
.arg( currentPartitions() ) .arg( currentPartitions() )
.arg( targetPartitions() ); .arg( targetPartitions() );
} }
QString QString
ResizeVolumeGroupJob::prettyStatusMessage() const ResizeVolumeGroupJob::prettyStatusMessage() const
{ {
return tr( "Resize volume group named %1 from %2 to %3." ) return tr( "Resize volume group named %1 from %2 to %3." )
.arg( m_device->name() ) .arg( m_device->name() )
.arg( currentPartitions() ) .arg( currentPartitions() )
.arg( targetPartitions() ); .arg( targetPartitions() );
} }
Calamares::JobResult Calamares::JobResult
@ -69,7 +68,9 @@ ResizeVolumeGroupJob::exec()
QString message = tr( "The installer failed to resize a volume group named '%1'." ).arg( m_device->name() ); QString message = tr( "The installer failed to resize a volume group named '%1'." ).arg( m_device->name() );
if ( op.execute( report ) ) if ( op.execute( report ) )
{
return Calamares::JobResult::ok(); return Calamares::JobResult::ok();
}
return Calamares::JobResult::error( message, report.toText() ); return Calamares::JobResult::error( message, report.toText() );
} }
@ -79,10 +80,12 @@ ResizeVolumeGroupJob::currentPartitions() const
{ {
QString result; QString result;
for ( const Partition *p : m_device->physicalVolumes() ) for ( const Partition* p : m_device->physicalVolumes() )
{
result += p->deviceNode() + ", "; result += p->deviceNode() + ", ";
}
result.chop(2); result.chop( 2 );
return result; return result;
} }
@ -92,10 +95,12 @@ ResizeVolumeGroupJob::targetPartitions() const
{ {
QString result; QString result;
for ( const Partition *p : m_partitionList ) for ( const Partition* p : m_partitionList )
{
result += p->deviceNode() + ", "; result += p->deviceNode() + ", ";
}
result.chop(2); result.chop( 2 );
return result; return result;
} }

View file

@ -48,4 +48,4 @@ private:
QVector< const Partition* > m_partitionList; QVector< const Partition* > m_partitionList;
}; };
#endif // RESIZEVOLUMEGROUPJOB_H #endif // RESIZEVOLUMEGROUPJOB_H

View file

@ -36,27 +36,29 @@ using CalamaresUtils::BytesToMiB;
using CalamaresUtils::Partition::untranslatedFS; using CalamaresUtils::Partition::untranslatedFS;
using CalamaresUtils::Partition::userVisibleFS; using CalamaresUtils::Partition::userVisibleFS;
SetPartFlagsJob::SetPartFlagsJob( Device* device, SetPartFlagsJob::SetPartFlagsJob( Device* device, Partition* partition, PartitionTable::Flags flags )
Partition* partition,
PartitionTable::Flags flags )
: PartitionJob( partition ) : PartitionJob( partition )
, m_device( device ) , m_device( device )
, m_flags( flags ) , m_flags( flags )
{} {
}
QString QString
SetPartFlagsJob::prettyName() const SetPartFlagsJob::prettyName() const
{ {
if ( !partition()->partitionPath().isEmpty() ) if ( !partition()->partitionPath().isEmpty() )
{
return tr( "Set flags on partition %1." ).arg( partition()->partitionPath() ); return tr( "Set flags on partition %1." ).arg( partition()->partitionPath() );
}
QString fsNameForUser = userVisibleFS( partition()->fileSystem() ); QString fsNameForUser = userVisibleFS( partition()->fileSystem() );
if ( !fsNameForUser.isEmpty() ) if ( !fsNameForUser.isEmpty() )
{
return tr( "Set flags on %1MiB %2 partition." ) return tr( "Set flags on %1MiB %2 partition." )
.arg( BytesToMiB( partition()->capacity() ) ) .arg( BytesToMiB( partition()->capacity() ) )
.arg( fsNameForUser ); .arg( fsNameForUser );
}
return tr( "Set flags on new partition." ); return tr( "Set flags on new partition." );
} }
@ -68,34 +70,39 @@ SetPartFlagsJob::prettyDescription() const
if ( flagsList.count() == 0 ) if ( flagsList.count() == 0 )
{ {
if ( !partition()->partitionPath().isEmpty() ) if ( !partition()->partitionPath().isEmpty() )
return tr( "Clear flags on partition <strong>%1</strong>." ) {
.arg( partition()->partitionPath() ); return tr( "Clear flags on partition <strong>%1</strong>." ).arg( partition()->partitionPath() );
}
QString fsNameForUser = userVisibleFS( partition()->fileSystem() ); QString fsNameForUser = userVisibleFS( partition()->fileSystem() );
if ( !fsNameForUser.isEmpty() ) if ( !fsNameForUser.isEmpty() )
{
return tr( "Clear flags on %1MiB <strong>%2</strong> partition." ) return tr( "Clear flags on %1MiB <strong>%2</strong> partition." )
.arg( BytesToMiB( partition()->capacity() ) ) .arg( BytesToMiB( partition()->capacity() ) )
.arg( fsNameForUser ); .arg( fsNameForUser );
}
return tr( "Clear flags on new partition." ); return tr( "Clear flags on new partition." );
} }
if ( !partition()->partitionPath().isEmpty() ) if ( !partition()->partitionPath().isEmpty() )
{
return tr( "Flag partition <strong>%1</strong> as " return tr( "Flag partition <strong>%1</strong> as "
"<strong>%2</strong>." ) "<strong>%2</strong>." )
.arg( partition()->partitionPath() ) .arg( partition()->partitionPath() )
.arg( flagsList.join( ", " ) ); .arg( flagsList.join( ", " ) );
}
QString fsNameForUser = userVisibleFS( partition()->fileSystem() ); QString fsNameForUser = userVisibleFS( partition()->fileSystem() );
if ( !fsNameForUser.isEmpty() ) if ( !fsNameForUser.isEmpty() )
{
return tr( "Flag %1MiB <strong>%2</strong> partition as " return tr( "Flag %1MiB <strong>%2</strong> partition as "
"<strong>%3</strong>." ) "<strong>%3</strong>." )
.arg( BytesToMiB( partition()->capacity() ) ) .arg( BytesToMiB( partition()->capacity() ) )
.arg( fsNameForUser ) .arg( fsNameForUser )
.arg( flagsList.join( ", " ) ); .arg( flagsList.join( ", " ) );
}
return tr( "Flag new partition as <strong>%1</strong>." ) return tr( "Flag new partition as <strong>%1</strong>." ).arg( flagsList.join( ", " ) );
.arg( flagsList.join( ", " ) );
} }
@ -106,53 +113,60 @@ SetPartFlagsJob::prettyStatusMessage() const
if ( flagsList.count() == 0 ) if ( flagsList.count() == 0 )
{ {
if ( !partition()->partitionPath().isEmpty() ) if ( !partition()->partitionPath().isEmpty() )
return tr( "Clearing flags on partition <strong>%1</strong>." ) {
.arg( partition()->partitionPath() ); return tr( "Clearing flags on partition <strong>%1</strong>." ).arg( partition()->partitionPath() );
}
QString fsNameForUser = userVisibleFS( partition()->fileSystem() ); QString fsNameForUser = userVisibleFS( partition()->fileSystem() );
if ( !fsNameForUser.isEmpty() ) if ( !fsNameForUser.isEmpty() )
{
return tr( "Clearing flags on %1MiB <strong>%2</strong> partition." ) return tr( "Clearing flags on %1MiB <strong>%2</strong> partition." )
.arg( BytesToMiB( partition()->capacity() ) ) .arg( BytesToMiB( partition()->capacity() ) )
.arg( fsNameForUser ); .arg( fsNameForUser );
}
return tr( "Clearing flags on new partition." ); return tr( "Clearing flags on new partition." );
} }
if ( !partition()->partitionPath().isEmpty() ) if ( !partition()->partitionPath().isEmpty() )
{
return tr( "Setting flags <strong>%2</strong> on partition " return tr( "Setting flags <strong>%2</strong> on partition "
"<strong>%1</strong>." ) "<strong>%1</strong>." )
.arg( partition()->partitionPath() ) .arg( partition()->partitionPath() )
.arg( flagsList.join( ", " ) ); .arg( flagsList.join( ", " ) );
}
QString fsNameForUser = userVisibleFS( partition()->fileSystem() ); QString fsNameForUser = userVisibleFS( partition()->fileSystem() );
if ( !fsNameForUser.isEmpty() ) if ( !fsNameForUser.isEmpty() )
{
return tr( "Setting flags <strong>%3</strong> on " return tr( "Setting flags <strong>%3</strong> on "
"%1MiB <strong>%2</strong> partition." ) "%1MiB <strong>%2</strong> partition." )
.arg( BytesToMiB( partition()->capacity() ) ) .arg( BytesToMiB( partition()->capacity() ) )
.arg( fsNameForUser ) .arg( fsNameForUser )
.arg( flagsList.join( ", " ) ); .arg( flagsList.join( ", " ) );
}
return tr( "Setting flags <strong>%1</strong> on new partition." ) return tr( "Setting flags <strong>%1</strong> on new partition." ).arg( flagsList.join( ", " ) );
.arg( flagsList.join( ", " ) );
} }
Calamares::JobResult Calamares::JobResult
SetPartFlagsJob::exec() SetPartFlagsJob::exec()
{ {
cDebug() << "Setting flags on" << m_device->deviceNode() cDebug() << "Setting flags on" << m_device->deviceNode() << "partition" << partition()->deviceNode() << "to"
<< "partition" << partition()->deviceNode() << m_flags;
<< "to" << m_flags;
Report report ( nullptr ); Report report( nullptr );
SetPartFlagsOperation op( *m_device, *partition(), m_flags ); SetPartFlagsOperation op( *m_device, *partition(), m_flags );
op.setStatus( Operation::StatusRunning ); op.setStatus( Operation::StatusRunning );
connect( &op, &Operation::progress, this, &SetPartFlagsJob::iprogress ); connect( &op, &Operation::progress, this, &SetPartFlagsJob::iprogress );
QString errorMessage = tr( "The installer failed to set flags on partition %1." ) QString errorMessage
.arg( m_partition->partitionPath() ); = tr( "The installer failed to set flags on partition %1." ).arg( m_partition->partitionPath() );
if ( op.execute( report ) ) if ( op.execute( report ) )
{
return Calamares::JobResult::ok(); return Calamares::JobResult::ok();
}
return Calamares::JobResult::error( errorMessage, report.toText() ); return Calamares::JobResult::error( errorMessage, report.toText() );
} }

View file

@ -49,4 +49,4 @@ private:
PartitionTable::Flags m_flags; PartitionTable::Flags m_flags;
}; };
#endif // SETPARTITIONFLAGSJOB_H #endif // SETPARTITIONFLAGSJOB_H