[partition] Update copyright, coding style

This commit is contained in:
Adriaan de Groot 2020-02-13 11:12:22 +01:00
parent a0449abab9
commit dac5516b2c

View File

@ -2,7 +2,7 @@
* *
* Copyright 2014, Aurélien Gâteau <agateau@kde.org> * Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2015-2016, Teo Mrnjavac <teo@kde.org> * Copyright 2015-2016, Teo Mrnjavac <teo@kde.org>
* Copyright 2017, 2019, Adriaan de Groot <groot@kde.org> * Copyright 2017, 2019-2020, Adriaan de Groot <groot@kde.org>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -20,13 +20,13 @@
#include "jobs/FillGlobalStorageJob.h" #include "jobs/FillGlobalStorageJob.h"
#include "core/KPMHelpers.h"
#include "core/PartitionInfo.h" #include "core/PartitionInfo.h"
#include "core/PartitionIterator.h" #include "core/PartitionIterator.h"
#include "core/KPMHelpers.h"
#include "Branding.h"
#include "GlobalStorage.h" #include "GlobalStorage.h"
#include "JobQueue.h" #include "JobQueue.h"
#include "Branding.h"
#include "utils/Logger.h" #include "utils/Logger.h"
// KPMcore // KPMcore
@ -43,16 +43,15 @@
using KPMHelpers::untranslatedFS; using KPMHelpers::untranslatedFS;
typedef QHash<QString, QString> UuidForPartitionHash; typedef QHash< QString, QString > UuidForPartitionHash;
static UuidForPartitionHash static UuidForPartitionHash
findPartitionUuids( QList < Device* > devices ) findPartitionUuids( QList< Device* > devices )
{ {
UuidForPartitionHash hash; UuidForPartitionHash hash;
foreach ( Device* device, devices ) foreach ( Device* device, devices )
{ {
for ( auto it = PartitionIterator::begin( device ); for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it )
it != PartitionIterator::end( device ); ++it )
{ {
Partition* p = *it; Partition* p = *it;
QString path = p->partitionPath(); QString path = p->partitionPath();
@ -62,7 +61,9 @@ findPartitionUuids( QList < Device* > devices )
} }
if ( hash.isEmpty() ) if ( hash.isEmpty() )
{
cDebug() << "No UUIDs found for existing partitions."; cDebug() << "No UUIDs found for existing partitions.";
}
return hash; return hash;
} }
@ -76,7 +77,9 @@ getLuksUuid( const QString& path )
process.start(); process.start();
process.waitForFinished(); process.waitForFinished();
if ( process.exitStatus() != QProcess::NormalExit || process.exitCode() ) if ( process.exitStatus() != QProcess::NormalExit || process.exitCode() )
{
return QString(); return QString();
}
QString uuid = QString::fromLocal8Bit( process.readAllStandardOutput() ).trimmed(); QString uuid = QString::fromLocal8Bit( process.readAllStandardOutput() ).trimmed();
return uuid; return uuid;
} }
@ -90,20 +93,20 @@ mapForPartition( Partition* partition, const QString& uuid )
map[ "mountPoint" ] = PartitionInfo::mountPoint( partition ); map[ "mountPoint" ] = PartitionInfo::mountPoint( partition );
map[ "fsName" ] = partition->fileSystem().name(); // User-visible map[ "fsName" ] = partition->fileSystem().name(); // User-visible
map[ "fs" ] = untranslatedFS( partition->fileSystem() ); map[ "fs" ] = untranslatedFS( partition->fileSystem() );
if ( partition->fileSystem().type() == FileSystem::Luks && if ( partition->fileSystem().type() == FileSystem::Luks
dynamic_cast< FS::luks& >( partition->fileSystem() ).innerFS() ) && dynamic_cast< FS::luks& >( partition->fileSystem() ).innerFS() )
{
map[ "fs" ] = untranslatedFS( dynamic_cast< FS::luks& >( partition->fileSystem() ).innerFS() ); map[ "fs" ] = untranslatedFS( dynamic_cast< FS::luks& >( partition->fileSystem() ).innerFS() );
}
map[ "uuid" ] = uuid; map[ "uuid" ] = uuid;
// Debugging for inside the loop in createPartitionList(), // Debugging for inside the loop in createPartitionList(),
// so indent a bit // so indent a bit
Logger::CDebug deb; Logger::CDebug deb;
using TR = Logger::DebugRow<const char *const, const QString&>; using TR = Logger::DebugRow< const char* const, const QString& >;
deb << Logger::SubEntry << "mapping for" << partition->partitionPath() << partition->deviceNode() deb << Logger::SubEntry << "mapping for" << partition->partitionPath() << partition->deviceNode()
<< TR( "mtpoint:", PartitionInfo::mountPoint( partition ) ) << TR( "mtpoint:", PartitionInfo::mountPoint( partition ) ) << TR( "fs:", map[ "fs" ].toString() )
<< TR( "fs:", map[ "fs" ].toString() ) << TR( "fsname", map[ "fsName" ].toString() ) << TR( "uuid", uuid );
<< TR( "fsname", map[ "fsName" ].toString() )
<< TR( "uuid", uuid );
if ( partition->roles().has( PartitionRole::Luks ) ) if ( partition->roles().has( PartitionRole::Luks ) )
{ {
@ -140,7 +143,7 @@ FillGlobalStorageJob::prettyDescription() const
QStringList lines; QStringList lines;
const auto partitionList = createPartitionList().toList(); const auto partitionList = createPartitionList().toList();
for ( const QVariant &partitionItem : partitionList ) for ( const QVariant& partitionItem : partitionList )
{ {
if ( partitionItem.type() == QVariant::Map ) if ( partitionItem.type() == QVariant::Map )
{ {
@ -149,32 +152,42 @@ FillGlobalStorageJob::prettyDescription() const
QString mountPoint = partitionMap.value( "mountPoint" ).toString(); QString mountPoint = partitionMap.value( "mountPoint" ).toString();
QString fsType = partitionMap.value( "fs" ).toString(); QString fsType = partitionMap.value( "fs" ).toString();
if ( mountPoint.isEmpty() || fsType.isEmpty() ) if ( mountPoint.isEmpty() || fsType.isEmpty() )
{
continue; continue;
}
if ( path.isEmpty() ) if ( path.isEmpty() )
{ {
if ( mountPoint == "/" ) if ( mountPoint == "/" )
{
lines.append( tr( "Install %1 on <strong>new</strong> %2 system partition." ) lines.append( tr( "Install %1 on <strong>new</strong> %2 system partition." )
.arg( *Calamares::Branding::ShortProductName ) .arg( *Calamares::Branding::ShortProductName )
.arg( fsType ) ); .arg( fsType ) );
}
else else
{
lines.append( tr( "Set up <strong>new</strong> %2 partition with mount point " lines.append( tr( "Set up <strong>new</strong> %2 partition with mount point "
"<strong>%1</strong>." ) "<strong>%1</strong>." )
.arg( mountPoint ) .arg( mountPoint )
.arg( fsType ) ); .arg( fsType ) );
}
} }
else else
{ {
if ( mountPoint == "/" ) if ( mountPoint == "/" )
{
lines.append( tr( "Install %2 on %3 system partition <strong>%1</strong>." ) lines.append( tr( "Install %2 on %3 system partition <strong>%1</strong>." )
.arg( path ) .arg( path )
.arg( *Calamares::Branding::ShortProductName ) .arg( *Calamares::Branding::ShortProductName )
.arg( fsType ) ); .arg( fsType ) );
}
else else
{
lines.append( tr( "Set up %3 partition <strong>%1</strong> with mount point " lines.append( tr( "Set up %3 partition <strong>%1</strong> with mount point "
"<strong>%2</strong>." ) "<strong>%2</strong>." )
.arg( path ) .arg( path )
.arg( mountPoint ) .arg( mountPoint )
.arg( fsType ) ); .arg( fsType ) );
}
} }
} }
} }
@ -182,8 +195,7 @@ FillGlobalStorageJob::prettyDescription() const
QVariant bootloaderMap = createBootLoaderMap(); QVariant bootloaderMap = createBootLoaderMap();
if ( !m_bootLoaderPath.isEmpty() ) if ( !m_bootLoaderPath.isEmpty() )
{ {
lines.append( tr( "Install boot loader on <strong>%1</strong>." ) lines.append( tr( "Install boot loader on <strong>%1</strong>." ).arg( m_bootLoaderPath ) );
.arg( m_bootLoaderPath ) );
} }
return lines.join( "<br/>" ); return lines.join( "<br/>" );
} }
@ -204,7 +216,9 @@ FillGlobalStorageJob::exec()
{ {
QVariant var = createBootLoaderMap(); QVariant var = createBootLoaderMap();
if ( !var.isValid() ) if ( !var.isValid() )
{
cDebug() << "Failed to find path for boot loader"; cDebug() << "Failed to find path for boot loader";
}
cDebug() << "FillGlobalStorageJob writing bootLoader path:" << var; cDebug() << "FillGlobalStorageJob writing bootLoader path:" << var;
storage->insert( "bootLoader", var ); storage->insert( "bootLoader", var );
} }
@ -225,8 +239,7 @@ FillGlobalStorageJob::createPartitionList() const
for ( auto device : m_devices ) for ( auto device : m_devices )
{ {
cDebug() << Logger::SubEntry << "partitions on" << device->deviceNode(); cDebug() << Logger::SubEntry << "partitions on" << device->deviceNode();
for ( auto it = PartitionIterator::begin( device ); for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it )
it != PartitionIterator::end( device ); ++it )
{ {
// Debug-logging is done when creating the map // Debug-logging is done when creating the map
lst << mapForPartition( *it, hash.value( ( *it )->partitionPath() ) ); lst << mapForPartition( *it, hash.value( ( *it )->partitionPath() ) );
@ -244,7 +257,9 @@ FillGlobalStorageJob::createBootLoaderMap() const
{ {
Partition* partition = KPMHelpers::findPartitionByMountPoint( m_devices, path ); Partition* partition = KPMHelpers::findPartitionByMountPoint( m_devices, path );
if ( !partition ) if ( !partition )
{
return QVariant(); return QVariant();
}
path = partition->partitionPath(); path = partition->partitionPath();
} }
map[ "installPath" ] = path; map[ "installPath" ] = path;