• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yast / yast-installation / 16913068408

12 Aug 2025 03:13PM UTC coverage: 40.949% (+0.02%) from 40.928%
16913068408

push

github

web-flow
Merge pull request #1136 from yast/drop_initviocons

Drop initviocons

4531 of 11065 relevant lines covered (40.95%)

6.37 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

57.14
/src/include/installation/misc.rb
1
# Copyright (c) [2006-2021] SUSE LLC
2
#
3
# All Rights Reserved.
4
#
5
# This program is free software; you can redistribute it and/or modify it
6
# under the terms of version 2 of the GNU General Public License as published
7
# by the Free Software Foundation.
8
#
9
# This program is distributed in the hope that it will be useful, but WITHOUT
10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12
# more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with this program; if not, contact SUSE LLC.
16
#
17
# To contact SUSE LLC about this file by physical or electronic mail, you may
18
# find current contact information at www.suse.com.
19

20
require "shellwords"
1✔
21

22
module Yast
1✔
23
  module InstallationMiscInclude
1✔
24
    def initialize_installation_misc(_include_target)
1✔
25
      Yast.import "UI"
22✔
26

27
      textdomain "installation"
22✔
28

29
      Yast.import "Installation"
22✔
30
      Yast.import "Mode"
22✔
31
      Yast.import "ProductControl"
22✔
32
      Yast.import "ProductFeatures"
22✔
33
      Yast.import "Label"
22✔
34
      Yast.import "FileUtils"
22✔
35
      Yast.import "Linuxrc"
22✔
36
      Yast.import "InstData"
22✔
37
      Yast.import "HTML"
22✔
38

39
      @modules_to_enable_with_AC_on = nil
22✔
40
    end
41

42
    def InjectFile(filename)
1✔
43
      command = "/bin/cp #{filename.shellescape} #{File.join(Installation.destdir,
×
44
        filename).shellescape}"
45
      Builtins.y2milestone("InjectFile: <%1>", filename)
×
46
      Builtins.y2debug("Inject command: #{command}")
×
47
      WFM.Execute(path(".local.bash"), command)
×
48
      nil
×
49
    end
50

51
    def UpdateWizardSteps
1✔
52
      wizard_mode = Mode.mode
×
53
      Builtins.y2milestone("Switching Steps to %1 ", wizard_mode)
×
54

55
      stage_mode = [
56
        { "stage" => "initial", "mode" => wizard_mode },
×
57
        { "stage" => "continue", "mode" => wizard_mode }
58
      ]
59
      Builtins.y2milestone("Updating wizard steps: %1", stage_mode)
×
60

61
      ProductControl.UpdateWizardSteps(stage_mode)
×
62

63
      nil
×
64
    end
65

66
    # Confirm installation or update
67
    #
68
    # @note moved from clients/inst_doit.ycp to fix bug #219097
69
    #
70
    # @return [Booelan] true if the user confirms; false otherwise
71
    def confirmInstallation
1✔
72
      display_info = UI.GetDisplayInfo
2✔
73
      size_x = Builtins.tointeger(Ops.get_integer(display_info, "Width", 800))
2✔
74
      size_y = Builtins.tointeger(Ops.get_integer(display_info, "Height", 600))
2✔
75

76
      # 576x384 support for for ps3
77
      # bugzilla #273147
78
      if Ops.greater_or_equal(size_x, 800) && Ops.greater_or_equal(size_y, 600)
2✔
79
        size_x = 70
2✔
80
        size_y = 18
2✔
81
      else
82
        size_x = 54
×
83
        size_y = 15
×
84
      end
85

86
      UI.OpenDialog(
2✔
87
        VBox(
88
          VSpacing(0.4),
89
          HSpacing(size_x), # force width
90
          HBox(
91
            HSpacing(0.7),
92
            VSpacing(size_y), # force height
93
            RichText(Mode.update ? confirm_update_text : confirm_installation_text),
2✔
94
            HSpacing(0.7)
95
          ),
96
          ButtonBox(
97
            PushButton(
98
              Id(:cancel),
99
              Opt(:cancelButton, :key_F10, :default),
100
              Label.BackButton
101
            ),
102
            PushButton(Id(:ok), Opt(:okButton, :key_F9), confirm_button_label)
103
          )
104
        )
105
      )
106

107
      button = Convert.to_symbol(UI.UserInput)
2✔
108
      UI.CloseDialog
2✔
109

110
      button == :ok
2✔
111
    end
112

113
    # Text for confirmation popup before the installation really starts
114
    #
115
    # @return [String]
116
    def confirm_installation_text
1✔
117
      result = ""
1✔
118

119
      result << HTML.Heading(_("Confirm Installation"))
1✔
120
      result << _("<p>Information required for the base installation is now complete.</p>")
1✔
121
      result << _(
1✔
122
        "<p>If you continue now, partitions on your\n" \
123
        "hard disk will be modified according to the installation settings in the\n" \
124
        "previous dialogs.</p>"
125
      )
126
      result << _(
1✔
127
        "<p>Go back and check the settings if you are unsure.</p>"
128
      )
129
    end
130

131
    # Text for confirmation popup before the update really starts
132
    #
133
    # @return [String]
134
    def confirm_update_text
1✔
135
      result = ""
1✔
136

137
      result << HTML.Heading(_("Confirm Update"))
1✔
138
      result << _("<p>Information required to perform an update is now complete.</p>")
1✔
139
      result << _(
1✔
140
        "\n" \
141
        "<p>If you continue now, data on your hard disk will be overwritten\n" \
142
        "according to the settings in the previous dialogs.</p>"
143
      )
144
      result << _("<p>Go back and check the settings if you are unsure.</p>")
1✔
145
    end
146

147
    # Label for the confirmation button before starting the installation or update process
148
    #
149
    # @return [String]
150
    def confirm_button_label
1✔
151
      Mode.update ? _("Start &Update") : Label.InstallButton
2✔
152
    end
153

154
    # Some client calls have to be called even if using AC
155
    def EnableRequiredModules
1✔
156
      # Lazy init
157
      if @modules_to_enable_with_AC_on.nil?
×
158
        feature = ProductFeatures.GetFeature(
×
159
          "globals",
160
          "autoconfiguration_enabled_modules"
161
        )
162

163
        @modules_to_enable_with_AC_on = if feature == "" || feature.nil? || feature == []
×
164
          []
×
165
        else
166
          Convert.convert(
×
167
            feature,
168
            from: "any",
169
            to:   "list <string>"
170
          )
171
        end
172

173
        Builtins.y2milestone(
×
174
          "Steps to enable with AC in use: %1",
175
          @modules_to_enable_with_AC_on
176
        )
177
      end
178

179
      if !@modules_to_enable_with_AC_on.nil?
×
180
        Builtins.foreach(@modules_to_enable_with_AC_on) do |one_module|
×
181
          ProductControl.EnableModule(one_module)
×
182
        end
183
      end
184

185
      nil
×
186
    end
187

188
    def AdjustStepsAccordingToInstallationSettings
1✔
189
      if Installation.add_on_selected == true ||
×
190
          !Linuxrc.InstallInf("addon").nil?
191
        ProductControl.EnableModule("add-on")
×
192
      else
193
        ProductControl.DisableModule("add-on")
×
194
      end
195

196
      if Installation.productsources_selected == true
×
197
        ProductControl.EnableModule("productsources")
×
198
      else
199
        ProductControl.DisableModule("productsources")
×
200
      end
201

202
      Builtins.y2milestone(
×
203
        "Disabled Modules: %1, Proposals: %2",
204
        ProductControl.GetDisabledModules,
205
        ProductControl.GetDisabledProposals
206
      )
207

208
      UpdateWizardSteps()
×
209

210
      nil
×
211
    end
212

213
    def SetXENExceptions
1✔
214
      # not in text-mode
215
      if !UI.TextMode
×
216
        # bnc #376945
217
        # problems with keyboard in xen
218
        if SCR.Read(path(".probe.xen")) == true
×
219
          Builtins.y2milestone("XEN in X detected: running xset")
×
220
          WFM.Execute(path(".local.bash"), "/usr/bin/xset r off; /usr/bin/xset m 1")
×
221
          # bnc #433338
222
          # enabling key-repeating
223
        else
224
          Builtins.y2milestone("Enabling key-repeating")
×
225
          WFM.Execute(path(".local.bash"), "/usr/bin/xset r on")
×
226
        end
227
      end
228

229
      nil
×
230
    end
231

232
    # Writes to /etc/install.inf whether running the second stage is required
233
    # This is written to inst-sys and not copied to the installed system
234
    # (which is already umounted in that time).
235
    #
236
    # @see BNC #439572
237
    def WriteSecondStageRequired(scst_required)
1✔
238
      # writes 'SecondStageRequired' '1' or '0'
239
      # if such tag exists, it is removed before
240
      WFM.Execute(
5✔
241
        path(".local.bash"),
242
        Builtins.sformat(
243
          "/usr/bin/sed --in-place '/^SecondStageRequired: .*/D' /etc/install.inf; " \
244
          "/usr/bin/echo 'SecondStageRequired: %1' >> /etc/install.inf",
245
          (scst_required == false) ? "0" : "1"
5✔
246
        )
247
      )
248
      # Is it really needed? It will enforce a read of /etc/install.inf from
249
      # any step after resetting it.
250
      Linuxrc.ResetInstallInf
5✔
251

252
      nil
5✔
253
    end
254
  end
255
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc