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

yast / yast-installation / 8705582428

16 Apr 2024 12:27PM UTC coverage: 40.913% (-0.2%) from 41.105%
8705582428

Pull #1114

github

shundhammer
Version bump and change log
Pull Request #1114: WIP: Handle autoinst AND autoupgrade (bsc#1222153)

0 of 1 new or added line in 1 file covered. (0.0%)

95 existing lines in 13 files now uncovered.

4489 of 10972 relevant lines covered (40.91%)

6.24 hits per line

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

32.52
/src/lib/installation/clients/inst_system_analysis.rb
1
# ------------------------------------------------------------------------------
2
# Copyright (c) 2006-2012 Novell, Inc. All Rights Reserved.
3
#
4
#
5
# This program is free software; you can redistribute it and/or modify it under
6
# the terms of version 2 of the GNU General Public License as published by the
7
# 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 FITNESS
11
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License along with
14
# this program; if not, contact Novell, Inc.
15
#
16
# To contact Novell about this file by physical or electronic mail, you may find
17
# current contact information at www.novell.com.
18
# ------------------------------------------------------------------------------
19

20
# File:  clients/inst_system_analysis.ycp
21
# Package:  Installation
22
# Summary:  Installation mode selection, system analysis
23
# Authors:  Jiri Srain <jsrain@suse.cz>
24
#    Lukas Ocilka <locilka@suse.cz>
25

26
require "yast"
1✔
27
require "y2storage"
1✔
28
require "y2storage/inhibitors"
1✔
29

30
module Yast
1✔
31
  class InstSystemAnalysisClient < Client
1✔
32
    include Yast::Logger
1✔
33

34
    def initialize
1✔
35
      super
6✔
36
      textdomain "installation"
6✔
37
    end
38

39
    def main
1✔
40
      Yast.import "UI"
×
41

42
      # Require here to break dependency cycle (bsc#1070996)
43
      require "autoinstall/activate_callbacks"
×
44

45
      Yast.import "Arch"
×
46
      Yast.import "GetInstArgs"
×
47
      Yast.import "Hotplug"
×
48
      Yast.import "InstData"
×
49
      Yast.import "Kernel"
×
50
      Yast.import "Packages"
×
51
      Yast.import "Popup"
×
52
      Yast.import "Product"
×
53
      Yast.import "ProductFeatures"
×
54
      Yast.import "Progress"
×
55
      Yast.import "Report"
×
56
      Yast.import "Wizard"
×
57
      Yast.import "PackageCallbacks"
×
58

59
      Yast.include self, "installation/misc.rb"
×
60
      Yast.include self, "packager/storage_include.rb"
×
61
      Yast.include self, "packager/load_release_notes.rb"
×
62

63
      # This dialog in not interactive
64
      # always return `back when came from the previous dialog
65
      return :back if GetInstArgs.going_back
×
66

67
      @packager_initialized = false
×
68
      @inhibitors = nil
×
69

70
      Wizard.SetContents(_("Analyzing the Computer"), Empty(), "", false, false)
×
71

72
      # Do hardware probing
73
      #
74
      # This must happen before submodule descriptions are initialized; module
75
      # constructors might depend on it.
76
      # In autoinst mode, this has been called already.
77

78
      actions_todo = []
×
79
      actions_doing = []
×
80
      actions_functions = []
×
81

82
      Builtins.y2milestone("Probing done: %1", Installation.probing_done)
×
83
      # skip part of probes as it doesn't change, but some parts (mostly disks
84
      # that can be activated) need rerun see BNC#865579
85
      if !Installation.probing_done
×
86
        # TRANSLATORS: progress steps in system probing
87
        if !(Arch.s390 || Arch.board_iseries)
×
88
          actions_todo      << _("Probe USB devices")
×
89
          actions_doing     << _("Probing USB devices...")
×
90
          actions_functions << fun_ref(method(:ActionUSB), "boolean ()")
×
91

92
          actions_todo      << _("Probe FireWire devices")
×
93
          actions_doing     << _("Probing FireWire devices...")
×
94
          actions_functions << fun_ref(method(:ActionFireWire), "boolean ()")
×
95
        end
96

97
        WFM.CallFunction("inst_features", [])
×
98
      end
99

100
      actions_todo      << _("Probe hard disks")
×
101
      actions_doing     << _("Probing hard disks...")
×
102
      actions_functions << fun_ref(method(:ActionHDDProbe), "boolean ()")
×
103

104
      # FATE #302980: Simplified user config during installation
105
      actions_todo      << _("Search for system files")
×
106
      actions_doing     << _("Searching for system files...")
×
107
      actions_functions << fun_ref(method(:FilesFromOlderSystems), "boolean ()")
×
108

109
      # skip the repository initialization on both Online and Full medium,
110
      # do it only on the standard medium layout (openSUSE Leap)
111
      skip_software = Mode.update && !Y2Packager::MediumType.standard?
×
112
      # we cannot initialize during update software manager until we know target partition
113
      # as base product is not known
114
      if !skip_software
×
115
        actions_todo      << _("Initialize software manager")
×
116
        actions_doing     << _("Initializing software manager...")
×
117
        actions_functions << fun_ref(method(:InitInstallationRepositories), "boolean ()")
×
118
      end
119

120
      Progress.New(
×
121
        # TRANSLATORS: dialog caption
122
        _("System Probing"),
123
        " ",
124
        actions_todo.size,
125
        actions_todo,
126
        actions_doing,
127
        # TRANSLATORS: dialog help
128
        _("YaST is probing computer hardware and installed systems now.")
129
      )
130

131
      actions_functions.each do |run_function|
×
132
        Progress.NextStage
×
133
        # Bugzilla #298049
134
        # Allow to abort the probing
135
        ui_ret = UI.PollInput
×
136
        if ui_ret == :abort
×
137
          Builtins.y2milestone("Abort pressed")
×
138

139
          if Popup.ConfirmAbort(:painless)
×
140
            Builtins.y2warning("User decided to abort the installation")
×
141
            return :abort
×
142
          end
143
        end
144

UNCOV
145
        begin
×
146
          ret = run_function.call
×
147
          Builtins.y2milestone("Function %1 returned %2", run_function, ret)
×
148
        rescue AbortException
149
          return :abort
×
150
        end
151

152
        # Return in case of restart is needed
153
        return ret if ret == :restart_yast
×
154
      end
155
      Installation.probing_done = true
×
156

157
      Progress.Finish
×
158

159
      return :abort if !skip_software && !@packager_initialized
×
160

161
      :next
×
162
    end
163

164
    # Function definitions -->
165

166
    #  USB initialization
167
    def ActionUSB
1✔
168
      Hotplug.StartUSB
×
169

170
      true
×
171
    end
172

173
    # FireWire (ieee1394) initialization
174
    def ActionFireWire
1✔
175
      Hotplug.StartFireWire
×
176

177
      true
×
178
    end
179

180
    #  Hard disks initialization
181
    #
182
    # @raise [AbortException] if an error is found and the installation must
183
    #   be aborted because of such error
184
    def ActionHDDProbe
1✔
185
      inhibit_storage
6✔
186

187
      init_storage
6✔
188
      devicegraph = storage_manager.probed
4✔
189

190
      # additonal error when HW was not found
191
      drivers_info = _(
4✔
192
        "\nCheck 'drivers.suse.com' if you need specific hardware drivers for installation."
193
      )
194

195
      drivers_info = "" if !ProductFeatures.GetBooleanFeature("globals", "show_drivers_info")
4✔
196

197
      # This error message is only shown when no disks where found during a normal
198
      # installation. The autoinstallation case will be handled later by AutoYaST at
199
      # https://github.com/yast/yast-autoinstallation/blob/8e414637d8157462bee5e1ee29c5d2e747754670/src/modules/AutoinstStorage.rb#L334
200
      if devicegraph.empty? && !Mode.auto
4✔
201
        Report.Error(
1✔
202
          Builtins.sformat(
203
            # TRANSLATORS: Error pop-up
204
            _(
205
              "No hard disks were found for the installation.\n" \
206
              "Please check your hardware!\n" \
207
              "%1\n"
208
            ),
209
            drivers_info
210
          )
211
        )
212

213
        return false
1✔
214
      end
215

216
      true
3✔
217
    end
218

219
    def InitInstallationRepositories
1✔
220
      # disable callbacks
221
      PackageCallbacks.RegisterEmptyProgressCallbacks
×
222

223
      ret = true
×
224

225
      Packages.InitializeCatalogs
×
226

227
      if Packages.InitFailed
×
228
        # popup message
229
        Popup.Message(
×
230
          _("Failed to initialize the software repositories.\nAborting the installation.")
231
        )
232
        ret = false
×
233
      else
234
        @packager_initialized = true
×
235
        Packages.InitializeAddOnProducts
×
236

237
        # bnc#886608: Adjusting product name (for &product; macro) right after we
238
        # initialize libzypp and get the base product name (intentionally not translated)
239
        UI.SetProductName(Product.name || "SUSE Linux")
×
240
      end
241

242
      # reregister callbacks
243
      PackageCallbacks.RestorePreviousProgressCallbacks
×
244

245
      ret
×
246
    end
247

248
    def FilesFromOlderSystems
1✔
249
      # FATE #300421: Import ssh keys from previous installations
250
      # FATE #120103: Import Users From Existing Partition
251
      # FATE #302980: Simplified user config during installation
252
      Builtins.y2milestone("PreInstallFunctions -- start --")
×
253
      WFM.CallFunction("inst_pre_install", [])
×
254
      Builtins.y2milestone("PreInstallFunctions -- end --")
×
255

256
      true
×
257
    end
258

259
  private
1✔
260

261
    # Inhibit various storage features, e.g. MD RAID auto assembly
262
    def inhibit_storage
1✔
263
      return if @inhibitors
6✔
264

265
      @inhibitors = Y2Storage::Inhibitors.new
6✔
266
      @inhibitors.inhibit
6✔
267
    end
268

269
    # Return the activate callbacks for libstorage-ng
270
    #
271
    # When running AutoYaST, it will use a different set of callbacks.
272
    # Otherwise, it just delegates on yast2-storage-ng which callbacks
273
    # to use.
274
    #
275
    # @return [Storage::ActivateCallbacks,nil] Activate callbacks to use
276
    #   or +nil+ for default.
277
    def activate_callbacks
1✔
278
      return nil unless Mode.auto
6✔
279

280
      Y2Autoinstallation::ActivateCallbacks.new
2✔
281
    end
282

283
    # Activates high level devices (RAID, multipath, LVM, encryption...)
284
    # and (re)probes
285
    #
286
    # Reprobing ensures we don't bring bug#806454 back and invalidates cached
287
    # proposal, so we are also safe from bug#865579.
288
    #
289
    # @raise [AbortException] if an error is found and the installation must
290
    #   be aborted because of such error
291
    def init_storage
1✔
292
      success = storage_manager.activate(activate_callbacks)
6✔
293
      success &&= storage_manager.probe
6✔
294
      return if success
6✔
295

296
      log.info "A storage error was raised and the installation must be aborted."
2✔
297
      raise AbortException, "User aborted"
2✔
298
    end
299

300
    # @return [Y2Storage::StorageManager]
301
    def storage_manager
1✔
302
      @storage_manager ||= Y2Storage::StorageManager.instance
15✔
303
    end
304
  end
305
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

© 2025 Coveralls, Inc