Skip to content

Commit

Permalink
Merge pull request #339 from yast/call_mkinitrd
Browse files Browse the repository at this point in the history
Call mkinitrd
  • Loading branch information
jreidinger committed May 24, 2016
2 parents 2205eca + 0d55038 commit 0f6f5cb
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 166 deletions.
8 changes: 8 additions & 0 deletions package/yast2-bootloader.changes
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Tue May 24 09:00:13 UTC 2016 - jreidinger@suse.com

- run mkinitrd at the end of installation to ensure proper initrd
even for image based installation or live install
(bnc#977656,bnc#979719)
- 3.1.188

-------------------------------------------------------------------
Tue May 17 07:42:46 UTC 2016 - jreidinger@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-bootloader.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-bootloader
Version: 3.1.187
Version: 3.1.188
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
10 changes: 7 additions & 3 deletions src/lib/bootloader/finish_client.rb
@@ -1,9 +1,9 @@
require "bootloader/kexec"
require "bootloader/bootloader_factory"
require "installation/finish_client"
require "yast2/execute"

Yast.import "Arch"
Yast.import "Bootloader"
Yast.import "Linuxrc"
Yast.import "Misc"
Yast.import "Mode"
Expand All @@ -13,8 +13,6 @@ module Bootloader
class FinishClient < ::Installation::FinishClient
include Yast::I18n

BASH_PATH = Yast::Path.new(".target.bash_output")

def initialize
textdomain "bootloader"
end
Expand Down Expand Up @@ -66,6 +64,12 @@ def write
log.info "Installation started with kexec_reboot set 0"
end

# call mkinitrd to ensure initrd is properly set, it is especially needed
# in live system install ( where it is just copyied ) and image based
# installation where post install script is not executed
# (bnc#979719,bnc#977656)
Yast::Execute.on_target("/sbin/mkinitrd")

true
end

Expand Down
279 changes: 117 additions & 162 deletions test/bootloader_finish_client_test.rb
Expand Up @@ -2,166 +2,121 @@

require "bootloader/finish_client"
require "bootloader/bootloader_factory"
require "yast2/execute"

# need to be adapted to new schema
#
# describe Bootloader::FinishClient do
# describe "#write" do
# before do
# Yast.import "Arch"
#
# allow(Yast::Arch).to receive(:s390).and_return(false)
#
# Yast.import "Bootloader"
#
# allow(Yast::Bootloader).to receive(:WriteInstallation).and_return(true)
# allow(Yast::Bootloader).to receive(:Update).and_return(true)
# allow(Yast::WFM).to receive(:Execute)
# .and_return("exit" => 0, "stdout" => "", "stderr" => "")
# allow(Yast::SCR).to receive(:Execute)
# allow(Yast::Bootloader).to receive(:Read)
# allow(Yast::Bootloader).to receive(:FlagOnetimeBoot).and_return(true)
# allow(Yast::Bootloader).to receive(:getDefaultSection).and_return("linux")
#
# Bootloader::BootloaderFactory.current_name = "grub2"
# allow(Bootloader::BootloaderFactory.current).to receive(:read?).and_return(true)
# end
#
# it "sets on non-s390 systems reboot message" do
# Yast.import "Misc"
#
# subject.write
#
# expect(Yast::Misc.boot_msg).to match(/will reboot/)
# end
#
# it "sets on s390 systems reboot message if reipl return not different" do
# allow(Yast::Arch).to receive(:s390).and_return(true)
#
# expect(Yast::WFM).to receive(:ClientExists).and_return(true)
# expect(Yast::WFM).to receive(:call).and_return(
# "different" => false,
# "ipl_msg" => ""
# )
#
# Yast.import "Misc"
#
# subject.write
#
# expect(Yast::Misc.boot_msg).to match(/will reboot/)
# end
#
# it "sets on s390 systems shut down message if reipl return different as true" do
# allow(Yast::Arch).to receive(:s390).and_return(true)
#
# expect(Yast::WFM).to receive(:ClientExists).and_return(true)
# expect(Yast::WFM).to receive(:call).and_return(
# "different" => true,
# "ipl_msg" => "message"
# )
#
# Yast.import "Misc"
#
# subject.write
#
# expect(Yast::Misc.boot_msg).to match(/will now shut down/)
# end
#
# context "in Mode update" do
# before do
# Yast.import "Mode"
#
# allow(Yast::Mode).to receive(:update).and_return(true)
# end
#
# it "mount bind /dev" do
# expect(Yast::WFM).to receive(:Execute)
# .with(Yast::Path.new(".local.bash_output"), /mount/)
# .and_return("exit" => 0, "stdout" => "", "stderr" => "")
#
# subject.write
# end
#
# it "calls Bootloader::Update" do
# expect(Yast::Bootloader).to receive(:Update)
#
# subject.write
# end
#
# it "recreate initrd" do
# expect(Yast::SCR).to receive(:Execute).with(anything, "/sbin/mkinitrd")
#
# subject.write
# end
# end
#
# context "other modes" do
# it "calls Bootloader::WriteInstallation" do
# expect(Yast::Bootloader).to receive(:WriteInstallation)
#
# subject.write
# end
#
# it "return false if Bootloader::WriteInstallation failed" do
# expect(Yast::Bootloader).to receive(:WriteInstallation).and_return(false)
#
# expect(subject.write).to eq false
# end
# end
#
# context "grub2 based bootloader" do
# before do
# allow(Yast::Bootloader).to receive(:getLoaderType).and_return("grub2")
# end
#
# it "call first branding activator it found" do
# allow(::Dir).to receive(:[]).and_return(["/mnt/test"])
# allow(Yast::Installation).to receive(:destdir).and_return("/mnt")
#
# expect(Yast::SCR).to receive(:Execute).with(anything, "/test")
#
# subject.write
# end
# end
#
# it "reread configuration" do
# expect(Yast::Bootloader).to receive(:Read)
#
# subject.write
# end
#
# context "when kexec is requested" do
# before do
# allow(Yast::Linuxrc).to receive(:InstallInf).with("kexec_reboot")
# .and_return("1")
# end
#
# it "prepare kexec environment" do
# kexec = double
# expect(kexec).to receive(:prepare_environment)
# allow(::Bootloader::Kexec).to receive(:new).and_return(kexec)
#
# subject.write
# end
# end
#
# context "when kexec is not requested" do
# it "flag for one time boot default section" do
# expect(Yast::Bootloader).to receive(:FlagOnetimeBoot).and_return(true)
#
# subject.write
# end
#
# it "returns false if flagging failed" do
# expect(Yast::Bootloader).to receive(:FlagOnetimeBoot).and_return(false)
#
# expect(subject.write).to eq false
# end
# end
#
# it "return true if everything goes as expect" do
# expect(subject.write).to eq true
# end
# end
# end
#
describe Bootloader::FinishClient do
describe "#write" do
before do
Yast.import "Arch"

allow(Yast::Arch).to receive(:s390).and_return(false)

Bootloader::BootloaderFactory.current_name = "grub2"
@current_bl = Bootloader::BootloaderFactory.current
allow(@current_bl).to receive(:read?).and_return(true)

@system_bl = Bootloader::Grub2.new
allow(Bootloader::BootloaderFactory).to receive(:system).and_return(@system_bl)
allow(@system_bl).to receive(:merge)
allow(@system_bl).to receive(:read)
allow(@system_bl).to receive(:write)

allow(Yast::Execute).to receive(:on_target)
end

it "sets on non-s390 systems reboot message" do
Yast.import "Misc"

subject.write

expect(Yast::Misc.boot_msg).to match(/will reboot/)
end

it "sets on s390 systems reboot message if reipl return not different" do
allow(Yast::Arch).to receive(:s390).and_return(true)

expect(Yast::WFM).to receive(:ClientExists).and_return(true)
expect(Yast::WFM).to receive(:call).and_return(
"different" => false,
"ipl_msg" => ""
)

Yast.import "Misc"

subject.write

expect(Yast::Misc.boot_msg).to match(/will reboot/)
end

it "sets on s390 systems shut down message if reipl return different as true" do
allow(Yast::Arch).to receive(:s390).and_return(true)

expect(Yast::WFM).to receive(:ClientExists).and_return(true)
expect(Yast::WFM).to receive(:call).and_return(
"different" => true,
"ipl_msg" => "message"
)

Yast.import "Misc"

subject.write

expect(Yast::Misc.boot_msg).to match(/will now shut down/)
end

it "runs mkinitrd" do
expect(Yast::Execute).to receive(:on_target).with("/sbin/mkinitrd")

subject.write
end

it "merges system configuration with selected one in installation and set it as current" do
expect(@system_bl).to receive(:merge).with(@current_bl)
expect(::Bootloader::BootloaderFactory).to receive(:current=).with(@system_bl)

subject.write
end

it "writes system configuration" do
expect(@system_bl).to receive(:write)

subject.write
end

it "returns true if everything goes as expect" do
expect(subject.write).to eq true
end

context "in Mode update" do
before do
Yast.import "Mode"

allow(Yast::Mode).to receive(:update).and_return(true)
end

it "does nothing if bootloader config is not read or proposed, so no changes done" do
allow(@current_bl).to receive(:read?).and_return(false)
allow(@current_bl).to receive(:proposed?).and_return(false)

expect(@system_bl).to_not receive(:write)

subject.write
end
end

context "when kexec is requested" do
before do
allow(Yast::Linuxrc).to receive(:InstallInf).with("kexec_reboot")
.and_return("1")
end

it "prepares kexec environment" do
kexec = double
expect(kexec).to receive(:prepare_environment)
allow(::Bootloader::Kexec).to receive(:new).and_return(kexec)

subject.write
end
end
end
end

0 comments on commit 0f6f5cb

Please sign in to comment.