Skip to content

Commit

Permalink
make rubocop happy
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed May 17, 2016
1 parent eb08b20 commit 00ae748
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
32 changes: 17 additions & 15 deletions src/lib/bootloader/grub_install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize(efi: false)
@efi = efi
end

def execute(devices: nil, secure_boot: false, trusted_boot: false)
def execute(devices: [], secure_boot: false, trusted_boot: false)
raise "cannot have secure boot without efi" if secure_boot && !@efi
raise "cannot have trusted boot with efi" if trusted_boot && @efi

Expand All @@ -25,6 +25,18 @@ def execute(devices: nil, secure_boot: false, trusted_boot: false)
cmd << "--directory=/usr/lib/trustedgrub2/#{target}" if trusted_boot
end

cmd << "--no-nvram" << "--removable" if removable_efi?

if no_device_install?
Yast::Execute.on_target(cmd)
else
devices.each { |d| Yast::Execute.on_target(cmd + [d]) }
end
end

private

def removable_efi?
# EFI has 2 boot paths. The default is that there is a target file listed
# in the boot list. The boot list is stored in NVRAM and exposed as
# efivars.
Expand All @@ -43,22 +55,12 @@ def execute(devices: nil, secure_boot: false, trusted_boot: false)
# working NVRAM, we either see no efivars at all (booted via non-EFI entry
# point) or there is no efi variable exposed. Install grub in the
# removable location there.
if @efi && Dir.glob("/sys/firmware/efi/efivars/*").empty?
cmd << "--no-nvram" << "--removable"
end

if devices && !devices.empty?
devices.each do |dev|
Yast::Execute.on_target(cmd + [dev])
end
else
# s390 and efi can install grub2 without device, otherwise user
# intentionally do not want grub2 installed by yast2
Yast::Execute.on_target(cmd) if Yast::Arch.s390 || @efi
end
@efi && Dir.glob("/sys/firmware/efi/efivars/*").empty?
end

private
def no_device_install?
Yast::Arch.s390 || @efi
end

def target
@target ||= case Yast::Arch.architecture
Expand Down
2 changes: 1 addition & 1 deletion src/lib/bootloader/stage1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def merge(other)
log.info "stage1 to merge #{other.inspect}"

if other.devices.empty?
self.activate = activate? || other.activate?
self.activate = activate? || other.activate?
self.generic_mbr = generic_mbr? || other.generic_mbr?
else
clear_devices
Expand Down
2 changes: 1 addition & 1 deletion src/modules/Bootloader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def Import(data)

proposed_configuration = ::Bootloader::BootloaderFactory
.bootloader_by_name(imported_configuration.name)
unless Mode.config # no AutoYaST configuration mode
unless Mode.config # no AutoYaST configuration mode
proposed_configuration.propose
proposed_configuration.merge(imported_configuration)
end
Expand Down

0 comments on commit 00ae748

Please sign in to comment.