Skip to content

Commit

Permalink
Merge 14d371d into 48d6adb
Browse files Browse the repository at this point in the history
  • Loading branch information
schubi2 committed Nov 27, 2019
2 parents 48d6adb + 14d371d commit 99903f8
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 63 deletions.
7 changes: 7 additions & 0 deletions package/autoyast2.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Nov 18 16:42:31 CET 2019 - schubi@suse.de

- Using Y2Packager::Resolvable.any? and Y2Packager::Resolvable.find
in order to decrease the required memory (bsc#1132650, bsc#1140037).
- 4.2.22

-------------------------------------------------------------------
Thu Nov 14 07:43:39 UTC 2019 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/autoyast2.spec
Expand Up @@ -22,7 +22,7 @@
%endif

Name: autoyast2
Version: 4.2.21
Version: 4.2.22
Release: 0
Summary: YaST2 - Automated Installation
License: GPL-2.0-only
Expand Down
44 changes: 20 additions & 24 deletions src/clients/inst_store_upgrade_software.rb
@@ -1,3 +1,5 @@
require "y2packager/resolvable"

module Yast
class InstStoreUpgradeSoftwareClient < Client
def main
Expand All @@ -10,26 +12,23 @@ def main
return :auto if GetInstArgs.going_back

# find out status of patterns
@patterns = Pkg.ResolvableProperties("", :pattern, "") || []
@patterns = Y2Packager::Resolvable.find(kind: :pattern) || []
@patterns.select! do |p|
Ops.get(p, "transact_by") == :user ||
Ops.get(p, "transact_by") == :app_high
p.transact_by == :user ||
p.transact_by == :app_high
end

# note: does not matter if it is installed or to be installed, the resulting
# state is the same; similar for uninstallation (valid for all packages, patterns
# and products
@patterns_to_remove = []
@patterns_to_install = @patterns.map do |p|
if Ops.get(p, "status") == :selected ||
Ops.get(p, "status") == :installed
next Ops.get_string(p, "name", "")
elsif Ops.get(p, "status") == :removed ||
Ops.get(p, "status") == :available
@patterns_to_remove = Builtins.add(
@patterns_to_remove,
Ops.get_string(p, "name", "")
)
if p.status == :selected ||
p.status == :installed
next p.name
elsif p.status == :removed ||
p.status == :available
@patterns_to_remove << p.name
end

nil
Expand All @@ -49,23 +48,20 @@ def main
Builtins.y2milestone("Packages to remove: %1", @packages_to_remove)

# find out status of products
@products = Pkg.ResolvableProperties("", :product, "") || []
@products = Y2Packager::Resolvable.find(kind: :product) || []
@products.select! do |p|
Ops.get(p, "transact_by") == :user ||
Ops.get(p, "transact_by") == :app_high
p.transact_by == :user ||
p.transact_by == :app_high
end

@products_to_remove = []
@products_to_install = @products.map do |p|
if Ops.get(p, "status") == :selected ||
Ops.get(p, "status") == :installed
next Ops.get_string(p, "name", "")
elsif Ops.get(p, "status") == :removed ||
Ops.get(p, "status") == :available
@products_to_remove = Builtins.add(
@products_to_remove,
Ops.get_string(p, "name", "")
)
if p.status == :selected ||
p.status == :installed
next p.name
elsif p.status == :removed ||
p.status == :available
@products_to_remove << p.name
end

nil
Expand Down
17 changes: 9 additions & 8 deletions src/clients/software_auto.rb
Expand Up @@ -4,6 +4,9 @@
# Summary: Handle Package selections and packages
#
# $Id$

require "y2packager/resolvable"

module Yast
class SoftwareAutoClient < Client
def main
Expand Down Expand Up @@ -183,7 +186,7 @@ def packageSelector
false,
true
)
patterns = Pkg.ResolvableProperties("", :pattern, "")
patterns = Y2Packager::Resolvable.find(kind: :pattern)
Builtins.y2milestone("available patterns %1", patterns)
# sort available_base_selections by order
# $[ "order" : [ "name", "summary" ], .... ]
Expand Down Expand Up @@ -228,15 +231,13 @@ def packageSelector

patadd = []
if @ret != :back
all_patterns = Y2Packager::Resolvable.find(
kind: :pattern, status: :selected
).map(&:name)
Builtins.y2milestone(
"available patterns %1",
Pkg.ResolvableProperties("", :pattern, "")
"available patterns %1", all_patterns
)
Builtins.foreach(Pkg.ResolvableProperties("", :pattern, "")) do |p|
if Ops.get_symbol(p, "status", :nothing) == :selected
patadd = Builtins.add(patadd, Ops.get_string(p, "name", ""))
end
end
patadd = all_patterns
else
patadd = deep_copy(AutoinstSoftware.patterns)
end
Expand Down
49 changes: 19 additions & 30 deletions src/modules/AutoinstSoftware.rb
Expand Up @@ -8,6 +8,7 @@
require "yast"
require "y2storage"
require "y2packager/product"
require "y2packager/resolvable"

module Yast
class AutoinstSoftwareClass < Module
Expand Down Expand Up @@ -108,12 +109,10 @@ def Import(settings)
@instsource = settings.fetch("instsource", "")

@packagesAvailable = Pkg.GetPackages(:available, true)
@patternsAvailable = []
allPatterns = Pkg.ResolvableDependencies("", :pattern, "")
Builtins.filter(allPatterns) do |m|
@patternsAvailable.push(m.fetch("name", "")) if m.fetch("user_visible", false)
m.fetch("user_visible", false)
end
@patternsAvailable = Y2Packager::Resolvable.find(
kind: :pattern,
user_visible: true
).map(&:name)

regexFound = []
Ops.set(
Expand Down Expand Up @@ -863,8 +862,8 @@ def Write
# switch for recommended patterns installation (workaround for our very weird pattern design)
if sw_settings.fetch("install_recommended", false) == false
# set SoftLock to avoid the installation of recommended patterns (#159466)
Builtins.foreach(Pkg.ResolvableProperties("", :pattern, "")) do |p|
Pkg.ResolvableSetSoftLock(Ops.get_string(p, "name", ""), :pattern)
Y2Packager::Resolvable.find(kind: :pattern).each do |p|
Pkg.ResolvableSetSoftLock(p.name, :pattern)
end
end

Expand Down Expand Up @@ -1020,23 +1019,15 @@ def ReadHelper
Pkg.SourceStartManager(true)
Pkg.PkgSolve(false)

all_patterns = Pkg.ResolvableProperties("", :pattern, "")
@all_xpatterns = Pkg.ResolvableDependencies("", :pattern, "")
@all_xpatterns = Y2Packager::Resolvable.find(kind: :pattern)
to_install_packages = install_packages
patterns = []

# FIXME: filter method but it use only side effect of filling patterns
Builtins.filter(all_patterns) do |p|
ret2 = false
if Ops.get_symbol(p, "status", :none) == :installed &&
!Builtins.contains(patterns, Ops.get_string(p, "name", "no name"))
patterns = Builtins.add(
patterns,
Ops.get_string(p, "name", "no name")
)
ret2 = true
@all_xpatterns.each do |p|
if p.status == :installed &&
!patterns.include?(p.name)
(patterns << p.name.empty?) ? "no name" : p.name
end
ret2
end
Pkg.TargetFinish

Expand All @@ -1051,7 +1042,7 @@ def ReadHelper
new_p = []
Builtins.foreach(patterns) do |tmp_pattern|
xpattern = Builtins.filter(@all_xpatterns) do |p|
Ops.get_string(p, "name", "") == tmp_pattern
p.name == tmp_pattern
end
found = Ops.get(xpattern, 0, {})
req = false
Expand Down Expand Up @@ -1092,15 +1083,13 @@ def ReadHelper
# "packages" -> list<string> user selected packages
# "remove-packages" -> list<string> packages to remove
def read_initial_stage
install_patterns = Pkg.ResolvableProperties("", :pattern, "").collect do |pattern|
# Do not take care about if the pattern has been selected by the user or the product
# definition, cause we need a base selection here for the future
# autoyast installation. (bnc#882886)
if pattern["user_visible"] &&
(pattern["status"] == :selected || pattern["status"] == :installed)
pattern["name"]
install_patterns =
Y2Packager::Resolvable.find(kind: :pattern, user_visible: true).map do |pattern|
# Do not take care about if the pattern has been selected by the user or the product
# definition, cause we need a base selection here for the future
# autoyast installation. (bnc#882886)
pattern.name if pattern.status == :selected || pattern.status == :installed
end
end

software = {}
software["packages"] = install_packages
Expand Down

0 comments on commit 99903f8

Please sign in to comment.