2016-06-26 00:26:08 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2016, Luca Giambonini <almack@chakraos.org>
|
2016-06-28 00:00:47 +02:00
|
|
|
* Copyright 2016, Lisa Vitolo <shainer@chakraos.org>
|
2017-01-25 09:34:18 +01:00
|
|
|
* Copyright 2017, Kyle Robbertze <krobbertze@gmail.com>
|
2018-06-15 11:59:11 +02:00
|
|
|
* Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
|
2016-06-26 00:26:08 +02:00
|
|
|
*
|
|
|
|
* Calamares is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Calamares is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "NetInstallViewStep.h"
|
|
|
|
|
|
|
|
#include "JobQueue.h"
|
|
|
|
#include "GlobalStorage.h"
|
2018-05-21 16:49:47 +02:00
|
|
|
|
|
|
|
#include "utils/CalamaresUtils.h"
|
2016-06-26 00:26:08 +02:00
|
|
|
#include "utils/Logger.h"
|
|
|
|
|
|
|
|
#include "NetInstallPage.h"
|
|
|
|
|
|
|
|
CALAMARES_PLUGIN_FACTORY_DEFINITION( NetInstallViewStepFactory, registerPlugin<NetInstallViewStep>(); )
|
|
|
|
|
|
|
|
NetInstallViewStep::NetInstallViewStep( QObject* parent )
|
|
|
|
: Calamares::ViewStep( parent )
|
|
|
|
, m_widget( new NetInstallPage() )
|
2017-11-06 11:14:42 +01:00
|
|
|
, m_nextEnabled( false )
|
2016-06-26 00:26:08 +02:00
|
|
|
{
|
|
|
|
emit nextStatusChanged( true );
|
|
|
|
connect( m_widget, &NetInstallPage::checkReady,
|
2017-11-06 11:14:42 +01:00
|
|
|
this, &NetInstallViewStep::nextIsReady );
|
2016-06-26 00:26:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NetInstallViewStep::~NetInstallViewStep()
|
|
|
|
{
|
|
|
|
if ( m_widget && m_widget->parent() == nullptr )
|
|
|
|
m_widget->deleteLater();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString
|
|
|
|
NetInstallViewStep::prettyName() const
|
|
|
|
{
|
2016-06-30 23:32:31 +02:00
|
|
|
return tr( "Package selection" );
|
2016-06-26 00:26:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString
|
|
|
|
NetInstallViewStep::prettyStatus() const
|
|
|
|
{
|
|
|
|
return m_prettyStatus;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QWidget*
|
|
|
|
NetInstallViewStep::widget()
|
|
|
|
{
|
|
|
|
return m_widget;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
NetInstallViewStep::isNextEnabled() const
|
|
|
|
{
|
|
|
|
return m_nextEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
NetInstallViewStep::isBackEnabled() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
NetInstallViewStep::isAtBeginning() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
NetInstallViewStep::isAtEnd() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QList< Calamares::job_ptr >
|
|
|
|
NetInstallViewStep::jobs() const
|
|
|
|
{
|
|
|
|
return m_jobs;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
NetInstallViewStep::onActivate()
|
|
|
|
{
|
|
|
|
m_widget->onActivate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
NetInstallViewStep::onLeave()
|
|
|
|
{
|
|
|
|
cDebug() << "Leaving netinstall, adding packages to be installed"
|
|
|
|
<< "to global storage";
|
|
|
|
|
2017-11-06 11:42:13 +01:00
|
|
|
PackageModel::PackageItemDataList packages = m_widget->selectedPackages();
|
2017-01-25 09:34:18 +01:00
|
|
|
QVariantList installPackages;
|
|
|
|
QVariantList tryInstallPackages;
|
2017-10-23 17:10:18 +02:00
|
|
|
QVariantList packageOperations;
|
|
|
|
|
2017-10-23 22:46:03 +02:00
|
|
|
cDebug() << "Processing" << packages.length() << "packages from netinstall.";
|
2017-01-25 09:34:18 +01:00
|
|
|
|
|
|
|
for ( auto package : packages )
|
|
|
|
{
|
2017-10-23 17:15:19 +02:00
|
|
|
QVariant details( package.packageName );
|
|
|
|
// If it's a package with a pre- or post-script, replace
|
|
|
|
// with the more complicated datastructure.
|
2017-11-06 11:34:57 +01:00
|
|
|
if ( !package.preScript.isEmpty() || !package.postScript.isEmpty() )
|
2017-10-23 17:15:19 +02:00
|
|
|
{
|
|
|
|
QMap<QString, QVariant> sdetails;
|
|
|
|
sdetails.insert( "pre-script", package.preScript );
|
|
|
|
sdetails.insert( "package", package.packageName );
|
|
|
|
sdetails.insert( "post-script", package.postScript );
|
|
|
|
details = sdetails;
|
|
|
|
}
|
2017-01-25 09:34:18 +01:00
|
|
|
if ( package.isCritical )
|
|
|
|
installPackages.append( details );
|
|
|
|
else
|
|
|
|
tryInstallPackages.append( details );
|
|
|
|
}
|
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
|
|
|
{
|
|
|
|
QMap<QString, QVariant> op;
|
|
|
|
op.insert( "install", QVariant( installPackages ) );
|
2017-11-06 11:34:57 +01:00
|
|
|
packageOperations.append( op );
|
2017-10-23 22:46:03 +02:00
|
|
|
cDebug() << " .." << 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
|
|
|
{
|
|
|
|
QMap<QString, QVariant> op;
|
|
|
|
op.insert( "try_install", QVariant( tryInstallPackages ) );
|
2017-11-06 11:34:57 +01:00
|
|
|
packageOperations.append( op );
|
2017-10-23 22:46:03 +02:00
|
|
|
cDebug() << " .." << tryInstallPackages.length() << "non-critical packages.";
|
2017-10-23 17:10:18 +02:00
|
|
|
}
|
2016-06-26 00:26:08 +02:00
|
|
|
|
2017-10-23 17:10:18 +02:00
|
|
|
if ( !packageOperations.isEmpty() )
|
2017-01-23 13:42:40 +01:00
|
|
|
{
|
2016-06-26 00:26:08 +02:00
|
|
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
2017-10-23 17:10:18 +02:00
|
|
|
gs->insert( "packageOperations", QVariant( packageOperations ) );
|
2016-06-26 00:26:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
NetInstallViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|
|
|
{
|
2018-05-21 16:49:47 +02:00
|
|
|
m_widget->setRequired( CalamaresUtils::getBool( configurationMap, "required", false ) );
|
2017-11-06 11:14:42 +01:00
|
|
|
|
2018-05-21 16:49:47 +02:00
|
|
|
QString groupsUrl = CalamaresUtils::getString( configurationMap, "groupsUrl" );
|
|
|
|
if ( !groupsUrl.isEmpty() )
|
2016-06-26 00:26:08 +02:00
|
|
|
{
|
2018-05-21 16:58:57 +02:00
|
|
|
// Keep putting groupsUrl into the global storage,
|
|
|
|
// even though it's no longer used for in-module data-passing.
|
2018-05-21 16:49:47 +02:00
|
|
|
Calamares::JobQueue::instance()->globalStorage()->insert( "groupsUrl", groupsUrl );
|
2018-05-21 16:58:57 +02:00
|
|
|
m_widget->loadGroupList( groupsUrl );
|
2016-06-26 00:26:08 +02:00
|
|
|
}
|
|
|
|
}
|
2017-11-06 11:14:42 +01:00
|
|
|
|
|
|
|
void
|
|
|
|
NetInstallViewStep::nextIsReady( bool b )
|
|
|
|
{
|
|
|
|
m_nextEnabled = b;
|
|
|
|
emit nextStatusChanged( b );
|
|
|
|
}
|