diff --git a/src/modules/partition/core/DeviceList.cpp b/src/modules/partition/core/DeviceList.cpp index f51eec047..4a353efb4 100644 --- a/src/modules/partition/core/DeviceList.cpp +++ b/src/modules/partition/core/DeviceList.cpp @@ -113,32 +113,28 @@ QList< Device* > getDevices( DeviceType which, qint64 minimumSize ) // Remove the device which contains / from the list for ( DeviceList::iterator it = devices.begin(); it != devices.end(); ) - if ( !( *it ) ) - { - cDebug() << " .. Skipping nullptr device"; - it = erase( devices, it); - } - else if ( ( *it )->deviceNode().startsWith( "/dev/zram" ) + if ( ! ( *it ) || + ( *it )->deviceNode().startsWith( "/dev/zram" ) ) { cDebug() << " .. Removing zram" << it; - it = erase( devices, it ); + it = erase(devices, it ); } else if ( writableOnly && hasRootPartition( *it ) ) { cDebug() << " .. Removing device with root filesystem (/) on it" << it; - it = erase( devices, it ); + it = erase(devices, it ); } else if ( writableOnly && isIso9660( *it ) ) { cDebug() << " .. Removing device with iso9660 filesystem (probably a CD) on it" << it; - it = erase( devices, it ); + it = erase(devices, it ); } else if ( (minimumSize >= 0) && !( (*it)->capacity() > minimumSize ) ) { cDebug() << " .. Removing too-small" << it; - it = erase( devices, it ); + it = erase(devices, it ); } else ++it; diff --git a/src/modules/partition/core/KPMHelpers.h b/src/modules/partition/core/KPMHelpers.h index 0bcc533fb..c9d9a30f9 100644 --- a/src/modules/partition/core/KPMHelpers.h +++ b/src/modules/partition/core/KPMHelpers.h @@ -89,7 +89,7 @@ Partition* createNewPartition( PartitionNode* parent, FileSystem::Type fsType, qint64 firstSector, qint64 lastSector, - PartitionTable::Flags flags ); + PartitionTable::Flags flags = PartitionTable::FlagNone ); Partition* createNewEncryptedPartition( PartitionNode* parent, const Device& device, @@ -98,7 +98,7 @@ Partition* createNewEncryptedPartition( PartitionNode* parent, qint64 firstSector, qint64 lastSector, const QString& passphrase, - PartitionTable::Flags flags ); + PartitionTable::Flags flags = PartitionTable::FlagNone ); Partition* clonePartition( Device* device, Partition* partition ); diff --git a/src/modules/partition/core/OsproberEntry.h b/src/modules/partition/core/OsproberEntry.h index e8c7895f0..792f22b29 100644 --- a/src/modules/partition/core/OsproberEntry.h +++ b/src/modules/partition/core/OsproberEntry.h @@ -1,7 +1,6 @@ /* === This file is part of Calamares - === * * Copyright 2014-2016, Teo Mrnjavac - * Copyright 2018, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,18 +29,6 @@ struct FstabEntry QString options; int dump; int pass; - - /// Does this entry make sense and is it complete? - bool isValid() const; // implemented in Partutils.cpp - - /** @brief Create an entry from a live of /etc/fstab - * - * Splits the given string (which ought to follow the format - * of /etc/fstab) and returns a corresponding Fstab entry. - * If the string isn't valid (e.g. comment-line, or broken - * fstab entry) then the entry that is returned is invalid. - */ - static FstabEntry fromEtcFstab( const QString& ); // implemented in Partutils.cpp }; typedef QList< FstabEntry > FstabEntryList; diff --git a/src/modules/partition/core/PartUtils.cpp b/src/modules/partition/core/PartUtils.cpp index d61064041..f080d97a4 100644 --- a/src/modules/partition/core/PartUtils.cpp +++ b/src/modules/partition/core/PartUtils.cpp @@ -31,7 +31,6 @@ #include #include -#include #include #include #include @@ -80,47 +79,26 @@ bool canBeResized( Partition* candidate ) { if ( !candidate ) - { - cDebug() << "Partition* is NULL"; return false; - } - cDebug() << "Checking if" << candidate->partitionPath() << "can be resized."; if ( !candidate->fileSystem().supportGrow() || !candidate->fileSystem().supportShrink() ) - { - cDebug() << " .. filesystem" << candidate->fileSystem().name() - << "does not support resize."; return false; - } if ( KPMHelpers::isPartitionFreeSpace( candidate ) ) - { - cDebug() << " .. partition is free space"; return false; - } if ( candidate->isMounted() ) - { - cDebug() << " .. partition is mounted"; return false; - } if ( candidate->roles().has( PartitionRole::Primary ) ) { PartitionTable* table = dynamic_cast< PartitionTable* >( candidate->parent() ); if ( !table ) - { - cDebug() << " .. no partition table found"; return false; - } if ( table->numPrimaries() >= table->maxPrimaries() ) - { - cDebug() << " .. partition table already has" - << table->maxPrimaries() << "primary partitions."; return false; - } } bool ok = false; @@ -157,10 +135,11 @@ bool canBeResized( PartitionCoreModule* core, const QString& partitionPath ) { //FIXME: check for max partitions count on DOS MBR - cDebug() << "Checking if" << partitionPath << "can be resized."; + cDebug() << "checking if" << partitionPath << "can be resized."; QString partitionWithOs = partitionPath; if ( partitionWithOs.startsWith( "/dev/" ) ) { + cDebug() << partitionWithOs << "seems like a good path"; DeviceModel* dm = core->deviceModel(); for ( int i = 0; i < dm->rowCount(); ++i ) { @@ -168,11 +147,10 @@ canBeResized( PartitionCoreModule* core, const QString& partitionPath ) Partition* candidate = KPMHelpers::findPartitionByPath( { dev }, partitionWithOs ); if ( candidate ) { - cDebug() << " .. found Partition* for" << partitionWithOs; + cDebug() << "found Partition* for" << partitionWithOs; return canBeResized( candidate ); } } - cDebug() << " .. no Partition* found for" << partitionWithOs; } cDebug() << "Partition" << partitionWithOs << "CANNOT BE RESIZED FOR AUTOINSTALL."; @@ -183,55 +161,43 @@ canBeResized( PartitionCoreModule* core, const QString& partitionPath ) static FstabEntryList lookForFstabEntries( const QString& partitionPath ) { - QStringList mountOptions{ "ro" }; - - auto r = CalamaresUtils::System::runCommand( - CalamaresUtils::System::RunLocation::RunInHost, - { "blkid", "-s", "TYPE", "-o", "value", partitionPath } - ); - if ( r.getExitCode() ) - cWarning() << "blkid on" << partitionPath << "failed."; - else - { - QString fstype = r.getOutput().trimmed(); - if ( ( fstype == "ext3" ) || ( fstype == "ext4" ) ) - mountOptions.append( "noload" ); - } - - cDebug() << "Checking device" << partitionPath - << "for fstab (fs=" << r.getOutput() << ')'; - FstabEntryList fstabEntries; QTemporaryDir mountsDir; mountsDir.setAutoRemove( false ); - int exit = QProcess::execute( "mount", { "-o", mountOptions.join(','), partitionPath, mountsDir.path() } ); + int exit = QProcess::execute( "mount", { partitionPath, mountsDir.path() } ); if ( !exit ) // if all is well { QFile fstabFile( mountsDir.path() + "/etc/fstab" ); - - cDebug() << " .. reading" << fstabFile.fileName(); - if ( fstabFile.open( QIODevice::ReadOnly | QIODevice::Text ) ) { const QStringList fstabLines = QString::fromLocal8Bit( fstabFile.readAll() ) .split( '\n' ); for ( const QString& rawLine : fstabLines ) - fstabEntries.append( FstabEntry::fromEtcFstab( rawLine ) ); - fstabFile.close(); - cDebug() << " .. got" << fstabEntries.count() << "lines."; - std::remove_if( fstabEntries.begin(), fstabEntries.end(), [](const FstabEntry& x) { return !x.isValid(); } ); - cDebug() << " .. got" << fstabEntries.count() << "fstab entries."; - } - else - cWarning() << "Could not read fstab from mounted fs"; + { + QString line = rawLine.simplified(); + if ( line.startsWith( '#' ) ) + continue; - if ( QProcess::execute( "umount", { "-R", mountsDir.path() } ) ) - cWarning() << "Could not unmount" << mountsDir.path(); + QStringList splitLine = line.split( ' ' ); + if ( splitLine.length() != 6 ) + continue; + + fstabEntries.append( { splitLine.at( 0 ), // path, or UUID, or LABEL, etc. + splitLine.at( 1 ), // mount point + splitLine.at( 2 ), // fs type + splitLine.at( 3 ), // options + splitLine.at( 4 ).toInt(), //dump + splitLine.at( 5 ).toInt() //pass + } ); + } + + fstabFile.close(); + } + + QProcess::execute( "umount", { "-R", mountsDir.path() } ); } - else - cWarning() << "Could not mount existing fs"; return fstabEntries; } @@ -330,6 +296,7 @@ runOsprober( PartitionCoreModule* core ) osprober.readAllStandardOutput() ).trimmed() ); } + QString osProberReport( "Osprober lines, clean:\n" ); QStringList osproberCleanLines; OsproberEntryList osproberEntries; const auto lines = osproberOutput.split( '\n' ); @@ -361,11 +328,8 @@ runOsprober( PartitionCoreModule* core ) osproberCleanLines.append( line ); } } - - if ( osproberCleanLines.count() > 0 ) - cDebug() << "os-prober lines after cleanup:" << Logger::DebugList( osproberCleanLines ); - else - cDebug() << "os-prober gave no output."; + osProberReport.append( osproberCleanLines.join( '\n' ) ); + cDebug() << osProberReport; Calamares::JobQueue::instance()->globalStorage()->insert( "osproberLines", osproberCleanLines ); @@ -409,31 +373,3 @@ isEfiBootable( const Partition* candidate ) } } // nmamespace PartUtils - -/* Implementation of methods for FstabEntry, from OsproberEntry.h */ - -bool -FstabEntry::isValid() const -{ - return !partitionNode.isEmpty() && !mountPoint.isEmpty() && !fsType.isEmpty(); -} - -FstabEntry -FstabEntry::fromEtcFstab( const QString& rawLine ) -{ - QString line = rawLine.simplified(); - if ( line.startsWith( '#' ) ) - return FstabEntry{ QString(), QString(), QString(), QString(), 0, 0 }; - - QStringList splitLine = line.split( ' ' ); - if ( splitLine.length() != 6 ) - return FstabEntry{ QString(), QString(), QString(), QString(), 0, 0 }; - - return FstabEntry{ splitLine.at( 0 ), // path, or UUID, or LABEL, etc. - splitLine.at( 1 ), // mount point - splitLine.at( 2 ), // fs type - splitLine.at( 3 ), // options - splitLine.at( 4 ).toInt(), //dump - splitLine.at( 5 ).toInt() //pass - }; - } diff --git a/src/modules/partition/core/PartitionActions.cpp b/src/modules/partition/core/PartitionActions.cpp index a4f2baa17..d35345424 100644 --- a/src/modules/partition/core/PartitionActions.cpp +++ b/src/modules/partition/core/PartitionActions.cpp @@ -28,6 +28,7 @@ #include "utils/Units.h" #include "JobQueue.h" #include "utils/Logger.h" +#include "GlobalStorage.h" #include #include @@ -42,38 +43,58 @@ using CalamaresUtils::operator""_GiB; using CalamaresUtils::operator""_MiB; qint64 -swapSuggestion( const qint64 availableSpaceB, Choices::SwapChoice swap ) +swapSuggestion( const qint64 availableSpaceB ) { - if ( ( swap != Choices::SmallSwap ) && ( swap != Choices::FullSwap ) ) - return 0; - - // See partition.conf for explanation + /* If suspend-to-disk is demanded, then we always need enough + * swap to write the whole memory to disk -- between 2GB and 8GB + * RAM give proportionally more swap, and from 8GB RAM keep + * swap = RAM. + * + * If suspend-to-disk is not demanded, then ramp up more slowly, + * to 8GB swap at 16GB memory, and then drop to 4GB for "large + * memory" machines, on the assumption that those don't need swap + * because they have tons of memory (or whatever they are doing, + * had better not run into swap). + */ qint64 suggestedSwapSizeB = 0; auto memory = CalamaresUtils::System::instance()->getTotalMemoryB(); qint64 availableRamB = memory.first; qreal overestimationFactor = memory.second; - bool ensureSuspendToDisk = swap == Choices::FullSwap; + bool ensureSuspendToDisk = + Calamares::JobQueue::instance()->globalStorage()-> + value( "ensureSuspendToDisk" ).toBool(); - // Ramp up quickly to 8GiB, then follow memory size - if ( availableRamB <= 4_GiB ) - suggestedSwapSizeB = availableRamB * 2; - else if ( availableRamB <= 8_GiB ) - suggestedSwapSizeB = 8_GiB; - else - suggestedSwapSizeB = availableRamB; + if ( ensureSuspendToDisk ) + { + if ( availableRamB < 4_GiB ) + suggestedSwapSizeB = qMax( 2_GiB, availableRamB * 2 ); + else if ( availableRamB >= 4_GiB && availableRamB < 8_GiB ) + suggestedSwapSizeB = 8_GiB; + else + suggestedSwapSizeB = availableRamB; - // .. top out at 8GiB if we don't care about suspend - if ( !ensureSuspendToDisk ) - suggestedSwapSizeB = qMin( 8_GiB, suggestedSwapSizeB ); + suggestedSwapSizeB *= overestimationFactor; + } + else //if we don't care about suspend to disk + { + if ( availableRamB < 2_GiB ) + suggestedSwapSizeB = qMax( 2_GiB, availableRamB * 2 ); + else if ( availableRamB >= 2_GiB && availableRamB < 8_GiB ) + suggestedSwapSizeB = availableRamB; + else if ( availableRamB >= 8_GiB && availableRamB < 16_GiB ) + suggestedSwapSizeB = 8_GiB; + else + suggestedSwapSizeB = 4_GiB; + suggestedSwapSizeB *= overestimationFactor; - // Allow for a fudge factor - suggestedSwapSizeB *= overestimationFactor; - - // don't use more than 10% of available space - if ( !ensureSuspendToDisk ) - suggestedSwapSizeB = qMin( suggestedSwapSizeB, qint64( 0.10 * availableSpaceB ) ); + // don't use more than 10% of available space + qreal maxSwapDiskRatio = 0.10; + qint64 maxSwapSizeB = availableSpaceB * maxSwapDiskRatio; + if ( suggestedSwapSizeB > maxSwapSizeB ) + suggestedSwapSizeB = maxSwapSizeB; + } cDebug() << "Suggested swap size:" << suggestedSwapSizeB / 1024. / 1024. / 1024. << "GiB"; @@ -83,7 +104,10 @@ swapSuggestion( const qint64 availableSpaceB, Choices::SwapChoice swap ) constexpr qint64 alignBytesToBlockSize( qint64 bytes, qint64 blocksize ) { + Q_ASSERT( bytes >= 0 ); + Q_ASSERT( blocksize > 0 ); qint64 blocks = bytes / blocksize; + Q_ASSERT( blocks >= 0 ); if ( blocks * blocksize != bytes ) ++blocks; @@ -97,29 +121,31 @@ bytesToSectors( qint64 bytes, qint64 blocksize ) } void -doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionOptions o ) +doAutopartition( PartitionCoreModule* core, Device* dev, const QString& luksPassphrase ) { - QString defaultFsType = o.defaultFsType; - if ( FileSystem::typeForName( defaultFsType ) == FileSystem::Unknown ) - defaultFsType = "ext4"; + Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); bool isEfi = PartUtils::isEfiSystem(); + QString defaultFsType = gs->value( "defaultFileSystemType" ).toString(); + if ( FileSystem::typeForName( defaultFsType ) == FileSystem::Unknown ) + defaultFsType = "ext4"; + // Partition sizes are expressed in MiB, should be multiples of // the logical sector size (usually 512B). EFI starts with 2MiB // empty and a 300MiB EFI boot partition, while BIOS starts at // the 1MiB boundary (usually sector 2048). - int uefisys_part_sizeB = isEfi ? 300_MiB : 0_MiB; - int empty_space_sizeB = isEfi ? 2_MiB : 1_MiB; + int uefisys_part_size = isEfi ? 300 : 0; + int empty_space_size = isEfi ? 2 : 1; // Since sectors count from 0, if the space is 2048 sectors in size, // the first free sector has number 2048 (and there are 2048 sectors // before that one, numbered 0..2047). - qint64 firstFreeSector = bytesToSectors( empty_space_sizeB, dev->logicalSize() ); + qint64 firstFreeSector = bytesToSectors( MiBtoBytes(empty_space_size), dev->logicalSize() ); if ( isEfi ) { - qint64 efiSectorCount = bytesToSectors( uefisys_part_sizeB, dev->logicalSize() ); + qint64 efiSectorCount = bytesToSectors( MiBtoBytes(uefisys_part_size), dev->logicalSize() ); Q_ASSERT( efiSectorCount > 0 ); // Since sectors count from 0, and this partition is created starting @@ -137,7 +163,8 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO PartitionTable::FlagNone ); PartitionInfo::setFormat( efiPartition, true ); - PartitionInfo::setMountPoint( efiPartition, o.efiPartitionMountPoint ); + PartitionInfo::setMountPoint( efiPartition, gs->value( "efiSystemPartition" ) + .toString() ); core->createPartition( dev, efiPartition, PartitionTable::FlagEsp ); firstFreeSector = lastSector + 1; } @@ -146,18 +173,20 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO core->createPartitionTable( dev, PartitionTable::msdos ); } - const bool mayCreateSwap = ( o.swap == Choices::SmallSwap ) || ( o.swap == Choices::FullSwap ); + const bool mayCreateSwap = !gs->value( "neverCreateSwap" ).toBool(); bool shouldCreateSwap = false; qint64 suggestedSwapSizeB = 0; if ( mayCreateSwap ) { qint64 availableSpaceB = ( dev->totalLogical() - firstFreeSector ) * dev->logicalSize(); - suggestedSwapSizeB = swapSuggestion( availableSpaceB, o.swap ); + suggestedSwapSizeB = swapSuggestion( availableSpaceB ); // Space required by this installation is what the distro claims is needed // (via global configuration) plus the swap size plus a fudge factor of // 0.6GiB (this was 2.1GiB up to Calamares 3.2.2). - qint64 requiredSpaceB = o.requiredSpaceB + 600_MiB + suggestedSwapSizeB; + qint64 requiredSpaceB = + GiBtoBytes( gs->value( "requiredStorageGB" ).toDouble() + 0.6 ) + + suggestedSwapSizeB; // If there is enough room for ESP + root + swap, create swap, otherwise don't. shouldCreateSwap = availableSpaceB > requiredSpaceB; @@ -170,7 +199,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO } Partition* rootPartition = nullptr; - if ( o.luksPassphrase.isEmpty() ) + if ( luksPassphrase.isEmpty() ) { rootPartition = KPMHelpers::createNewPartition( dev->partitionTable(), @@ -178,8 +207,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO PartitionRole( PartitionRole::Primary ), FileSystem::typeForName( defaultFsType ), firstFreeSector, - lastSectorForRoot, - PartitionTable::FlagNone + lastSectorForRoot ); } else @@ -191,22 +219,17 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO FileSystem::typeForName( defaultFsType ), firstFreeSector, lastSectorForRoot, - o.luksPassphrase, - PartitionTable::FlagNone + luksPassphrase ); } PartitionInfo::setFormat( rootPartition, true ); PartitionInfo::setMountPoint( rootPartition, "/" ); - // 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. - core->createPartition( dev, rootPartition, - rootPartition->activeFlags() | ( isEfi ? PartitionTable::FlagNone : PartitionTable::FlagBoot ) - ); + core->createPartition( dev, rootPartition ); if ( shouldCreateSwap ) { Partition* swapPartition = nullptr; - if ( o.luksPassphrase.isEmpty() ) + if ( luksPassphrase.isEmpty() ) { swapPartition = KPMHelpers::createNewPartition( dev->partitionTable(), @@ -214,8 +237,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO PartitionRole( PartitionRole::Primary ), FileSystem::LinuxSwap, lastSectorForRoot + 1, - dev->totalLogical() - 1, - PartitionTable::FlagNone + dev->totalLogical() - 1 ); } else @@ -227,8 +249,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO FileSystem::LinuxSwap, lastSectorForRoot + 1, dev->totalLogical() - 1, - o.luksPassphrase, - PartitionTable::FlagNone + luksPassphrase ); } PartitionInfo::setFormat( swapPartition, true ); @@ -243,11 +264,13 @@ void doReplacePartition( PartitionCoreModule* core, Device* dev, Partition* partition, - Choices::ReplacePartitionOptions o ) + const QString& luksPassphrase ) { cDebug() << "doReplacePartition for device" << partition->partitionPath(); - QString defaultFsType = o.defaultFsType; + QString defaultFsType = Calamares::JobQueue::instance()-> + globalStorage()-> + value( "defaultFileSystemType" ).toString(); if ( FileSystem::typeForName( defaultFsType ) == FileSystem::Unknown ) defaultFsType = "ext4"; @@ -268,7 +291,7 @@ doReplacePartition( PartitionCoreModule* core, } Partition* newPartition = nullptr; - if ( o.luksPassphrase.isEmpty() ) + if ( luksPassphrase.isEmpty() ) { newPartition = KPMHelpers::createNewPartition( partition->parent(), @@ -276,8 +299,7 @@ doReplacePartition( PartitionCoreModule* core, newRoles, FileSystem::typeForName( defaultFsType ), partition->firstSector(), - partition->lastSector(), - PartitionTable::FlagNone + partition->lastSector() ); } else @@ -289,8 +311,7 @@ doReplacePartition( PartitionCoreModule* core, FileSystem::typeForName( defaultFsType ), partition->firstSector(), partition->lastSector(), - o.luksPassphrase, - PartitionTable::FlagNone + luksPassphrase ); } PartitionInfo::setMountPoint( newPartition, "/" ); diff --git a/src/modules/partition/core/PartitionActions.h b/src/modules/partition/core/PartitionActions.h index 5acf444fa..bb624552f 100644 --- a/src/modules/partition/core/PartitionActions.h +++ b/src/modules/partition/core/PartitionActions.h @@ -27,74 +27,29 @@ class Partition; namespace PartitionActions { -/** @brief Namespace for enums - * - * This namespace houses non-class enums..... - */ -namespace Choices -{ - /** @brief Ccchoice of swap (size and type) */ - enum SwapChoice - { - NoSwap, // don't create any swap, don't use any - ReuseSwap, // don't create, but do use existing - SmallSwap, // up to 8GiB of swap - FullSwap, // ensureSuspendToDisk -- at least RAM size - SwapFile // use a file (if supported) - }; - - struct ReplacePartitionOptions - { - QString defaultFsType; // e.g. "ext4" or "btrfs" - QString luksPassphrase; // optional - - ReplacePartitionOptions( const QString& fs, const QString& luks ) - : defaultFsType( fs ) - , luksPassphrase( luks ) - { - } - }; - - struct AutoPartitionOptions : ReplacePartitionOptions - { - QString efiPartitionMountPoint; // optional, e.g. "/boot" - quint64 requiredSpaceB; // estimated required space for root partition - SwapChoice swap; - - AutoPartitionOptions( const QString& fs, const QString& luks, const QString& efi, qint64 r, SwapChoice s ) - : ReplacePartitionOptions( fs, luks ) - , efiPartitionMountPoint( efi ) - , requiredSpaceB( r > 0 ? r : 0 ) - , swap( s ) - { - } - }; - -} // namespace Choices /** * @brief doAutopartition sets up an autopartitioning operation on the given Device. * @param core a pointer to the PartitionCoreModule instance. * @param dev the device to wipe. - * @param options settings for autopartitioning. + * @param luksPassphrase the passphrase for LUKS encryption (optional, default is empty). */ void doAutopartition( PartitionCoreModule* core, Device* dev, - Choices::AutoPartitionOptions options ); + const QString& luksPassphrase = QString() ); /** * @brief doReplacePartition sets up replace-partitioning with the given partition. * @param core a pointer to the PartitionCoreModule instance. * @param dev a pointer to the Device on which to replace a partition. * @param partition a pointer to the Partition to be replaced. - * @param options settings for partitioning (not all fields apply) - * + * @param luksPassphrase the passphrase for LUKS encryption (optional, default is empty). * @note this function also takes care of requesting PCM to delete the partition. */ void doReplacePartition( PartitionCoreModule* core, Device* dev, Partition* partition, - Choices::ReplacePartitionOptions options ); -} // namespace PartitionActions + const QString& luksPassphrase = QString() ); +} #endif // PARTITIONACTIONS_H diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp index f41142b6a..b8011f066 100644 --- a/src/modules/partition/core/PartitionCoreModule.cpp +++ b/src/modules/partition/core/PartitionCoreModule.cpp @@ -509,8 +509,17 @@ 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 ) ); + + QStringList jobsDebug; + foreach ( auto job, lst ) + jobsDebug.append( job->prettyName() ); + + cDebug() << "PartitionCodeModule has been asked for jobs. About to return:" + << jobsDebug.join( "\n" ); + return lst; } diff --git a/src/modules/partition/core/PartitionCoreModule.h b/src/modules/partition/core/PartitionCoreModule.h index 15dadc7f5..704fff322 100644 --- a/src/modules/partition/core/PartitionCoreModule.h +++ b/src/modules/partition/core/PartitionCoreModule.h @@ -128,12 +128,6 @@ public: void createPartitionTable( Device* device, PartitionTable::TableType type ); - /** - * @brief Add a job to do the actual partition-creation. - * - * If @p flags is not FlagNone, then the given flags are - * applied to the newly-created partition. - */ void createPartition( Device* device, Partition* partition, PartitionTable::Flags flags = PartitionTable::FlagNone ); diff --git a/src/modules/partition/core/PartitionIterator.cpp b/src/modules/partition/core/PartitionIterator.cpp index 8301835c6..5ed48fd91 100644 --- a/src/modules/partition/core/PartitionIterator.cpp +++ b/src/modules/partition/core/PartitionIterator.cpp @@ -18,7 +18,7 @@ * along with Calamares. If not, see . */ -#include "PartitionIterator.h" +#include // KPMcore #include diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index 3aeb4d258..bef6e4966 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -2,7 +2,6 @@ * * Copyright 2014-2017, Teo Mrnjavac * Copyright 2017-2018, Adriaan de Groot - * Copyright 2019, Collabora Ltd * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,39 +20,34 @@ #include "ChoicePage.h" #include "core/BootLoaderModel.h" -#include "core/DeviceModel.h" -#include "core/KPMHelpers.h" -#include "core/OsproberEntry.h" -#include "core/PartUtils.h" #include "core/PartitionActions.h" #include "core/PartitionCoreModule.h" -#include "core/PartitionInfo.h" -#include "core/PartitionIterator.h" +#include "core/DeviceModel.h" #include "core/PartitionModel.h" +#include "core/OsproberEntry.h" +#include "core/PartUtils.h" +#include "core/PartitionIterator.h" -#include "BootInfoWidget.h" -#include "DeviceInfoWidget.h" +#include "ReplaceWidget.h" +#include "PrettyRadioButton.h" #include "PartitionBarsView.h" #include "PartitionLabelsView.h" #include "PartitionSplitterWidget.h" -#include "PrettyRadioButton.h" -#include "ReplaceWidget.h" +#include "BootInfoWidget.h" +#include "DeviceInfoWidget.h" #include "ScanningDialog.h" #include "utils/CalamaresUtilsGui.h" #include "utils/Logger.h" #include "utils/Retranslator.h" -#include "utils/Units.h" - #include "Branding.h" -#include "GlobalStorage.h" +#include "core/KPMHelpers.h" #include "JobQueue.h" +#include "GlobalStorage.h" +#include "core/PartitionInfo.h" #include #include -#ifdef WITH_KPMCOREGT33 -#include -#endif #include #include @@ -64,7 +58,7 @@ #include #include -using PartitionActions::Choices::SwapChoice; + /** * @brief ChoicePage::ChoicePage is the default constructor. Called on startup as part of @@ -84,9 +78,6 @@ ChoicePage::ChoicePage( QWidget* parent ) , m_eraseButton( nullptr ) , m_replaceButton( nullptr ) , m_somethingElseButton( nullptr ) - , m_eraseSwapChoices( nullptr ) - , m_replaceSwapChoices( nullptr ) - , m_alongsideSwapChoices( nullptr ) , m_deviceInfoWidget( nullptr ) , m_beforePartitionBarsView( nullptr ) , m_beforePartitionLabelsView( nullptr ) @@ -182,19 +173,6 @@ ChoicePage::init( PartitionCoreModule* core ) } -/** @brief Creates a combobox with the given choices in it. - * - * No texts are set -- that happens later by the translator functions. - */ -static inline QComboBox* -createCombo( std::initializer_list< SwapChoice > l ) -{ - QComboBox* box = new QComboBox; - for ( SwapChoice c : l ) - box->addItem( QString(), c ); - return box; -} - /** * @brief ChoicePage::setupChoices creates PrettyRadioButton objects for the action * choices. @@ -248,19 +226,6 @@ ChoicePage::setupChoices() iconSize ) ); m_grp->addButton( m_replaceButton->buttonWidget(), Replace ); - // Fill up swap options - // .. TODO: only if enabled in the config - m_eraseSwapChoices = createCombo( { SwapChoice::NoSwap, SwapChoice::SmallSwap, SwapChoice::FullSwap } ); - m_eraseButton->addOptionsComboBox( m_eraseSwapChoices ); - -#if 0 - m_replaceSwapChoices = createCombo( { SwapChoice::NoSwap, SwapChoice::ReuseSwap, SwapChoice::SmallSwap, SwapChoice::FullSwap } ); - m_replaceButton->addOptionsComboBox( m_replaceSwapChoices ); - - m_alongsideSwapChoices = createCombo( { SwapChoice::NoSwap, SwapChoice::ReuseSwap, SwapChoice::SmallSwap, SwapChoice::FullSwap } ); - m_alongsideButton->addOptionsComboBox( m_alongsideSwapChoices ); -#endif - m_itemsLayout->addWidget( m_alongsideButton ); m_itemsLayout->addWidget( m_replaceButton ); m_itemsLayout->addWidget( m_eraseButton ); @@ -284,7 +249,7 @@ ChoicePage::setupChoices() { if ( checked ) // An action was picked. { - m_choice = static_cast< InstallChoice >( id ); + m_choice = static_cast< Choice >( id ); updateNextEnabled(); emit actionChosen(); @@ -314,12 +279,6 @@ ChoicePage::setupChoices() applyActionChoice( currentChoice() ); } } ); - - CALAMARES_RETRANSLATE( - updateSwapChoicesTr( m_eraseSwapChoices ); - updateSwapChoicesTr( m_alongsideSwapChoices ); - updateSwapChoicesTr( m_replaceSwapChoices ); - ) } @@ -414,7 +373,7 @@ ChoicePage::continueApplyDeviceChoice() void -ChoicePage::applyActionChoice( ChoicePage::InstallChoice choice ) +ChoicePage::applyActionChoice( ChoicePage::Choice choice ) { m_beforePartitionBarsView->selectionModel()-> disconnect( SIGNAL( currentRowChanged( QModelIndex, QModelIndex ) ) ); @@ -424,37 +383,30 @@ ChoicePage::applyActionChoice( ChoicePage::InstallChoice choice ) switch ( choice ) { case Erase: + if ( m_core->isDirty() ) { - auto gs = Calamares::JobQueue::instance()->globalStorage(); - - PartitionActions::Choices::AutoPartitionOptions options { - gs->value( "defaultFileSystemType" ).toString(), - m_encryptWidget->passphrase(), - gs->value( "efiSystemPartition" ).toString(), - CalamaresUtils::GiBtoBytes( gs->value( "requiredStorageGB" ).toDouble() ), - static_cast( m_eraseSwapChoices->currentData().toInt() ) - }; - - if ( m_core->isDirty() ) + ScanningDialog::run( QtConcurrent::run( [ = ] { - ScanningDialog::run( QtConcurrent::run( [ = ] - { - QMutexLocker locker( &m_coreMutex ); - m_core->revertDevice( selectedDevice() ); - } ), - [ = ] - { - PartitionActions::doAutopartition( m_core, selectedDevice(), options ); - emit deviceChosen(); - }, - this ); - } - else + QMutexLocker locker( &m_coreMutex ); + m_core->revertDevice( selectedDevice() ); + } ), + [ = ] { - PartitionActions::doAutopartition( m_core, selectedDevice(), options ); + PartitionActions::doAutopartition( m_core, + selectedDevice(), + m_encryptWidget->passphrase() ); emit deviceChosen(); - } + }, + this ); } + else + { + PartitionActions::doAutopartition( m_core, + selectedDevice(), + m_encryptWidget->passphrase() ); + emit deviceChosen(); + } + break; case Replace: if ( m_core->isDirty() ) @@ -532,7 +484,6 @@ ChoicePage::doAlongsideSetupSplitter( const QModelIndex& current, ->value( "requiredStorageGB" ) .toDouble(); - // TODO: make this consistent qint64 requiredStorageB = qRound64( requiredStorageGB + 0.1 + 2.0 ) * 1024 * 1024 * 1024; m_afterPartitionSplitterWidget->setSplitPartition( @@ -681,8 +632,7 @@ ChoicePage::doAlongsideApply() candidate->roles(), FileSystem::typeForName( m_defaultFsType ), newLastSector + 2, // * - oldLastSector, - PartitionTable::FlagNone + oldLastSector ); } else @@ -694,8 +644,7 @@ ChoicePage::doAlongsideApply() FileSystem::typeForName( m_defaultFsType ), newLastSector + 2, // * oldLastSector, - luksPassphrase, - PartitionTable::FlagNone + luksPassphrase ); } PartitionInfo::setMountPoint( newPartition, "/" ); @@ -783,9 +732,7 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current ) FileSystem::typeForName( m_defaultFsType ), selectedPartition->firstSector(), selectedPartition->lastSector(), - m_encryptWidget->passphrase(), - PartitionTable::FlagNone - ); + m_encryptWidget->passphrase() ); } else { @@ -795,9 +742,7 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current ) newRoles, FileSystem::typeForName( m_defaultFsType ), selectedPartition->firstSector(), - selectedPartition->lastSector(), - PartitionTable::FlagNone - ); + selectedPartition->lastSector() ); } PartitionInfo::setMountPoint( newPartition, "/" ); @@ -823,19 +768,14 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current ) if ( homePartitionPath->isEmpty() ) doReuseHomePartition = false; - Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); - - PartitionActions::doReplacePartition( - m_core, - selectedDevice(), - selectedPartition, - { - gs->value( "defaultFileSystemType" ).toString(), - m_encryptWidget->passphrase() - } ); + PartitionActions::doReplacePartition( m_core, + selectedDevice(), + selectedPartition, + m_encryptWidget->passphrase() ); Partition* homePartition = KPMHelpers::findPartitionByPath( { selectedDevice() }, *homePartitionPath ); + Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); if ( homePartition && doReuseHomePartition ) { PartitionInfo::setMountPoint( homePartition, "/home" ); @@ -948,7 +888,7 @@ ChoicePage::updateDeviceStatePreview() * @param choice the chosen partitioning action. */ void -ChoicePage::updateActionChoicePreview( ChoicePage::InstallChoice choice ) +ChoicePage::updateActionChoicePreview( ChoicePage::Choice choice ) { Device* currentDevice = selectedDevice(); Q_ASSERT( currentDevice ); @@ -1218,13 +1158,6 @@ force_uncheck(QButtonGroup* grp, PrettyRadioButton* button) grp->setExclusive( true ); } -static inline QDebug& -operator <<( QDebug& s, PartitionIterator& it ) -{ - s << ( ( *it ) ? ( *it )->deviceNode() : QString( "" ) ); - return s; -} - /** * @brief ChoicePage::setupActions happens every time a new Device* is selected in the * device picker. Sets up the text and visibility of the partitioning actions based @@ -1238,9 +1171,6 @@ ChoicePage::setupActions() OsproberEntryList osproberEntriesForCurrentDevice = getOsproberEntriesForDevice( currentDevice ); - cDebug() << "Setting up actions for" << currentDevice->deviceNode() - << "with" << osproberEntriesForCurrentDevice.count() << "entries."; - if ( currentDevice->partitionTable() ) m_deviceInfoWidget->setPartitionTableType( currentDevice->partitionTable()->type() ); else @@ -1252,35 +1182,16 @@ ChoicePage::setupActions() bool atLeastOneCanBeResized = false; bool atLeastOneCanBeReplaced = false; bool atLeastOneIsMounted = false; // Suppress 'erase' if so - bool isInactiveRAID = false; - -#ifdef WITH_KPMCOREGT33 - if ( currentDevice->type() == Device::Type::SoftwareRAID_Device && - static_cast< SoftwareRAID* >(currentDevice)->status() == SoftwareRAID::Status::Inactive ) - { - cDebug() << ".. part of an inactive RAID device"; - isInactiveRAID = true; - } -#endif for ( auto it = PartitionIterator::begin( currentDevice ); it != PartitionIterator::end( currentDevice ); ++it ) { if ( PartUtils::canBeResized( *it ) ) - { - cDebug() << ".. contains resizable" << it; atLeastOneCanBeResized = true; - } if ( PartUtils::canBeReplaced( *it ) ) - { - cDebug() << ".. contains replacable" << it; atLeastOneCanBeReplaced = true; - } if ( (*it)->isMounted() ) - { - cDebug() << ".. contains mounted" << it; atLeastOneIsMounted = true; - } } if ( osproberEntriesForCurrentDevice.count() == 0 ) @@ -1394,15 +1305,10 @@ ChoicePage::setupActions() else force_uncheck( m_grp, m_alongsideButton ); - if ( !atLeastOneIsMounted && !isInactiveRAID ) + if ( !atLeastOneIsMounted ) m_eraseButton->show(); // None mounted else - { - cDebug() << "Erase button suppressed" - << "mount?" << atLeastOneIsMounted - << "raid?" << isInactiveRAID; force_uncheck( m_grp, m_eraseButton ); - } bool isEfi = PartUtils::isEfiSystem(); bool efiSystemPartitionFound = !m_core->efiSystemPartitions().isEmpty(); @@ -1437,7 +1343,7 @@ ChoicePage::isNextEnabled() const } -ChoicePage::InstallChoice +ChoicePage::Choice ChoicePage::currentChoice() const { return m_choice; @@ -1485,55 +1391,3 @@ ChoicePage::updateNextEnabled() emit nextStatusChanged( enabled ); } -void -ChoicePage::updateSwapChoicesTr(QComboBox* box) -{ - if ( !box ) - return; - - static_assert(SwapChoice::NoSwap == 0, "Enum values out-of-sync"); - for ( int index = 0; index < box->count(); ++index ) - { - bool ok = false; - int value = 0; - - switch ( value = box->itemData( index ).toInt( &ok ) ) - { - // case 0: - case SwapChoice::NoSwap: - // toInt() returns 0 on failure, so check for ok - if ( ok ) // It was explicitly set to 0 - box->setItemText( index, tr( "No Swap" ) ); - else - cWarning() << "Box item" << index << box->itemText( index ) << "has non-integer role."; - break; - case SwapChoice::ReuseSwap: - box->setItemText( index, tr( "Reuse Swap" ) ); - break; - case SwapChoice::SmallSwap: - box->setItemText( index, tr( "Swap (no Hibernate)" ) ); - break; - case SwapChoice::FullSwap: - box->setItemText( index, tr( "Swap (with Hibernate)" ) ); - break; - case SwapChoice::SwapFile: - box->setItemText( index, tr( "Swap to file" ) ); - break; - default: - cWarning() << "Box item" << index << box->itemText( index ) << "has role" << value; - } - } -} - -int -ChoicePage::lastSelectedDeviceIndex() -{ - return m_lastSelectedDeviceIndex; -} - -void -ChoicePage::setLastSelectedDeviceIndex( int index ) -{ - m_lastSelectedDeviceIndex = index; - m_drivesCombo->setCurrentIndex( m_lastSelectedDeviceIndex ); -} diff --git a/src/modules/partition/gui/ChoicePage.h b/src/modules/partition/gui/ChoicePage.h index a53f3fff1..c36747e93 100644 --- a/src/modules/partition/gui/ChoicePage.h +++ b/src/modules/partition/gui/ChoicePage.h @@ -2,7 +2,6 @@ * * Copyright 2014-2016, Teo Mrnjavac * Copyright 2018, Adriaan de Groot - * Copyright 2019, Collabora Ltd * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -54,7 +53,7 @@ class ChoicePage : public QWidget, private Ui::ChoicePage { Q_OBJECT public: - enum InstallChoice + enum Choice { NoChoice, Alongside, @@ -85,7 +84,7 @@ public: * currently selected partitioning mode (with a PrettyRadioButton). * @return the enum Choice value. */ - InstallChoice currentChoice() const; + Choice currentChoice() const; /** * @brief onLeave runs when control passes from this page to another one. @@ -96,10 +95,7 @@ public: * @brief applyActionChoice reacts to a choice of partitioning mode. * @param choice the partitioning action choice. */ - void applyActionChoice( ChoicePage::InstallChoice choice ); - - int lastSelectedDeviceIndex(); - void setLastSelectedDeviceIndex( int index ); + void applyActionChoice( ChoicePage::Choice choice ); signals: void nextStatusChanged( bool ); @@ -125,21 +121,18 @@ private: void continueApplyDeviceChoice(); // .. called after scan void updateDeviceStatePreview(); - void updateActionChoicePreview( ChoicePage::InstallChoice choice ); + void updateActionChoicePreview( ChoicePage::Choice choice ); void setupActions(); OsproberEntryList getOsproberEntriesForDevice( Device* device ) const; void doAlongsideApply(); void setupEfiSystemPartitionSelector(); - // Translations support - void updateSwapChoicesTr( QComboBox* box ); - bool m_nextEnabled; PartitionCoreModule* m_core; QMutex m_previewsMutex; - InstallChoice m_choice; + Choice m_choice; bool m_isEfi; QComboBox* m_drivesCombo; @@ -149,9 +142,6 @@ private: PrettyRadioButton* m_eraseButton; PrettyRadioButton* m_replaceButton; PrettyRadioButton* m_somethingElseButton; - QComboBox* m_eraseSwapChoices; - QComboBox* m_replaceSwapChoices; - QComboBox* m_alongsideSwapChoices; DeviceInfoWidget* m_deviceInfoWidget; diff --git a/src/modules/partition/gui/CreatePartitionDialog.cpp b/src/modules/partition/gui/CreatePartitionDialog.cpp index 7823d743d..0e7602c08 100644 --- a/src/modules/partition/gui/CreatePartitionDialog.cpp +++ b/src/modules/partition/gui/CreatePartitionDialog.cpp @@ -72,7 +72,7 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* par m_ui->encryptWidget->setText( tr( "En&crypt" ) ); m_ui->encryptWidget->hide(); - if (m_device->type() != Device::Type::LVM_Device) { + if (m_device->type() == Device::Type::Disk_Device) { m_ui->lvNameLabel->hide(); m_ui->lvNameLineEdit->hide(); } diff --git a/src/modules/partition/gui/PartitionPage.cpp b/src/modules/partition/gui/PartitionPage.cpp index 86de992e6..994adc3e8 100644 --- a/src/modules/partition/gui/PartitionPage.cpp +++ b/src/modules/partition/gui/PartitionPage.cpp @@ -4,8 +4,6 @@ * Copyright 2015-2016, Teo Mrnjavac * Copyright 2018, Adriaan de Groot * Copyright 2018, Andrius Štikonas - * Copyright 2018, Caio Jordão Carvalho - * Copyright 2019, Collabora Ltd * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -49,9 +47,6 @@ // KPMcore #include #include -#ifdef WITH_KPMCOREGT33 -#include -#endif #include #include @@ -151,7 +146,6 @@ PartitionPage::updateButtons() bool isInVG = m_core->isInVG( partition ); create = isFree; - // Keep it simple for now: do not support editing extended partitions as // it does not work with our current edit implementation which is // actually remove + add. This would not work with extended partitions @@ -166,20 +160,8 @@ PartitionPage::updateButtons() if ( m_ui->deviceComboBox->currentIndex() >= 0 ) { QModelIndex deviceIndex = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 ); - auto device = m_core->deviceModel()->deviceForIndex( deviceIndex ); - if ( device->type() != Device::Type::LVM_Device ) - { + if ( m_core->deviceModel()->deviceForIndex( deviceIndex )->type() != Device::Type::LVM_Device ) createTable = true; - -#ifdef WITH_KPMCOREGT33 - if ( device->type() == Device::Type::SoftwareRAID_Device && - static_cast< SoftwareRAID* >(device)->status() == SoftwareRAID::Status::Inactive ) - { - createTable = false; - create = false; - } -#endif - } else { currentDeviceIsVG = true; @@ -610,15 +592,3 @@ PartitionPage::getCurrentUsedMountpoints() return mountPoints; } - -int -PartitionPage::selectedDeviceIndex() -{ - return m_ui->deviceComboBox->currentIndex(); -} - -void -PartitionPage::selectDeviceByIndex ( int index ) -{ - m_ui->deviceComboBox->setCurrentIndex( index ); -} diff --git a/src/modules/partition/gui/PartitionPage.h b/src/modules/partition/gui/PartitionPage.h index 8289f2cdd..70d8ccdfb 100644 --- a/src/modules/partition/gui/PartitionPage.h +++ b/src/modules/partition/gui/PartitionPage.h @@ -2,7 +2,6 @@ * * Copyright 2014, Aurélien Gâteau * Copyright 2018, Adriaan de Groot - * Copyright 2019, Collabora Ltd * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -47,9 +46,6 @@ public: void onRevertClicked(); - int selectedDeviceIndex(); - void selectDeviceByIndex( int index ); - private: QScopedPointer< Ui_PartitionPage > m_ui; PartitionCoreModule* m_core; diff --git a/src/modules/partition/gui/PartitionViewStep.cpp b/src/modules/partition/gui/PartitionViewStep.cpp index c303cff91..b49b6c93b 100644 --- a/src/modules/partition/gui/PartitionViewStep.cpp +++ b/src/modules/partition/gui/PartitionViewStep.cpp @@ -3,7 +3,6 @@ * Copyright 2014, Aurélien Gâteau * Copyright 2014-2017, Teo Mrnjavac * Copyright 2018, Adriaan de Groot - * Copyright 2019, Collabora Ltd * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +21,6 @@ #include "gui/PartitionViewStep.h" #include "core/DeviceModel.h" -#include "core/PartitionActions.h" #include "core/PartitionCoreModule.h" #include "core/PartitionModel.h" #include "core/KPMHelpers.h" @@ -140,7 +138,7 @@ PartitionViewStep::createSummaryWidget() const widget->setLayout( mainLayout ); mainLayout->setMargin( 0 ); - ChoicePage::InstallChoice choice = m_choicePage->currentChoice(); + ChoicePage::Choice choice = m_choicePage->currentChoice(); QFormLayout* formLayout = new QFormLayout( widget ); const int MARGIN = CalamaresUtils::defaultFontHeight() / 2; @@ -287,7 +285,6 @@ PartitionViewStep::next() if ( m_choicePage->currentChoice() == ChoicePage::Manual ) { m_widget->setCurrentWidget( m_manualPartitionPage ); - m_manualPartitionPage->selectDeviceByIndex( m_choicePage->lastSelectedDeviceIndex() ); if ( m_core->isDirty() ) m_manualPartitionPage->onRevertClicked(); } @@ -317,10 +314,7 @@ void PartitionViewStep::back() { if ( m_widget->currentWidget() != m_choicePage ) - { m_widget->setCurrentWidget( m_choicePage ); - m_choicePage->setLastSelectedDeviceIndex( m_manualPartitionPage->selectedDeviceIndex() ); - } } @@ -476,161 +470,92 @@ PartitionViewStep::onLeave() } -static PartitionActions::Choices::SwapChoice -nameToChoice( QString name, bool& ok ) -{ - ok = false; - name = name.toLower(); - - using namespace PartitionActions::Choices; - - // Each return here first sets ok to true, returns enum value - if ( name == QStringLiteral( "none" ) ) - return( ok=true, SwapChoice::NoSwap ); - else if ( name == QStringLiteral( "small" ) ) - return( ok=true, SwapChoice::SmallSwap); - else if ( name == QStringLiteral( "suspend" ) ) - return( ok=true, SwapChoice::FullSwap ); - else if ( name == QStringLiteral( "reuse" ) ) - return( ok=true, SwapChoice::ReuseSwap ); - else if ( name == QStringLiteral( "file" ) ) - return( ok=true, SwapChoice::SwapFile ); - - ok = false; - return SwapChoice::NoSwap; -} - -/** @brief translate @p defaultFS into a recognized name - * - * Makes several attempts to translate the string into a - * name that KPMCore will recognize. - */ -static QString -findFS( QString defaultFS ) -{ - QStringList fsLanguage { QLatin1Literal( "C" ) }; // Required language list to turn off localization - if ( defaultFS.isEmpty() ) - defaultFS = QStringLiteral( "ext4" ); - if ( FileSystem::typeForName( defaultFS, fsLanguage ) != FileSystem::Unknown ) - { - cDebug() << "Partition-module setting *defaultFileSystemType*" << defaultFS; - return defaultFS; - } - - // First pass: try the default language instead of C locale - auto fsType = FileSystem::typeForName( defaultFS ); - if ( fsType != FileSystem::Unknown ) - { - defaultFS = FileSystem::nameForType( fsType, fsLanguage ); - cWarning() << "Partition-module setting *defaultFileSystemType* changed" << defaultFS; - return defaultFS; - } - - // Second pass: try case-insensitive, both unlocalized and localized - const auto fstypes = FileSystem::types(); - for ( FileSystem::Type t : fstypes ) - { - if ( ( 0 == QString::compare( defaultFS, FileSystem::nameForType( t, fsLanguage ), Qt::CaseInsensitive ) ) || - ( 0 == QString::compare( defaultFS, FileSystem::nameForType( t ), Qt::CaseInsensitive ) ) ) - { - defaultFS = FileSystem::nameForType( fsType, fsLanguage ); - cWarning() << "Partition-module setting *defaultFileSystemType* changed" << defaultFS; - return defaultFS; - } - } - - cWarning() << "Partition-module setting *defaultFileSystemType* is bad (" << defaultFS << ") using ext4."; - defaultFS = QStringLiteral( "ext4" ); -#ifdef DEBUG_FILESYSTEMS - // This bit is for distro's debugging their settings, and shows - // all the strings that KPMCore is matching against for FS type. - { - Logger::CLog d( Logger::LOGDEBUG ); - using TR = Logger::DebugRow< int, QString >; - const auto fstypes = FileSystem::types(); - d << "Available types (" << fstypes.count() << ')'; - for ( FileSystem::Type t : fstypes ) - d << TR( static_cast( t ), FileSystem::nameForType( t, fsLanguage ) ); - } -#endif - return defaultFS; -} - void PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { // Copy the efiSystemPartition setting to the global storage. It is needed not only in // the EraseDiskPage, but also in the bootloader configuration modules (grub, bootloader). Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); - QString efiSP = CalamaresUtils::getString( configurationMap, "efiSystemPartition" ); - if ( efiSP.isEmpty() ) - efiSP = QStringLiteral( "/boot/efi" ); - gs->insert( "efiSystemPartition", efiSP ); - - // SWAP SETTINGS - // - // This is a bit convoluted because there's legacy settings to handle as well - // as the new-style list of choices, with mapping back-and-forth. - if ( configurationMap.contains( "userSwapChoices" ) && - ( configurationMap.contains( "ensureSuspendToDisk" ) || configurationMap.contains( "neverCreateSwap" ) ) ) - cError() << "Partition-module configuration mixes old- and new-style swap settings."; - - if ( configurationMap.contains( "ensureSuspendToDisk" ) ) - cWarning() << "Partition-module setting *ensureSuspendToDisk* is deprecated."; - bool ensureSuspendToDisk = CalamaresUtils::getBool( configurationMap, "ensureSuspendToDisk", true ); - - if ( configurationMap.contains( "neverCreateSwap" ) ) - cWarning() << "Partition-module setting *neverCreateSwap* is deprecated."; - bool neverCreateSwap = CalamaresUtils::getBool( configurationMap, "neverCreateSwap", false ); - - QSet< PartitionActions::Choices::SwapChoice > choices; // Available swap choices - if ( configurationMap.contains( "userSwapChoices" ) ) + if ( configurationMap.contains( "efiSystemPartition" ) && + configurationMap.value( "efiSystemPartition" ).type() == QVariant::String && + !configurationMap.value( "efiSystemPartition" ).toString().isEmpty() ) { - // We've already warned about overlapping settings with the - // legacy *ensureSuspendToDisk* and *neverCreateSwap*. - QStringList l = configurationMap[ "userSwapChoices" ].toStringList(); - - for ( const auto& item : l ) - { - bool ok = false; - auto v = nameToChoice( item, ok ); - if ( ok ) - choices.insert( v ); - } - - if ( choices.isEmpty() ) - { - cWarning() << "Partition-module configuration for *userSwapChoices* is empty:" << l; - choices.insert( PartitionActions::Choices::SwapChoice::FullSwap ); - } - - // suspend if it's one of the possible choices; suppress swap only if it's - // the **only** choice available. - ensureSuspendToDisk = choices.contains( PartitionActions::Choices::SwapChoice::FullSwap ); - neverCreateSwap = ( choices.count() == 1 ) && choices.contains( PartitionActions::Choices::SwapChoice::NoSwap ); + gs->insert( "efiSystemPartition", configurationMap.value( "efiSystemPartition" ).toString() ); } else { - // Convert the legacy settings into a single setting for now. - if ( neverCreateSwap ) - choices.insert( PartitionActions::Choices::SwapChoice::NoSwap ); - else if ( ensureSuspendToDisk ) - choices.insert( PartitionActions::Choices::SwapChoice::FullSwap ); - else - choices.insert( PartitionActions::Choices::SwapChoice::SmallSwap ); + gs->insert( "efiSystemPartition", QStringLiteral( "/boot/efi" ) ); } - // These gs settings seem to be unused (in upstream Calamares) outside of - // the partition module itself. - gs->insert( "ensureSuspendToDisk", ensureSuspendToDisk ); - gs->insert( "neverCreateSwap", neverCreateSwap ); + if ( configurationMap.contains( "ensureSuspendToDisk" ) && + configurationMap.value( "ensureSuspendToDisk" ).type() == QVariant::Bool ) + { + gs->insert( "ensureSuspendToDisk", configurationMap.value( "ensureSuspendToDisk" ).toBool() ); + } + else + { + gs->insert( "ensureSuspendToDisk", true ); + } - // OTHER SETTINGS - // - gs->insert( "drawNestedPartitions", CalamaresUtils::getBool( configurationMap, "drawNestedPartitions", false ) ); - gs->insert( "alwaysShowPartitionLabels", CalamaresUtils::getBool( configurationMap, "alwaysShowPartitionLabels", true ) ); - gs->insert( "enableLuksAutomatedPartitioning", CalamaresUtils::getBool( configurationMap, "enableLuksAutomatedPartitioning", true ) ); - gs->insert( "defaultFileSystemType", findFS( CalamaresUtils::getString( configurationMap, "defaultFileSystemType" ) ) ); + if ( configurationMap.contains( "neverCreateSwap" ) && + configurationMap.value( "neverCreateSwap" ).type() == QVariant::Bool ) + { + gs->insert( "neverCreateSwap", configurationMap.value( "neverCreateSwap" ).toBool() ); + } + else + { + gs->insert( "neverCreateSwap", false ); + } + + if ( configurationMap.contains( "drawNestedPartitions" ) && + configurationMap.value( "drawNestedPartitions" ).type() == QVariant::Bool ) + { + gs->insert( "drawNestedPartitions", + configurationMap.value( "drawNestedPartitions", false ).toBool() ); + } + else + { + gs->insert( "drawNestedPartitions", false ); + } + + if ( configurationMap.contains( "alwaysShowPartitionLabels" ) && + configurationMap.value( "alwaysShowPartitionLabels" ).type() == QVariant::Bool ) + { + gs->insert( "alwaysShowPartitionLabels", + configurationMap.value( "alwaysShowPartitionLabels", true ).toBool() ); + } + else + { + gs->insert( "alwaysShowPartitionLabels", true ); + } + + if ( configurationMap.contains( "defaultFileSystemType" ) && + configurationMap.value( "defaultFileSystemType" ).type() == QVariant::String && + !configurationMap.value( "defaultFileSystemType" ).toString().isEmpty() ) + { + QString typeString = configurationMap.value( "defaultFileSystemType" ).toString(); + gs->insert( "defaultFileSystemType", typeString ); + if ( FileSystem::typeForName( typeString ) == FileSystem::Unknown ) + { + cWarning() << "bad default filesystem configuration for partition module. Reverting to ext4 as default."; + gs->insert( "defaultFileSystemType", "ext4" ); + } + } + else + { + gs->insert( "defaultFileSystemType", QStringLiteral( "ext4" ) ); + } + + if ( configurationMap.contains( "enableLuksAutomatedPartitioning" ) && + configurationMap.value( "enableLuksAutomatedPartitioning" ).type() == QVariant::Bool ) + { + gs->insert( "enableLuksAutomatedPartitioning", + configurationMap.value( "enableLuksAutomatedPartitioning" ).toBool() ); + } + else + { + gs->insert( "enableLuksAutomatedPartitioning", true ); + } // Now that we have the config, we load the PartitionCoreModule in the background @@ -638,7 +563,7 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap ) // and remove the spinner. QFutureWatcher< void >* watcher = new QFutureWatcher< void >(); connect( watcher, &QFutureWatcher< void >::finished, - this, [ this, watcher, choices ] + this, [ this, watcher ] { continueLoading(); watcher->deleteLater(); diff --git a/src/modules/partition/gui/PrettyRadioButton.cpp b/src/modules/partition/gui/PrettyRadioButton.cpp index 18627f41c..a697ed270 100644 --- a/src/modules/partition/gui/PrettyRadioButton.cpp +++ b/src/modules/partition/gui/PrettyRadioButton.cpp @@ -21,34 +21,29 @@ #include "utils/CalamaresUtilsGui.h" #include "widgets/ClickableLabel.h" -#include -#include -#include #include +#include PrettyRadioButton::PrettyRadioButton( QWidget* parent ) : QWidget( parent ) - , m_label( new ClickableLabel ) - , m_radio( new QRadioButton ) - , m_mainLayout( new QGridLayout ) - , m_optionsLayout( nullptr ) { - setLayout( m_mainLayout ); + QHBoxLayout* mainLayout = new QHBoxLayout; + setLayout( mainLayout ); + m_radio = new QRadioButton; + m_label = new ClickableLabel; + + connect( m_label, &ClickableLabel::clicked, + m_radio, &QRadioButton::click ); m_label->setBuddy( m_radio ); m_label->setWordWrap( true ); m_label->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); - m_mainLayout->addWidget( m_radio, 0, 0 ); - m_mainLayout->addWidget( m_label, 0, 1 ); - m_mainLayout->setContentsMargins( 0, 0, 0, 0 ); - - connect( m_label, &ClickableLabel::clicked, - m_radio, &QRadioButton::click ); - connect( m_radio, &QRadioButton::toggled, - this, &PrettyRadioButton::toggleOptions ); + mainLayout->addWidget( m_radio ); + mainLayout->addWidget( m_label ); + mainLayout->setContentsMargins( 0, 0, 0, 0 ); } @@ -85,32 +80,3 @@ PrettyRadioButton::buttonWidget() const { return m_radio; } - -void -PrettyRadioButton::addOptionsComboBox( QComboBox* box ) -{ - if ( !box ) - return; - - if ( !m_optionsLayout ) - { - QWidget* w = new QWidget; - m_optionsLayout = new QHBoxLayout; - m_optionsLayout->setAlignment( Qt::AlignmentFlag::AlignLeft ); - m_optionsLayout->addStretch( 1 ); - - w->setLayout( m_optionsLayout ); - m_mainLayout->addWidget( w, 1, 1 ); - - toggleOptions( m_radio->isChecked() ); - } - - m_optionsLayout->insertWidget( m_optionsLayout->count()-1, box ); -} - -void -PrettyRadioButton::toggleOptions( bool toggle ) -{ - if ( m_optionsLayout ) - m_optionsLayout->parentWidget()->setVisible( toggle ); -} diff --git a/src/modules/partition/gui/PrettyRadioButton.h b/src/modules/partition/gui/PrettyRadioButton.h index c88c00728..f475ce528 100644 --- a/src/modules/partition/gui/PrettyRadioButton.h +++ b/src/modules/partition/gui/PrettyRadioButton.h @@ -22,17 +22,7 @@ #include class ClickableLabel; -class QComboBox; -class QGridLayout; -class QHBoxLayout; -/** @brief A radio button with fancy label next to it. - * - * The radio button itself can be retrieved with buttonWidget(), - * and the whole behaves a lot like a label. Extra options can be - * added to the display (options are hidden when the button is - * not selected) with addOptionsComboBox(). - */ class PrettyRadioButton : public QWidget { Q_OBJECT @@ -50,18 +40,9 @@ public: virtual QRadioButton* buttonWidget() const; - /** @brief Add an options drop-down to this button. */ - void addOptionsComboBox( QComboBox* ); - -protected slots: - /// Options are hidden when the radio button is off - void toggleOptions( bool checked ); - protected: ClickableLabel* m_label; QRadioButton* m_radio; - QGridLayout* m_mainLayout; - QHBoxLayout* m_optionsLayout; }; #endif // PRETTYRADIOBUTTON_H diff --git a/src/modules/partition/gui/ReplaceWidget.cpp b/src/modules/partition/gui/ReplaceWidget.cpp index faedc03d4..524932057 100644 --- a/src/modules/partition/gui/ReplaceWidget.cpp +++ b/src/modules/partition/gui/ReplaceWidget.cpp @@ -85,8 +85,6 @@ ReplaceWidget::reset() void ReplaceWidget::applyChanges() { - auto gs = Calamares::JobQueue::instance()->globalStorage(); - PartitionModel* model = qobject_cast< PartitionModel* >( m_ui->partitionTreeView->model() ); if ( model ) { @@ -95,9 +93,7 @@ ReplaceWidget::applyChanges() { Device* dev = model->device(); - PartitionActions::doReplacePartition( - m_core, dev, partition, - { gs->value( "defaultFileSystemType" ).toString(), QString() } ); + PartitionActions::doReplacePartition( m_core, dev, partition ); if ( m_isEfi ) { @@ -106,13 +102,17 @@ ReplaceWidget::applyChanges() { PartitionInfo::setMountPoint( efiSystemPartitions.first(), - gs->value( "efiSystemPartition" ).toString() ); + Calamares::JobQueue::instance()-> + globalStorage()-> + value( "efiSystemPartition" ).toString() ); } else if ( efiSystemPartitions.count() > 1 ) { PartitionInfo::setMountPoint( efiSystemPartitions.at( m_ui->bootComboBox->currentIndex() ), - gs->value( "efiSystemPartition" ).toString() ); + Calamares::JobQueue::instance()-> + globalStorage()-> + value( "efiSystemPartition" ).toString() ); } } diff --git a/src/modules/partition/jobs/CreatePartitionTableJob.cpp b/src/modules/partition/jobs/CreatePartitionTableJob.cpp index 937b8437d..2aec4a5fc 100644 --- a/src/modules/partition/jobs/CreatePartitionTableJob.cpp +++ b/src/modules/partition/jobs/CreatePartitionTableJob.cpp @@ -20,8 +20,6 @@ #include "jobs/CreatePartitionTableJob.h" -#include "core/PartitionIterator.h" - #include "utils/Logger.h" // KPMcore @@ -67,14 +65,6 @@ CreatePartitionTableJob::prettyStatusMessage() const } -static inline QDebug& -operator <<( QDebug& s, PartitionIterator& it ) -{ - s << ( ( *it ) ? ( *it )->deviceNode() : QString( "" ) ); - return s; -} - - Calamares::JobResult CreatePartitionTableJob::exec() { @@ -83,28 +73,21 @@ CreatePartitionTableJob::exec() PartitionTable* table = m_device->partitionTable(); cDebug() << "Creating new partition table of type" << table->typeName() - << ", uncommitted yet:"; + << ", uncommitted yet:\n" << table; - if ( Logger::logLevelEnabled( Logger::LOGDEBUG ) ) - { - for ( auto it = PartitionIterator::begin( table ); - it != PartitionIterator::end( table ); ++it ) - cDebug() << *it; + QProcess lsblk; + lsblk.setProgram( "lsblk" ); + lsblk.setProcessChannelMode( QProcess::MergedChannels ); + lsblk.start(); + lsblk.waitForFinished(); + cDebug() << "lsblk:\n" << lsblk.readAllStandardOutput(); - QProcess lsblk; - lsblk.setProgram( "lsblk" ); - lsblk.setProcessChannelMode( QProcess::MergedChannels ); - lsblk.start(); - lsblk.waitForFinished(); - cDebug() << "lsblk:\n" << lsblk.readAllStandardOutput(); - - QProcess mount; - mount.setProgram( "mount" ); - mount.setProcessChannelMode( QProcess::MergedChannels ); - mount.start(); - mount.waitForFinished(); - cDebug() << "mount:\n" << mount.readAllStandardOutput(); - } + QProcess mount; + mount.setProgram( "mount" ); + mount.setProcessChannelMode( QProcess::MergedChannels ); + mount.start(); + mount.waitForFinished(); + cDebug() << "mount:\n" << mount.readAllStandardOutput(); CreatePartitionTableOperation op(*m_device, table); op.setStatus(Operation::StatusRunning); diff --git a/src/modules/partition/jobs/FillGlobalStorageJob.cpp b/src/modules/partition/jobs/FillGlobalStorageJob.cpp index 597d62a82..43a5f3904 100644 --- a/src/modules/partition/jobs/FillGlobalStorageJob.cpp +++ b/src/modules/partition/jobs/FillGlobalStorageJob.cpp @@ -56,12 +56,9 @@ findPartitionUuids( QList < Device* > devices ) QString path = p->partitionPath(); QString uuid = p->fileSystem().readUUID( p->partitionPath() ); hash.insert( path, uuid ); - cDebug() << ".. added path=" << path << "UUID=" << uuid; } } - - if ( hash.isEmpty() ) - cDebug() << ".. no UUIDs found."; + cDebug() << hash; return hash; } @@ -93,16 +90,10 @@ mapForPartition( Partition* partition, const QString& uuid ) dynamic_cast< FS::luks& >( partition->fileSystem() ).innerFS() ) map[ "fs" ] = dynamic_cast< FS::luks& >( partition->fileSystem() ).innerFS()->name(); map[ "uuid" ] = uuid; - - // Debugging for inside the loop in createPartitionList(), - // so indent a bit - Logger::CLog deb = cDebug(); - using TR = Logger::DebugRow; - deb << " .. mapping for" << partition->partitionPath() << partition->deviceNode() - << TR( "mtpoint:", PartitionInfo::mountPoint( partition ) ) - << TR( "fs:", map[ "fs" ].toString() ) - << TR( "fsname", map[ "fsName" ].toString() ) - << TR( "uuid", uuid ); + cDebug() << partition->partitionPath() + << "mtpoint:" << PartitionInfo::mountPoint( partition ) + << "fs:" << map[ "fs" ] << '(' << map[ "fsName" ] << ')' + << uuid; if ( partition->roles().has( PartitionRole::Luks ) ) { @@ -113,7 +104,7 @@ mapForPartition( Partition* partition, const QString& uuid ) map[ "luksMapperName" ] = luksFs->mapperName().split( "/" ).last(); map[ "luksUuid" ] = getLuksUuid( partition->partitionPath() ); map[ "luksPassphrase" ] = luksFs->passphrase(); - deb << TR( "luksMapperName:", map[ "luksMapperName" ].toString() ); + cDebug() << "luksMapperName:" << map[ "luksMapperName" ]; } } @@ -224,11 +215,9 @@ FillGlobalStorageJob::createPartitionList() const cDebug() << "Writing to GlobalStorage[\"partitions\"]"; for ( auto device : m_devices ) { - cDebug() << ".. partitions on" << device->deviceNode(); for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it ) { - // Debug-logging is done when creating the map lst << mapForPartition( *it, hash.value( ( *it )->partitionPath() ) ); } } diff --git a/src/modules/partition/jobs/SetPartitionFlagsJob.cpp b/src/modules/partition/jobs/SetPartitionFlagsJob.cpp index fee987479..7f6169bbe 100644 --- a/src/modules/partition/jobs/SetPartitionFlagsJob.cpp +++ b/src/modules/partition/jobs/SetPartitionFlagsJob.cpp @@ -132,10 +132,6 @@ SetPartFlagsJob::prettyStatusMessage() const Calamares::JobResult SetPartFlagsJob::exec() { - cDebug() << "Setting flags on" << m_device->deviceNode() - << "partition" << partition()->deviceNode() - << "to" << m_flags; - Report report ( nullptr ); SetPartFlagsOperation op( *m_device, *partition(), m_flags ); op.setStatus( Operation::StatusRunning ); diff --git a/src/modules/partition/partition.conf b/src/modules/partition/partition.conf index 229ffc32c..78ad82f10 100644 --- a/src/modules/partition/partition.conf +++ b/src/modules/partition/partition.conf @@ -3,37 +3,22 @@ # etc.) use just /boot. efiSystemPartition: "/boot/efi" -# In autogenerated partitioning, allow the user to select a swap size? -# If there is exactly one choice, no UI is presented, and the user -# cannot make a choice -- this setting is used. If there is more than -# one choice, a UI is presented. +# Make sure an autogenerated swap partition is big enough for hibernation in +# automated partitioning modes. Swap can be disabled through *neverCreateSwap*. # -# Legacy settings *neverCreateSwap* and *ensureSuspendToDisk* correspond -# to values of *userSwapChoices* as follows: -# - *neverCreateSwap* is true, means [none] -# - *neverCreateSwap* is false, *ensureSuspendToDisk* is false, [small] -# - *neverCreateSwap* is false, *ensureSuspendToDisk* is true, [suspend] +# When *ensureSuspendToDisk* is true, swap is never smaller than physical +# memory, follows the guideline 2 * memory until swap reaches 8GiB. +# When *ensureSuspendToDisk* is false, swap size scales up with memory +# size until 8GiB, then at roughly half of memory size. # -# Autogenerated swap sizes are as follows: -# - *suspend*: Swap is always at least total memory size, -# and up to 4GiB RAM follows the rule-of-thumb 2 * memory; -# from 4GiB to 8 GiB it stays steady at 8GiB, and over 8 GiB memory -# swap is the size of main memory. -# - *small*: Follows the rules above, but Swap is at -# most 8GiB, and no more than 10% of available disk. -# In both cases, a fudge factor (usually 10% extra) is applied so that there -# is some space for administrative overhead (e.g. 8 GiB swap will allocate -# 8.8GiB on disk in the end). -userSwapChoices: - - none # Create no swap, use no swap - # - reuse # Re-use existing swap, but don't create any - - small # Up to 4GB - - suspend # At least main memory size - # - file # To swap file instead of partition (unsupported right now) +# +# Default is true. +ensureSuspendToDisk: true -# LEGACY SETTINGS (these will generate a warning) -# ensureSuspendToDisk: true -# neverCreateSwap: false +# Never create swap partitions in automated partitioning modes. +# If this is true, ensureSuspendToDisk is ignored. +# Default is false. +neverCreateSwap: false # Correctly draw nested (e.g. logical) partitions as such. drawNestedPartitions: false @@ -53,8 +38,6 @@ alwaysShowPartitionLabels: true # # Suggested values: ext2, ext3, ext4, reiser, xfs, jfs, btrfs # If nothing is specified, Calamares defaults to "ext4". -# -# Names are case-sensitive and defined by KPMCore. defaultFileSystemType: "ext4" # Show/hide LUKS related functionality in automated partitioning modes. diff --git a/src/modules/partition/tests/CMakeLists.txt b/src/modules/partition/tests/CMakeLists.txt index 7b40c34a5..68474287e 100644 --- a/src/modules/partition/tests/CMakeLists.txt +++ b/src/modules/partition/tests/CMakeLists.txt @@ -1,4 +1,6 @@ -find_package( Qt5 COMPONENTS Gui REQUIRED ) +find_package( Qt5 COMPONENTS Gui Test REQUIRED ) + +include( ECMAddTests ) set( PartitionModule_SOURCE_DIR .. ) @@ -21,15 +23,13 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) -if( ECM_FOUND AND BUILD_TESTING ) - ecm_add_test( ${partitionjobtests_SRCS} - TEST_NAME partitionjobtests - LINK_LIBRARIES - ${CALAMARES_LIBRARIES} - kpmcore - Qt5::Core - Qt5::Test - ) +ecm_add_test( ${partitionjobtests_SRCS} + TEST_NAME partitionjobtests + LINK_LIBRARIES + ${CALAMARES_LIBRARIES} + kpmcore + Qt5::Core + Qt5::Test +) - set_target_properties( partitionjobtests PROPERTIES AUTOMOC TRUE ) -endif() +set_target_properties( partitionjobtests PROPERTIES AUTOMOC TRUE ) diff --git a/src/modules/partition/tests/PartitionJobTests.cpp b/src/modules/partition/tests/PartitionJobTests.cpp index f261b12ed..de10631a0 100644 --- a/src/modules/partition/tests/PartitionJobTests.cpp +++ b/src/modules/partition/tests/PartitionJobTests.cpp @@ -2,7 +2,6 @@ * * Copyright 2014, Aurélien Gâteau * Copyright 2017, Adriaan de Groot - * Copyright 2018, Philip Müller * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -359,15 +358,7 @@ PartitionJobTests::testResizePartition() Partition* freePartition = firstFreePartition( m_device->partitionTable() ); QVERIFY( freePartition ); - Partition* partition = KPMHelpers::createNewPartition( - freePartition->parent(), - *m_device, - PartitionRole( PartitionRole::Primary ), - FileSystem::Ext4, - oldFirst, - oldLast, - PartitionTable::FlagNone - ); + Partition* partition = KPMHelpers::createNewPartition( freePartition->parent(), *m_device, PartitionRole( PartitionRole::Primary ), FileSystem::Ext4, oldFirst, oldLast ); CreatePartitionJob* job = new CreatePartitionJob( m_device.data(), partition ); job->updatePreview(); m_queue.enqueue( job_ptr( job ) );