From 62888f7984d82af360cd475042057eaeed360575 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 21 Feb 2022 11:56:34 +0100 Subject: [PATCH 1/8] [partition] Rename setting to BAIL_OUT - unsafe partitioning will bail out (and end the installation) if BAIL_OUT is set (previously _LAME). --- CMakeLists.txt | 2 +- src/modules/partition/CMakeLists.txt | 8 ++++---- src/modules/partition/core/DeviceList.cpp | 2 +- src/modules/partition/core/PartitionCoreModule.cpp | 4 ++-- src/modules/partition/gui/ChoicePage.cpp | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd46148d8..9d841d284 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,7 +75,7 @@ option( BUILD_SCHEMA_TESTING "Enable schema-validation-tests" ON ) # - DEBUG_FILESYSTEMS does extra logging and checking when looking at # partition configuration. Lists known KPMCore FS types. # - DEBUG_PARTITION_UNSAFE (see partition/CMakeLists.txt) -# - DEBUG_PARTITION_LAME (see partition/CMakeLists.txt) +# - DEBUG_PARTITION_BAIL_OUT (see partition/CMakeLists.txt) ### USE_* diff --git a/src/modules/partition/CMakeLists.txt b/src/modules/partition/CMakeLists.txt index 96378d98d..2a2ddf188 100644 --- a/src/modules/partition/CMakeLists.txt +++ b/src/modules/partition/CMakeLists.txt @@ -9,10 +9,10 @@ # current disk). Set DEBUG_PARTITION_UNSAFE to allow that (it turns off # some filtering of devices). If you **do** allow unsafe partitioning, # 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. 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 ) # This is very chatty, useful mostly if you don't know what KPMCore offers. option( DEBUG_FILESYSTEMS "Log all available Filesystems from KPMCore." OFF ) @@ -21,8 +21,8 @@ include_directories( ${CMAKE_SOURCE_DIR} ) # For 3rdparty set( _partition_defs ) if( DEBUG_PARTITION_UNSAFE ) - if( DEBUG_PARTITION_LAME ) - list( APPEND _partition_defs DEBUG_PARTITION_LAME ) + if( DEBUG_PARTITION_BAIL_OUT ) + list( APPEND _partition_defs DEBUG_PARTITION_BAIL_OUT ) endif() list( APPEND _partition_defs DEBUG_PARTITION_UNSAFE ) endif() diff --git a/src/modules/partition/core/DeviceList.cpp b/src/modules/partition/core/DeviceList.cpp index adbbddd68..b3a10dde7 100644 --- a/src/modules/partition/core/DeviceList.cpp +++ b/src/modules/partition/core/DeviceList.cpp @@ -143,7 +143,7 @@ getDevices( DeviceType which ) */ #ifdef DEBUG_PARTITION_UNSAFE 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."; #endif diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp index 989327ef0..367672c75 100644 --- a/src/modules/partition/core/PartitionCoreModule.cpp +++ b/src/modules/partition/core/PartitionCoreModule.cpp @@ -37,7 +37,7 @@ #include "jobs/ResizeVolumeGroupJob.h" #include "jobs/SetPartitionFlagsJob.h" -#ifdef DEBUG_PARTITION_LAME +#ifdef DEBUG_PARTITION_BAIL_OUT #include "JobExample.h" #endif #include "partition/PartitionIterator.h" @@ -622,7 +622,7 @@ PartitionCoreModule::jobs( const Config* config ) const QList< Device* > devices; #ifdef DEBUG_PARTITION_UNSAFE -#ifdef DEBUG_PARTITION_LAME +#ifdef DEBUG_PARTITION_BAIL_OUT cDebug() << "Unsafe partitioning is enabled."; cDebug() << Logger::SubEntry << "it has been lamed, and will fail."; lst << Calamares::job_ptr( new Calamares::FailJob( QStringLiteral( "Partition" ) ) ); diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index 588c1b643..c0845da7f 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -1481,7 +1481,7 @@ ChoicePage::setupActions() } #ifdef DEBUG_PARTITION_UNSAFE -#ifdef DEBUG_PARTITION_LAME +#ifdef DEBUG_PARTITION_BAIL_OUT // If things can't be broken, allow all the buttons atLeastOneCanBeReplaced = true; atLeastOneCanBeResized = true; From 99d11f754f34a307c5132d1ab7201bc4a65f6a20 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 21 Feb 2022 12:12:20 +0100 Subject: [PATCH 2/8] [partition] Tighten up determining job labels for description --- src/modules/partition/PartitionViewStep.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/modules/partition/PartitionViewStep.cpp b/src/modules/partition/PartitionViewStep.cpp index 5e8bf2ef0..1eed8e2d7 100644 --- a/src/modules/partition/PartitionViewStep.cpp +++ b/src/modules/partition/PartitionViewStep.cpp @@ -216,7 +216,7 @@ diskDescription( int listLength, const PartitionCoreModule::SummaryInfo& info, C QString PartitionViewStep::prettyStatus() const { - QString jobsLabel, modeText, diskInfoLabel; + QString modeText, diskInfoLabel; const Config::InstallChoice choice = m_config->installChoice(); const QList< PartitionCoreModule::SummaryInfo > list = m_core->createSummaryInfo(); @@ -233,12 +233,7 @@ PartitionViewStep::prettyStatus() const diskInfoLabel = diskDescription( list.length(), info, choice ); } - const QStringList jobsLines = jobDescriptions( jobs() ); - if ( !jobsLines.isEmpty() ) - { - jobsLabel = jobsLines.join( "
" ); - } - + const QString jobsLabel = jobDescriptions( jobs() ).join( QStringLiteral( "
" ) ); return diskInfoLabel + "
" + jobsLabel; } From f04f0a7e1d5561d3fb9816e0966b10c9fe718ba7 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 21 Feb 2022 12:13:11 +0100 Subject: [PATCH 3/8] [partition] Remove unused text --- src/modules/partition/PartitionViewStep.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/modules/partition/PartitionViewStep.cpp b/src/modules/partition/PartitionViewStep.cpp index 1eed8e2d7..483036436 100644 --- a/src/modules/partition/PartitionViewStep.cpp +++ b/src/modules/partition/PartitionViewStep.cpp @@ -216,17 +216,12 @@ diskDescription( int listLength, const PartitionCoreModule::SummaryInfo& info, C QString PartitionViewStep::prettyStatus() const { - QString modeText, diskInfoLabel; + QString diskInfoLabel; const Config::InstallChoice choice = m_config->installChoice(); const QList< PartitionCoreModule::SummaryInfo > list = m_core->createSummaryInfo(); cDebug() << "Summary for Partition" << list.length() << choice; - if ( list.length() > 1 ) // There are changes on more than one disk - { - modeText = modeDescription( choice ); - } - for ( const auto& info : list ) { // TODO: this overwrites each iteration From 9dd2f275f1b39f461541ea06abcdf9ad2e4a30ec Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 21 Feb 2022 12:27:59 +0100 Subject: [PATCH 4/8] CI: allow clang-format naming according to Debian --- ci/calamaresstyle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/calamaresstyle b/ci/calamaresstyle index f5bcd2bb9..52fe30737 100755 --- a/ci/calamaresstyle +++ b/ci/calamaresstyle @@ -24,7 +24,7 @@ test -f "$TOPDIR/.clang-format" || { echo "! No .clang-format support files in $ AS=$( which astyle ) # 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 do # Not an error if this particular clang-format isn't found From 7129a2239c46b28a3b57b1707733f494cacf7c41 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 21 Feb 2022 12:30:34 +0100 Subject: [PATCH 5/8] [partition] Tidy up description in prettyStatus - the length parameter to diskDescription() is worse than useless, because it doesn't say anything about what will be done if there's more than one disk. --- src/modules/partition/PartitionViewStep.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/modules/partition/PartitionViewStep.cpp b/src/modules/partition/PartitionViewStep.cpp index 483036436..c87d1b314 100644 --- a/src/modules/partition/PartitionViewStep.cpp +++ b/src/modules/partition/PartitionViewStep.cpp @@ -52,8 +52,8 @@ PartitionViewStep::PartitionViewStep( QObject* parent ) m_waitingWidget = new WaitingWidget( QString() ); m_widget->addWidget( m_waitingWidget ); - CALAMARES_RETRANSLATE( - if ( m_waitingWidget ) { m_waitingWidget->setText( tr( "Gathering system information..." ) ); } ); + CALAMARES_RETRANSLATE( if ( m_waitingWidget ) + { m_waitingWidget->setText( tr( "Gathering system information..." ) ); } ); m_core = new PartitionCoreModule( this ); // Unusable before init is complete! // We're not done loading, but we need the configuration map first. @@ -216,18 +216,13 @@ diskDescription( int listLength, const PartitionCoreModule::SummaryInfo& info, C QString PartitionViewStep::prettyStatus() const { - QString diskInfoLabel; - const Config::InstallChoice choice = m_config->installChoice(); const QList< PartitionCoreModule::SummaryInfo > list = m_core->createSummaryInfo(); cDebug() << "Summary for Partition" << list.length() << choice; - for ( const auto& info : list ) - { - // TODO: this overwrites each iteration - diskInfoLabel = diskDescription( list.length(), info, choice ); - } - + auto joinDiskInfo = [ choice = choice ]( QString& s, const PartitionCoreModule::SummaryInfo& i ) + { return s + diskDescription( 1, i, choice ); }; + const QString diskInfoLabel = std::accumulate( list.begin(), list.end(), QString(), joinDiskInfo ); const QString jobsLabel = jobDescriptions( jobs() ).join( QStringLiteral( "
" ) ); return diskInfoLabel + "
" + jobsLabel; } From 682ae24b7dbb4ff0fa6b8f7056e2c0c91368fe22 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 21 Feb 2022 12:39:56 +0100 Subject: [PATCH 6/8] [partition] Introduce skipping-partitioning-jobs Don't do the actual KPM work, but pretend that they were done. This can be useful -- independently of the existing unsafe- options and failing partitioning entirely -- for testing partition layouts in modules following the *partition* one. --- src/modules/partition/CMakeLists.txt | 11 +++++++++++ src/modules/partition/core/PartitionCoreModule.cpp | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/src/modules/partition/CMakeLists.txt b/src/modules/partition/CMakeLists.txt index 2a2ddf188..940aacdd8 100644 --- a/src/modules/partition/CMakeLists.txt +++ b/src/modules/partition/CMakeLists.txt @@ -11,8 +11,16 @@ # it will error out at runtime unless you **also** switch **off** # DEBUG_PARTITION_BAIL_OUT, at which point you are welcome to shoot # 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_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. option( DEBUG_FILESYSTEMS "Log all available Filesystems from KPMCore." OFF ) @@ -29,6 +37,9 @@ endif() if ( DEBUG_FILESYSTEMS ) list( APPEND _partition_defs DEBUG_FILESYSTEMS ) endif() +if( DEBUG_PARTITION_SKIP ) + list( APPEND _partition_defs DEBUG_PARTITION_SKIP ) +endif() find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE) diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp index 367672c75..79adf7686 100644 --- a/src/modules/partition/core/PartitionCoreModule.cpp +++ b/src/modules/partition/core/PartitionCoreModule.cpp @@ -639,6 +639,9 @@ PartitionCoreModule::jobs( const Config* config ) const lst << automountControl; lst << Calamares::job_ptr( new ClearTempMountsJob() ); +#ifdef DEBUG_PARTITION_SKIP + cWarning() << "Partitioning actions are skipped."; +#else const QStringList doNotClose = findEssentialLVs( m_deviceInfos ); for ( const auto* info : m_deviceInfos ) @@ -650,10 +653,15 @@ PartitionCoreModule::jobs( const Config* config ) const lst << Calamares::job_ptr( job ); } } +#endif for ( const auto* info : m_deviceInfos ) { +#ifdef DEBUG_PARTITION_SKIP + cWarning() << Logger::SubEntry << "Skipping jobs for" << info->device.data()->deviceNode(); +#else lst << info->jobs(); +#endif devices << info->device.data(); } lst << Calamares::job_ptr( new FillGlobalStorageJob( config, devices, m_bootLoaderInstallPath ) ); From 92f4ab30ea7d411e834d1833dfe6eeefeb7adcac Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 21 Feb 2022 12:51:25 +0100 Subject: [PATCH 7/8] [partition] Add a note and an icon about unusually-configured partition module --- src/modules/partition/PartitionViewStep.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/modules/partition/PartitionViewStep.cpp b/src/modules/partition/PartitionViewStep.cpp index c87d1b314..f3d4fc8ac 100644 --- a/src/modules/partition/PartitionViewStep.cpp +++ b/src/modules/partition/PartitionViewStep.cpp @@ -242,6 +242,24 @@ PartitionViewStep::createSummaryWidget() const formLayout->setContentsMargins( MARGIN, 0, MARGIN, MARGIN ); 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 always 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(); if ( list.length() > 1 ) // There are changes on more than one disk { From 23f501c0710639c856358f243d437dab386772b0 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 21 Feb 2022 14:56:45 +0100 Subject: [PATCH 8/8] [fstab] Recognize mmc and nvme disks correctly - basename() returns the last path component, so never includes the leading '/dev/' - the check for mmc and nvme looked for device names starting with '/dev/mmc' .. but '/dev/' has just been stripped away by the call to basename, so this never matched - stripped the trailing digits rather than trailing 'p[0-9]', so 'nvme0n1p2' became 'nvme0n1p' which isn't a useful device name. FIXES #1883 --- src/modules/fstab/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/fstab/main.py b/src/modules/fstab/main.py index 6a771a24b..07a00c14d 100644 --- a/src/modules/fstab/main.py +++ b/src/modules/fstab/main.py @@ -92,7 +92,8 @@ def disk_name_for_partition(partition): """ 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("[0-9]+$", "", name)