From 15cce29a5159dd81bb3dc1d923af5ab5fb0ea3a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20PORTAY?= Date: Mon, 16 Mar 2020 17:25:55 -0400 Subject: [PATCH] [partition] Add support for filesystem-specific features --- src/libcalamares/CMakeLists.txt | 7 ++++++- src/modules/fsresizer/CMakeLists.txt | 4 +++- src/modules/partition/CMakeLists.txt | 3 +++ src/modules/partition/core/PartitionCoreModule.cpp | 2 ++ src/modules/partition/core/PartitionLayout.cpp | 11 +++++++++++ src/modules/partition/core/PartitionLayout.h | 3 +++ src/modules/partition/partition.conf | 8 ++++++++ 7 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index 156ab2cc6..608768a97 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -128,7 +128,12 @@ if ( KPMcore_FOUND ) find_package( Qt5 REQUIRED DBus ) # Needed for KPMCore find_package( KF5 REQUIRED I18n WidgetsAddons ) # Needed for KPMCore - if( KPMcore_VERSION VERSION_GREATER_EQUAL "4.0" ) + if( KPMcore_VERSION VERSION_GREATER_EQUAL "4.2" ) + add_definitions( + -DWITH_KPMCORE42API + -DWITH_KPMCORE4API + ) # kpmcore 4.2 with new API + elseif( KPMcore_VERSION VERSION_GREATER_EQUAL "4.0" ) add_definitions( -DWITH_KPMCORE4API ) # kpmcore 4 with new API elseif( KPMcore_VERSION VERSION_GREATER "3.3.70" ) message( FATAL_ERROR "KPMCore beta versions ${KPMcore_VERSION} not supported" ) diff --git a/src/modules/fsresizer/CMakeLists.txt b/src/modules/fsresizer/CMakeLists.txt index 1f4260518..6808f1bea 100644 --- a/src/modules/fsresizer/CMakeLists.txt +++ b/src/modules/fsresizer/CMakeLists.txt @@ -8,7 +8,9 @@ set( _partition_defs "" ) if ( KPMcore_FOUND AND Qt5DBus_FOUND AND KF5CoreAddons_FOUND AND KF5Config_FOUND ) include_directories( ${KPMCORE_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/src/modules/partition ) - if( KPMcore_VERSION VERSION_GREATER_EQUAL "4.0" ) + if( KPMcore_VERSION VERSION_GREATER_EQUAL "4.2" ) + list( APPEND _partition_defs WITH_KPMCORE42API WITH_KPMCORE4API ) # kpmcore 4.2 with new API + elseif( KPMcore_VERSION VERSION_GREATER_EQUAL "4.0" ) list( APPEND _partition_defs WITH_KPMCORE4API ) # kpmcore 4 with new API elseif( KPMcore_VERSION VERSION_GREATER "3.3.70" ) message( FATAL_ERROR "KPMCore beta versions ${KPMcore_VERSION} are not supported" ) diff --git a/src/modules/partition/CMakeLists.txt b/src/modules/partition/CMakeLists.txt index 2ac926346..2f9474a29 100644 --- a/src/modules/partition/CMakeLists.txt +++ b/src/modules/partition/CMakeLists.txt @@ -33,6 +33,9 @@ if ( KPMcore_FOUND AND Qt5DBus_FOUND AND KF5CoreAddons_FOUND AND KF5Config_FOUND if ( KPMcore_VERSION VERSION_GREATER "3.90") list( APPEND _partition_defs WITH_KPMCORE4API) # kpmcore 4 with new API endif() + if( KPMcore_VERSION VERSION_GREATER_EQUAL "4.2" ) + list( APPEND _partition_defs WITH_KPMCORE42API) # kpmcore 4.2 with new API + endif() include_directories( ${KPMCORE_INCLUDE_DIR} ) include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui ) diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp index 5d4d8f3cd..e05f43d3d 100644 --- a/src/modules/partition/core/PartitionCoreModule.cpp +++ b/src/modules/partition/core/PartitionCoreModule.cpp @@ -834,6 +834,7 @@ PartitionCoreModule::initLayout() void PartitionCoreModule::initLayout( const QVariantList& config ) { + bool ok; QString sizeString; QString minSizeString; QString maxSizeString; @@ -884,6 +885,7 @@ PartitionCoreModule::initLayout( const QVariantList& config ) if ( !m_partLayout->addEntry( CalamaresUtils::getString( pentry, "name" ), CalamaresUtils::getString( pentry, "mountPoint" ), CalamaresUtils::getString( pentry, "filesystem" ), + CalamaresUtils::getSubMap( pentry, "features", ok ), sizeString, minSizeString, maxSizeString ) ) diff --git a/src/modules/partition/core/PartitionLayout.cpp b/src/modules/partition/core/PartitionLayout.cpp index 23332f3f5..4f1086d19 100644 --- a/src/modules/partition/core/PartitionLayout.cpp +++ b/src/modules/partition/core/PartitionLayout.cpp @@ -120,6 +120,7 @@ bool PartitionLayout::addEntry( const QString& label, const QString& mountPoint, const QString& fs, + const QVariantMap& features, const QString& size, const QString& min, const QString& max ) @@ -144,6 +145,7 @@ PartitionLayout::addEntry( const QString& label, { entry.partFileSystem = m_defaultFsType; } + entry.partFeatures = features; m_partLayout.append( entry ); @@ -239,6 +241,15 @@ PartitionLayout::execute( Device* dev, { currentPartition->fileSystem().setLabel( part.partLabel ); } + if ( !part.partFeatures.isEmpty() ) + { +#if defined( WITH_KPMCORE42API ) + for ( const auto& k : part.partFeatures.keys() ) + currentPartition->fileSystem().addFeature( k, part.partFeatures.value(k) ); +#else + cWarning() << "Ignoring features; requires KPMcore >= 4.2.0."; +#endif + } // Some buggy (legacy) BIOSes test if the bootflag of at least one partition is set. // Otherwise they ignore the device in boot-order, so add it here. partList.append( currentPartition ); diff --git a/src/modules/partition/core/PartitionLayout.h b/src/modules/partition/core/PartitionLayout.h index 50bb1ba43..3ec7f48ee 100644 --- a/src/modules/partition/core/PartitionLayout.h +++ b/src/modules/partition/core/PartitionLayout.h @@ -31,6 +31,7 @@ // Qt #include #include +#include class Partition; @@ -42,6 +43,7 @@ public: QString partLabel; QString partMountPoint; FileSystem::Type partFileSystem = FileSystem::Unknown; + QVariantMap partFeatures; CalamaresUtils::Partition::PartitionSize partSize; CalamaresUtils::Partition::PartitionSize partMinSize; CalamaresUtils::Partition::PartitionSize partMaxSize; @@ -75,6 +77,7 @@ public: bool addEntry( const QString& label, const QString& mountPoint, const QString& fs, + const QVariantMap& features, const QString& size, const QString& min = QString(), const QString& max = QString() ); diff --git a/src/modules/partition/partition.conf b/src/modules/partition/partition.conf index 6fbb44cb4..5b7d5ee60 100644 --- a/src/modules/partition/partition.conf +++ b/src/modules/partition/partition.conf @@ -106,9 +106,15 @@ defaultFileSystemType: "ext4" # mountPoint: "/home" # size: 3G # minSize: 1.5G +# features: +# 64bit: false +# casefold: true # - name: "data" # filesystem: "fat32" # mountPoint: "/data" +# features: +# sector-size: 4096 +# sectors-per-cluster: 128 # size: 100% # # There can be any number of partitions, each entry having the following attributes: @@ -120,6 +126,8 @@ defaultFileSystemType: "ext4" # % of the available drive space if a '%' is appended to the value # - minSize: minimum partition size (optional parameter) # - maxSize: maximum partition size (optional parameter) +# - features: filesystem features (optional parameter; requires KPMCore >= 4.2.0) +# name: boolean or integer or string # Checking for available storage #