From a57b08c200f7eb6ab3fedcc9e8591024c7e43f51 Mon Sep 17 00:00:00 2001 From: Philip Date: Mon, 23 Jan 2017 15:23:22 +0100 Subject: [PATCH] Adopt upstream changes on webview and partition - [webview] fix crash on loading webview page with QtWebengine - [partition] Bump KPMcore dependency to 3.0.2 - [partition] Make sure to disable the root password if setRootPassword is false - [partition] Force the correct flags for EFI system partition - [partition] Always write bootloader path - [partition] Do not write bootloader install path if the system is EFI --- src/modules/partition/CMakeLists.txt | 2 +- src/modules/partition/core/PartUtils.cpp | 9 ++++-- .../partition/core/PartitionActions.cpp | 4 +-- .../partition/core/PartitionCoreModule.cpp | 2 ++ src/modules/partition/gui/ChoicePage.cpp | 18 ++++++++++-- .../partition/gui/CreatePartitionDialog.cpp | 13 +++++---- .../partition/gui/CreatePartitionDialog.ui | 5 ---- .../gui/EditExistingPartitionDialog.cpp | 16 ++++++---- .../gui/EditExistingPartitionDialog.ui | 5 ---- src/modules/partition/gui/PartitionPage.cpp | 29 ++++++++++++++----- src/modules/partition/gui/PartitionPage.h | 1 + .../partition/jobs/FillGlobalStorageJob.cpp | 2 ++ src/modules/webview/WebViewStep.cpp | 4 +++ 13 files changed, 72 insertions(+), 38 deletions(-) diff --git a/src/modules/partition/CMakeLists.txt b/src/modules/partition/CMakeLists.txt index b14165512..4d68f4b10 100644 --- a/src/modules/partition/CMakeLists.txt +++ b/src/modules/partition/CMakeLists.txt @@ -10,7 +10,7 @@ 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 ) -find_package( KPMcore 3.0.0 REQUIRED ) +find_package( KPMcore 3.0.2 REQUIRED ) add_subdirectory( tests ) diff --git a/src/modules/partition/core/PartUtils.cpp b/src/modules/partition/core/PartUtils.cpp index 11931347f..0f9b4203a 100644 --- a/src/modules/partition/core/PartUtils.cpp +++ b/src/modules/partition/core/PartUtils.cpp @@ -51,8 +51,9 @@ canBeReplaced( Partition* candidate ) qint64 requiredStorageB = ( requiredStorageGB + 0.5 ) * 1024 * 1024 * 1024; cDebug() << "Required storage B:" << requiredStorageB << QString( "(%1GB)" ).arg( requiredStorageB / 1024 / 1024 / 1024 ); - cDebug() << "Available storage B:" << availableStorageB - << QString( "(%1GB)" ).arg( availableStorageB / 1024 / 1024 / 1024 ); + cDebug() << "Storage capacity B:" << availableStorageB + << QString( "(%1GB)" ).arg( availableStorageB / 1024 / 1024 / 1024 ) + << "for" << candidate->partitionPath() << " length:" << candidate->length(); if ( ok && availableStorageB > requiredStorageB ) @@ -102,7 +103,9 @@ canBeResized( Partition* candidate ) cDebug() << "Required storage B:" << requiredStorageB << QString( "(%1GB)" ).arg( requiredStorageB / 1024 / 1024 / 1024 ); cDebug() << "Available storage B:" << availableStorageB - << QString( "(%1GB)" ).arg( availableStorageB / 1024 / 1024 / 1024 ); + << QString( "(%1GB)" ).arg( availableStorageB / 1024 / 1024 / 1024 ) + << "for" << candidate->partitionPath() << " length:" << candidate->length() + << " sectorsUsed:" << candidate->sectorsUsed() << " fsType:" << candidate->fileSystem().name(); if ( ok && availableStorageB > requiredStorageB ) diff --git a/src/modules/partition/core/PartitionActions.cpp b/src/modules/partition/core/PartitionActions.cpp index 90779b7fa..b8d81d913 100644 --- a/src/modules/partition/core/PartitionActions.cpp +++ b/src/modules/partition/core/PartitionActions.cpp @@ -1,6 +1,6 @@ /* === This file is part of Calamares - === * - * Copyright 2014-2016, Teo Mrnjavac + * Copyright 2014-2017, Teo Mrnjavac * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -148,7 +148,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, const QString& luksPass ->globalStorage() ->value( "efiSystemPartition" ) .toString() ); - core->createPartition( dev, efiPartition ); + core->createPartition( dev, efiPartition, PartitionTable::FlagEsp | PartitionTable::FlagBoot ); firstFreeSector = lastSector + 1; } else diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp index 87393a424..7ce67be16 100644 --- a/src/modules/partition/core/PartitionCoreModule.cpp +++ b/src/modules/partition/core/PartitionCoreModule.cpp @@ -441,6 +441,7 @@ PartitionCoreModule::jobs() const lst << info->jobs; devices << info->device.data(); } + cDebug() << "Creating FillGlobalStorageJob with bootLoader path" << m_bootLoaderInstallPath; lst << Calamares::job_ptr( new FillGlobalStorageJob( devices, m_bootLoaderInstallPath ) ); @@ -596,6 +597,7 @@ PartitionCoreModule::findPartitionByMountPoint( const QString& mountPoint ) cons void PartitionCoreModule::setBootLoaderInstallPath( const QString& path ) { + cDebug() << "PCM::setBootLoaderInstallPath" << path; m_bootLoaderInstallPath = path; } diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index b700a24aa..68a75c2df 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -1,6 +1,6 @@ /* === This file is part of Calamares - === * - * Copyright 2014-2016, Teo Mrnjavac + * Copyright 2014-2017, Teo Mrnjavac * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -565,8 +565,20 @@ ChoicePage::onLeave() } else // installPath is then passed to the bootloader module for MBR setup { - if ( m_bootloaderComboBox.isNull() ) - m_core->setBootLoaderInstallPath( selectedDevice()->deviceNode() ); + if ( !m_isEfi ) + { + if ( m_bootloaderComboBox.isNull() ) + { + m_core->setBootLoaderInstallPath( selectedDevice()->deviceNode() ); + } + else + { + QVariant var = m_bootloaderComboBox->currentData( BootLoaderModel::BootLoaderPathRole ); + if ( !var.isValid() ) + return; + m_core->setBootLoaderInstallPath( var.toString() ); + } + } } } diff --git a/src/modules/partition/gui/CreatePartitionDialog.cpp b/src/modules/partition/gui/CreatePartitionDialog.cpp index 90545fe80..4cd22bf68 100644 --- a/src/modules/partition/gui/CreatePartitionDialog.cpp +++ b/src/modules/partition/gui/CreatePartitionDialog.cpp @@ -263,12 +263,15 @@ CreatePartitionDialog::checkMountPointSelection() { const QString& selection = m_ui->mountPointComboBox->currentText(); - if (m_usedMountPoints.contains(selection)) { - m_ui->labelMountPoint->setText("Mountpoint already in use. Please select another one."); - m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); - } else { + if ( m_usedMountPoints.contains( selection ) ) + { + m_ui->labelMountPoint->setText( tr( "Mountpoint already in use. Please select another one." ) ); + m_ui->buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false ); + } + else + { m_ui->labelMountPoint->setText( QString() ); - m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); + m_ui->buttonBox->button( QDialogButtonBox::Ok )->setEnabled( true ); } } diff --git a/src/modules/partition/gui/CreatePartitionDialog.ui b/src/modules/partition/gui/CreatePartitionDialog.ui index bad15a4cf..53445e0ec 100644 --- a/src/modules/partition/gui/CreatePartitionDialog.ui +++ b/src/modules/partition/gui/CreatePartitionDialog.ui @@ -167,11 +167,6 @@ - - - true - - diff --git a/src/modules/partition/gui/EditExistingPartitionDialog.cpp b/src/modules/partition/gui/EditExistingPartitionDialog.cpp index 5aa1e21f6..1909e48e8 100644 --- a/src/modules/partition/gui/EditExistingPartitionDialog.cpp +++ b/src/modules/partition/gui/EditExistingPartitionDialog.cpp @@ -67,7 +67,8 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, Partit m_partitionSizeController->setSpinBox( m_ui->sizeSpinBox ); m_ui->mountPointComboBox->setCurrentText( PartitionInfo::mountPoint( partition ) ); - connect( m_ui->mountPointComboBox, &QComboBox::currentTextChanged, this, &EditExistingPartitionDialog::checkMountPointSelection ); + connect( m_ui->mountPointComboBox, &QComboBox::currentTextChanged, + this, &EditExistingPartitionDialog::checkMountPointSelection ); replacePartResizerWidget(); @@ -300,11 +301,14 @@ EditExistingPartitionDialog::checkMountPointSelection() { const QString& selection = m_ui->mountPointComboBox->currentText(); - if (m_usedMountPoints.contains(selection)) { - m_ui->labelMountPoint->setText("Mountpoint already in use. Please select another one."); - m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); - } else { + if ( m_usedMountPoints.contains( selection ) ) + { + m_ui->labelMountPoint->setText( tr( "Mountpoint already in use. Please select another one." ) ); + m_ui->buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false ); + } + else + { m_ui->labelMountPoint->setText( QString() ); - m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); + m_ui->buttonBox->button( QDialogButtonBox::Ok )->setEnabled( true ); } } diff --git a/src/modules/partition/gui/EditExistingPartitionDialog.ui b/src/modules/partition/gui/EditExistingPartitionDialog.ui index 27e930fda..edee3c7a7 100644 --- a/src/modules/partition/gui/EditExistingPartitionDialog.ui +++ b/src/modules/partition/gui/EditExistingPartitionDialog.ui @@ -161,11 +161,6 @@ - - - true - - diff --git a/src/modules/partition/gui/PartitionPage.cpp b/src/modules/partition/gui/PartitionPage.cpp index 5e3239050..93d8e8be2 100644 --- a/src/modules/partition/gui/PartitionPage.cpp +++ b/src/modules/partition/gui/PartitionPage.cpp @@ -57,7 +57,10 @@ PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent ) , m_ui( new Ui_PartitionPage ) , m_lastSelectedBootLoaderIndex(-1) , m_core( core ) + , m_isEfi( false ) { + m_isEfi = QDir( "/sys/firmware/efi/efivars" ).exists(); + m_ui->setupUi( this ); m_ui->partitionLabelsView->setVisible( Calamares::JobQueue::instance()->globalStorage()-> @@ -100,7 +103,7 @@ PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent ) connect( m_ui->editButton, &QAbstractButton::clicked, this, &PartitionPage::onEditClicked ); connect( m_ui->deleteButton, &QAbstractButton::clicked, this, &PartitionPage::onDeleteClicked ); - if ( QDir( "/sys/firmware/efi/efivars" ).exists() ) { + if ( m_isEfi ) { m_ui->bootLoaderComboBox->hide(); m_ui->label_3->hide(); } @@ -177,7 +180,10 @@ PartitionPage::onCreateClicked() Partition* partition = model->partitionForIndex( index ); Q_ASSERT( partition ); - QPointer dlg = new CreatePartitionDialog( model->device(), partition->parent(), getCurrentUsedMountpoints(), this ); + QPointer< CreatePartitionDialog > dlg = new CreatePartitionDialog( model->device(), + partition->parent(), + getCurrentUsedMountpoints(), + this ); dlg->initFromFreeSpace( partition ); if ( dlg->exec() == QDialog::Accepted ) { @@ -269,7 +275,10 @@ PartitionPage::updatePartitionToCreate( Device* device, Partition* partition ) QStringList mountPoints = getCurrentUsedMountpoints(); mountPoints.removeOne( PartitionInfo::mountPoint( partition ) ); - QPointer dlg = new CreatePartitionDialog( device, partition->parent(), mountPoints, this ); + QPointer< CreatePartitionDialog > dlg = new CreatePartitionDialog( device, + partition->parent(), + mountPoints, + this ); dlg->initFromPartitionToCreate( partition ); if ( dlg->exec() == QDialog::Accepted ) { @@ -295,9 +304,13 @@ PartitionPage::editExistingPartition( Device* device, Partition* partition ) void PartitionPage::updateBootLoaderInstallPath() { + if ( m_isEfi || !m_ui->bootLoaderComboBox->isVisible() ) + return; + QVariant var = m_ui->bootLoaderComboBox->currentData( BootLoaderModel::BootLoaderPathRole ); if ( !var.isValid() ) return; + qDebug() << "PartitionPage::updateBootLoaderInstallPath" << var.toString(); m_core->setBootLoaderInstallPath( var.toString() ); } @@ -386,19 +399,19 @@ PartitionPage::updateBootLoaderIndex() QStringList PartitionPage::getCurrentUsedMountpoints() { - QModelIndex index = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 ); + QModelIndex index = m_core->deviceModel()->index( + m_ui->deviceComboBox->currentIndex(), 0 ); if ( !index.isValid() ) return QStringList(); Device* device = m_core->deviceModel()->deviceForIndex( index ); QStringList mountPoints; - for (Partition* partition : device->partitionTable()->children()) { + for ( Partition* partition : device->partitionTable()->children() ) + { const QString& mountPoint = PartitionInfo::mountPoint( partition ); - - if (!mountPoint.isEmpty()) { + if ( !mountPoint.isEmpty() ) mountPoints << mountPoint; - } } return mountPoints; diff --git a/src/modules/partition/gui/PartitionPage.h b/src/modules/partition/gui/PartitionPage.h index 59453ce18..f998fe2ae 100644 --- a/src/modules/partition/gui/PartitionPage.h +++ b/src/modules/partition/gui/PartitionPage.h @@ -66,6 +66,7 @@ private: QMutex m_revertMutex; int m_lastSelectedBootLoaderIndex; + bool m_isEfi; }; #endif // PARTITIONPAGE_H diff --git a/src/modules/partition/jobs/FillGlobalStorageJob.cpp b/src/modules/partition/jobs/FillGlobalStorageJob.cpp index 553b56b52..db59528a4 100644 --- a/src/modules/partition/jobs/FillGlobalStorageJob.cpp +++ b/src/modules/partition/jobs/FillGlobalStorageJob.cpp @@ -198,10 +198,12 @@ FillGlobalStorageJob::exec() QVariant var = createBootLoaderMap(); if ( !var.isValid() ) cDebug() << "Failed to find path for boot loader"; + cDebug() << "FillGlobalStorageJob writing bootLoader path:" << var; storage->insert( "bootLoader", var ); } else { + cDebug() << "FillGlobalStorageJob writing empty bootLoader value"; storage->insert( "bootLoader", QVariant() ); } return Calamares::JobResult::ok(); diff --git a/src/modules/webview/WebViewStep.cpp b/src/modules/webview/WebViewStep.cpp index b1d50bf7c..069b52d5a 100644 --- a/src/modules/webview/WebViewStep.cpp +++ b/src/modules/webview/WebViewStep.cpp @@ -25,6 +25,7 @@ #include #else #include +#include #endif CALAMARES_PLUGIN_FACTORY_DEFINITION( WebViewStepFactory, registerPlugin(); ) @@ -33,6 +34,9 @@ WebViewStep::WebViewStep( QObject* parent ) : Calamares::ViewStep( parent ) { emit nextStatusChanged( true ); +#ifdef WEBVIEW_WITH_WEBENGINE + QtWebEngine::initialize(); +#endif m_view = new C_QWEBVIEW(); #ifdef WEBVIEW_WITH_WEBKIT m_view->settings()->setFontFamily( QWebSettings::StandardFont,