Class: Installation::ProposalRunner

Inherits:
Object
  • Object
show all
Includes:
UI::TextHelpers, Yast::I18n, Yast::Logger, Yast::UIShortcuts
Defined in:
src/lib/installation/proposal_runner.rb

Overview

Create and display reasonable proposal for basic installation and call sub-workflows as required on user request.

See ProposalClient from yast2 for API overview

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(store = ::Installation::ProposalStore) ⇒ ProposalRunner

Returns a new instance of ProposalRunner.



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
77
# File 'src/lib/installation/proposal_runner.rb', line 42

def initialize(store = ::Installation::ProposalStore)
  Yast.import "Pkg"
  Yast.import "UI"
  textdomain "installation"

  Yast.import "Label"
  Yast.import "Mode"
  Yast.import "Stage"
  Yast.import "AutoinstConfig"
  Yast.import "AutoinstFunctions"
  Yast.import "Wizard"
  Yast.import "HTML"
  Yast.import "Popup"
  Yast.import "Language"
  Yast.import "GetInstArgs"
  Yast.import "ProductControl"
  Yast.import "HTML"
  Yast.import "Packages"
  Yast.import "Report"
  Yast.import "UI"

  # values used in defined functions

  @submodules_presentation = []
  @mod2tab = {} # module -> tab it is in
  @current_tab = 0 # ID of current tab
  @html = {} # proposals of all modules - HTML part
  @have_blocker = false

  # BNC #463567
  @submods_already_called = []
  # NOTE: it would be better to receive the object already initialized. Why? Because if it
  # needs some argument, we do not know how to handle it.
  @store_class = store
  @errors = ProposalErrors.new
end

Class Method Details

.runObject



38
39
40
# File 'src/lib/installation/proposal_runner.rb', line 38

def self.run
  new.run
end

Instance Method Details

#runObject



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'src/lib/installation/proposal_runner.rb', line 79

def run
  if Yast::Mode.auto
    # Checking if second stage is needed and the environment has been setup.
    second_stage_error = Yast::AutoinstFunctions.check_second_stage_environment

    if Yast::AutoinstConfig.Confirm
      # This string will be shown in the proposal overview
      Yast::AutoinstData.autoyast_second_stage_error = second_stage_error
    else
      # Checking if vnc, ssh,... is available
      error_message = Yast::Packages.check_remote_installation_packages
      # Fit to the given UI
      displayinfo = Yast::UI.GetDisplayInfo || {}
      width = displayinfo["TextMode"] ? displayinfo.fetch("Width", 80) : 80
      unless error_message.empty?
        Yast::Report.Warning(wrap_text(error_message,
          width - 4))
      end
      unless second_stage_error.empty?
        Yast::Report.Warning(wrap_text(second_stage_error,
          width - 4))
      end
      # skip if not interactive mode.
      return :auto
    end
  end

  log.info "Installation step #2"
  @proposal_mode = Yast::GetInstArgs.proposal

  return :auto if Yast::ProductControl.GetDisabledProposals.include?(@proposal_mode)

  @store = @store_class.new(@proposal_mode)

  build_dialog

  #
  # Get submodule descriptions
  #
  proposal_result = load_matching_submodules_list
  return :abort if proposal_result == :abort

  Yast::UI.ChangeWidget(Id(:menu_dummy), :Enabled, false) if Yast::UI.TextMode
  richtext_busy_cursor(Id(:proposal))

  # The "next" button is disabled via Wizard::SetContents() until everything is set up allright
  Yast::Wizard.EnableNextButton
  Yast::Wizard.EnableAbortButton

  return :auto if !submod_descriptions_and_build_menu

  # Default language is the most often set by language proposal later in the workflow
  # and overwrites this.
  # However, some products do not contain such proposal (e.g. CaaSP) and needs this
  # setup to avoid false language change detection (e.g. in software proposal)
  Yast::Pkg.SetPackageLocale(Yast::Language.language)

  #
  # Make the initial proposal
  #
  make_proposal(false, false)

  # Set keyboard focus to the [Install] / [Update] or [Next] button
  Yast::Wizard.SetFocusToNextButton

  input_loop
end