From 9159761171555715f54a8e01706d7595c9a92099 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 12 Apr 2019 11:18:29 +0200 Subject: [PATCH 1/5] [partition] [fsresizer] Fix KPMCore API detection - There will be a 3.3.1 which still has the "old" API, so look at 3.3.80 (pre-4.0) instead. Make the way compile flags are passed consistent. --- src/modules/fsresizer/CMakeLists.txt | 7 +++++-- src/modules/partition/CMakeLists.txt | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/modules/fsresizer/CMakeLists.txt b/src/modules/fsresizer/CMakeLists.txt index 12349c835..4351dca51 100644 --- a/src/modules/fsresizer/CMakeLists.txt +++ b/src/modules/fsresizer/CMakeLists.txt @@ -2,12 +2,14 @@ find_package( KPMcore 3.3 ) find_package( Qt5 REQUIRED DBus ) # Needed for KPMCore find_package( KF5 REQUIRED I18n WidgetsAddons ) # Needed for KPMCore +set( _partition_defs "" ) + if ( KPMcore_FOUND ) include_directories( ${KPMCORE_INCLUDE_DIR} ) include_directories( ${PROJECT_BINARY_DIR}/src/libcalamares ) - if ( KPMcore_VERSION VERSION_GREATER "3.3.0") - add_definitions(-DWITH_KPMCOREGT33) # kpmcore greater than 3.3 + if ( KPMcore_VERSION VERSION_GREATER "3.90") + list( APPEND _partition_defs WITH_KPMCORE4API) # kpmcore 4 with new API endif() # The PartitionIterator is a small class, and it's easiest -- but also a @@ -21,6 +23,7 @@ if ( KPMcore_FOUND ) LINK_PRIVATE_LIBRARIES kpmcore calamares + COMPILE_DEFINITIONS ${_partition_defs} SHARED_LIB ) diff --git a/src/modules/partition/CMakeLists.txt b/src/modules/partition/CMakeLists.txt index 56520845e..844c50ed4 100644 --- a/src/modules/partition/CMakeLists.txt +++ b/src/modules/partition/CMakeLists.txt @@ -27,8 +27,8 @@ set_package_properties( ) if ( KPMcore_FOUND ) - if ( KPMcore_VERSION VERSION_GREATER "3.3.0") - add_definitions(-DWITH_KPMCOREGT33) # kpmcore greater than 3.3 + if ( KPMcore_VERSION VERSION_GREATER "3.90") + list( APPEND _partition_defs WITH_KPMCORE4API) # kpmcore 4 with new API endif() include_directories( ${KPMCORE_INCLUDE_DIR} ) From c0710cabe4700eff45427b82f41ab6b72b8b070d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 12 Apr 2019 11:21:18 +0200 Subject: [PATCH 2/5] [partition] [fsresizer] Adjust to new #define - Using KPMCORE4API is clearer than just relying on a version number --- src/modules/fsresizer/ResizeFSJob.cpp | 2 +- src/modules/partition/core/DeviceList.cpp | 2 +- src/modules/partition/core/KPMHelpers.h | 2 +- src/modules/partition/core/PartitionCoreModule.cpp | 4 ++-- src/modules/partition/gui/ChoicePage.cpp | 4 ++-- src/modules/partition/gui/PartitionPage.cpp | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/modules/fsresizer/ResizeFSJob.cpp b/src/modules/fsresizer/ResizeFSJob.cpp index fa197e476..d2cfaf6ed 100644 --- a/src/modules/fsresizer/ResizeFSJob.cpp +++ b/src/modules/fsresizer/ResizeFSJob.cpp @@ -120,7 +120,7 @@ ResizeFSJob::PartitionMatch ResizeFSJob::findPartition( CoreBackend* backend ) { using DeviceList = QList< Device* >; -#ifdef WITH_KPMCOREGT33 +#ifdef WITH_KPMCORE4API DeviceList devices = backend->scanDevices( /* not includeReadOnly, not includeLoopback */ ScanFlag(0) ); #else DeviceList devices = backend->scanDevices( /* excludeReadOnly */ true ); diff --git a/src/modules/partition/core/DeviceList.cpp b/src/modules/partition/core/DeviceList.cpp index cef1c0414..b65473cf6 100644 --- a/src/modules/partition/core/DeviceList.cpp +++ b/src/modules/partition/core/DeviceList.cpp @@ -107,7 +107,7 @@ QList< Device* > getDevices( DeviceType which, qint64 minimumSize ) bool writableOnly = (which == DeviceType::WritableOnly); CoreBackend* backend = CoreBackendManager::self()->backend(); -#ifdef WITH_KPMCOREGT33 +#ifdef WITH_KPMCORE4API DeviceList devices = backend->scanDevices( /* not includeReadOnly, not includeLoopback */ ScanFlag(0) ); #else DeviceList devices = backend->scanDevices( /* excludeReadOnly */ true ); diff --git a/src/modules/partition/core/KPMHelpers.h b/src/modules/partition/core/KPMHelpers.h index f1b8bd8a9..aa279b1fb 100644 --- a/src/modules/partition/core/KPMHelpers.h +++ b/src/modules/partition/core/KPMHelpers.h @@ -33,7 +33,7 @@ class Partition; class PartitionNode; class PartitionRole; -#ifdef WITH_KPMCOREGT33 +#ifdef WITH_KPMCORE4API #define KPM_PARTITION_FLAG(x) PartitionTable::Flag::x #define KPM_PARTITION_STATE(x) Partition::State::x #define KPM_PARTITION_FLAG_ESP PartitionTable::Flag::Boot diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp index f183d6c40..df331f04b 100644 --- a/src/modules/partition/core/PartitionCoreModule.cpp +++ b/src/modules/partition/core/PartitionCoreModule.cpp @@ -683,7 +683,7 @@ PartitionCoreModule::scanForLVMPVs() } } -#ifdef WITH_KPMCOREGT33 +#ifdef WITH_KPMCORE4API VolumeManagerDevice::scanDevices( physicalDevices ); for ( auto p : LVM::pvList::list() ) @@ -724,7 +724,7 @@ PartitionCoreModule::scanForLVMPVs() if ( innerFS && innerFS->type() == FileSystem::Type::Lvm2_PV ) m_lvmPVs << p; } -#ifdef WITH_KPMCOREGT33 +#ifdef WITH_KPMCORE4API else if ( p->fileSystem().type() == FileSystem::Type::Luks2 ) { // Encrypted LVM PVs diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index 10f73964f..edeee11a6 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -51,7 +51,7 @@ #include #include -#ifdef WITH_KPMCOREGT33 +#ifdef WITH_KPMCORE4API #include #endif @@ -1224,7 +1224,7 @@ ChoicePage::setupActions() bool atLeastOneIsMounted = false; // Suppress 'erase' if so bool isInactiveRAID = false; -#ifdef WITH_KPMCOREGT33 +#ifdef WITH_KPMCORE4API if ( currentDevice->type() == Device::Type::SoftwareRAID_Device && static_cast< SoftwareRAID* >(currentDevice)->status() == SoftwareRAID::Status::Inactive ) { diff --git a/src/modules/partition/gui/PartitionPage.cpp b/src/modules/partition/gui/PartitionPage.cpp index 5f16e9dc1..22398bddb 100644 --- a/src/modules/partition/gui/PartitionPage.cpp +++ b/src/modules/partition/gui/PartitionPage.cpp @@ -49,7 +49,7 @@ // KPMcore #include #include -#ifdef WITH_KPMCOREGT33 +#ifdef WITH_KPMCORE4API #include #endif #include @@ -162,7 +162,7 @@ PartitionPage::updateButtons() { createTable = true; -#ifdef WITH_KPMCOREGT33 +#ifdef WITH_KPMCORE4API if ( device->type() == Device::Type::SoftwareRAID_Device && static_cast< SoftwareRAID* >(device)->status() == SoftwareRAID::Status::Inactive ) { From 4e24ea29e24208d880cbce5aa4431d4f06ba09e5 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 12 Apr 2019 12:44:59 +0200 Subject: [PATCH 3/5] [partition] [fsresizer] Adjust to post-3.3.0 API - KDE neon ships a post-3.3.0 KPMCore, with deprecations, but not yet the KPMCore 4 API, so add another API-version check to handle the deprecations. Keeps warnings down. --- src/modules/fsresizer/CMakeLists.txt | 3 +++ src/modules/partition/CMakeLists.txt | 3 +++ src/modules/partition/core/KPMHelpers.h | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/modules/fsresizer/CMakeLists.txt b/src/modules/fsresizer/CMakeLists.txt index 4351dca51..582a02627 100644 --- a/src/modules/fsresizer/CMakeLists.txt +++ b/src/modules/fsresizer/CMakeLists.txt @@ -8,6 +8,9 @@ if ( KPMcore_FOUND ) include_directories( ${KPMCORE_INCLUDE_DIR} ) include_directories( ${PROJECT_BINARY_DIR}/src/libcalamares ) + if ( KPMcore_VERSION VERSION_GREATER "3.3.0") + list( APPEND _partition_defs WITH_KPMCORE331API) # kpmcore > 3.3.0 with deprecations + endif() if ( KPMcore_VERSION VERSION_GREATER "3.90") list( APPEND _partition_defs WITH_KPMCORE4API) # kpmcore 4 with new API endif() diff --git a/src/modules/partition/CMakeLists.txt b/src/modules/partition/CMakeLists.txt index 844c50ed4..9bcace064 100644 --- a/src/modules/partition/CMakeLists.txt +++ b/src/modules/partition/CMakeLists.txt @@ -27,6 +27,9 @@ set_package_properties( ) if ( KPMcore_FOUND ) + if ( KPMcore_VERSION VERSION_GREATER "3.3.0") + list( APPEND _partition_defs WITH_KPMCORE331API) # kpmcore > 3.3.0 with deprecations + endif() if ( KPMcore_VERSION VERSION_GREATER "3.90") list( APPEND _partition_defs WITH_KPMCORE4API) # kpmcore 4 with new API endif() diff --git a/src/modules/partition/core/KPMHelpers.h b/src/modules/partition/core/KPMHelpers.h index aa279b1fb..b1c3832fc 100644 --- a/src/modules/partition/core/KPMHelpers.h +++ b/src/modules/partition/core/KPMHelpers.h @@ -33,7 +33,7 @@ class Partition; class PartitionNode; class PartitionRole; -#ifdef WITH_KPMCORE4API +#ifdef WITH_KPMCORE331API #define KPM_PARTITION_FLAG(x) PartitionTable::Flag::x #define KPM_PARTITION_STATE(x) Partition::State::x #define KPM_PARTITION_FLAG_ESP PartitionTable::Flag::Boot From c844188907fa71353c2e3a1ac8c7ea35df2f9063 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 12 Apr 2019 12:54:13 +0200 Subject: [PATCH 4/5] [partition] Fix build w/ "3.3.1" API - Need older-style scanning, but new-style iteration --- src/modules/partition/core/PartitionCoreModule.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp index df331f04b..f50510da7 100644 --- a/src/modules/partition/core/PartitionCoreModule.cpp +++ b/src/modules/partition/core/PartitionCoreModule.cpp @@ -683,14 +683,17 @@ PartitionCoreModule::scanForLVMPVs() } } -#ifdef WITH_KPMCORE4API +#if defined( WITH_KPMCORE4API ) VolumeManagerDevice::scanDevices( physicalDevices ); - + for ( auto p : LVM::pvList::list() ) +#else +#if defined( WITH_KPMCORE331API ) + LvmDevice::scanSystemLVM( physicalDevices ); for ( auto p : LVM::pvList::list() ) #else LvmDevice::scanSystemLVM( physicalDevices ); - for ( auto p : LVM::pvList ) +#endif #endif { m_lvmPVs << p.partition().data(); From 198acadd2311b89e57731428be4c9c6f06e1fc11 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 12 Apr 2019 13:14:13 +0200 Subject: [PATCH 5/5] [partition] [fsresizer] Fix KPMCore API versions - tests need the defines as well - scandevices API changed with API 3.3.1 --- src/modules/fsresizer/CMakeLists.txt | 3 ++- src/modules/fsresizer/ResizeFSJob.cpp | 2 +- src/modules/partition/core/DeviceList.cpp | 2 +- src/modules/partition/tests/CMakeLists.txt | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modules/fsresizer/CMakeLists.txt b/src/modules/fsresizer/CMakeLists.txt index 582a02627..36c8c764c 100644 --- a/src/modules/fsresizer/CMakeLists.txt +++ b/src/modules/fsresizer/CMakeLists.txt @@ -44,7 +44,8 @@ if ( KPMcore_FOUND ) Qt5::Test ) set_target_properties( fsresizertest PROPERTIES AUTOMOC TRUE ) - target_include_directories(fsresizertest PRIVATE /usr/local/include ) + target_include_directories( fsresizertest PRIVATE /usr/local/include ) + target_compile_definitions( fsresizertest PRIVATE ${_partition_defs} ) endif() else() calamares_skip_module( "fsresizer (missing suitable KPMcore)" ) diff --git a/src/modules/fsresizer/ResizeFSJob.cpp b/src/modules/fsresizer/ResizeFSJob.cpp index d2cfaf6ed..61fbc6898 100644 --- a/src/modules/fsresizer/ResizeFSJob.cpp +++ b/src/modules/fsresizer/ResizeFSJob.cpp @@ -120,7 +120,7 @@ ResizeFSJob::PartitionMatch ResizeFSJob::findPartition( CoreBackend* backend ) { using DeviceList = QList< Device* >; -#ifdef WITH_KPMCORE4API +#ifdef WITH_KPMCORE331API DeviceList devices = backend->scanDevices( /* not includeReadOnly, not includeLoopback */ ScanFlag(0) ); #else DeviceList devices = backend->scanDevices( /* excludeReadOnly */ true ); diff --git a/src/modules/partition/core/DeviceList.cpp b/src/modules/partition/core/DeviceList.cpp index b65473cf6..a7f9ff44c 100644 --- a/src/modules/partition/core/DeviceList.cpp +++ b/src/modules/partition/core/DeviceList.cpp @@ -107,7 +107,7 @@ QList< Device* > getDevices( DeviceType which, qint64 minimumSize ) bool writableOnly = (which == DeviceType::WritableOnly); CoreBackend* backend = CoreBackendManager::self()->backend(); -#ifdef WITH_KPMCORE4API +#ifdef WITH_KPMCORE331API DeviceList devices = backend->scanDevices( /* not includeReadOnly, not includeLoopback */ ScanFlag(0) ); #else DeviceList devices = backend->scanDevices( /* excludeReadOnly */ true ); diff --git a/src/modules/partition/tests/CMakeLists.txt b/src/modules/partition/tests/CMakeLists.txt index 7b40c34a5..ac3968df9 100644 --- a/src/modules/partition/tests/CMakeLists.txt +++ b/src/modules/partition/tests/CMakeLists.txt @@ -32,4 +32,5 @@ if( ECM_FOUND AND BUILD_TESTING ) ) set_target_properties( partitionjobtests PROPERTIES AUTOMOC TRUE ) + target_compile_definitions( partitionjobtests PRIVATE ${_partition_defs} ) endif()