mirror of https://github.com/cutefishos/calamares
Merge branch 'calamares' into improve-partition
commit
df20aa9ddb
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- SPDX-FileCopyrightText: no
|
||||
SPDX-License-Identifier: CC0-1.0
|
||||
-->
|
||||
<!DOCTYPE TS>
|
||||
<TS language="nl" version="2.1">
|
||||
<context>
|
||||
<name>LocaleTests</name>
|
||||
<message>
|
||||
<location filename="Tests.cpp" line="22"/>
|
||||
<source>Quit</source>
|
||||
<translation>Ophouden</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
@ -0,0 +1,7 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
---
|
||||
required: true
|
||||
groupsUrl:
|
||||
- file://$TESTDIR/bad.yaml
|
@ -0,0 +1,7 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
---
|
||||
required: true
|
||||
groupsUrl:
|
||||
- file://$TESTDIR/data-empty.yaml
|
@ -0,0 +1,7 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
---
|
||||
required: true
|
||||
groupsUrl:
|
||||
- file://$TESTDIR/data-error.yaml
|
@ -0,0 +1,7 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
---
|
||||
required: true
|
||||
groupsUrl:
|
||||
- file://$TESTDIR/data-large.yaml
|
@ -0,0 +1,7 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
---
|
||||
required: true
|
||||
groupsUrl:
|
||||
- file://$TESTDIR/data-small.yaml
|
@ -0,0 +1,6 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
---
|
||||
required: true
|
||||
groupsUrl: []
|
@ -0,0 +1,5 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
---
|
||||
required: true
|
@ -0,0 +1,10 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
---
|
||||
required: true
|
||||
groupsUrl:
|
||||
- file://$TESTDIR/data-nonexistent.yaml
|
||||
- file://$TESTDIR/data-empty.yaml
|
||||
- file://$TESTDIR/data-empty.yaml
|
||||
- file://$TESTDIR/data-bad.yaml
|
@ -0,0 +1,10 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
---
|
||||
required: true
|
||||
groupsUrl:
|
||||
- file://$TESTDIR/data-nonexistent.yaml
|
||||
- file://$TESTDIR/data-bad.yaml
|
||||
- file://$TESTDIR/data-large.yaml
|
||||
- file://$TESTDIR/data-small.yaml
|
@ -0,0 +1,13 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
---
|
||||
required: true
|
||||
groupsUrl:
|
||||
- file://$TESTDIR/data-nonexistent.yaml
|
||||
- file://$TESTDIR/data-empty.yaml
|
||||
- file://$TESTDIR/data-bad.yaml
|
||||
- file://$TESTDIR/data-empty.yaml
|
||||
- file://$TESTDIR/data-small.yaml
|
||||
- file://$TESTDIR/data-large.yaml
|
||||
- file://$TESTDIR/data-bad.yaml
|
@ -0,0 +1,10 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
---
|
||||
required: true
|
||||
groupsUrl:
|
||||
- file://$TESTDIR/data-nonexistent.yaml
|
||||
- file://$TESTDIR/data-bad.yaml
|
||||
- file://$TESTDIR/data-small.yaml
|
||||
- file://$TESTDIR/data-large.yaml
|
@ -0,0 +1,6 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
---
|
||||
bogus: true
|
||||
|
@ -0,0 +1,8 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
derp
|
||||
derp
|
||||
herpa-derp: no
|
||||
--
|
||||
# This file is not valid YAML
|
@ -0,0 +1,38 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
- name: "Default"
|
||||
description: "Default group"
|
||||
hidden: false
|
||||
selected: true
|
||||
critical: false
|
||||
packages:
|
||||
- base
|
||||
- name: "Two"
|
||||
description: "group 2"
|
||||
hidden: false
|
||||
selected: true
|
||||
critical: false
|
||||
packages:
|
||||
- chakra-live-two
|
||||
- name: "Three"
|
||||
description: "group 3"
|
||||
hidden: false
|
||||
selected: true
|
||||
critical: false
|
||||
packages:
|
||||
- chakra-live-three
|
||||
- name: "Four"
|
||||
description: "group 4"
|
||||
hidden: false
|
||||
selected: true
|
||||
critical: false
|
||||
packages:
|
||||
- chakra-live-four
|
||||
- name: "Five"
|
||||
description: "group 5"
|
||||
hidden: false
|
||||
selected: true
|
||||
critical: false
|
||||
packages:
|
||||
- chakra-live-five
|
@ -0,0 +1,17 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
- name: "Default"
|
||||
description: "Default group"
|
||||
hidden: false
|
||||
selected: true
|
||||
critical: false
|
||||
packages:
|
||||
- base
|
||||
- name: "Second"
|
||||
description: "Second group"
|
||||
hidden: false
|
||||
selected: true
|
||||
critical: false
|
||||
packages:
|
||||
- chakra-live-skel
|
@ -0,0 +1,224 @@
|
||||
/* === This file is part of Calamares - <https://calamares.io> ===
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2021 Adriaan de Groot <groot@kde.org>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* Calamares is Free Software: see the License-Identifier above.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#ifdef HAVE_XML
|
||||
#include "ItemAppData.h"
|
||||
#endif
|
||||
|
||||
#include "GlobalStorage.h"
|
||||
#include "JobQueue.h"
|
||||
#include "packages/Globals.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/Variant.h"
|
||||
|
||||
const NamedEnumTable< PackageChooserMode >&
|
||||
packageChooserModeNames()
|
||||
{
|
||||
static const NamedEnumTable< PackageChooserMode > names {
|
||||
{ "optional", PackageChooserMode::Optional },
|
||||
{ "required", PackageChooserMode::Required },
|
||||
{ "optionalmultiple", PackageChooserMode::OptionalMultiple },
|
||||
{ "requiredmultiple", PackageChooserMode::RequiredMultiple },
|
||||
// and a bunch of aliases
|
||||
{ "zero-or-one", PackageChooserMode::Optional },
|
||||
{ "radio", PackageChooserMode::Required },
|
||||
{ "one", PackageChooserMode::Required },
|
||||
{ "set", PackageChooserMode::OptionalMultiple },
|
||||
{ "zero-or-more", PackageChooserMode::OptionalMultiple },
|
||||
{ "multiple", PackageChooserMode::RequiredMultiple },
|
||||
{ "one-or-more", PackageChooserMode::RequiredMultiple }
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
const NamedEnumTable< PackageChooserMethod >&
|
||||
PackageChooserMethodNames()
|
||||
{
|
||||
static const NamedEnumTable< PackageChooserMethod > names {
|
||||
{ "legacy", PackageChooserMethod::Legacy },
|
||||
{ "custom", PackageChooserMethod::Legacy },
|
||||
{ "contextualprocess", PackageChooserMethod::Legacy },
|
||||
{ "packages", PackageChooserMethod::Packages },
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
Config::Config( QObject* parent )
|
||||
: Calamares::ModuleSystem::Config( parent )
|
||||
, m_model( new PackageListModel( this ) )
|
||||
, m_mode( PackageChooserMode::Required )
|
||||
{
|
||||
}
|
||||
|
||||
Config::~Config() {}
|
||||
|
||||
const PackageItem&
|
||||
Config::introductionPackage() const
|
||||
{
|
||||
for ( int i = 0; i < m_model->packageCount(); ++i )
|
||||
{
|
||||
const auto& package = m_model->packageData( i );
|
||||
if ( package.isNonePackage() )
|
||||
{
|
||||
return package;
|
||||
}
|
||||
}
|
||||
|
||||
static PackageItem* defaultIntroduction = nullptr;
|
||||
if ( !defaultIntroduction )
|
||||
{
|
||||
const auto name = QT_TR_NOOP( "Package Selection" );
|
||||
const auto description
|
||||
= QT_TR_NOOP( "Please pick a product from the list. The selected product will be installed." );
|
||||
defaultIntroduction = new PackageItem( QString(), name, description );
|
||||
defaultIntroduction->screenshot = QPixmap( QStringLiteral( ":/images/no-selection.png" ) );
|
||||
defaultIntroduction->name = CalamaresUtils::Locale::TranslatedString( name, metaObject()->className() );
|
||||
defaultIntroduction->description
|
||||
= CalamaresUtils::Locale::TranslatedString( description, metaObject()->className() );
|
||||
}
|
||||
return *defaultIntroduction;
|
||||
}
|
||||
|
||||
void
|
||||
Config::updateGlobalStorage( const QStringList& selected ) const
|
||||
{
|
||||
if ( m_method == PackageChooserMethod::Legacy )
|
||||
{
|
||||
QString value = selected.join( ',' );
|
||||
Calamares::JobQueue::instance()->globalStorage()->insert( m_id, value );
|
||||
cDebug() << m_id<< "selected" << value;
|
||||
}
|
||||
else if ( m_method == PackageChooserMethod::Packages )
|
||||
{
|
||||
QStringList packageNames = m_model->getInstallPackagesForNames( selected );
|
||||
cDebug() << m_defaultId << "packages to install" << packageNames;
|
||||
CalamaresUtils::Packages::setGSPackageAdditions(
|
||||
Calamares::JobQueue::instance()->globalStorage(), m_defaultId, packageNames );
|
||||
}
|
||||
else
|
||||
{
|
||||
cWarning() << "Unknown packagechooser method" << smash( m_method );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
fillModel( PackageListModel* model, const QVariantList& items )
|
||||
{
|
||||
if ( items.isEmpty() )
|
||||
{
|
||||
cWarning() << "No *items* for PackageChooser module.";
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef HAVE_APPSTREAM
|
||||
std::unique_ptr< AppStream::Pool > pool;
|
||||
bool poolOk = false;
|
||||
#endif
|
||||
|
||||
cDebug() << "Loading PackageChooser model items from config";
|
||||
int item_index = 0;
|
||||
for ( const auto& item_it : items )
|
||||
{
|
||||
++item_index;
|
||||
QVariantMap item_map = item_it.toMap();
|
||||
if ( item_map.isEmpty() )
|
||||
{
|
||||
cWarning() << "PackageChooser entry" << item_index << "is not valid.";
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( item_map.contains( "appdata" ) )
|
||||
{
|
||||
#ifdef HAVE_XML
|
||||
model->addPackage( fromAppData( item_map ) );
|
||||
#else
|
||||
cWarning() << "Loading AppData XML is not supported.";
|
||||
#endif
|
||||
}
|
||||
else if ( item_map.contains( "appstream" ) )
|
||||
{
|
||||
#ifdef HAVE_APPSTREAM
|
||||
if ( !pool )
|
||||
{
|
||||
pool = std::make_unique< AppStream::Pool >();
|
||||
pool->setLocale( QStringLiteral( "ALL" ) );
|
||||
poolOk = pool->load();
|
||||
}
|
||||
if ( pool && poolOk )
|
||||
{
|
||||
model->addPackage( fromAppStream( *pool, item_map ) );
|
||||
}
|
||||
#else
|
||||
cWarning() << "Loading AppStream data is not supported.";
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
model->addPackage( PackageItem( item_map ) );
|
||||
}
|
||||
}
|
||||
cDebug() << Logger::SubEntry << "Loaded PackageChooser with" << model->packageCount() << "entries.";
|
||||
}
|
||||
|
||||
void
|
||||
Config::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
{
|
||||
m_mode = packageChooserModeNames().find( CalamaresUtils::getString( configurationMap, "mode" ),
|
||||
PackageChooserMode::Required );
|
||||
m_method = PackageChooserMethodNames().find( CalamaresUtils::getString( configurationMap, "method" ),
|
||||
PackageChooserMethod::Legacy );
|
||||
|
||||
if ( m_method == PackageChooserMethod::Legacy )
|
||||
{
|
||||
const QString configId = CalamaresUtils::getString( configurationMap, "id" );
|
||||
const QString base = QStringLiteral( "packagechooser_" );
|
||||
if ( configId.isEmpty() )
|
||||
{
|
||||
if ( m_defaultId.id().isEmpty() )
|
||||
{
|
||||
// We got nothing to work with
|
||||
m_id = base;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_id = base + m_defaultId.id();
|
||||
}
|
||||
cDebug() << "Using default ID" << m_id << "from" << m_defaultId.toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_id = base + configId;
|
||||
cDebug() << "Using configured ID" << m_id;
|
||||
}
|
||||
}
|
||||
|
||||
if ( configurationMap.contains( "items" ) )
|
||||
{
|
||||
fillModel( m_model, configurationMap.value( "items" ).toList() );
|
||||
}
|
||||
|
||||
QString default_item_id = CalamaresUtils::getString( configurationMap, "default" );
|
||||
if ( !default_item_id.isEmpty() )
|
||||
{
|
||||
for ( int item_n = 0; item_n < m_model->packageCount(); ++item_n )
|
||||
{
|
||||
QModelIndex item_idx = m_model->index( item_n, 0 );
|
||||
QVariant item_id = m_model->data( item_idx, PackageListModel::IdRole );
|
||||
|
||||
if ( item_id.toString() == default_item_id )
|
||||
{
|
||||
m_defaultModelIndex = item_idx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
/* === This file is part of Calamares - <https://calamares.io> ===
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2021 Adriaan de Groot <groot@kde.org>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* Calamares is Free Software: see the License-Identifier above.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PACKAGECHOOSER_CONFIG_H
|
||||
#define PACKAGECHOOSER_CONFIG_H
|
||||
|
||||
#include "PackageModel.h"
|
||||
|
||||
#include "modulesystem/Config.h"
|
||||
#include "modulesystem/InstanceKey.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
enum class PackageChooserMode
|
||||
{
|
||||
Optional, // zero or one
|
||||
Required, // exactly one
|
||||
OptionalMultiple, // zero or more
|
||||
RequiredMultiple // one or more
|
||||
};
|
||||
|
||||
const NamedEnumTable< PackageChooserMode >& packageChooserModeNames();
|
||||
|
||||
enum class PackageChooserMethod
|
||||
{
|
||||
Legacy, // use contextualprocess or other custom
|
||||
Packages, // use the packages module
|
||||
};
|
||||
|
||||
const NamedEnumTable< PackageChooserMethod >& PackageChooserMethodNames();
|
||||
|
||||
class Config : public Calamares::ModuleSystem::Config
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Config( QObject* parent = nullptr );
|
||||
~Config() override;
|
||||
|
||||
/** @brief Sets the default Id for this Config
|
||||
*
|
||||
* The default Id is the (owning) module identifier for the config,
|
||||
* and it is used when the Id read from the config file is empty.
|
||||
* The **usual** configuration when using method *packages* is
|
||||
* to rely on the default Id.
|
||||
*/
|
||||
void setDefaultId( const Calamares::ModuleSystem::InstanceKey& defaultId ) { m_defaultId = defaultId; }
|
||||
void setConfigurationMap( const QVariantMap& ) override;
|
||||
|
||||
PackageChooserMode mode() const { return m_mode; }
|
||||
PackageListModel* model() const { return m_model; }
|
||||
QModelIndex defaultSelectionIndex() const { return m_defaultModelIndex; }
|
||||
|
||||
/** @brief Returns an "introductory package" which describes packagechooser
|
||||
*
|
||||
* If the model contains a "none" package, returns that one on
|
||||
* the assumption that it is one to describe the whole; otherwise
|
||||
* returns a totally generic description.
|
||||
*/
|
||||
const PackageItem& introductionPackage() const;
|
||||
|
||||
/** @brief Write selection to global storage
|
||||
*
|
||||
* Updates the GS keys for this packagechooser, marking all
|
||||
* (and only) the packages in @p selected as selected.
|
||||
*/
|
||||
void updateGlobalStorage( const QStringList& selected ) const;
|
||||
/// As updateGlobalStorage() with an empty selection list
|
||||
void updateGlobalStorage() const { updateGlobalStorage( QStringList() ); }
|
||||
|
||||
private:
|
||||
PackageListModel* m_model = nullptr;
|
||||
QModelIndex m_defaultModelIndex;
|
||||
|
||||
/// Selection mode for this module
|
||||
PackageChooserMode m_mode = PackageChooserMode::Optional;
|
||||
/// How this module stores to GS
|
||||
PackageChooserMethod m_method = PackageChooserMethod::Legacy;
|
||||
/// Id (used to identify settings from this module in GS)
|
||||
QString m_id;
|
||||
/// Value to use for id if none is set in the config file
|
||||
Calamares::ModuleSystem::InstanceKey m_defaultId;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@ -0,0 +1,7 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
---
|
||||
autologinGroup: derp
|
||||
doAutologin: true
|
||||
|
@ -0,0 +1,7 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
---
|
||||
autologinGroup: derp
|
||||
doAutoLogin: true
|
||||
|
@ -0,0 +1,7 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
---
|
||||
autoLoginGroup: derp
|
||||
doAutologin: true
|
||||
|
@ -0,0 +1,7 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
---
|
||||
autoLoginGroup: derp
|
||||
doAutoLogin: true
|
||||
|
@ -0,0 +1,7 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
---
|
||||
doautologin: true
|
||||
autologingroup: wheel
|
||||
|
Loading…
Reference in New Issue