[partition] Require modern KPMCore
This commit is contained in:
parent
49c56add7d
commit
aedb55ea36
@ -10,7 +10,7 @@
|
||||
if ( NOT KPMcore_searched_for )
|
||||
set( KPMcore_searched_for TRUE )
|
||||
|
||||
find_package( KPMcore 3.3 )
|
||||
find_package( KPMcore 21.12.0 )
|
||||
set_package_properties(
|
||||
KPMcore PROPERTIES
|
||||
URL "https://invent.kde.org/kde/kpmcore"
|
||||
@ -21,18 +21,6 @@ if ( NOT KPMcore_searched_for )
|
||||
|
||||
if( KPMcore_FOUND )
|
||||
set( KPMcore_API_DEFINITIONS "" )
|
||||
if( KPMcore_VERSION VERSION_GREATER "3.3.70" AND KPMcore_VERSION VERSION_LESS "4.0" )
|
||||
message( FATAL_ERROR "KPMCore beta versions ${KPMcore_VERSION} not supported" )
|
||||
endif()
|
||||
if ( KPMcore_VERSION VERSION_GREATER "3.3.0")
|
||||
list( APPEND KPMcore_API_DEFINITIONS WITH_KPMCORE331API) # kpmcore > 3.3.0 with deprecations
|
||||
endif()
|
||||
if ( KPMcore_VERSION VERSION_GREATER_EQUAL "4.0")
|
||||
list( APPEND KPMcore_API_DEFINITIONS WITH_KPMCORE4API) # kpmcore 4 with new API
|
||||
endif()
|
||||
if( KPMcore_VERSION VERSION_GREATER_EQUAL "4.2" )
|
||||
list( APPEND KPMcore_API_DEFINITIONS WITH_KPMCORE42API) # kpmcore 4.2 with new API
|
||||
endif()
|
||||
else()
|
||||
set( KPMcore_API_DEFINITIONS WITHOUT_KPMcore )
|
||||
endif()
|
||||
|
@ -17,13 +17,10 @@
|
||||
#define PARTITION_GLOBAL_H
|
||||
|
||||
#include "DllMacro.h"
|
||||
#include "FileSystem.h"
|
||||
#include "JobQueue.h"
|
||||
|
||||
#ifdef WITH_KPMCORE4API
|
||||
#include "FileSystem.h"
|
||||
|
||||
#include <kpmcore/fs/filesystem.h>
|
||||
#endif
|
||||
|
||||
namespace CalamaresUtils
|
||||
{
|
||||
@ -78,7 +75,6 @@ isFilesystemUsedGS( const QString& filesystemType )
|
||||
return isFilesystemUsedGS( Calamares::JobQueue::instanceGlobalStorage(), filesystemType );
|
||||
}
|
||||
|
||||
#ifdef WITH_KPMCORE4API
|
||||
/** @brief Mark a particular filesystem type as used (or not)
|
||||
*
|
||||
* See useFilesystemGS(const QString&, bool); this method uses the filesystem type
|
||||
@ -100,7 +96,6 @@ isFilesystemUsedGS( FileSystem::Type filesystem )
|
||||
return isFilesystemUsedGS( untranslatedFS( filesystem ) );
|
||||
}
|
||||
|
||||
#endif
|
||||
} // namespace Partition
|
||||
} // namespace CalamaresUtils
|
||||
|
||||
|
@ -14,10 +14,7 @@
|
||||
|
||||
#include <kpmcore/backend/corebackend.h>
|
||||
#include <kpmcore/backend/corebackendmanager.h>
|
||||
#if defined( WITH_KPMCORE4API )
|
||||
#include <kpmcore/util/externalcommand.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <QObject>
|
||||
|
||||
@ -30,7 +27,6 @@ class InternalManager
|
||||
{
|
||||
public:
|
||||
InternalManager();
|
||||
~InternalManager();
|
||||
};
|
||||
|
||||
static bool s_kpm_loaded = false;
|
||||
@ -69,22 +65,6 @@ InternalManager::InternalManager()
|
||||
}
|
||||
}
|
||||
|
||||
InternalManager::~InternalManager()
|
||||
{
|
||||
#if defined( WITH_KPMCORE4API ) && !defined( WITH_KPMCORE42API )
|
||||
cDebug() << "Cleaning up KPMCore backend ..";
|
||||
|
||||
// From KPMcore 4.0 until KPMcore 4.2 we needed to stop
|
||||
// the helper by hand. KPMcore 4.2 ported to polkit directly,
|
||||
// which doesn't need a helper.
|
||||
auto backend_p = CoreBackendManager::self()->backend();
|
||||
if ( backend_p )
|
||||
{
|
||||
ExternalCommand::stopHelper();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
std::shared_ptr< InternalManager >
|
||||
getInternal()
|
||||
{
|
||||
@ -102,9 +82,7 @@ KPMManager::KPMManager()
|
||||
{
|
||||
}
|
||||
|
||||
KPMManager::~KPMManager()
|
||||
{
|
||||
}
|
||||
KPMManager::~KPMManager() {}
|
||||
|
||||
KPMManager::operator bool() const
|
||||
{
|
||||
|
@ -57,18 +57,10 @@ KPMTests::testFlagNames()
|
||||
|
||||
QCOMPARE( PartitionTable::flagName( static_cast< PartitionTable::Flag >( 1 ) ), QStringLiteral( "boot" ) );
|
||||
|
||||
#ifdef WITH_KPMCORE4API
|
||||
// KPMCore 4 unifies the flags and handles them internally
|
||||
QCOMPARE( PartitionTable::flagName( PartitionTable::Flag::Boot ), QStringLiteral( "boot" ) );
|
||||
QVERIFY( names.contains( QStringLiteral( "boot" ) ) );
|
||||
QVERIFY( !names.contains( QStringLiteral( "esp" ) ) );
|
||||
#else
|
||||
// KPMCore 3 has separate flags
|
||||
QCOMPARE( PartitionTable::flagName( PartitionTable::FlagBoot ), QStringLiteral( "boot" ) );
|
||||
QCOMPARE( PartitionTable::flagName( PartitionTable::FlagEsp ), QStringLiteral( "esp" ) );
|
||||
QVERIFY( names.contains( QStringLiteral( "boot" ) ) );
|
||||
QVERIFY( names.contains( QStringLiteral( "esp" ) ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -50,12 +50,7 @@ isPartitionFreeSpace( const Partition* partition )
|
||||
bool
|
||||
isPartitionNew( const Partition* partition )
|
||||
{
|
||||
#if defined( WITH_KPMCORE4API )
|
||||
constexpr auto NewState = Partition::State::New;
|
||||
#else
|
||||
constexpr auto NewState = Partition::StateNew;
|
||||
#endif
|
||||
return partition->state() == NewState;
|
||||
return partition->state() == Partition::State::New;
|
||||
}
|
||||
|
||||
|
||||
|
@ -49,12 +49,8 @@ ResizeFSJob::PartitionMatch
|
||||
ResizeFSJob::findPartition()
|
||||
{
|
||||
using DeviceList = QList< Device* >;
|
||||
#if defined( WITH_KPMCORE4API )
|
||||
DeviceList devices
|
||||
= m_kpmcore.backend()->scanDevices( /* not includeReadOnly, not includeLoopback */ ScanFlag( 0 ) );
|
||||
#else
|
||||
DeviceList devices = m_kpmcore.backend()->scanDevices( /* excludeReadOnly */ true );
|
||||
#endif
|
||||
|
||||
cDebug() << "ResizeFSJob found" << devices.count() << "devices.";
|
||||
for ( DeviceList::iterator dev_it = devices.begin(); dev_it != devices.end(); ++dev_it )
|
||||
|
@ -508,11 +508,6 @@ PartitionViewStep::onLeave()
|
||||
{
|
||||
const QString espMountPoint
|
||||
= Calamares::JobQueue::instance()->globalStorage()->value( "efiSystemPartition" ).toString();
|
||||
#ifdef WITH_KPMCORE4API
|
||||
const auto espFlag = PartitionTable::Flag::Boot;
|
||||
#else
|
||||
const auto espFlag = PartitionTable::FlagEsp;
|
||||
#endif
|
||||
Partition* esp = m_core->findPartitionByMountPoint( espMountPoint );
|
||||
|
||||
QString message;
|
||||
@ -567,7 +562,7 @@ PartitionViewStep::onLeave()
|
||||
cDebug() << o << "ESP missing flag";
|
||||
description.append( ' ' );
|
||||
description.append( tr( "The filesystem must have flag <strong>%1</strong> set." )
|
||||
.arg( PartitionTable::flagName( espFlag ) ) );
|
||||
.arg( PartitionTable::flagName( PartitionTable::Flag::Boot ) ) );
|
||||
}
|
||||
if ( !description.isEmpty() )
|
||||
{
|
||||
|
@ -127,11 +127,7 @@ getDevices( DeviceType which )
|
||||
cWarning() << "No KPM backend found.";
|
||||
return {};
|
||||
}
|
||||
#if defined( WITH_KPMCORE4API )
|
||||
DeviceList devices = backend->scanDevices( /* not includeReadOnly, not includeLoopback */ ScanFlag( 0 ) );
|
||||
#else
|
||||
DeviceList devices = backend->scanDevices( /* excludeReadOnly */ true );
|
||||
#endif
|
||||
|
||||
/* The list of devices is cleaned up for use:
|
||||
* - some devices can **never** be used (e.g. floppies, nullptr)
|
||||
|
@ -27,15 +27,10 @@ class Partition;
|
||||
class PartitionNode;
|
||||
class PartitionRole;
|
||||
|
||||
#if defined( WITH_KPMCORE4API )
|
||||
// TODO:3.3: Remove defines, expand in-place
|
||||
#define KPM_PARTITION_FLAG( x ) PartitionTable::Flag::x
|
||||
#define KPM_PARTITION_STATE( x ) Partition::State::x
|
||||
#define KPM_PARTITION_FLAG_ESP PartitionTable::Flag::Boot
|
||||
#else
|
||||
#define KPM_PARTITION_FLAG( x ) PartitionTable::Flag##x
|
||||
#define KPM_PARTITION_STATE( x ) Partition::State##x
|
||||
#define KPM_PARTITION_FLAG_ESP PartitionTable::FlagEsp
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Helper functions to manipulate partitions
|
||||
|
@ -457,9 +457,7 @@ isEfiFilesystemSuitableType( const Partition* candidate )
|
||||
{
|
||||
case FileSystem::Type::Fat32:
|
||||
return true;
|
||||
#ifdef WITH_KPMCORE4API
|
||||
case FileSystem::Type::Fat12:
|
||||
#endif
|
||||
case FileSystem::Type::Fat16:
|
||||
cWarning() << "FAT12 and FAT16 are probably not supported by EFI";
|
||||
return false;
|
||||
@ -496,31 +494,9 @@ isEfiBootable( const Partition* candidate )
|
||||
{
|
||||
const auto flags = PartitionInfo::flags( candidate );
|
||||
|
||||
#if defined( WITH_KPMCORE4API )
|
||||
// In KPMCore4, the flags are remapped, and the ESP flag is the same as Boot.
|
||||
static_assert( KPM_PARTITION_FLAG_ESP == KPM_PARTITION_FLAG( Boot ), "KPMCore API enum changed" );
|
||||
return flags.testFlag( KPM_PARTITION_FLAG_ESP );
|
||||
#else
|
||||
// In KPMCore3, bit 17 is the old-style Esp flag, and it's OK
|
||||
if ( flags.testFlag( KPM_PARTITION_FLAG_ESP ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Otherwise, if it's a GPT table, Boot (bit 0) is the same as Esp */
|
||||
const PartitionTable* table = CalamaresUtils::Partition::getPartitionTable( candidate );
|
||||
if ( !table )
|
||||
{
|
||||
cWarning() << "Root of partition table is not a PartitionTable object";
|
||||
return false;
|
||||
}
|
||||
if ( table->type() == PartitionTable::TableType::gpt )
|
||||
{
|
||||
const auto bootFlag = KPM_PARTITION_FLAG( Boot );
|
||||
return flags.testFlag( bootFlag );
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
// TODO: this is configurable via the config file **already**
|
||||
|
@ -847,13 +847,8 @@ PartitionCoreModule::scanForLVMPVs()
|
||||
}
|
||||
}
|
||||
|
||||
#if defined( WITH_KPMCORE4API )
|
||||
VolumeManagerDevice::scanDevices( physicalDevices );
|
||||
for ( auto p : LVM::pvList::list() )
|
||||
#else
|
||||
LvmDevice::scanSystemLVM( physicalDevices );
|
||||
for ( auto p : LVM::pvList )
|
||||
#endif
|
||||
{
|
||||
m_lvmPVs << p.partition().data();
|
||||
|
||||
@ -890,7 +885,6 @@ PartitionCoreModule::scanForLVMPVs()
|
||||
m_lvmPVs << p;
|
||||
}
|
||||
}
|
||||
#if defined( WITH_KPMCORE4API )
|
||||
else if ( p->fileSystem().type() == FileSystem::Type::Luks2 )
|
||||
{
|
||||
// Encrypted LVM PVs
|
||||
@ -901,7 +895,6 @@ PartitionCoreModule::scanForLVMPVs()
|
||||
m_lvmPVs << p;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -154,11 +154,9 @@ PartitionLayout::setDefaultFsType( FileSystem::Type defaultFsType )
|
||||
case FileSystem::Lvm2_PV:
|
||||
case FileSystem::Udf:
|
||||
case FileSystem::Iso9660:
|
||||
#ifdef WITH_KPMCORE4API
|
||||
case FileSystem::Luks2:
|
||||
case FileSystem::LinuxRaidMember:
|
||||
case FileSystem::BitLocker:
|
||||
#endif
|
||||
// bad bad
|
||||
cWarning() << "The selected default FS" << defaultFsType << "is not suitable."
|
||||
<< "Using ext4 instead.";
|
||||
@ -185,11 +183,9 @@ PartitionLayout::setDefaultFsType( FileSystem::Type defaultFsType )
|
||||
case FileSystem::Hpfs:
|
||||
case FileSystem::Zfs:
|
||||
case FileSystem::Nilfs2:
|
||||
#ifdef WITH_KPMCORE4API
|
||||
case FileSystem::Fat12:
|
||||
case FileSystem::Apfs:
|
||||
case FileSystem::Minix:
|
||||
#endif
|
||||
// weird
|
||||
cWarning() << "The selected default FS" << defaultFsType << "is unusual, but not wrong.";
|
||||
break;
|
||||
@ -355,30 +351,18 @@ PartitionLayout::createPartitions( Device* dev,
|
||||
}
|
||||
if ( !entry.partType.isEmpty() )
|
||||
{
|
||||
#if defined( WITH_KPMCORE42API )
|
||||
part->setType( entry.partType );
|
||||
#else
|
||||
cWarning() << "Ignoring type; requires KPMcore >= 4.2.0.";
|
||||
#endif
|
||||
}
|
||||
if ( entry.partAttributes )
|
||||
{
|
||||
#if defined( WITH_KPMCORE42API )
|
||||
part->setAttributes( entry.partAttributes );
|
||||
#else
|
||||
cWarning() << "Ignoring attributes; requires KPMcore >= 4.2.0.";
|
||||
#endif
|
||||
}
|
||||
if ( !entry.partFeatures.isEmpty() )
|
||||
{
|
||||
#if defined( WITH_KPMCORE42API )
|
||||
for ( const auto& k : entry.partFeatures.keys() )
|
||||
{
|
||||
part->fileSystem().addFeature( k, entry.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.
|
||||
|
@ -42,9 +42,7 @@
|
||||
#include "widgets/PrettyRadioButton.h"
|
||||
|
||||
#include <kpmcore/core/device.h>
|
||||
#ifdef WITH_KPMCORE4API
|
||||
#include <kpmcore/core/softwareraid.h>
|
||||
#endif
|
||||
|
||||
#include <QBoxLayout>
|
||||
#include <QButtonGroup>
|
||||
@ -1344,14 +1342,12 @@ ChoicePage::setupActions()
|
||||
bool isInactiveRAID = false;
|
||||
bool matchTableType = false;
|
||||
|
||||
#ifdef WITH_KPMCORE4API
|
||||
if ( currentDevice->type() == Device::Type::SoftwareRAID_Device
|
||||
&& static_cast< SoftwareRAID* >( currentDevice )->status() == SoftwareRAID::Status::Inactive )
|
||||
{
|
||||
cDebug() << Logger::SubEntry << "part of an inactive RAID device";
|
||||
isInactiveRAID = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
PartitionTable::TableType tableType = PartitionTable::unknownTableType;
|
||||
if ( currentDevice->partitionTable() )
|
||||
|
@ -100,9 +100,7 @@ DeviceInfoWidget::retranslateUi()
|
||||
"that makes a file accessible as a block device. "
|
||||
"This kind of setup usually only contains a single filesystem." );
|
||||
break;
|
||||
#if defined( WITH_KPMCORE42API )
|
||||
case PartitionTable::none:
|
||||
#endif
|
||||
case PartitionTable::unknownTableType:
|
||||
typeString = " ? ";
|
||||
toolTipString = tr( "This installer <strong>cannot detect a partition table</strong> on the "
|
||||
|
@ -42,9 +42,7 @@
|
||||
// KPMcore
|
||||
#include <kpmcore/core/device.h>
|
||||
#include <kpmcore/core/partition.h>
|
||||
#ifdef WITH_KPMCORE4API
|
||||
#include <kpmcore/core/softwareraid.h>
|
||||
#endif
|
||||
#include <kpmcore/ops/deactivatevolumegroupoperation.h>
|
||||
#include <kpmcore/ops/removevolumegroupoperation.h>
|
||||
|
||||
@ -179,14 +177,12 @@ PartitionPage::updateButtons()
|
||||
{
|
||||
allow_create_table = true;
|
||||
|
||||
#ifdef WITH_KPMCORE4API
|
||||
if ( device->type() == Device::Type::SoftwareRAID_Device
|
||||
&& static_cast< SoftwareRAID* >( device )->status() == SoftwareRAID::Status::Inactive )
|
||||
{
|
||||
allow_create_table = false;
|
||||
allow_create = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -111,7 +111,6 @@ CreatePartitionJob::CreatePartitionJob( Device* device, Partition* partition )
|
||||
static QString
|
||||
prettyGptType( const Partition* partition )
|
||||
{
|
||||
#ifdef WITH_KPMCORE42API
|
||||
static const QMap< QString, QString > gptTypePrettyStrings = {
|
||||
{ "44479540-f297-41b2-9af7-d131d5f0458a", "Linux Root Partition (x86)" },
|
||||
{ "4f68bce3-e8cd-4db1-96e7-fbcaf984b709", "Linux Root Partition (x86-64)" },
|
||||
@ -146,9 +145,6 @@ prettyGptType( const Partition* partition )
|
||||
|
||||
auto type = partition->type();
|
||||
return gptTypePrettyStrings.value( type.toLower(), type );
|
||||
#else
|
||||
return QString();
|
||||
#endif
|
||||
}
|
||||
|
||||
static QString
|
||||
|
@ -88,11 +88,9 @@ mapForPartition( Partition* partition, const QString& uuid )
|
||||
map[ "mountPoint" ] = PartitionInfo::mountPoint( partition );
|
||||
map[ "fsName" ] = userVisibleFS( partition->fileSystem() );
|
||||
map[ "fs" ] = untranslatedFS( partition->fileSystem() );
|
||||
#ifdef WITH_KPMCORE42API
|
||||
map[ "parttype" ] = partition->type();
|
||||
map[ "partattrs" ] = partition->attributes();
|
||||
map[ "features" ] = partition->fileSystem().features();
|
||||
#endif
|
||||
if ( partition->fileSystem().type() == FileSystem::Luks
|
||||
&& dynamic_cast< FS::luks& >( partition->fileSystem() ).innerFS() )
|
||||
{
|
||||
|
@ -125,7 +125,6 @@ CreateLayoutsTests::testMixedSizePartition()
|
||||
QCOMPARE( partitions[ 2 ]->length(), ( ( 5_GiB - 5_MiB ) / 2 ) / LOGICAL_SIZE );
|
||||
}
|
||||
|
||||
#ifdef WITH_KPMCORE4API
|
||||
// TODO: Get a clean way to instantiate a test Device from KPMCore
|
||||
class DevicePrivate
|
||||
{
|
||||
@ -150,11 +149,5 @@ TestDevice::TestDevice( const QString& name, const qint64 logicalSectorSize, con
|
||||
Device::Type::Unknown_Device )
|
||||
{
|
||||
}
|
||||
#else
|
||||
TestDevice::TestDevice( const QString& name, const qint64 logicalSectorSize, const qint64 totalLogicalSectors )
|
||||
: Device( name, QString( "node" ), logicalSectorSize, totalLogicalSectors, QString(), Device::Type::Unknown_Device )
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
TestDevice::~TestDevice() {}
|
||||
|
@ -52,12 +52,7 @@ DevicesTests::testKPMScanDevices()
|
||||
cDebug() << "Getting devices via KPMCore";
|
||||
CoreBackend* backend = CoreBackendManager::self()->backend();
|
||||
QVERIFY( backend );
|
||||
#if defined( WITH_KPMCORE4API )
|
||||
auto flags = ScanFlag( ~0 );
|
||||
#else
|
||||
auto flags = true;
|
||||
#endif
|
||||
auto devices = backend->scanDevices( flags ); // These flags try to get "all"
|
||||
auto devices = backend->scanDevices( ScanFlag( ~0 ) ); // These flags try to get "all"
|
||||
cDebug() << Logger::SubEntry << "Done getting devices.";
|
||||
|
||||
if ( !m_isRoot )
|
||||
|
Loading…
Reference in New Issue
Block a user