2016-06-26 00:26:08 +02:00
|
|
|
/*
|
2020-08-22 01:19:58 +02:00
|
|
|
* SPDX-FileCopyrightText: 2016 Luca Giambonini <almack@chakraos.org>
|
|
|
|
* SPDX-FileCopyrightText: 2016 Lisa Vitolo <shainer@chakraos.org>
|
|
|
|
* SPDX-FileCopyrightText: 2017 Kyle Robbertze <krobbertze@gmail.com>
|
|
|
|
* SPDX-FileCopyrightText: 2017-2018 2020, Adriaan de Groot <groot@kde.org>
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2016-06-26 00:26:08 +02:00
|
|
|
*
|
2020-08-25 16:05:56 +02:00
|
|
|
* Calamares is Free Software: see the License-Identifier above.
|
2016-06-26 00:26:08 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "NetInstallViewStep.h"
|
|
|
|
|
|
|
|
#include "GlobalStorage.h"
|
2020-02-18 11:02:53 +01:00
|
|
|
#include "JobQueue.h"
|
2018-05-21 16:49:47 +02:00
|
|
|
|
2016-06-26 00:26:08 +02:00
|
|
|
#include "utils/Logger.h"
|
2019-04-29 11:51:27 +02:00
|
|
|
#include "utils/Variant.h"
|
2016-06-26 00:26:08 +02:00
|
|
|
|
|
|
|
#include "NetInstallPage.h"
|
|
|
|
|
2020-02-18 11:02:53 +01:00
|
|
|
CALAMARES_PLUGIN_FACTORY_DEFINITION( NetInstallViewStepFactory, registerPlugin< NetInstallViewStep >(); )
|
2016-06-26 00:26:08 +02:00
|
|
|
|
|
|
|
NetInstallViewStep::NetInstallViewStep( QObject* parent )
|
|
|
|
: Calamares::ViewStep( parent )
|
2020-03-27 16:12:48 +01:00
|
|
|
, m_widget( new NetInstallPage( &m_config ) )
|
2020-03-27 15:51:03 +01:00
|
|
|
, m_nextEnabled( false )
|
2016-06-26 00:26:08 +02:00
|
|
|
{
|
2020-03-27 16:12:48 +01:00
|
|
|
connect( &m_config, &Config::statusReady, this, &NetInstallViewStep::nextIsReady );
|
2016-06-26 00:26:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NetInstallViewStep::~NetInstallViewStep()
|
|
|
|
{
|
|
|
|
if ( m_widget && m_widget->parent() == nullptr )
|
2020-02-18 11:02:53 +01:00
|
|
|
{
|
2016-06-26 00:26:08 +02:00
|
|
|
m_widget->deleteLater();
|
2020-02-18 11:02:53 +01:00
|
|
|
}
|
2016-06-26 00:26:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString
|
|
|
|
NetInstallViewStep::prettyName() const
|
|
|
|
{
|
2021-02-08 22:57:38 +01:00
|
|
|
return m_config.sidebarLabel();
|
2020-02-19 14:37:47 +01:00
|
|
|
|
2020-03-23 14:10:48 +01:00
|
|
|
#if defined( TABLE_OF_TRANSLATIONS )
|
2020-10-25 12:48:12 +01:00
|
|
|
__builtin_unreachable();
|
2020-02-19 14:37:47 +01:00
|
|
|
// This is a table of "standard" labels for this module. If you use them
|
|
|
|
// in the label: sidebar: section of the config file, the existing
|
|
|
|
// translations can be used.
|
2021-02-09 10:58:11 +01:00
|
|
|
//
|
|
|
|
// These translations still live here, even though the lookup
|
|
|
|
// code is in the Config class.
|
2020-02-19 14:37:47 +01:00
|
|
|
tr( "Package selection" );
|
|
|
|
tr( "Office software" );
|
|
|
|
tr( "Office package" );
|
|
|
|
tr( "Browser software" );
|
|
|
|
tr( "Browser package" );
|
|
|
|
tr( "Web browser" );
|
2020-02-19 17:21:12 +01:00
|
|
|
tr( "Kernel" );
|
|
|
|
tr( "Services" );
|
|
|
|
tr( "Login" );
|
|
|
|
tr( "Desktop" );
|
|
|
|
tr( "Applications" );
|
2020-04-06 17:35:27 +02:00
|
|
|
tr( "Communication" );
|
|
|
|
tr( "Development" );
|
|
|
|
tr( "Office" );
|
|
|
|
tr( "Multimedia" );
|
|
|
|
tr( "Internet" );
|
|
|
|
tr( "Theming" );
|
|
|
|
tr( "Gaming" );
|
|
|
|
tr( "Utilities" );
|
2020-02-19 17:21:12 +01:00
|
|
|
#endif
|
2016-06-26 00:26:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QWidget*
|
|
|
|
NetInstallViewStep::widget()
|
|
|
|
{
|
|
|
|
return m_widget;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
NetInstallViewStep::isNextEnabled() const
|
|
|
|
{
|
2020-03-27 16:12:48 +01:00
|
|
|
return !m_config.required() || m_nextEnabled;
|
2016-06-26 00:26:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
NetInstallViewStep::isBackEnabled() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
NetInstallViewStep::isAtBeginning() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
NetInstallViewStep::isAtEnd() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-27 15:14:37 +01:00
|
|
|
Calamares::JobList
|
2016-06-26 00:26:08 +02:00
|
|
|
NetInstallViewStep::jobs() const
|
|
|
|
{
|
2020-03-27 15:14:37 +01:00
|
|
|
return Calamares::JobList();
|
2016-06-26 00:26:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
NetInstallViewStep::onActivate()
|
|
|
|
{
|
|
|
|
m_widget->onActivate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
NetInstallViewStep::onLeave()
|
|
|
|
{
|
2020-03-27 15:51:03 +01:00
|
|
|
auto packages = m_config.model()->getPackages();
|
2020-02-18 11:28:42 +01:00
|
|
|
cDebug() << "Netinstall: Processing" << packages.length() << "packages.";
|
|
|
|
|
|
|
|
static const char PACKAGEOP[] = "packageOperations";
|
|
|
|
|
|
|
|
// Check if there's already a PACAKGEOP entry in GS, and if so we'll
|
|
|
|
// extend that one (overwriting the value in GS at the end of this method)
|
|
|
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
|
|
|
QVariantList packageOperations = gs->contains( PACKAGEOP ) ? gs->value( PACKAGEOP ).toList() : QVariantList();
|
|
|
|
cDebug() << Logger::SubEntry << "Existing package operations length" << packageOperations.length();
|
|
|
|
|
2020-02-18 14:46:00 +01:00
|
|
|
// Clear out existing operations for this module, going backwards:
|
|
|
|
// Sometimes we remove an item, and we don't want the index to
|
|
|
|
// fall off the end of the list.
|
2020-11-18 17:27:50 +01:00
|
|
|
bool somethingRemoved = false;
|
2020-02-18 17:37:58 +01:00
|
|
|
for ( int index = packageOperations.length() - 1; 0 <= index; index-- )
|
2020-02-18 14:46:00 +01:00
|
|
|
{
|
2020-02-18 17:37:58 +01:00
|
|
|
const QVariantMap op = packageOperations.at( index ).toMap();
|
2020-02-18 14:46:00 +01:00
|
|
|
if ( op.contains( "source" ) && op.value( "source" ).toString() == moduleInstanceKey().toString() )
|
|
|
|
{
|
|
|
|
cDebug() << Logger::SubEntry << "Removing existing operations for" << moduleInstanceKey();
|
|
|
|
packageOperations.removeAt( index );
|
2020-11-18 17:27:50 +01:00
|
|
|
somethingRemoved = true;
|
2020-02-18 14:46:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-18 11:28:42 +01:00
|
|
|
// This netinstall module may add two sub-steps to the packageOperations,
|
|
|
|
// one for installing and one for try-installing.
|
2017-01-25 09:34:18 +01:00
|
|
|
QVariantList installPackages;
|
|
|
|
QVariantList tryInstallPackages;
|
|
|
|
|
2020-02-18 11:40:43 +01:00
|
|
|
for ( const auto& package : packages )
|
2017-01-25 09:34:18 +01:00
|
|
|
{
|
2020-03-20 23:03:47 +01:00
|
|
|
if ( package->isCritical() )
|
2020-02-18 11:02:53 +01:00
|
|
|
{
|
2020-03-20 23:03:47 +01:00
|
|
|
installPackages.append( package->toOperation() );
|
2020-02-18 11:02:53 +01:00
|
|
|
}
|
2017-01-25 09:34:18 +01:00
|
|
|
else
|
2020-02-18 11:02:53 +01:00
|
|
|
{
|
2020-03-20 23:03:47 +01:00
|
|
|
tryInstallPackages.append( package->toOperation() );
|
2020-02-18 11:02:53 +01:00
|
|
|
}
|
2017-01-25 09:34:18 +01:00
|
|
|
}
|
2016-11-12 18:57:58 +01:00
|
|
|
|
2017-01-23 13:42:40 +01:00
|
|
|
if ( !installPackages.empty() )
|
2017-10-23 17:10:18 +02:00
|
|
|
{
|
2020-02-18 14:18:48 +01:00
|
|
|
QVariantMap op;
|
2017-10-23 17:10:18 +02:00
|
|
|
op.insert( "install", QVariant( installPackages ) );
|
2020-02-18 14:18:48 +01:00
|
|
|
op.insert( "source", moduleInstanceKey().toString() );
|
2017-11-06 11:34:57 +01:00
|
|
|
packageOperations.append( op );
|
2019-04-15 14:59:12 +02:00
|
|
|
cDebug() << Logger::SubEntry << installPackages.length() << "critical packages.";
|
2017-10-23 17:10:18 +02:00
|
|
|
}
|
2017-01-23 13:42:40 +01:00
|
|
|
if ( !tryInstallPackages.empty() )
|
2017-10-23 17:10:18 +02:00
|
|
|
{
|
2020-02-18 14:18:48 +01:00
|
|
|
QVariantMap op;
|
2017-10-23 17:10:18 +02:00
|
|
|
op.insert( "try_install", QVariant( tryInstallPackages ) );
|
2020-02-18 14:18:48 +01:00
|
|
|
op.insert( "source", moduleInstanceKey().toString() );
|
2017-11-06 11:34:57 +01:00
|
|
|
packageOperations.append( op );
|
2019-04-15 14:59:12 +02:00
|
|
|
cDebug() << Logger::SubEntry << tryInstallPackages.length() << "non-critical packages.";
|
2017-10-23 17:10:18 +02:00
|
|
|
}
|
2016-06-26 00:26:08 +02:00
|
|
|
|
2020-11-18 17:27:50 +01:00
|
|
|
if ( somethingRemoved || !packageOperations.isEmpty() )
|
2017-01-23 13:42:40 +01:00
|
|
|
{
|
2020-02-18 11:28:42 +01:00
|
|
|
gs->insert( PACKAGEOP, packageOperations );
|
2016-06-26 00:26:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-18 17:59:34 +01:00
|
|
|
void
|
2020-03-27 16:12:48 +01:00
|
|
|
NetInstallViewStep::nextIsReady()
|
2020-02-18 17:59:34 +01:00
|
|
|
{
|
2020-03-27 16:12:48 +01:00
|
|
|
m_nextEnabled = true;
|
|
|
|
emit nextStatusChanged( true );
|
2020-02-18 17:59:34 +01:00
|
|
|
}
|
2016-06-26 00:26:08 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
NetInstallViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|
|
|
{
|
2021-02-08 22:57:38 +01:00
|
|
|
m_config.setConfigurationMap( configurationMap );
|
2017-11-06 11:14:42 +01:00
|
|
|
}
|