From 56b9e340086aa9f455341209ba3d89c7a299fb4f Mon Sep 17 00:00:00 2001 From: Stefan Hundhammer Date: Tue, 13 Nov 2018 12:16:16 +0100 Subject: [PATCH 01/10] Don't disable the back button for no good reason --- src/lib/y2packager/clients/inst_productsources.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib/y2packager/clients/inst_productsources.rb b/src/lib/y2packager/clients/inst_productsources.rb index cacf50dd5..ee2524cb8 100644 --- a/src/lib/y2packager/clients/inst_productsources.rb +++ b/src/lib/y2packager/clients/inst_productsources.rb @@ -1288,7 +1288,6 @@ def SourcesDialog # bnc #392111 Wizard.RestoreNextButton Wizard.EnableNextButton - Wizard.DisableBackButton # from add-ons if @script_called_from_another From 92aab284278a2a42e949c942d5d782d4b83efeb8 Mon Sep 17 00:00:00 2001 From: Stefan Hundhammer Date: Tue, 13 Nov 2018 12:21:47 +0100 Subject: [PATCH 02/10] Ask the user first if he would like to use online repos --- .../y2packager/clients/inst_productsources.rb | 71 +++++++++++++++++-- 1 file changed, 64 insertions(+), 7 deletions(-) diff --git a/src/lib/y2packager/clients/inst_productsources.rb b/src/lib/y2packager/clients/inst_productsources.rb index ee2524cb8..df1047ffa 100644 --- a/src/lib/y2packager/clients/inst_productsources.rb +++ b/src/lib/y2packager/clients/inst_productsources.rb @@ -87,6 +87,8 @@ module Yast # # class InstProductsourcesClient < Client + include Yast::Logger + # too low memory for using online repositories (in MiB), # at least 1GiB is recommended LOW_MEMORY_MIB = 1024 @@ -94,22 +96,30 @@ class InstProductsourcesClient < Client # we want new target in releaseversion and not old one ) RELEASEVER_ENV = "ZYPP_REPO_RELEASEVER".freeze + @@posted_low_memory_warning = false + @@ask_activate_online_repos_result = nil + def main textdomain "packager" if AddOnProduct.skip_add_ons - Builtins.y2milestone("Skipping module (as requested before)") + log.info("Skipping module (as requested before)") return :auto end - if GetInstArgs.going_back - Builtins.y2milestone("Going back...") + if GetInstArgs.going_back && Mode.update + log.info("Going back...") ENV.delete(RELEASEVER_ENV) - return :back + end + + if Mode.installation || Mode.update + if !ask_activate_online_repos + return :auto + end end @args = WFM.Args - Builtins.y2milestone("Script args: %1", @args) + log.info("Script args: #{@args}") # similar to commandline mode but actually it's called from another YaST script @script_noncmdline_args = {} @@ -1680,17 +1690,64 @@ def check_memory_size return if !Mode.installation # less than LOW_MEMORY_MIB RAM, the 64MiB buffer is for possible # rounding in hwinfo memory detection (bsc#1045915) - return if Yast2::HwDetection.memory >= ((LOW_MEMORY_MIB - 64) << 20) + return unless low_memory? + + # Warn only once + return if @@posted_low_memory_warning + @@posted_low_memory_warning = true Report.Warning(_("Low memory detected.\n\nUsing online repositories " \ "during initial installation with less than\n" \ - "%dMiB system memory is not recommended.\n\n" \ + "%d MiB system memory is not recommended.\n\n" \ "The installer may crash or freeze if the additional package data\n" \ "need too much memory.\n\n" \ "Using the online repositories later in the installed system is\n" \ "recommended in this case.") % LOW_MEMORY_MIB) end + # Return 'true' if running on a system with low memory, 'false' if not. + # + # @return Boolean + # + def low_memory? + Yast2::HwDetection.memory < ((LOW_MEMORY_MIB - 64) << 20) + end + + # Ask the user if he wishes to activate online repos. + # Return 'true' if the user answered "Yes", 'false' if 'No'. + # + # @return Boolean + # + def ask_activate_online_repos + if GetInstArgs.going_back && @@ask_activate_online_repos_result == false + # If the user previously answered "no" and he is now going back, give + # him a chance to change his mind when he comes here the next time + # going forward again. But for now, since we are going back, prepare to + # skip this step since otherwise it would open the full dialog which he + # has not seen before, so that would be awkward. + @@ask_activate_online_repos_result = nil + return false + end + + # Ask only once + return @@ask_activate_online_repos_result unless @@ask_activate_online_repos_result.nil? + + msg = _("Would you like to activate online repositories?") + + if low_memory? + msg += "\n\n" + msg += _("Since your system has less than %d MiB memory,\n" \ + "there is a significant risk of running out of memory,\n" \ + "and the installer may crash or freeze.\n" \ + "\n" \ + "Using the online repositories later in the installed\n" \ + "system is recommended.") % LOW_MEMORY_MIB + @@posted_low_memory_warning = true + end + + @@ask_activate_online_repos_result = Yast::Popup.YesNo(msg) + end + # fallback when alias is not defined def fallback_alias(url) # create alias in form "-" From 4ad8775ed0fa7a954e9074fb397150273787f946 Mon Sep 17 00:00:00 2001 From: Stefan Hundhammer Date: Wed, 14 Nov 2018 14:59:38 +0100 Subject: [PATCH 03/10] Version bump and change log --- package/yast2-packager.changes | 8 ++++++++ package/yast2-packager.spec | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/package/yast2-packager.changes b/package/yast2-packager.changes index 53f588755..eaefc0d44 100644 --- a/package/yast2-packager.changes +++ b/package/yast2-packager.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Wed Nov 14 13:56:53 UTC 2018 - Stefan Hundhammer + +- Support for adding online repos during installation (bsc#1112937) +- Added pop-up dialog to ask user first if he would like to add + online repos during installation and upgrade (only once) +- 4.1.13 + ------------------------------------------------------------------- Fri Nov 2 15:34:01 UTC 2018 - lslezak@suse.cz diff --git a/package/yast2-packager.spec b/package/yast2-packager.spec index e943a46af..8b2993bd0 100644 --- a/package/yast2-packager.spec +++ b/package/yast2-packager.spec @@ -17,7 +17,7 @@ Name: yast2-packager -Version: 4.1.12 +Version: 4.1.13 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build From 9d7b61fe7598676678be887322b8274070fac964 Mon Sep 17 00:00:00 2001 From: Stefan Hundhammer Date: Wed, 14 Nov 2018 17:27:16 +0100 Subject: [PATCH 04/10] Text change as requested by lnussel --- src/lib/y2packager/clients/inst_productsources.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/y2packager/clients/inst_productsources.rb b/src/lib/y2packager/clients/inst_productsources.rb index df1047ffa..c79ea4686 100644 --- a/src/lib/y2packager/clients/inst_productsources.rb +++ b/src/lib/y2packager/clients/inst_productsources.rb @@ -1732,7 +1732,9 @@ def ask_activate_online_repos # Ask only once return @@ask_activate_online_repos_result unless @@ask_activate_online_repos_result.nil? - msg = _("Would you like to activate online repositories?") + msg = _("Your system has an active network connection.\n" \ + "Additional software is available online.\n" \ + "Would you like to activate online repositories?") if low_memory? msg += "\n\n" From bd623b44b10d67f54cee7e84cb67eeb01bd1a193 Mon Sep 17 00:00:00 2001 From: Stefan Hundhammer Date: Wed, 14 Nov 2018 17:27:27 +0100 Subject: [PATCH 05/10] Skip online repos if no network available (requested by lnussel) --- src/lib/y2packager/clients/inst_productsources.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/y2packager/clients/inst_productsources.rb b/src/lib/y2packager/clients/inst_productsources.rb index c79ea4686..f05eaf02c 100644 --- a/src/lib/y2packager/clients/inst_productsources.rb +++ b/src/lib/y2packager/clients/inst_productsources.rb @@ -113,6 +113,11 @@ def main end if Mode.installation || Mode.update + if !NetworkService.isNetworkRunning + log.info("No network connection - skipping module") + return :auto + end + if !ask_activate_online_repos return :auto end From 983e61799ed0b123d1cb9fb933b864e17a8ae2cd Mon Sep 17 00:00:00 2001 From: Stefan Hundhammer Date: Wed, 14 Nov 2018 18:20:27 +0100 Subject: [PATCH 06/10] Make rubocop shut up --- src/lib/y2packager/clients/inst_productsources.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib/y2packager/clients/inst_productsources.rb b/src/lib/y2packager/clients/inst_productsources.rb index f05eaf02c..2e6e733b2 100644 --- a/src/lib/y2packager/clients/inst_productsources.rb +++ b/src/lib/y2packager/clients/inst_productsources.rb @@ -87,6 +87,7 @@ module Yast # # class InstProductsourcesClient < Client + # rubocop:disable Style/ClassVars include Yast::Logger # too low memory for using online repositories (in MiB), @@ -119,6 +120,7 @@ def main end if !ask_activate_online_repos + log.info("Skipping module") return :auto end end From b622a0c597c8eb344e80eac2f4535e2312734439 Mon Sep 17 00:00:00 2001 From: Stefan Hundhammer Date: Wed, 14 Nov 2018 18:37:59 +0100 Subject: [PATCH 07/10] Adapted unit test to new desired behaviour --- test/lib/clients/inst_productsources_test.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/lib/clients/inst_productsources_test.rb b/test/lib/clients/inst_productsources_test.rb index e050cbfe4..8988811ba 100755 --- a/test/lib/clients/inst_productsources_test.rb +++ b/test/lib/clients/inst_productsources_test.rb @@ -19,12 +19,6 @@ expect(client.main).to eq :auto end - it "returns :back if going back" do - allow(Yast::GetInstArgs).to receive(:going_back).and_return(true) - - expect(client.main).to eq :back - end - context "run as command line" do before do allow(Yast::Mode).to receive(:normal).and_return(true) From 1136ddf30ce72c6c033d4cf2714ea87e4aacfa69 Mon Sep 17 00:00:00 2001 From: Stefan Hundhammer Date: Thu, 15 Nov 2018 11:58:23 +0100 Subject: [PATCH 08/10] Use different default button in low-memory scenario --- src/lib/y2packager/clients/inst_productsources.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/y2packager/clients/inst_productsources.rb b/src/lib/y2packager/clients/inst_productsources.rb index 2e6e733b2..c69ed21cd 100644 --- a/src/lib/y2packager/clients/inst_productsources.rb +++ b/src/lib/y2packager/clients/inst_productsources.rb @@ -1739,6 +1739,7 @@ def ask_activate_online_repos # Ask only once return @@ask_activate_online_repos_result unless @@ask_activate_online_repos_result.nil? + default_button = :focus_yes msg = _("Your system has an active network connection.\n" \ "Additional software is available online.\n" \ "Would you like to activate online repositories?") @@ -1751,10 +1752,16 @@ def ask_activate_online_repos "\n" \ "Using the online repositories later in the installed\n" \ "system is recommended.") % LOW_MEMORY_MIB + default_button = :focus_no @@posted_low_memory_warning = true end - @@ask_activate_online_repos_result = Yast::Popup.YesNo(msg) + @@ask_activate_online_repos_result = Popup.AnyQuestion( + Popup.NoHeadline, + msg, + Label.YesButton, + Label.NoButton, + default_button) end # fallback when alias is not defined From c590f38dd28615f30834f91865a60d6ce51c7f5d Mon Sep 17 00:00:00 2001 From: Stefan Hundhammer Date: Thu, 15 Nov 2018 12:07:27 +0100 Subject: [PATCH 09/10] Made code less readable to satisfy the mindless check bot --- src/lib/y2packager/clients/inst_productsources.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/lib/y2packager/clients/inst_productsources.rb b/src/lib/y2packager/clients/inst_productsources.rb index c69ed21cd..7538656a4 100644 --- a/src/lib/y2packager/clients/inst_productsources.rb +++ b/src/lib/y2packager/clients/inst_productsources.rb @@ -1756,12 +1756,8 @@ def ask_activate_online_repos @@posted_low_memory_warning = true end - @@ask_activate_online_repos_result = Popup.AnyQuestion( - Popup.NoHeadline, - msg, - Label.YesButton, - Label.NoButton, - default_button) + @@ask_activate_online_repos_result = Popup.AnyQuestion(Popup.NoHeadline, + msg, Label.YesButton, Label.NoButton, default_button) end # fallback when alias is not defined From 79d796b08ca41560e04d36c0426c2a36105bcd34 Mon Sep 17 00:00:00 2001 From: Stefan Hundhammer Date: Thu, 15 Nov 2018 13:36:11 +0100 Subject: [PATCH 10/10] Moved comment to relevant check --- src/lib/y2packager/clients/inst_productsources.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/y2packager/clients/inst_productsources.rb b/src/lib/y2packager/clients/inst_productsources.rb index 7538656a4..9de550707 100644 --- a/src/lib/y2packager/clients/inst_productsources.rb +++ b/src/lib/y2packager/clients/inst_productsources.rb @@ -1695,8 +1695,6 @@ def RunMain # with low memory (the installer may crash or freeze, see bnc#854755) def check_memory_size return if !Mode.installation - # less than LOW_MEMORY_MIB RAM, the 64MiB buffer is for possible - # rounding in hwinfo memory detection (bsc#1045915) return unless low_memory? # Warn only once @@ -1717,6 +1715,8 @@ def check_memory_size # @return Boolean # def low_memory? + # less than LOW_MEMORY_MIB RAM, the 64MiB buffer is for possible + # rounding in hwinfo memory detection (bsc#1045915) Yast2::HwDetection.memory < ((LOW_MEMORY_MIB - 64) << 20) end