Merge branch 'ff-fslabel' into calamares

This was a PR from Lisa Vitolo a long time ago, to expose
FS labels in the UI, and it got lost in transition.
Five-years-too late thanks.
main
Adriaan de Groot 4 years ago
commit fac0c90de1

@ -80,6 +80,7 @@ if ( KPMcore_FOUND AND Qt5DBus_FOUND AND KF5CoreAddons_FOUND AND KF5Config_FOUND
gui/ReplaceWidget.cpp gui/ReplaceWidget.cpp
gui/VolumeGroupBaseDialog.cpp gui/VolumeGroupBaseDialog.cpp
jobs/AutoMountManagementJob.cpp jobs/AutoMountManagementJob.cpp
jobs/ChangeFilesystemLabelJob.cpp
jobs/ClearMountsJob.cpp jobs/ClearMountsJob.cpp
jobs/ClearTempMountsJob.cpp jobs/ClearTempMountsJob.cpp
jobs/CreatePartitionJob.cpp jobs/CreatePartitionJob.cpp
@ -117,3 +118,4 @@ else()
calamares_skip_module( "partition (missing dependencies for KPMcore)" ) calamares_skip_module( "partition (missing dependencies for KPMcore)" )
endif() endif()
endif() endif()

@ -46,11 +46,13 @@ createNewPartition( PartitionNode* parent,
const Device& device, const Device& device,
const PartitionRole& role, const PartitionRole& role,
FileSystem::Type fsType, FileSystem::Type fsType,
const QString& fsLabel,
qint64 firstSector, qint64 firstSector,
qint64 lastSector, qint64 lastSector,
PartitionTable::Flags flags ) PartitionTable::Flags flags )
{ {
FileSystem* fs = FileSystemFactory::create( fsType, firstSector, lastSector, device.logicalSize() ); FileSystem* fs = FileSystemFactory::create( fsType, firstSector, lastSector, device.logicalSize() );
fs->setLabel( fsLabel );
return new Partition( parent, return new Partition( parent,
device, device,
role, role,
@ -71,6 +73,7 @@ createNewEncryptedPartition( PartitionNode* parent,
const Device& device, const Device& device,
const PartitionRole& role, const PartitionRole& role,
FileSystem::Type fsType, FileSystem::Type fsType,
const QString& fsLabel,
qint64 firstSector, qint64 firstSector,
qint64 lastSector, qint64 lastSector,
const QString& passphrase, const QString& passphrase,
@ -92,6 +95,7 @@ createNewEncryptedPartition( PartitionNode* parent,
fs->createInnerFileSystem( fsType ); fs->createInnerFileSystem( fsType );
fs->setPassphrase( passphrase ); fs->setPassphrase( passphrase );
fs->setLabel( fsLabel );
Partition* p = new Partition( parent, Partition* p = new Partition( parent,
device, device,
PartitionRole( newRoles ), PartitionRole( newRoles ),

@ -55,6 +55,7 @@ Partition* createNewPartition( PartitionNode* parent,
const Device& device, const Device& device,
const PartitionRole& role, const PartitionRole& role,
FileSystem::Type fsType, FileSystem::Type fsType,
const QString& fsLabel,
qint64 firstSector, qint64 firstSector,
qint64 lastSector, qint64 lastSector,
PartitionTable::Flags flags ); PartitionTable::Flags flags );
@ -63,6 +64,7 @@ Partition* createNewEncryptedPartition( PartitionNode* parent,
const Device& device, const Device& device,
const PartitionRole& role, const PartitionRole& role,
FileSystem::Type fsType, FileSystem::Type fsType,
const QString& fsLabel,
qint64 firstSector, qint64 firstSector,
qint64 lastSector, qint64 lastSector,
const QString& passphrase, const QString& passphrase,

@ -132,6 +132,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO
*dev, *dev,
PartitionRole( PartitionRole::Primary ), PartitionRole( PartitionRole::Primary ),
FileSystem::Fat32, FileSystem::Fat32,
QString(),
firstFreeSector, firstFreeSector,
lastSector, lastSector,
KPM_PARTITION_FLAG( None ) ); KPM_PARTITION_FLAG( None ) );
@ -180,6 +181,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO
*dev, *dev,
PartitionRole( PartitionRole::Primary ), PartitionRole( PartitionRole::Primary ),
FileSystem::LinuxSwap, FileSystem::LinuxSwap,
QStringLiteral( "swap" ),
lastSectorForRoot + 1, lastSectorForRoot + 1,
dev->totalLogical() - 1, dev->totalLogical() - 1,
KPM_PARTITION_FLAG( None ) ); KPM_PARTITION_FLAG( None ) );
@ -190,6 +192,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO
*dev, *dev,
PartitionRole( PartitionRole::Primary ), PartitionRole( PartitionRole::Primary ),
FileSystem::LinuxSwap, FileSystem::LinuxSwap,
QStringLiteral( "swap" ),
lastSectorForRoot + 1, lastSectorForRoot + 1,
dev->totalLogical() - 1, dev->totalLogical() - 1,
o.luksPassphrase, o.luksPassphrase,

@ -22,6 +22,7 @@
#include "core/PartitionInfo.h" #include "core/PartitionInfo.h"
#include "core/PartitionModel.h" #include "core/PartitionModel.h"
#include "jobs/AutoMountManagementJob.h" #include "jobs/AutoMountManagementJob.h"
#include "jobs/ChangeFilesystemLabelJob.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"
@ -541,6 +542,16 @@ PartitionCoreModule::formatPartition( Device* device, Partition* partition )
deviceInfo->makeJob< FormatPartitionJob >( partition ); deviceInfo->makeJob< FormatPartitionJob >( partition );
} }
void
PartitionCoreModule::setFilesystemLabel( Device* device, Partition* partition, const QString& newLabel )
{
auto deviceInfo = infoForDevice( device );
Q_ASSERT( deviceInfo );
OperationHelper helper( partitionModelForDevice( device ), this );
deviceInfo->makeJob< ChangeFilesystemLabelJob >( partition, newLabel );
}
void void
PartitionCoreModule::resizePartition( Device* device, Partition* partition, qint64 first, qint64 last ) PartitionCoreModule::resizePartition( Device* device, Partition* partition, qint64 first, qint64 last )
{ {
@ -911,6 +922,14 @@ PartitionCoreModule::layoutApply( Device* dev,
= std::find_if( partList.constBegin(), partList.constEnd(), is_boot ) != partList.constEnd(); = std::find_if( partList.constBegin(), partList.constEnd(), is_boot ) != partList.constEnd();
for ( Partition* part : partList ) for ( Partition* part : partList )
{ {
if ( is_boot( part ) )
{
part->setLabel( "boot" );
}
if ( is_root( part ) )
{
part->setLabel( "root" );
}
if ( ( separate_boot_partition && is_boot( part ) ) || ( !separate_boot_partition && is_root( part ) ) ) if ( ( separate_boot_partition && is_boot( part ) ) || ( !separate_boot_partition && is_root( part ) ) )
{ {
createPartition( createPartition(

@ -147,6 +147,8 @@ public:
void formatPartition( Device* device, Partition* partition ); void formatPartition( Device* device, Partition* partition );
void setFilesystemLabel( Device* device, Partition* partition, const QString& newLabel );
void resizePartition( Device* device, Partition* partition, qint64 first, qint64 last ); void resizePartition( Device* device, Partition* partition, qint64 first, qint64 last );
void setPartitionFlags( Device* device, Partition* partition, PartitionTable::Flags flags ); void setPartitionFlags( Device* device, Partition* partition, PartitionTable::Flags flags );

@ -230,6 +230,7 @@ PartitionLayout::createPartitions( Device* dev,
*dev, *dev,
role, role,
entry.partFileSystem, entry.partFileSystem,
entry.partLabel,
currentSector, currentSector,
currentSector + sectors - 1, currentSector + sectors - 1,
KPM_PARTITION_FLAG( None ) ); KPM_PARTITION_FLAG( None ) );
@ -240,6 +241,7 @@ PartitionLayout::createPartitions( Device* dev,
*dev, *dev,
role, role,
entry.partFileSystem, entry.partFileSystem,
entry.partLabel,
currentSector, currentSector,
currentSector + sectors - 1, currentSector + sectors - 1,
luksPassphrase, luksPassphrase,

@ -167,6 +167,10 @@ PartitionModel::data( const QModelIndex& index, int role ) const
{ {
return CalamaresUtils::Partition::prettyNameForFileSystemType( partition->fileSystem().type() ); return CalamaresUtils::Partition::prettyNameForFileSystemType( partition->fileSystem().type() );
} }
if ( col == FileSystemLabelColumn )
{
return partition->fileSystem().label();
}
if ( col == MountPointColumn ) if ( col == MountPointColumn )
{ {
return PartitionInfo::mountPoint( partition ); return PartitionInfo::mountPoint( partition );
@ -296,6 +300,8 @@ PartitionModel::headerData( int section, Qt::Orientation, int role ) const
return tr( "Name" ); return tr( "Name" );
case FileSystemColumn: case FileSystemColumn:
return tr( "File System" ); return tr( "File System" );
case FileSystemLabelColumn:
return tr( "File System Label" );
case MountPointColumn: case MountPointColumn:
return tr( "Mount Point" ); return tr( "Mount Point" );
case SizeColumn: case SizeColumn:

@ -79,6 +79,7 @@ public:
{ {
NameColumn, NameColumn,
FileSystemColumn, FileSystemColumn,
FileSystemLabelColumn,
MountPointColumn, MountPointColumn,
SizeColumn, SizeColumn,
ColumnCount // Must remain last ColumnCount // Must remain last

@ -202,17 +202,19 @@ 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() );
const QString fsLabel = m_ui->filesystemLabelEdit->text();
Partition* partition = nullptr; Partition* partition = nullptr;
QString luksPassphrase = m_ui->encryptWidget->passphrase(); QString luksPassphrase = m_ui->encryptWidget->passphrase();
if ( m_ui->encryptWidget->state() == EncryptWidget::Encryption::Confirmed && !luksPassphrase.isEmpty() ) if ( m_ui->encryptWidget->state() == EncryptWidget::Encryption::Confirmed && !luksPassphrase.isEmpty() )
{ {
partition = KPMHelpers::createNewEncryptedPartition( partition = KPMHelpers::createNewEncryptedPartition(
m_parent, *m_device, m_role, fsType, first, last, luksPassphrase, newFlags() ); m_parent, *m_device, m_role, fsType, fsLabel, first, last, luksPassphrase, newFlags() );
} }
else else
{ {
partition = KPMHelpers::createNewPartition( m_parent, *m_device, m_role, fsType, first, last, newFlags() ); partition
= KPMHelpers::createNewPartition( m_parent, *m_device, m_role, fsType, fsLabel, first, last, newFlags() );
} }
if ( m_device->type() == Device::Type::LVM_Device ) if ( m_device->type() == Device::Type::LVM_Device )

@ -130,10 +130,10 @@ SPDX-License-Identifier: GPL-3.0-or-later
<item row="3" column="1"> <item row="3" column="1">
<widget class="QComboBox" name="fsComboBox"/> <widget class="QComboBox" name="fsComboBox"/>
</item> </item>
<item row="4" column="1"> <item row="5" column="1">
<widget class="EncryptWidget" name="encryptWidget" native="true"/> <widget class="EncryptWidget" name="encryptWidget" native="true"/>
</item> </item>
<item row="5" column="1"> <item row="6" column="1">
<spacer name="verticalSpacer_2"> <spacer name="verticalSpacer_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -149,17 +149,17 @@ SPDX-License-Identifier: GPL-3.0-or-later
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="6" column="0"> <item row="7" column="0">
<widget class="QLabel" name="lvNameLabel"> <widget class="QLabel" name="lvNameLabel">
<property name="text"> <property name="text">
<string>LVM LV name</string> <string>LVM LV name</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="1"> <item row="7" column="1">
<widget class="QLineEdit" name="lvNameLineEdit"/> <widget class="QLineEdit" name="lvNameLineEdit"/>
</item> </item>
<item row="7" column="0"> <item row="8" column="0">
<widget class="QLabel" name="mountPointLabel"> <widget class="QLabel" name="mountPointLabel">
<property name="text"> <property name="text">
<string>&amp;Mount Point:</string> <string>&amp;Mount Point:</string>
@ -169,7 +169,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="1"> <item row="8" column="1">
<widget class="QComboBox" name="mountPointComboBox"> <widget class="QComboBox" name="mountPointComboBox">
<property name="editable"> <property name="editable">
<bool>true</bool> <bool>true</bool>
@ -179,21 +179,21 @@ SPDX-License-Identifier: GPL-3.0-or-later
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="1"> <item row="10" column="1">
<widget class="QLabel" name="labelMountPoint"> <widget class="QLabel" name="labelMountPoint">
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="0"> <item row="11" column="0">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="text"> <property name="text">
<string>Flags:</string> <string>Flags:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="1"> <item row="11" column="1">
<widget class="QListWidget" name="m_listFlags"> <widget class="QListWidget" name="m_listFlags">
<property name="alternatingRowColors"> <property name="alternatingRowColors">
<bool>true</bool> <bool>true</bool>
@ -206,7 +206,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
</property> </property>
</widget> </widget>
</item> </item>
<item row="10" column="0"> <item row="12" column="0">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -219,6 +219,29 @@ SPDX-License-Identifier: GPL-3.0-or-later
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="9" column="1">
<widget class="QLineEdit" name="filesystemLabelEdit">
<property name="maximumSize">
<size>
<width>150</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Label for the filesystem</string>
</property>
<property name="maxLength">
<number>16</number>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>FS Label:</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>

@ -62,6 +62,10 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device,
this, this,
&EditExistingPartitionDialog::checkMountPointSelection ); &EditExistingPartitionDialog::checkMountPointSelection );
// The filesystem label dialog is always enabled, because we may want to change
// the label on the current filesystem without formatting.
m_ui->fileSystemLabelEdit->setText( m_partition->fileSystem().label() );
replacePartResizerWidget(); replacePartResizerWidget();
connect( m_ui->formatRadioButton, &QAbstractButton::toggled, [this]( bool doFormat ) { connect( m_ui->formatRadioButton, &QAbstractButton::toggled, [this]( bool doFormat ) {
@ -146,6 +150,7 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
? FileSystem::Extended ? FileSystem::Extended
: FileSystem::typeForName( m_ui->fileSystemComboBox->currentText() ); : FileSystem::typeForName( m_ui->fileSystemComboBox->currentText() );
} }
const QString fsLabel = m_ui->fileSystemLabelEdit->text();
const auto resultFlags = newFlags(); const auto resultFlags = newFlags();
const auto currentFlags = PartitionInfo::flags( m_partition ); const auto currentFlags = PartitionInfo::flags( m_partition );
@ -158,6 +163,7 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
*m_device, *m_device,
m_partition->roles(), m_partition->roles(),
fsType, fsType,
fsLabel,
newFirstSector, newFirstSector,
newLastSector, newLastSector,
resultFlags ); resultFlags );
@ -190,6 +196,7 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
{ {
core->setPartitionFlags( m_device, m_partition, resultFlags ); core->setPartitionFlags( m_device, m_partition, resultFlags );
} }
core->setFilesystemLabel( m_device, m_partition, fsLabel );
} }
else // otherwise, we delete and recreate the partition with new fs type else // otherwise, we delete and recreate the partition with new fs type
{ {
@ -197,6 +204,7 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
*m_device, *m_device,
m_partition->roles(), m_partition->roles(),
fsType, fsType,
fsLabel,
m_partition->firstSector(), m_partition->firstSector(),
m_partition->lastSector(), m_partition->lastSector(),
resultFlags ); resultFlags );
@ -214,6 +222,14 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
{ {
core->setPartitionFlags( m_device, m_partition, resultFlags ); core->setPartitionFlags( m_device, m_partition, resultFlags );
} }
// In this case, we are not formatting the partition, but we are setting the
// label on the current filesystem, if any. We only create the job if the
// label actually changed.
if ( m_partition->fileSystem().type() != FileSystem::Type::Unformatted
&& fsLabel != m_partition->fileSystem().label() )
{
core->setFilesystemLabel( m_device, m_partition, fsLabel );
}
core->refreshPartition( m_device, m_partition ); core->refreshPartition( m_device, m_partition );
} }
} }

@ -11,7 +11,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>450</width> <width>450</width>
<height>579</height> <height>615</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -147,14 +147,14 @@ SPDX-License-Identifier: GPL-3.0-or-later
<item row="5" column="1"> <item row="5" column="1">
<widget class="QComboBox" name="fileSystemComboBox"/> <widget class="QComboBox" name="fileSystemComboBox"/>
</item> </item>
<item row="8" column="0"> <item row="9" column="0">
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_4">
<property name="text"> <property name="text">
<string>Flags:</string> <string>Flags:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="1"> <item row="9" column="1">
<widget class="QListWidget" name="m_listFlags"> <widget class="QListWidget" name="m_listFlags">
<property name="alternatingRowColors"> <property name="alternatingRowColors">
<bool>true</bool> <bool>true</bool>
@ -167,13 +167,36 @@ SPDX-License-Identifier: GPL-3.0-or-later
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="1"> <item row="8" column="1">
<widget class="QLabel" name="labelMountPoint"> <widget class="QLabel" name="labelMountPoint">
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="1">
<widget class="QLineEdit" name="fileSystemLabelEdit">
<property name="maximumSize">
<size>
<width>150</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Label for the filesystem</string>
</property>
<property name="maxLength">
<number>16</number>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="fileSystemLabelLabel">
<property name="text">
<string>FS Label:</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>

@ -0,0 +1,105 @@
/* === This file is part of Calamares - <https://calamares.io> ===
*
* SPDX-FileCopyrightText: 2016, Lisa Vitolo <shainer@chakraos.org>
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Calamares is Free Software: see the License-Identifier above.
*
*/
#include "ChangeFilesystemLabelJob.h"
#include "utils/Logger.h"
#include <kpmcore/backend/corebackend.h>
#include <kpmcore/backend/corebackenddevice.h>
#include <kpmcore/backend/corebackendmanager.h>
#include <kpmcore/backend/corebackendpartition.h>
#include <kpmcore/backend/corebackendpartitiontable.h>
#include <kpmcore/core/device.h>
#include <kpmcore/core/partition.h>
#include <kpmcore/util/report.h>
ChangeFilesystemLabelJob::ChangeFilesystemLabelJob( Device* device, Partition* partition, const QString& newLabel )
: PartitionJob( partition )
, m_device( device )
, m_label( newLabel )
{
}
QString
ChangeFilesystemLabelJob::prettyName() const
{
return tr( "Set filesystem label on %1." ).arg( partition()->partitionPath() );
}
QString
ChangeFilesystemLabelJob::prettyDescription() const
{
return tr( "Set filesystem label <strong>%1</strong> to partition "
"<strong>%2</strong>." )
.arg( m_label )
.arg( partition()->partitionPath() );
}
QString
ChangeFilesystemLabelJob::prettyStatusMessage() const
{
return prettyDescription();
}
Calamares::JobResult
ChangeFilesystemLabelJob::exec()
{
if ( m_label == partition()->fileSystem().label() )
{
return Calamares::JobResult::ok();
}
Report report( nullptr );
CoreBackend* backend = CoreBackendManager::self()->backend();
QScopedPointer< CoreBackendDevice > backendDevice( backend->openDevice( m_device->deviceNode() ) );
if ( !backendDevice.data() )
{
return Calamares::JobResult::error( tr( "Could not open device '%1'." ).arg( m_device->deviceNode() ),
report.toText() );
}
QScopedPointer< CoreBackendPartitionTable > backendPartitionTable( backendDevice->openPartitionTable() );
if ( !backendPartitionTable.data() )
{
return Calamares::JobResult::error(
tr( "Could not open partition table on device '%1'." ).arg( m_device->deviceNode() ), report.toText() );
}
QScopedPointer< CoreBackendPartition > backendPartition(
( partition()->roles().has( PartitionRole::Extended ) )
? backendPartitionTable->getExtendedPartition()
: backendPartitionTable->getPartitionBySector( partition()->firstSector() ) );
if ( !backendPartition.data() )
{
return Calamares::JobResult::error( tr( "Could not find partition '%1'." ).arg( partition()->partitionPath() ),
report.toText() );
}
FileSystem& fs = m_partition->fileSystem();
fs.setLabel( m_label );
if ( !backendPartitionTable->setPartitionSystemType( report, *m_partition ) )
{
return Calamares::JobResult::error(
tr( "The installer failed to update partition table on disk '%1'." ).arg( m_device->name() ),
report.toText() );
}
backendPartitionTable->commit();
return Calamares::JobResult::ok();
}
#include "ChangeFilesystemLabelJob.moc"

@ -0,0 +1,40 @@
/* === This file is part of Calamares - <https://calamares.io> ===
*
* SPDX-FileCopyrightText: 2016, Lisa Vitolo <shainer@chakraos.org>
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Calamares is Free Software: see the License-Identifier above.
*
*/
#ifndef CHANGEFILESYSTEMLABELJOB_H
#define CHANGEFILESYSTEMLABELJOB_H
#include "PartitionJob.h"
#include <kpmcore/core/partitiontable.h>
class Device;
class Partition;
/**
* This job changes the flags on an existing partition.
*/
class ChangeFilesystemLabelJob : public PartitionJob
{
Q_OBJECT
public:
ChangeFilesystemLabelJob( Device* device, Partition* partition, const QString& newLabel );
QString prettyName() const override;
QString prettyDescription() const override;
QString prettyStatusMessage() const override;
Calamares::JobResult exec() override;
Device* device() const;
private:
Device* m_device;
QString m_label;
};
#endif // CHANGEFILESYSTEMLABELJOB_H

@ -33,7 +33,7 @@ CreatePartitionJob::CreatePartitionJob( Device* device, Partition* partition )
{ {
} }
static const QMap < QString, QString > gptTypePrettyStrings = { static const QMap< QString, QString > gptTypePrettyStrings = {
{ "44479540-f297-41b2-9af7-d131d5f0458a", "Linux Root Partition (x86)" }, { "44479540-f297-41b2-9af7-d131d5f0458a", "Linux Root Partition (x86)" },
{ "4f68bce3-e8cd-4db1-96e7-fbcaf984b709", "Linux Root Partition (x86-64)" }, { "4f68bce3-e8cd-4db1-96e7-fbcaf984b709", "Linux Root Partition (x86-64)" },
{ "69dad710-2ce4-4e3c-b16c-21a1d49abed3", "Linux Root Partition (32-bit ARM)" }, { "69dad710-2ce4-4e3c-b16c-21a1d49abed3", "Linux Root Partition (32-bit ARM)" },
@ -115,17 +115,17 @@ CreatePartitionJob::prettyName() const
if ( !entries.isEmpty() ) if ( !entries.isEmpty() )
{ {
return tr( "Create new %1MiB partition on %3 (%2) with entries %4." ) return tr( "Create new %1MiB partition on %3 (%2) with entries %4." )
.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() )
.arg( entries ); .arg( entries );
} }
else else
{ {
return tr( "Create new %1MiB partition on %3 (%2)." ) return tr( "Create new %1MiB partition on %3 (%2)." )
.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() );
} }
} }
@ -146,18 +146,19 @@ CreatePartitionJob::prettyDescription() const
QString entries = prettyGptEntries( m_partition ); QString entries = prettyGptEntries( m_partition );
if ( !entries.isEmpty() ) if ( !entries.isEmpty() )
{ {
return tr( "Create new <strong>%1MiB</strong> partition on <strong>%3</strong> (%2) with entries <em>%4</em>." ) return tr( "Create new <strong>%1MiB</strong> partition on <strong>%3</strong> (%2) with entries "
.arg( CalamaresUtils::BytesToMiB( m_partition->capacity() ) ) "<em>%4</em>." )
.arg( m_device->name() ) .arg( CalamaresUtils::BytesToMiB( m_partition->capacity() ) )
.arg( m_device->deviceNode() ) .arg( m_device->name() )
.arg( entries ); .arg( m_device->deviceNode() )
.arg( entries );
} }
else else
{ {
return tr( "Create new <strong>%1MiB</strong> partition on <strong>%3</strong> (%2)." ) return tr( "Create new <strong>%1MiB</strong> partition on <strong>%3</strong> (%2)." )
.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() );
} }
} }
@ -186,9 +187,7 @@ CreatePartitionJob::prettyStatusMessage() const
type = userVisibleFS( m_partition->fileSystem() ); type = userVisibleFS( m_partition->fileSystem() );
} }
return tr( "Creating new %1 partition on %2." ) return tr( "Creating new %1 partition on %2." ).arg( type ).arg( m_device->deviceNode() );
.arg( type )
.arg( m_device->deviceNode() );
} }
return tr( "Creating new %1 partition on %2." ) return tr( "Creating new %1 partition on %2." )

@ -9,8 +9,8 @@
#include "jobs/AutoMountManagementJob.h" #include "jobs/AutoMountManagementJob.h"
#include "utils/Logger.h"
#include "JobQueue.h" #include "JobQueue.h"
#include "utils/Logger.h"
#include <QObject> #include <QObject>
#include <QtTest/QtTest> #include <QtTest/QtTest>
@ -52,7 +52,8 @@ AutoMountJobTests::testRunThrice()
CalamaresUtils::Partition::automountRestore( original ); CalamaresUtils::Partition::automountRestore( original );
} }
void AutoMountJobTests::testRunQueue() void
AutoMountJobTests::testRunQueue()
{ {
Calamares::JobQueue q; Calamares::JobQueue q;
Calamares::job_ptr jp( new AutoMountManagementJob( false ) ); Calamares::job_ptr jp( new AutoMountManagementJob( false ) );
@ -68,8 +69,8 @@ void AutoMountJobTests::testRunQueue()
QVERIFY( !q.isRunning() ); QVERIFY( !q.isRunning() );
QEventLoop loop; QEventLoop loop;
QTimer::singleShot( std::chrono::milliseconds( 100 ), [&q](){ q.start(); } ); QTimer::singleShot( std::chrono::milliseconds( 100 ), [&q]() { q.start(); } );
QTimer::singleShot( std::chrono::milliseconds( 5000 ), [&loop](){ loop.quit(); } ); QTimer::singleShot( std::chrono::milliseconds( 5000 ), [&loop]() { loop.quit(); } );
connect( &q, &Calamares::JobQueue::finished, &loop, &QEventLoop::quit ); connect( &q, &Calamares::JobQueue::finished, &loop, &QEventLoop::quit );
loop.exec(); loop.exec();

@ -377,6 +377,7 @@ PartitionJobTests::testResizePartition()
*m_device, *m_device,
PartitionRole( PartitionRole::Primary ), PartitionRole( PartitionRole::Primary ),
FileSystem::Ext4, FileSystem::Ext4,
QStringLiteral( "testp" ),
oldFirst, oldFirst,
oldLast, oldLast,
KPM_PARTITION_FLAG( None ) ); KPM_PARTITION_FLAG( None ) );

Loading…
Cancel
Save