CI: apply style tool across the entire codebase

This commit is contained in:
Adriaan de Groot 2023-10-17 22:24:46 +02:00
parent e1747af296
commit 63b0589382
84 changed files with 232 additions and 106 deletions

View File

@ -20,10 +20,10 @@
#include "ViewManager.h"
#include "locale/TranslationsModel.h"
#include "modulesystem/ModuleManager.h"
#include "utils/Gui.h"
#include "utils/System.h"
#include "utils/Dirs.h"
#include "utils/Gui.h"
#include "utils/Logger.h"
#include "utils/System.h"
#ifdef WITH_QML
#include "utils/Qml.h"
#endif
@ -121,10 +121,12 @@ brandingFileCandidates( bool assumeBuilddir, const QString& brandingFilename )
brandingPaths << ( QDir::currentPath() + QStringLiteral( "/src/" ) + brandingFilename );
}
if ( Calamares::haveExtraDirs() )
{
for ( auto s : Calamares::extraDataDirs() )
{
brandingPaths << ( s + brandingFilename );
}
}
brandingPaths << QDir( CMAKE_INSTALL_FULL_SYSCONFDIR "/calamares/" ).absoluteFilePath( brandingFilename );
brandingPaths << Calamares::appDataDir().absoluteFilePath( brandingFilename );
}

View File

@ -169,7 +169,8 @@ getWidgetSidebar( Calamares::DebugWindowManager* debug,
debugWindowBtn->setIcon( Calamares::defaultPixmap(
Calamares::Bugs, Calamares::Original, 2 * QSize( defaultFontHeight, defaultFontHeight ) ) );
CALAMARES_RETRANSLATE_FOR(
debugWindowBtn, debugWindowBtn->setText( QCoreApplication::translate( "calamares-sidebar", "Debug", "@button" ) );
debugWindowBtn,
debugWindowBtn->setText( QCoreApplication::translate( "calamares-sidebar", "Debug", "@button" ) );
debugWindowBtn->setToolTip(
QCoreApplication::translate( "calamares-sidebar", "Show debug information", "@tooltip" ) ); );
extraButtons->addWidget( debugWindowBtn );
@ -197,8 +198,8 @@ getWidgetNavigation( Calamares::DebugWindowManager*,
// Create buttons and sets an initial icon; the icons may change
{
auto* back
= new QPushButton( getButtonIcon( QStringLiteral( "go-previous" ) ),
auto* back = new QPushButton(
getButtonIcon( QStringLiteral( "go-previous" ) ),
QCoreApplication::translate( CalamaresWindow::staticMetaObject.className(), "&Back", "@button" ),
navigation );
back->setObjectName( "view-button-back" );
@ -213,8 +214,8 @@ getWidgetNavigation( Calamares::DebugWindowManager*,
bottomLayout->addWidget( back );
}
{
auto* next
= new QPushButton( getButtonIcon( QStringLiteral( "go-next" ) ),
auto* next = new QPushButton(
getButtonIcon( QStringLiteral( "go-next" ) ),
QCoreApplication::translate( CalamaresWindow::staticMetaObject.className(), "&Next", "@button" ),
navigation );
next->setObjectName( "view-button-next" );
@ -230,8 +231,8 @@ getWidgetNavigation( Calamares::DebugWindowManager*,
}
bottomLayout->addSpacing( 12 );
{
auto* quit
= new QPushButton( getButtonIcon( QStringLiteral( "dialog-cancel" ) ),
auto* quit = new QPushButton(
getButtonIcon( QStringLiteral( "dialog-cancel" ) ),
QCoreApplication::translate( CalamaresWindow::staticMetaObject.className(), "&Cancel", "@button" ),
navigation );
quit->setObjectName( "view-button-cancel" );

View File

@ -10,8 +10,8 @@
#include "ProcessJob.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include <QDir>
@ -51,10 +51,13 @@ ProcessJob::exec()
using Calamares::System;
if ( m_runInChroot )
{
return Calamares::System::instance()
->targetEnvCommand( { m_command }, m_workingPath, QString(), m_timeoutSec )
.explainProcess( m_command, m_timeoutSec );
}
else
{
return System::runCommand( System::RunLocation::RunInHost,
{ "/bin/sh", "-c", m_command },
m_workingPath,
@ -62,5 +65,6 @@ ProcessJob::exec()
m_timeoutSec )
.explainProcess( m_command, m_timeoutSec );
}
}
} // namespace Calamares

View File

@ -15,11 +15,11 @@
#include "PythonHelper.h"
#include "locale/Global.h"
#include "partition/Mount.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/RAII.h"
#include "utils/Runner.h"
#include "utils/String.h"
#include "utils/System.h"
#include "utils/Yaml.h"
#include <QCoreApplication>

View File

@ -384,10 +384,12 @@ settingsFileCandidates( bool assumeBuilddir )
settingsPaths << QDir::current().absoluteFilePath( settings );
}
if ( Calamares::haveExtraDirs() )
{
for ( auto s : Calamares::extraConfigDirs() )
{
settingsPaths << ( s + settings );
}
}
settingsPaths << CMAKE_INSTALL_FULL_SYSCONFDIR "/calamares/settings.conf"; // String concat
settingsPaths << Calamares::appDataDir().absoluteFilePath( settings );
}

View File

@ -78,10 +78,12 @@ TranslationsModel::locale( int row ) const
if ( ( row < 0 ) || ( row >= m_locales.count() ) )
{
for ( const auto& l : m_locales )
{
if ( l->isEnglish() )
{
return *l;
}
}
return *m_locales[ 0 ];
}
return *m_locales[ row ];

View File

@ -74,10 +74,12 @@ moduleConfigurationCandidates( bool assumeBuildDir, const QString& moduleName, c
}
if ( Calamares::haveExtraDirs() )
{
for ( auto s : Calamares::extraConfigDirs() )
{
paths << ( s + QString( "modules/%1" ).arg( configFileName ) );
}
}
paths << QString( "/etc/calamares/modules/%1" ).arg( configFileName );
paths << Calamares::appDataDir().absoluteFilePath( QString( "modules/%1" ).arg( configFileName ) );

View File

@ -12,9 +12,9 @@
#include "Mount.h"
#include "partition/Sync.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/String.h"
#include "utils/System.h"
#include <QDir>
#include <QTemporaryDir>

View File

@ -58,11 +58,15 @@ Partition*
findPartitionByCurrentMountPoint( const QList< Device* >& devices, const QString& mountPoint )
{
for ( auto device : devices )
{
for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it )
{
if ( ( *it )->mountPoint() == mountPoint )
{
return *it;
}
}
}
return nullptr;
}

View File

@ -10,8 +10,8 @@
#include "Sync.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
void
Calamares::Partition::sync()

View File

@ -94,7 +94,7 @@ namespace Python __attribute__( ( visibility( "hidden" ) ) )
};
} // namespace )
} // namespace Python
} // namespace Calamares
#endif

View File

@ -33,6 +33,6 @@ namespace Python __attribute__( ( visibility( "hidden" ) ) )
return QString::fromUtf8( pybind11::str( o ).cast< std::string >().c_str() );
}
} // namespace )
} // namespace Python
} // namespace Calamares
#endif

View File

@ -14,9 +14,9 @@
#include "JobQueue.h"
#include "compat/Variant.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/StringExpander.h"
#include "utils/System.h"
#include "utils/Variant.h"
#include <QCoreApplication>

View File

@ -249,6 +249,7 @@ operator<<( QDebug& s, const RedactedCommand& l )
if ( l.list.contains( "usermod" ) )
{
for ( const auto& item : l.list )
{
if ( item.startsWith( "$6$" ) )
{
s << "<password>";
@ -258,6 +259,7 @@ operator<<( QDebug& s, const RedactedCommand& l )
s << item;
}
}
}
else
{
s << l.list;

View File

@ -164,11 +164,13 @@ struct NamedEnumTable
ok = false;
for ( const auto& p : table )
{
if ( 0 == QString::compare( s, p.first, Qt::CaseInsensitive ) )
{
ok = true;
return p.second;
}
}
// ok is still false
return table.begin()->second;
@ -207,11 +209,13 @@ struct NamedEnumTable
ok = false;
for ( const auto& p : table )
{
if ( s == p.second )
{
ok = true;
return p.first;
}
}
// ok is still false
return string_t();

View File

@ -65,6 +65,7 @@ public:
: NamedSuffix()
{
for ( const auto& suffix : table.table )
{
if ( s.endsWith( suffix.first ) )
{
m_value = s.left( s.length() - suffix.first.length() ).toLongLong();
@ -72,6 +73,7 @@ public:
break;
}
}
}
/** @brief Construct value from string.
*

View File

@ -7,8 +7,8 @@
#include "Permissions.h"
#include "System.h"
#include "Logger.h"
#include "System.h"
#include <QString>
#include <QStringList>

View File

@ -104,7 +104,9 @@ protected:
{ \
pluginRegistrations; \
} \
name::~name() {}
name::~name() \
{ \
}
Q_DECLARE_INTERFACE( CalamaresPluginFactory, CalamaresPluginFactory_iid )

View File

@ -262,6 +262,7 @@ System::getCpuDescription() const
#ifdef Q_OS_LINUX
QFile file( "/proc/cpuinfo" );
if ( file.open( QIODevice::ReadOnly | QIODevice::Text ) )
{
while ( !file.atEnd() )
{
QByteArray line = file.readLine();
@ -271,6 +272,7 @@ System::getCpuDescription() const
break;
}
}
}
#elif defined( Q_OS_FREEBSD )
// This would use sysctl "hw.model", which has a string value
#endif
@ -303,29 +305,37 @@ ProcessResult::explainProcess( int ec, const QString& command, const QString& ou
? QCoreApplication::translate( "ProcessResult", "\nThere was no output from the command." )
: ( QCoreApplication::translate( "ProcessResult", "\nOutput:\n" ) + output );
if ( ec == static_cast< int >( ProcessResult::Code::Crashed ) ) //Crash!
if ( ec == static_cast< int >( ProcessResult::Code::Crashed ) )
{ //Crash!
return JobResult::error(
QCoreApplication::translate( "ProcessResult", "External command crashed." ),
QCoreApplication::translate( "ProcessResult", "Command <i>%1</i> crashed." ).arg( command )
+ outputMessage );
}
if ( ec == static_cast< int >( ProcessResult::Code::FailedToStart ) )
{
return JobResult::error(
QCoreApplication::translate( "ProcessResult", "External command failed to start." ),
QCoreApplication::translate( "ProcessResult", "Command <i>%1</i> failed to start." ).arg( command ) );
}
if ( ec == static_cast< int >( ProcessResult::Code::NoWorkingDirectory ) )
{
return JobResult::error(
QCoreApplication::translate( "ProcessResult", "Internal error when starting command." ),
QCoreApplication::translate( "ProcessResult", "Bad parameters for process job call." ) );
}
if ( ec == static_cast< int >( ProcessResult::Code::TimedOut ) )
{
return JobResult::error(
QCoreApplication::translate( "ProcessResult", "External command failed to finish." ),
QCoreApplication::translate( "ProcessResult", "Command <i>%1</i> failed to finish in %2 seconds." )
.arg( command )
.arg( timeout.count() )
+ outputMessage );
}
//Any other exit code
return JobResult::error(

View File

@ -9,9 +9,9 @@
*
*/
#include "System.h"
#include "Entropy.h"
#include "Logger.h"
#include "System.h"
#include "UMask.h"
#include "Yaml.h"

View File

@ -9,7 +9,6 @@
*
*/
#include "System.h"
#include "CommandList.h"
#include "Entropy.h"
#include "Logger.h"
@ -17,6 +16,7 @@
#include "Runner.h"
#include "String.h"
#include "StringExpander.h"
#include "System.h"
#include "Traits.h"
#include "UMask.h"
#include "Variant.h"
@ -183,7 +183,9 @@ findConf( const QDir& d )
QString path = d.absolutePath();
path.append( d.separator() );
for ( const auto& confname : d.entryList( { "*.conf" } ) )
{
mine.append( path + confname );
}
for ( const auto& subdirname : d.entryList( QDir::AllDirs | QDir::NoDotAndDotDot ) )
{
QDir subdir( d );

View File

@ -229,9 +229,11 @@ Branding::Branding( const QString& brandingFilePath, QObject* parent, qreal devi
m_componentName = QString::fromStdString( doc[ "componentName" ].as< std::string >() );
if ( m_componentName != componentDir.dirName() )
{
bail( m_descriptorPath,
"The branding component name should match the name of the "
"component directory." );
}
initSimpleSettings( doc );
initSlideshowSettings( doc );
@ -630,9 +632,11 @@ Branding::initSlideshowSettings( const ::YAML::Node& doc )
QString slideshowPath = QString::fromStdString( slideshow.as< std::string >() );
QFileInfo slideshowFi( componentDir.absoluteFilePath( slideshowPath ) );
if ( !slideshowFi.exists() || !slideshowFi.fileName().toLower().endsWith( ".qml" ) )
{
bail( m_descriptorPath,
QString( "Slideshow file %1 does not exist or is not a valid QML file." )
.arg( slideshowFi.absoluteFilePath() ) );
}
m_slideshowPath = slideshowFi.absoluteFilePath();
// API choice is relevant for QML slideshow

View File

@ -420,11 +420,13 @@ ModuleManager::checkModuleDependencies( const Module& m )
{
bool requirementFound = false;
for ( const Module* v : m_loadedModulesByInstanceKey )
{
if ( required == v->name() )
{
requirementFound = true;
break;
}
}
if ( !requirementFound )
{
cError() << "Module" << m.name() << "requires" << required << "before it in sequence.";

View File

@ -57,10 +57,12 @@ qmlDirCandidates( bool assumeBuilddir )
qmlDirs << QDir::current().absoluteFilePath( "src/qml" ); // In build-dir
}
if ( Calamares::haveExtraDirs() )
{
for ( auto s : Calamares::extraDataDirs() )
{
qmlDirs << ( s + QML );
}
}
qmlDirs << Calamares::appDataDir().absoluteFilePath( QML );
}

View File

@ -14,9 +14,9 @@
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "utils/System.h"
#include "utils/CommandList.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include "utils/Yaml.h"
#include <QtTest/QtTest>

View File

@ -19,8 +19,8 @@
#include "JobQueue.h"
#include "compat/Variant.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
DummyCppJob::DummyCppJob( QObject* parent )
: Calamares::CppJob( parent )

View File

@ -157,9 +157,11 @@ Calamares::JobResult
ResizeFSJob::exec()
{
if ( !isValid() )
{
return Calamares::JobResult::error(
tr( "Invalid configuration" ),
tr( "The file-system resize job has an invalid configuration and will not run." ) );
}
if ( !m_kpmcore )
{
@ -172,11 +174,13 @@ ResizeFSJob::exec()
// Now get the partition and FS we want to work on
PartitionMatch m = findPartition();
if ( !m.first || !m.second )
{
return Calamares::JobResult::error(
tr( "Resize Failed" ),
!m_fsname.isEmpty()
? tr( "The filesystem %1 could not be found in this system, and cannot be resized." ).arg( m_fsname )
: tr( "The device %1 could not be found in this system, and cannot be resized." ).arg( m_devicename ) );
}
m.second->fileSystem().init(); // Initialize support for specific FS
if ( !ResizeOperation::canGrow( m.second ) )
@ -193,18 +197,22 @@ ResizeFSJob::exec()
<< ')' << "to -" << new_end;
if ( new_end < 0 )
{
return Calamares::JobResult::error( tr( "Resize Failed" ),
!m_fsname.isEmpty()
? tr( "The filesystem %1 cannot be resized." ).arg( m_fsname )
: tr( "The device %1 cannot be resized." ).arg( m_devicename ) );
}
if ( new_end == 0 )
{
cWarning() << "Resize operation on" << m_fsname << m_devicename << "skipped as not-useful.";
if ( m_required )
{
return Calamares::JobResult::error(
tr( "Resize Failed" ),
!m_fsname.isEmpty() ? tr( "The filesystem %1 must be resized, but cannot." ).arg( m_fsname )
: tr( "The device %1 must be resized, but cannot" ).arg( m_fsname ) );
}
return Calamares::JobResult::ok();
}

View File

@ -11,8 +11,8 @@
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include "utils/Units.h"
#include <QDir>

View File

@ -10,8 +10,8 @@
#include "InitcpioJob.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include "utils/UMask.h"
#include "utils/Variant.h"

View File

@ -9,8 +9,8 @@
#include "InitramfsJob.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include "utils/UMask.h"
#include "utils/Variant.h"

View File

@ -13,8 +13,8 @@
#include "JobQueue.h"
#include "Settings.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include "utils/Yaml.h"
#include <QtTest/QtTest>

View File

@ -19,9 +19,9 @@
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/String.h"
#include "utils/System.h"
#include <QDir>
#include <QFile>
@ -37,7 +37,7 @@ removeEmpty(QStringList&& list)
list.removeAll( QString() );
return list;
}
}
} // namespace
SetKeyboardLayoutJob::SetKeyboardLayoutJob( const QString& model,
const QString& layout,
@ -290,8 +290,8 @@ SetKeyboardLayoutJob::writeX11Data( const QString& keyboardConfPath ) const
file.close();
cDebug() << Logger::SubEntry << "Written XkbLayout" << layouts.join(",") << "; XkbModel" << m_model << "; XkbVariant"
<< variants.join(",") << "to X.org file" << keyboardConfPath << stream.status();
cDebug() << Logger::SubEntry << "Written XkbLayout" << layouts.join( "," ) << "; XkbModel" << m_model
<< "; XkbVariant" << variants.join( "," ) << "to X.org file" << keyboardConfPath << stream.status();
return ( stream.status() == QTextStream::Ok );
}
@ -327,8 +327,9 @@ SetKeyboardLayoutJob::writeDefaultKeyboardData( const QString& defaultKeyboardPa
file.close();
cDebug() << Logger::SubEntry << "Written XKBMODEL" << m_model << "; XKBLAYOUT" << layouts.join(",") << "; XKBVARIANT"
<< variants.join(",") << "to /etc/default/keyboard file" << defaultKeyboardPath << stream.status();
cDebug() << Logger::SubEntry << "Written XKBMODEL" << m_model << "; XKBLAYOUT" << layouts.join( "," )
<< "; XKBVARIANT" << variants.join( "," ) << "to /etc/default/keyboard file" << defaultKeyboardPath
<< stream.status();
return ( stream.status() == QTextStream::Ok );
}

View File

@ -30,8 +30,7 @@ class Config : public QObject
Q_PROPERTY( Calamares::Locale::ZonesModel* zonesModel READ zonesModel CONSTANT FINAL )
Q_PROPERTY( QAbstractItemModel* regionalZonesModel READ regionalZonesModel CONSTANT FINAL )
Q_PROPERTY(
Calamares::Locale::TimeZoneData* currentLocation READ currentLocation_c NOTIFY currentLocationChanged )
Q_PROPERTY( Calamares::Locale::TimeZoneData* currentLocation READ currentLocation_c NOTIFY currentLocationChanged )
// Status are complete, human-readable, messages
Q_PROPERTY( QString currentLocationStatus READ currentLocationStatus NOTIFY currentLanguageStatusChanged )

View File

@ -13,8 +13,8 @@
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "Settings.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include <QDir>
#include <QFileInfo>
@ -56,23 +56,29 @@ SetTimezoneJob::exec()
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
QFileInfo zoneFile( gs->value( "rootMountPoint" ).toString() + zoneinfoPath );
if ( !zoneFile.exists() || !zoneFile.isReadable() )
{
return Calamares::JobResult::error( tr( "Cannot access selected timezone path." ),
tr( "Bad path: %1" ).arg( zoneFile.absolutePath() ) );
}
// Make sure /etc/localtime doesn't exist, otherwise symlinking will fail
Calamares::System::instance()->targetEnvCall( { "rm", "-f", localtimeSlink } );
int ec = Calamares::System::instance()->targetEnvCall( { "ln", "-s", zoneinfoPath, localtimeSlink } );
if ( ec )
{
return Calamares::JobResult::error(
tr( "Cannot set timezone." ),
tr( "Link creation failed, target: %1; link name: %2" ).arg( zoneinfoPath ).arg( "/etc/localtime" ) );
}
QFile timezoneFile( gs->value( "rootMountPoint" ).toString() + "/etc/timezone" );
if ( !timezoneFile.open( QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate ) )
{
return Calamares::JobResult::error( tr( "Cannot set timezone," ),
tr( "Cannot open /etc/timezone for writing" ) );
}
QTextStream out( &timezoneFile );
out << m_region << '/' << m_zone << "\n";

View File

@ -310,7 +310,8 @@ LocaleTests::testLanguageDetection_data()
<< QStringLiteral( "en_US.UTF-8" );
QTest::newRow( "english (GB)" ) << QStringLiteral( "en" ) << QStringLiteral( "GB" )
<< QStringLiteral( "en_GB.UTF-8" );
QTest::newRow( "english (NL)" ) << QStringLiteral( "en" ) << QStringLiteral( "NL" ) << QStringLiteral( "en_US.UTF-8" );
QTest::newRow( "english (NL)" ) << QStringLiteral( "en" ) << QStringLiteral( "NL" )
<< QStringLiteral( "en_US.UTF-8" );
QTest::newRow( "portuguese (PT)" ) << QStringLiteral( "pt" ) << QStringLiteral( "PT" )
<< QStringLiteral( "pt_PT.UTF-8" );

View File

@ -7,10 +7,10 @@
#include "LuksBootKeyFileJob.h"
#include "utils/System.h"
#include "utils/Entropy.h"
#include "utils/Logger.h"
#include "utils/NamedEnum.h"
#include "utils/System.h"
#include "utils/UMask.h"
#include "utils/Variant.h"

View File

@ -10,11 +10,11 @@
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/Permissions.h"
#include "utils/PluginFactory.h"
#include "utils/String.h"
#include "utils/System.h"
#include "utils/Variant.h"
#include <QList>

View File

@ -10,8 +10,8 @@
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include <QtTest/QtTest>

View File

@ -13,8 +13,8 @@
#include "MachineIdJob.h"
#include "Workers.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include "utils/Variant.h"
#include "GlobalStorage.h"

View File

@ -12,8 +12,8 @@
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include <QDir>
#include <QFile>

View File

@ -12,9 +12,9 @@
#include "Workers.h"
#include "utils/System.h"
#include "utils/Entropy.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include <QFile>

View File

@ -241,6 +241,7 @@ void
PackageTreeItem::setChildrenSelected( Qt::CheckState isSelected )
{
if ( isSelected != Qt::PartiallyChecked )
{
// Children are never root; don't need to use setSelected on them.
for ( auto child : m_childItems )
{
@ -248,6 +249,7 @@ PackageTreeItem::setChildrenSelected( Qt::CheckState isSelected )
child->setChildrenSelected( isSelected );
}
}
}
void
PackageTreeItem::removeChild( int row )

View File

@ -11,8 +11,8 @@
#include "DllMacro.h"
#include "locale/TranslatableConfiguration.h"
#include "utils/System.h"
#include "utils/PluginFactory.h"
#include "utils/System.h"
#include "utils/Variant.h"
#include "viewpages/QmlViewStep.h"

View File

@ -77,10 +77,12 @@ IDJob::exec()
// Don't bother translating internal errors
if ( rootMount.isEmpty() && Calamares::Settings::instance()->doChroot() )
{
return Calamares::JobResult::internalError( "OEM Batch Identifier",
"No rootMountPoint is set, but a chroot is required. "
"Is there a module before oemid that sets up the partitions?",
Calamares::JobResult::InvalidConfiguration );
}
return writeId( Calamares::Settings::instance()->doChroot() ? rootMount + targetDir : targetDir,
targetFile,
m_batchIdentifier );

View File

@ -16,8 +16,8 @@
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "locale/TranslatableConfiguration.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include "utils/Variant.h"
#include <QDesktopServices>

View File

@ -13,8 +13,8 @@
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "locale/TranslatableConfiguration.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include "utils/Variant.h"
CALAMARES_PLUGIN_FACTORY_DEFINITION( PackageChooserQmlViewStepFactory, registerPlugin< PackageChooserQmlViewStep >(); )

View File

@ -156,9 +156,11 @@ colorForPartition( Partition* partition )
}
}
else
{
s_partitionColorsCache.insert( partition->fileSystem().uuid(),
PARTITION_COLORS[ colorIdx % NUM_PARTITION_COLORS ] );
}
}
return PARTITION_COLORS[ colorIdx % NUM_PARTITION_COLORS ];
}

View File

@ -11,8 +11,8 @@
#include "DeviceList.h"
#include "partition/PartitionIterator.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include <kpmcore/backend/corebackend.h>
#include <kpmcore/backend/corebackendmanager.h>
@ -34,10 +34,12 @@ static bool
hasRootPartition( Device* device )
{
for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it )
{
if ( ( *it )->mountPoint() == "/" )
{
return true;
}
}
return false;
}

View File

@ -128,8 +128,7 @@ int cryptVersion( Partition* partition );
*
* @return The LUKS FS type (default @c luks )
*/
FileSystem::Type
luksGenerationToFSName( Config::LuksGeneration luksGeneration );
FileSystem::Type luksGenerationToFSName( Config::LuksGeneration luksGeneration );
/** @brief Return a result for an @p operation

View File

@ -20,9 +20,9 @@
#include "partition/Mount.h"
#include "partition/PartitionIterator.h"
#include "partition/PartitionQuery.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/RAII.h"
#include "utils/System.h"
#include <kpmcore/backend/corebackend.h>
#include <kpmcore/backend/corebackendmanager.h>
@ -595,11 +595,15 @@ 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.

View File

@ -18,9 +18,9 @@
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/NamedEnum.h"
#include "utils/System.h"
#include "utils/Units.h"
#include <kpmcore/core/device.h>

View File

@ -315,6 +315,7 @@ PartitionCoreModule::doInit()
DeviceList bootLoaderDevices;
for ( DeviceList::Iterator it = devices.begin(); it != devices.end(); ++it )
{
if ( ( *it )->type() != Device::Type::Disk_Device )
{
cDebug() << "Ignoring device that is not Disk_Device to bootLoaderDevices list.";
@ -324,6 +325,7 @@ PartitionCoreModule::doInit()
{
bootLoaderDevices.append( *it );
}
}
m_bootLoaderModel->init( bootLoaderDevices );
@ -482,10 +484,12 @@ PartitionCoreModule::deletePartition( Device* device, Partition* partition )
// deleting them, so let's play it safe and keep our own list.
QList< Partition* > lst;
for ( auto childPartition : partition->children() )
{
if ( !isPartitionFreeSpace( childPartition ) )
{
lst << childPartition;
}
}
for ( auto childPartition : lst )
{
@ -781,11 +785,13 @@ PartitionCoreModule::updateIsDirty()
bool oldValue = m_isDirty;
m_isDirty = false;
for ( auto info : m_deviceInfos )
{
if ( info->isDirty() )
{
m_isDirty = true;
break;
}
}
if ( oldValue != m_isDirty )
{
isDirtyChanged( m_isDirty );
@ -806,8 +812,7 @@ PartitionCoreModule::scanForEfiSystemPartitions()
devices.append( device );
}
QList< Partition* > efiSystemPartitions
= Calamares::Partition::findPartitions( devices, PartUtils::isEfiBootable );
QList< Partition* > efiSystemPartitions = Calamares::Partition::findPartitions( devices, PartUtils::isEfiBootable );
if ( efiSystemPartitions.isEmpty() )
{
@ -853,6 +858,7 @@ PartitionCoreModule::scanForLVMPVs()
m_lvmPVs << p.partition().data();
for ( LvmDevice* device : vgDevices )
{
if ( p.vgName() == device->name() )
{
// Adding scanned VG to PV list
@ -860,6 +866,7 @@ PartitionCoreModule::scanForLVMPVs()
break;
}
}
}
for ( DeviceInfo* d : m_deviceInfos )
{
@ -924,11 +931,13 @@ PartitionCoreModule::findPartitionByMountPoint( const QString& mountPoint ) cons
{
Device* device = deviceInfo->device.data();
for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it )
{
if ( PartitionInfo::mountPoint( *it ) == mountPoint )
{
return *it;
}
}
}
return nullptr;
}
@ -1144,10 +1153,12 @@ bool
PartitionCoreModule::isVGdeactivated( LvmDevice* device )
{
for ( DeviceInfo* deviceInfo : m_deviceInfos )
{
if ( device == deviceInfo->device.data() && !deviceInfo->isAvailable )
{
return true;
}
}
return false;
}

View File

@ -205,8 +205,7 @@ PartitionModel::data( const QModelIndex& index, int role ) const
name = isPartitionNew( partition ) ? tr( "New partition" ) : partition->partitionPath();
}
}
QString prettyFileSystem
= Calamares::Partition::prettyNameForFileSystemType( partition->fileSystem().type() );
QString prettyFileSystem = Calamares::Partition::prettyNameForFileSystemType( partition->fileSystem().type() );
qint64 size = ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSize();
QString prettySize = formatByteSize( size );
return QVariant( name + " " + prettyFileSystem + " " + prettySize );
@ -239,43 +238,53 @@ PartitionModel::data( const QModelIndex& index, int role ) const
// Osprober roles:
case OsproberNameRole:
foreach ( const OsproberEntry& osproberEntry, m_osproberEntries )
{
if ( partition->fileSystem().supportGetUUID() != FileSystem::cmdSupportNone
&& !partition->fileSystem().uuid().isEmpty() && osproberEntry.uuid == partition->fileSystem().uuid() )
{
return osproberEntry.prettyName;
}
}
return QVariant();
case OsproberPathRole:
foreach ( const OsproberEntry& osproberEntry, m_osproberEntries )
{
if ( partition->fileSystem().supportGetUUID() != FileSystem::cmdSupportNone
&& !partition->fileSystem().uuid().isEmpty() && osproberEntry.uuid == partition->fileSystem().uuid() )
{
return osproberEntry.path;
}
}
return QVariant();
case OsproberCanBeResizedRole:
foreach ( const OsproberEntry& osproberEntry, m_osproberEntries )
{
if ( partition->fileSystem().supportGetUUID() != FileSystem::cmdSupportNone
&& !partition->fileSystem().uuid().isEmpty() && osproberEntry.uuid == partition->fileSystem().uuid() )
{
return osproberEntry.canBeResized;
}
}
return QVariant();
case OsproberRawLineRole:
foreach ( const OsproberEntry& osproberEntry, m_osproberEntries )
{
if ( partition->fileSystem().supportGetUUID() != FileSystem::cmdSupportNone
&& !partition->fileSystem().uuid().isEmpty() && osproberEntry.uuid == partition->fileSystem().uuid() )
{
return osproberEntry.line;
}
}
return QVariant();
case OsproberHomePartitionPathRole:
foreach ( const OsproberEntry& osproberEntry, m_osproberEntries )
{
if ( partition->fileSystem().supportGetUUID() != FileSystem::cmdSupportNone
&& !partition->fileSystem().uuid().isEmpty() && osproberEntry.uuid == partition->fileSystem().uuid() )
{
return osproberEntry.homePath;
}
}
return QVariant();
// end Osprober roles.

View File

@ -206,10 +206,12 @@ createCombo( const QSet< SwapChoice >& s, SwapChoice dflt )
SwapChoice::FullSwap,
SwapChoice::ReuseSwap,
SwapChoice::SwapFile } )
{
if ( s.contains( c ) )
{
box->addItem( QString(), c );
}
}
int dfltIndex = box->findData( dflt );
if ( dfltIndex >= 0 )
@ -851,10 +853,12 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current )
// m_reuseHomeCheckBox visible and set its text to something meaningful.
homePartitionPath->clear();
for ( const OsproberEntry& osproberEntry : m_core->osproberEntries() )
{
if ( osproberEntry.path == partPath )
{
*homePartitionPath = osproberEntry.homePath;
}
}
if ( homePartitionPath->isEmpty() )
{
doReuseHomePartition = false;
@ -888,17 +892,23 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current )
{
m_reuseHomeCheckBox->setVisible( !homePartitionPath->isEmpty() );
if ( !homePartitionPath->isEmpty() )
{
m_reuseHomeCheckBox->setText( tr( "Reuse %1 as home partition for %2." )
.arg( *homePartitionPath )
.arg( Calamares::Branding::instance()->shortProductName() ) );
}
delete homePartitionPath;
if ( m_isEfi )
{
setupEfiSystemPartitionSelector();
}
updateNextEnabled();
if ( !m_bootloaderComboBox.isNull() && m_bootloaderComboBox->currentIndex() < 0 )
{
m_bootloaderComboBox->setCurrentIndex( m_lastSelectedDeviceIndex );
}
},
this );
}

View File

@ -250,7 +250,8 @@ CreatePartitionDialog::getNewlyCreatedPartition()
if ( m_ui->encryptWidget->state() == EncryptWidget::Encryption::Confirmed && !luksPassphrase.isEmpty()
&& fsType != FileSystem::Zfs )
{
partition = KPMHelpers::createNewEncryptedPartition( m_parent,
partition = KPMHelpers::createNewEncryptedPartition(
m_parent,
*m_device,
m_role,
fsType,

View File

@ -223,10 +223,12 @@ PartitionLabelsView::buildTexts( const QModelIndex& index ) const
secondLine = index.sibling( index.row(), PartitionModel::SizeColumn ).data().toString();
}
else
{
//: size[number] filesystem[name]
secondLine = tr( "%1 %2" )
.arg( index.sibling( index.row(), PartitionModel::SizeColumn ).data().toString() )
.arg( index.sibling( index.row(), PartitionModel::FileSystemColumn ).data().toString() );
}
return { firstLine, secondLine };
}

View File

@ -284,10 +284,12 @@ PartitionPage::onNewVolumeGroupClicked()
QVector< const Partition* > availablePVs;
for ( const Partition* p : m_core->lvmPVs() )
{
if ( !m_core->isInVG( p ) )
{
availablePVs << p;
}
}
QPointer< CreateVolumeGroupDialog > dlg
= new CreateVolumeGroupDialog( vgName, selectedPVs, availablePVs, peSize, this );
@ -342,10 +344,12 @@ PartitionPage::onResizeVolumeGroupClicked()
QVector< const Partition* > selectedPVs;
for ( const Partition* p : m_core->lvmPVs() )
{
if ( !m_core->isInVG( p ) )
{
availablePVs << p;
}
}
QPointer< ResizeVolumeGroupDialog > dlg = new ResizeVolumeGroupDialog( device, availablePVs, selectedPVs, this );

View File

@ -16,8 +16,8 @@
#include "partition/FileSystem.h"
#include "partition/PartitionQuery.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include "utils/Units.h"
#include <kpmcore/core/device.h>

View File

@ -12,8 +12,8 @@
#include "CreatePartitionTableJob.h"
#include "partition/PartitionIterator.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include "core/KPMHelpers.h"

View File

@ -11,9 +11,9 @@
#include "FillGlobalStorageJob.h"
#include "compat/Variant.h"
#include "core/KPMHelpers.h"
#include "core/PartitionInfo.h"
#include "compat/Variant.h"
#include "Branding.h"
#include "GlobalStorage.h"

View File

@ -14,8 +14,8 @@
#include "core/KPMHelpers.h"
#include "partition/FileSystem.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include <kpmcore/core/device.h>
#include <kpmcore/core/partition.h>

View File

@ -104,10 +104,12 @@ static ::Partition*
firstFreePartition( PartitionNode* parent )
{
for ( auto child : parent->children() )
{
if ( Calamares::Partition::isPartitionFreeSpace( child ) )
{
return child;
}
}
return nullptr;
}

View File

@ -12,8 +12,8 @@
#include "PlasmaLnfJob.h"
#include "ThemeInfo.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include "utils/Variant.h"
#ifdef WITH_KCONFIG
@ -76,6 +76,7 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
// about the themes from Plasma (e.g. human-readable name and description)
// are filled in by update_names() in PlasmaLnfPage.
for ( const auto& i : themeList )
{
if ( i.type() == QVariant::Map )
{
auto iv = i.toMap();
@ -85,6 +86,7 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
{
listedThemes.insert( i.toString(), QString() );
}
}
if ( listedThemes.count() == 1 )
{

View File

@ -11,8 +11,8 @@
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#ifdef WITH_KCONFIG
#include <KConfigGroup>

View File

@ -76,15 +76,19 @@ PlasmaLnfPage::PlasmaLnfPage( Config* config, QWidget* parent )
CALAMARES_RETRANSLATE( {
ui->retranslateUi( this );
if ( Calamares::Settings::instance()->isSetupMode() )
{
ui->generalExplanation->setText( tr( "Please choose a look-and-feel for the KDE Plasma Desktop. "
"You can also skip this step and configure the look-and-feel "
"once the system is set up. Clicking on a look-and-feel "
"selection will give you a live preview of that look-and-feel." ) );
}
else
{
ui->generalExplanation->setText( tr( "Please choose a look-and-feel for the KDE Plasma Desktop. "
"You can also skip this step and configure the look-and-feel "
"once the system is installed. Clicking on a look-and-feel "
"selection will give you a live preview of that look-and-feel." ) );
}
} );
auto* view = new QListView( this );

View File

@ -10,8 +10,8 @@
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "compat/Variant.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include "utils/Units.h"
#include "utils/Variant.h"

View File

@ -13,10 +13,10 @@
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "compat/Variant.h"
#include "utils/System.h"
#include "utils/CommandList.h"
#include "utils/Logger.h"
#include "utils/StringExpander.h"
#include "utils/System.h"
#include "utils/Units.h"
#include <QFile>

View File

@ -10,9 +10,9 @@
#include "Item.h"
#include "Settings.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/NamedEnum.h"
#include "utils/System.h"
#include "utils/Yaml.h"
#include <QtTest/QtTest>

View File

@ -13,8 +13,8 @@
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include "utils/Variant.h"
#include <QFile>

View File

@ -14,8 +14,8 @@
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "network/Manager.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include <KMacroExpander>

View File

@ -16,8 +16,8 @@
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include "utils/Variant.h"
#include <QDesktopServices>

View File

@ -11,8 +11,8 @@
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include <QDir>
#include <QFile>

View File

@ -15,8 +15,8 @@
#include "UmountJob.h"
#include "partition/Mount.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include "utils/Variant.h"
#include "GlobalStorage.h"

View File

@ -11,9 +11,9 @@
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/Permissions.h"
#include "utils/System.h"
#include <QDateTime>
#include <QDir>

View File

@ -14,9 +14,9 @@
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/Permissions.h"
#include "utils/System.h"
#include <QDir>
#include <QFile>

View File

@ -13,8 +13,8 @@
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include <QDBusConnection>
#include <QDBusInterface>

View File

@ -12,9 +12,9 @@
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "utils/System.h"
#include "utils/Entropy.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include <QDir>
@ -74,15 +74,19 @@ SetPasswordJob::exec()
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
QDir destDir( gs->value( "rootMountPoint" ).toString() );
if ( !destDir.exists() )
{
return Calamares::JobResult::error( tr( "Bad destination system path." ),
tr( "rootMountPoint is %1" ).arg( destDir.absolutePath() ) );
}
if ( m_userName == "root" && m_newPassword.isEmpty() ) //special case for disabling root account
{
int ec = Calamares::System::instance()->targetEnvCall( { "usermod", "-p", "!", m_userName } );
if ( ec )
{
return Calamares::JobResult::error( tr( "Cannot disable root account." ),
tr( "usermod terminated with error code %1." ).arg( ec ) );
}
return Calamares::JobResult::ok();
}
@ -90,8 +94,10 @@ SetPasswordJob::exec()
int ec = Calamares::System::instance()->targetEnvCall( { "usermod", "-p", encrypted, m_userName } );
if ( ec )
{
return Calamares::JobResult::error( tr( "Cannot set password for user %1." ).arg( m_userName ),
tr( "usermod terminated with error code %1." ).arg( ec ) );
}
return Calamares::JobResult::ok();
}

View File

@ -16,8 +16,8 @@ extern bool setSystemdHostname( const QString& );
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include "utils/Yaml.h"
#include <QTemporaryDir>

View File

@ -12,8 +12,8 @@
#include "Branding.h"
#include "Settings.h"
#include "network/Manager.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include "utils/Yaml.h"
#include <QtTest/QtTest>

View File

@ -29,7 +29,7 @@ namespace GeoIP
{
class Handler;
} // namespace GeoIP
} // namespace CalamaresUtils
} // namespace Calamares
class PLUGINDLLEXPORT WelcomeViewStep : public Calamares::ViewStep
{

View File

@ -23,9 +23,9 @@
#include "modulesystem/Requirement.h"
#include "network/Manager.h"
#include "utils/Gui.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/Retranslator.h"
#include "utils/System.h"
#include "utils/Units.h"
#include "utils/Variant.h"
#include "widgets/WaitingWidget.h"
@ -367,10 +367,12 @@ GeneralRequirements::setConfigurationMap( const QVariantMap& configurationMap )
// Help out with consistency, but don't fix
for ( const auto& r : m_entriesToRequire )
{
if ( !m_entriesToCheck.contains( r ) )
{
cWarning() << "GeneralRequirements requires" << r << "but does not check it.";
}
}
if ( configurationMap.contains( "requiredStorage" )
&& ( Calamares::typeOf( configurationMap.value( "requiredStorage" ) ) == Calamares::DoubleVariantType

View File

@ -27,7 +27,7 @@ namespace GeoIP
{
class Handler;
} // namespace GeoIP
} // namespace CalamaresUtils
} // namespace Calamares
// TODO: refactor and move what makes sense to base class

View File

@ -9,8 +9,8 @@
#include "ZfsJob.h"
#include "utils/System.h"
#include "utils/Logger.h"
#include "utils/System.h"
#include "utils/Variant.h"
#include "GlobalStorage.h"