Merge branch 'issue-1110'

SEE #1110

There isn't really anything to fix: partitions are aligned to 1MiB
boundaries now. Manjaro 18.0.3 is probably before the early-august
commit that added that.

While here, add some better partitioning-debugging and cleanups.
This commit is contained in:
Adriaan de Groot 2019-03-20 18:21:34 +01:00
commit 228971ce0b
25 changed files with 268 additions and 56 deletions

View File

@ -24,6 +24,9 @@
# #
# SKIP_MODULES : a space or semicolon-separated list of directory names # SKIP_MODULES : a space or semicolon-separated list of directory names
# under src/modules that should not be built. # under src/modules that should not be built.
# USE_<foo> : fills in SKIP_MODULES for modules called <foo>-<something>
# BUILD_<foo> : choose additional things to build
# DEBUG_<foo> : special developer flags for debugging
# #
# Example usage: # Example usage:
# #
@ -62,7 +65,8 @@ option( WITH_KF5Crash "Enable crash reporting with KCrash." ON )
# all the implementations are enabled (this just means they are # all the implementations are enabled (this just means they are
# **available** to `settings.conf`, not that they are used). # **available** to `settings.conf`, not that they are used).
# #
# Currently, no USE_<foo> variables exist. # Currently, only USE_services is in use (to pick only one of the two
# modules, systemd or openrc).
set( USE_services "" CACHE STRING "Select the services module to use" ) set( USE_services "" CACHE STRING "Select the services module to use" )
### Calamares application info ### Calamares application info

View File

@ -19,27 +19,41 @@
### ###
# #
# Support functions for building plugins. # Support functions for building plugins.
#
# Usage:
#
# calamares_add_library(
# library-name
# EXPORT_MACRO macro-name
# TARGET_TYPE <STATIC|MODULE|...>
# EXPORT export-name
# VERSION version
# SOVERSION version
# INSTALL_BINDIR dir
# RESOURCES resource-file
# SOURCES source-file...
# UI ui-file...
# LINK_LIBRARIES lib...
# LINK_PRIVATE_LIBRARIES lib...
# COMPILE_DEFINITIONS def...
# [NO_INSTALL]
# [NO_VERSION]
# )
#
# The COMPILE_DEFINITIONS are set on the resulting module with a suitable
# flag (i.e. `-D`) so only state the name (optionally, also the value)
# without a `-D` prefixed to it. Pass in a CMake list as needed.
include( CMakeParseArguments ) include( CMakeParseArguments )
function(calamares_add_library) function(calamares_add_library)
# parse arguments (name needs to be saved before passing ARGN into the macro) # parse arguments (name needs to be saved before passing ARGN into the macro)
set(NAME ${ARGV0}) set(NAME ${ARGV0})
set(options NO_INSTALL NO_VERSION) set(options NO_INSTALL NO_VERSION)
set(oneValueArgs NAME TYPE EXPORT_MACRO TARGET TARGET_TYPE EXPORT VERSION SOVERSION INSTALL_BINDIR RESOURCES) set(oneValueArgs NAME EXPORT_MACRO TARGET_TYPE EXPORT VERSION SOVERSION INSTALL_BINDIR RESOURCES)
set(multiValueArgs SOURCES UI LINK_LIBRARIES LINK_PRIVATE_LIBRARIES COMPILE_DEFINITIONS QT5_MODULES) set(multiValueArgs SOURCES UI LINK_LIBRARIES LINK_PRIVATE_LIBRARIES COMPILE_DEFINITIONS)
cmake_parse_arguments(LIBRARY "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) cmake_parse_arguments(LIBRARY "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(LIBRARY_NAME ${NAME}) set(LIBRARY_NAME ${NAME})
# message("*** Arguments for ${LIBRARY_NAME}")
# message("Sources: ${LIBRARY_SOURCES}")
# message("Link libraries: ${LIBRARY_LINK_LIBRARIES}")
# message("UI: ${LIBRARY_UI}")
# message("TARGET_TYPE: ${LIBRARY_TARGET_TYPE}")
# message("EXPORT_MACRO: ${LIBRARY_EXPORT_MACRO}")
# message("NO_INSTALL: ${LIBRARY_NO_INSTALL}")
set(target ${LIBRARY_NAME}) set(target ${LIBRARY_NAME})
# qt stuff # qt stuff
@ -76,13 +90,8 @@ function(calamares_add_library)
endif() endif()
if(LIBRARY_COMPILE_DEFINITIONS) if(LIBRARY_COMPILE_DEFINITIONS)
# Dear CMake, i hate you! Sincerely, domme set( _lib_definitions "${LIBRARY_EXPORT_MACRO}" ${LIBRARY_COMPILE_DEFINITIONS} )
# At least in CMake 2.8.8, you CANNOT set more than one COMPILE_DEFINITIONS value set_target_properties(${target} PROPERTIES COMPILE_DEFINITIONS "${_lib_definitions}")
# only takes the first one if called multiple times or bails out with wrong number of arguments
# when passing in a list, thus i redefine the export macro here in hope it won't mess up other targets
add_definitions( "-D${LIBRARY_EXPORT_MACRO}" )
set_target_properties(${target} PROPERTIES COMPILE_DEFINITIONS ${LIBRARY_COMPILE_DEFINITIONS})
endif() endif()
# add link targets # add link targets
@ -119,9 +128,6 @@ function(calamares_add_library)
set(LIBRARY_INSTALL_LIBDIR "${LIBRARY_INSTALL_BINDIR}") set(LIBRARY_INSTALL_LIBDIR "${LIBRARY_INSTALL_BINDIR}")
endif() endif()
#message("INSTALL_BINDIR: ${LIBRARY_INSTALL_BINDIR}")
#message("INSTALL_LIBDIR: ${LIBRARY_INSTALL_LIBDIR}")
# make installation optional, maybe useful for dummy plugins one day # make installation optional, maybe useful for dummy plugins one day
if(NOT LIBRARY_NO_INSTALL) if(NOT LIBRARY_NO_INSTALL)
include(GNUInstallDirs) include(GNUInstallDirs)

View File

@ -40,6 +40,10 @@
# [SHARED_LIB] # [SHARED_LIB]
# [EMERGENCY] # [EMERGENCY]
# ) # )
#
# The COMPILE_DEFINITIONS are set on the resulting module with a suitable
# flag (i.e. `-D`) so only state the name (optionally, also the value)
# without a `-D` prefixed to it.
include( CMakeParseArguments ) include( CMakeParseArguments )
include( CalamaresAddLibrary ) include( CalamaresAddLibrary )

View File

@ -114,6 +114,7 @@ main( int argc, char* argv[] )
} }
else else
{ {
// Here we have not yet set-up the logger system, so qDebug() is ok
auto instancelist = guard.instances(); auto instancelist = guard.instances();
qDebug() << "Calamares is already running, shutting down."; qDebug() << "Calamares is already running, shutting down.";
if ( instancelist.count() > 0 ) if ( instancelist.count() > 0 )

View File

@ -16,6 +16,7 @@ set( libSources
CppJob.cpp CppJob.cpp
GlobalStorage.cpp GlobalStorage.cpp
Job.cpp Job.cpp
JobExample.cpp
JobQueue.cpp JobQueue.cpp
ProcessJob.cpp ProcessJob.cpp
Settings.cpp Settings.cpp

View File

@ -0,0 +1,42 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2019, Adriaan de Groot <groot.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "JobExample.h"
namespace Calamares
{
QString
NamedJob::prettyName() const
{
return tr( "Example job (%1)" ).arg( m_name );
}
JobResult
GoodJob::exec()
{
return JobResult::ok();
}
JobResult
FailJob::exec()
{
return JobResult::error( tr( "Job failed (%1)" ).arg( m_name ), tr( "Programmed job failure was explicitly requested." ) );
}
} // namespace

View File

@ -0,0 +1,73 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2019, Adriaan de Groot <groot.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CALAMARES_JOB_EXAMPLE_H
#define CALAMARES_JOB_EXAMPLE_H
#include "Job.h"
namespace Calamares {
/** @brief A Job with a name
*
* This includes a default implementation of prettyName(),
* but is only used as a base for FailJob and GoodJob,
* which are support / bogus classes.
*/
class DLLEXPORT NamedJob : public Job
{
public:
explicit NamedJob( const QString& name, QObject* parent = nullptr )
: Job( parent )
, m_name( name )
{
}
virtual QString prettyName() const override;
protected:
const QString m_name;
} ;
/// @brief Job does nothing, always succeeds
class DLLEXPORT GoodJob : public NamedJob
{
public:
explicit GoodJob( const QString& name, QObject* parent = nullptr )
: NamedJob( name, parent )
{
}
virtual JobResult exec() override;
} ;
/// @brief Job does nothing, always fails
class DLLEXPORT FailJob : public NamedJob
{
public:
explicit FailJob( const QString& name, QObject* parent = nullptr )
: NamedJob( name, parent )
{
}
virtual JobResult exec() override;
} ;
} // namespace Calamares
#endif // CALAMARES_JOB_EXAMPLE_H

View File

@ -6,6 +6,10 @@ if ( KPMcore_FOUND )
include_directories( ${KPMCORE_INCLUDE_DIR} ) include_directories( ${KPMCORE_INCLUDE_DIR} )
include_directories( ${PROJECT_BINARY_DIR}/src/libcalamares ) include_directories( ${PROJECT_BINARY_DIR}/src/libcalamares )
if ( KPMcore_VERSION VERSION_GREATER "3.3.0")
add_definitions(-DWITH_KPMCOREGT33) # kpmcore greater than 3.3
endif()
# The PartitionIterator is a small class, and it's easiest -- but also a # The PartitionIterator is a small class, and it's easiest -- but also a
# gross hack -- to just compile it again from the partition module tree. # gross hack -- to just compile it again from the partition module tree.
calamares_add_plugin( fsresizer calamares_add_plugin( fsresizer

View File

@ -120,7 +120,12 @@ ResizeFSJob::PartitionMatch
ResizeFSJob::findPartition( CoreBackend* backend ) ResizeFSJob::findPartition( CoreBackend* backend )
{ {
using DeviceList = QList< Device* >; using DeviceList = QList< Device* >;
DeviceList devices = backend->scanDevices( false ); #ifdef WITH_KPMCOREGT33
DeviceList devices = backend->scanDevices( /* not includeReadOnly, not includeLoopback */ ScanFlag(0) );
#else
DeviceList devices = backend->scanDevices( /* excludeReadOnly */ true );
#endif
cDebug() << "ResizeFSJob found" << devices.count() << "devices."; cDebug() << "ResizeFSJob found" << devices.count() << "devices.";
for ( DeviceList::iterator dev_it = devices.begin(); dev_it != devices.end(); ++dev_it ) for ( DeviceList::iterator dev_it = devices.begin(); dev_it != devices.end(); ++dev_it )
{ {

View File

@ -22,6 +22,8 @@
#include "keyboardglobal.h" #include "keyboardglobal.h"
#include "utils/Logger.h"
//### //###
//### Public methods //### Public methods
//### //###
@ -52,7 +54,7 @@ QMap<QString, QString> KeyboardGlobal::parseKeyboardModels(QString filepath)
fh.open(QIODevice::ReadOnly); fh.open(QIODevice::ReadOnly);
if (!fh.isOpen()) { if (!fh.isOpen()) {
qDebug() << "X11 Keyboard model definitions not found!"; cDebug() << "X11 Keyboard model definitions not found!";
return models; return models;
} }
@ -100,7 +102,7 @@ QMap< QString, KeyboardGlobal::KeyboardInfo > KeyboardGlobal::parseKeyboardLayou
fh.open(QIODevice::ReadOnly); fh.open(QIODevice::ReadOnly);
if (!fh.isOpen()) { if (!fh.isOpen()) {
qDebug() << "X11 Keyboard layout definitions not found!"; cDebug() << "X11 Keyboard layout definitions not found!";
return layouts; return layouts;
} }

View File

@ -1,8 +1,10 @@
# When debugging the timezone widget, add this debugging definition # When debugging the timezone widget, add this debugging definition
# to have a debugging-friendly timezone widget, debug logging, # to have a debugging-friendly timezone widget, debug logging,
# and no intrusive timezone-setting while clicking around. # and no intrusive timezone-setting while clicking around.
# option( DEBUG_TIMEZONES "Debug-friendly timezone widget." OFF )
# add_definitions( -DDEBUG_TIMEZONES ) if( DEBUG_TIMEZONES )
add_definitions( -DDEBUG_TIMEZONES )
endif()
include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui ) include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui )

View File

@ -1,3 +1,18 @@
# When debugging the partitioning widget, or experimenting, you may
# want to allow unsafe partitioning choices (e.g. doing things to the
# current disk). Set DEBUG_PARTITION_UNSAFE to allow that (it turns off
# some filtering of devices).
option( DEBUG_PARTITION_UNSAFE "Allow unsafe partitioning choices." OFF )
option( DEBUG_PARTITION_LAME "Unsafe partitioning will error out on exec." ON )
set( _partition_defs )
if( DEBUG_PARTITION_UNSAFE )
if( DEBUG_PARTITION_LAME )
list( APPEND _partition_defs DEBUG_PARTITION_LAME )
endif()
list( APPEND _partition_defs DEBUG_PARTITION_UNSAFE )
endif()
find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE) find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE)
include(KDEInstallDirs) include(KDEInstallDirs)
@ -84,6 +99,7 @@ if ( KPMcore_FOUND )
kpmcore kpmcore
calamaresui calamaresui
KF5::CoreAddons KF5::CoreAddons
COMPILE_DEFINITIONS ${_partition_defs}
SHARED_LIB SHARED_LIB
) )
else() else()

View File

@ -107,8 +107,18 @@ QList< Device* > getDevices( DeviceType which, qint64 minimumSize )
bool writableOnly = (which == DeviceType::WritableOnly); bool writableOnly = (which == DeviceType::WritableOnly);
CoreBackend* backend = CoreBackendManager::self()->backend(); CoreBackend* backend = CoreBackendManager::self()->backend();
DeviceList devices = backend->scanDevices( true ); #ifdef WITH_KPMCOREGT33
DeviceList devices = backend->scanDevices( /* not includeReadOnly, not includeLoopback */ ScanFlag(0) );
#else
DeviceList devices = backend->scanDevices( /* excludeReadOnly */ true );
#endif
#ifdef DEBUG_PARTITION_UNSAFE
cWarning() << "Allowing unsafe partitioning choices." << devices.count() << "candidates.";
#ifdef DEBUG_PARTITION_LAME
cDebug() << ".. it has been lamed, and will fail.";
#endif
#else
cDebug() << "Removing unsuitable devices:" << devices.count() << "candidates."; cDebug() << "Removing unsuitable devices:" << devices.count() << "candidates.";
// Remove the device which contains / from the list // Remove the device which contains / from the list
@ -142,6 +152,7 @@ QList< Device* > getDevices( DeviceType which, qint64 minimumSize )
} }
else else
++it; ++it;
#endif
return devices; return devices;
} }

View File

@ -67,7 +67,7 @@ isPartitionFreeSpace( Partition* partition )
bool bool
isPartitionNew( Partition* partition ) isPartitionNew( Partition* partition )
{ {
return partition->state() == Partition::StateNew; return partition->state() == KPM_PARTITION_STATE(New);
} }
@ -127,11 +127,11 @@ createNewPartition( PartitionNode* parent,
role, role,
fs, fs->firstSector(), fs->lastSector(), fs, fs->firstSector(), fs->lastSector(),
QString() /* path */, QString() /* path */,
PartitionTable::FlagNone /* availableFlags */, KPM_PARTITION_FLAG(None) /* availableFlags */,
QString() /* mountPoint */, QString() /* mountPoint */,
false /* mounted */, false /* mounted */,
flags /* activeFlags */, flags /* activeFlags */,
Partition::StateNew KPM_PARTITION_STATE(New)
); );
} }
@ -169,11 +169,11 @@ createNewEncryptedPartition( PartitionNode* parent,
PartitionRole( newRoles ), PartitionRole( newRoles ),
fs, fs->firstSector(), fs->lastSector(), fs, fs->firstSector(), fs->lastSector(),
QString() /* path */, QString() /* path */,
PartitionTable::FlagNone /* availableFlags */, KPM_PARTITION_FLAG(None) /* availableFlags */,
QString() /* mountPoint */, QString() /* mountPoint */,
false /* mounted */, false /* mounted */,
flags /* activeFlags */, flags /* activeFlags */,
Partition::StateNew ); KPM_PARTITION_STATE(New) );
return p; return p;
} }

View File

@ -33,6 +33,16 @@ class Partition;
class PartitionNode; class PartitionNode;
class PartitionRole; class PartitionRole;
#ifdef WITH_KPMCOREGT33
#define KPM_PARTITION_FLAG(x) PartitionTable::Flag::x
#define KPM_PARTITION_STATE(x) Partition::State::x
#define KPM_PARTITION_FLAG_ESP PartitionTable::Flag::Boot
#else
#define KPM_PARTITION_FLAG(x) PartitionTable::Flag##x
#define KPM_PARTITION_STATE(x) Partition::State##x
#define KPM_PARTITION_FLAG_ESP PartitionTable::FlagEsp
#endif
/** /**
* Helper functions to manipulate partitions * Helper functions to manipulate partitions
*/ */

View File

@ -43,7 +43,7 @@
namespace PartUtils namespace PartUtils
{ {
static QString QString
convenienceName( const Partition* const candidate ) convenienceName( const Partition* const candidate )
{ {
if ( !candidate->mountPoint().isEmpty() ) if ( !candidate->mountPoint().isEmpty() )
@ -407,7 +407,7 @@ isEfiBootable( const Partition* candidate )
auto flags = PartitionInfo::flags( candidate ); auto flags = PartitionInfo::flags( candidate );
/* If bit 17 is set, old-style Esp flag, it's OK */ /* If bit 17 is set, old-style Esp flag, it's OK */
if ( flags.testFlag( PartitionTable::FlagEsp ) ) if ( flags.testFlag( KPM_PARTITION_FLAG_ESP ) )
return true; return true;
/* Otherwise, if it's a GPT table, Boot (bit 0) is the same as Esp */ /* Otherwise, if it's a GPT table, Boot (bit 0) is the same as Esp */
@ -425,7 +425,7 @@ isEfiBootable( const Partition* candidate )
const PartitionTable* table = dynamic_cast<const PartitionTable*>( root ); const PartitionTable* table = dynamic_cast<const PartitionTable*>( root );
cDebug() << " .. partition table" << (void *)table << "type" << ( table ? table->type() : PartitionTable::TableType::unknownTableType ); cDebug() << " .. partition table" << (void *)table << "type" << ( table ? table->type() : PartitionTable::TableType::unknownTableType );
return table && ( table->type() == PartitionTable::TableType::gpt ) && return table && ( table->type() == PartitionTable::TableType::gpt ) &&
flags.testFlag( PartitionTable::FlagBoot ); flags.testFlag( KPM_PARTITION_FLAG(Boot) );
} }
QString QString

View File

@ -46,6 +46,15 @@ enum SizeUnit
GiB GiB
}; };
/**
* @brief Provides a nice human-readable name for @p candidate
*
* The most-specific human-readable name for the partition @p candidate
* is returned (e.g. device name, or partition path). In the worst
* case, a string representation of (void *)candidate is returned.
*/
QString convenienceName( const Partition* const candidate );
/** /**
* @brief canBeReplaced checks whether the given Partition satisfies the criteria * @brief canBeReplaced checks whether the given Partition satisfies the criteria
* for replacing it with the new OS. * for replacing it with the new OS.

View File

@ -129,11 +129,11 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO
FileSystem::Fat32, FileSystem::Fat32,
firstFreeSector, firstFreeSector,
lastSector, lastSector,
PartitionTable::FlagNone KPM_PARTITION_FLAG(None)
); );
PartitionInfo::setFormat( efiPartition, true ); PartitionInfo::setFormat( efiPartition, true );
PartitionInfo::setMountPoint( efiPartition, o.efiPartitionMountPoint ); PartitionInfo::setMountPoint( efiPartition, o.efiPartitionMountPoint );
core->createPartition( dev, efiPartition, PartitionTable::FlagEsp ); core->createPartition( dev, efiPartition, KPM_PARTITION_FLAG_ESP );
firstFreeSector = lastSector + 1; firstFreeSector = lastSector + 1;
} }
else else
@ -178,7 +178,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO
FileSystem::LinuxSwap, FileSystem::LinuxSwap,
lastSectorForRoot + 1, lastSectorForRoot + 1,
dev->totalLogical() - 1, dev->totalLogical() - 1,
PartitionTable::FlagNone KPM_PARTITION_FLAG(None)
); );
} }
else else
@ -191,7 +191,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO
lastSectorForRoot + 1, lastSectorForRoot + 1,
dev->totalLogical() - 1, dev->totalLogical() - 1,
o.luksPassphrase, o.luksPassphrase,
PartitionTable::FlagNone KPM_PARTITION_FLAG(None)
); );
} }
PartitionInfo::setFormat( swapPartition, true ); PartitionInfo::setFormat( swapPartition, true );

View File

@ -45,6 +45,9 @@
#include "jobs/SetPartitionFlagsJob.h" #include "jobs/SetPartitionFlagsJob.h"
#include "utils/CalamaresUtils.h" #include "utils/CalamaresUtils.h"
#ifdef DEBUG_PARTITION_LAME
#include "JobExample.h"
#endif
#include "Typedefs.h" #include "Typedefs.h"
#include "utils/Logger.h" #include "utils/Logger.h"
@ -296,7 +299,7 @@ PartitionCoreModule::createPartition( Device* device,
deviceInfo->jobs << Calamares::job_ptr( job ); deviceInfo->jobs << Calamares::job_ptr( job );
if ( flags != PartitionTable::FlagNone ) if ( flags != KPM_PARTITION_FLAG(None) )
{ {
SetPartFlagsJob* fJob = new SetPartFlagsJob( device, partition, flags ); SetPartFlagsJob* fJob = new SetPartFlagsJob( device, partition, flags );
deviceInfo->jobs << Calamares::job_ptr( fJob ); deviceInfo->jobs << Calamares::job_ptr( fJob );
@ -398,7 +401,7 @@ PartitionCoreModule::deletePartition( Device* device, Partition* partition )
} }
QList< Calamares::job_ptr >& jobs = deviceInfo->jobs; QList< Calamares::job_ptr >& jobs = deviceInfo->jobs;
if ( partition->state() == Partition::StateNew ) if ( partition->state() == KPM_PARTITION_STATE(New) )
{ {
// First remove matching SetPartFlagsJobs // First remove matching SetPartFlagsJobs
for ( auto it = jobs.begin(); it != jobs.end(); ) for ( auto it = jobs.begin(); it != jobs.end(); )
@ -497,6 +500,17 @@ PartitionCoreModule::jobs() const
QList< Calamares::job_ptr > lst; QList< Calamares::job_ptr > lst;
QList< Device* > devices; QList< Device* > devices;
#ifdef DEBUG_PARTITION_UNSAFE
#ifdef DEBUG_PARTITION_LAME
cDebug() << "Unsafe partitioning is enabled.";
cDebug() << ".. it has been lamed, and will fail.";
lst << Calamares::job_ptr( new Calamares::FailJob( QStringLiteral( "Partition" ) ) );
#else
cWarning() << "Unsafe partitioning is enabled.";
cWarning() << ".. the unsafe actions will be executed.";
#endif
#endif
lst << Calamares::job_ptr( new ClearTempMountsJob() ); lst << Calamares::job_ptr( new ClearTempMountsJob() );
for ( auto info : m_deviceInfos ) for ( auto info : m_deviceInfos )
@ -818,7 +832,7 @@ PartitionCoreModule::layoutApply( Device *dev,
if ( part->mountPoint() == "/" ) if ( part->mountPoint() == "/" )
{ {
createPartition( dev, part, createPartition( dev, part,
part->activeFlags() | ( isEfi ? PartitionTable::FlagNone : PartitionTable::FlagBoot ) part->activeFlags() | ( isEfi ? KPM_PARTITION_FLAG(None) : KPM_PARTITION_FLAG(Boot) )
); );
} }
else else

View File

@ -20,6 +20,7 @@
#ifndef PARTITIONCOREMODULE_H #ifndef PARTITIONCOREMODULE_H
#define PARTITIONCOREMODULE_H #define PARTITIONCOREMODULE_H
#include "core/KPMHelpers.h"
#include "core/PartitionLayout.h" #include "core/PartitionLayout.h"
#include "core/PartitionModel.h" #include "core/PartitionModel.h"
#include "Typedefs.h" #include "Typedefs.h"
@ -136,7 +137,7 @@ public:
* applied to the newly-created partition. * applied to the newly-created partition.
*/ */
void createPartition( Device* device, Partition* partition, void createPartition( Device* device, Partition* partition,
PartitionTable::Flags flags = PartitionTable::FlagNone ); PartitionTable::Flags flags = KPM_PARTITION_FLAG(None) );
void createVolumeGroup( QString &vgName, QVector< const Partition* > pvList, qint32 peSize ); void createVolumeGroup( QString &vgName, QVector< const Partition* > pvList, qint32 peSize );

View File

@ -143,7 +143,7 @@ PartitionLayout::execute( Device *dev, qint64 firstSector,
part.partFileSystem, part.partFileSystem,
firstSector, firstSector,
end, end,
PartitionTable::FlagNone KPM_PARTITION_FLAG(None)
); );
} }
else else
@ -156,7 +156,7 @@ PartitionLayout::execute( Device *dev, qint64 firstSector,
firstSector, firstSector,
end, end,
luksPassphrase, luksPassphrase,
PartitionTable::FlagNone KPM_PARTITION_FLAG(None)
); );
} }
PartitionInfo::setFormat( currentPartition, true ); PartitionInfo::setFormat( currentPartition, true );

View File

@ -1359,6 +1359,16 @@ ChoicePage::setupActions()
) )
} }
#ifdef DEBUG_PARTITION_UNSAFE
#ifdef DEBUG_PARTITION_LAME
// If things can't be broken, allow all the buttons
atLeastOneCanBeReplaced = true;
atLeastOneCanBeResized = true;
atLeastOneIsMounted = false;
isInactiveRAID = false;
#endif
#endif
if ( atLeastOneCanBeReplaced ) if ( atLeastOneCanBeReplaced )
m_replaceButton->show(); m_replaceButton->show();
else else

View File

@ -154,7 +154,7 @@ ReplaceWidget::onPartitionSelected()
Partition* partition = model->partitionForIndex( m_ui->partitionTreeView->currentIndex() ); Partition* partition = model->partitionForIndex( m_ui->partitionTreeView->currentIndex() );
if ( !partition || if ( !partition ||
partition->state() != Partition::StateNone ) partition->state() != KPM_PARTITION_STATE(None) )
{ {
updateStatus( CalamaresUtils::Fail, updateStatus( CalamaresUtils::Fail,
tr( "The selected item does not appear to be a valid partition." ) ); tr( "The selected item does not appear to be a valid partition." ) );

View File

@ -45,7 +45,6 @@ typedef QHash<QString, QString> UuidForPartitionHash;
static UuidForPartitionHash static UuidForPartitionHash
findPartitionUuids( QList < Device* > devices ) findPartitionUuids( QList < Device* > devices )
{ {
cDebug() << "Gathering UUIDs for partitions that exist now.";
UuidForPartitionHash hash; UuidForPartitionHash hash;
foreach ( Device* device, devices ) foreach ( Device* device, devices )
{ {
@ -56,12 +55,11 @@ findPartitionUuids( QList < Device* > devices )
QString path = p->partitionPath(); QString path = p->partitionPath();
QString uuid = p->fileSystem().readUUID( p->partitionPath() ); QString uuid = p->fileSystem().readUUID( p->partitionPath() );
hash.insert( path, uuid ); hash.insert( path, uuid );
cDebug() << ".. added path=" << path << "UUID=" << uuid;
} }
} }
if ( hash.isEmpty() ) if ( hash.isEmpty() )
cDebug() << ".. no UUIDs found."; cDebug() << "No UUIDs found for existing partitions.";
return hash; return hash;
} }
@ -147,7 +145,6 @@ FillGlobalStorageJob::prettyDescription() const
QString path = partitionMap.value( "device" ).toString(); QString path = partitionMap.value( "device" ).toString();
QString mountPoint = partitionMap.value( "mountPoint" ).toString(); QString mountPoint = partitionMap.value( "mountPoint" ).toString();
QString fsType = partitionMap.value( "fs" ).toString(); QString fsType = partitionMap.value( "fs" ).toString();
qDebug() << partitionMap.value( "uuid" ) << path << mountPoint << fsType;
if ( mountPoint.isEmpty() || fsType.isEmpty() ) if ( mountPoint.isEmpty() || fsType.isEmpty() )
continue; continue;
if ( path.isEmpty() ) if ( path.isEmpty() )

View File

@ -228,11 +228,11 @@ PartitionJobTests::newCreatePartitionJob( Partition* freeSpacePartition, Partiti
role, role,
fs, firstSector, lastSector, fs, firstSector, lastSector,
QString() /* path */, QString() /* path */,
PartitionTable::FlagNone /* availableFlags */, KPM_PARTITION_FLAG(None) /* availableFlags */,
QString() /* mountPoint */, QString() /* mountPoint */,
false /* mounted */, false /* mounted */,
PartitionTable::FlagNone /* activeFlags */, KPM_PARTITION_FLAG(None) /* activeFlags */,
Partition::StateNew KPM_PARTITION_STATE(New)
); );
return new CreatePartitionJob( m_device.data(), partition ); return new CreatePartitionJob( m_device.data(), partition );
} }
@ -366,7 +366,7 @@ PartitionJobTests::testResizePartition()
FileSystem::Ext4, FileSystem::Ext4,
oldFirst, oldFirst,
oldLast, oldLast,
PartitionTable::FlagNone KPM_PARTITION_FLAG(None)
); );
CreatePartitionJob* job = new CreatePartitionJob( m_device.data(), partition ); CreatePartitionJob* job = new CreatePartitionJob( m_device.data(), partition );
job->updatePreview(); job->updatePreview();