Skip to content
Permalink
Browse files

Merge pull request #395 from yast/SLE-12-SP2_bnc_1077292_2

Sle 12 sp2 bnc 1077292 2
  • Loading branch information...
schubi2 committed Feb 1, 2018
2 parents 2508f78 + dd75ba4 commit 5e61a30c1b1627ede995eb5cc82af57dfbddb721
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Thu Feb 1 12:59:08 CET 2018 - schubi@suse.de

- Report packages which cannot be select for installation
(except those packages not included in the AutoYaST profile)
(bnc#1077292)
- 3.1.170

-------------------------------------------------------------------
Fri Jan 26 12:58:17 CET 2018 - schubi@suse.de

@@ -17,7 +17,7 @@


Name: autoyast2
Version: 3.1.169
Version: 3.1.170
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
@@ -12,6 +12,11 @@
module Yast
class AutoinstSoftwareClass < Module
include Yast::Logger

# Maximal amount of packages which will be shown
# in a popup.
MAX_PACKAGE_VIEW = 5

def main
Yast.import "UI"
Yast.import "Pkg"
@@ -1087,14 +1092,40 @@ def SelectPackagesForInstallation
log.info "Storage packages for installation: #{storage_pack}"
failed_packages = failed_packages.merge(Pkg.DoProvide(storage_pack)) unless storage_pack.empty?

# Blaming only packages which have been selected by the AutoYaST configuration file
log.error "Cannot select following packages for installation:" unless failed_packages.empty?
failed_packages.reject! do |name,reason|
if @Software["packages"] && @Software["packages"].include?(name)
log.error(" #{name} : #{reason} (selected by AutoYaST configuration file)")
false
else
log.error(" #{name} : #{reason} (selected by YAST automatically)")
true
end
end

unless failed_packages.empty?
log.error "Cannot select: #{failed_packages}"
not_selected = ""
suggest_y2log = false
failed_count = failed_packages.size
if failed_packages.size > MAX_PACKAGE_VIEW
failed_packages = failed_packages.first(MAX_PACKAGE_VIEW).to_h
suggest_y2log = true
end
failed_packages.each do |name,reason|
not_selected << "#{name}: #{reason}\n"
end
# TRANSLATORS: Warning text during the installation. %s is a list of package
Report.Error(_("These packages cannot be found in the software repositories:\n%s") % not_selected)
error_message = _("These packages cannot be found in the software repositories:\n%s") % not_selected
if suggest_y2log
# TRANSLATORS: Error message, %d is replaced by the amount of failed packages.
error_message += _("and %d additional packages") % (failed_count - MAX_PACKAGE_VIEW)
# TRANSLATORS: Error message, %s is replaced by "/var/log/YaST2/y2log"
error_message += "\n\n" + _("Details can be found in the %s file.") %
"/var/log/YaST2/y2log"
end

Report.Error(error_message)
end
end

@@ -30,15 +30,38 @@
end

describe "selecting packages for installation" do
it "shows a popup if some packages have not been found" do

before(:each) do
allow(subject).to receive(:autoinstPackages).and_return(["a1"])
expect(Yast::Packages).to receive(:ComputeSystemPackageList).and_return([])
expect(Yast::Storage).to receive(:AddPackageList).and_return(["a2","a3"])
allow(subject).to receive(:autoinstPackages).and_return(["a1"])
expect(Yast::Pkg).to receive(:DoProvide).with(["a1"]).and_return({"a1" => "not found"})
end

it "shows a popup if some packages have not been found" do
expect(Yast::Storage).to receive(:AddPackageList).and_return(["a2","a3"])
expect(Yast::Pkg).to receive(:DoProvide).with(["a2","a3"]).and_return({})
expect(Yast::Report).to receive(:Error)
subject.SelectPackagesForInstallation()
end

it "shows a popup for not found packages which have been selected by AY configuration only" do
subject.Import(Yast::Profile.current["software"])
expect(Yast::Storage).to receive(:AddPackageList).and_return(["a2","a3","a4"])
expect(Yast::Pkg).to receive(:DoProvide).with(["a2","a3","a4"]).and_return({"a4" => "not found"})
# a4 is not in the software/packages section
expect(Yast::Report).to receive(:Error).with("These packages cannot be found in the software repositories:\na1: not found\n")
subject.SelectPackagesForInstallation()
end

it "shows no popup if no software section has been defined in the AY configuration" do
subject.Import({})
expect(Yast::Storage).to receive(:AddPackageList).and_return(["a2","a3","a4"])
expect(Yast::Pkg).to receive(:DoProvide).with(["a2","a3","a4"]).and_return({"a4" => "not found"})
expect(Yast::Report).to_not receive(:Error)
subject.SelectPackagesForInstallation()
end

end

end
@@ -9,5 +9,10 @@
<post-package>a2</post-package>
<post-package>a3</post-package>
</post-packages>
<packages config:type="list">
<post-package>a1</post-package>
<post-package>a2</post-package>
<post-package>a3</post-package>
</packages>
</software>
</profile>

0 comments on commit 5e61a30

Please sign in to comment.
You can’t perform that action at this time.