Merge branch 'issues-1166' into calamares

FIXES #1166
This commit is contained in:
Adriaan de Groot 2020-10-06 22:25:33 +02:00
commit 88b1d36009
32 changed files with 618 additions and 380 deletions

1
.gitignore vendored
View File

@ -50,6 +50,7 @@ CMakeLists.txt.user
# Backup files
*~
*.bak
# Kate
*.kate-swp

View File

@ -24,6 +24,10 @@ This release contains contributions from (alphabetically by first name):
system) now supports more than one entropy file; generate them as needed
(or copy a fixed value to all, depending on *entropy-copy*). Deprecate
*entropy* (which generates a specific output file) as too inflexible.
- In the *partition* module, swap can now be chosen as *file*, which is
**not** create a swap partition, but write a `/swapfile` in the root
directory, 512MiB large, and set that as swap. There is as yet no
"smarts" about the size of the swap file.
- Progress reporting from the *unpackfs* module has been revamped:
it reports more often now, so that it is more obvious that files
are being transferred even when the percentage progress does not

View File

@ -35,7 +35,13 @@ test -n "$CF" || { echo "! No clang-format ($CF_VERSIONS) found in PATH"; exit 1
test -x "$AS" || { echo "! $AS is not executable."; exit 1 ; }
test -x "$CF" || { echo "! $CF is not executable."; exit 1 ; }
expr `"$CF" --version | tr -dc '[^.0-9]' | cut -d . -f 1` '<' 10 > /dev/null || { echo "! $CF is version 10 or later, needs different .clang-format" ; exit 1 ; }
unmangle_clang_format=""
if expr `"$CF" --version | tr -dc '[^.0-9]' | cut -d . -f 1` '<' 10 > /dev/null ; then
:
else
unmangle_clang_format=$( dirname $0 )/../.clang-format
echo "SpaceInEmptyBlock: false" >> "$unmangle_clang_format"
fi
set -e
@ -65,3 +71,7 @@ if test "x$any_dirs" = "xyes" ; then
else
style_some "$@"
fi
if test -n "$unmangle_clang_format" ; then
sed -i.bak '/^SpaceInEmptyBlock/d' "$unmangle_clang_format"
fi

View File

@ -257,7 +257,7 @@ class FstabGenerator(object):
if mount_point == "/":
check = 1
elif mount_point:
elif mount_point and mount_point != "swap":
check = 2
else:
check = 0
@ -270,8 +270,10 @@ class FstabGenerator(object):
if has_luks:
device = "/dev/mapper/" + partition["luksMapperName"]
else:
elif partition["uuid"] is not None:
device = "UUID=" + partition["uuid"]
else:
device = partition["device"]
return dict(device=device,
mount_point=mount_point,
@ -307,6 +309,29 @@ class FstabGenerator(object):
self.mount_options["default"])
def create_swapfile(root_mount_point, root_btrfs):
"""
Creates /swapfile in @p root_mount_point ; if the root filesystem
is on btrfs, then handle some btrfs specific features as well,
as documented in
https://wiki.archlinux.org/index.php/Swap#Swap_file
"""
swapfile_path = os.path.join(root_mount_point, "swapfile")
with open(swapfile_path, "wb") as f:
pass
if root_btrfs:
o = subprocess.check_output(["chattr", "+C", swapfile_path])
libcalamares.utils.debug("swapfile attributes: {!s}".format(o))
o = subprocess.check_output(["btrfs", "property", "set", swapfile_path, "compression", "none"])
libcalamares.utils.debug("swapfile compression: {!s}".format(o))
# Create the swapfile; swapfiles are small-ish
o = subprocess.check_output(["dd", "if=/dev/zero", "of=" + swapfile_path, "bs=1M", "count=512", "conv=notrunc"])
libcalamares.utils.debug("swapfile dd: {!s}".format(o))
os.chmod(swapfile_path, 0o600)
o = subprocess.check_output(["mkswap", swapfile_path])
libcalamares.utils.debug("swapfile mkswap: {!s}".format(o))
def run():
""" Configures fstab.
@ -330,6 +355,17 @@ def run():
_("No root mount point is given for <pre>{!s}</pre> to use.")
.format("fstab"))
# This follows the GS settings from the partition module's Config object
swap_choice = global_storage.value( "partitionChoices" )
if swap_choice:
swap_choice = swap_choice.get( "swap", None )
if swap_choice and swap_choice == "file":
# There's no formatted partition for it, so we'll sneak in an entry
partitions.append( dict(fs="swap", mountPoint=None, claimed=True, device="/swapfile", uuid=None) )
else:
swap_choice = None
libcalamares.job.setprogress(0.1)
mount_options = conf["mountOptions"]
ssd_extra_mount_options = conf.get("ssdExtraMountOptions", {})
crypttab_options = conf.get("crypttabOptions", "luks")
@ -339,4 +375,14 @@ def run():
ssd_extra_mount_options,
crypttab_options)
return generator.run()
if swap_choice is not None:
libcalamares.job.setprogress(0.2)
root_partitions = [ p["fs"].lower() for p in partitions if p["mountPoint"] == "/" ]
root_btrfs = (root_partitions[0] == "btrfs") if root_partitions else False
create_swapfile(root_mount_point, root_btrfs)
try:
libcalamares.job.setprogress(0.5)
return generator.run()
finally:
libcalamares.job.setprogress(1.0)

View File

@ -19,7 +19,51 @@ Config::Config( QObject* parent )
{
}
static PartitionActions::Choices::SwapChoiceSet
const NamedEnumTable< Config::InstallChoice >&
Config::installChoiceNames()
{
static const NamedEnumTable< InstallChoice > names { { QStringLiteral( "none" ), InstallChoice::NoChoice },
{ QStringLiteral( "nochoice" ), InstallChoice::NoChoice },
{ QStringLiteral( "alongside" ), InstallChoice::Alongside },
{ QStringLiteral( "erase" ), InstallChoice::Erase },
{ QStringLiteral( "replace" ), InstallChoice::Replace },
{ QStringLiteral( "manual" ), InstallChoice::Manual } };
return names;
}
const NamedEnumTable< Config::SwapChoice >&
Config::swapChoiceNames()
{
static const NamedEnumTable< SwapChoice > names { { QStringLiteral( "none" ), SwapChoice::NoSwap },
{ QStringLiteral( "small" ), SwapChoice::SmallSwap },
{ QStringLiteral( "suspend" ), SwapChoice::FullSwap },
{ QStringLiteral( "reuse" ), SwapChoice::ReuseSwap },
{ QStringLiteral( "file" ), SwapChoice::SwapFile } };
return names;
}
Config::SwapChoice
pickOne( const Config::SwapChoiceSet& s )
{
if ( s.count() == 0 )
{
return Config::SwapChoice::NoSwap;
}
if ( s.count() == 1 )
{
return *( s.begin() );
}
if ( s.contains( Config::SwapChoice::NoSwap ) )
{
return Config::SwapChoice::NoSwap;
}
// Here, count > 1 but NoSwap is not a member.
return *( s.begin() );
}
static Config::SwapChoiceSet
getSwapChoices( const QVariantMap& configurationMap )
{
// SWAP SETTINGS
@ -44,7 +88,7 @@ getSwapChoices( const QVariantMap& configurationMap )
}
bool neverCreateSwap = CalamaresUtils::getBool( configurationMap, "neverCreateSwap", false );
PartitionActions::Choices::SwapChoiceSet choices; // Available swap choices
Config::SwapChoiceSet choices; // Available swap choices
if ( configurationMap.contains( "userSwapChoices" ) )
{
// We've already warned about overlapping settings with the
@ -54,7 +98,7 @@ getSwapChoices( const QVariantMap& configurationMap )
for ( const auto& item : l )
{
bool ok = false;
auto v = PartitionActions::Choices::swapChoiceNames().find( item, ok );
auto v = Config::swapChoiceNames().find( item, ok );
if ( ok )
{
choices.insert( v );
@ -64,28 +108,28 @@ getSwapChoices( const QVariantMap& configurationMap )
if ( choices.isEmpty() )
{
cWarning() << "Partition-module configuration for *userSwapChoices* is empty:" << l;
choices.insert( PartitionActions::Choices::SwapChoice::FullSwap );
choices.insert( Config::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 );
ensureSuspendToDisk = choices.contains( Config::SwapChoice::FullSwap );
neverCreateSwap = ( choices.count() == 1 ) && choices.contains( Config::SwapChoice::NoSwap );
}
else
{
// Convert the legacy settings into a single setting for now.
if ( neverCreateSwap )
{
choices.insert( PartitionActions::Choices::SwapChoice::NoSwap );
choices.insert( Config::SwapChoice::NoSwap );
}
else if ( ensureSuspendToDisk )
{
choices.insert( PartitionActions::Choices::SwapChoice::FullSwap );
choices.insert( Config::SwapChoice::FullSwap );
}
else
{
choices.insert( PartitionActions::Choices::SwapChoice::SmallSwap );
choices.insert( Config::SwapChoice::SmallSwap );
}
}
@ -96,17 +140,81 @@ getSwapChoices( const QVariantMap& configurationMap )
if ( choices.contains( x ) ) \
{ \
bool bogus = false; \
cWarning() << unsupportedSetting << PartitionActions::Choices::swapChoiceNames().find( x, bogus ); \
cWarning() << unsupportedSetting << Config::swapChoiceNames().find( x, bogus ); \
choices.remove( x ); \
}
COMPLAIN_UNSUPPORTED( PartitionActions::Choices::SwapChoice::SwapFile )
COMPLAIN_UNSUPPORTED( PartitionActions::Choices::SwapChoice::ReuseSwap )
COMPLAIN_UNSUPPORTED( Config::SwapChoice::ReuseSwap )
#undef COMPLAIN_UNSUPPORTED
return choices;
}
void
updateGlobalStorage( Config::InstallChoice installChoice, Config::SwapChoice swapChoice )
{
auto* gs = Calamares::JobQueue::instance() ? Calamares::JobQueue::instance()->globalStorage() : nullptr;
if ( gs )
{
QVariantMap m;
m.insert( "install", Config::installChoiceNames().find( installChoice ) );
m.insert( "swap", Config::swapChoiceNames().find( swapChoice ) );
gs->insert( "partitionChoices", m );
}
}
void
Config::setInstallChoice( int c )
{
if ( ( c < InstallChoice::NoChoice ) || ( c > InstallChoice::Manual ) )
{
cWarning() << "Invalid install choice (int)" << c;
c = InstallChoice::NoChoice;
}
setInstallChoice( static_cast< InstallChoice >( c ) );
}
void
Config::setInstallChoice( InstallChoice c )
{
if ( c != m_installChoice )
{
m_installChoice = c;
emit installChoiceChanged( c );
::updateGlobalStorage( c, m_swapChoice );
}
}
void
Config::setSwapChoice( int c )
{
if ( ( c < SwapChoice::NoSwap ) || ( c > SwapChoice::SwapFile ) )
{
cWarning() << "Instalid swap choice (int)" << c;
c = SwapChoice::NoSwap;
}
setSwapChoice( static_cast< SwapChoice >( c ) );
}
void
Config::setSwapChoice( Config::SwapChoice c )
{
if ( c != m_swapChoice )
{
m_swapChoice = c;
emit swapChoiceChanged( c );
::updateGlobalStorage( m_installChoice, c );
}
}
bool
Config::allowManualPartitioning() const
{
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
return gs->value( "allowManualPartitioning" ).toBool();
}
void
Config::setConfigurationMap( const QVariantMap& configurationMap )
{
@ -115,8 +223,22 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
m_swapChoices = getSwapChoices( configurationMap );
bool nameFound = false; // In the name table (ignored, falls back to first entry in table)
m_initialInstallChoice = PartitionActions::Choices::installChoiceNames().find(
m_initialInstallChoice = installChoiceNames().find(
CalamaresUtils::getString( configurationMap, "initialPartitioningChoice" ), nameFound );
setInstallChoice( m_initialInstallChoice );
m_initialSwapChoice
= swapChoiceNames().find( CalamaresUtils::getString( configurationMap, "initialSwapChoice" ), nameFound );
if ( !m_swapChoices.contains( m_initialSwapChoice ) )
{
cWarning() << "Configuration for *initialSwapChoice* is not one of the *userSwapChoices*";
m_initialSwapChoice = pickOne( m_swapChoices );
}
setSwapChoice( m_initialSwapChoice );
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
gs->insert( "allowManualPartitioning",
CalamaresUtils::getBool( configurationMap, "allowManualPartitioning", true ) );
}
void

View File

@ -10,7 +10,7 @@
#ifndef PARTITION_CONFIG_H
#define PARTITION_CONFIG_H
#include "core/PartitionActions.h"
#include "utils/NamedEnum.h"
#include <QObject>
#include <QSet>
@ -18,28 +18,111 @@
class Config : public QObject
{
Q_OBJECT
///@brief The installation choice (Erase, Alongside, ...)
Q_PROPERTY( InstallChoice installChoice READ installChoice WRITE setInstallChoice NOTIFY installChoiceChanged )
///@brief The swap choice (None, Small, Hibernate, ...) which only makes sense when Erase is chosen
Q_PROPERTY( SwapChoice swapChoice READ swapChoice WRITE setSwapChoice NOTIFY swapChoiceChanged )
Q_PROPERTY( bool allowManualPartitioning READ allowManualPartitioning CONSTANT FINAL )
public:
Config( QObject* parent );
virtual ~Config() = default;
enum InstallChoice
{
NoChoice,
Alongside,
Erase,
Replace,
Manual
};
Q_ENUM( InstallChoice )
static const NamedEnumTable< InstallChoice >& installChoiceNames();
/** @brief Choice 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)
};
Q_ENUM( SwapChoice )
static const NamedEnumTable< SwapChoice >& swapChoiceNames();
using SwapChoiceSet = QSet< SwapChoice >;
void setConfigurationMap( const QVariantMap& );
void updateGlobalStorage() const;
PartitionActions::Choices::SwapChoiceSet swapChoices() const { return m_swapChoices; }
/**
* @brief What kind of installation (partitioning) is requested **initially**?
/** @brief What kind of installation (partitioning) is requested **initially**?
*
* @return the partitioning choice (may by @c NoChoice)
* @return the partitioning choice (may be @c NoChoice)
*/
PartitionActions::Choices::InstallChoice initialInstallChoice() const { return m_initialInstallChoice; }
InstallChoice initialInstallChoice() const { return m_initialInstallChoice; }
/** @brief What kind of installation (partition) is requested **now**?
*
* This changes depending on what the user selects (unlike the initial choice,
* which is fixed by the configuration).
*
* @return the partitioning choice (may be @c NoChoice)
*/
InstallChoice installChoice() const { return m_installChoice; }
/** @brief The set of swap choices enabled for this install
*
* Not all swap choices are supported by each distro, so they
* can choose to enable or disable them. This method
* returns a set (hopefully non-empty) of configured swap choices.
*/
SwapChoiceSet swapChoices() const { return m_swapChoices; }
/** @brief What kind of swap selection is requested **initially**?
*
* @return The swap choice (may be @c NoSwap )
*/
SwapChoice initialSwapChoice() const { return m_initialSwapChoice; }
/** @brief What kind of swap selection is requested **now**?
*
* A choice of swap only makes sense when install choice Erase is made.
*
* @return The swap choice (may be @c NoSwap).
*/
SwapChoice swapChoice() const { return m_swapChoice; }
///@brief Is manual partitioning allowed (not explicitly disnabled in the config file)?
bool allowManualPartitioning() const;
public Q_SLOTS:
void setInstallChoice( int ); ///< Translates a button ID or so to InstallChoice
void setInstallChoice( InstallChoice );
void setSwapChoice( int ); ///< Translates a button ID or so to SwapChoice
void setSwapChoice( SwapChoice );
Q_SIGNALS:
void installChoiceChanged( InstallChoice );
void swapChoiceChanged( SwapChoice );
private:
PartitionActions::Choices::SwapChoiceSet m_swapChoices;
PartitionActions::Choices::InstallChoice m_initialInstallChoice = PartitionActions::Choices::NoChoice;
SwapChoiceSet m_swapChoices;
SwapChoice m_initialSwapChoice = NoSwap;
SwapChoice m_swapChoice = NoSwap;
InstallChoice m_initialInstallChoice = NoChoice;
InstallChoice m_installChoice = NoChoice;
qreal m_requiredStorageGiB = 0.0; // May duplicate setting in the welcome module
};
/** @brief Given a set of swap choices, return a sensible value from it.
*
* "Sensible" here means: if there is one value, use it; otherwise, use
* NoSwap if there are no choices, or if NoSwap is one of the choices, in the set.
* If that's not possible, any value from the set.
*/
Config::SwapChoice pickOne( const Config::SwapChoiceSet& s );
#endif

View File

@ -35,9 +35,9 @@ using CalamaresUtils::operator""_GiB;
using CalamaresUtils::operator""_MiB;
qint64
swapSuggestion( const qint64 availableSpaceB, Choices::SwapChoice swap )
swapSuggestion( const qint64 availableSpaceB, Config::SwapChoice swap )
{
if ( ( swap != Choices::SmallSwap ) && ( swap != Choices::FullSwap ) )
if ( ( swap != Config::SwapChoice::SmallSwap ) && ( swap != Config::SwapChoice::FullSwap ) )
{
return 0;
}
@ -48,7 +48,7 @@ swapSuggestion( const qint64 availableSpaceB, Choices::SwapChoice swap )
qint64 availableRamB = memory.first;
qreal overestimationFactor = memory.second;
bool ensureSuspendToDisk = swap == Choices::FullSwap;
bool ensureSuspendToDisk = swap == Config::SwapChoice::FullSwap;
// Ramp up quickly to 8GiB, then follow memory size
if ( availableRamB <= 4_GiB )
@ -149,7 +149,8 @@ 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
= ( o.swap == Config::SwapChoice::SmallSwap ) || ( o.swap == Config::SwapChoice::FullSwap );
bool shouldCreateSwap = false;
qint64 suggestedSwapSizeB = 0;
@ -246,52 +247,4 @@ doReplacePartition( PartitionCoreModule* core, Device* dev, Partition* partition
core->dumpQueue();
}
namespace Choices
{
const NamedEnumTable< SwapChoice >&
swapChoiceNames()
{
static const NamedEnumTable< SwapChoice > names { { QStringLiteral( "none" ), SwapChoice::NoSwap },
{ QStringLiteral( "small" ), SwapChoice::SmallSwap },
{ QStringLiteral( "suspend" ), SwapChoice::FullSwap },
{ QStringLiteral( "reuse" ), SwapChoice::ReuseSwap },
{ QStringLiteral( "file" ), SwapChoice::SwapFile } };
return names;
}
SwapChoice
pickOne( const SwapChoiceSet& s )
{
if ( s.count() == 0 )
{
return SwapChoice::NoSwap;
}
if ( s.count() == 1 )
{
return *( s.begin() );
}
if ( s.contains( SwapChoice::NoSwap ) )
{
return SwapChoice::NoSwap;
}
// Here, count > 1 but NoSwap is not a member.
return *( s.begin() );
}
const NamedEnumTable< InstallChoice >&
installChoiceNames()
{
static const NamedEnumTable< InstallChoice > names { { QStringLiteral( "none" ), InstallChoice::NoChoice },
{ QStringLiteral( "nochoice" ), InstallChoice::NoChoice },
{ QStringLiteral( "alongside" ), InstallChoice::Alongside },
{ QStringLiteral( "erase" ), InstallChoice::Erase },
{ QStringLiteral( "replace" ), InstallChoice::Replace },
{ QStringLiteral( "manual" ), InstallChoice::Manual } };
return names;
}
} // namespace Choices
} // namespace PartitionActions

View File

@ -10,7 +10,7 @@
#ifndef PARTITIONACTIONS_H
#define PARTITIONACTIONS_H
#include "utils/NamedEnum.h"
#include "core/Config.h"
#include <QSet>
#include <QString>
@ -27,36 +27,6 @@ namespace PartitionActions
*/
namespace Choices
{
/** @brief Choice 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)
};
using SwapChoiceSet = QSet< SwapChoice >;
const NamedEnumTable< SwapChoice >& swapChoiceNames();
/** @brief Given a set of swap choices, return a sensible value from it.
*
* "Sensible" here means: if there is one value, use it; otherwise, use
* NoSwap if there are no choices, or if NoSwap is one of the choices, in the set.
* If that's not possible, any value from the set.
*/
SwapChoice pickOne( const SwapChoiceSet& s );
enum InstallChoice
{
NoChoice,
Alongside,
Erase,
Replace,
Manual
};
const NamedEnumTable< InstallChoice >& installChoiceNames();
struct ReplacePartitionOptions
{
QString defaultFsType; // e.g. "ext4" or "btrfs"
@ -73,13 +43,13 @@ struct AutoPartitionOptions : ReplacePartitionOptions
{
QString efiPartitionMountPoint; // optional, e.g. "/boot"
quint64 requiredSpaceB; // estimated required space for root partition
SwapChoice swap;
Config::SwapChoice swap;
AutoPartitionOptions( const QString& fs,
const QString& luks,
const QString& efi,
qint64 requiredBytes,
SwapChoice s )
Config::SwapChoice s )
: ReplacePartitionOptions( fs, luks )
, efiPartitionMountPoint( efi )
, requiredSpaceB( requiredBytes > 0 ? static_cast< quint64 >( requiredBytes ) : 0 )

View File

@ -41,6 +41,7 @@
#include "partition/PartitionIterator.h"
#include "partition/PartitionQuery.h"
#include "utils/Logger.h"
#include "utils/Traits.h"
#include "utils/Variant.h"
// KPMcore
@ -97,6 +98,89 @@ private:
//- DeviceInfo ---------------------------------------------
// Some jobs have an updatePreview some don't
DECLARE_HAS_METHOD( updatePreview )
template < typename Job >
void
updatePreview( Job* job, const std::true_type& )
{
job->updatePreview();
}
template < typename Job >
void
updatePreview( Job* job, const std::false_type& )
{
}
template < typename Job >
void
updatePreview( Job* job )
{
updatePreview( job, has_updatePreview< Job > {} );
}
/**
* Owns the Device, PartitionModel and the jobs
*/
struct PartitionCoreModule::DeviceInfo
{
DeviceInfo( Device* );
~DeviceInfo();
QScopedPointer< Device > device;
QScopedPointer< PartitionModel > partitionModel;
const QScopedPointer< Device > immutableDevice;
// To check if LVM VGs are deactivated
bool isAvailable;
void forgetChanges();
bool isDirty() const;
const Calamares::JobList& jobs() const { return m_jobs; }
/** @brief Take the jobs of the given type that apply to @p partition
*
* Returns a job pointer to the job that has just been removed.
*/
template < typename Job >
Calamares::job_ptr takeJob( Partition* partition )
{
for ( auto it = m_jobs.begin(); it != m_jobs.end(); )
{
Job* job = qobject_cast< Job* >( it->data() );
if ( job && job->partition() == partition )
{
Calamares::job_ptr p = *it;
it = m_jobs.erase( it );
return p;
}
else
{
++it;
}
}
return Calamares::job_ptr( nullptr );
}
/** @brief Add a job of given type to the job list
*/
template < typename Job, typename... Args >
Calamares::Job* makeJob( Args... a )
{
auto* job = new Job( device.get(), a... );
updatePreview( job );
m_jobs << Calamares::job_ptr( job );
return job;
}
private:
Calamares::JobList m_jobs;
};
PartitionCoreModule::DeviceInfo::DeviceInfo( Device* _device )
: device( _device )
, partitionModel( new PartitionModel )
@ -111,7 +195,7 @@ PartitionCoreModule::DeviceInfo::~DeviceInfo() {}
void
PartitionCoreModule::DeviceInfo::forgetChanges()
{
jobs.clear();
m_jobs.clear();
for ( auto it = PartitionIterator::begin( device.data() ); it != PartitionIterator::end( device.data() ); ++it )
{
PartitionInfo::reset( *it );
@ -123,16 +207,18 @@ PartitionCoreModule::DeviceInfo::forgetChanges()
bool
PartitionCoreModule::DeviceInfo::isDirty() const
{
if ( !jobs.isEmpty() )
if ( !m_jobs.isEmpty() )
{
return true;
}
for ( auto it = PartitionIterator::begin( device.data() ); it != PartitionIterator::end( device.data() ); ++it )
{
if ( PartitionInfo::isDirty( *it ) )
{
return true;
}
}
return false;
}
@ -284,36 +370,30 @@ PartitionCoreModule::immutableDeviceCopy( const Device* device )
void
PartitionCoreModule::createPartitionTable( Device* device, PartitionTable::TableType type )
{
DeviceInfo* info = infoForDevice( device );
if ( info )
auto* deviceInfo = infoForDevice( device );
if ( deviceInfo )
{
// Creating a partition table wipes all the disk, so there is no need to
// keep previous changes
info->forgetChanges();
deviceInfo->forgetChanges();
OperationHelper helper( partitionModelForDevice( device ), this );
CreatePartitionTableJob* job = new CreatePartitionTableJob( device, type );
job->updatePreview();
info->jobs << Calamares::job_ptr( job );
deviceInfo->makeJob< CreatePartitionTableJob >( type );
}
}
void
PartitionCoreModule::createPartition( Device* device, Partition* partition, PartitionTable::Flags flags )
{
auto deviceInfo = infoForDevice( device );
auto* deviceInfo = infoForDevice( device );
Q_ASSERT( deviceInfo );
OperationHelper helper( partitionModelForDevice( device ), this );
CreatePartitionJob* job = new CreatePartitionJob( device, partition );
job->updatePreview();
deviceInfo->jobs << Calamares::job_ptr( job );
deviceInfo->makeJob< CreatePartitionJob >( partition );
if ( flags != KPM_PARTITION_FLAG( None ) )
{
SetPartFlagsJob* fJob = new SetPartFlagsJob( device, partition, flags );
deviceInfo->jobs << Calamares::job_ptr( fJob );
deviceInfo->makeJob< SetPartFlagsJob >( partition, flags );
PartitionInfo::setFlags( partition, flags );
}
}
@ -327,49 +407,39 @@ PartitionCoreModule::createVolumeGroup( QString& vgName, QVector< const Partitio
vgName.append( '_' );
}
CreateVolumeGroupJob* job = new CreateVolumeGroupJob( vgName, pvList, peSize );
job->updatePreview();
LvmDevice* device = new LvmDevice( vgName );
for ( const Partition* p : pvList )
{
device->physicalVolumes() << p;
}
DeviceInfo* deviceInfo = new DeviceInfo( device );
deviceInfo->partitionModel->init( device, osproberEntries() );
m_deviceModel->addDevice( device );
m_deviceInfos << deviceInfo;
deviceInfo->jobs << Calamares::job_ptr( job );
deviceInfo->makeJob< CreateVolumeGroupJob >( vgName, pvList, peSize );
refreshAfterModelChange();
}
void
PartitionCoreModule::resizeVolumeGroup( LvmDevice* device, QVector< const Partition* >& pvList )
{
DeviceInfo* deviceInfo = infoForDevice( device );
auto* deviceInfo = infoForDevice( device );
Q_ASSERT( deviceInfo );
ResizeVolumeGroupJob* job = new ResizeVolumeGroupJob( device, pvList );
deviceInfo->jobs << Calamares::job_ptr( job );
deviceInfo->makeJob< ResizeVolumeGroupJob >( device, pvList );
refreshAfterModelChange();
}
void
PartitionCoreModule::deactivateVolumeGroup( LvmDevice* device )
{
DeviceInfo* deviceInfo = infoForDevice( device );
auto* deviceInfo = infoForDevice( device );
Q_ASSERT( deviceInfo );
deviceInfo->isAvailable = false;
// TODO: this leaks
DeactivateVolumeGroupJob* job = new DeactivateVolumeGroupJob( device );
// DeactivateVolumeGroupJob needs to be immediately called
@ -381,20 +451,16 @@ PartitionCoreModule::deactivateVolumeGroup( LvmDevice* device )
void
PartitionCoreModule::removeVolumeGroup( LvmDevice* device )
{
DeviceInfo* deviceInfo = infoForDevice( device );
auto* deviceInfo = infoForDevice( device );
Q_ASSERT( deviceInfo );
RemoveVolumeGroupJob* job = new RemoveVolumeGroupJob( device );
deviceInfo->jobs << Calamares::job_ptr( job );
deviceInfo->makeJob< RemoveVolumeGroupJob >( device );
refreshAfterModelChange();
}
void
PartitionCoreModule::deletePartition( Device* device, Partition* partition )
{
auto deviceInfo = infoForDevice( device );
auto* deviceInfo = infoForDevice( device );
Q_ASSERT( deviceInfo );
OperationHelper helper( partitionModelForDevice( device ), this );
@ -417,29 +483,23 @@ PartitionCoreModule::deletePartition( Device* device, Partition* partition )
}
}
Calamares::JobList& jobs = deviceInfo->jobs;
const Calamares::JobList& jobs = deviceInfo->jobs();
if ( partition->state() == KPM_PARTITION_STATE( New ) )
{
// First remove matching SetPartFlagsJobs
for ( auto it = jobs.begin(); it != jobs.end(); )
// Take all the SetPartFlagsJob from the list and delete them
do
{
SetPartFlagsJob* job = qobject_cast< SetPartFlagsJob* >( it->data() );
if ( job && job->partition() == partition )
auto job_ptr = deviceInfo->takeJob< SetPartFlagsJob >( partition );
if ( job_ptr.data() )
{
it = jobs.erase( it );
continue;
}
else
{
++it;
}
}
} while ( false );
// Find matching CreatePartitionJob
auto it = std::find_if( jobs.begin(), jobs.end(), [partition]( Calamares::job_ptr job ) {
CreatePartitionJob* createJob = qobject_cast< CreatePartitionJob* >( job.data() );
return createJob && createJob->partition() == partition;
} );
if ( it == jobs.end() )
auto job_ptr = deviceInfo->takeJob< CreatePartitionJob >( partition );
if ( !job_ptr.data() )
{
cDebug() << "Failed to find a CreatePartitionJob matching the partition to remove";
return;
@ -452,7 +512,6 @@ PartitionCoreModule::deletePartition( Device* device, Partition* partition )
}
device->partitionTable()->updateUnallocated( *device );
jobs.erase( it );
// The partition is no longer referenced by either a job or the device
// partition list, so we have to delete it
delete partition;
@ -460,61 +519,49 @@ PartitionCoreModule::deletePartition( Device* device, Partition* partition )
else
{
// Remove any PartitionJob on this partition
for ( auto it = jobs.begin(); it != jobs.end(); )
do
{
PartitionJob* job = qobject_cast< PartitionJob* >( it->data() );
if ( job && job->partition() == partition )
auto job_ptr = deviceInfo->takeJob< PartitionJob >( partition );
if ( job_ptr.data() )
{
it = jobs.erase( it );
continue;
}
else
{
++it;
}
}
DeletePartitionJob* job = new DeletePartitionJob( device, partition );
job->updatePreview();
jobs << Calamares::job_ptr( job );
} while ( false );
deviceInfo->makeJob< DeletePartitionJob >( partition );
}
}
void
PartitionCoreModule::formatPartition( Device* device, Partition* partition )
{
auto deviceInfo = infoForDevice( device );
auto* deviceInfo = infoForDevice( device );
Q_ASSERT( deviceInfo );
OperationHelper helper( partitionModelForDevice( device ), this );
FormatPartitionJob* job = new FormatPartitionJob( device, partition );
deviceInfo->jobs << Calamares::job_ptr( job );
deviceInfo->makeJob< FormatPartitionJob >( partition );
}
void
PartitionCoreModule::resizePartition( Device* device, Partition* partition, qint64 first, qint64 last )
{
auto deviceInfo = infoForDevice( device );
auto* deviceInfo = infoForDevice( device );
Q_ASSERT( deviceInfo );
OperationHelper helper( partitionModelForDevice( device ), this );
ResizePartitionJob* job = new ResizePartitionJob( device, partition, first, last );
job->updatePreview();
deviceInfo->jobs << Calamares::job_ptr( job );
deviceInfo->makeJob< ResizePartitionJob >( partition, first, last );
}
void
PartitionCoreModule::setPartitionFlags( Device* device, Partition* partition, PartitionTable::Flags flags )
{
auto deviceInfo = infoForDevice( device );
auto* deviceInfo = infoForDevice( device );
Q_ASSERT( deviceInfo );
OperationHelper( partitionModelForDevice( device ), this );
SetPartFlagsJob* job = new SetPartFlagsJob( device, partition, flags );
deviceInfo->jobs << Calamares::job_ptr( job );
deviceInfo->makeJob< SetPartFlagsJob >( partition, flags );
PartitionInfo::setFlags( partition, flags );
}
Calamares::JobList
PartitionCoreModule::jobs() const
PartitionCoreModule::jobs( const Config* config ) const
{
Calamares::JobList lst;
QList< Device* > devices;
@ -542,10 +589,10 @@ PartitionCoreModule::jobs() const
for ( auto info : m_deviceInfos )
{
lst << info->jobs;
lst << info->jobs();
devices << info->device.data();
}
lst << Calamares::job_ptr( new FillGlobalStorageJob( devices, m_bootLoaderInstallPath ) );
lst << Calamares::job_ptr( new FillGlobalStorageJob( config, devices, m_bootLoaderInstallPath ) );
return lst;
}
@ -571,7 +618,7 @@ PartitionCoreModule::lvmPVs() const
bool
PartitionCoreModule::hasVGwithThisName( const QString& name ) const
{
auto condition = [name]( DeviceInfo* d ) {
auto condition = [ name ]( DeviceInfo* d ) {
return dynamic_cast< LvmDevice* >( d->device.data() ) && d->device.data()->name() == name;
};
@ -581,7 +628,7 @@ PartitionCoreModule::hasVGwithThisName( const QString& name ) const
bool
PartitionCoreModule::isInVG( const Partition* partition ) const
{
auto condition = [partition]( DeviceInfo* d ) {
auto condition = [ partition ]( DeviceInfo* d ) {
LvmDevice* vg = dynamic_cast< LvmDevice* >( d->device.data() );
return vg && vg->physicalVolumes().contains( partition );
};
@ -596,7 +643,7 @@ PartitionCoreModule::dumpQueue() const
for ( auto info : m_deviceInfos )
{
cDebug() << "## Device:" << info->device->name();
for ( auto job : info->jobs )
for ( const auto& job : info->jobs() )
{
cDebug() << "-" << job->prettyName();
}
@ -736,7 +783,7 @@ PartitionCoreModule::scanForLVMPVs()
for ( DeviceInfo* d : m_deviceInfos )
{
for ( auto job : d->jobs )
for ( const auto& job : d->jobs() )
{
// Including new LVM PVs
CreatePartitionJob* partJob = dynamic_cast< CreatePartitionJob* >( job.data() );
@ -914,9 +961,9 @@ PartitionCoreModule::layoutApply( Device* dev,
const QString boot = QStringLiteral( "/boot" );
const QString root = QStringLiteral( "/" );
const auto is_boot
= [&]( Partition* p ) -> bool { return PartitionInfo::mountPoint( p ) == boot || p->mountPoint() == boot; };
= [ & ]( Partition* p ) -> bool { return PartitionInfo::mountPoint( p ) == boot || p->mountPoint() == boot; };
const auto is_root
= [&]( Partition* p ) -> bool { return PartitionInfo::mountPoint( p ) == root || p->mountPoint() == root; };
= [ & ]( Partition* p ) -> bool { return PartitionInfo::mountPoint( p ) == root || p->mountPoint() == root; };
const bool separate_boot_partition
= std::find_if( partList.constBegin(), partList.constEnd(), is_boot ) != partList.constEnd();
@ -963,9 +1010,9 @@ PartitionCoreModule::revertAllDevices()
{
( *it )->isAvailable = true;
if ( !( *it )->jobs.empty() )
if ( !( *it )->jobs().empty() )
{
CreateVolumeGroupJob* vgJob = dynamic_cast< CreateVolumeGroupJob* >( ( *it )->jobs[ 0 ].data() );
CreateVolumeGroupJob* vgJob = dynamic_cast< CreateVolumeGroupJob* >( ( *it )->jobs().first().data() );
if ( vgJob )
{
@ -1031,7 +1078,7 @@ void
PartitionCoreModule::asyncRevertDevice( Device* dev, std::function< void() > callback )
{
QFutureWatcher< void >* watcher = new QFutureWatcher< void >();
connect( watcher, &QFutureWatcher< void >::finished, this, [watcher, callback] {
connect( watcher, &QFutureWatcher< void >::finished, this, [ watcher, callback ] {
callback();
watcher->deleteLater();
} );

View File

@ -15,6 +15,7 @@
#include "core/KPMHelpers.h"
#include "core/PartitionLayout.h"
#include "core/PartitionModel.h"
#include "jobs/PartitionJob.h"
#include "Job.h"
#include "partition/KPMManager.h"
@ -31,6 +32,7 @@
#include <functional>
class BootLoaderModel;
class Config;
class CreatePartitionJob;
class Device;
class DeviceModel;
@ -170,7 +172,7 @@ public:
* requested by the user.
* @return a list of jobs.
*/
Calamares::JobList jobs() const;
Calamares::JobList jobs( const Config* ) const;
bool hasRootMountPoint() const;
@ -232,28 +234,19 @@ Q_SIGNALS:
void deviceReverted( Device* device );
private:
CalamaresUtils::Partition::KPMManager m_kpmcore;
struct DeviceInfo;
void refreshAfterModelChange();
/**
* Owns the Device, PartitionModel and the jobs
*/
struct DeviceInfo
{
DeviceInfo( Device* );
~DeviceInfo();
QScopedPointer< Device > device;
QScopedPointer< PartitionModel > partitionModel;
const QScopedPointer< Device > immutableDevice;
Calamares::JobList jobs;
void doInit();
void updateHasRootMountPoint();
void updateIsDirty();
void scanForEfiSystemPartitions();
void scanForLVMPVs();
// To check if LVM VGs are deactivated
bool isAvailable;
DeviceInfo* infoForDevice( const Device* ) const;
CalamaresUtils::Partition::KPMManager m_kpmcore;
void forgetChanges();
bool isDirty() const;
};
QList< DeviceInfo* > m_deviceInfos;
QList< Partition* > m_efiSystemPartitions;
QVector< const Partition* > m_lvmPVs;
@ -265,14 +258,6 @@ private:
QString m_bootLoaderInstallPath;
PartitionLayout* m_partLayout;
void doInit();
void updateHasRootMountPoint();
void updateIsDirty();
void scanForEfiSystemPartitions();
void scanForLVMPVs();
DeviceInfo* infoForDevice( const Device* ) const;
OsproberEntryList m_osproberLines;
QMutex m_revertMutex;

View File

@ -165,12 +165,12 @@ PartitionLayout::execute( Device* dev,
{
QList< Partition* > partList;
// Map each partition entry to its requested size (0 when calculated later)
QMap< const PartitionLayout::PartitionEntry *, qint64 > partSizeMap;
QMap< const PartitionLayout::PartitionEntry*, qint64 > partSizeMap;
qint64 totalSize = lastSector - firstSector + 1;
qint64 availableSize = totalSize;
// Let's check if we have enough space for each partSize
for( const auto& part : qAsConst(m_partLayout) )
for ( const auto& part : qAsConst( m_partLayout ) )
{
qint64 size;
// Calculate partition size
@ -178,7 +178,7 @@ PartitionLayout::execute( Device* dev,
if ( part.partSize.isValid() )
{
// We need to ignore the percent-defined
if ( part.partSize.unit() != CalamaresUtils::Partition::SizeUnit::Percent)
if ( part.partSize.unit() != CalamaresUtils::Partition::SizeUnit::Percent )
{
size = part.partSize.toSectors( totalSize, dev->logicalSize() );
}
@ -200,15 +200,15 @@ PartitionLayout::execute( Device* dev,
continue;
}
partSizeMap.insert(&part, size);
partSizeMap.insert( &part, size );
availableSize -= size;
}
// Use partMinSize and see if we can do better afterward.
if (availableSize < 0)
if ( availableSize < 0 )
{
availableSize = totalSize;
for( const auto& part : qAsConst(m_partLayout) )
for ( const auto& part : qAsConst( m_partLayout ) )
{
qint64 size;
@ -218,7 +218,7 @@ PartitionLayout::execute( Device* dev,
}
else if ( part.partSize.isValid() )
{
if ( part.partSize.unit() != CalamaresUtils::Partition::SizeUnit::Percent)
if ( part.partSize.unit() != CalamaresUtils::Partition::SizeUnit::Percent )
{
size = part.partSize.toSectors( totalSize, dev->logicalSize() );
}
@ -232,22 +232,22 @@ PartitionLayout::execute( Device* dev,
size = 0;
}
partSizeMap.insert(&part, size);
partSizeMap.insert( &part, size );
availableSize -= size;
}
}
// Assign size for percentage-defined partitions
for( const auto& part : qAsConst(m_partLayout) )
for ( const auto& part : qAsConst( m_partLayout ) )
{
if ( part.partSize.unit() == CalamaresUtils::Partition::SizeUnit::Percent)
if ( part.partSize.unit() == CalamaresUtils::Partition::SizeUnit::Percent )
{
qint64 size = partSizeMap.value(&part);
qint64 size = partSizeMap.value( &part );
size = part.partSize.toSectors( availableSize + size, dev->logicalSize() );
if ( part.partMinSize.isValid() )
{
qint64 minSize = part.partMinSize.toSectors( totalSize, dev->logicalSize() );
if (minSize > size)
if ( minSize > size )
{
size = minSize;
}
@ -255,13 +255,13 @@ PartitionLayout::execute( Device* dev,
if ( part.partMaxSize.isValid() )
{
qint64 maxSize = part.partMaxSize.toSectors( totalSize, dev->logicalSize() );
if (maxSize < size)
if ( maxSize < size )
{
size = maxSize;
}
}
partSizeMap.insert(&part, size);
partSizeMap.insert( &part, size );
}
}
@ -270,12 +270,12 @@ PartitionLayout::execute( Device* dev,
// TODO: Refine partition sizes to make sure there is room for every partition
// Use a default (200-500M ?) minimum size for partition without minSize
for( const auto& part : qAsConst(m_partLayout) )
for ( const auto& part : qAsConst( m_partLayout ) )
{
qint64 size, end;
Partition* currentPartition = nullptr;
size = partSizeMap.value(&part);
size = partSizeMap.value( &part );
// Adjust partition size based on available space
if ( size > availableSize )
@ -283,7 +283,7 @@ PartitionLayout::execute( Device* dev,
size = availableSize;
}
end = firstSector + std::max(size - 1, Q_INT64_C(0));
end = firstSector + std::max( size - 1, Q_INT64_C( 0 ) );
if ( luksPassphrase.isEmpty() )
{

View File

@ -59,7 +59,8 @@ using Calamares::PrettyRadioButton;
using CalamaresUtils::Partition::findPartitionByPath;
using CalamaresUtils::Partition::isPartitionFreeSpace;
using CalamaresUtils::Partition::PartitionIterator;
using PartitionActions::Choices::SwapChoice;
using InstallChoice = Config::InstallChoice;
using SwapChoice = Config::SwapChoice;
/**
* @brief ChoicePage::ChoicePage is the default constructor. Called on startup as part of
@ -71,7 +72,6 @@ ChoicePage::ChoicePage( Config* config, QWidget* parent )
, m_config( config )
, m_nextEnabled( false )
, m_core( nullptr )
, m_choice( InstallChoice::NoChoice )
, m_isEfi( false )
, m_grp( nullptr )
, m_alongsideButton( nullptr )
@ -83,11 +83,7 @@ ChoicePage::ChoicePage( Config* config, QWidget* parent )
, m_beforePartitionBarsView( nullptr )
, m_beforePartitionLabelsView( nullptr )
, m_bootloaderComboBox( nullptr )
, m_lastSelectedDeviceIndex( -1 )
, m_enableEncryptionWidget( true )
, m_availableSwapChoices( config->swapChoices() )
, m_eraseSwapChoice( PartitionActions::Choices::pickOne( m_availableSwapChoices ) )
, m_allowManualPartitioning( true )
{
setupUi( this );
@ -95,7 +91,6 @@ ChoicePage::ChoicePage( Config* config, QWidget* parent )
m_defaultFsType = gs->value( "defaultFileSystemType" ).toString();
m_enableEncryptionWidget = gs->value( "enableLuksAutomatedPartitioning" ).toBool();
m_allowManualPartitioning = gs->value( "allowManualPartitioning" ).toBool();
if ( FileSystem::typeForName( m_defaultFsType ) == FileSystem::Unknown )
{
@ -154,7 +149,7 @@ ChoicePage::init( PartitionCoreModule* core )
// We need to do this because a PCM revert invalidates the deviceModel.
connect( core, &PartitionCoreModule::reverted, this, [=] {
connect( core, &PartitionCoreModule::reverted, this, [ = ] {
m_drivesCombo->setModel( core->deviceModel() );
m_drivesCombo->setCurrentIndex( m_lastSelectedDeviceIndex );
} );
@ -250,10 +245,9 @@ ChoicePage::setupChoices()
m_replaceButton->addToGroup( m_grp, InstallChoice::Replace );
// Fill up swap options
// .. TODO: only if enabled in the config
if ( m_availableSwapChoices.count() > 1 )
if ( m_config->swapChoices().count() > 1 )
{
m_eraseSwapChoiceComboBox = createCombo( m_availableSwapChoices, m_eraseSwapChoice );
m_eraseSwapChoiceComboBox = createCombo( m_config->swapChoices(), m_config->swapChoice() );
m_eraseButton->addOptionsComboBox( m_eraseSwapChoiceComboBox );
}
@ -275,10 +269,10 @@ ChoicePage::setupChoices()
#else
auto buttonSignal = &QButtonGroup::idToggled;
#endif
connect( m_grp, buttonSignal, this, [this]( int id, bool checked ) {
connect( m_grp, buttonSignal, this, [ this ]( int id, bool checked ) {
if ( checked ) // An action was picked.
{
m_choice = static_cast< InstallChoice >( id );
m_config->setInstallChoice( id );
updateNextEnabled();
emit actionChosen();
@ -288,7 +282,7 @@ ChoicePage::setupChoices()
if ( m_grp->checkedButton() == nullptr ) // If no other action is chosen, we must
{
// set m_choice to NoChoice and reset previews.
m_choice = InstallChoice::NoChoice;
m_config->setInstallChoice( InstallChoice::NoChoice );
updateNextEnabled();
emit actionChosen();
@ -339,6 +333,19 @@ ChoicePage::hideButtons()
m_somethingElseButton->hide();
}
void
ChoicePage::checkInstallChoiceRadioButton( InstallChoice c )
{
QSignalBlocker b( m_grp );
m_grp->setExclusive( false );
// If c == InstallChoice::NoChoice none will match and all are deselected
m_eraseButton->setChecked( InstallChoice::Erase == c );
m_replaceButton->setChecked( InstallChoice::Replace == c );
m_alongsideButton->setChecked( InstallChoice::Alongside == c );
m_somethingElseButton->setChecked( InstallChoice::Manual == c );
m_grp->setExclusive( true );
}
/**
* @brief ChoicePage::applyDeviceChoice handler for the selected event of the device
@ -359,11 +366,11 @@ ChoicePage::applyDeviceChoice()
if ( m_core->isDirty() )
{
ScanningDialog::run(
QtConcurrent::run( [=] {
QtConcurrent::run( [ = ] {
QMutexLocker locker( &m_coreMutex );
m_core->revertAllDevices();
} ),
[this] { continueApplyDeviceChoice(); },
[ this ] { continueApplyDeviceChoice(); },
this );
}
else
@ -392,7 +399,14 @@ ChoicePage::continueApplyDeviceChoice()
// Preview setup done. Now we show/hide choices as needed.
setupActions();
m_lastSelectedDeviceIndex = m_drivesCombo->currentIndex();
cDebug() << "Previous device" << m_lastSelectedDeviceIndex << "new device" << m_drivesCombo->currentIndex();
if ( m_lastSelectedDeviceIndex != m_drivesCombo->currentIndex() )
{
m_lastSelectedDeviceIndex = m_drivesCombo->currentIndex();
m_lastSelectedActionIndex = -1;
m_config->setInstallChoice( m_config->initialInstallChoice() );
checkInstallChoiceRadioButton( m_config->installChoice() );
}
emit actionChosen();
emit deviceChosen();
@ -405,7 +419,7 @@ ChoicePage::onActionChanged()
Device* currd = selectedDevice();
if ( currd )
{
applyActionChoice( currentChoice() );
applyActionChoice( m_config->installChoice() );
}
}
@ -414,15 +428,16 @@ ChoicePage::onEraseSwapChoiceChanged()
{
if ( m_eraseSwapChoiceComboBox )
{
m_eraseSwapChoice
= static_cast< PartitionActions::Choices::SwapChoice >( m_eraseSwapChoiceComboBox->currentData().toInt() );
m_config->setSwapChoice( m_eraseSwapChoiceComboBox->currentData().toInt() );
onActionChanged();
}
}
void
ChoicePage::applyActionChoice( ChoicePage::InstallChoice choice )
ChoicePage::applyActionChoice( InstallChoice choice )
{
cDebug() << "Prev" << m_lastSelectedActionIndex << "InstallChoice" << choice
<< Config::installChoiceNames().find( choice );
m_beforePartitionBarsView->selectionModel()->disconnect( SIGNAL( currentRowChanged( QModelIndex, QModelIndex ) ) );
m_beforePartitionBarsView->selectionModel()->clearSelection();
m_beforePartitionBarsView->selectionModel()->clearCurrentIndex();
@ -438,16 +453,16 @@ ChoicePage::applyActionChoice( ChoicePage::InstallChoice choice )
gs->value( "efiSystemPartition" ).toString(),
CalamaresUtils::GiBtoBytes(
gs->value( "requiredStorageGiB" ).toDouble() ),
m_eraseSwapChoice };
m_config->swapChoice() };
if ( m_core->isDirty() )
{
ScanningDialog::run(
QtConcurrent::run( [=] {
QtConcurrent::run( [ = ] {
QMutexLocker locker( &m_coreMutex );
m_core->revertDevice( selectedDevice() );
} ),
[=] {
[ = ] {
PartitionActions::doAutopartition( m_core, selectedDevice(), options );
emit deviceChosen();
},
@ -464,7 +479,7 @@ ChoicePage::applyActionChoice( ChoicePage::InstallChoice choice )
if ( m_core->isDirty() )
{
ScanningDialog::run(
QtConcurrent::run( [=] {
QtConcurrent::run( [ = ] {
QMutexLocker locker( &m_coreMutex );
m_core->revertDevice( selectedDevice() );
} ),
@ -484,14 +499,14 @@ ChoicePage::applyActionChoice( ChoicePage::InstallChoice choice )
if ( m_core->isDirty() )
{
ScanningDialog::run(
QtConcurrent::run( [=] {
QtConcurrent::run( [ = ] {
QMutexLocker locker( &m_coreMutex );
m_core->revertDevice( selectedDevice() );
} ),
[this] {
[ this ] {
// We need to reupdate after reverting because the splitter widget is
// not a true view.
updateActionChoicePreview( currentChoice() );
updateActionChoicePreview( m_config->installChoice() );
updateNextEnabled();
},
this );
@ -564,14 +579,14 @@ void
ChoicePage::onEncryptWidgetStateChanged()
{
EncryptWidget::Encryption state = m_encryptWidget->state();
if ( m_choice == InstallChoice::Erase )
if ( m_config->installChoice() == InstallChoice::Erase )
{
if ( state == EncryptWidget::Encryption::Confirmed || state == EncryptWidget::Encryption::Disabled )
{
applyActionChoice( m_choice );
applyActionChoice( m_config->installChoice() );
}
}
else if ( m_choice == InstallChoice::Replace )
else if ( m_config->installChoice() == InstallChoice::Replace )
{
if ( m_beforePartitionBarsView && m_beforePartitionBarsView->selectionModel()->currentIndex().isValid()
&& ( state == EncryptWidget::Encryption::Confirmed || state == EncryptWidget::Encryption::Disabled ) )
@ -586,7 +601,7 @@ ChoicePage::onEncryptWidgetStateChanged()
void
ChoicePage::onHomeCheckBoxStateChanged()
{
if ( currentChoice() == InstallChoice::Replace
if ( m_config->installChoice() == InstallChoice::Replace
&& m_beforePartitionBarsView->selectionModel()->currentIndex().isValid() )
{
doReplaceSelectedPartition( m_beforePartitionBarsView->selectionModel()->currentIndex() );
@ -597,12 +612,14 @@ ChoicePage::onHomeCheckBoxStateChanged()
void
ChoicePage::onLeave()
{
if ( m_choice == InstallChoice::Alongside )
if ( m_config->installChoice() == InstallChoice::Alongside )
{
doAlongsideApply();
}
if ( m_isEfi && ( m_choice == InstallChoice::Alongside || m_choice == InstallChoice::Replace ) )
if ( m_isEfi
&& ( m_config->installChoice() == InstallChoice::Alongside
|| m_config->installChoice() == InstallChoice::Replace ) )
{
QList< Partition* > efiSystemPartitions = m_core->efiSystemPartitions();
if ( efiSystemPartitions.count() == 1 )
@ -724,7 +741,7 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current )
// doReuseHomePartition *after* the device revert, for later use.
ScanningDialog::run(
QtConcurrent::run(
[this, current]( QString* homePartitionPath, bool doReuseHomePartition ) {
[ this, current ]( QString* homePartitionPath, bool doReuseHomePartition ) {
QMutexLocker locker( &m_coreMutex );
if ( m_core->isDirty() )
@ -805,7 +822,7 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current )
},
homePartitionPath,
doReuseHomePartition ),
[=] {
[ = ] {
m_reuseHomeCheckBox->setVisible( !homePartitionPath->isEmpty() );
if ( !homePartitionPath->isEmpty() )
m_reuseHomeCheckBox->setText( tr( "Reuse %1 as home partition for %2." )
@ -878,7 +895,7 @@ ChoicePage::updateDeviceStatePreview()
sm->deleteLater();
}
switch ( m_choice )
switch ( m_config->installChoice() )
{
case InstallChoice::Replace:
case InstallChoice::Alongside:
@ -903,7 +920,7 @@ ChoicePage::updateDeviceStatePreview()
* @param choice the chosen partitioning action.
*/
void
ChoicePage::updateActionChoicePreview( ChoicePage::InstallChoice choice )
ChoicePage::updateActionChoicePreview( InstallChoice choice )
{
Device* currentDevice = selectedDevice();
Q_ASSERT( currentDevice );
@ -955,7 +972,7 @@ ChoicePage::updateActionChoicePreview( ChoicePage::InstallChoice choice )
connect( m_afterPartitionSplitterWidget,
&PartitionSplitterWidget::partitionResized,
this,
[this, sizeLabel]( const QString& path, qint64 size, qint64 sizeNext ) {
[ this, sizeLabel ]( const QString& path, qint64 size, qint64 sizeNext ) {
Q_UNUSED( path )
sizeLabel->setText(
tr( "%1 will be shrunk to %2MiB and a new "
@ -969,7 +986,7 @@ ChoicePage::updateActionChoicePreview( ChoicePage::InstallChoice choice )
m_previewAfterFrame->show();
m_previewAfterLabel->show();
SelectionFilter filter = [this]( const QModelIndex& index ) {
SelectionFilter filter = [ this ]( const QModelIndex& index ) {
return PartUtils::canBeResized(
static_cast< Partition* >( index.data( PartitionModel::PartitionPtrRole ).value< void* >() ) );
};
@ -1017,7 +1034,7 @@ ChoicePage::updateActionChoicePreview( ChoicePage::InstallChoice choice )
eraseBootloaderLabel->setText( tr( "Boot loader location:" ) );
m_bootloaderComboBox = createBootloaderComboBox( eraseWidget );
connect( m_core->bootLoaderModel(), &QAbstractItemModel::modelReset, [this]() {
connect( m_core->bootLoaderModel(), &QAbstractItemModel::modelReset, [ this ]() {
if ( !m_bootloaderComboBox.isNull() )
{
Calamares::restoreSelectedBootLoader( *m_bootloaderComboBox, m_core->bootLoaderInstallPath() );
@ -1027,7 +1044,7 @@ ChoicePage::updateActionChoicePreview( ChoicePage::InstallChoice choice )
m_core,
&PartitionCoreModule::deviceReverted,
this,
[this]( Device* dev ) {
[ this ]( Device* dev ) {
Q_UNUSED( dev )
if ( !m_bootloaderComboBox.isNull() )
{
@ -1052,13 +1069,13 @@ ChoicePage::updateActionChoicePreview( ChoicePage::InstallChoice choice )
m_previewAfterFrame->show();
m_previewAfterLabel->show();
if ( m_choice == InstallChoice::Erase )
if ( m_config->installChoice() == InstallChoice::Erase )
{
m_selectLabel->hide();
}
else
{
SelectionFilter filter = [this]( const QModelIndex& index ) {
SelectionFilter filter = [ this ]( const QModelIndex& index ) {
return PartUtils::canBeReplaced(
static_cast< Partition* >( index.data( PartitionModel::PartitionPtrRole ).value< void* >() ) );
};
@ -1081,7 +1098,9 @@ ChoicePage::updateActionChoicePreview( ChoicePage::InstallChoice choice )
break;
}
if ( m_isEfi && ( m_choice == InstallChoice::Alongside || m_choice == InstallChoice::Replace ) )
if ( m_isEfi
&& ( m_config->installChoice() == InstallChoice::Alongside
|| m_config->installChoice() == InstallChoice::Replace ) )
{
QHBoxLayout* efiLayout = new QHBoxLayout;
layout->addLayout( efiLayout );
@ -1096,7 +1115,7 @@ ChoicePage::updateActionChoicePreview( ChoicePage::InstallChoice choice )
// Also handle selection behavior on beforeFrame.
QAbstractItemView::SelectionMode previewSelectionMode;
switch ( m_choice )
switch ( m_config->installChoice() )
{
case InstallChoice::Replace:
case InstallChoice::Alongside:
@ -1160,7 +1179,7 @@ ChoicePage::createBootloaderComboBox( QWidget* parent )
bcb->setModel( m_core->bootLoaderModel() );
// When the chosen bootloader device changes, we update the choice in the PCM
connect( bcb, QOverload< int >::of( &QComboBox::currentIndexChanged ), this, [this]( int newIndex ) {
connect( bcb, QOverload< int >::of( &QComboBox::currentIndexChanged ), this, [ this ]( int newIndex ) {
QComboBox* bcb = qobject_cast< QComboBox* >( sender() );
if ( bcb )
{
@ -1217,7 +1236,7 @@ ChoicePage::setupActions()
m_deviceInfoWidget->setPartitionTableType( PartitionTable::unknownTableType );
}
if ( m_allowManualPartitioning )
if ( m_config->allowManualPartitioning() )
{
m_somethingElseButton->show();
}
@ -1436,19 +1455,13 @@ ChoicePage::isNextEnabled() const
}
ChoicePage::InstallChoice
ChoicePage::currentChoice() const
{
return m_choice;
}
bool
ChoicePage::calculateNextEnabled() const
{
bool enabled = false;
auto sm_p = m_beforePartitionBarsView ? m_beforePartitionBarsView->selectionModel() : nullptr;
switch ( m_choice )
switch ( m_config->installChoice() )
{
case InstallChoice::NoChoice:
cDebug() << "No partitioning choice";
@ -1474,7 +1487,9 @@ ChoicePage::calculateNextEnabled() const
}
if ( m_isEfi && ( m_choice == InstallChoice::Alongside || m_choice == InstallChoice::Replace ) )
if ( m_isEfi
&& ( m_config->installChoice() == InstallChoice::Alongside
|| m_config->installChoice() == InstallChoice::Replace ) )
{
if ( m_core->efiSystemPartitions().count() == 0 )
{
@ -1483,7 +1498,7 @@ ChoicePage::calculateNextEnabled() const
}
}
if ( m_choice != InstallChoice::Manual && m_encryptWidget->isVisible() )
if ( m_config->installChoice() != InstallChoice::Manual && m_encryptWidget->isVisible() )
{
switch ( m_encryptWidget->state() )
{

View File

@ -15,8 +15,8 @@
#include "ui_ChoicePage.h"
#include "core/Config.h"
#include "core/OsproberEntry.h"
#include "core/PartitionActions.h"
#include <QMutex>
#include <QPointer>
@ -42,7 +42,7 @@ class PartitionCoreModule;
class Device;
using SwapChoiceSet = QSet< PartitionActions::Choices::SwapChoice >;
using SwapChoiceSet = Config::SwapChoiceSet;
/**
* @brief The ChoicePage class is the first page of the partitioning interface.
@ -53,8 +53,6 @@ class ChoicePage : public QWidget, private Ui::ChoicePage
{
Q_OBJECT
public:
using InstallChoice = PartitionActions::Choices::InstallChoice;
explicit ChoicePage( Config* config, QWidget* parent = nullptr );
virtual ~ChoicePage();
@ -72,13 +70,6 @@ public:
*/
bool isNextEnabled() const;
/**
* @brief currentChoice returns the enum Choice value corresponding to the
* currently selected partitioning mode (with a PrettyRadioButton).
* @return the enum Choice value.
*/
InstallChoice currentChoice() const;
/**
* @brief onLeave runs when control passes from this page to another one.
*/
@ -88,7 +79,7 @@ public:
* @brief applyActionChoice reacts to a choice of partitioning mode.
* @param choice the partitioning action choice.
*/
void applyActionChoice( ChoicePage::InstallChoice choice );
void applyActionChoice( Config::InstallChoice choice );
int lastSelectedDeviceIndex();
void setLastSelectedDeviceIndex( int index );
@ -114,6 +105,7 @@ private:
bool calculateNextEnabled() const;
void updateNextEnabled();
void setupChoices();
void checkInstallChoiceRadioButton( Config::InstallChoice choice ); ///< Sets the chosen button to "on"
QComboBox* createBootloaderComboBox( QWidget* parentButton );
Device* selectedDevice();
@ -123,7 +115,7 @@ private:
void continueApplyDeviceChoice(); // .. called after scan
void updateDeviceStatePreview();
void updateActionChoicePreview( ChoicePage::InstallChoice choice );
void updateActionChoicePreview( Config::InstallChoice choice );
void setupActions();
OsproberEntryList getOsproberEntriesForDevice( Device* device ) const;
void doAlongsideApply();
@ -138,8 +130,6 @@ private:
QMutex m_previewsMutex;
InstallChoice m_choice;
bool m_isEfi;
QComboBox* m_drivesCombo;
@ -161,14 +151,11 @@ private:
QPointer< QLabel > m_efiLabel;
QPointer< QComboBox > m_efiComboBox;
int m_lastSelectedDeviceIndex;
int m_lastSelectedDeviceIndex = -1;
int m_lastSelectedActionIndex = -1;
QString m_defaultFsType;
bool m_enableEncryptionWidget;
SwapChoiceSet m_availableSwapChoices; // What is available
PartitionActions::Choices::SwapChoice m_eraseSwapChoice; // what is selected
bool m_allowManualPartitioning;
QMutex m_coreMutex;
};

View File

@ -64,7 +64,7 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device,
replacePartResizerWidget();
connect( m_ui->formatRadioButton, &QAbstractButton::toggled, [this]( bool doFormat ) {
connect( m_ui->formatRadioButton, &QAbstractButton::toggled, [ this ]( bool doFormat ) {
replacePartResizerWidget();
m_ui->fileSystemLabel->setEnabled( doFormat );
@ -79,7 +79,7 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device,
} );
connect(
m_ui->fileSystemComboBox, &QComboBox::currentTextChanged, [this]( QString ) { updateMountPointPicker(); } );
m_ui->fileSystemComboBox, &QComboBox::currentTextChanged, [ this ]( QString ) { updateMountPointPicker(); } );
// File system
QStringList fsNames;

View File

@ -54,7 +54,7 @@ PartitionBarsView::PartitionBarsView( QWidget* parent )
setSelectionMode( QAbstractItemView::SingleSelection );
// Debug
connect( this, &PartitionBarsView::clicked, this, [=]( const QModelIndex& index ) {
connect( this, &PartitionBarsView::clicked, this, [ = ]( const QModelIndex& index ) {
cDebug() << "Clicked row" << index.row();
} );
setMouseTracking( true );
@ -399,7 +399,7 @@ void
PartitionBarsView::setSelectionModel( QItemSelectionModel* selectionModel )
{
QAbstractItemView::setSelectionModel( selectionModel );
connect( selectionModel, &QItemSelectionModel::selectionChanged, this, [=] { viewport()->repaint(); } );
connect( selectionModel, &QItemSelectionModel::selectionChanged, this, [ = ] { viewport()->repaint(); } );
}

View File

@ -520,7 +520,7 @@ void
PartitionLabelsView::setSelectionModel( QItemSelectionModel* selectionModel )
{
QAbstractItemView::setSelectionModel( selectionModel );
connect( selectionModel, &QItemSelectionModel::selectionChanged, this, [=] { viewport()->repaint(); } );
connect( selectionModel, &QItemSelectionModel::selectionChanged, this, [ = ] { viewport()->repaint(); } );
}

View File

@ -438,7 +438,7 @@ void
PartitionPage::onRevertClicked()
{
ScanningDialog::run(
QtConcurrent::run( [this] {
QtConcurrent::run( [ this ] {
QMutexLocker locker( &m_revertMutex );
int oldIndex = m_ui->deviceComboBox->currentIndex();
@ -446,7 +446,7 @@ PartitionPage::onRevertClicked()
m_ui->deviceComboBox->setCurrentIndex( ( oldIndex < 0 ) ? 0 : oldIndex );
updateFromCurrentDevice();
} ),
[this] {
[ this ] {
m_lastSelectedBootLoaderIndex = -1;
if ( m_ui->bootLoaderComboBox->currentIndex() < 0 )
{
@ -594,7 +594,7 @@ PartitionPage::updateFromCurrentDevice()
m_ui->partitionBarsView->selectionModel(),
&QItemSelectionModel::currentChanged,
this,
[=] {
[ = ] {
QModelIndex selectedIndex = m_ui->partitionBarsView->selectionModel()->currentIndex();
selectedIndex = selectedIndex.sibling( selectedIndex.row(), 0 );
m_ui->partitionBarsView->setCurrentIndex( selectedIndex );
@ -613,7 +613,7 @@ PartitionPage::updateFromCurrentDevice()
// model changes
connect( m_ui->partitionTreeView->selectionModel(),
&QItemSelectionModel::currentChanged,
[this]( const QModelIndex&, const QModelIndex& ) { updateButtons(); } );
[ this ]( const QModelIndex&, const QModelIndex& ) { updateButtons(); } );
connect( model, &QAbstractItemModel::modelReset, this, &PartitionPage::onPartitionModelReset );
}

View File

@ -159,7 +159,7 @@ PartitionSplitterWidget::setSplitPartition( const QString& path, qint64 minSize,
m_itemToResizePath.clear();
}
PartitionSplitterItem itemToResize = _findItem( m_items, [path]( PartitionSplitterItem& item ) -> bool {
PartitionSplitterItem itemToResize = _findItem( m_items, [ path ]( PartitionSplitterItem& item ) -> bool {
if ( path == item.itemPath )
{
item.status = PartitionSplitterItem::Resizing;
@ -184,7 +184,7 @@ PartitionSplitterWidget::setSplitPartition( const QString& path, qint64 minSize,
qint64 newSize = m_itemToResize.size - preferredSize;
m_itemToResize.size = preferredSize;
int opCount = _eachItem( m_items, [preferredSize]( PartitionSplitterItem& item ) -> bool {
int opCount = _eachItem( m_items, [ preferredSize ]( PartitionSplitterItem& item ) -> bool {
if ( item.status == PartitionSplitterItem::Resizing )
{
item.size = preferredSize;
@ -358,7 +358,7 @@ PartitionSplitterWidget::mouseMoveEvent( QMouseEvent* event )
m_itemToResize.size = qRound64( span * percent );
m_itemToResizeNext.size -= m_itemToResize.size - oldsize;
_eachItem( m_items, [this]( PartitionSplitterItem& item ) -> bool {
_eachItem( m_items, [ this ]( PartitionSplitterItem& item ) -> bool {
if ( item.status == PartitionSplitterItem::Resizing )
{
item.size = m_itemToResize.size;

View File

@ -140,7 +140,7 @@ PartitionViewStep::createSummaryWidget() const
widget->setLayout( mainLayout );
mainLayout->setMargin( 0 );
ChoicePage::InstallChoice choice = m_choicePage->currentChoice();
Config::InstallChoice choice = m_config->installChoice();
QFormLayout* formLayout = new QFormLayout( widget );
const int MARGIN = CalamaresUtils::defaultFontHeight() / 2;
@ -158,18 +158,18 @@ PartitionViewStep::createSummaryWidget() const
QString modeText;
switch ( choice )
{
case ChoicePage::InstallChoice::Alongside:
case Config::InstallChoice::Alongside:
modeText = tr( "Install %1 <strong>alongside</strong> another operating system." )
.arg( branding->shortVersionedName() );
break;
case ChoicePage::InstallChoice::Erase:
case Config::InstallChoice::Erase:
modeText = tr( "<strong>Erase</strong> disk and install %1." ).arg( branding->shortVersionedName() );
break;
case ChoicePage::InstallChoice::Replace:
case Config::InstallChoice::Replace:
modeText = tr( "<strong>Replace</strong> a partition with %1." ).arg( branding->shortVersionedName() );
break;
case ChoicePage::InstallChoice::NoChoice:
case ChoicePage::InstallChoice::Manual:
case Config::InstallChoice::NoChoice:
case Config::InstallChoice::Manual:
modeText = tr( "<strong>Manual</strong> partitioning." );
}
modeLabel->setText( modeText );
@ -182,27 +182,27 @@ PartitionViewStep::createSummaryWidget() const
QString modeText;
switch ( choice )
{
case ChoicePage::InstallChoice::Alongside:
case Config::InstallChoice::Alongside:
modeText = tr( "Install %1 <strong>alongside</strong> another operating system on disk "
"<strong>%2</strong> (%3)." )
.arg( branding->shortVersionedName() )
.arg( info.deviceNode )
.arg( info.deviceName );
break;
case ChoicePage::InstallChoice::Erase:
case Config::InstallChoice::Erase:
modeText = tr( "<strong>Erase</strong> disk <strong>%2</strong> (%3) and install %1." )
.arg( branding->shortVersionedName() )
.arg( info.deviceNode )
.arg( info.deviceName );
break;
case ChoicePage::InstallChoice::Replace:
case Config::InstallChoice::Replace:
modeText = tr( "<strong>Replace</strong> a partition on disk <strong>%2</strong> (%3) with %1." )
.arg( branding->shortVersionedName() )
.arg( info.deviceNode )
.arg( info.deviceName );
break;
case ChoicePage::InstallChoice::NoChoice:
case ChoicePage::InstallChoice::Manual:
case Config::InstallChoice::NoChoice:
case Config::InstallChoice::Manual:
modeText = tr( "<strong>Manual</strong> partitioning on disk <strong>%1</strong> (%2)." )
.arg( info.deviceNode )
.arg( info.deviceName );
@ -286,7 +286,7 @@ PartitionViewStep::next()
{
if ( m_choicePage == m_widget->currentWidget() )
{
if ( m_choicePage->currentChoice() == ChoicePage::InstallChoice::Manual )
if ( m_config->installChoice() == Config::InstallChoice::Manual )
{
if ( !m_manualPartitionPage )
{
@ -301,7 +301,7 @@ PartitionViewStep::next()
m_manualPartitionPage->onRevertClicked();
}
}
cDebug() << "Choice applied: " << m_choicePage->currentChoice();
cDebug() << "Choice applied: " << m_config->installChoice();
}
}
@ -368,9 +368,9 @@ PartitionViewStep::isAtEnd() const
{
if ( m_widget->currentWidget() == m_choicePage )
{
if ( m_choicePage->currentChoice() == ChoicePage::InstallChoice::Erase
|| m_choicePage->currentChoice() == ChoicePage::InstallChoice::Replace
|| m_choicePage->currentChoice() == ChoicePage::InstallChoice::Alongside )
auto choice = m_config->installChoice();
if ( Config::InstallChoice::Erase == choice || Config::InstallChoice::Replace == choice
|| Config::InstallChoice::Alongside == choice )
{
return true;
}
@ -386,10 +386,9 @@ PartitionViewStep::onActivate()
m_config->updateGlobalStorage();
// if we're coming back to PVS from the next VS
if ( m_widget->currentWidget() == m_choicePage
&& m_choicePage->currentChoice() == ChoicePage::InstallChoice::Alongside )
if ( m_widget->currentWidget() == m_choicePage && m_config->installChoice() == Config::InstallChoice::Alongside )
{
m_choicePage->applyActionChoice( ChoicePage::InstallChoice::Alongside );
m_choicePage->applyActionChoice( Config::InstallChoice::Alongside );
// m_choicePage->reset();
//FIXME: ReplaceWidget should be reset maybe?
}
@ -523,11 +522,7 @@ 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" );
}
QString efiSP = CalamaresUtils::getString( configurationMap, "efiSystemPartition", QStringLiteral( "/boot/efi" ) );
gs->insert( "efiSystemPartition", efiSP );
// Set up firmwareType global storage entry. This is used, e.g. by the bootloader module.
@ -554,8 +549,6 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
CalamaresUtils::getBool( configurationMap, "alwaysShowPartitionLabels", true ) );
gs->insert( "enableLuksAutomatedPartitioning",
CalamaresUtils::getBool( configurationMap, "enableLuksAutomatedPartitioning", true ) );
gs->insert( "allowManualPartitioning",
CalamaresUtils::getBool( configurationMap, "allowManualPartitioning", true ) );
// The defaultFileSystemType setting needs a bit more processing,
// as we want to cover various cases (such as different cases)
@ -586,7 +579,7 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
// because it could take a while. Then when it's done, we can set up the widgets
// and remove the spinner.
m_future = new QFutureWatcher< void >();
connect( m_future, &QFutureWatcher< void >::finished, this, [this] {
connect( m_future, &QFutureWatcher< void >::finished, this, [ this ] {
continueLoading();
this->m_future->deleteLater();
this->m_future = nullptr;
@ -597,7 +590,7 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
if ( configurationMap.contains( "partitionLayout" ) )
{
m_core->initLayout( configurationMap.values( "partitionLayout" ).at( 0 ).toList() );
m_core->initLayout( configurationMap.value( "partitionLayout" ).toList() );
}
else
{
@ -609,7 +602,7 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
Calamares::JobList
PartitionViewStep::jobs() const
{
return m_core->jobs();
return m_core->jobs( m_config );
}
Calamares::RequirementsList

View File

@ -46,7 +46,7 @@ ReplaceWidget::ReplaceWidget( PartitionCoreModule* core, QComboBox* devicesCombo
m_ui->bootStatusLabel->clear();
updateFromCurrentDevice( devicesComboBox );
connect( devicesComboBox, &QComboBox::currentTextChanged, this, [=]( const QString& /* text */ ) {
connect( devicesComboBox, &QComboBox::currentTextChanged, this, [ = ]( const QString& /* text */ ) {
updateFromCurrentDevice( devicesComboBox );
} );

View File

@ -47,7 +47,7 @@ ScanningDialog::run( const QFuture< void >& future,
theDialog->show();
QFutureWatcher< void >* watcher = new QFutureWatcher< void >();
connect( watcher, &QFutureWatcher< void >::finished, theDialog, [watcher, theDialog, callback] {
connect( watcher, &QFutureWatcher< void >::finished, theDialog, [ watcher, theDialog, callback ] {
watcher->deleteLater();
theDialog->hide();
theDialog->deleteLater();

View File

@ -46,17 +46,17 @@ VolumeGroupBaseDialog::VolumeGroupBaseDialog( QString& vgName, QVector< const Pa
updateOkButton();
updateTotalSize();
connect( ui->pvList, &QListWidget::itemChanged, this, [&]( QListWidgetItem* ) {
connect( ui->pvList, &QListWidget::itemChanged, this, [ & ]( QListWidgetItem* ) {
updateTotalSize();
updateOkButton();
} );
connect( ui->peSize, qOverload< int >( &QSpinBox::valueChanged ), this, [&]( int ) {
connect( ui->peSize, qOverload< int >( &QSpinBox::valueChanged ), this, [ & ]( int ) {
updateTotalSectors();
updateOkButton();
} );
connect( ui->vgName, &QLineEdit::textChanged, this, [&]( const QString& ) { updateOkButton(); } );
connect( ui->vgName, &QLineEdit::textChanged, this, [ & ]( const QString& ) { updateOkButton(); } );
}
VolumeGroupBaseDialog::~VolumeGroupBaseDialog()

View File

@ -15,7 +15,10 @@
#include <kpmcore/ops/createvolumegroupoperation.h>
#include <kpmcore/util/report.h>
CreateVolumeGroupJob::CreateVolumeGroupJob( QString& vgName, QVector< const Partition* > pvList, const qint32 peSize )
CreateVolumeGroupJob::CreateVolumeGroupJob( Device*,
QString& vgName,
QVector< const Partition* > pvList,
const qint32 peSize )
: m_vgName( vgName )
, m_pvList( pvList )
, m_peSize( peSize )

View File

@ -15,13 +15,14 @@
#include <QVector>
class Device;
class Partition;
class CreateVolumeGroupJob : public Calamares::Job
{
Q_OBJECT
public:
CreateVolumeGroupJob( QString& vgName, QVector< const Partition* > pvList, const qint32 peSize );
CreateVolumeGroupJob( Device*, QString& vgName, QVector< const Partition* > pvList, const qint32 peSize );
QString prettyName() const override;
QString prettyDescription() const override;

View File

@ -126,7 +126,7 @@ mapForPartition( Partition* partition, const QString& uuid )
return map;
}
FillGlobalStorageJob::FillGlobalStorageJob( QList< Device* > devices, const QString& bootLoaderPath )
FillGlobalStorageJob::FillGlobalStorageJob( const Config*, QList< Device* > devices, const QString& bootLoaderPath )
: m_devices( devices )
, m_bootLoaderPath( bootLoaderPath )
{

View File

@ -16,6 +16,7 @@
#include <QList>
#include <QVariantList>
class Config;
class Device;
class Partition;
@ -30,7 +31,8 @@ class FillGlobalStorageJob : public Calamares::Job
{
Q_OBJECT
public:
FillGlobalStorageJob( QList< Device* > devices, const QString& bootLoaderPath );
FillGlobalStorageJob( const Config* config, QList< Device* > devices, const QString& bootLoaderPath );
QString prettyName() const override;
QString prettyDescription() const override;
QString prettyStatusMessage() const override;

View File

@ -13,7 +13,7 @@
#include <kpmcore/ops/removevolumegroupoperation.h>
#include <kpmcore/util/report.h>
RemoveVolumeGroupJob::RemoveVolumeGroupJob( LvmDevice* device )
RemoveVolumeGroupJob::RemoveVolumeGroupJob( Device*, LvmDevice* device )
: m_device( device )
{
}

View File

@ -13,13 +13,14 @@
#include "Job.h"
#include "partition/KPMManager.h"
class Device;
class LvmDevice;
class RemoveVolumeGroupJob : public Calamares::Job
{
Q_OBJECT
public:
RemoveVolumeGroupJob( LvmDevice* device );
RemoveVolumeGroupJob( Device*, LvmDevice* device );
QString prettyName() const override;
QString prettyDescription() const override;

View File

@ -15,7 +15,7 @@
#include <kpmcore/ops/resizevolumegroupoperation.h>
#include <kpmcore/util/report.h>
ResizeVolumeGroupJob::ResizeVolumeGroupJob( LvmDevice* device, QVector< const Partition* >& partitionList )
ResizeVolumeGroupJob::ResizeVolumeGroupJob( Device*, LvmDevice* device, QVector< const Partition* >& partitionList )
: m_device( device )
, m_partitionList( partitionList )
{

View File

@ -15,6 +15,7 @@
#include <QVector>
class Device;
class LvmDevice;
class Partition;
@ -22,7 +23,7 @@ class ResizeVolumeGroupJob : public Calamares::Job
{
Q_OBJECT
public:
ResizeVolumeGroupJob( LvmDevice* device, QVector< const Partition* >& partitionList );
ResizeVolumeGroupJob( Device*, LvmDevice* device, QVector< const Partition* >& partitionList );
QString prettyName() const override;
QString prettyDescription() const override;

View File

@ -4,6 +4,8 @@
# This setting specifies the mount point of the EFI system partition. Some
# distributions (Fedora, Debian, Manjaro, etc.) use /boot/efi, others (KaOS,
# etc.) use just /boot.
#
# Defaults to "/boot/efi", may be empty (but weird effects ensue)
efiSystemPartition: "/boot/efi"
# This optional setting specifies the size of the EFI system partition.
@ -35,12 +37,16 @@ efiSystemPartition: "/boot/efi"
# 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).
#
# If *file* is enabled here, make sure to have the *fstab* module
# as well (later in the exec phase) so that the swap file is
# actually created.
userSwapChoices:
- none # Create no swap, use no swap
- small # Up to 4GB
- suspend # At least main memory size
# - reuse # Re-use existing swap, but don't create any (unsupported right now)
# - file # To swap file instead of partition (unsupported right now)
- file # To swap file instead of partition
# LEGACY SETTINGS (these will generate a warning)
# ensureSuspendToDisk: true
@ -72,8 +78,15 @@ alwaysShowPartitionLabels: true
#
# The default is "none"
#
# TODO: this isn't implemented
# initialPartitioningChoice: none
initialPartitioningChoice: none
#
# Similarly, some of the installation choices may offer a choice of swap;
# the available choices depend on *userSwapChoices*, above, and this
# setting can be used to pick a specific one.
#
# The default is "none" (no swap) if that is one of the enabled options, otherwise
# one of the items from the options.
initialSwapChoice: none
# Default filesystem type, used when a "new" partition is made.
#

View File

@ -22,6 +22,7 @@ properties:
allowManualPartitioning: { type: boolean, default: true }
partitionLayout: { type: array } # TODO: specify items
initialPartitioningChoice: { type: string, enum: [ none, erase, replace, alongside, manual ] }
initialSwapChoice: { type: string, enum: [ none, small, suspend, reuse, file ] }
requiredStorage: { type: number }
required: