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:
parent
a9d8107b3b
commit
58ae8e13c9
@ -85,6 +85,9 @@ void NetInstallPage::readGroups( const QByteArray& yamlData )
|
|||||||
if ( groupDefinition["hidden"] )
|
if ( groupDefinition["hidden"] )
|
||||||
m_groups[name].hidden = yamlToVariant( groupDefinition["hidden"] ).toBool();
|
m_groups[name].hidden = yamlToVariant( groupDefinition["hidden"] ).toBool();
|
||||||
|
|
||||||
|
if ( groupDefinition["critical"] )
|
||||||
|
m_groups[name].critical = yamlToVariant( groupDefinition["critical"] ).toBool();
|
||||||
|
|
||||||
m_groupOrder.append( name );
|
m_groupOrder.append( name );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,25 +127,25 @@ NetInstallPage::dataIsHere( QNetworkReply* reply )
|
|||||||
emit checkReady( isReady() );
|
emit checkReady( isReady() );
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList NetInstallPage::selectedPackages() const
|
QList<Group> NetInstallPage::selectedGroups() const
|
||||||
{
|
{
|
||||||
QStringList selectedPackages;
|
QList<Group> selectedGroups;
|
||||||
|
|
||||||
// Add all the packages for groups that are toggled in the view.
|
// Add all the groups that are toggled in the view.
|
||||||
for ( auto it = m_groupWidgets.constBegin(); it != m_groupWidgets.constEnd(); it++ )
|
for ( auto it = m_groupWidgets.constBegin(); it != m_groupWidgets.constEnd(); it++ )
|
||||||
{
|
{
|
||||||
if ( it.value()->isToggled() )
|
if ( it.value()->isToggled() )
|
||||||
selectedPackages += m_groups[it.key()].packages;
|
selectedGroups += m_groups[it.key()];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add all the packages for groups that are hidden but selected.
|
// Add all groups that are hidden but selected.
|
||||||
for ( const Group& group : m_groups.values() )
|
for ( const Group& group : m_groups.values() )
|
||||||
{
|
{
|
||||||
if ( group.hidden && group.selected )
|
if ( group.hidden && group.selected )
|
||||||
selectedPackages += group.packages;
|
selectedGroups += group;
|
||||||
}
|
}
|
||||||
|
|
||||||
return selectedPackages;
|
return selectedGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetInstallPage::loadGroupList()
|
void NetInstallPage::loadGroupList()
|
||||||
|
@ -34,29 +34,30 @@ namespace Ui
|
|||||||
class Page_NetInst;
|
class Page_NetInst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Representation of a package group.
|
||||||
|
struct Group
|
||||||
|
{
|
||||||
|
Group()
|
||||||
|
: Group( "","",false, false, true ) { }
|
||||||
|
Group( QString name, QString description, bool selected, bool hidden, bool critical )
|
||||||
|
: name( name ), description( description ), selected( selected ), hidden( hidden ), critical( critical ) { }
|
||||||
|
Group( QString name, QString description )
|
||||||
|
: Group( name, description, false, false, true ) { }
|
||||||
|
|
||||||
|
QString name;
|
||||||
|
QString description;
|
||||||
|
QStringList packages;
|
||||||
|
|
||||||
|
// See README.md for a description of these fields.
|
||||||
|
bool selected = false;
|
||||||
|
bool hidden = false;
|
||||||
|
bool critical = true;
|
||||||
|
};
|
||||||
|
|
||||||
class NetInstallPage : public QWidget
|
class NetInstallPage : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
// Internal representation of a package group.
|
|
||||||
struct Group
|
|
||||||
{
|
|
||||||
Group()
|
|
||||||
: Group( "","",false, false ) { }
|
|
||||||
Group( QString name, QString description, bool selected, bool hidden )
|
|
||||||
: name( name ), description( description ), selected( selected ), hidden( hidden ) { }
|
|
||||||
Group( QString name, QString description )
|
|
||||||
: Group( name, description, false, false ) { }
|
|
||||||
|
|
||||||
QString name;
|
|
||||||
QString description;
|
|
||||||
QStringList packages;
|
|
||||||
|
|
||||||
// See README.md for a description of these two fields.
|
|
||||||
bool selected = false;
|
|
||||||
bool hidden = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NetInstallPage( QWidget* parent = nullptr );
|
NetInstallPage( QWidget* parent = nullptr );
|
||||||
|
|
||||||
@ -69,10 +70,9 @@ public:
|
|||||||
// in the global storage. This should be called before displaying the page.
|
// in the global storage. This should be called before displaying the page.
|
||||||
void loadGroupList();
|
void loadGroupList();
|
||||||
|
|
||||||
// Returns the list of packages belonging to groups that are
|
// Return a list of groups currently selected. No data is cached here, so
|
||||||
// selected in the view in this given moment. No data is cached here, so
|
// this function does not run in constant time.
|
||||||
// this function does not have constant time.
|
QList<Group> selectedGroups() const;
|
||||||
QStringList selectedPackages() const;
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void dataIsHere( QNetworkReply* );
|
void dataIsHere( QNetworkReply* );
|
||||||
|
@ -125,12 +125,31 @@ NetInstallViewStep::onLeave()
|
|||||||
cDebug() << "Leaving netinstall, adding packages to be installed"
|
cDebug() << "Leaving netinstall, adding packages to be installed"
|
||||||
<< "to global storage";
|
<< "to global storage";
|
||||||
|
|
||||||
if ( !m_widget->selectedPackages().empty() )
|
const QList<Group>& selectedGroups = m_widget->selectedGroups();
|
||||||
|
|
||||||
|
if ( !selectedGroups.empty() )
|
||||||
{
|
{
|
||||||
QMap<QString, QVariant> packagesWithOperation;
|
QMap<QString, QVariant> packagesWithOperation;
|
||||||
// Gets all packages selected in the page; includes groups that are
|
QStringList packages, critical_packages;
|
||||||
// selected by default but not displayed.
|
|
||||||
packagesWithOperation.insert( "install", m_widget->selectedPackages() );
|
// 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();
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||||
gs->insert( "packageOperations", QVariant( packagesWithOperation ) );
|
gs->insert( "packageOperations", QVariant( packagesWithOperation ) );
|
||||||
|
@ -27,8 +27,16 @@ The URL must point to a YAML file. Here is a short example of how the YAML file
|
|||||||
|
|
||||||
The file is composed of a list of entry, each describing one group. The keys *name*, *description* and *packages* are required.
|
The file is composed of a list of entry, each describing one group. The keys *name*, *description* and *packages* are required.
|
||||||
|
|
||||||
Two more keys are supported, *hidden* (if true, do not show the group on the page) and *selected* (if true, display the group as selected). Both default to false if not present.
|
Three more keys are supported:
|
||||||
If both keys are set to true for the same group, you are basically creating a "default" group of packages which will always be installed in the user's system.
|
|
||||||
|
- hidden: if true, do not show the group on the page. Defaults to false.
|
||||||
|
- selected: if true, display the group as selected. Defaults to false.
|
||||||
|
- critical: if true, make the installation process fail if installing
|
||||||
|
any of the packages in the group fails. Otherwise, just log a warning.
|
||||||
|
Defaults to true.
|
||||||
|
|
||||||
|
If you set both *hidden* and *selected* for a group, you are basically creating a "default" group of packages
|
||||||
|
which will always be installed in the user's system.
|
||||||
|
|
||||||
## Configuration of the module
|
## Configuration of the module
|
||||||
Here is the set of instructions to have the module work in your Calamares. As of July 2016, this has been successfully
|
Here is the set of instructions to have the module work in your Calamares. As of July 2016, this has been successfully
|
||||||
|
Loading…
Reference in New Issue
Block a user