From 2dcf6ba0c4a81395b1926b25c1309e8b0eb276b9 Mon Sep 17 00:00:00 2001 From: Stefan Schubert Date: Thu, 28 Sep 2017 16:30:04 +0200 Subject: [PATCH 01/11] disabling vnc, shh,.... if it is not supported --- src/clients/inst_kickoff.rb | 3 + src/lib/packager/clients/software_proposal.rb | 12 ++ src/modules/Packages.rb | 116 +++++++++++-- test/packages_test.rb | 153 ++++++++++++++++++ 4 files changed, 271 insertions(+), 13 deletions(-) diff --git a/src/clients/inst_kickoff.rb b/src/clients/inst_kickoff.rb index a50a0c5a0..813f95160 100644 --- a/src/clients/inst_kickoff.rb +++ b/src/clients/inst_kickoff.rb @@ -27,6 +27,9 @@ def main Mtab.clone_to_target end + # Disabling VPN, SSH,.... if the packages are not available + Linuxrc.disable_remote(Packages.missing_remote_kind) + # Feature #301903, bugzilla #244937 if Mode.update # "/" means updating the running system, bugzilla #246389 diff --git a/src/lib/packager/clients/software_proposal.rb b/src/lib/packager/clients/software_proposal.rb index d1ae145ac..e4b817c1f 100644 --- a/src/lib/packager/clients/software_proposal.rb +++ b/src/lib/packager/clients/software_proposal.rb @@ -81,6 +81,18 @@ def make_proposal(flags) "warning_level" => :blocker ) end + remote_installation_error = Packages.check_remote_installation_packages + unless remote_installation_error.empty? + # The Default warning_level is "error". So the user can continue + # installation. + if @ret["warning"] + @ret["warning"] << "\n" + @ret["warning"] << remote_installation_error + else + @ret["warning"] = remote_installation_error + end + end + @ret end diff --git a/src/modules/Packages.rb b/src/modules/Packages.rb index 3e931e876..1a790e783 100644 --- a/src/modules/Packages.rb +++ b/src/modules/Packages.rb @@ -12,6 +12,8 @@ class PackagesClass < Module include Yast::Logger include ERB::Util + attr_reader :missing_remote_packages, :missing_remote_kind + # All known types of resolvables RESOLVABLE_TYPES = [:product, :patch, :package, :pattern, :language].freeze @@ -151,6 +153,13 @@ def main @base_source_id = nil @old_packages_proposal = nil + + # Remote kinds (vnc, ssh,...) which cannot be used in an + # installed system. + @missing_remote_kind = [] + # Packages which are missed to enable remote handling in + # an installed system. + @missing_remote_packages = [] end # summary functions @@ -927,23 +936,66 @@ def architecturePackages deep_copy(packages) end - # Compute special packages - # @return [Array](string) - def modePackages - tags = [] - tags << "sbl" if Linuxrc.braille - # ssh installation + # Checking if all needed packages for remote installation + # will be installed on the target system. + # @return [String] empty string or error message if there are missing packages + def check_remote_installation_packages + @missing_remote_kind = [] + @missing_remote_packages = [] + + if Linuxrc.braille + missing = braille_packages.reject { |tag| pkg_will_be_installed(tag) } + unless missing.empty? + @missing_remote_packages << missing + @missing_remote_kind << "braille" + end + end if Linuxrc.usessh - # "ip" tool is needed by the YaST2.ssh start script (bnc#920175) - tags.concat(["openssh", "iproute2"]) + missing = ssh_packages.reject { |tag| pkg_will_be_installed(tag) } + unless missing.empty? + @missing_remote_packages << missing + @missing_remote_kind << "ssh" + end + end + if Linuxrc.vnc + missing = vnc_packages.reject { |tag| pkg_will_be_installed(tag) } + unless missing.empty? + @missing_remote_packages << missing + @missing_remote_kind << "vnc" + end + end + if Linuxrc.display_ip + missing = remote_x11_packages.reject { |tag| pkg_will_be_installed(tag) } + unless missing.empty? + @missing_remote_packages << missing + @missing_remote_kind << "display-ip" + end end - packages = find_providers(tags) - packages.concat(vnc_packages) if Linuxrc.vnc - # this means we have a remote X server - packages.concat(remote_x11_packages) if Linuxrc.display_ip + missing_remote_packages.flatten! + unless missing_remote_packages.empty? + error_string = _("Cannot support %s due missing packages %s. It will be disabled." % + [@missing_remote_kind.join(", "), @missing_remote_packages.join(", ")]) + if Mode.auto + error_string << " \n" + error_string << _("But the AutoYaST installation will be finished offline.") + end + log.warn error_string + return error_string + end + return "" + end - Builtins.y2milestone("Installation mode packages: %1", packages) + # Compute special packages + # @return [Array](string) + def modePackages + packages = [] + packages << braille_packages if Linuxrc.braille + packages << ssh_packages if Linuxrc.usessh + packages << vnc_packages if Linuxrc.vnc + packages << remote_x11_packages if Linuxrc.display_ip + packages.flatten! + log.info("Installation mode packages: #{packages}") packages end @@ -2373,6 +2425,25 @@ def log_software_selection nil end + # List of packages expected to be installed in order to enable + # ssh. + # + # @return [Array] package list + def ssh_packages + # "ip" tool is needed by the YaST2.ssh start script (bnc#920175) + tags = ["openssh", "iproute2"] + find_providers(tags) + end + + # List of packages expected to be installed in order to enable + # braille + # + # @return [Array] package list + def braille_packages + tags = ["sbl"] + find_providers(tags) + end + # List of packages expected to be installed in order to enable # remote administration (VNC) # @@ -2688,6 +2759,25 @@ def create_baseproduct_symlink log.info("Creating #{BASE_PRODUCT_FILE} symlink pointing to #{product_file}") ::FileUtils.ln_s(product_file, BASE_PRODUCT_FILE) end + + # Checking if a package will be installed or is already installed + # on a system and will not be deleted. + # @param [String] package name + # @return [Boolean] true if the package will be on the installed system + def pkg_will_be_installed(tag) + provides = Pkg.PkgQueryProvides(tag) + # e.g.: [["kernel-bigsmp", :CAND, :NONE], ["kernel-default", :CAND, :CAND], + # ["kernel-default", `BOTH, :INST]] + log.info("provides: #{provides}") + if provides.any? { |p| p[2] != :NONE } + log.info("#{tag} will be installed") + return true + else + log.info("#{tag} will not be installed") + return false + end + end + end Packages = PackagesClass.new diff --git a/test/packages_test.rb b/test/packages_test.rb index 497ba3474..9ffc028ae 100755 --- a/test/packages_test.rb +++ b/test/packages_test.rb @@ -914,6 +914,159 @@ def product(properties = {}) end end + describe "#check_remote_installation_packages" do + before do + allow(Yast::Linuxrc).to receive(:vnc).and_return vnc + allow(Yast::Linuxrc).to receive(:display_ip).and_return display_ip + allow(Yast::Linuxrc).to receive(:braille).and_return braille + allow(Yast::Linuxrc).to receive(:usessh).and_return usessh + allow(Yast::Packages).to receive(:vnc_packages).and_return(vnc_packages) + allow(Yast::Packages).to receive(:remote_x11_packages).and_return(remote_x11_packages) + allow(Yast::Packages).to receive(:ssh_packages).and_return(ssh_packages) + allow(Yast::Packages).to receive(:braille_packages).and_return(braille_packages) + end + + let(:vnc_packages) { %w(some-vnc-packages) } + let(:remote_x11_packages) { %w(some-x11-packages) } + let(:ssh_packages) { %w(openssh iproute2) } + let(:braille_packages) { %w(sbl) } + + context "on a boring local regular installation" do + let(:vnc) { false } + let(:display_ip) { false } + let(:braille) { false } + let(:usessh) { false } + + it "reports no error" do + expect(Yast::Packages.check_remote_installation_packages).to be_empty + expect(Yast::Packages.missing_remote_packages).to be_empty + expect(Yast::Packages.missing_remote_kind).to be_empty + end + end + + context "on a installation with braille enabled" do + let(:vnc) { false } + let(:display_ip) { false } + let(:braille) { true } + let(:usessh) { false } + + context "needed packages are available" do + before do + braille_packages.each do |pkg| + allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return([[pkg, :CAND, :CAND]]) + end + end + + it "reports no error" do + expect(Yast::Packages.check_remote_installation_packages).to be_empty + expect(Yast::Packages.missing_remote_packages).to be_empty + expect(Yast::Packages.missing_remote_kind).to be_empty + end + end + + context "needed packages are not available" do + before do + braille_packages.each do |pkg| + allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return([[pkg, :CAND, :NONE]]) + end + end + + it "reports error" do + expect(Yast::Packages.check_remote_installation_packages).to_not be_empty + expect(Yast::Packages.missing_remote_packages).to eq(braille_packages) + expect(Yast::Packages.missing_remote_kind).to eq(["braille"]) + end + end + end + + context "over ssh with a remote X server" do + let(:vnc) { false } + let(:display_ip) { true } + let(:braille) { false } + let(:usessh) { true } + + context "needed packages are available" do + before do + (remote_x11_packages + ssh_packages).each do |pkg| + allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return([[pkg, :CAND, :CAND]]) + end + end + + it "reports no error" do + expect(Yast::Packages.check_remote_installation_packages).to be_empty + expect(Yast::Packages.missing_remote_packages).to be_empty + expect(Yast::Packages.missing_remote_kind).to be_empty + end + end + + context "only ssh packages are available" do + before do + ssh_packages.each do |pkg| + allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return([[pkg, :CAND, :NONE]]) + end + remote_x11_packages.each do |pkg| + allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return([[pkg, :CAND, :CAND]]) + end + end + + it "reports error for X11 packages" do + expect(Yast::Packages.check_remote_installation_packages).to_not be_empty + expect(Yast::Packages.missing_remote_packages).to eq(ssh_packages) + expect(Yast::Packages.missing_remote_kind).to eq(["ssh"]) + end + end + + context "no package is available" do + before do + (remote_x11_packages + ssh_packages).each do |pkg| + allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return([[pkg, :CAND, :NONE]]) + end + end + + it "reports error for X11 packages" do + expect(Yast::Packages.check_remote_installation_packages).to_not be_empty + expect(Yast::Packages.missing_remote_packages.sort).to eq((ssh_packages+remote_x11_packages).sort) + expect(Yast::Packages.missing_remote_kind).to eq(["ssh", "display-ip"]) + end + end + end + + context "on vnc installation" do + let(:vnc) { true } + let(:display_ip) { false } + let(:braille) { false } + let(:usessh) { false } + + context "needed packages are available" do + before do + vnc_packages.each do |pkg| + allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return([[pkg, :CAND, :CAND]]) + end + end + + it "reports no error" do + expect(Yast::Packages.check_remote_installation_packages).to be_empty + expect(Yast::Packages.missing_remote_packages).to be_empty + expect(Yast::Packages.missing_remote_kind).to be_empty + end + end + + context "needed packages are not available" do + before do + vnc_packages.each do |pkg| + allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return([[pkg, :CAND, :NONE]]) + end + end + + it "reports error" do + expect(Yast::Packages.check_remote_installation_packages).to_not be_empty + expect(Yast::Packages.missing_remote_packages).to eq(vnc_packages) + expect(Yast::Packages.missing_remote_kind).to eq(["vnc"]) + end + end + end + end + describe "#Reset" do # Reset all package changes done by YaST then re-select only the products # which previously were selected. (see bsc#963036). From 957f2c3549fc62ba1483d22e17dff07135607719 Mon Sep 17 00:00:00 2001 From: Stefan Schubert Date: Thu, 28 Sep 2017 16:34:50 +0200 Subject: [PATCH 02/11] disabling vnc, shh,.... if it is not supported --- package/yast2-packager.changes | 7 +++++++ package/yast2-packager.spec | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/package/yast2-packager.changes b/package/yast2-packager.changes index 7b066a808..e8ad2b02b 100644 --- a/package/yast2-packager.changes +++ b/package/yast2-packager.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Thu Sep 28 16:32:30 CEST 2017 - schubi@suse.de + +- Disable vpn, ssh,... and inform the user if the needed packages + are not available. (bnc#1055279, bnc#1058071) +- 4.0.9 + ------------------------------------------------------------------- Mon Sep 25 14:10:51 UTC 2017 - igonzalezsosa@suse.com diff --git a/package/yast2-packager.spec b/package/yast2-packager.spec index b69b681f4..5a1db2f72 100644 --- a/package/yast2-packager.spec +++ b/package/yast2-packager.spec @@ -17,7 +17,7 @@ Name: yast2-packager -Version: 4.0.8 +Version: 4.0.9 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build From 6871cf3b339ee627bef3dde0d06d836b284ec1f4 Mon Sep 17 00:00:00 2001 From: Stefan Schubert Date: Wed, 4 Oct 2017 17:05:01 +0200 Subject: [PATCH 03/11] rubocop --- src/modules/Packages.rb | 7 +++---- test/packages_test.rb | 29 +++++++++++++++++++---------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/modules/Packages.rb b/src/modules/Packages.rb index 1a790e783..ff0a2a4a5 100644 --- a/src/modules/Packages.rb +++ b/src/modules/Packages.rb @@ -974,8 +974,8 @@ def check_remote_installation_packages missing_remote_packages.flatten! unless missing_remote_packages.empty? - error_string = _("Cannot support %s due missing packages %s. It will be disabled." % - [@missing_remote_kind.join(", "), @missing_remote_packages.join(", ")]) + error_string = _("Cannot support %s due missing packages %s. It will be disabled.") % + [@missing_remote_kind.join(", "), @missing_remote_packages.join(", ")] if Mode.auto error_string << " \n" error_string << _("But the AutoYaST installation will be finished offline.") @@ -983,7 +983,7 @@ def check_remote_installation_packages log.warn error_string return error_string end - return "" + "" end # Compute special packages @@ -2777,7 +2777,6 @@ def pkg_will_be_installed(tag) return false end end - end Packages = PackagesClass.new diff --git a/test/packages_test.rb b/test/packages_test.rb index 9ffc028ae..52dd1bcc3 100755 --- a/test/packages_test.rb +++ b/test/packages_test.rb @@ -953,7 +953,8 @@ def product(properties = {}) context "needed packages are available" do before do braille_packages.each do |pkg| - allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return([[pkg, :CAND, :CAND]]) + allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return( + [[pkg, :CAND, :CAND]]) end end @@ -967,7 +968,8 @@ def product(properties = {}) context "needed packages are not available" do before do braille_packages.each do |pkg| - allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return([[pkg, :CAND, :NONE]]) + allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return( + [[pkg, :CAND, :NONE]]) end end @@ -988,7 +990,8 @@ def product(properties = {}) context "needed packages are available" do before do (remote_x11_packages + ssh_packages).each do |pkg| - allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return([[pkg, :CAND, :CAND]]) + allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return( + [[pkg, :CAND, :CAND]]) end end @@ -1002,10 +1005,12 @@ def product(properties = {}) context "only ssh packages are available" do before do ssh_packages.each do |pkg| - allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return([[pkg, :CAND, :NONE]]) + allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return( + [[pkg, :CAND, :NONE]]) end remote_x11_packages.each do |pkg| - allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return([[pkg, :CAND, :CAND]]) + allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return( + [[pkg, :CAND, :CAND]]) end end @@ -1019,13 +1024,15 @@ def product(properties = {}) context "no package is available" do before do (remote_x11_packages + ssh_packages).each do |pkg| - allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return([[pkg, :CAND, :NONE]]) + allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return( + [[pkg, :CAND, :NONE]]) end end - it "reports error for X11 packages" do + it "reports error for X11 and ssh packages" do expect(Yast::Packages.check_remote_installation_packages).to_not be_empty - expect(Yast::Packages.missing_remote_packages.sort).to eq((ssh_packages+remote_x11_packages).sort) + expect(Yast::Packages.missing_remote_packages.sort).to eq( + (ssh_packages + remote_x11_packages).sort) expect(Yast::Packages.missing_remote_kind).to eq(["ssh", "display-ip"]) end end @@ -1040,7 +1047,8 @@ def product(properties = {}) context "needed packages are available" do before do vnc_packages.each do |pkg| - allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return([[pkg, :CAND, :CAND]]) + allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return( + [[pkg, :CAND, :CAND]]) end end @@ -1054,7 +1062,8 @@ def product(properties = {}) context "needed packages are not available" do before do vnc_packages.each do |pkg| - allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return([[pkg, :CAND, :NONE]]) + allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return( + [[pkg, :CAND, :NONE]]) end end From 568b56c586929b6ade6ffb59a8f29ce33b72e18f Mon Sep 17 00:00:00 2001 From: Stefan Schubert Date: Wed, 4 Oct 2017 17:25:25 +0200 Subject: [PATCH 04/11] rubocop --- src/modules/Packages.rb | 4 ++-- test/packages_test.rb | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/modules/Packages.rb b/src/modules/Packages.rb index ff0a2a4a5..ced4c7e07 100644 --- a/src/modules/Packages.rb +++ b/src/modules/Packages.rb @@ -974,8 +974,8 @@ def check_remote_installation_packages missing_remote_packages.flatten! unless missing_remote_packages.empty? - error_string = _("Cannot support %s due missing packages %s. It will be disabled.") % - [@missing_remote_kind.join(", "), @missing_remote_packages.join(", ")] + error_string = (_("Cannot support %s due missing packages %s. It will be disabled.") % + [@missing_remote_kind.join(", "), @missing_remote_packages.join(", ")]) if Mode.auto error_string << " \n" error_string << _("But the AutoYaST installation will be finished offline.") diff --git a/test/packages_test.rb b/test/packages_test.rb index 52dd1bcc3..ce260922f 100755 --- a/test/packages_test.rb +++ b/test/packages_test.rb @@ -968,8 +968,8 @@ def product(properties = {}) context "needed packages are not available" do before do braille_packages.each do |pkg| - allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return( - [[pkg, :CAND, :NONE]]) + allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg) + .and_return([[pkg, :CAND, :NONE]]) end end @@ -1005,8 +1005,8 @@ def product(properties = {}) context "only ssh packages are available" do before do ssh_packages.each do |pkg| - allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return( - [[pkg, :CAND, :NONE]]) + allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg) + .and_return([[pkg, :CAND, :NONE]]) end remote_x11_packages.each do |pkg| allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return( @@ -1024,15 +1024,15 @@ def product(properties = {}) context "no package is available" do before do (remote_x11_packages + ssh_packages).each do |pkg| - allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return( - [[pkg, :CAND, :NONE]]) + allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg) + .and_return([[pkg, :CAND, :NONE]]) end end it "reports error for X11 and ssh packages" do expect(Yast::Packages.check_remote_installation_packages).to_not be_empty - expect(Yast::Packages.missing_remote_packages.sort).to eq( - (ssh_packages + remote_x11_packages).sort) + expect(Yast::Packages.missing_remote_packages.sort) + .to eq((ssh_packages + remote_x11_packages).sort) expect(Yast::Packages.missing_remote_kind).to eq(["ssh", "display-ip"]) end end @@ -1062,8 +1062,8 @@ def product(properties = {}) context "needed packages are not available" do before do vnc_packages.each do |pkg| - allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return( - [[pkg, :CAND, :NONE]]) + allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg) + .and_return([[pkg, :CAND, :NONE]]) end end From 5cce7e12b8a9dea5e9986553b3eb41463a48e94a Mon Sep 17 00:00:00 2001 From: Stefan Schubert Date: Wed, 4 Oct 2017 17:32:32 +0200 Subject: [PATCH 05/11] rubocop --- test/packages_test.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/packages_test.rb b/test/packages_test.rb index ce260922f..3180f5939 100755 --- a/test/packages_test.rb +++ b/test/packages_test.rb @@ -953,8 +953,8 @@ def product(properties = {}) context "needed packages are available" do before do braille_packages.each do |pkg| - allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return( - [[pkg, :CAND, :CAND]]) + allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg) + .and_return([[pkg, :CAND, :CAND]]) end end @@ -990,8 +990,8 @@ def product(properties = {}) context "needed packages are available" do before do (remote_x11_packages + ssh_packages).each do |pkg| - allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return( - [[pkg, :CAND, :CAND]]) + allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg) + .and_return([[pkg, :CAND, :CAND]]) end end @@ -1009,8 +1009,8 @@ def product(properties = {}) .and_return([[pkg, :CAND, :NONE]]) end remote_x11_packages.each do |pkg| - allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return( - [[pkg, :CAND, :CAND]]) + allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg) + .and_return([[pkg, :CAND, :CAND]]) end end @@ -1047,8 +1047,8 @@ def product(properties = {}) context "needed packages are available" do before do vnc_packages.each do |pkg| - allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg).and_return( - [[pkg, :CAND, :CAND]]) + allow(Yast::Pkg).to receive(:PkgQueryProvides).with(pkg) + .and_return([[pkg, :CAND, :CAND]]) end end From 17a94339f76ed8f1c9f32d5eb1a1877177c6ad80 Mon Sep 17 00:00:00 2001 From: Stefan Schubert Date: Wed, 4 Oct 2017 17:36:50 +0200 Subject: [PATCH 06/11] rubocop --- src/modules/Packages.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/Packages.rb b/src/modules/Packages.rb index ced4c7e07..32b755885 100644 --- a/src/modules/Packages.rb +++ b/src/modules/Packages.rb @@ -974,8 +974,8 @@ def check_remote_installation_packages missing_remote_packages.flatten! unless missing_remote_packages.empty? - error_string = (_("Cannot support %s due missing packages %s. It will be disabled.") % - [@missing_remote_kind.join(", "), @missing_remote_packages.join(", ")]) + error_string = format(_("Cannot support %s due missing packages %s. It will be disabled."), + @missing_remote_kind.join(", "), @missing_remote_packages.join(", ")) if Mode.auto error_string << " \n" error_string << _("But the AutoYaST installation will be finished offline.") From c53c2c3f512b6a5f92b269c5b5669865d4e42631 Mon Sep 17 00:00:00 2001 From: Stefan Schubert Date: Thu, 5 Oct 2017 15:21:14 +0200 Subject: [PATCH 07/11] adapted suggestions --- src/modules/Packages.rb | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/modules/Packages.rb b/src/modules/Packages.rb index 32b755885..1243805e7 100644 --- a/src/modules/Packages.rb +++ b/src/modules/Packages.rb @@ -947,40 +947,44 @@ def check_remote_installation_packages missing = braille_packages.reject { |tag| pkg_will_be_installed(tag) } unless missing.empty? @missing_remote_packages << missing - @missing_remote_kind << "braille" + @missing_remote_kind << "BRAILLE" end end if Linuxrc.usessh missing = ssh_packages.reject { |tag| pkg_will_be_installed(tag) } unless missing.empty? @missing_remote_packages << missing - @missing_remote_kind << "ssh" + @missing_remote_kind << "SSH" end end if Linuxrc.vnc missing = vnc_packages.reject { |tag| pkg_will_be_installed(tag) } unless missing.empty? @missing_remote_packages << missing - @missing_remote_kind << "vnc" + @missing_remote_kind << "VNC" end end if Linuxrc.display_ip missing = remote_x11_packages.reject { |tag| pkg_will_be_installed(tag) } unless missing.empty? @missing_remote_packages << missing - @missing_remote_kind << "display-ip" + @missing_remote_kind << "DISPLAY_IP" end end missing_remote_packages.flatten! unless missing_remote_packages.empty? - error_string = format(_("Cannot support %s due missing packages %s. It will be disabled."), + error_string = format( + _("Cannot support %s remote access in the installed system due missing packages \n%s. \n" \ + "It will be disabled."), @missing_remote_kind.join(", "), @missing_remote_packages.join(", ")) if Mode.auto error_string << " \n" - error_string << _("But the AutoYaST installation will be finished offline.") + error_string << _("But the AutoYaST installation will be still finished automatically " \ + "without any user interaction.") end - log.warn error_string + log.warn ("Cannot support #{@missing_remote_kind.join(", ")} remote access in the " \ + "installed system due missing packages #{@missing_remote_packages.join(", ")}") return error_string end "" @@ -2768,14 +2772,9 @@ def pkg_will_be_installed(tag) provides = Pkg.PkgQueryProvides(tag) # e.g.: [["kernel-bigsmp", :CAND, :NONE], ["kernel-default", :CAND, :CAND], # ["kernel-default", `BOTH, :INST]] - log.info("provides: #{provides}") - if provides.any? { |p| p[2] != :NONE } - log.info("#{tag} will be installed") - return true - else - log.info("#{tag} will not be installed") - return false - end + ret = provides.any? { |p| p[2] != :NONE } + log.info("#{tag} will #{ret ? "" : "not "}be installed") + return ret end end From de9868f6523da5511e06cd0afddc2e01b5983b69 Mon Sep 17 00:00:00 2001 From: Stefan Schubert Date: Thu, 5 Oct 2017 15:37:54 +0200 Subject: [PATCH 08/11] rubocop --- src/modules/Packages.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/Packages.rb b/src/modules/Packages.rb index 1243805e7..37d2e185c 100644 --- a/src/modules/Packages.rb +++ b/src/modules/Packages.rb @@ -975,16 +975,16 @@ def check_remote_installation_packages missing_remote_packages.flatten! unless missing_remote_packages.empty? error_string = format( - _("Cannot support %s remote access in the installed system due missing packages \n%s. \n" \ - "It will be disabled."), + _("Cannot support %s remote access in the installed system due missing " \ + "packages \n%s. \nIt will be disabled."), @missing_remote_kind.join(", "), @missing_remote_packages.join(", ")) if Mode.auto error_string << " \n" error_string << _("But the AutoYaST installation will be still finished automatically " \ "without any user interaction.") end - log.warn ("Cannot support #{@missing_remote_kind.join(", ")} remote access in the " \ - "installed system due missing packages #{@missing_remote_packages.join(", ")}") + log.warn("Cannot support #{@missing_remote_kind} remote access in the " \ + "installed system due missing packages #{@missing_remote_packages}") return error_string end "" @@ -2774,7 +2774,7 @@ def pkg_will_be_installed(tag) # ["kernel-default", `BOTH, :INST]] ret = provides.any? { |p| p[2] != :NONE } log.info("#{tag} will #{ret ? "" : "not "}be installed") - return ret + ret end end From 2613ac2c678f1c66e71d391f1826dc19b3857a7e Mon Sep 17 00:00:00 2001 From: Stefan Schubert Date: Thu, 5 Oct 2017 15:49:26 +0200 Subject: [PATCH 09/11] rubocop --- src/modules/Packages.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/modules/Packages.rb b/src/modules/Packages.rb index 37d2e185c..0b3181727 100644 --- a/src/modules/Packages.rb +++ b/src/modules/Packages.rb @@ -974,9 +974,8 @@ def check_remote_installation_packages missing_remote_packages.flatten! unless missing_remote_packages.empty? - error_string = format( - _("Cannot support %s remote access in the installed system due missing " \ - "packages \n%s. \nIt will be disabled."), + error_string = format(_("Cannot support %s remote access in the installed system" \ + " due missing packages \n%s. \nIt will be disabled."), @missing_remote_kind.join(", "), @missing_remote_packages.join(", ")) if Mode.auto error_string << " \n" From 523a5d4ef4687aa6faf6e3951ba3e56a01ef620e Mon Sep 17 00:00:00 2001 From: Stefan Schubert Date: Thu, 5 Oct 2017 15:59:37 +0200 Subject: [PATCH 10/11] rubocop --- test/packages_test.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/packages_test.rb b/test/packages_test.rb index 3180f5939..cbb2409bd 100755 --- a/test/packages_test.rb +++ b/test/packages_test.rb @@ -976,7 +976,7 @@ def product(properties = {}) it "reports error" do expect(Yast::Packages.check_remote_installation_packages).to_not be_empty expect(Yast::Packages.missing_remote_packages).to eq(braille_packages) - expect(Yast::Packages.missing_remote_kind).to eq(["braille"]) + expect(Yast::Packages.missing_remote_kind).to eq(["BRAILLE"]) end end end @@ -1017,7 +1017,7 @@ def product(properties = {}) it "reports error for X11 packages" do expect(Yast::Packages.check_remote_installation_packages).to_not be_empty expect(Yast::Packages.missing_remote_packages).to eq(ssh_packages) - expect(Yast::Packages.missing_remote_kind).to eq(["ssh"]) + expect(Yast::Packages.missing_remote_kind).to eq(["SSH"]) end end @@ -1033,7 +1033,7 @@ def product(properties = {}) expect(Yast::Packages.check_remote_installation_packages).to_not be_empty expect(Yast::Packages.missing_remote_packages.sort) .to eq((ssh_packages + remote_x11_packages).sort) - expect(Yast::Packages.missing_remote_kind).to eq(["ssh", "display-ip"]) + expect(Yast::Packages.missing_remote_kind).to eq(["SSH", "DISPLAY_IP"]) end end end @@ -1070,7 +1070,7 @@ def product(properties = {}) it "reports error" do expect(Yast::Packages.check_remote_installation_packages).to_not be_empty expect(Yast::Packages.missing_remote_packages).to eq(vnc_packages) - expect(Yast::Packages.missing_remote_kind).to eq(["vnc"]) + expect(Yast::Packages.missing_remote_kind).to eq(["VNC"]) end end end From db42fd0c206e2b07f18c6b4785bdc39f96949742 Mon Sep 17 00:00:00 2001 From: Stefan Schubert Date: Fri, 6 Oct 2017 10:39:30 +0200 Subject: [PATCH 11/11] correct position --- src/modules/Packages.rb | 107 ++++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 53 deletions(-) diff --git a/src/modules/Packages.rb b/src/modules/Packages.rb index 0b3181727..468d6b66b 100644 --- a/src/modules/Packages.rb +++ b/src/modules/Packages.rb @@ -860,6 +860,59 @@ def InitializeAddOnProducts nil end + # Checking if all needed packages for remote installation + # will be installed on the target system. + # @return [String] empty string or error message if there are missing packages + def check_remote_installation_packages + @missing_remote_kind = [] + @missing_remote_packages = [] + + if Linuxrc.braille + missing = braille_packages.reject { |tag| pkg_will_be_installed(tag) } + unless missing.empty? + @missing_remote_packages << missing + @missing_remote_kind << "BRAILLE" + end + end + if Linuxrc.usessh + missing = ssh_packages.reject { |tag| pkg_will_be_installed(tag) } + unless missing.empty? + @missing_remote_packages << missing + @missing_remote_kind << "SSH" + end + end + if Linuxrc.vnc + missing = vnc_packages.reject { |tag| pkg_will_be_installed(tag) } + unless missing.empty? + @missing_remote_packages << missing + @missing_remote_kind << "VNC" + end + end + if Linuxrc.display_ip + missing = remote_x11_packages.reject { |tag| pkg_will_be_installed(tag) } + unless missing.empty? + @missing_remote_packages << missing + @missing_remote_kind << "DISPLAY_IP" + end + end + + missing_remote_packages.flatten! + unless missing_remote_packages.empty? + error_string = format(_("Cannot support %s remote access in the installed system" \ + " due missing packages \n%s. \nIt will be disabled."), + @missing_remote_kind.join(", "), @missing_remote_packages.join(", ")) + if Mode.auto + error_string << " \n" + error_string << _("But the AutoYaST installation will be still finished automatically " \ + "without any user interaction.") + end + log.warn("Cannot support #{@missing_remote_kind} remote access in the " \ + "installed system due missing packages #{@missing_remote_packages}") + return error_string + end + "" + end + #----------------------------------------------------------------------- # LOCALE FUNCTIONS #----------------------------------------------------------------------- @@ -936,59 +989,6 @@ def architecturePackages deep_copy(packages) end - # Checking if all needed packages for remote installation - # will be installed on the target system. - # @return [String] empty string or error message if there are missing packages - def check_remote_installation_packages - @missing_remote_kind = [] - @missing_remote_packages = [] - - if Linuxrc.braille - missing = braille_packages.reject { |tag| pkg_will_be_installed(tag) } - unless missing.empty? - @missing_remote_packages << missing - @missing_remote_kind << "BRAILLE" - end - end - if Linuxrc.usessh - missing = ssh_packages.reject { |tag| pkg_will_be_installed(tag) } - unless missing.empty? - @missing_remote_packages << missing - @missing_remote_kind << "SSH" - end - end - if Linuxrc.vnc - missing = vnc_packages.reject { |tag| pkg_will_be_installed(tag) } - unless missing.empty? - @missing_remote_packages << missing - @missing_remote_kind << "VNC" - end - end - if Linuxrc.display_ip - missing = remote_x11_packages.reject { |tag| pkg_will_be_installed(tag) } - unless missing.empty? - @missing_remote_packages << missing - @missing_remote_kind << "DISPLAY_IP" - end - end - - missing_remote_packages.flatten! - unless missing_remote_packages.empty? - error_string = format(_("Cannot support %s remote access in the installed system" \ - " due missing packages \n%s. \nIt will be disabled."), - @missing_remote_kind.join(", "), @missing_remote_packages.join(", ")) - if Mode.auto - error_string << " \n" - error_string << _("But the AutoYaST installation will be still finished automatically " \ - "without any user interaction.") - end - log.warn("Cannot support #{@missing_remote_kind} remote access in the " \ - "installed system due missing packages #{@missing_remote_packages}") - return error_string - end - "" - end - # Compute special packages # @return [Array](string) def modePackages @@ -2513,6 +2513,7 @@ def remote_x11_packages publish function: :vnc_packages, type: "list ()" publish function: :remote_x11_packages, type: "list ()" publish variable: :init_called, type: "boolean" + publish function: :check_remote_installation_packages, type: "void (string)" private