Skip to content

Commit

Permalink
merged with SP2
Browse files Browse the repository at this point in the history
  • Loading branch information
schubi2 committed Jan 26, 2018
2 parents 1a64d3f + 2508f78 commit 3a598f1
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 50 deletions.
7 changes: 7 additions & 0 deletions package/autoyast2.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Fri Jan 26 12:58:17 CET 2018 - schubi@suse.de

- Reporting packages which cannot be selected for installation.
(bnc#1077292)
- 3.2.28

-------------------------------------------------------------------
Wed Oct 18 14:09:07 UTC 2017 - igonzalezsosa@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/autoyast2.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: autoyast2
Version: 3.2.27
Version: 3.2.28
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
73 changes: 24 additions & 49 deletions src/modules/AutoinstSoftware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ def Import(settings)
@patterns = settings.fetch("patterns",[])
@instsource = settings.fetch("instsource","")

notFound = ""

# what is this good for? disturbs the main-repo selection
# Packages::Init(true);
# Packages::InitializeAddOnProducts();
Expand Down Expand Up @@ -160,26 +158,6 @@ def Import(settings)
:to => "list <string>"
)

Builtins.foreach(Ops.get_list(settings, "packages", [])) do |pack|
if Stage.initial && # We are in the first installation stage
!Mode.config && # but not cloning system to autoinst.xml (bnc#901747)
!Pkg.IsAvailable(pack) # and package is NOT on installation medium
notFound = Ops.add(Ops.add(notFound, pack), "\n")
end
end
if Ops.greater_than(Builtins.size(notFound), 0)
Builtins.y2error("packages not found: %1", notFound)
# warning text during the installation. %1 is a list of package names
Report.Error(
Builtins.sformat(
_(
"These packages could not be found in the software repositories:\n%1"
),
notFound
)
)
end

PackageAI.toinstall = settings.fetch("packages",[])
@kernel = settings.fetch("kernel","")

Expand Down Expand Up @@ -878,28 +856,9 @@ def Write
)
end

autoinstPacks = autoinstPackages
# FIXME: optimization for package list evaluation turned off because it optimized it
# into an unbootable state (no kernel) bnc#427731
#
# list<string> autoinstPacks = PackageAI::toinstall;
Builtins.y2milestone(
"Packages selected in autoinstall mode: %1",
autoinstPacks
)

if Ops.greater_than(Builtins.size(autoinstPacks), 0)
Builtins.y2milestone(
"Installing individual packages: %1",
Pkg.DoProvide(autoinstPacks)
)
end

SelectPackagesForInstallation()

computed_packages = Packages.ComputeSystemPackageList
Builtins.y2debug("Computed list of packages: %1", computed_packages)
Pkg.DoProvide(computed_packages)

Builtins.foreach(computed_packages) do |pack2|
if Ops.greater_than(Builtins.size(@kernel), 0) && pack2 != @kernel &&
Builtins.search(pack2, "kernel-") == 0
Expand All @@ -921,13 +880,7 @@ def Write

Pkg.DoRemove(PackageAI.toremove)
end
pack = Storage.AddPackageList
if Ops.greater_than(Builtins.size(pack), 0)
Builtins.y2milestone(
"Installing storage packages: %1",
Pkg.DoProvide(pack)
)
end

#
# Solve dependencies
#
Expand Down Expand Up @@ -1123,6 +1076,28 @@ def SavedPackageSelection
@saved_package_selection
end

def SelectPackagesForInstallation
log.info "Individual Packages for installation: #{autoinstPackages}"
failed_packages = {}
failed_packages = Pkg.DoProvide(autoinstPackages) unless autoinstPackages.empty?
computed_packages = Packages.ComputeSystemPackageList
log.info "Computed packages for installation: #{computed_packages}"
failed_packages = failed_packages.merge(Pkg.DoProvide(computed_packages)) unless computed_packages.empty?
storage_pack = Storage.AddPackageList
log.info "Storage packages for installation: #{storage_pack}"
failed_packages = failed_packages.merge(Pkg.DoProvide(storage_pack)) unless storage_pack.empty?

unless failed_packages.empty?
log.error "Cannot select: #{failed_packages}"
not_selected = ""
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)
end
end

publish :variable => :Software, :type => "map"
publish :variable => :image, :type => "map <string, any>"
publish :variable => :image_arch, :type => "string"
Expand Down
12 changes: 12 additions & 0 deletions test/AutoinstSoftware_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,16 @@

end

describe "selecting packages for installation" do
it "shows a popup if some packages have not been found" 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"])
expect(Yast::Pkg).to receive(:DoProvide).with(["a1"]).and_return({"a1" => "not found"})
expect(Yast::Pkg).to receive(:DoProvide).with(["a2","a3"]).and_return({})
expect(Yast::Report).to receive(:Error)
subject.SelectPackagesForInstallation()
end
end

end

0 comments on commit 3a598f1

Please sign in to comment.