mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-24 02:45:44 -05:00
Merge branch 'kpmcore-3.2'
- Bumps requireed KPMCore to 3.3 (in spite of the branch name) - Cleans up some dependencies Thanks to Andrius Stikonas.
This commit is contained in:
commit
1a42b8af41
16 changed files with 125 additions and 323 deletions
17
CMakeModules/IncludeKPMCore.cmake
Normal file
17
CMakeModules/IncludeKPMCore.cmake
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Shared CMake core for finding KPMCore
|
||||
#
|
||||
# This is wrapped into a CMake include file because there's a bunch of
|
||||
# pre-requisites that need searching for before looking for KPMCore.
|
||||
# If you just do find_package( KPMCore ) without finding the things
|
||||
# it links against first, you get CMake errors.
|
||||
#
|
||||
#
|
||||
find_package(ECM 5.10.0 REQUIRED NO_MODULE)
|
||||
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH})
|
||||
|
||||
include(KDEInstallDirs)
|
||||
include(GenerateExportHeader)
|
||||
find_package( KF5 REQUIRED CoreAddons )
|
||||
find_package( KF5 REQUIRED Config I18n Service WidgetsAddons )
|
||||
|
||||
find_package( KPMcore 3.2 REQUIRED )
|
|
@ -1,2 +1,2 @@
|
|||
FROM kdeneon/all
|
||||
RUN sudo apt-get update && sudo apt-get -y install build-essential cmake extra-cmake-modules gettext kio-dev libatasmart-dev libboost-python-dev libkf5config-dev libkf5coreaddons-dev libkf5i18n-dev libkf5iconthemes-dev libkf5parts-dev libkf5service-dev libkf5solid-dev libkpmcore-dev libparted-dev libpolkit-qt5-1-dev libqt5svg5-dev libqt5webkit5-dev libyaml-cpp-dev os-prober pkg-config python3-dev qtbase5-dev qtdeclarative5-dev qttools5-dev qttools5-dev-tools
|
||||
RUN sudo apt-get update && sudo apt-get -y install build-essential cmake extra-cmake-modules gettext libatasmart-dev libboost-python-dev libkf5config-dev libkf5coreaddons-dev libkf5i18n-dev libkf5parts-dev libkf5service-dev libkf5widgetsaddons-dev libkpmcore-dev libparted-dev libpolkit-qt5-1-dev libqt5svg5-dev libqt5webkit5-dev libyaml-cpp-dev os-prober pkg-config python3-dev qtbase5-dev qtdeclarative5-dev qttools5-dev qttools5-dev-tools
|
||||
|
|
|
@ -26,8 +26,9 @@ Modules:
|
|||
* NetworkManager
|
||||
* UPower (optional, runtime)
|
||||
* partition:
|
||||
* KF5: KCoreAddons, KConfig, KI18n, KIconThemes, KIO, KService
|
||||
* KPMcore >= 3.0.2
|
||||
* extra-cmake-modules
|
||||
* KF5: KCoreAddons, KConfig, KI18n, KService, KWidgetsAddons
|
||||
* KPMcore >= 3.3
|
||||
* bootloader:
|
||||
* systemd-boot or GRUB
|
||||
* unpackfs:
|
||||
|
|
|
@ -100,6 +100,7 @@ def modify_mkinitcpio_conf(partitions, root_mount_point):
|
|||
cpu = cpuinfo()
|
||||
swap_uuid = ""
|
||||
btrfs = ""
|
||||
lvm2 = ""
|
||||
hooks = ["base", "udev", "autodetect", "modconf", "block", "keyboard",
|
||||
"keymap"]
|
||||
modules = []
|
||||
|
@ -122,6 +123,9 @@ def modify_mkinitcpio_conf(partitions, root_mount_point):
|
|||
if partition["fs"] == "btrfs":
|
||||
btrfs = "yes"
|
||||
|
||||
if "lvm2" in partition["fs"]:
|
||||
lvm2 = "yes"
|
||||
|
||||
if partition["mountPoint"] == "/" and "luksMapperName" in partition:
|
||||
encrypt_hook = True
|
||||
|
||||
|
@ -137,6 +141,9 @@ def modify_mkinitcpio_conf(partitions, root_mount_point):
|
|||
):
|
||||
files.append("/crypto_keyfile.bin")
|
||||
|
||||
if lvm2:
|
||||
hooks.append("lvm2")
|
||||
|
||||
if swap_uuid != "":
|
||||
if encrypt_hook and openswap_hook:
|
||||
hooks.extend(["openswap"])
|
||||
|
|
|
@ -2,40 +2,10 @@ find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE)
|
|||
|
||||
include(KDEInstallDirs)
|
||||
include(GenerateExportHeader)
|
||||
find_package( KF5 REQUIRED CoreAddons )
|
||||
|
||||
# These are needed because KPMcore links publicly against ConfigCore, I18n, IconThemes, KIOCore and Service
|
||||
find_package( KF5 REQUIRED Config I18n IconThemes KIO Service )
|
||||
|
||||
# Compatibility: KPMCore 3.2 has a different API, so detect it
|
||||
# first and add a define for it; otherwise we need 3.0.3 for NVMe
|
||||
# support; 3.0.2 works as well, but is buggy (#697)
|
||||
find_package( KPMcore 3.1.50 QUIET )
|
||||
if ( KPMcore_FOUND )
|
||||
add_definitions(-DWITH_KPMCORE22)
|
||||
endif()
|
||||
find_package( KPMcore 3.0.3 QUIET )
|
||||
# 3.0.3 and newer has fixes for NVMe support; allow 3.0.2, but warn
|
||||
# about it .. needs to use a different feature name because it otherwise
|
||||
# gets reported as KPMcore (the package).
|
||||
if ( KPMcore_FOUND )
|
||||
message( STATUS "KPMCore supports NVMe operations" )
|
||||
add_feature_info( KPMcoreNVMe KPMcore_FOUND "KPMcore with NVMe support" )
|
||||
else()
|
||||
find_package( KPMcore 3.0.2 REQUIRED )
|
||||
message( WARNING "KPMCore 3.0.2 is known to have bugs with NVMe devices" )
|
||||
add_feature_info( KPMcoreNVMe KPMcore_FOUND "Older KPMcore with no NVMe support" )
|
||||
endif()
|
||||
|
||||
find_library( atasmart_LIB atasmart )
|
||||
find_library( blkid_LIB blkid )
|
||||
if( NOT atasmart_LIB )
|
||||
message( WARNING "atasmart library not found." )
|
||||
endif()
|
||||
if( NOT blkid_LIB )
|
||||
message( WARNING "blkid library not found." )
|
||||
endif()
|
||||
find_package( Qt5 REQUIRED DBus )
|
||||
find_package( KF5 REQUIRED Config CoreAddons I18n WidgetsAddons )
|
||||
|
||||
find_package( KPMcore 3.3 REQUIRED )
|
||||
|
||||
include_directories( ${KPMCORE_INCLUDE_DIR} )
|
||||
include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui )
|
||||
|
|
|
@ -116,9 +116,7 @@ createNewPartition( PartitionNode* parent,
|
|||
PartitionTable::Flags flags )
|
||||
{
|
||||
FileSystem* fs = FileSystemFactory::create( fsType, firstSector, lastSector
|
||||
#ifdef WITH_KPMCORE22
|
||||
,device.logicalSize()
|
||||
#endif
|
||||
);
|
||||
return new Partition(
|
||||
parent,
|
||||
|
@ -153,9 +151,7 @@ createNewEncryptedPartition( PartitionNode* parent,
|
|||
FileSystemFactory::create( FileSystem::Luks,
|
||||
firstSector,
|
||||
lastSector
|
||||
#ifdef WITH_KPMCORE22
|
||||
,device.logicalSize()
|
||||
#endif
|
||||
) );
|
||||
if ( !fs )
|
||||
{
|
||||
|
@ -186,9 +182,7 @@ clonePartition( Device* device, Partition* partition )
|
|||
partition->fileSystem().type(),
|
||||
partition->firstSector(),
|
||||
partition->lastSector()
|
||||
#ifdef WITH_KPMCORE22
|
||||
,device->logicalSize()
|
||||
#endif
|
||||
);
|
||||
return new Partition( partition->parent(),
|
||||
*device,
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
#include <QDir>
|
||||
#include <QListWidgetItem>
|
||||
#include <QPushButton>
|
||||
#include <QRegularExpression>
|
||||
#include <QRegularExpressionValidator>
|
||||
#include <QSet>
|
||||
|
||||
static QSet< FileSystem::Type > s_unmountableFS(
|
||||
|
@ -66,6 +68,19 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* par
|
|||
m_ui->encryptWidget->setText( tr( "En&crypt" ) );
|
||||
m_ui->encryptWidget->hide();
|
||||
|
||||
if (m_device->type() == Device::Disk_Device) {
|
||||
m_ui->lvNameLabel->hide();
|
||||
m_ui->lvNameLineEdit->hide();
|
||||
}
|
||||
if (m_device->type() == Device::LVM_Device) {
|
||||
/* LVM logical volume name can consist of: letters numbers _ . - +
|
||||
* It cannot start with underscore _ and must not be equal to . or .. or any entry in /dev/
|
||||
* QLineEdit accepts QValidator::Intermediate, so we just disable . at the beginning */
|
||||
QRegularExpression re(QStringLiteral(R"(^(?!_|\.)[\w\-.+]+)"));
|
||||
QRegularExpressionValidator *validator = new QRegularExpressionValidator(re, this);
|
||||
m_ui->lvNameLineEdit->setValidator(validator);
|
||||
}
|
||||
|
||||
QStringList mountPoints = { "/", "/boot", "/home", "/opt", "/usr", "/var" };
|
||||
if ( PartUtils::isEfiSystem() )
|
||||
mountPoints << Calamares::JobQueue::instance()->globalStorage()->value( "efiSystemPartition" ).toString();
|
||||
|
@ -227,6 +242,10 @@ CreatePartitionDialog::createPartition()
|
|||
);
|
||||
}
|
||||
|
||||
if (m_device->type() == Device::LVM_Device) {
|
||||
partition->setPartitionPath(m_device->deviceNode() + QStringLiteral("/") + m_ui->lvNameLineEdit->text().trimmed());
|
||||
}
|
||||
|
||||
PartitionInfo::setMountPoint( partition, m_ui->mountPointComboBox->currentText() );
|
||||
PartitionInfo::setFormat( partition, true );
|
||||
|
||||
|
|
|
@ -146,6 +146,16 @@
|
|||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="lvNameLabel">
|
||||
<property name="text">
|
||||
<string>LVM LV name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QLineEdit" name="lvNameLineEdit"/>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="mountPointLabel">
|
||||
<property name="text">
|
||||
<string>&Mount Point:</string>
|
||||
|
@ -155,7 +165,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<item row="7" column="1">
|
||||
<widget class="QComboBox" name="mountPointComboBox">
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
|
@ -165,21 +175,21 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<item row="8" column="1">
|
||||
<widget class="QLabel" name="labelMountPoint">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Flags:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<item row="9" column="1">
|
||||
<widget class="QListWidget" name="m_listFlags">
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
|
@ -192,7 +202,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<item row="10" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
|
|
|
@ -119,7 +119,7 @@ PartitionPage::~PartitionPage()
|
|||
void
|
||||
PartitionPage::updateButtons()
|
||||
{
|
||||
bool create = false, edit = false, del = false;
|
||||
bool create = false, createTable = false, edit = false, del = false;
|
||||
|
||||
QModelIndex index = m_ui->partitionTreeView->currentIndex();
|
||||
if ( index.isValid() )
|
||||
|
@ -141,11 +141,18 @@ PartitionPage::updateButtons()
|
|||
edit = !isFree && !isExtended;
|
||||
del = !isFree;
|
||||
}
|
||||
|
||||
if ( m_ui->deviceComboBox->currentIndex() >= 0 )
|
||||
{
|
||||
QModelIndex deviceIndex = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 );
|
||||
if ( m_core->deviceModel()->deviceForIndex( deviceIndex )->type() != Device::LVM_Device )
|
||||
createTable = true;
|
||||
}
|
||||
|
||||
m_ui->createButton->setEnabled( create );
|
||||
m_ui->editButton->setEnabled( edit );
|
||||
m_ui->deleteButton->setEnabled( del );
|
||||
|
||||
m_ui->newPartitionTableButton->setEnabled( m_ui->deviceComboBox->currentIndex() >= 0 );
|
||||
m_ui->newPartitionTableButton->setEnabled( createTable );
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -24,20 +24,14 @@
|
|||
#include "utils/Units.h"
|
||||
|
||||
// KPMcore
|
||||
#include <kpmcore/backend/corebackend.h>
|
||||
#include <kpmcore/backend/corebackendmanager.h>
|
||||
#include <kpmcore/backend/corebackenddevice.h>
|
||||
#include <kpmcore/backend/corebackendpartition.h>
|
||||
#include <kpmcore/backend/corebackendpartitiontable.h>
|
||||
#include <kpmcore/core/device.h>
|
||||
#include <kpmcore/core/lvmdevice.h>
|
||||
#include <kpmcore/core/partition.h>
|
||||
#include <kpmcore/core/partitiontable.h>
|
||||
#include <kpmcore/fs/filesystem.h>
|
||||
#include <kpmcore/ops/newoperation.h>
|
||||
#include <kpmcore/util/report.h>
|
||||
|
||||
// Qt
|
||||
#include <QScopedPointer>
|
||||
|
||||
CreatePartitionJob::CreatePartitionJob( Device* device, Partition* partition )
|
||||
: PartitionJob( partition )
|
||||
, m_device( device )
|
||||
|
@ -78,68 +72,15 @@ CreatePartitionJob::prettyStatusMessage() const
|
|||
Calamares::JobResult
|
||||
CreatePartitionJob::exec()
|
||||
{
|
||||
int step = 0;
|
||||
const qreal stepCount = 4;
|
||||
|
||||
Report report( nullptr );
|
||||
NewOperation op(*m_device, m_partition);
|
||||
op.setStatus(Operation::StatusRunning);
|
||||
|
||||
QString message = tr( "The installer failed to create partition on disk '%1'." ).arg( m_device->name() );
|
||||
|
||||
progress( step++ / stepCount );
|
||||
CoreBackend* backend = CoreBackendManager::self()->backend();
|
||||
QScopedPointer<CoreBackendDevice> backendDevice( backend->openDevice( m_device->deviceNode() ) );
|
||||
if ( !backendDevice.data() )
|
||||
{
|
||||
return Calamares::JobResult::error(
|
||||
message,
|
||||
tr( "Could not open device '%1'." ).arg( m_device->deviceNode() )
|
||||
);
|
||||
}
|
||||
|
||||
progress( step++ / stepCount );
|
||||
QScopedPointer<CoreBackendPartitionTable> backendPartitionTable( backendDevice->openPartitionTable() );
|
||||
if ( !backendPartitionTable.data() )
|
||||
{
|
||||
return Calamares::JobResult::error(
|
||||
message,
|
||||
tr( "Could not open partition table." )
|
||||
);
|
||||
}
|
||||
|
||||
progress( step++ / stepCount );
|
||||
QString partitionPath = backendPartitionTable->createPartition( report, *m_partition );
|
||||
if ( partitionPath.isEmpty() )
|
||||
{
|
||||
return Calamares::JobResult::error(
|
||||
message,
|
||||
report.toText()
|
||||
);
|
||||
}
|
||||
m_partition->setPartitionPath( partitionPath );
|
||||
backendPartitionTable->commit();
|
||||
|
||||
progress( step++ / stepCount );
|
||||
FileSystem& fs = m_partition->fileSystem();
|
||||
if ( fs.type() == FileSystem::Unformatted || fs.type() == FileSystem::Extended )
|
||||
if (op.execute(report))
|
||||
return Calamares::JobResult::ok();
|
||||
|
||||
if ( !fs.create( report, partitionPath ) )
|
||||
{
|
||||
return Calamares::JobResult::error(
|
||||
tr( "The installer failed to create file system on partition %1." ).arg( partitionPath ),
|
||||
report.toText()
|
||||
);
|
||||
}
|
||||
|
||||
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();
|
||||
return Calamares::JobResult::error(message, report.toText());
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -23,19 +23,14 @@
|
|||
#include "utils/Logger.h"
|
||||
|
||||
// KPMcore
|
||||
#include <kpmcore/backend/corebackend.h>
|
||||
#include <kpmcore/backend/corebackendmanager.h>
|
||||
#include <kpmcore/backend/corebackenddevice.h>
|
||||
#include <kpmcore/backend/corebackendpartition.h>
|
||||
#include <kpmcore/backend/corebackendpartitiontable.h>
|
||||
#include <kpmcore/core/device.h>
|
||||
#include <kpmcore/core/partition.h>
|
||||
#include <kpmcore/core/partitiontable.h>
|
||||
#include <kpmcore/fs/filesystem.h>
|
||||
#include <kpmcore/util/report.h>
|
||||
#include <core/device.h>
|
||||
#include <core/partition.h>
|
||||
#include <core/partitiontable.h>
|
||||
#include <fs/filesystem.h>
|
||||
#include <ops/createpartitiontableoperation.h>
|
||||
#include <util/report.h>
|
||||
|
||||
// Qt
|
||||
#include <QScopedPointer>
|
||||
#include <QProcess>
|
||||
|
||||
CreatePartitionTableJob::CreatePartitionTableJob( Device* device, PartitionTable::TableType type )
|
||||
|
@ -76,17 +71,7 @@ CreatePartitionTableJob::exec()
|
|||
Report report( nullptr );
|
||||
QString message = tr( "The installer failed to create a partition table on %1." ).arg( m_device->name() );
|
||||
|
||||
CoreBackend* backend = CoreBackendManager::self()->backend();
|
||||
QScopedPointer< CoreBackendDevice > backendDevice( backend->openDevice( m_device->deviceNode() ) );
|
||||
if ( !backendDevice.data() )
|
||||
{
|
||||
return Calamares::JobResult::error(
|
||||
message,
|
||||
tr( "Could not open device %1." ).arg( m_device->deviceNode() )
|
||||
);
|
||||
}
|
||||
|
||||
QScopedPointer< PartitionTable > table( createTable() );
|
||||
PartitionTable* table = m_device->partitionTable();
|
||||
cDebug() << "Creating new partition table of type" << table->typeName()
|
||||
<< ", uncommitted yet:\n" << table;
|
||||
|
||||
|
@ -104,20 +89,13 @@ CreatePartitionTableJob::exec()
|
|||
mount.waitForFinished();
|
||||
cDebug() << "mount:\n" << mount.readAllStandardOutput();
|
||||
|
||||
bool ok = backendDevice->createPartitionTable( report, *table );
|
||||
if ( !ok )
|
||||
{
|
||||
return Calamares::JobResult::error(
|
||||
message,
|
||||
QString( "Text: %1\nCommand: %2\nOutput: %3\nStatus: %4" )
|
||||
.arg( report.toText() )
|
||||
.arg( report.command() )
|
||||
.arg( report.output() )
|
||||
.arg( report.status() )
|
||||
);
|
||||
}
|
||||
CreatePartitionTableOperation op(*m_device, table);
|
||||
op.setStatus(Operation::StatusRunning);
|
||||
|
||||
if (op.execute(report))
|
||||
return Calamares::JobResult::ok();
|
||||
|
||||
return Calamares::JobResult::error(message, report.toText());
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -21,15 +21,12 @@
|
|||
#include "jobs/DeletePartitionJob.h"
|
||||
|
||||
// KPMcore
|
||||
#include <kpmcore/backend/corebackend.h>
|
||||
#include <kpmcore/backend/corebackendmanager.h>
|
||||
#include <kpmcore/backend/corebackenddevice.h>
|
||||
#include <kpmcore/backend/corebackendpartitiontable.h>
|
||||
#include <kpmcore/core/device.h>
|
||||
#include <kpmcore/core/partition.h>
|
||||
#include <kpmcore/core/partitiontable.h>
|
||||
#include <kpmcore/fs/filesystem.h>
|
||||
#include <kpmcore/util/report.h>
|
||||
#include <core/device.h>
|
||||
#include <core/partition.h>
|
||||
#include <core/partitiontable.h>
|
||||
#include <fs/filesystem.h>
|
||||
#include <ops/deleteoperation.h>
|
||||
#include <util/report.h>
|
||||
|
||||
DeletePartitionJob::DeletePartitionJob( Device* device, Partition* partition )
|
||||
: PartitionJob( partition )
|
||||
|
@ -65,48 +62,14 @@ Calamares::JobResult
|
|||
DeletePartitionJob::exec()
|
||||
{
|
||||
Report report( nullptr );
|
||||
DeleteOperation op(*m_device, m_partition);
|
||||
op.setStatus(Operation::StatusRunning);
|
||||
|
||||
QString message = tr( "The installer failed to delete partition %1." ).arg( m_partition->devicePath() );
|
||||
|
||||
if ( m_device->deviceNode() != m_partition->devicePath() )
|
||||
{
|
||||
return Calamares::JobResult::error(
|
||||
message,
|
||||
tr( "Partition (%1) and device (%2) do not match." )
|
||||
.arg( m_partition->devicePath() )
|
||||
.arg( m_device->deviceNode() )
|
||||
);
|
||||
}
|
||||
|
||||
CoreBackend* backend = CoreBackendManager::self()->backend();
|
||||
QScopedPointer<CoreBackendDevice> backendDevice( backend->openDevice( m_device->deviceNode() ) );
|
||||
if ( !backendDevice.data() )
|
||||
{
|
||||
return Calamares::JobResult::error(
|
||||
message,
|
||||
tr( "Could not open device %1." ).arg( m_device->deviceNode() )
|
||||
);
|
||||
}
|
||||
|
||||
QScopedPointer<CoreBackendPartitionTable> backendPartitionTable( backendDevice->openPartitionTable() );
|
||||
if ( !backendPartitionTable.data() )
|
||||
{
|
||||
return Calamares::JobResult::error(
|
||||
message,
|
||||
tr( "Could not open partition table." )
|
||||
);
|
||||
}
|
||||
|
||||
bool ok = backendPartitionTable->deletePartition( report, *m_partition );
|
||||
if ( !ok )
|
||||
{
|
||||
return Calamares::JobResult::error(
|
||||
message,
|
||||
report.toText()
|
||||
);
|
||||
}
|
||||
|
||||
backendPartitionTable->commit();
|
||||
if (op.execute(report))
|
||||
return Calamares::JobResult::ok();
|
||||
|
||||
return Calamares::JobResult::error(message, report.toText());
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -28,11 +28,11 @@
|
|||
#include "Branding.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
// CalaPM
|
||||
#include <kpmcore/core/device.h>
|
||||
#include <kpmcore/core/partition.h>
|
||||
#include <kpmcore/fs/filesystem.h>
|
||||
#include <kpmcore/fs/luks.h>
|
||||
// KPMcore
|
||||
#include <core/device.h>
|
||||
#include <core/partition.h>
|
||||
#include <fs/filesystem.h>
|
||||
#include <fs/luks.h>
|
||||
|
||||
// Qt
|
||||
#include <QDebug>
|
||||
|
@ -77,50 +77,6 @@ getLuksUuid( const QString& path )
|
|||
return uuid;
|
||||
}
|
||||
|
||||
// TODO: this will be available from KPMCore soon
|
||||
static const char* filesystem_labels[] = {
|
||||
"unknown",
|
||||
"extended",
|
||||
|
||||
"ext2",
|
||||
"ext3",
|
||||
"ext4",
|
||||
"linuxswap",
|
||||
"fat16",
|
||||
"fat32",
|
||||
"ntfs",
|
||||
"reiser",
|
||||
"reiser4",
|
||||
"xfs",
|
||||
"jfs",
|
||||
"hfs",
|
||||
"hfsplus",
|
||||
"ufs",
|
||||
"unformatted",
|
||||
"btrfs",
|
||||
"hpfs",
|
||||
"luks",
|
||||
"ocfs2",
|
||||
"zfs",
|
||||
"exfat",
|
||||
"nilfs2",
|
||||
"lvm2 pv",
|
||||
"f2fs",
|
||||
"udf",
|
||||
"iso9660",
|
||||
};
|
||||
|
||||
Q_STATIC_ASSERT_X((sizeof(filesystem_labels) / sizeof(char *)) >= FileSystem::__lastType, "Mismatch in filesystem labels");
|
||||
|
||||
static QString
|
||||
untranslatedTypeName(FileSystem::Type t)
|
||||
{
|
||||
|
||||
Q_ASSERT( t >= 0 );
|
||||
Q_ASSERT( t <= FileSystem::__lastType );
|
||||
|
||||
return QLatin1String(filesystem_labels[t]);
|
||||
}
|
||||
|
||||
static QVariant
|
||||
mapForPartition( Partition* partition, const QString& uuid )
|
||||
|
@ -129,7 +85,7 @@ mapForPartition( Partition* partition, const QString& uuid )
|
|||
map[ "device" ] = partition->partitionPath();
|
||||
map[ "mountPoint" ] = PartitionInfo::mountPoint( partition );
|
||||
map[ "fsName" ] = partition->fileSystem().name();
|
||||
map[ "fs" ] = untranslatedTypeName( partition->fileSystem().type() );
|
||||
map[ "fs" ] = partition->fileSystem().name( { QStringLiteral("C") } ); // Untranslated
|
||||
if ( partition->fileSystem().type() == FileSystem::Luks &&
|
||||
dynamic_cast< FS::luks& >( partition->fileSystem() ).innerFS() )
|
||||
map[ "fs" ] = dynamic_cast< FS::luks& >( partition->fileSystem() ).innerFS()->name();
|
||||
|
|
|
@ -22,20 +22,12 @@
|
|||
#include "utils/Logger.h"
|
||||
|
||||
// KPMcore
|
||||
#include <kpmcore/backend/corebackend.h>
|
||||
#include <kpmcore/backend/corebackendmanager.h>
|
||||
#include <kpmcore/backend/corebackenddevice.h>
|
||||
#include <kpmcore/backend/corebackendpartition.h>
|
||||
#include <kpmcore/backend/corebackendpartitiontable.h>
|
||||
#include <kpmcore/core/device.h>
|
||||
#include <kpmcore/core/partition.h>
|
||||
#include <kpmcore/core/partitiontable.h>
|
||||
#include <kpmcore/fs/filesystem.h>
|
||||
#include <kpmcore/util/report.h>
|
||||
|
||||
// Qt
|
||||
#include <QScopedPointer>
|
||||
#include <QThread>
|
||||
#include <core/device.h>
|
||||
#include <core/partition.h>
|
||||
#include <core/partitiontable.h>
|
||||
#include <fs/filesystem.h>
|
||||
#include <ops/createfilesystemoperation.h>
|
||||
#include <util/report.h>
|
||||
|
||||
FormatPartitionJob::FormatPartitionJob( Device* device, Partition* partition )
|
||||
: PartitionJob( partition )
|
||||
|
@ -79,62 +71,13 @@ Calamares::JobResult
|
|||
FormatPartitionJob::exec()
|
||||
{
|
||||
Report report( nullptr ); // Root of the report tree, no parent
|
||||
QString partitionPath = m_partition->partitionPath();
|
||||
QString message = tr( "The installer failed to format partition %1 on disk '%2'." ).arg( partitionPath, m_device->name() );
|
||||
CreateFileSystemOperation op(*m_device, *m_partition, m_partition->fileSystem().type());
|
||||
op.setStatus(Operation::StatusRunning);
|
||||
|
||||
CoreBackend* backend = CoreBackendManager::self()->backend();
|
||||
QScopedPointer<CoreBackendDevice> backendDevice( backend->openDevice( m_device->deviceNode() ) );
|
||||
if ( !backendDevice.data() )
|
||||
{
|
||||
return Calamares::JobResult::error(
|
||||
message,
|
||||
tr( "Could not open device '%1'." ).arg( m_device->deviceNode() )
|
||||
);
|
||||
}
|
||||
QString message = tr( "The installer failed to format partition %1 on disk '%2'." ).arg( m_partition->partitionPath(), m_device->name() );
|
||||
|
||||
QScopedPointer<CoreBackendPartitionTable> backendPartitionTable( backendDevice->openPartitionTable() );
|
||||
if ( !backendPartitionTable.data() )
|
||||
{
|
||||
return Calamares::JobResult::error(
|
||||
message,
|
||||
tr( "Could not open partition table." )
|
||||
);
|
||||
}
|
||||
|
||||
FileSystem& fs = m_partition->fileSystem();
|
||||
|
||||
bool ok = fs.create( report, partitionPath );
|
||||
int retries = 0;
|
||||
const int MAX_RETRIES = 10;
|
||||
while ( !ok )
|
||||
{
|
||||
cDebug() << "Partition" << m_partition->partitionPath()
|
||||
<< "might not be ready yet, retrying (" << ++retries
|
||||
<< "/" << MAX_RETRIES << ") ...";
|
||||
QThread::sleep( 2 /*seconds*/ );
|
||||
ok = fs.create( report, partitionPath );
|
||||
|
||||
if ( retries == MAX_RETRIES )
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !ok )
|
||||
{
|
||||
return Calamares::JobResult::error(
|
||||
tr( "The installer failed to create file system on partition %1." )
|
||||
.arg( partitionPath ),
|
||||
report.toText()
|
||||
);
|
||||
}
|
||||
|
||||
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();
|
||||
if (op.execute(report))
|
||||
return Calamares::JobResult::ok();
|
||||
|
||||
return Calamares::JobResult::error(message, report.toText());
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
find_package( Qt5 COMPONENTS Gui Test REQUIRED )
|
||||
find_package( KF5 COMPONENTS Service REQUIRED )
|
||||
|
||||
include( ECMAddTests )
|
||||
|
||||
|
@ -31,7 +30,6 @@ ecm_add_test( ${partitionjobtests_SRCS}
|
|||
kpmcore
|
||||
Qt5::Core
|
||||
Qt5::Test
|
||||
KF5::Service
|
||||
)
|
||||
|
||||
set_target_properties( partitionjobtests PROPERTIES AUTOMOC TRUE )
|
||||
|
|
|
@ -219,9 +219,7 @@ PartitionJobTests::newCreatePartitionJob( Partition* freeSpacePartition, Partiti
|
|||
else
|
||||
lastSector = freeSpacePartition->lastSector();
|
||||
FileSystem* fs = FileSystemFactory::create( type, firstSector, lastSector
|
||||
#ifdef WITH_KPMCORE22
|
||||
,m_device->logicalSize()
|
||||
#endif
|
||||
);
|
||||
|
||||
Partition* partition = new Partition(
|
||||
|
|
Loading…
Add table
Reference in a new issue