Class: Bootloader::Stage1Proposal

Inherits:
Object
  • Object
show all
Includes:
Yast::Logger
Defined in:
src/lib/bootloader/stage1_proposal.rb

Overview

Represents object that can set passed stage1 to proposed values. It is highly coupled with Stage1 class and it is recommended to use Bootloader::Stage1#propose instead of direct usage of this class.

Direct Known Subclasses

PPC, S390, X64

Defined Under Namespace

Classes: PPC, S390, X64

Constant Summary collapse

AVAILABLE_PROPOSALS =

rubocop:disable Style/MutableConstant default_proc conflict

{ # rubocop:disable Style/MutableConstant default_proc conflict
  "i386"    => X64,
  "x86_64"  => X64,
  "s390_32" => S390,
  "s390_64" => S390,
  "ppc"     => PPC,
  "ppc64"   => PPC
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stage1) ⇒ Stage1Proposal (protected)

Returns a new instance of Stage1Proposal.



33
34
35
# File 'src/lib/bootloader/stage1_proposal.rb', line 33

def initialize(stage1)
  @stage1 = stage1
end

Instance Attribute Details

#stage1Object (readonly, protected)

Returns the value of attribute stage1.



31
32
33
# File 'src/lib/bootloader/stage1_proposal.rb', line 31

def stage1
  @stage1
end

Class Method Details

.propose(stage1) ⇒ void

This method returns an undefined value.

Sets passed stage1 to proposed values

Parameters:



20
21
22
23
24
25
26
27
# File 'src/lib/bootloader/stage1_proposal.rb', line 20

def self.propose(stage1)
  arch = Yast::Arch.architecture
  proposal = AVAILABLE_PROPOSALS[arch]

  proposal.new(stage1).propose

  log.info "proposed stage1 configuration #{stage1.inspect}"
end

Instance Method Details

#assign_bootloader_device(selected_location) ⇒ Object (protected)

Set "boot_*" flags in the globals map according to the boot device selected with parameter selected_location. Only a single boot device can be selected with this function. The function cannot be used to set a custom boot device. It will always be deleted.

FIXME: `mbr_md is probably unneeded; AFA we can see, this decision is automatic anyway and perl-Bootloader should be able to make it without help from the user or the proposal.

Parameters:

  • selected_location (Symbol, Array)

    symbol one of :boot, :root, :mbr, :extended, `none or Array with first value :custom and second device for custom devices



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'src/lib/bootloader/stage1_proposal.rb', line 49

def assign_bootloader_device(selected_location)
  log.info "assign bootloader device '#{selected_location.inspect}'"
  # first, default to all off:
  stage1.clear_devices

  case selected_location
  when :boot, :mbr
    method = (selected_location == :mbr) ? :boot_disk_names : :boot_partition_names
    devices = stage1.public_send(method)
    devices.each do |dev|
      stage1.add_udev_device(dev)
    end
  when :none then log.info "Resetting bootloader device"
  when Array
    if selected_location.first != :custom
      raise "Unknown value to select bootloader device #{selected_location.inspect}"
    end

    stage1.model.add_device(selected_location[1]) # add directly proposed value without changes
  else
    raise "Unknown value to select bootloader device #{selected_location.inspect}"
  end
end