Merge branch 'master' into partition-type
This commit is contained in:
commit
1718f7a8a8
@ -89,7 +89,7 @@ yamlScalarToVariant( const YAML::Node& scalarNode )
|
||||
}
|
||||
|
||||
|
||||
QVariant
|
||||
QVariantList
|
||||
yamlSequenceToVariant( const YAML::Node& sequenceNode )
|
||||
{
|
||||
QVariantList vl;
|
||||
@ -101,7 +101,7 @@ yamlSequenceToVariant( const YAML::Node& sequenceNode )
|
||||
}
|
||||
|
||||
|
||||
QVariant
|
||||
QVariantMap
|
||||
yamlMapToVariant( const YAML::Node& mapNode )
|
||||
{
|
||||
QVariantMap vm;
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
#include <QStringList>
|
||||
#include <QVariant>
|
||||
#include <QVariantList>
|
||||
#include <QVariantMap>
|
||||
|
||||
class QByteArray;
|
||||
class QFileInfo;
|
||||
@ -60,8 +62,8 @@ QVariantMap loadYaml( const QFileInfo&, bool* ok = nullptr );
|
||||
|
||||
QVariant yamlToVariant( const YAML::Node& node );
|
||||
QVariant yamlScalarToVariant( const YAML::Node& scalarNode );
|
||||
QVariant yamlSequenceToVariant( const YAML::Node& sequenceNode );
|
||||
QVariant yamlMapToVariant( const YAML::Node& mapNode );
|
||||
QVariantList yamlSequenceToVariant( const YAML::Node& sequenceNode );
|
||||
QVariantMap yamlMapToVariant( const YAML::Node& mapNode );
|
||||
|
||||
/// @brief Returns all the elements of @p listNode in a StringList
|
||||
QStringList yamlToStringList( const YAML::Node& listNode );
|
||||
|
@ -123,7 +123,7 @@ loadStrings( QMap< QString, QString >& map,
|
||||
throw YAML::Exception( YAML::Mark(), std::string( "Branding configuration is not a map: " ) + key );
|
||||
}
|
||||
|
||||
const auto& config = CalamaresUtils::yamlMapToVariant( doc[ key ] ).toMap();
|
||||
const auto& config = CalamaresUtils::yamlMapToVariant( doc[ key ] );
|
||||
|
||||
map.clear();
|
||||
for ( auto it = config.constBegin(); it != config.constEnd(); ++it )
|
||||
|
@ -237,7 +237,7 @@ void Module::loadConfigurationFile( const QString& configFileName ) //throws YA
|
||||
}
|
||||
|
||||
cDebug() << "Loaded module configuration" << path;
|
||||
m_configurationMap = CalamaresUtils::yamlMapToVariant( doc ).toMap();
|
||||
m_configurationMap = CalamaresUtils::yamlMapToVariant( doc );
|
||||
m_emergency = m_maybe_emergency && m_configurationMap.contains( EMERGENCY )
|
||||
&& m_configurationMap[ EMERGENCY ].toBool();
|
||||
return;
|
||||
|
@ -79,14 +79,15 @@ ContextualProcessTests::testProcessListSampleConfig()
|
||||
}
|
||||
|
||||
ContextualProcessJob job;
|
||||
job.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc ).toMap() );
|
||||
job.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc ) );
|
||||
|
||||
QCOMPARE( job.count(), 2 ); // Only "firmwareType" and "branding.shortVersion"
|
||||
QCOMPARE( job.count( "firmwareType" ), 4 );
|
||||
QCOMPARE( job.count( "branding.shortVersion" ), 2 ); // in the example config
|
||||
}
|
||||
|
||||
void ContextualProcessTests::testFetch()
|
||||
void
|
||||
ContextualProcessTests::testFetch()
|
||||
{
|
||||
Logger::setupLogLevel( Logger::LOGVERBOSE );
|
||||
|
||||
@ -187,5 +188,4 @@ void ContextualProcessTests::testFetch()
|
||||
QCOMPARE( s, QString() );
|
||||
QVERIFY( s.isEmpty() );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ void FSResizerTests::testConfigurationRobust()
|
||||
size: 100%
|
||||
atleast: 600MiB
|
||||
)" );
|
||||
j.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc0 ).toMap() );
|
||||
j.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc0 ) );
|
||||
QVERIFY( j.name().isEmpty() );
|
||||
QCOMPARE( j.size().unit(), SizeUnit::None );
|
||||
QCOMPARE( j.minimumSize().unit(), SizeUnit::None );
|
||||
@ -82,7 +82,7 @@ fs: /
|
||||
size: 100%
|
||||
atleast: 600MiB
|
||||
)" );
|
||||
j.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc0 ).toMap() );
|
||||
j.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc0 ) );
|
||||
QVERIFY( !j.name().isEmpty() );
|
||||
QCOMPARE( j.name(), QString("/") );
|
||||
QCOMPARE( j.size().unit(), SizeUnit::Percent );
|
||||
@ -97,7 +97,7 @@ dev: /dev/m00
|
||||
size: 72 MiB
|
||||
atleast: 127 %
|
||||
)" );
|
||||
j.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc0 ).toMap() );
|
||||
j.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc0 ) );
|
||||
QVERIFY( !j.name().isEmpty() );
|
||||
QCOMPARE( j.name(), QString("/") );
|
||||
QCOMPARE( j.size().unit(), SizeUnit::MiB );
|
||||
@ -111,7 +111,7 @@ dev: /dev/m00
|
||||
size: 72 MiB
|
||||
atleast: 127 %
|
||||
)" );
|
||||
j.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc0 ).toMap() );
|
||||
j.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc0 ) );
|
||||
QVERIFY( !j.name().isEmpty() );
|
||||
QCOMPARE( j.name(), QString("/dev/m00") );
|
||||
QCOMPARE( j.size().unit(), SizeUnit::MiB );
|
||||
@ -126,7 +126,7 @@ fs: /
|
||||
size: 71MiB
|
||||
# atleast: 127%
|
||||
)" );
|
||||
j.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc0 ).toMap() );
|
||||
j.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc0 ) );
|
||||
QVERIFY( !j.name().isEmpty() );
|
||||
QCOMPARE( j.name(), QString("/") );
|
||||
QCOMPARE( j.size().unit(), SizeUnit::MiB );
|
||||
|
@ -834,6 +834,7 @@ PartitionCoreModule::initLayout()
|
||||
void
|
||||
PartitionCoreModule::initLayout( const QVariantList& config )
|
||||
{
|
||||
bool ok;
|
||||
QString sizeString;
|
||||
QString minSizeString;
|
||||
QString maxSizeString;
|
||||
@ -885,6 +886,7 @@ PartitionCoreModule::initLayout( const QVariantList& config )
|
||||
CalamaresUtils::getString( pentry, "type" ),
|
||||
CalamaresUtils::getString( pentry, "mountPoint" ),
|
||||
CalamaresUtils::getString( pentry, "filesystem" ),
|
||||
CalamaresUtils::getSubMap( pentry, "features", ok ),
|
||||
sizeString,
|
||||
minSizeString,
|
||||
maxSizeString ) )
|
||||
|
@ -121,6 +121,7 @@ PartitionLayout::addEntry( const QString& label,
|
||||
const QString& type,
|
||||
const QString& mountPoint,
|
||||
const QString& fs,
|
||||
const QVariantMap& features,
|
||||
const QString& size,
|
||||
const QString& min,
|
||||
const QString& max )
|
||||
@ -146,6 +147,7 @@ PartitionLayout::addEntry( const QString& label,
|
||||
{
|
||||
entry.partFileSystem = m_defaultFsType;
|
||||
}
|
||||
entry.partFeatures = features;
|
||||
|
||||
m_partLayout.append( entry );
|
||||
|
||||
@ -239,6 +241,7 @@ PartitionLayout::execute( Device* dev,
|
||||
PartitionInfo::setMountPoint( currentPartition, part.partMountPoint );
|
||||
if ( !part.partLabel.isEmpty() )
|
||||
{
|
||||
currentPartition->setLabel( part.partLabel );
|
||||
currentPartition->fileSystem().setLabel( part.partLabel );
|
||||
}
|
||||
if ( !part.partType.isEmpty() )
|
||||
@ -247,6 +250,17 @@ PartitionLayout::execute( Device* dev,
|
||||
currentPartition->setType( part.partType );
|
||||
#else
|
||||
cWarning() << "Ignoring type; requires KPMcore >= 4.2.0.";
|
||||
#endif
|
||||
}
|
||||
if ( !part.partFeatures.isEmpty() )
|
||||
{
|
||||
#if defined( WITH_KPMCORE42API )
|
||||
for ( const auto& k : part.partFeatures.keys() )
|
||||
{
|
||||
currentPartition->fileSystem().addFeature( k, part.partFeatures.value(k) );
|
||||
}
|
||||
#else
|
||||
cWarning() << "Ignoring features; requires KPMcore >= 4.2.0.";
|
||||
#endif
|
||||
}
|
||||
// Some buggy (legacy) BIOSes test if the bootflag of at least one partition is set.
|
||||
|
@ -31,6 +31,7 @@
|
||||
// Qt
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
#include <QVariantMap>
|
||||
|
||||
class Partition;
|
||||
|
||||
@ -43,6 +44,7 @@ public:
|
||||
QString partType;
|
||||
QString partMountPoint;
|
||||
FileSystem::Type partFileSystem = FileSystem::Unknown;
|
||||
QVariantMap partFeatures;
|
||||
CalamaresUtils::Partition::PartitionSize partSize;
|
||||
CalamaresUtils::Partition::PartitionSize partMinSize;
|
||||
CalamaresUtils::Partition::PartitionSize partMaxSize;
|
||||
@ -77,6 +79,7 @@ public:
|
||||
const QString& type,
|
||||
const QString& mountPoint,
|
||||
const QString& fs,
|
||||
const QVariantMap& features,
|
||||
const QString& size,
|
||||
const QString& min = QString(),
|
||||
const QString& max = QString() );
|
||||
|
@ -108,13 +108,21 @@ defaultFileSystemType: "ext4"
|
||||
# mountPoint: "/home"
|
||||
# size: 3G
|
||||
# minSize: 1.5G
|
||||
# features:
|
||||
# 64bit: false
|
||||
# casefold: true
|
||||
# - name: "data"
|
||||
# filesystem: "fat32"
|
||||
# mountPoint: "/data"
|
||||
# features:
|
||||
# sector-size: 4096
|
||||
# sectors-per-cluster: 128
|
||||
# size: 100%
|
||||
#
|
||||
# There can be any number of partitions, each entry having the following attributes:
|
||||
# - name: partition label
|
||||
# - name: filesystem label
|
||||
# and
|
||||
# partition name (gpt only; since KPMCore 4.2.0)
|
||||
# - type: partition type (optional parameter; gpt only; requires KPMCore >= 4.2.0)
|
||||
# - filesystem: filesystem type
|
||||
# - mountPoint: partition mount point
|
||||
@ -123,6 +131,8 @@ defaultFileSystemType: "ext4"
|
||||
# % of the available drive space if a '%' is appended to the value
|
||||
# - minSize: minimum partition size (optional parameter)
|
||||
# - maxSize: maximum partition size (optional parameter)
|
||||
# - features: filesystem features (optional parameter; requires KPMCore >= 4.2.0)
|
||||
# name: boolean or integer or string
|
||||
|
||||
# Checking for available storage
|
||||
#
|
||||
|
@ -62,7 +62,7 @@ ShellProcessTests::testProcessListSampleConfig()
|
||||
}
|
||||
}
|
||||
|
||||
CommandList cl( CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) );
|
||||
CommandList cl( CalamaresUtils::yamlMapToVariant( doc ).value( "script" ) );
|
||||
QVERIFY( !cl.isEmpty() );
|
||||
QCOMPARE( cl.count(), 3 );
|
||||
|
||||
@ -79,7 +79,7 @@ script:
|
||||
- "ls /nonexistent"
|
||||
- "/bin/false"
|
||||
)" );
|
||||
CommandList cl( CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) );
|
||||
CommandList cl( CalamaresUtils::yamlMapToVariant( doc ).value( "script" ) );
|
||||
QVERIFY( !cl.isEmpty() );
|
||||
QCOMPARE( cl.count(), 3 );
|
||||
|
||||
@ -90,7 +90,7 @@ script:
|
||||
- false
|
||||
- "ls /nonexistent"
|
||||
)" );
|
||||
CommandList cl1( CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) );
|
||||
CommandList cl1( CalamaresUtils::yamlMapToVariant( doc ).value( "script" ) );
|
||||
QVERIFY( !cl1.isEmpty() );
|
||||
QCOMPARE( cl1.count(), 2 ); // One element ignored
|
||||
}
|
||||
@ -101,7 +101,7 @@ ShellProcessTests::testProcessListFromString()
|
||||
YAML::Node doc = YAML::Load( R"(---
|
||||
script: "ls /tmp"
|
||||
)" );
|
||||
CommandList cl( CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) );
|
||||
CommandList cl( CalamaresUtils::yamlMapToVariant( doc ).value( "script" ) );
|
||||
|
||||
QVERIFY( !cl.isEmpty() );
|
||||
QCOMPARE( cl.count(), 1 );
|
||||
@ -112,7 +112,7 @@ script: "ls /tmp"
|
||||
doc = YAML::Load( R"(---
|
||||
script: false
|
||||
)" );
|
||||
CommandList cl1( CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) );
|
||||
CommandList cl1( CalamaresUtils::yamlMapToVariant( doc ).value( "script" ) );
|
||||
QVERIFY( cl1.isEmpty() );
|
||||
QCOMPARE( cl1.count(), 0 );
|
||||
}
|
||||
@ -125,7 +125,7 @@ script:
|
||||
command: "ls /tmp"
|
||||
timeout: 20
|
||||
)" );
|
||||
CommandList cl( CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) );
|
||||
CommandList cl( CalamaresUtils::yamlMapToVariant( doc ).value( "script" ) );
|
||||
|
||||
QVERIFY( !cl.isEmpty() );
|
||||
QCOMPARE( cl.count(), 1 );
|
||||
@ -142,7 +142,7 @@ script:
|
||||
timeout: 12
|
||||
- "-/bin/false"
|
||||
)" );
|
||||
CommandList cl( CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" ) );
|
||||
CommandList cl( CalamaresUtils::yamlMapToVariant( doc ).value( "script" ) );
|
||||
QVERIFY( !cl.isEmpty() );
|
||||
QCOMPARE( cl.count(), 2 );
|
||||
QCOMPARE( cl.at( 0 ).timeout(), 12s );
|
||||
@ -157,12 +157,11 @@ ShellProcessTests::testRootSubstitution()
|
||||
script:
|
||||
- "ls /tmp"
|
||||
)" );
|
||||
QVariant plainScript = CalamaresUtils::yamlMapToVariant( doc ).toMap().value( "script" );
|
||||
QVariant plainScript = CalamaresUtils::yamlMapToVariant( doc ).value( "script" );
|
||||
QVariant rootScript = CalamaresUtils::yamlMapToVariant( YAML::Load( R"(---
|
||||
script:
|
||||
- "ls @@ROOT@@"
|
||||
)" ) )
|
||||
.toMap()
|
||||
.value( "script" );
|
||||
QVariant userScript = CalamaresUtils::yamlMapToVariant( YAML::Load( R"(---
|
||||
script:
|
||||
@ -170,7 +169,6 @@ script:
|
||||
- "chown @@USER@@ @@ROOT@@/calatest*"
|
||||
- rm -rf @@ROOT@@/calatest*
|
||||
)" ) )
|
||||
.toMap()
|
||||
.value( "script" );
|
||||
|
||||
if ( !Calamares::JobQueue::instance() )
|
||||
|
Loading…
Reference in New Issue
Block a user