From 689c966ce483873d6d29021d6429ccf2e1a52b2f Mon Sep 17 00:00:00 2001 From: Jozef Pupava Date: Tue, 27 Apr 2021 13:19:31 +0200 Subject: [PATCH 1/2] Use linuxrc option reboot_timeout to configure the timeout before reboot bsc#1122493 poo#89716 --- library/general/src/modules/Linuxrc.rb | 7 +++++++ library/general/test/linuxrc_test.rb | 12 ++++++++++++ package/yast2.changes | 7 +++++++ package/yast2.spec | 2 +- 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/library/general/src/modules/Linuxrc.rb b/library/general/src/modules/Linuxrc.rb index 4cc5e612c..8a9f4f634 100644 --- a/library/general/src/modules/Linuxrc.rb +++ b/library/general/src/modules/Linuxrc.rb @@ -142,6 +142,12 @@ def text InstallInf("Textmode") == "1" end + def reboot_timeout + return nil unless InstallInf("reboot_timeout") + + InstallInf("reboot_timeout").to_i + end + # end of install.inf reading routines # Write /etc/yast.inf during installation @@ -287,6 +293,7 @@ def disable_remote(services) publish function: :keys, type: "list ()" publish function: :value_for, type: "string (string)" publish function: :disable_remote, type: "list ()" + publish function: :reboot_timeout, type: "integer ()" private diff --git a/library/general/test/linuxrc_test.rb b/library/general/test/linuxrc_test.rb index 4c6fafffd..9af9e0f11 100755 --- a/library/general/test/linuxrc_test.rb +++ b/library/general/test/linuxrc_test.rb @@ -279,4 +279,16 @@ def load_install_inf(defaults_replacement = {}) end end end + + describe "#reboot_timeout" do + it "returns integer value if 'reboot_timeout' is found in install.inf" do + load_install_inf("reboot_timeout" => "15") + expect(subject.reboot_timeout).to eq(15) + end + + it "returns nil if 'reboot_timeout' is not found in install.inf" do + load_install_inf({}) + expect(subject.reboot_timeout).to eq(nil) + end + end end diff --git a/package/yast2.changes b/package/yast2.changes index 8e1c64db9..ffb53e2bc 100644 --- a/package/yast2.changes +++ b/package/yast2.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Tue Apr 27 13:24:40 CEST 2021 - Jozef Pupava + +- Add linuxrc option "reboot_timeout" to configure the timeout + before reboot (bsc#1122493 poo#89716) +- 4.1.81 + ------------------------------------------------------------------- Mon Dec 21 10:27:21 UTC 2020 - Imobach Gonzalez Sosa diff --git a/package/yast2.spec b/package/yast2.spec index 68751af1e..822c930e4 100644 --- a/package/yast2.spec +++ b/package/yast2.spec @@ -17,7 +17,7 @@ Name: yast2 -Version: 4.1.80 +Version: 4.1.81 Release: 0 Summary: YaST2 - Main Package From 6a2893511d32edde11793ce872603edc12cf6d4d Mon Sep 17 00:00:00 2001 From: Jozef Pupava Date: Thu, 29 Apr 2021 11:05:34 +0200 Subject: [PATCH 2/2] Ensure closing the opened SCR instance and do some more test mocking --- library/general/src/modules/Linuxrc.rb | 43 ++++++++++++------- library/system/test/fs_snapshot_store_test.rb | 25 +++++------ library/system/test/fs_snapshot_test.rb | 5 +++ package/yast2.changes | 6 ++- 4 files changed, 50 insertions(+), 29 deletions(-) diff --git a/library/general/src/modules/Linuxrc.rb b/library/general/src/modules/Linuxrc.rb index 8a9f4f634..59d574867 100644 --- a/library/general/src/modules/Linuxrc.rb +++ b/library/general/src/modules/Linuxrc.rb @@ -51,22 +51,33 @@ def main def ReadInstallInf return if !@install_inf.nil? - @install_inf = {} - # don't read anything if the file doesn't exist - if SCR.Read(path(".target.size"), "/etc/install.inf") == -1 - Builtins.y2error("Reading install.inf, but file doesn't exist!!!") - return - end - entries = SCR.Dir(path(".etc.install_inf")) - if entries.nil? - Builtins.y2error("install.inf is empty") - return - end - Builtins.foreach(entries) do |e| - val = Convert.to_string( - SCR.Read(Builtins.add(path(".etc.install_inf"), e)) - ) - Ops.set(@install_inf, e, val) + # skip from chroot + old_SCR = WFM.SCRGetDefault + new_SCR = WFM.SCROpen("chroot=/:scr", false) + WFM.SCRSetDefault(new_SCR) + + begin + @install_inf = {} + # don't read anything if the file doesn't exist + if SCR.Read(path(".target.size"), "/etc/install.inf") == -1 + Builtins.y2error("Reading install.inf, but file doesn't exist!!!") + return + end + entries = SCR.Dir(path(".etc.install_inf")) + if entries.nil? + Builtins.y2error("install.inf is empty") + return + end + Builtins.foreach(entries) do |e| + val = Convert.to_string( + SCR.Read(Builtins.add(path(".etc.install_inf"), e)) + ) + Ops.set(@install_inf, e, val) + end + ensure + # close and chroot back + WFM.SCRSetDefault(old_SCR) + WFM.SCRClose(new_SCR) end nil diff --git a/library/system/test/fs_snapshot_store_test.rb b/library/system/test/fs_snapshot_store_test.rb index 0c7a84168..d908ac842 100755 --- a/library/system/test/fs_snapshot_store_test.rb +++ b/library/system/test/fs_snapshot_store_test.rb @@ -64,22 +64,23 @@ described_class.clean("test") end - end - context "in initial stage before SCR switched" do - it "use path on mounted target system" do - Yast.import "Installation" - Yast::Installation.destdir = "/mnt" + context "in initial stage before SCR switched" do + it "use path on mounted target system" do + Yast.import "Installation" + Yast::Installation.destdir = "/mnt" - Yast.import "Stage" - allow(Yast::Stage).to receive(:initial).and_return(true) + Yast.import "Stage" + allow(Yast::Stage).to receive(:initial).and_return(true) + allow(Yast::WFM).to receive(:scr_chrooted?).and_return(false) - expect(Yast::SCR).to receive(:Execute).with( - path(".target.remove"), - "/mnt/var/lib/YaST2/pre_snapshot_test.id" - ) + expect(Yast::SCR).to receive(:Execute).with( + path(".target.remove"), + "/mnt/var/lib/YaST2/pre_snapshot_test.id" + ) - described_class.clean("test") + described_class.clean("test") + end end end end diff --git a/library/system/test/fs_snapshot_test.rb b/library/system/test/fs_snapshot_test.rb index 6cfdd20c6..9bfbd6b66 100755 --- a/library/system/test/fs_snapshot_test.rb +++ b/library/system/test/fs_snapshot_test.rb @@ -20,10 +20,13 @@ def logger end describe ".configured?" do + let(:chrooted) { true } + before do allow(Yast::SCR).to receive(:Execute) .with(path(".target.bash_output"), FIND_CONFIG) .and_return("stdout" => "", "exit" => find_code) + allow(Yast::WFM).to receive(:scr_chrooted?).and_return chrooted end context "when snapper's configuration does not exist" do @@ -44,6 +47,8 @@ def logger end context "in initial stage before scr switched" do + let(:chrooted) { false } + let(:find_code) { 0 } before do Yast.import "Installation" diff --git a/package/yast2.changes b/package/yast2.changes index ffb53e2bc..f5d3c8f9b 100644 --- a/package/yast2.changes +++ b/package/yast2.changes @@ -1,8 +1,12 @@ ------------------------------------------------------------------- -Tue Apr 27 13:24:40 CEST 2021 - Jozef Pupava +Thu Apr 29 13:24:40 CEST 2021 - Jozef Pupava - Add linuxrc option "reboot_timeout" to configure the timeout before reboot (bsc#1122493 poo#89716) +- Linuxrc: Ensure the new opened SCR instace is closed when reading + the /etc/install.inf file (bsc#1122493, bsc#1157476) +- Ensure /etc/install.inf is not read from the target system but + from the local one. (bsc#1122493, bsc#1157476) - 4.1.81 -------------------------------------------------------------------