Merge branch 'issue-1883' into calamares

FIXES #1883
This commit is contained in:
Adriaan de Groot 2022-02-21 15:07:58 +01:00
commit c1f1934c27
8 changed files with 55 additions and 32 deletions

View File

@ -75,7 +75,7 @@ option( BUILD_SCHEMA_TESTING "Enable schema-validation-tests" ON )
# - DEBUG_FILESYSTEMS does extra logging and checking when looking at # - DEBUG_FILESYSTEMS does extra logging and checking when looking at
# partition configuration. Lists known KPMCore FS types. # partition configuration. Lists known KPMCore FS types.
# - DEBUG_PARTITION_UNSAFE (see partition/CMakeLists.txt) # - DEBUG_PARTITION_UNSAFE (see partition/CMakeLists.txt)
# - DEBUG_PARTITION_LAME (see partition/CMakeLists.txt) # - DEBUG_PARTITION_BAIL_OUT (see partition/CMakeLists.txt)
### USE_* ### USE_*

View File

@ -24,7 +24,7 @@ test -f "$TOPDIR/.clang-format" || { echo "! No .clang-format support files in $
AS=$( which astyle ) AS=$( which astyle )
# Allow specifying CF_VERSIONS outside already # Allow specifying CF_VERSIONS outside already
CF_VERSIONS="$CF_VERSIONS clang-format13 clang-format12 clang-format" CF_VERSIONS="$CF_VERSIONS clang-format13 clang-format-13 clang-format12 clang-format-12 clang-format"
for _cf in $CF_VERSIONS for _cf in $CF_VERSIONS
do do
# Not an error if this particular clang-format isn't found # Not an error if this particular clang-format isn't found

View File

@ -92,7 +92,8 @@ def disk_name_for_partition(partition):
""" """
name = os.path.basename(partition["device"]) name = os.path.basename(partition["device"])
if name.startswith("/dev/mmcblk") or name.startswith("/dev/nvme"): if name.startswith("mmcblk") or name.startswith("nvme"):
# Typical mmc device is mmcblk0p1, nvme looks like nvme0n1p2
return re.sub("p[0-9]+$", "", name) return re.sub("p[0-9]+$", "", name)
return re.sub("[0-9]+$", "", name) return re.sub("[0-9]+$", "", name)

View File

@ -9,10 +9,18 @@
# current disk). Set DEBUG_PARTITION_UNSAFE to allow that (it turns off # current disk). Set DEBUG_PARTITION_UNSAFE to allow that (it turns off
# some filtering of devices). If you **do** allow unsafe partitioning, # some filtering of devices). If you **do** allow unsafe partitioning,
# it will error out at runtime unless you **also** switch **off** # it will error out at runtime unless you **also** switch **off**
# DEBUG_PARTITION_LAME, at which point you are welcome to shoot # DEBUG_PARTITION_BAIL_OUT, at which point you are welcome to shoot
# yourself in the foot. # yourself in the foot.
#
# Independently, DEBUG_PARTITION_SKIP will not do the actual partitioning
# through KPMCore, but it **will** save the global storage setup as if
# it has done the partitioning. This is going to confuse subsequent
# modules since the partitions on disk won't match GS, but it can be
# useful for debugging simulated installations that don't need to
# mount the target filesystems.
option( DEBUG_PARTITION_UNSAFE "Allow unsafe partitioning choices." OFF ) option( DEBUG_PARTITION_UNSAFE "Allow unsafe partitioning choices." OFF )
option( DEBUG_PARTITION_LAME "Unsafe partitioning will error out on exec." ON ) option( DEBUG_PARTITION_BAIL_OUT "Unsafe partitioning will error out on exec." ON )
option( DEBUG_PARTITION_SKIP "Don't actually do any partitioning." OFF)
# This is very chatty, useful mostly if you don't know what KPMCore offers. # This is very chatty, useful mostly if you don't know what KPMCore offers.
option( DEBUG_FILESYSTEMS "Log all available Filesystems from KPMCore." OFF ) option( DEBUG_FILESYSTEMS "Log all available Filesystems from KPMCore." OFF )
@ -21,14 +29,17 @@ include_directories( ${CMAKE_SOURCE_DIR} ) # For 3rdparty
set( _partition_defs ) set( _partition_defs )
if( DEBUG_PARTITION_UNSAFE ) if( DEBUG_PARTITION_UNSAFE )
if( DEBUG_PARTITION_LAME ) if( DEBUG_PARTITION_BAIL_OUT )
list( APPEND _partition_defs DEBUG_PARTITION_LAME ) list( APPEND _partition_defs DEBUG_PARTITION_BAIL_OUT )
endif() endif()
list( APPEND _partition_defs DEBUG_PARTITION_UNSAFE ) list( APPEND _partition_defs DEBUG_PARTITION_UNSAFE )
endif() endif()
if ( DEBUG_FILESYSTEMS ) if ( DEBUG_FILESYSTEMS )
list( APPEND _partition_defs DEBUG_FILESYSTEMS ) list( APPEND _partition_defs DEBUG_FILESYSTEMS )
endif() endif()
if( DEBUG_PARTITION_SKIP )
list( APPEND _partition_defs DEBUG_PARTITION_SKIP )
endif()
find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE) find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE)

View File

@ -52,8 +52,8 @@ PartitionViewStep::PartitionViewStep( QObject* parent )
m_waitingWidget = new WaitingWidget( QString() ); m_waitingWidget = new WaitingWidget( QString() );
m_widget->addWidget( m_waitingWidget ); m_widget->addWidget( m_waitingWidget );
CALAMARES_RETRANSLATE( CALAMARES_RETRANSLATE( if ( m_waitingWidget )
if ( m_waitingWidget ) { m_waitingWidget->setText( tr( "Gathering system information..." ) ); } ); { m_waitingWidget->setText( tr( "Gathering system information..." ) ); } );
m_core = new PartitionCoreModule( this ); // Unusable before init is complete! m_core = new PartitionCoreModule( this ); // Unusable before init is complete!
// We're not done loading, but we need the configuration map first. // We're not done loading, but we need the configuration map first.
@ -216,29 +216,14 @@ diskDescription( int listLength, const PartitionCoreModule::SummaryInfo& info, C
QString QString
PartitionViewStep::prettyStatus() const PartitionViewStep::prettyStatus() const
{ {
QString jobsLabel, modeText, diskInfoLabel;
const Config::InstallChoice choice = m_config->installChoice(); const Config::InstallChoice choice = m_config->installChoice();
const QList< PartitionCoreModule::SummaryInfo > list = m_core->createSummaryInfo(); const QList< PartitionCoreModule::SummaryInfo > list = m_core->createSummaryInfo();
cDebug() << "Summary for Partition" << list.length() << choice; cDebug() << "Summary for Partition" << list.length() << choice;
if ( list.length() > 1 ) // There are changes on more than one disk auto joinDiskInfo = [ choice = choice ]( QString& s, const PartitionCoreModule::SummaryInfo& i )
{ { return s + diskDescription( 1, i, choice ); };
modeText = modeDescription( choice ); const QString diskInfoLabel = std::accumulate( list.begin(), list.end(), QString(), joinDiskInfo );
} const QString jobsLabel = jobDescriptions( jobs() ).join( QStringLiteral( "<br/>" ) );
for ( const auto& info : list )
{
// TODO: this overwrites each iteration
diskInfoLabel = diskDescription( list.length(), info, choice );
}
const QStringList jobsLines = jobDescriptions( jobs() );
if ( !jobsLines.isEmpty() )
{
jobsLabel = jobsLines.join( "<br/>" );
}
return diskInfoLabel + "<br/>" + jobsLabel; return diskInfoLabel + "<br/>" + jobsLabel;
} }
@ -257,6 +242,24 @@ PartitionViewStep::createSummaryWidget() const
formLayout->setContentsMargins( MARGIN, 0, MARGIN, MARGIN ); formLayout->setContentsMargins( MARGIN, 0, MARGIN, MARGIN );
mainLayout->addLayout( formLayout ); mainLayout->addLayout( formLayout );
#if defined( DEBUG_PARTITION_UNSAFE ) || defined( DEBUG_PARTITION_BAIL_OUT ) || defined( DEBUG_PARTITION_SKIP )
auto specialRow = [ = ]( CalamaresUtils::ImageType t, const QString& s )
{
QLabel* icon = new QLabel;
icon->setPixmap( CalamaresUtils::defaultPixmap( t ) );
formLayout->addRow( icon, new QLabel( s ) );
};
#endif
#if defined( DEBUG_PARTITION_UNSAFE )
specialRow( CalamaresUtils::ImageType::StatusWarning, tr( "Unsafe partition actions are enabled." ) );
#endif
#if defined( DEBUG_PARTITION_BAIL_OUT )
specialRow( CalamaresUtils::ImageType::Information, tr( "Partitioning is configured to <b>always</b> fail." ) );
#endif
#if defined( DEBUG_PARTITION_SKIP )
specialRow( CalamaresUtils::ImageType::Information, tr( "No partitions will be changed." ) );
#endif
const QList< PartitionCoreModule::SummaryInfo > list = m_core->createSummaryInfo(); const QList< PartitionCoreModule::SummaryInfo > list = m_core->createSummaryInfo();
if ( list.length() > 1 ) // There are changes on more than one disk if ( list.length() > 1 ) // There are changes on more than one disk
{ {

View File

@ -143,7 +143,7 @@ getDevices( DeviceType which )
*/ */
#ifdef DEBUG_PARTITION_UNSAFE #ifdef DEBUG_PARTITION_UNSAFE
cWarning() << "Allowing unsafe partitioning choices." << devices.count() << "candidates."; cWarning() << "Allowing unsafe partitioning choices." << devices.count() << "candidates.";
#ifdef DEBUG_PARTITION_LAME #ifdef DEBUG_PARTITION_BAIL_OUT
cDebug() << Logger::SubEntry << "unsafe partitioning has been lamed, and will fail."; cDebug() << Logger::SubEntry << "unsafe partitioning has been lamed, and will fail.";
#endif #endif

View File

@ -37,7 +37,7 @@
#include "jobs/ResizeVolumeGroupJob.h" #include "jobs/ResizeVolumeGroupJob.h"
#include "jobs/SetPartitionFlagsJob.h" #include "jobs/SetPartitionFlagsJob.h"
#ifdef DEBUG_PARTITION_LAME #ifdef DEBUG_PARTITION_BAIL_OUT
#include "JobExample.h" #include "JobExample.h"
#endif #endif
#include "partition/PartitionIterator.h" #include "partition/PartitionIterator.h"
@ -622,7 +622,7 @@ PartitionCoreModule::jobs( const Config* config ) const
QList< Device* > devices; QList< Device* > devices;
#ifdef DEBUG_PARTITION_UNSAFE #ifdef DEBUG_PARTITION_UNSAFE
#ifdef DEBUG_PARTITION_LAME #ifdef DEBUG_PARTITION_BAIL_OUT
cDebug() << "Unsafe partitioning is enabled."; cDebug() << "Unsafe partitioning is enabled.";
cDebug() << Logger::SubEntry << "it has been lamed, and will fail."; cDebug() << Logger::SubEntry << "it has been lamed, and will fail.";
lst << Calamares::job_ptr( new Calamares::FailJob( QStringLiteral( "Partition" ) ) ); lst << Calamares::job_ptr( new Calamares::FailJob( QStringLiteral( "Partition" ) ) );
@ -639,6 +639,9 @@ PartitionCoreModule::jobs( const Config* config ) const
lst << automountControl; lst << automountControl;
lst << Calamares::job_ptr( new ClearTempMountsJob() ); lst << Calamares::job_ptr( new ClearTempMountsJob() );
#ifdef DEBUG_PARTITION_SKIP
cWarning() << "Partitioning actions are skipped.";
#else
const QStringList doNotClose = findEssentialLVs( m_deviceInfos ); const QStringList doNotClose = findEssentialLVs( m_deviceInfos );
for ( const auto* info : m_deviceInfos ) for ( const auto* info : m_deviceInfos )
@ -650,10 +653,15 @@ PartitionCoreModule::jobs( const Config* config ) const
lst << Calamares::job_ptr( job ); lst << Calamares::job_ptr( job );
} }
} }
#endif
for ( const auto* info : m_deviceInfos ) for ( const auto* info : m_deviceInfos )
{ {
#ifdef DEBUG_PARTITION_SKIP
cWarning() << Logger::SubEntry << "Skipping jobs for" << info->device.data()->deviceNode();
#else
lst << info->jobs(); lst << info->jobs();
#endif
devices << info->device.data(); devices << info->device.data();
} }
lst << Calamares::job_ptr( new FillGlobalStorageJob( config, devices, m_bootLoaderInstallPath ) ); lst << Calamares::job_ptr( new FillGlobalStorageJob( config, devices, m_bootLoaderInstallPath ) );

View File

@ -1481,7 +1481,7 @@ ChoicePage::setupActions()
} }
#ifdef DEBUG_PARTITION_UNSAFE #ifdef DEBUG_PARTITION_UNSAFE
#ifdef DEBUG_PARTITION_LAME #ifdef DEBUG_PARTITION_BAIL_OUT
// If things can't be broken, allow all the buttons // If things can't be broken, allow all the buttons
atLeastOneCanBeReplaced = true; atLeastOneCanBeReplaced = true;
atLeastOneCanBeResized = true; atLeastOneCanBeResized = true;