diff --git a/CHANGES-3.3 b/CHANGES-3.3 index a355f90af..48435a0b4 100644 --- a/CHANGES-3.3 +++ b/CHANGES-3.3 @@ -10,11 +10,23 @@ the history of the 3.2 series (2018-05 - 2022-08). # 3.3.7 (unreleased) This release contains contributions from (alphabetically by first name): - - Nobody, yet + - Adriaan de Groot + - Eugene San + - Evan James + - Vincent Penvern + - Vladislav Nepogodin ## Core ## + - Updated clang-formatting + - Some C++20 future-proofing (thanks Vladislav) ## Modules ## + - *fstab* module does not add an encryption keyfile if it does + not exist. (thanks Eugene) + - *partition* module did not filter out invalid fstab entries; + they were not written, either, so no net change. + - *partition* module now has a configurable default check-state + for the encryption checkbox. (thanks Vincent) # 3.3.6 (2024-04-16) @@ -22,7 +34,7 @@ This release contains contributions from (alphabetically by first name): This release contains contributions from (alphabetically by first name): - Adriaan de Groot - Anke Boersma - - Eugene Sam + - Eugene San - Evan James - Harald Sitter - Mike Stemle diff --git a/src/libcalamares/CalamaresAbout.cpp b/src/libcalamares/CalamaresAbout.cpp index 31389c679..4ff44356d 100644 --- a/src/libcalamares/CalamaresAbout.cpp +++ b/src/libcalamares/CalamaresAbout.cpp @@ -22,15 +22,6 @@ static const char s_footer[] "and the Calamares " "translators team." ); -#if 0 -// Blue Systems sponsored until June 2022 -static const char s_sponsor[] = QT_TRANSLATE_NOOP( "AboutData", - "Calamares " - "development is sponsored by
" - "Blue Systems - " - "Liberating Software." ); -#endif - struct Maintainer { unsigned int start; @@ -57,14 +48,12 @@ static constexpr const Maintainer maintainers[] = { static QString aboutMaintainers() { - return std::accumulate( std::cbegin( maintainers ), - std::cend( maintainers ), - QString(), - []( QString& s, const Maintainer& m ) - { - s += m.text(); - return s; - } ); + QStringList s; + for ( const auto& m : maintainers ) + { + s.append( m.text() ); + } + return s.join( QString() ); } static QString diff --git a/src/libcalamares/compat/Size.h b/src/libcalamares/compat/Size.h new file mode 100644 index 000000000..5e217e4cb --- /dev/null +++ b/src/libcalamares/compat/Size.h @@ -0,0 +1,23 @@ +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2024 Adriaan de Groot + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Calamares is Free Software: see the License-Identifier above. + * + * + */ +#ifndef CALAMARES_COMPAT_SIZE_H +#define CALAMARES_COMPAT_SIZE_H + +#include + +namespace Calamares +{ +/* Compatibility of size types (e.g. qsizetype, STL sizes, int) between Qt5 and Qt6 */ + +using NumberForTr = int; + +} + +#endif diff --git a/src/libcalamares/modulesystem/RequirementsChecker.cpp b/src/libcalamares/modulesystem/RequirementsChecker.cpp index 1eb85113d..25930b942 100644 --- a/src/libcalamares/modulesystem/RequirementsChecker.cpp +++ b/src/libcalamares/modulesystem/RequirementsChecker.cpp @@ -11,6 +11,7 @@ #include "RequirementsChecker.h" #include "compat/Mutex.h" +#include "compat/Size.h" #include "modulesystem/Module.h" #include "modulesystem/Requirement.h" #include "modulesystem/RequirementsModel.h" @@ -120,7 +121,7 @@ RequirementsChecker::reportProgress() { cDebug() << "Remaining modules:" << remaining << Logger::DebugList( remainingNames ); unsigned int posInterval = ( m_progressTimer->interval() < 0 ) ? 1000 : uint( m_progressTimer->interval() ); - QString waiting = tr( "Waiting for %n module(s)…", "@status", remaining ); + QString waiting = tr( "Waiting for %n module(s)…", "@status", static_cast(remaining) ); QString elapsed = tr( "(%n second(s))", "@status", m_progressTimeouts * posInterval / 999 ); Q_EMIT requirementsProgress( waiting + QString( " " ) + elapsed ); } diff --git a/src/libcalamares/modulesystem/RequirementsModel.cpp b/src/libcalamares/modulesystem/RequirementsModel.cpp index 3ad98ae88..4b44d62a4 100644 --- a/src/libcalamares/modulesystem/RequirementsModel.cpp +++ b/src/libcalamares/modulesystem/RequirementsModel.cpp @@ -66,7 +66,7 @@ RequirementsModel::reCheckList() int RequirementsModel::rowCount( const QModelIndex& ) const { - return m_requirements.count(); + return static_cast< int >( m_requirements.count() ); // TODO 3.4 use qsizetype } QVariant diff --git a/src/libcalamares/modulesystem/RequirementsModel.h b/src/libcalamares/modulesystem/RequirementsModel.h index bd71ce81f..e6cd06854 100644 --- a/src/libcalamares/modulesystem/RequirementsModel.h +++ b/src/libcalamares/modulesystem/RequirementsModel.h @@ -61,8 +61,8 @@ public: QVariant data( const QModelIndex& index, int role ) const override; - int rowCount( const QModelIndex& ) const override; - int count() const { return m_requirements.count(); } + int rowCount( const QModelIndex& ) const override; // TODO 3.4 use qsizetype + int count() const { return static_cast< int >( m_requirements.count() ); } // TODO 3.4 use qsizetype ///@brief Debugging tool, describe the checking-state void describe() const; diff --git a/src/modules/fstab/main.py b/src/modules/fstab/main.py index 78cae6349..bd7ae77c3 100755 --- a/src/modules/fstab/main.py +++ b/src/modules/fstab/main.py @@ -151,8 +151,12 @@ class FstabGenerator(object): if not mapper_name or not luks_uuid: return None - password = "/crypto_keyfile.bin" crypttab_options = self.crypttab_options + # Make sure to not use missing keyfile + if os.path.isfile(os.path.join(self.root_mount_point, "crypto_keyfile.bin")): + password = "/crypto_keyfile.bin" + else: + password = "none" # Set crypttab password for partition to none and remove crypttab options # if root partition was not encrypted diff --git a/src/modules/keyboard/non-ascii-layouts b/src/modules/keyboard/non-ascii-layouts index 21c5704f6..e7fb7b289 100644 --- a/src/modules/keyboard/non-ascii-layouts +++ b/src/modules/keyboard/non-ascii-layouts @@ -11,6 +11,8 @@ he us - he ar us - ar ir us - fa +# This list is from /usr/share/X11/xkb/rules/base, all the non-latin +# layouts are collected in $nonlatin . Add us (English) to all of them. af us - af am us - am ara us - ara diff --git a/src/modules/partition/CMakeLists.txt b/src/modules/partition/CMakeLists.txt index 5a92e713e..3af8e4465 100644 --- a/src/modules/partition/CMakeLists.txt +++ b/src/modules/partition/CMakeLists.txt @@ -60,6 +60,7 @@ if(KPMcore_FOUND) core/DeviceList.cpp core/DeviceModel.cpp core/KPMHelpers.cpp + core/OsproberEntry.cpp core/PartitionActions.cpp core/PartitionCoreModule.cpp core/PartitionInfo.cpp diff --git a/src/modules/partition/Config.cpp b/src/modules/partition/Config.cpp index 2010fecdd..f4e404c28 100644 --- a/src/modules/partition/Config.cpp +++ b/src/modules/partition/Config.cpp @@ -444,6 +444,7 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) m_allowZfsEncryption = Calamares::getBool( configurationMap, "allowZfsEncryption", true ); m_allowManualPartitioning = Calamares::getBool( configurationMap, "allowManualPartitioning", true ); + m_preCheckEncryption = Calamares::getBool( configurationMap, "preCheckEncryption", false ); m_showNotEncryptedBootMessage = Calamares::getBool( configurationMap, "showNotEncryptedBootMessage", true ); m_requiredPartitionTableType = Calamares::getStringList( configurationMap, "requiredPartitionTableType" ); diff --git a/src/modules/partition/Config.h b/src/modules/partition/Config.h index d8d68c6d2..8ec139169 100644 --- a/src/modules/partition/Config.h +++ b/src/modules/partition/Config.h @@ -35,7 +35,7 @@ class Config : public QObject replaceModeFilesystemChanged ) Q_PROPERTY( bool allowManualPartitioning READ allowManualPartitioning CONSTANT FINAL ) - + Q_PROPERTY( bool preCheckEncryption READ preCheckEncryption CONSTANT FINAL ) Q_PROPERTY( bool showNotEncryptedBootMessage READ showNotEncryptedBootMessage CONSTANT FINAL ) public: @@ -148,6 +148,13 @@ public: /// @brief Is manual partitioning allowed (not explicitly disabled in the config file)? bool allowManualPartitioning() const { return m_allowManualPartitioning; } + /** @brief Pre-check encryption checkbox. + * + * This is meaningful only if enableLuksAutomatedPartitioning is @c true. + * Default value is @c false + */ + bool preCheckEncryption() const { return m_preCheckEncryption; } + /// @brief Show "Boot partition not encrypted" warning (not explicitly disabled in the config file)? bool showNotEncryptedBootMessage() const { return m_showNotEncryptedBootMessage; } @@ -199,6 +206,7 @@ private: QStringList m_requiredPartitionTableType; bool m_allowZfsEncryption = true; bool m_allowManualPartitioning = true; + bool m_preCheckEncryption = false; bool m_showNotEncryptedBootMessage = true; }; diff --git a/src/modules/partition/PartitionViewStep.cpp b/src/modules/partition/PartitionViewStep.cpp index 119bf1baa..db087b59d 100644 --- a/src/modules/partition/PartitionViewStep.cpp +++ b/src/modules/partition/PartitionViewStep.cpp @@ -223,9 +223,15 @@ PartitionViewStep::prettyStatus() const const QList< PartitionCoreModule::SummaryInfo > list = m_core->createSummaryInfo(); cDebug() << "Summary for Partition" << list.length() << choice; - auto joinDiskInfo = [ 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 diskInfoLabel = [ &choice, &list ]() + { + QStringList s; + for ( const auto& i : list ) + { + s.append( diskDescription( 1, i, choice ) ); + } + return s.join( QString() ); + }(); const QString jobsLabel = jobDescriptions( jobs() ).join( QStringLiteral( "
" ) ); return diskInfoLabel + "
" + jobsLabel; } diff --git a/src/modules/partition/core/OsproberEntry.cpp b/src/modules/partition/core/OsproberEntry.cpp new file mode 100644 index 000000000..4a59f7d07 --- /dev/null +++ b/src/modules/partition/core/OsproberEntry.cpp @@ -0,0 +1,63 @@ +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2015-2016 Teo Mrnjavac + * SPDX-FileCopyrightText: 2018-2019, 2024 Adriaan de Groot + * SPDX-FileCopyrightText: 2019 Collabora Ltd + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Calamares is Free Software: see the License-Identifier above. + * + */ + +#include "OsproberEntry.h" + + +bool +FstabEntry::isValid() const +{ + return !partitionNode.isEmpty() && !mountPoint.isEmpty() && !fsType.isEmpty(); +} + +FstabEntry +FstabEntry::fromEtcFstab( const QString& rawLine ) +{ + QString line = rawLine.simplified(); + if ( line.startsWith( '#' ) ) + { + return FstabEntry { QString(), QString(), QString(), QString(), 0, 0 }; + } + + QStringList splitLine = line.split( ' ' ); + if ( splitLine.length() != 6 ) + { + return FstabEntry { QString(), QString(), QString(), QString(), 0, 0 }; + } + + return FstabEntry { + splitLine.at( 0 ), // path, or UUID, or LABEL, etc. + splitLine.at( 1 ), // mount point + splitLine.at( 2 ), // fs type + splitLine.at( 3 ), // options + splitLine.at( 4 ).toInt(), //dump + splitLine.at( 5 ).toInt() //pass + }; +} + +namespace Calamares +{ +FstabEntryList +fromEtcFstabContents( const QStringList& fstabLines ) +{ + FstabEntryList fstabEntries; + + for ( const QString& rawLine : fstabLines ) + { + fstabEntries.append( FstabEntry::fromEtcFstab( rawLine ) ); + } + const auto invalidEntries = std::remove_if( + fstabEntries.begin(), fstabEntries.end(), []( const FstabEntry& x ) { return !x.isValid(); } ); + fstabEntries.erase( invalidEntries, fstabEntries.end() ); + return fstabEntries; +} + +} // namespace Calamares diff --git a/src/modules/partition/core/OsproberEntry.h b/src/modules/partition/core/OsproberEntry.h index 86b7691b8..0db7c9a51 100644 --- a/src/modules/partition/core/OsproberEntry.h +++ b/src/modules/partition/core/OsproberEntry.h @@ -32,11 +32,24 @@ struct FstabEntry * If the string isn't valid (e.g. comment-line, or broken * fstab entry) then the entry that is returned is invalid. */ - static FstabEntry fromEtcFstab( const QString& ); // implemented in Partutils.cpp + static FstabEntry fromEtcFstab( const QString& ); }; typedef QList< FstabEntry > FstabEntryList; +namespace Calamares +{ +/** @brief Returns valid entries from the lines of a fstab file */ +FstabEntryList fromEtcFstabContents( const QStringList& fstabLines ); + +/** @brief Returns valid entries from the byte-contents of a fstab file */ +inline FstabEntryList +fromEtcFstabContents( const QByteArray& contents ) +{ + return fromEtcFstabContents( QString::fromLocal8Bit( contents ).split( '\n' ) ); +} +} // namespace Calamares + struct OsproberEntry { QString prettyName; diff --git a/src/modules/partition/core/PartUtils.cpp b/src/modules/partition/core/PartUtils.cpp index e233403b4..9818ea71f 100644 --- a/src/modules/partition/core/PartUtils.cpp +++ b/src/modules/partition/core/PartUtils.cpp @@ -254,30 +254,25 @@ lookForFstabEntries( const QString& partitionPath ) if ( fstabFile.open( QIODevice::ReadOnly | QIODevice::Text ) ) { - const QStringList fstabLines = QString::fromLocal8Bit( fstabFile.readAll() ).split( '\n' ); - - for ( const QString& rawLine : fstabLines ) - { - fstabEntries.append( FstabEntry::fromEtcFstab( rawLine ) ); - } + const auto fstabLines = QString::fromLocal8Bit( fstabFile.readAll() ).split( '\n' ); fstabFile.close(); - const int lineCount = fstabEntries.count(); - std::remove_if( - fstabEntries.begin(), fstabEntries.end(), []( const FstabEntry& x ) { return !x.isValid(); } ); - cDebug() << Logger::SubEntry << "got" << fstabEntries.count() << "fstab entries from" << lineCount + + const auto fstabEntries = Calamares::fromEtcFstabContents( fstabLines ); + cDebug() << Logger::SubEntry << "got" << fstabEntries.count() << "fstab entries from" << fstabLines.count() << "lines in" << fstabFile.fileName(); + return fstabEntries; } else { cWarning() << "Could not read fstab from mounted fs"; + return {}; } } else { cWarning() << "Could not mount existing fs"; + return {}; } - - return fstabEntries; } static QString @@ -641,36 +636,3 @@ canonicalFilesystemName( const QString& fsName, FileSystem::Type* fsType ) } } // namespace PartUtils - -/* Implementation of methods for FstabEntry, from OsproberEntry.h */ - -bool -FstabEntry::isValid() const -{ - return !partitionNode.isEmpty() && !mountPoint.isEmpty() && !fsType.isEmpty(); -} - -FstabEntry -FstabEntry::fromEtcFstab( const QString& rawLine ) -{ - QString line = rawLine.simplified(); - if ( line.startsWith( '#' ) ) - { - return FstabEntry { QString(), QString(), QString(), QString(), 0, 0 }; - } - - QStringList splitLine = line.split( ' ' ); - if ( splitLine.length() != 6 ) - { - return FstabEntry { QString(), QString(), QString(), QString(), 0, 0 }; - } - - return FstabEntry { - splitLine.at( 0 ), // path, or UUID, or LABEL, etc. - splitLine.at( 1 ), // mount point - splitLine.at( 2 ), // fs type - splitLine.at( 3 ), // options - splitLine.at( 4 ).toInt(), //dump - splitLine.at( 5 ).toInt() //pass - }; -} diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index 5cddfe798..62cf0f6e1 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -185,7 +185,6 @@ ChoicePage::init( PartitionCoreModule* core ) setModelToComboBox( m_drivesCombo, core->deviceModel() ); connect( m_drivesCombo, qOverload< int >( &QComboBox::currentIndexChanged ), this, &ChoicePage::applyDeviceChoice ); - connect( m_encryptWidget, &EncryptWidget::stateChanged, this, &ChoicePage::onEncryptWidgetStateChanged ); connect( m_reuseHomeCheckBox, &QCheckBox::stateChanged, this, &ChoicePage::onHomeCheckBoxStateChanged ); @@ -468,6 +467,8 @@ ChoicePage::onActionChanged() { m_encryptWidget->setFilesystem( FileSystem::typeForName( m_replaceFsTypesChoiceComboBox->currentText() ) ); } + + m_encryptWidget->setEncryptionCheckbox( m_config->preCheckEncryption() ); } Device* currd = selectedDevice(); @@ -679,7 +680,11 @@ ChoicePage::onLeave() { if ( m_config->installChoice() == InstallChoice::Alongside ) { - doAlongsideApply(); + if ( m_afterPartitionSplitterWidget->splitPartitionSize() >= 0 + && m_afterPartitionSplitterWidget->newPartitionSize() >= 0 ) + { + doAlongsideApply(); + } } if ( m_isEfi @@ -1579,7 +1584,10 @@ ChoicePage::calculateNextEnabled() const } } - if ( m_config->installChoice() != InstallChoice::Manual && m_encryptWidget->isVisible() ) + // You can have an invisible encryption checkbox, which is + // still checked -- then do the encryption. + if ( m_config->installChoice() != InstallChoice::Manual + && ( m_encryptWidget->isVisible() || m_encryptWidget->isEncryptionCheckboxChecked() ) ) { switch ( m_encryptWidget->state() ) { diff --git a/src/modules/partition/gui/EncryptWidget.cpp b/src/modules/partition/gui/EncryptWidget.cpp index 73a6b6f8b..8726df147 100644 --- a/src/modules/partition/gui/EncryptWidget.cpp +++ b/src/modules/partition/gui/EncryptWidget.cpp @@ -70,6 +70,18 @@ EncryptWidget::EncryptWidget( QWidget* parent ) CALAMARES_RETRANSLATE_SLOT( &EncryptWidget::retranslate ); } +bool +EncryptWidget::isEncryptionCheckboxChecked() +{ + return m_ui->m_encryptCheckBox->isChecked(); +} + +void +EncryptWidget::setEncryptionCheckbox( bool preCheckEncrypt ) +{ + m_ui->m_encryptCheckBox->setChecked( preCheckEncrypt ); +} + void EncryptWidget::reset( bool checkVisible ) { @@ -170,15 +182,10 @@ EncryptWidget::updateState( const bool notify ) } } - Encryption newState = state(); - - if ( newState != m_state ) + m_state = state(); + if ( notify ) { - m_state = newState; - if ( notify ) - { - Q_EMIT stateChanged( m_state ); - } + Q_EMIT stateChanged( m_state ); } } diff --git a/src/modules/partition/gui/EncryptWidget.h b/src/modules/partition/gui/EncryptWidget.h index 9669b4d21..c7cc23daa 100644 --- a/src/modules/partition/gui/EncryptWidget.h +++ b/src/modules/partition/gui/EncryptWidget.h @@ -36,8 +36,10 @@ public: explicit EncryptWidget( QWidget* parent = nullptr ); + void setEncryptionCheckbox( bool preCheckEncrypt = false); void reset( bool checkVisible = true ); + bool isEncryptionCheckboxChecked(); Encryption state() const; void setText( const QString& text ); diff --git a/src/modules/partition/partition.conf b/src/modules/partition/partition.conf index 0975179de..3d335432f 100644 --- a/src/modules/partition/partition.conf +++ b/src/modules/partition/partition.conf @@ -240,6 +240,11 @@ defaultFileSystemType: "ext4" # If nothing is specified, LUKS is enabled in automated modes. #enableLuksAutomatedPartitioning: true +# When enableLuksAutomatedPartitioning is true, this option will pre-check +# encryption checkbox. This option is only usefull to help people to not forget +# to cypher their disk when installing in enterprise (for exemple). +#preCheckEncryption: false + # Partition layout. # # This optional setting specifies a custom partition layout. diff --git a/src/modules/partition/partition.schema.yaml b/src/modules/partition/partition.schema.yaml index 769c1abae..65bc723f5 100644 --- a/src/modules/partition/partition.schema.yaml +++ b/src/modules/partition/partition.schema.yaml @@ -34,6 +34,7 @@ properties: luksGeneration: { type: string, enum: [luks1, luks2] } # Also allows "luks" as alias of "luks1" enableLuksAutomatedPartitioning: { type: boolean, default: false } + preCheckEncryption: { type: boolean, default: false } allowManualPartitioning: { type: boolean, default: true } showNotEncryptedBootMessage: { type: boolean, default: true } diff --git a/src/modules/partition/tests/CMakeLists.txt b/src/modules/partition/tests/CMakeLists.txt index 1cb4ff7a1..3418859c4 100644 --- a/src/modules/partition/tests/CMakeLists.txt +++ b/src/modules/partition/tests/CMakeLists.txt @@ -14,6 +14,12 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) +set(PartitionModule_basic_SRC + ${PartitionModule_SOURCE_DIR}/core/OsproberEntry.cpp + ${PartitionModule_SOURCE_DIR}/core/PartitionInfo.cpp + ${PartitionModule_SOURCE_DIR}/core/PartUtils.cpp + ) + calamares_add_test( partitionjobtest SOURCES @@ -40,10 +46,9 @@ calamares_add_test( partitioncreatelayoutstest SOURCES CreateLayoutsTests.cpp + ${PartitionModule_basic_SRC} ${PartitionModule_SOURCE_DIR}/core/KPMHelpers.cpp - ${PartitionModule_SOURCE_DIR}/core/PartitionInfo.cpp ${PartitionModule_SOURCE_DIR}/core/PartitionLayout.cpp - ${PartitionModule_SOURCE_DIR}/core/PartUtils.cpp ${PartitionModule_SOURCE_DIR}/core/DeviceModel.cpp LIBRARIES calamares::kpmcore Calamares::calamaresui DEFINITIONS ${_partition_defs} @@ -66,9 +71,8 @@ calamares_add_test( partitionconfigtest SOURCES ConfigTests.cpp + ${PartitionModule_basic_SRC} ${PartitionModule_SOURCE_DIR}/core/DeviceModel.cpp - ${PartitionModule_SOURCE_DIR}/core/PartitionInfo.cpp - ${PartitionModule_SOURCE_DIR}/core/PartUtils.cpp ${PartitionModule_SOURCE_DIR}/Config.cpp LIBRARIES calamares::kpmcore Calamares::calamaresui DEFINITIONS diff --git a/src/modules/partition/tests/ConfigTests.cpp b/src/modules/partition/tests/ConfigTests.cpp index eae912f71..0e030d57e 100644 --- a/src/modules/partition/tests/ConfigTests.cpp +++ b/src/modules/partition/tests/ConfigTests.cpp @@ -9,6 +9,7 @@ #include "Config.h" +#include "core/OsproberEntry.h" #include "core/PartUtils.h" #include "GlobalStorage.h" @@ -17,6 +18,7 @@ #include "utils/System.h" #include "utils/Yaml.h" +#include #include #include @@ -35,6 +37,9 @@ private Q_SLOTS: void testLegacySize(); void testAll(); void testWeirdConfig(); + + void testNormalFstab(); + void testWeirdFstab(); }; ConfigTests::ConfigTests() = default; @@ -222,6 +227,48 @@ ConfigTests::testWeirdConfig() } } +void +ConfigTests::testNormalFstab() +{ + const auto contents + = QByteArrayLiteral( "# A FreeBSD fstab\n" + "/dev/nvd0p3 none swap sw 0 0\n" ); + const auto entries = Calamares::fromEtcFstabContents( contents ); + for ( const auto& e : entries ) + { + QVERIFY( e.isValid() ); + } + QCOMPARE( entries.count(), 1 ); +} + +void +ConfigTests::testWeirdFstab() +{ + const auto contents + = QByteArrayLiteral( "# \n" + "UUID=dae80d0a-f6c7-46f4-a04a-6761f2cfd9b6 / ext4 defaults,noatime 0 1\n" + "UUID=423892d5-a929-41a9-a846-f410cf3fe25b swap swap defaults,noatime 0 2\n" + "# another comment\n" + "borked 2\n" + "ok /dev1 ext4 none 0 0\n" + "bogus /dev2 ext4 none no later\n" + "# comment\n" ); + const auto entries = Calamares::fromEtcFstabContents( contents ); + QCOMPARE( entries.count(), 4 ); + + QStringList mountPoints; + for ( const auto& e : entries ) + { + mountPoints.append( e.mountPoint ); + } + mountPoints.sort(); + QCOMPARE( mountPoints, + QStringList() << "/" + << "/dev1" + << "/dev2" + << "swap" ); +} + QTEST_GUILESS_MAIN( ConfigTests ) diff --git a/src/modules/users/ActiveDirectoryJob.cpp b/src/modules/users/ActiveDirectoryJob.cpp index deb4c82d7..97a9f3cf7 100644 --- a/src/modules/users/ActiveDirectoryJob.cpp +++ b/src/modules/users/ActiveDirectoryJob.cpp @@ -51,7 +51,6 @@ ActiveDirectoryJob::exec() if ( !m_ip.isEmpty() ) { const QString hostsFilePath = Calamares::System::instance()->targetPath( QStringLiteral( "/etc/hosts" ) ); - ; QFile hostsFile( hostsFilePath ); if ( hostsFile.open( QIODevice::Append | QIODevice::Text ) ) { diff --git a/src/modules/welcome/checker/ResultDelegate.cpp b/src/modules/welcome/checker/ResultDelegate.cpp index 060febbb5..19f906a0d 100644 --- a/src/modules/welcome/checker/ResultDelegate.cpp +++ b/src/modules/welcome/checker/ResultDelegate.cpp @@ -35,7 +35,7 @@ paintRequirement( QPainter* painter, const QStyleOptionViewItem& option, const Q Calamares::ImageType statusImage = Calamares::StatusOk; - painter->setPen( QColorConstants::Black ); + painter->setPen( Qt::black ); if ( index.data( Calamares::RequirementsModel::Satisfied ).toBool() ) { painter->fillRect( textRect, option.palette.window().color() );