Skip to content

Commit

Permalink
Decreasing required memory (#485)
Browse files Browse the repository at this point in the history
Decreasing required memory
  • Loading branch information
schubi2 authored and lslezak committed Nov 25, 2019
1 parent b3c9e60 commit a380016
Show file tree
Hide file tree
Showing 20 changed files with 387 additions and 395 deletions.
8 changes: 8 additions & 0 deletions package/yast2-packager.changes
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
-------------------------------------------------------------------
Fri Nov 8 19:28:57 UTC 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.33

-------------------------------------------------------------------
Fri Nov 8 18:58:23 UTC 2019 - Ladislav Slezák <lslezak@suse.cz>

- Preselect the installed add-ons when upgrading from the Full
Expand Down
2 changes: 1 addition & 1 deletion package/yast2-packager.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-packager
Version: 4.2.32
Version: 4.2.33
Release: 0
Summary: YaST2 - Package Library
License: GPL-2.0-or-later
Expand Down
6 changes: 4 additions & 2 deletions src/clients/inst_rpmcopy.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require "y2packager/resolvable"

module Yast
# Install all the RPM packages the user has selected.
# Show installation dialogue. Show progress bars.
Expand Down Expand Up @@ -322,8 +324,8 @@ def AutoinstPostPackages
failed = []
patterns = deep_copy(AutoinstData.post_patterns)
# 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
Builtins.foreach(Builtins.toset(patterns)) do |p|
failed = Builtins.add(failed, p) if !Pkg.ResolvableInstall(p, :pattern)
Expand Down
13 changes: 6 additions & 7 deletions src/clients/sw_single.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

require "y2packager/known_repositories"
require "y2packager/system_packages"
require "y2packager/resolvable"

module Yast
# Purpose: contains dialog loop for workflows:
Expand Down Expand Up @@ -363,6 +364,7 @@ def CheckWhichPackages(arg_list)
# @param a_version [String] first version
# @param b_version [String] second version
# @return [Boolean] true if the second one is newer than the first one
# @deprecated Use {#Pkg.CompareVersions} instead.
def VersionALtB(a_version, b_version)
a_version_l = Builtins.filter(Builtins.splitstring(a_version, "-.")) do |s|
Builtins.regexpmatch(s, "^[0123456789]+$")
Expand Down Expand Up @@ -404,21 +406,18 @@ def VersionALtB(a_version, b_version)
# Check if there is an uninstalled package of the same name with a
# higher version. Otherwise we would forcefully reinstall it. #222757#c9
def CanBeUpdated(package)
props = Pkg.ResolvableProperties(
package, # any version
:package,
""
)
props = Y2Packager::Resolvable.find(kind: :package, name: package)

# find maximum version and remember
# if it is installed
max_ver = "0"
max_is_installed = false
Builtins.foreach(props) do |prop|
cur_ver = Ops.get_string(prop, "version", "0")
cur_ver = prop.version
if VersionALtB(max_ver, cur_ver)
max_ver = cur_ver
# `installed or `selected is ok
max_is_installed = Ops.get_symbol(prop, "status", :available) != :available
max_is_installed = prop.status != :available
Builtins.y2milestone("new max: installed: %1", max_is_installed)
end
end
Expand Down
17 changes: 9 additions & 8 deletions src/lib/packager/product_patterns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#

require "yast"
require "y2packager/resolvable"

module Yast
# Evaluate the default patterns for the currently selected products
Expand Down Expand Up @@ -53,9 +54,9 @@ def select
# Find the default patterns for all selected products.
# @return [Array<String>] pattern names
def find
products = Yast::Pkg.ResolvableProperties("", :product, "")
products = Y2Packager::Resolvable.find(kind: :product)
remove_unselected(products)
products.map! { |product| product["name"] }
products.map!(&:name)
log.info "Found selected products: #{products}"

patterns = products.map { |p| product_patterns(p) }.flatten.uniq
Expand All @@ -81,19 +82,19 @@ def product_patterns(product)
def dependencies(product)
product_dependencies = []

resolvables = Yast::Pkg.ResolvableProperties(product, :product, "")
resolvables = Y2Packager::Resolvable.find(kind: :product, name: product)
remove_unselected(resolvables)
remove_other_repos(resolvables) if src

resolvables.each do |resolvable|
prod_pkg = resolvable["product_package"]
prod_pkg = resolvable.product_package
next unless prod_pkg

release_resolvables = Yast::Pkg.ResolvableDependencies(prod_pkg, :package, "")
release_resolvables = Y2Packager::Resolvable.find(kind: :package, name: prod_pkg)
remove_unselected(release_resolvables)

release_resolvables.each do |release_resolvable|
deps = release_resolvable["deps"]
deps = release_resolvable.deps
product_dependencies.concat(deps) if deps
end
end
Expand All @@ -107,14 +108,14 @@ def dependencies(product)
# @param [Array<Hash>] resolvables only the Hashes where the key "status"
# maps to :selected value are kept, the rest is removed
def remove_unselected(resolvables)
resolvables.select! { |p| p["status"] == :selected }
resolvables.select! { |p| p.status == :selected }
end

# Remove the resolvables from other repositories than in 'src'
# @param [Array<Hash>] resolvables only the Hashes where the key "status"
# is equal to `src` are kept, the rest is removed
def remove_other_repos(resolvables)
resolvables.select! { |p| p["source"] == src }
resolvables.select! { |p| p.source == src }
end

# Collect "provides" dependencies from the list.
Expand Down
10 changes: 4 additions & 6 deletions src/lib/y2packager/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

require "uri"
require "y2packager/product"
require "y2packager/resolvable"

module Y2Packager
# This class represents a libzypp repository
Expand Down Expand Up @@ -140,20 +141,17 @@ def scheme
#
# @return [Array<Y2Packager::Product>] Products in the repository
#
# @see Yast::Pkg.ResolvableProperties
# @see Y2Packager::Product
def products
return @products unless @products.nil?

# Filter products from this repository
candidates = Yast::Pkg.ResolvableProperties("", :product, "").select do |pro|
pro["source"] == repo_id
end
candidates = Y2Packager::Resolvable.find(kind: :product, source: repo_id)

# Build an array of Y2Packager::Product objects
@products = candidates.map do |data|
Y2Packager::Product.new(name: data["name"], version: data["version"],
arch: data["arch"], category: data["category"], vendor: data["vendor"])
Y2Packager::Product.new(name: data.name, version: data.version,
arch: data.arch, category: data.category, vendor: data.vendor)
end
end

Expand Down
4 changes: 2 additions & 2 deletions src/lib/y2packager/self_update_addon_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# find current contact information at www.suse.com.

require "yast"
require "y2packager/resolvable"

Yast.import "Pkg"

Expand Down Expand Up @@ -57,8 +58,7 @@ def self.packages(repo_id)
# but rather be safe than sorry...

pkgs.select! do |pkg|
props = Yast::Pkg.ResolvableProperties(pkg, :package, "")
props.any? { |p| p["source"] == repo_id }
Y2Packager::Resolvable.any?(kind: :package, name: pkg, source: repo_id)
end

log.info "Found addon packages in the self update repository: #{pkgs}"
Expand Down
13 changes: 8 additions & 5 deletions src/lib/y2packager/system_packages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# ------------------------------------------------------------------------------

require "yast"
require "y2packager/resolvable"

module Y2Packager
# Preselect the system packages (drivers) from the specified repositories.
Expand Down Expand Up @@ -75,16 +76,18 @@ def find_packages

ids = repo_ids(repositories)

pkgs = Yast::Pkg.ResolvableProperties("", :package, "")
pkgs = pkgs.select do |p|
# the packages from the specified repositories selected by the solver
p["status"] == :selected && ids.include?(p["source"]) && p["transact_by"] == :solver
pkgs = Y2Packager::Resolvable.find(kind: :package,
transact_by: :solver,
status: :selected)
pkgs.select! do |p|
# the packages from the specified repositories
ids.include?(p.source)
end

# set back the original solver flags
Yast::Pkg.SetSolverFlags(original_solver_flags)

pkgs.map! { |p| p["name"] }
pkgs.map!(&:name)
log.info "Found system packages: #{pkgs}"

pkgs
Expand Down
Loading

0 comments on commit a380016

Please sign in to comment.