Add support for non-critical groups in netinstall.

Package groups are divided into critical and non-critical
depending on whether we want all Calamares to fail if installing
a package in the group fails, or we are okay with just logging a
warning.

The distinction is configured in the YAML file listing the package
groups. By default, all groups are critical, to keep supporting
the previous behaviour.
This commit is contained in:
shainer 2016-11-12 17:57:58 +00:00
parent a9d8107b3b
commit 58ae8e13c9
4 changed files with 66 additions and 36 deletions

View file

@ -125,12 +125,31 @@ NetInstallViewStep::onLeave()
cDebug() << "Leaving netinstall, adding packages to be installed"
<< "to global storage";
if ( !m_widget->selectedPackages().empty() )
const QList<Group>& selectedGroups = m_widget->selectedGroups();
if ( !selectedGroups.empty() )
{
QMap<QString, QVariant> packagesWithOperation;
// Gets all packages selected in the page; includes groups that are
// selected by default but not displayed.
packagesWithOperation.insert( "install", m_widget->selectedPackages() );
QStringList packages, critical_packages;
// We have two types of groups: "critical" (failing to install any of
// the packages makes Calamares fail) and "non critical" (we only log
// an error if the installation fails). We distinguish them here and select
// the correct package operation.
for (const Group& group : selectedGroups) {
if (group.critical) {
critical_packages += group.packages;
} else {
packages += group.packages;
}
}
if (!critical_packages.empty()) {
packagesWithOperation.insert( "install", critical_packages );
}
if (!packages.empty()) {
packagesWithOperation.insert( "try_install", packages);
}
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
gs->insert( "packageOperations", QVariant( packagesWithOperation ) );