Skip to content

Commit

Permalink
Merge pull request #833 from yast/merge-sle-15-sp3
Browse files Browse the repository at this point in the history
bsc#1196566: properly handle the dopackages option (master)
  • Loading branch information
imobachgs committed Mar 7, 2022
2 parents 88cb442 + 9abfae4 commit 81f27da
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 11 deletions.
7 changes: 7 additions & 0 deletions package/autoyast2.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Mar 7 11:00:12 UTC 2022 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

- Properly handle the "dopackages" option in the openFile
method of the AyastSetup module (bsc#1196566).
- 4.4.35

-------------------------------------------------------------------
Tue Mar 4 13:14:15 UTC 2022 - José Iván López González <jlopez@suse.com>

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

Name: autoyast2
Version: 4.4.34
Version: 4.4.35
Release: 0
Summary: YaST2 - Automated Installation
License: GPL-2.0-only
Expand Down
1 change: 0 additions & 1 deletion src/clients/ayast_setup.rb
Expand Up @@ -34,7 +34,6 @@ def main
Yast.import "CommandLine"
Yast.import "Mode"

@dopackages = true
@cmdline = {
"id" => "ayast_setup",
"help" => _(
Expand Down
15 changes: 11 additions & 4 deletions src/lib/autoinstall/clients/ayast_setup.rb
Expand Up @@ -42,7 +42,14 @@ module AyastSetup
WFM = Yast::WFM
Profile = Yast::Profile
Builtins = Yast::Builtins
def Setup

# Configures up the system according to the current AutoYaST profile
#
# It relies on clients like `inst_autopost`, `inst_rpmcopy` or
# `inst_autoconfigure`.
#
# @param install_packages [Boolean] Install patterns and packages
def Setup(install_packages: true)
textdomain "autoinst"
Yast::AutoInstall.Save
Yast::Wizard.CreateDialog
Expand Down Expand Up @@ -74,7 +81,7 @@ def Setup
[]
)

if @dopackages
if install_packages
Yast::Pkg.TargetInit("/", false)
WFM.CallFunction("inst_rpmcopy", [])
end
Expand All @@ -91,7 +98,7 @@ def openFile(options)
Yast::CommandLine.Error(_("Path to AutoYaST profile must be set."))
return false
end
@dopackages = false if Ops.get_string(options, "dopackages", "yes") == "no"
install_packages = options["dopackages"] != "no"
if SCR.Read(
path(".target.lstat"),
Ops.get_string(options, "filename", "")
Expand All @@ -108,7 +115,7 @@ def openFile(options)
return false
end

Setup()
Setup(install_packages: install_packages)
true
end

Expand Down
17 changes: 12 additions & 5 deletions test/lib/clients/ayast_setup_test.rb
Expand Up @@ -64,7 +64,6 @@ class DummyClient < Module
allow(Yast::Package).to receive(:Installed).and_return(true)
allow(Yast::Pkg).to receive(:TargetInit)
allow(subject).to receive(:restart_initscripts)
subject.dopackages = dopackages
end

it "saves the current profile if modified" do
Expand All @@ -79,9 +78,17 @@ class DummyClient < Module
subject.Setup
end

context "when dopackages is enabled" do
let(:dopackages) { true }
context "when install_packages is set to true" do
it "installs given post installation packages / patterns when not installed yet" do
expect(Yast::Package).to receive(:Installed).and_return(false)
expect(Yast::AutoinstSoftware).to receive(:addPostPackages).with(["vim"])
expect(Yast::WFM).to receive(:CallFunction).with("inst_rpmcopy", [])

subject.Setup(install_packages: true)
end
end

context "when install_packages is set to specified" do
it "installs given post installation packages / patterns when not installed yet" do
expect(Yast::Package).to receive(:Installed).and_return(false)
expect(Yast::AutoinstSoftware).to receive(:addPostPackages).with(["vim"])
Expand All @@ -91,11 +98,11 @@ class DummyClient < Module
end
end

context "when dopackages is disabled" do
context "when install_packages is set to false" do
it "does not try to install given post installation packages / patterns" do
expect(Yast::WFM).to_not receive(:CallFunction).with("inst_rpmcopy", [])

subject.Setup
subject.Setup(install_packages: false)
end
end

Expand Down

0 comments on commit 81f27da

Please sign in to comment.