Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
gilsonsouza committed Nov 7, 2017
2 parents 20fff38 + 3a3a348 commit 85f182e
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 48 deletions.
22 changes: 20 additions & 2 deletions package/yast2-bootloader.changes
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
-------------------------------------------------------------------
Thu Oct 26 12:51:47 UTC 2017 - gsouza@suse.com
Tue Nov 7 14:25:52 UTC 2017 - gsouza@suse.com

- bsc#1059757: use correct function to detect devices
- bsc#1059757: filter out multipath wires from devices
- 4.0.5

-------------------------------------------------------------------
Tue Nov 7 10:25:47 UTC 2017 - jreidinger@suse.com

- merge SLE12 SP3 fixes:
- Fix detection of upgrade of grub2 (bsc#1059603)
- Fallback to default when default section does not exists. It can
happen during upgrade, when sections are renamed.(bsc#1059603)
- Find correct mbr device to install grub (bsc#1039712,
bsc#1052006)
- 4.0.4

-------------------------------------------------------------------
Fri Nov 3 10:09:39 CET 2017 - schubi@suse.de

- AutoYaST: Do not export stage1 settings anymore (boot_boot,
boot_custom,...) (bnc#1063975)
- 4.0.3

-------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion package/yast2-bootloader.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@


Name: yast2-bootloader
Version: 4.0.3

Version: 4.0.5
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
21 changes: 0 additions & 21 deletions src/lib/bootloader/autoyast_converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def export(config)
res["global"] = {}
global = res["global"]
export_grub2(global, config) if config.name == "grub2"
export_stage1(global, config.stage1) if config.respond_to?(:stage1)
export_default(global, config.grub_default)
# Do not export device map as device name are very unpredictable and is used only as
# work-around when automatic ones do not work for what-ever reasons ( it can really safe
Expand Down Expand Up @@ -195,26 +194,6 @@ def bootloader_from_data(data)
end
end

STAGE1_MAPPING = {
"activate" => :activate?,
"generic_mbr" => :generic_mbr?,
"boot_root" => :root_partition?,
"boot_boot" => :boot_partition?,
"boot_mbr" => :mbr?,
"boot_extended" => :extended_partition?
}.freeze
def export_stage1(res, stage1)
STAGE1_MAPPING.each do |key, method|
res[key] = stage1.public_send(method) ? "true" : "false"
end

# if there is no separated boot, then root and boot partition is same, so in such case
# have only one true there
res["boot_boot"] = "false" if res["boot_root"] == "true" && res["boot_boot"] == "true"

res["boot_custom"] = stage1.custom_devices.join(",") unless stage1.custom_devices.empty?
end

# only for grub2, not for others
GRUB2_BOOLEAN_MAPPING = {
"trusted_grub" => :trusted_boot
Expand Down
27 changes: 19 additions & 8 deletions src/lib/bootloader/proposal_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ def initialize

def make_proposal(attrs)
force_reset = attrs["force_reset"]
storage_read = Yast::BootStorage.storage_read?
storage_changed = Yast::BootStorage.storage_changed?
# clean device cache if storage changed
Yast::BootStorage.reset_disks if storage_changed
log.info "Storage changed: #{storage_changed}"
log.info "Storage changed: #{storage_changed} force_reset #{force_reset}."
log.info "Storage read previously #{storage_read.inspect}"

if reset_needed?(force_reset, storage_changed)
if reset_needed?(force_reset, storage_changed && storage_read)
# force re-calculation of bootloader proposal
# this deletes any internally cached values, a new proposal will
# not be partially based on old data now any more
Expand Down Expand Up @@ -112,9 +112,15 @@ def description
# but only when not using auto_mode
# But if storage changed, always repropose as it can be very wrong.
def reset_needed?(force_reset, storage_changed)
log.info "reset_needed? force_reset: #{force_reset} storage_changed: #{storage_changed}" \
"auto mode: #{Yast::Mode.auto} cfg_changed #{Yast::Bootloader.proposed_cfg_changed}"
return true if storage_changed
return false if Yast::Mode.autoinst || Yast::Mode.autoupgrade
force_reset || !Yast::Bootloader.proposed_cfg_changed
return true if force_reset
# reset when user does not do any change and not in update
return true if !Yast::Mode.update && !Yast::Bootloader.proposed_cfg_changed

false
end

BOOT_SYSCONFIG_PATH = "/etc/sysconfig/bootloader".freeze
Expand All @@ -135,9 +141,8 @@ def old_bootloader

def propose_for_update(force_reset)
current_bl = ::Bootloader::BootloaderFactory.current
if ["grub2", "grub2-efi"].include?(old_bootloader) &&
!current_bl.proposed? &&
!Yast::Bootloader.proposed_cfg_changed

if grub2_update?(current_bl)
log.info "update of grub2, do not repropose"
return false
elsif old_bootloader == "none"
Expand All @@ -162,6 +167,12 @@ def propose_for_update(force_reset)
true
end

def grub2_update?(current_bl)
["grub2", "grub2-efi"].include?(old_bootloader) &&
!current_bl.proposed? &&
!Yast::Bootloader.proposed_cfg_changed
end

def construct_proposal_map
ret = {}

Expand Down
5 changes: 4 additions & 1 deletion src/lib/bootloader/sections.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ def default=(value)
log.info "set new default to '#{value.inspect}'"

# empty value mean no default specified
raise "Unknown value #{value.inspect}" if !all.empty? && !all.include?(value) && !value.empty?
if !all.empty? && !all.include?(value) && !value.empty?
log.warn "Invalid value #{value} trying to set as default. Fallback to default"
value = ""
end

@default = value
end
Expand Down
4 changes: 4 additions & 0 deletions src/modules/BootStorage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ def assign_mbr_disk_by_name(dev_name)
@mbr_disk = staging.disks.find { |d| d.name == dev_name }
end

def storage_read?
!@storage_revision.nil?
end

def gpt_boot_disk?
require "bootloader/bootloader_factory"
current_bl = ::Bootloader::BootloaderFactory.current
Expand Down
18 changes: 6 additions & 12 deletions test/autoyast_converter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,12 @@
bootloader.trusted_boot = true

expected_export = {
"append" => "verbose nomodeset",
"terminal" => "gfxterm",
"os_prober" => "true",
"hiddenmenu" => "true",
"timeout" => 10,
"boot_mbr" => "false",
"boot_boot" => "false",
"boot_extended" => "false",
"boot_root" => "false",
"activate" => "true",
"generic_mbr" => "false",
"trusted_grub" => "true"
"append" => "verbose nomodeset",
"terminal" => "gfxterm",
"os_prober" => "true",
"hiddenmenu" => "true",
"timeout" => 10,
"trusted_grub" => "true"
}

expect(subject.export(bootloader)["global"]).to eq expected_export
Expand Down
2 changes: 1 addition & 1 deletion test/bootloader_proposal_client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@

it "do not resets configuration in automode and even if force_reset passed" do
Yast.import "Mode"
expect(Yast::Mode).to receive(:autoinst).and_return(true)
allow(Yast::Mode).to receive(:autoinst).and_return(true)
expect(Yast::Bootloader).to_not receive(:Reset)

subject.make_proposal("force_reset" => true)
Expand Down
5 changes: 3 additions & 2 deletions test/sections_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@
expect(subject.default).to eq "windows"
end

it "raises exception if section do not exists" do
expect { subject.default = "non-exist" }.to raise_error(RuntimeError)
it "sets default to empty if section do not exists" do
subject.default = "non-exist"
expect(subject.default).to eq ""
end

it "handles localized grub.cfg" do
Expand Down

0 comments on commit 85f182e

Please sign in to comment.