Skip to content

Commit

Permalink
Merge 1964681 into 9b52064
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Jan 21, 2022
2 parents 9b52064 + 1964681 commit 8a54c7a
Show file tree
Hide file tree
Showing 7 changed files with 220 additions and 80 deletions.
7 changes: 7 additions & 0 deletions package/autoyast2.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Fri Jan 21 12:07:59 UTC 2022 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

- Replace references to PackageAI module with proper calls to
Package methods (bsc#1194886).
- 4.4.27

-------------------------------------------------------------------
Thu Jan 20 07:58:35 UTC 2022 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

Expand Down
11 changes: 5 additions & 6 deletions package/autoyast2.spec
Expand Up @@ -22,7 +22,7 @@
%endif

Name: autoyast2
Version: 4.4.26
Version: 4.4.27
Release: 0
Summary: YaST2 - Automated Installation
License: GPL-2.0-only
Expand All @@ -41,9 +41,8 @@ BuildRequires: libxml2-tools
# xsltproc for AutoinstClass
BuildRequires: libxslt
BuildRequires: rubygem(%{rb_default_ruby_abi}:rspec)
# GPG symmetric methods and Password dialog
# ProductSpec API
BuildRequires: yast2 >= 4.4.21
# PackageProposal API to taboo resolvables
BuildRequires: yast2 >= 4.4.37
# FileSystems.read_default_subvol_from_target
BuildRequires: yast2-xml
BuildRequires: yast2-transfer
Expand All @@ -68,8 +67,8 @@ BuildRequires: rubygem(%rb_default_ruby_abi:yast-rake)

Requires: autoyast2-installation = %{version}
Requires: libxslt
# ProductSpec API
Requires: yast2 >= 4.4.21
# PackageProposal API to taboo resolvables
Requires: yast2 >= 4.4.37
Requires: yast2-core
Requires: yast2-country >= 3.1.13
# Moving security module to first installation stage
Expand Down
9 changes: 5 additions & 4 deletions src/lib/autoinstall/clients/inst_autosetup.rb
Expand Up @@ -41,6 +41,7 @@
Yast.import "AutoinstScripts"
Yast.import "AutoinstGeneral"
Yast.import "AutoinstSoftware"
Yast.import "PackagesProposal"
Yast.import "Popup"
Yast.import "Arch"
Yast.import "Call"
Expand Down Expand Up @@ -291,18 +292,18 @@ def main
Progress.NextStage

# Evaluating package and patterns selection.
# Selection will be stored in PackageAI.
# Selection will be stored in PackagesProposal.
AutoinstSoftware.Import(Ops.get_map(Profile.current, "software", {}))

# Add additional packages in order to run YAST modules which
# have been defined in the AutoYaST configuration file.
# Selection will be stored in PackageAI.
# Selection will be stored in PackagesProposal.
add_yast2_dependencies if AutoinstFunctions.second_stage_required?
# Also add packages needed by some profile configuration but missing the
# explicit declaration in the software section
AutoinstSoftware.add_additional_packages(pkg_list) unless pkg_list.empty?
Yast::PackagesProposal.AddResolvables("autoyast", :package, pkg_list) unless pkg_list.empty?

# Adding selections (defined in PackageAI) to libzypp and solving
# Adding selections (defined in PackagesProposal) to libzypp and solving
# package dependencies.
if !AutoinstSoftware.Write
Report.Error(
Expand Down
25 changes: 17 additions & 8 deletions src/lib/autoinstall/clients/software_auto.rb
Expand Up @@ -35,7 +35,7 @@ def main
Yast.import "AutoinstConfig"
Yast.import "AutoinstSoftware"
Yast.import "Label"
Yast.import "PackageAI"
Yast.import "PackagesProposal"
Yast.import "AutoInstall"
Yast.import "SourceManager"
Yast.import "PackagesUI"
Expand Down Expand Up @@ -74,7 +74,9 @@ def main
elsif @func == "Change"
@ret = packageSelector
elsif @func == "GetModified"
@ret = Yast::AutoinstSoftware.GetModified || Yast::PackageAI.GetModified
packages = Yast::PackagesProposal.GetResolvables("autoyast", :package) +
Yast::PackagesProposal.GetTaboos("autoyast", :package)
@ret = Yast::AutoinstSoftware.GetModified || !packages.empty?
elsif @func == "SetModified"
Yast::AutoinstSoftware.SetModified
@ret = true
Expand Down Expand Up @@ -213,17 +215,20 @@ def packageSelector
Yast::Pkg.ResolvableInstall(pattern, :pattern)
end

if Yast::Ops.greater_than(Yast::Builtins.size(Yast::PackageAI.toinstall), 0)
Yast::Builtins.foreach(Yast::PackageAI.toinstall) do |p|
pkgs_to_install = Yast::PackagesProposal.GetResolvables("autoyast", :package)
if Yast::Ops.greater_than(Yast::Builtins.size(pkgs_to_install), 0)
Yast::Builtins.foreach(pkgs_to_install) do |p|
Yast::Builtins.y2milestone(
"selecting package for installation: %1 -> %2",
p,
Yast::Pkg.PkgInstall(p)
)
end
end
if Yast::Ops.greater_than(Yast::Builtins.size(Yast::PackageAI.toremove), 0)
Yast::Builtins.foreach(Yast::PackageAI.toremove) do |p|

pkgs_to_remove = Yast::PackagesProposal.GetTaboos("autoyast", :package)
if Yast::Ops.greater_than(Yast::Builtins.size(pkgs_to_remove), 0)
Yast::Builtins.foreach(pkgs_to_remove) do |p|
Yast::Builtins.y2milestone(
"deselecting package for installation: %1 -> %2",
p,
Expand Down Expand Up @@ -257,8 +262,12 @@ def packageSelector
patadd = deep_copy(Yast::AutoinstSoftware.patterns)
end

Yast::PackageAI.toinstall = Yast::Pkg.FilterPackages(false, true, true, true)
Yast::PackageAI.toremove = Yast::Pkg.GetPackages(:taboo, true)
Yast::PackagesProposal.SetResolvables(
"autoyast", :package, Yast::Pkg.FilterPackages(false, true, true, true)
)
Yast::PackagesProposal.SetTaboos(
"autoyast", :package, Yast::Pkg.GetPackages(:taboo, true)
)
Yast::AutoinstSoftware.patterns = Yast::Convert.convert(
Yast::Builtins.union(patadd, patadd),
from: "list",
Expand Down
75 changes: 23 additions & 52 deletions src/modules/AutoinstSoftware.rb
Expand Up @@ -52,7 +52,7 @@ def main

# All shared data are in yast2.rpm to break cyclic dependencies
Yast.import "AutoinstData"
Yast.import "PackageAI"
Yast.import "PackagesProposal"

@Software = {}

Expand Down Expand Up @@ -151,12 +151,14 @@ def Import(settings)
to: "list <string>"
)

PackageAI.toinstall = settings.fetch("packages", [])
to_install = settings.fetch("packages", [])
PackagesProposal.AddResolvables("autoyast", :package, to_install) unless to_install.empty?
@kernel = settings.fetch("kernel", "")

addPostPackages(settings.fetch("post-packages", []))
AutoinstData.post_patterns = settings.fetch("post-patterns", [])
PackageAI.toremove = settings.fetch("remove-packages", [])
to_remove = settings.fetch("remove-packages", [])
PackagesProposal.AddTaboos("autoyast", :package, to_remove) unless to_remove.empty?

true
end
Expand All @@ -165,11 +167,8 @@ def Import(settings)
#
# @param pkglist [Array<String>] list of additional packages to be installed
def add_additional_packages(pkglist)
pkglist.each do |p|
if !PackageAI.toinstall.include?(p) && @packagesAvailable.include?(p)
PackageAI.toinstall.push(p)
end
end
available = pkglist & @packagesAvailable
PackagesProposal.AddResolvables("autoyast", :package, available) unless available.empty?
end

def AddYdepsFromProfile(entries)
Expand Down Expand Up @@ -208,14 +207,14 @@ def Export
s["kernel"] = @kernel if !@kernel.empty?
s["patterns"] = @patterns if !@patterns.empty?

pkg_toinstall = PackageAI.toinstall
s["packages"] = pkg_toinstall if !pkg_toinstall.empty?
pkgs_to_install = Yast::PackagesProposal.GetResolvables("autoyast", :package)
s["packages"] = pkgs_to_install unless pkgs_to_install.empty?

pkg_post = AutoinstData.post_packages
s["post-packages"] = pkg_post if !pkg_post.empty?
s["post-packages"] = pkg_post unless pkg_post.empty?

pkg_toremove = PackageAI.toremove
s["remove-packages"] = PackageAI.toremove if !pkg_toremove.empty?
pkgs_to_remove = Yast::PackagesProposal.GetTaboos("autoyast", :package)
s["remove-packages"] = pkgs_to_remove unless pkgs_to_remove.empty?

s["instsource"] = @instsource

Expand All @@ -238,35 +237,6 @@ def Export
s
end

# Add packages needed by modules, i.e. NIS, NFS etc.
# @param module_packages [Array<String>] list of strings packages to add
def AddModulePackages(module_packages)
module_packages = deep_copy(module_packages)
PackageAI.toinstall = Builtins.toset(
Convert.convert(
Builtins.union(PackageAI.toinstall, module_packages),
from: "list",
to: "list <string>"
)
)
#
# Update profile
#
Ops.set(Profile.current, "software", Export())
nil
end

# Remove packages not needed by modules, i.e. NIS, NFS etc.
# @param module_packages [Array<String>] list of strings packages to add
def RemoveModulePackages(module_packages)
module_packages = deep_copy(module_packages)
PackageAI.toinstall = Builtins.filter(PackageAI.toinstall) do |p|
!Builtins.contains(module_packages, p)
end
Ops.set(Profile.current, "software", Export())
nil
end

# Summary
# @return Html formatted configuration summary
def Summary
Expand All @@ -283,15 +253,17 @@ def Summary
summary = Summary.AddLine(summary, Summary.NotConfigured)
end
summary = Summary.AddHeader(summary, _("Individually Selected Packages"))
pkgs_to_install = Yast::PackagesProposal.GetResolvables("autoyast", :package)
summary = Summary.AddLine(
summary,
Builtins.sformat("%1", Builtins.size(PackageAI.toinstall))
Builtins.sformat("%1", Builtins.size(pkgs_to_install))
)

summary = Summary.AddHeader(summary, _("Packages to Remove"))
pkgs_to_remove = Yast::PackagesProposal.GetTaboos("autoyast", :package)
summary = Summary.AddLine(
summary,
Builtins.sformat("%1", Builtins.size(PackageAI.toremove))
Builtins.sformat("%1", Builtins.size(pkgs_to_remove))
)

if @kernel != ""
Expand All @@ -309,7 +281,7 @@ def autoinstPackages

# the primary list of packages
allpackages = Convert.convert(
Builtins.union(allpackages, PackageAI.toinstall),
Builtins.union(allpackages, Yast::PackagesProposal.GetResolvables("autoyast", :package)),
from: "list",
to: "list <string>"
)
Expand Down Expand Up @@ -407,12 +379,13 @@ def Write

SelectPackagesForInstallation()

pkgs_to_remove = PackagesProposal.GetTaboos("autoyast", :package).dup
computed_packages = Packages.ComputeSystemPackageList
Builtins.foreach(computed_packages) do |pack2|
if Ops.greater_than(Builtins.size(@kernel), 0) && pack2 != @kernel &&
Builtins.search(pack2, "kernel-") == 0
Builtins.y2milestone("taboo for kernel %1", pack2)
PackageAI.toremove = Builtins.add(PackageAI.toremove, pack2)
pkgs_to_remove.push(pack2)
end
end

Expand All @@ -421,14 +394,14 @@ def Write
#
# Now remove all packages listed in remove-packages
#
Builtins.y2milestone("Packages to be removed: %1", PackageAI.toremove)
if Ops.greater_than(Builtins.size(PackageAI.toremove), 0)
Builtins.foreach(PackageAI.toremove) do |rp|
Builtins.y2milestone("Packages to be removed: %1", pkgs_to_remove)
if Ops.greater_than(Builtins.size(pkgs_to_remove), 0)
Builtins.foreach(pkgs_to_remove) do |rp|
# Pkg::ResolvableSetSoftLock( rp, `package ); // FIXME: maybe better Pkg::PkgTaboo(rp) ?
Pkg.PkgTaboo(rp)
end

Pkg.DoRemove(PackageAI.toremove)
Pkg.DoRemove(pkgs_to_remove)
end

#
Expand Down Expand Up @@ -702,9 +675,7 @@ def SelectPackagesForInstallation
publish function: :Import, type: "boolean (map)"
publish function: :AutoinstSoftware, type: "void ()"
publish function: :Export, type: "map ()"
publish function: :AddModulePackages, type: "void (list <string>)"
publish function: :AddYdepsFromProfile, type: "void (list <string>)"
publish function: :RemoveModulePackages, type: "void (list <string>)"
publish function: :Summary, type: "string ()"
publish function: :autoinstPackages, type: "list <string> ()"
publish function: :Write, type: "boolean ()"
Expand Down

0 comments on commit 8a54c7a

Please sign in to comment.