Class: Bootloader::ProposalClient

Inherits:
Installation::ProposalClient
  • Object
show all
Includes:
Yast::I18n, Yast::Logger
Defined in:
src/lib/bootloader/proposal_client.rb

Overview

Proposal client for bootloader configuration

Constant Summary

[
  "enable_boot_mbr",
  "disable_boot_mbr",
  "enable_boot_root",
  "disable_boot_root",
  "enable_boot_boot",
  "disable_boot_boot"
].freeze

Instance Method Summary (collapse)

Constructor Details

- (ProposalClient) initialize

Returns a new instance of ProposalClient



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'src/lib/bootloader/proposal_client.rb', line 12

def initialize
  Yast.import "UI"
  textdomain "bootloader"

  Yast.import "Arch"
  Yast.import "BootStorage"
  Yast.import "Bootloader"
  Yast.import "Installation"
  Yast.import "Storage"
  Yast.import "Mode"
  Yast.import "BootSupportCheck"
  Yast.import "Product"
  Yast.import "PackagesProposal"
end

Instance Method Details

- (Object) ask_user(param)



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'src/lib/bootloader/proposal_client.rb', line 78

def ask_user(param)
  chosen_id = param["chosen_id"]
  result = :next
  log.info "ask user called with #{chosen_id}"

  # enable boot from MBR
  case chosen_id
  when *PROPOSAL_LINKS
    value = chosen_id =~ /enable/ ? true : false
    option = chosen_id[/(enable|disable)_boot_(.*)/, 2]
    single_click_action(option, value)
  else
    settings = Yast::Bootloader.Export
    result = ::Bootloader::MainDialog.new.run_auto
    if result != :next
      Yast::Bootloader.Import(settings)
    else
      Yast::Bootloader.proposed_cfg_changed = true
    end
  end
  # Fill return map
  { "workflow_sequence" => result }
end

- (Object) description



102
103
104
105
106
107
108
109
110
# File 'src/lib/bootloader/proposal_client.rb', line 102

def description
  {
    # proposal part - bootloader label
    "rich_text_title" => _("Booting"),
    # menubutton entry
    "menu_title"      => _("&Booting"),
    "id"              => "bootloader_stuff"
  }
end

- (Object) make_proposal(attrs)



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'src/lib/bootloader/proposal_client.rb', line 36

def make_proposal(attrs)
  force_reset = attrs["force_reset"]
  storage_changed = Yast::BootStorage.storage_changed?
  storage_read = Yast::BootStorage.storage_read?
  # redetect disks if cache is invalid as first part
  Yast::BootStorage.detect_disks if 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 && 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
    log.info "Recalculation of bootloader configuration"
    Yast::Bootloader.Reset
  end

  if Yast::Mode.update
    return { "raw_proposal" => [_("do not change")] } unless propose_for_update(force_reset)
  elsif Yast::Bootloader.proposed_cfg_changed
    # do nothing as user already modify it
  else
    # in installation always propose missing stuff
    # current below use proposed value if not already set
    # If set, then use same bootloader, but propose it again
    bl = ::Bootloader::BootloaderFactory.current
    bl.propose
  end

  bl = ::Bootloader::BootloaderFactory.current
  log.info "propose to install #{bl.packages}"
  Yast::PackagesProposal.AddResolvables("yast2-bootloader", :package, bl.packages)

  construct_proposal_map
rescue ::Bootloader::NoRoot
  {
    "label_proposal" => [],
    "warning_level"  => :fatal,
    "warning"        => _("Cannot detect device mounted as root. Please check partitioning.")
  }
end