diff options
author | bill-auger <mr.j.spam.me@gmail.com> | 2018-05-21 20:35:11 -0400 |
---|---|---|
committer | bill-auger <mr.j.spam.me@gmail.com> | 2018-05-27 06:26:01 -0400 |
commit | 8f0035f4a5864494bbcc2a7e46dee0a8c7a13765 (patch) | |
tree | a6e3c77b8a97a7657c3e4e75a2697e58101e3766 | |
parent | c84317762af82ee603c734ef74f41041cf339633 (diff) |
stash - pacstrap extra packgaes (fully in memory)
-rw-r--r-- | src/modules/netinstall/NetInstallPage.cpp | 86 | ||||
-rw-r--r-- | src/modules/netinstall/NetInstallViewStep.cpp | 68 |
2 files changed, 90 insertions, 64 deletions
diff --git a/src/modules/netinstall/NetInstallPage.cpp b/src/modules/netinstall/NetInstallPage.cpp index c0cc23e3b..d654f110d 100644 --- a/src/modules/netinstall/NetInstallPage.cpp +++ b/src/modules/netinstall/NetInstallPage.cpp @@ -100,6 +100,8 @@ NetInstallPage::readGroups( const QByteArray& yamlData ) void NetInstallPage::dataIsHere( QNetworkReply* reply ) { + bool is_valid_package_data = false; + // If m_required is *false* then we still say we're ready // even if the reply is corrupt or missing. if ( reply->error() != QNetworkReply::NoError ) @@ -108,27 +110,81 @@ NetInstallPage::dataIsHere( QNetworkReply* reply ) cDebug() << " ..Netinstall reply error: " << reply->error(); cDebug() << " ..Request for url: " << reply->url().toString() << " failed with: " << reply->errorString(); ui->netinst_status->setText( tr( "Network Installation. (Disabled: Unable to fetch package lists, check your network connection)" ) ); - emit checkReady( !m_required ); - return; } - - if ( !readGroups( reply->readAll() ) ) + else { - cDebug() << "WARNING: netinstall groups data was received, but invalid."; - cDebug() << " ..Url: " << reply->url().toString(); - cDebug() << " ..Headers: " << reply->rawHeaderList(); - ui->netinst_status->setText( tr( "Network Installation. (Disabled: Received invalid groups data)" ) ); + // Parse received YAML to create the PackageModel + is_valid_package_data = readGroups( reply->readAll() ); + + if ( !is_valid_package_data ) + { + cDebug() << "WARNING: netinstall groups data was received, but invalid."; + cDebug() << " ..Url: " << reply->url().toString(); + cDebug() << " ..Headers: " << reply->rawHeaderList(); + ui->netinst_status->setText( tr( "Network Installation. (Disabled: Received invalid groups data)" ) ); + } + reply->deleteLater(); - emit checkReady( !m_required ); - return; } - ui->groupswidget->setModel( m_groups ); - ui->groupswidget->header()->setSectionResizeMode( 0, QHeaderView::ResizeToContents ); - ui->groupswidget->header()->setSectionResizeMode( 1, QHeaderView::Stretch ); + populateGroupsWidget( is_valid_package_data ); +} + +void +NetInstallPage::parseGroupList( const QVariantList& package_groups ) +{ + // Convert netinstall.conf packages lists to YAML + QVariantList package_groups = configurationMap.value( GS::PACKAGE_GROUPS_KEY ).toList(); + YAML::Emitter package_groups_yaml; + package_groups_yaml.SetOutputCharset(YAML::EscapeNonAscii); + package_groups_yaml << YAML::BeginSeq; + for ( int groups_n = 0; groups_n < package_groups.length(); ++groups_n ) + { + QVariantMap package_group = package_groups.value(groups_n).toMap(); + std::string group_name = package_group["name"].toString().toStdString(); + std::string group_desc = package_group["description"].toString().toStdString(); + std::string group_critical = package_group["critical"].toString().toStdString(); + QStringList group_packages = package_group.value( "packages" ).toStringList(); + std::vector< std::string > packages; + foreach ( const QString& package , group_packages ) + packages.push_back( package.toStdString() ); + +cDebug() << "NetInstallPage::parseGroupList() package_group[name]=" << QString::fromStdString(group_name); +cDebug() << "NetInstallPage::parseGroupList() package_group[description]=" << QString::fromStdString(group_desc); +cDebug() << "NetInstallPage::parseGroupList() package_group[critical]=" << QString::fromStdString(group_critical); +cDebug() << "NetInstallPage::parseGroupList() package_group[packages]=" << group_packages; + + package_groups_yaml << YAML::BeginMap; + package_groups_yaml << YAML::Key << "name" << YAML::Value << group_name; + package_groups_yaml << YAML::Key << "description" << YAML::Value << group_desc; + package_groups_yaml << YAML::Key << "critical" << YAML::Value << group_critical; + package_groups_yaml << YAML::Key << "packages" << YAML::Value << packages; + package_groups_yaml << YAML::EndMap; + } + package_groups_yaml << YAML::EndSeq; + +// DBG << "NetInstallPage::parseGroupList() err=" << QString(package_groups_yaml.GetLastError()); + + // Parse generated YAML to create the PackageModel + bool is_valid_package_data = readGroups( QByteArray( package_groups_yaml.c_str() ) ); + + if ( !is_valid_package_data ) + ui->netinst_status->setText( tr( "Package Selection. (Disabled: Invalid groups data)" ) ); + + populateGroupsWidget( is_valid_package_data ); +} + +void +NetInstallPage::populateGroupsWidget( bool is_valid_package_data ) +{ + if ( is_valid_package_data ) + { + ui->groupswidget->setModel( m_groups ); + ui->groupswidget->header()->setSectionResizeMode( 0, QHeaderView::ResizeToContents ); + ui->groupswidget->header()->setSectionResizeMode( 1, QHeaderView::Stretch ); + } - reply->deleteLater(); - emit checkReady( true ); + emit checkReady( is_valid_package_data || !m_required ); } void diff --git a/src/modules/netinstall/NetInstallViewStep.cpp b/src/modules/netinstall/NetInstallViewStep.cpp index 4d9bb9b95..1e9466cbe 100644 --- a/src/modules/netinstall/NetInstallViewStep.cpp +++ b/src/modules/netinstall/NetInstallViewStep.cpp @@ -195,66 +195,36 @@ NetInstallViewStep::setConfigurationMap( const QVariantMap& configurationMap ) configurationMap.value( "required" ).type() == QVariant::Bool && configurationMap.value( "required" ).toBool() ); + // Load package groups from the network if ( configurationMap.contains( "groupsUrl" ) && configurationMap.value( "groupsUrl" ).type() == QVariant::String ) { -cDebug() << "NetInstallViewStep::setConfigurationMap() groupsUrl=" << configurationMap.value( "groupsUrl" ).toString(); - - // load package groups from netinstall.conf localStorage - if ( configurationMap.contains( GS::PACKAGE_GROUPS_KEY ) && - configurationMap.value( GS::PACKAGE_GROUPS_KEY ).type() == QVariant::List && - configurationMap.value( "groupsUrl" ).toString() == PACKAGE_GROUPS_FILE ) - { - // convert local storage packages lists to YAML - QVariantList package_groups = configurationMap.value( GS::PACKAGE_GROUPS_KEY ).toList(); - YAML::Emitter package_groups_yaml; - package_groups_yaml.SetOutputCharset(YAML::EscapeNonAscii); - package_groups_yaml << YAML::BeginSeq; - for ( int groups_n = 0; groups_n < package_groups.length(); ++groups_n ) - { - QVariantMap package_group = package_groups.value(groups_n).toMap(); - std::string group_name = package_group["name"].toString().toStdString(); - std::string group_desc = package_group["description"].toString().toStdString(); - std::string group_critical = package_group["critical"].toString().toStdString(); - QStringList group_packages = package_group.value( "packages" ).toStringList(); - std::vector< std::string > packages; - foreach ( const QString& package , group_packages ) - packages.push_back( package.toStdString() ); - -cDebug() << "NetInstallViewStep::setConfigurationMap() package_group[name]=" << QString::fromStdString(group_name); -cDebug() << "NetInstallViewStep::setConfigurationMap() package_group[description]=" << QString::fromStdString(group_desc); -cDebug() << "NetInstallViewStep::setConfigurationMap() package_group[critical]=" << QString::fromStdString(group_critical); -cDebug() << "NetInstallViewStep::setConfigurationMap() package_group[packages]=" << group_packages; - - package_groups_yaml << YAML::BeginMap; - package_groups_yaml << YAML::Key << "name" << YAML::Value << group_name; - package_groups_yaml << YAML::Key << "description" << YAML::Value << group_desc; - package_groups_yaml << YAML::Key << "critical" << YAML::Value << group_critical; - package_groups_yaml << YAML::Key << "packages" << YAML::Value << packages; - package_groups_yaml << YAML::EndMap; - } - package_groups_yaml << YAML::EndSeq; - -// DBG << "NetInstallViewStep::setConfigurationMap() err=" << QString(package_groups_yaml.GetLastError()); - - QFile package_groups_file( QString( PACKAGE_GROUPS_FILE ).remove(0, 7) ); - if (package_groups_file.open( QIODevice::WriteOnly | QIODevice::Text )) - { - QTextStream out( &package_groups_file ); - out << package_groups_yaml.c_str(); // TODO: - } - cDebug() << "wrote package groups from netinstall.conf to" << PACKAGE_GROUPS_FILE; - } - else cDebug() << "no package groups defined in netinstall.conf - trying 'groupsUrl'"; + cDebug() << "Fetching package groups from 'groupsUrl':" << configurationMap.value( "groupsUrl" ).toString(); Calamares::JobQueue::instance()->globalStorage()->insert( "groupsUrl", configurationMap.value( "groupsUrl" ).toString() ); m_widget->loadGroupList(); } + // Load package groups from netinstall.conf + else if ( configurationMap.contains( GS::PACKAGE_GROUPS_KEY ) && + configurationMap.value( GS::PACKAGE_GROUPS_KEY ).type() == QVariant::List ) + { + cDebug() << "Loading package groups from netinstall.conf"; + + QVariantList package_groups = configurationMap.value( GS::PACKAGE_GROUPS_KEY ).toList(); + + m_widget->parseGroupList( package_groups ); + } - m_widget->populateComboboxes( configurationMap ); + // Load InitSystem and WM/DE options from netinstall.conf + if ( configurationMap.contains( GS::INITSYSTEMS_KEY ) && + configurationMap.value( GS::INITSYSTEMS_KEY ).type() == QVariant::Map && + configurationMap.contains( GS::DESKTOPS_KEY ) && + configurationMap.value( GS::DESKTOPS_KEY ).type() == QVariant::Map ) + m_widget->populateComboboxes( configurationMap ); } + void NetInstallViewStep::nextIsReady( bool b ) { |