Merge branch 'master' of https://github.com/calamares/calamares into development

This commit is contained in:
Philip 2017-09-06 18:13:08 +01:00
commit c61f662c86
11 changed files with 131 additions and 34 deletions

View File

@ -179,7 +179,7 @@ Branding::Branding( const QString& brandingFilePath,
}
catch ( YAML::Exception& e )
{
cDebug() << "WARNING: YAML parser error " << e.what();
cDebug() << "WARNING: YAML parser error " << e.what() << "in" << file.fileName();
}
QDir translationsDir( componentDir.filePath( "lang" ) );

View File

@ -156,7 +156,7 @@ Settings::Settings( const QString& settingsFilePath,
}
catch ( YAML::Exception& e )
{
cDebug() << "WARNING: YAML parser error " << e.what();
cDebug() << "WARNING: YAML parser error " << e.what() << "in" << file.fileName();
}
}
else

View File

@ -18,8 +18,11 @@
*/
#include "YamlUtils.h"
#include "utils/Logger.h"
#include <yaml-cpp/yaml.h>
#include <QByteArray>
#include <QRegExp>
void
@ -105,4 +108,42 @@ yamlMapToVariant( const YAML::Node& mapNode )
}
void
explainYamlException( const YAML::Exception& e, const QByteArray& yamlData, const char *label )
{
cDebug() << "WARNING: YAML error " << e.what() << "in" << label << '.';
if ( ( e.mark.line >= 0 ) && ( e.mark.column >= 0 ) )
{
// Try to show the line where it happened.
int linestart = 0;
for ( int linecount = 0; linecount < e.mark.line; ++linecount )
{
linestart = yamlData.indexOf( '\n', linestart );
// No more \ns found, weird
if ( linestart < 0 )
break;
linestart += 1; // Skip that \n
}
int lineend = linestart;
if ( linestart >= 0 )
{
lineend = yamlData.indexOf( '\n', linestart );
if ( lineend < 0 )
lineend = yamlData.length();
}
int rangestart = linestart;
int rangeend = lineend;
// Adjust range (linestart..lineend) so it's not too long
if ( ( linestart >= 0 ) && ( e.mark.column > 30 ) )
rangestart += ( e.mark.column - 30 );
if ( ( linestart >= 0 ) && ( rangeend - rangestart > 40 ) )
rangeend = rangestart + 40;
if ( linestart >= 0 )
cDebug() << "WARNING: offending YAML data:" << yamlData.mid( rangestart, rangeend-rangestart ).constData();
}
}
} // namespace

View File

@ -1,6 +1,7 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
* Copyright 2017, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -22,9 +23,12 @@
#include <QStringList>
#include <QVariant>
class QByteArray;
namespace YAML
{
class Node;
class Exception;
}
void operator>>( const YAML::Node& node, QStringList& v );
@ -37,6 +41,13 @@ QVariant yamlScalarToVariant( const YAML::Node& scalarNode );
QVariant yamlSequenceToVariant( const YAML::Node& sequenceNode );
QVariant yamlMapToVariant( const YAML::Node& mapNode );
/**
* Given an exception from the YAML parser library, explain
* what is going on in terms of the data passed to the parser.
* Uses @p label when labeling the data source (e.g. "netinstall data")
*/
void explainYamlException( const YAML::Exception& e, const QByteArray& data, const char *label );
} //ns
#endif // YAMLUTILS_H

View File

@ -35,8 +35,6 @@ FinishedViewStep::FinishedViewStep( QObject* parent )
, m_widget( new FinishedPage() )
, installFailed( false )
{
cDebug() << "FinishedViewStep()";
auto jq = Calamares::JobQueue::instance();
connect( jq, &Calamares::JobQueue::failed,
m_widget, &FinishedPage::onInstallationFailed );
@ -64,7 +62,6 @@ FinishedViewStep::prettyName() const
QWidget*
FinishedViewStep::widget()
{
cDebug() << "FinishedViewStep::widget()";
return m_widget;
}
@ -140,7 +137,6 @@ FinishedViewStep::sendNotification()
void
FinishedViewStep::onActivate()
{
cDebug() << "FinishedViewStep::onActivate()";
m_widget->setUpRestart();
sendNotification();
@ -150,7 +146,6 @@ FinishedViewStep::onActivate()
QList< Calamares::job_ptr >
FinishedViewStep::jobs() const
{
cDebug() << "FinishedViewStep::jobs";
return QList< Calamares::job_ptr >();
}

View File

@ -115,6 +115,10 @@ LocaleViewStep::fetchGeoIpTimezone()
[=]( QNetworkReply* reply )
{
if ( reply->error() == QNetworkReply::NoError )
{
QByteArray data = reply->readAll();
try
{
YAML::Node doc = YAML::Load( reply->readAll() );
@ -139,6 +143,11 @@ LocaleViewStep::fetchGeoIpTimezone()
}
}
}
catch ( YAML::Exception& e )
{
CalamaresUtils::explainYamlException( e, data, "GeoIP data");
}
}
reply->deleteLater();
manager->deleteLater();

View File

@ -64,14 +64,28 @@ NetInstallPage::isReady()
return true;
}
void NetInstallPage::readGroups( const QByteArray& yamlData )
bool
NetInstallPage::readGroups( const QByteArray& yamlData )
{
try
{
YAML::Node groups = YAML::Load( yamlData.constData() );
if ( !groups.IsSequence() )
cDebug() << "WARNING: netinstall groups data does not form a sequence.";
Q_ASSERT( groups.IsSequence() );
m_groups = new PackageModel( groups );
CALAMARES_RETRANSLATE(
m_groups->setHeaderData( 0, Qt::Horizontal, tr( "Name" ) );
m_groups->setHeaderData( 0, Qt::Horizontal, tr( "Description" ) ); )
return true;
}
catch ( YAML::Exception& e )
{
CalamaresUtils::explainYamlException( e, yamlData, "netinstall groups data" );
return false;
}
}
void
@ -84,7 +98,13 @@ NetInstallPage::dataIsHere( QNetworkReply* reply )
return;
}
readGroups( reply->readAll() );
if ( !readGroups( reply->readAll() ) )
{
cDebug() << "Netinstall groups data was received, but invalid.";
ui->netinst_status->setText( tr( "Network Installation. (Disabled: Unable to fetch package lists, check your network connection)" ) );
reply->deleteLater();
return;
}
ui->groupswidget->setModel( m_groups );
ui->groupswidget->header()->setSectionResizeMode( 0, QHeaderView::ResizeToContents );

View File

@ -2,6 +2,7 @@
* Copyright 2016, Luca Giambonini <almack@chakraos.org>
* Copyright 2016, Lisa Vitolo <shainer@chakraos.org>
* Copyright 2017, Kyle Robbertze <krobbertze@gmail.com>
* Copyright 2017, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -67,7 +68,7 @@ private:
// Takes the YAML data representing the groups and reads them into the
// m_groups and m_groupOrder internal structures. See the README.md
// of this module to know the format expected of the YAML files.
void readGroups( const QByteArray& yamlData );
bool readGroups( const QByteArray& yamlData );
Ui::Page_NetInst* ui;

View File

@ -8,6 +8,10 @@ find_package( KF5 REQUIRED CoreAddons )
# These are needed because KPMcore links publicly against ConfigCore, I18n, IconThemes, KIOCore and Service
find_package( KF5 REQUIRED Config I18n IconThemes KIO Service )
find_package( KPMcore 3.1.50 )
if ( ${KPMcore_FOUND} )
add_definitions(-DWITH_KPMCORE22)
endif()
find_package( KPMcore 3.0.3 REQUIRED )
find_library( atasmart_LIB atasmart )
find_library( blkid_LIB blkid )

View File

@ -23,6 +23,7 @@
#include "core/PartitionIterator.h"
// KPMcore
#include <kpmcore/core/device.h>
#include <kpmcore/core/partition.h>
#include <kpmcore/fs/filesystemfactory.h>
#include <kpmcore/backend/corebackendmanager.h>
@ -114,7 +115,11 @@ createNewPartition( PartitionNode* parent,
qint64 lastSector,
PartitionTable::Flags flags )
{
FileSystem* fs = FileSystemFactory::create( fsType, firstSector, lastSector );
FileSystem* fs = FileSystemFactory::create( fsType, firstSector, lastSector
#ifdef WITH_KPMCORE22
,device.logicalSize()
#endif
);
return new Partition(
parent,
device,
@ -147,7 +152,11 @@ createNewEncryptedPartition( PartitionNode* parent,
FS::luks* fs = dynamic_cast< FS::luks* >(
FileSystemFactory::create( FileSystem::Luks,
firstSector,
lastSector ) );
lastSector
#ifdef WITH_KPMCORE22
,device.logicalSize()
#endif
) );
if ( !fs )
{
qDebug() << "ERROR: cannot create LUKS filesystem. Giving up.";
@ -177,6 +186,9 @@ clonePartition( Device* device, Partition* partition )
partition->fileSystem().type(),
partition->firstSector(),
partition->lastSector()
#ifdef WITH_KPMCORE22
,device->logicalSize()
#endif
);
return new Partition( partition->parent(),
*device,

View File

@ -217,7 +217,11 @@ PartitionJobTests::newCreatePartitionJob( Partition* freeSpacePartition, Partiti
lastSector = firstSector + size / m_device->logicalSize();
else
lastSector = freeSpacePartition->lastSector();
FileSystem* fs = FileSystemFactory::create( type, firstSector, lastSector );
FileSystem* fs = FileSystemFactory::create( type, firstSector, lastSector
#ifdef WITH_KPMCORE22
,m_device->logicalSize()
#endif
);
Partition* partition = new Partition(
freeSpacePartition->parent(),