From 58ae8e13c9f49ea1caf691b7957796b7e56d190e Mon Sep 17 00:00:00 2001 From: shainer Date: Sat, 12 Nov 2016 17:57:58 +0000 Subject: [PATCH 1/5] 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. --- src/modules/netinstall/NetInstallPage.cpp | 17 ++++--- src/modules/netinstall/NetInstallPage.h | 46 +++++++++---------- src/modules/netinstall/NetInstallViewStep.cpp | 27 +++++++++-- src/modules/netinstall/README.md | 12 ++++- 4 files changed, 66 insertions(+), 36 deletions(-) diff --git a/src/modules/netinstall/NetInstallPage.cpp b/src/modules/netinstall/NetInstallPage.cpp index 89f8e58dd..5c02d0b1b 100644 --- a/src/modules/netinstall/NetInstallPage.cpp +++ b/src/modules/netinstall/NetInstallPage.cpp @@ -85,6 +85,9 @@ void NetInstallPage::readGroups( const QByteArray& yamlData ) if ( groupDefinition["hidden"] ) m_groups[name].hidden = yamlToVariant( groupDefinition["hidden"] ).toBool(); + if ( groupDefinition["critical"] ) + m_groups[name].critical = yamlToVariant( groupDefinition["critical"] ).toBool(); + m_groupOrder.append( name ); } } @@ -124,25 +127,25 @@ NetInstallPage::dataIsHere( QNetworkReply* reply ) emit checkReady( isReady() ); } -QStringList NetInstallPage::selectedPackages() const +QList NetInstallPage::selectedGroups() const { - QStringList selectedPackages; + QList 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++ ) { 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() ) { if ( group.hidden && group.selected ) - selectedPackages += group.packages; + selectedGroups += group; } - return selectedPackages; + return selectedGroups; } void NetInstallPage::loadGroupList() diff --git a/src/modules/netinstall/NetInstallPage.h b/src/modules/netinstall/NetInstallPage.h index 5145fdb23..a79c116b5 100644 --- a/src/modules/netinstall/NetInstallPage.h +++ b/src/modules/netinstall/NetInstallPage.h @@ -34,29 +34,30 @@ namespace Ui 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 { 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: NetInstallPage( QWidget* parent = nullptr ); @@ -69,10 +70,9 @@ public: // in the global storage. This should be called before displaying the page. void loadGroupList(); - // Returns the list of packages belonging to groups that are - // selected in the view in this given moment. No data is cached here, so - // this function does not have constant time. - QStringList selectedPackages() const; + // Return a list of groups currently selected. No data is cached here, so + // this function does not run in constant time. + QList selectedGroups() const; public slots: void dataIsHere( QNetworkReply* ); diff --git a/src/modules/netinstall/NetInstallViewStep.cpp b/src/modules/netinstall/NetInstallViewStep.cpp index 333debd9b..3313996b2 100644 --- a/src/modules/netinstall/NetInstallViewStep.cpp +++ b/src/modules/netinstall/NetInstallViewStep.cpp @@ -125,12 +125,31 @@ NetInstallViewStep::onLeave() cDebug() << "Leaving netinstall, adding packages to be installed" << "to global storage"; - if ( !m_widget->selectedPackages().empty() ) + const QList& selectedGroups = m_widget->selectedGroups(); + + if ( !selectedGroups.empty() ) { QMap 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 ) ); diff --git a/src/modules/netinstall/README.md b/src/modules/netinstall/README.md index 790691e1b..85eb3d67b 100644 --- a/src/modules/netinstall/README.md +++ b/src/modules/netinstall/README.md @@ -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. -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. -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. +Three more keys are supported: + + - 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 Here is the set of instructions to have the module work in your Calamares. As of July 2016, this has been successfully From 5fadd0a3ce2137ee1d8f449e9d464ec381c2644a Mon Sep 17 00:00:00 2001 From: shainer Date: Sat, 12 Nov 2016 18:08:08 +0000 Subject: [PATCH 2/5] New example netinstall.yaml with non-critical group. --- src/modules/netinstall/netinstall.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/netinstall/netinstall.yaml b/src/modules/netinstall/netinstall.yaml index e37188312..392f04511 100644 --- a/src/modules/netinstall/netinstall.yaml +++ b/src/modules/netinstall/netinstall.yaml @@ -165,6 +165,7 @@ - kapudan - name: "Wireless" description: "Tools for wireless connections" + critical: false packages: - crda - ndiswrapper From b6d607521316c5e6ec34a051daaa2ec11cdd97cc Mon Sep 17 00:00:00 2001 From: shainer Date: Sun, 13 Nov 2016 10:56:13 +0000 Subject: [PATCH 3/5] New example netinstall.yaml, less groups for easier testing. --- src/modules/netinstall/netinstall.yaml | 46 +------------------------- 1 file changed, 1 insertion(+), 45 deletions(-) diff --git a/src/modules/netinstall/netinstall.yaml b/src/modules/netinstall/netinstall.yaml index 392f04511..8e9037f4d 100644 --- a/src/modules/netinstall/netinstall.yaml +++ b/src/modules/netinstall/netinstall.yaml @@ -2,6 +2,7 @@ description: "Default group" hidden: true selected: true + critical: false packages: - base - chakra-live-skel @@ -199,49 +200,4 @@ - kdegraphics-svgpart - kdegraphics-thumbnailers - imagemagick -- name: "Burning" - description: "Set of packages for disc burning" - packages: - - dvd+rw-tools - - vcdimager - - transcode - - emovix - - k3b - - libdvdcss -- name: "Printing" - description: "Print much?" - packages: - - cups - - gutenprint - - cups-pdf - - kdeadmin-print-manager - - hplip - - epsoneplijs - - epson-inkjet-printer-escpr - - python2-gobject2 - - samba -- name: "Multimedia" - description: "Music and video players" - packages: - - kdemultimedia-dragonplayer - - kdenlive - - amarok -- name: "Miscellaneous" - description: "Useful tools and apps" - packages: - - imagewriter - - tomoyo-tools - - python2-gobject ## needed for systemd-analyze - - clamav - - kdenetwork-kget ## maybe move to a network group? - - kdeplasma-addons-applets-lancelot - - kdeplasma-applets-homerun - - kdeplasma-applets-appmenu-qml - - kdeplasma-addons-runners-characters - - kdeplasma-addons-runners-converter - - kdeplasma-addons-runners-datetime - - kdeplasma-addons-runners-dictionary ##4.10 option - - kdeplasma-addons-runners-spellchecker - - appmenu-qt ## needed for menubar options in 4.10 - - kscreen From 5dd667660221ff11275367d4c7d08a3ef75210f1 Mon Sep 17 00:00:00 2001 From: Kevin Kofler Date: Sun, 13 Nov 2016 03:56:55 +0100 Subject: [PATCH 4/5] Bump version to 2.4.80. We need master to have a higher version than the stable branch. I used 2.4.80 so that it can be bumped again to 2.4.90 when starting to do alpha/beta/RC releases. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 92ca01266..c902768c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,7 +102,7 @@ set( CALAMARES_TRANSLATION_LANGUAGES ar ast bg ca cs_CZ da de el en en_GB es_MX ### Bump version here set( CALAMARES_VERSION_MAJOR 2 ) set( CALAMARES_VERSION_MINOR 4 ) -set( CALAMARES_VERSION_PATCH 1 ) +set( CALAMARES_VERSION_PATCH 80 ) set( CALAMARES_VERSION_RC 0 ) set( CALAMARES_VERSION ${CALAMARES_VERSION_MAJOR}.${CALAMARES_VERSION_MINOR}.${CALAMARES_VERSION_PATCH} ) From e5f5bb99d78f375912b144f976a42da9c2539053 Mon Sep 17 00:00:00 2001 From: shainer Date: Sun, 13 Nov 2016 12:12:07 +0000 Subject: [PATCH 5/5] Change the default value of critical to false. This means all package groups are non-critical by default. Update documentation accordingly. --- src/modules/netinstall/NetInstallPage.h | 6 +++--- src/modules/netinstall/README.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/netinstall/NetInstallPage.h b/src/modules/netinstall/NetInstallPage.h index a79c116b5..7460c9c11 100644 --- a/src/modules/netinstall/NetInstallPage.h +++ b/src/modules/netinstall/NetInstallPage.h @@ -38,11 +38,11 @@ class Page_NetInst; struct Group { Group() - : Group( "","",false, false, true ) { } + : Group( "","",false, false, false ) { } 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 ) { } + : Group( name, description, false, false, false ) { } QString name; QString description; @@ -51,7 +51,7 @@ struct Group // See README.md for a description of these fields. bool selected = false; bool hidden = false; - bool critical = true; + bool critical = false; }; class NetInstallPage : public QWidget diff --git a/src/modules/netinstall/README.md b/src/modules/netinstall/README.md index 85eb3d67b..931ef37ff 100644 --- a/src/modules/netinstall/README.md +++ b/src/modules/netinstall/README.md @@ -33,7 +33,7 @@ Three more keys are supported: - 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. + Defaults to false. 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.