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

yast / yast-autoinstallation / 13494013411

24 Feb 2025 08:44AM UTC coverage: 69.018% (+0.03%) from 68.993%
13494013411

push

github

web-flow
Merge pull request #881 from yast/merge_SLE-15-SP7

Added pervasive encryption fields (master)

6429 of 9315 relevant lines covered (69.02%)

10.35 hits per line

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

41.99
/src/include/autoinstall/conftree.rb
1
# File:  clients/autoyast.ycp
2
# Summary:  Main file for client call
3
# Authors:  Anas Nashif <nashif@suse.de>
4
#
5
# $Id$
6

7
require "autoinstall/importer"
1✔
8
require "autoinstall/entries/registry"
1✔
9

10
module Yast
1✔
11
  module AutoinstallConftreeInclude
1✔
12
    def initialize_autoinstall_conftree(_include_target)
1✔
13
      textdomain "autoinst"
23✔
14
      Yast.import "HTML"
23✔
15
      Yast.import "XML"
23✔
16
      Yast.import "Call"
23✔
17
      Yast.import "Label"
23✔
18
      Yast.import "Popup"
23✔
19
      Yast.import "Wizard"
23✔
20
      Yast.import "Report"
23✔
21
      Yast.import "AutoinstConfig"
23✔
22
      Yast.import "Profile"
23✔
23
      Yast.import "Mode"
23✔
24
      Yast.import "Stage"
23✔
25
      Yast.import "Icon"
23✔
26
      Yast.import "AutoinstSoftware"
23✔
27

28
      @title = _("Autoinstallation - Configuration")
23✔
29
      @show_source = false
23✔
30
    end
31

32
    def SaveAs
1✔
33
      filename = UI.AskForSaveFileName(
×
34
        AutoinstConfig.Repository,
35
        "*",
36
        _("Save as...")
37
      )
38
      if !filename.nil? && Convert.to_string(filename) != ""
×
39
        AutoinstConfig.currentFile = Convert.to_string(filename)
×
40
        if Profile.Save(AutoinstConfig.currentFile)
×
41
          Popup.Message(
×
42
            Builtins.sformat(
43
              _("File %1 was saved successfully."),
44
              AutoinstConfig.currentFile
45
            )
46
          )
47
          Profile.changed = false
×
48
        else
49
          Popup.Warning(_("An error occurred while saving the file."))
×
50
        end
51
      end
52
      :next
×
53
    end
54

55
    # Creates the group selection box with the specified YaST group selected.
56
    #
57
    # @param [String] selectedGroup The group to select.
58
    # @return The newly created `SelectionBox widget.
59
    def groups(selectedGroup)
1✔
60
      itemList = []
1✔
61
      registry = Y2Autoinstallation::Entries::Registry.instance
1✔
62
      sortedGroups = Builtins.maplist(registry.groups) { |k, _v| k } # keys()
12✔
63
      sortedGroups = Builtins.sort(sortedGroups) do |a, b|
1✔
64
        aa = Builtins.tointeger(
17✔
65
          Ops.get_string(registry.groups, [a, "SortKey"], "500")
66
        )
67
        bb = Builtins.tointeger(
17✔
68
          Ops.get_string(registry.groups, [b, "SortKey"], "500")
69
        )
70
        (aa != bb) ? Ops.less_than(aa, bb) : Ops.less_than(a, b) # by "SortKey" or alphabetical
17✔
71
      end
72

73
      Builtins.foreach(sortedGroups) do |k|
1✔
74
        v = Ops.get(registry.groups, k, {})
11✔
75
        desktop_file = Builtins.substring(
11✔
76
          Ops.get_string(v, "X-SuSE-DocTeamID", ""),
77
          4
78
        )
79
        translation = Builtins.dpgettext(
11✔
80
          "desktop_translations",
81
          "/usr/share/locale/",
82
          Ops.add(
83
            Ops.add(Ops.add("Name(", desktop_file), ".desktop): "),
84
            Ops.get_string(v, "Name", "")
85
          )
86
        )
87
        if translation ==
11✔
88
            Ops.add(
89
              Ops.add(Ops.add("Name(", desktop_file), ".desktop): "),
90
              Ops.get_string(v, "Name", "")
91
            )
92
          translation = Ops.get_string(v, "Name", "")
11✔
93
        end
94
        item = Item(
11✔
95
          Id(k),
96
          term(:icon, Ops.get_string(v, "Icon", "")),
97
          translation,
98
          k == selectedGroup
99
        )
100
        itemList = Builtins.add(itemList, item)
11✔
101
      end
102
      SelectionBox(Id(:groups), Opt(:notify), _("Groups"), itemList)
1✔
103
    end
104

105
    # Creates the modules selection box displaying modules in the specified group.
106
    # The specified YaST module is selected.
107
    #
108
    # @param [String] group_name YaST group of modules to display.
109
    # @param [String] selected_module Module to preselect.
110
    def modules(group_name, selected_module)
1✔
111
      Builtins.y2milestone("group_name: %1", group_name)
1✔
112
      registry = Y2Autoinstallation::Entries::Registry.instance
1✔
113
      items = []
1✔
114
      registry.configurable_descriptions.each do |description|
1✔
115
        # bnc #887115 comment #9: Desktop file is "hidden" and should not be shown at all
116
        next if description.hidden?
10✔
117
        next if description.group != group_name
10✔
118

119
        items << Item(
6✔
120
          Id(description.resource_name),
121
          term(:icon, description.icon),
122
          description.translated_name,
123
          description.resource_name == selected_module
124
        )
125
      end
126
      items << Item(Id("none"), _("No modules available")) if items.empty?
1✔
127
      SelectionBox(Id(:modules), Opt(:notify), _("Modules"), items)
1✔
128
    end
129

130
    # Creates an `HBox containing the buttons to be displayed below the summary column
131
    #
132
    # @return The `HBox widget.
133
    def buttons
1✔
134
      Wizard.HideNextButton
1✔
135
      Wizard.HideBackButton
1✔
136
      Wizard.HideAbortButton
1✔
137
      HBox(
1✔
138
        HSpacing(1),
139
        VBox(
140
          PushButton(Id(:read), _("&Clone")),
141
          PushButton(Id(:writeNow), _("&Apply to System"))
142
        ),
143
        HStretch(),
144
        VBox(
145
          PushButton(Id(:configure), _("&Edit")),
146
          PushButton(Id(:reset), _("Clea&r"))
147
        ),
148
        HSpacing(1)
149
      )
150
    end
151

152
    # Creates a `VBox containg the summary of the specified module and the action buttons below.
153
    #
154
    # @param [String] module_name The module to summarize.
155
    # @return The `VBox widget.
156
    def details(module_name)
1✔
157
      registry = Y2Autoinstallation::Entries::Registry.instance
1✔
158
      description = registry.configurable_descriptions.find { |d| d.resource_name == module_name }
4✔
159
      summary = WFM.CallFunction(description.client_name, ["Summary"]) if description
1✔
160
      summary ||= ""
1✔
161
      VBox(Left(Label(_("Details"))), RichText(summary), buttons)
1✔
162
    end
163

164
    # Sets the high level layout to 3 columns:
165
    #
166
    #  - left:    the YaST groups are displayed in a selection box
167
    #  - middle: the modules of the selected group are displayed in a selection box
168
    #  - right:  the summary of the selected module is displayed, action buttons below
169
    #
170
    # @param [String] preselectedGroup The YaST group to preselect
171
    # @param [String] preselectedModule The module to preselect
172
    def layout(preselectedGroup, preselectedModule)
1✔
173
      HBox(
1✔
174
        HWeight(33, groups(preselectedGroup)),
175
        HWeight(
176
          33,
177
          ReplacePoint(
178
            Id(:rp_modules),
179
            modules(preselectedGroup, preselectedModule)
180
          )
181
        ),
182
        HWeight(33, ReplacePoint(Id(:rp_details), details(preselectedModule)))
183
      )
184
    end
185

186
    # Set the group selection box to the specified YaST group.
187
    #
188
    # @param group_name YaST group to select.
189
    def setGroup(group_name)
1✔
190
      UI.ChangeWidget(Id(:groups), :CurrentItem, group_name)
×
191
      updateModules
×
192

193
      nil
×
194
    end
195

196
    # Get the currently selected YaST group from the selection box widget.
197
    #
198
    # @return The currently selected group.
199
    def getGroup
1✔
200
      Convert.to_string(UI.QueryWidget(Id(:groups), :CurrentItem))
×
201
    end
202

203
    # Get the currently selected Module from the selection box widget.
204
    #
205
    # @return The currently selected module.
206
    def getModule
1✔
207
      Convert.to_string(UI.QueryWidget(Id(:modules), :CurrentItem))
×
208
    end
209

210
    # Updates the action button activation status. (Some modules are not
211
    # clonable, some are not writeable).
212
    #
213
    # @param [String] selectedModule The module to define the button status.
214
    def updateButtons(selectedModule)
1✔
215
      # enable/disable write button
216
      if Builtins.contains(AutoinstConfig.noWriteNow, selectedModule)
1✔
217
        UI.ChangeWidget(Id(:writeNow), :Enabled, false)
×
218
      end
219

220
      if AutoinstConfig.dont_edit.include?(selectedModule)
1✔
221
        UI.ChangeWidget(Id(:configure), :Enabled, false)
×
222
      end
223

224
      # set read button status
225
      registry = Y2Autoinstallation::Entries::Registry.instance
1✔
226
      description = registry.descriptions.find { |d| d.resource_name == selectedModule }
5✔
227
      UI.ChangeWidget(Id(:read), :Enabled, description ? description.clonable? : false)
1✔
228

229
      nil
1✔
230
    end
231

232
    # Set the module selection box to the specified YaST module and
233
    # update the details and group column.
234
    #
235
    # @param [String] module_name The module to select.
236
    def setModule(module_name)
1✔
237
      registry = Y2Autoinstallation::Entries::Registry.instance
×
238
      description = registry.descriptions.find { |d| d.resource_name == module_name }
×
239
      if description
×
240
        group = description.group
×
241
        setGroup(group) if "" != group
×
242
        UI.ChangeWidget(Id(:modules), :CurrentItem, module_name)
×
243
        updateDetails
×
244
      end
245

246
      nil
×
247
    end
248

249
    def updateModules
1✔
250
      selectedGroup = getGroup
×
251
      Builtins.y2milestone("group: %1", selectedGroup)
×
252
      newModules = modules(selectedGroup, "")
×
253
      UI.ReplaceWidget(Id(:rp_modules), newModules)
×
254
      updateDetails
×
255

256
      nil
×
257
    end
258

259
    def updateDetails
1✔
260
      selectedModule = Convert.to_string(
×
261
        UI.QueryWidget(Id(:modules), :CurrentItem)
262
      )
263
      Builtins.y2milestone("module: %1", selectedModule)
×
264
      newDetails = details(selectedModule)
×
265
      UI.ReplaceWidget(Id(:rp_details), newDetails)
×
266
      updateButtons(selectedModule)
×
267

268
      nil
×
269
    end
270

271
    # Reset Configuration
272
    # @param [String] resource Module/Resource to reset
273
    # @return [Object]
274
    def resetModule(resource)
1✔
275
      Builtins.y2debug("resource: %1", resource)
×
276
      registry = Y2Autoinstallation::Entries::Registry.instance
×
277
      description = registry.descriptions.find { |d| d.resource_name == resource }
×
278
      if Builtins.haskey(Profile.current, resource)
×
279
        Profile.current = Builtins.remove(Profile.current, resource)
×
280
      end
281
      WFM.CallFunction(description.client_name, ["Reset"])
×
282

283
      :next
×
284
    end
285

286
    # Read the setting of the specifed module from the current system.
287
    #
288
    # @param [String] module_name The module to read in.
289
    def readModule(module_name)
1✔
290
      registry = Y2Autoinstallation::Entries::Registry.instance
×
291
      description = registry.descriptions.find { |d| d.resource_name == module_name }
×
292
      Call.Function(description.client_name, ["Read"])
×
293
      Call.Function(description.client_name, ["SetModified"])
×
294
      Profile.prepare = true
×
295
      Profile.changed = true
×
296
      true
×
297
    end
298

299
    # Configure module
300
    # @param [String] resource Module/Resource to configure
301
    # @return [Object]
302
    def configureModule(resource)
1✔
303
      registry = Y2Autoinstallation::Entries::Registry.instance
5✔
304
      description = registry.descriptions.find { |d| d.resource_name == resource }
10✔
305

306
      Builtins.y2milestone("Mode::mode %1", Mode.mode)
5✔
307
      original_settings = WFM.CallFunction(description.client_name, ["Export"])
5✔
308
      seq = WFM.CallFunction(description.client_name, ["Change"])
5✔
309
      Builtins.y2milestone("Change response: %1", seq)
5✔
310
      if seq == :accept || seq == :next || seq == :finish
5✔
311
        new_settings = WFM.CallFunction(description.client_name, ["Export"])
4✔
312
        if new_settings.nil?
4✔
313
          Builtins.y2milestone("Importing original settings.")
2✔
314
          Popup.Error(_("The module returned invalid data."))
2✔
315
          WFM.CallFunction(description.client_name, ["Import", original_settings])
2✔
316
          return :abort
2✔
317
        else
318
          Builtins.y2milestone("original=%1", original_settings)
2✔
319
          Builtins.y2milestone("new=%1", new_settings)
2✔
320
          if original_settings != new_settings
2✔
321
            WFM.CallFunction(description.client_name, ["SetModified"])
1✔
322
            Profile.changed = true
1✔
323
            Profile.prepare = true
1✔
324
          end
325
        end
326
      else
327
        WFM.CallFunction(description.client_name, ["Import", original_settings])
1✔
328
      end
329
      deep_copy(seq)
3✔
330
    end
331

332
    # Sets the menus in the wizard.
333
    # @return [void]
334
    def menus
1✔
335
      menu = []
1✔
336
      menu = Wizard.AddMenu(menu, _("&File"), "file-menu")
1✔
337
      menu = Wizard.AddMenu(menu, _("&View"), "view-menu")
1✔
338
      menu = Wizard.AddMenu(menu, _("&Classes"), "class-menu")
1✔
339
      menu = Wizard.AddMenu(menu, _("&Tools"), "tools-menu")
1✔
340

341
      menu = Wizard.AddMenuEntry(menu, "file-menu", _("&New"), "menu_new")
1✔
342
      menu = Wizard.AddMenuEntry(menu, "file-menu", _("&Open"), "menu_open")
1✔
343
      menu = Wizard.AddMenuEntry(menu, "file-menu", _("&Save"), "menu_save")
1✔
344
      menu = Wizard.AddMenuEntry(
1✔
345
        menu,
346
        "file-menu",
347
        _("Save &As"),
348
        "menu_saveas"
349
      )
350
      menu = Wizard.AddMenuEntry(
1✔
351
        menu,
352
        "file-menu",
353
        _("Settin&gs"),
354
        "menu_settings"
355
      )
356
      menu = Wizard.AddMenuEntry(
1✔
357
        menu,
358
        "file-menu",
359
        AutoinstConfig.ProfileEncrypted ? _("Change to Decrypted") : _("Change to Encrypted"),
1✔
360
        "change_encryption"
361
      )
362
      menu = Wizard.AddMenuEntry(
1✔
363
        menu,
364
        "file-menu",
365
        _("Apply Profile to this System"),
366
        "write_to_system"
367
      )
368
      menu = Wizard.AddMenuEntry(menu, "file-menu", _("E&xit"), "menu_exit")
1✔
369
      menu = if @show_source == true
1✔
370
        Wizard.AddMenuEntry(
×
371
          menu,
372
          "view-menu",
373
          _("Configu&ration Tree"),
374
          "menu_tree"
375
        )
376
      else
377
        Wizard.AddMenuEntry(
1✔
378
          menu,
379
          "view-menu",
380
          _("So&urce"),
381
          "menu_source"
382
        )
383
      end
384
      menu = Wizard.AddMenuEntry(
1✔
385
        menu,
386
        "class-menu",
387
        _("Cla&sses"),
388
        "menu_classes"
389
      )
390
      menu = Wizard.AddMenuEntry(
1✔
391
        menu,
392
        "class-menu",
393
        _("Me&rge Classes"),
394
        "menu_merge"
395
      )
396

397
      menu = Wizard.AddMenuEntry(
1✔
398
        menu,
399
        "tools-menu",
400
        _("Create Reference Pro&file"),
401
        "menu_clone"
402
      )
403
      menu = Wizard.AddMenuEntry(
1✔
404
        menu,
405
        "tools-menu",
406
        _("Check &Validity of Profile"),
407
        "menu_valid"
408
      )
409
      Wizard.CreateMenu(menu)
1✔
410
      nil
1✔
411
    end
412

413
    # Create the complete dialog (called in wizard.ycp and in MainDialog())
414
    # @param [String] currentGroup Group to select.
415
    # @param [String] currentModule Module to select.
416
    # @return [void]
417
    def CreateDialog(currentGroup, currentModule)
1✔
418
      currentGroup = "System" if "" == currentGroup || nil == currentGroup
1✔
419
      currentModule = "general" if "" == currentModule || nil == currentModule
1✔
420
      Wizard.SetContents(
1✔
421
        @title,
422
        layout(currentGroup, currentModule),
423
        AutoinstConfig.MainHelp,
424
        true,
425
        true
426
      )
427
      updateButtons(currentModule)
1✔
428
      nil
1✔
429
    end
430

431
    # Show Source
432
    def ShowSource
1✔
433
      Profile.Prepare
2✔
434
      begin
435
        source = XML.YCPToXMLString(:profile, Profile.current)
2✔
436
      rescue XMLSerializationError => e
437
        Builtins.y2error "Creation of XML failed with #{e.inspect}"
1✔
438
        Popup.Error(
1✔
439
          _("An error occurred while creating XML Sources.")
440
        )
441
        source = ""
1✔
442
      end
443

444
      sourceView = RichText(Id(:class_source), Opt(:plainText), source)
2✔
445

446
      Wizard.SetTitleIcon("autoyast")
2✔
447
      Wizard.SetContents(
2✔
448
        _("Source"),
449
        sourceView,
450
        AutoinstConfig.MainHelp,
451
        true,
452
        true
453
      )
454
      nil
2✔
455
    end
456

457
    # Menu interface
458
    #
459
    # @return [Symbol]
460
    def MainDialog
1✔
461
      icons = {}
×
462
      Ops.set(icons, "Net_advanced", "network_advanced")
×
463
      ret = nil
×
464
      currentGroup = "System"
×
465
      currentModule = "general"
×
466

467
      loop do
×
468
        if AutoinstConfig.runModule == ""
×
469
          event = UI.WaitForEvent
×
470
          ret = Ops.get(event, "ID")
×
471
        else
472
          ret = :configure
×
473
          setModule(AutoinstConfig.runModule)
×
474
        end
475
        AutoinstConfig.runModule = ""
×
476
        case ret
×
477
        when :groups
478
          updateModules
×
479
        when :modules
480
          updateDetails
×
481
        when :configure
482
          currentGroup = getGroup
×
483
          currentModule = getModule
×
484
          Builtins.y2debug("configure module: %1", currentModule)
×
485
          if currentModule != ""
×
486
            configret = configureModule(currentModule)
×
487
            Builtins.y2debug("configureModule ret : %1", configret)
×
488
            # Some configuration modules removes/exchange the menu bar.
489
            # So we have to reset. (bnc#872711)
490
            Wizard.DeleteMenus
×
491
            menus
×
492
            CreateDialog(currentGroup, currentModule)
×
493
          end
494
        when :reset
495
          Profile.prepare = true
×
496
          Builtins.y2debug("reset")
×
497
          currentGroup = getGroup
×
498
          currentModule = getModule
×
499
          Builtins.y2debug("reset module: %1", currentModule)
×
500
          if currentModule != ""
×
501
            configret = resetModule(currentModule)
×
502
            Builtins.y2debug("resetModule ret : %1", configret)
×
503
            CreateDialog(currentGroup, currentModule)
×
504
          end
505
        when :writeNow
506
          modulename = getModule
×
507
          if modulename != ""
×
508
            registry = Y2Autoinstallation::Entries::Registry.instance
×
509
            description = registry.descriptions.find { |d| d.resource_name == modulename }
×
510
            if Popup.YesNo(
×
511
              Builtins.sformat(
512
                _(
513
                  "Do you really want to apply the settings of the module '%1' " \
514
                  "to your current system?"
515
                ),
516
                modulename
517
              )
518
            )
519
              oldMode = Mode.mode
×
520
              # The settings will be written in a running system.
521
              # So we are switching to "normal" mode. (bnc#909223)
522
              Mode.SetMode("normal")
×
523

524
              Call.Function(description.client_name, ["Write"])
×
525
              Mode.SetMode(oldMode)
×
526
            end
527
          end
528
        when :read
529
          currentGroup = getGroup
×
530
          currentModule = getModule
×
531
          resetModule(currentModule)
×
532
          readModule(currentModule)
×
533
          if UI.WidgetExists(Id(:rp_details))
×
534
            # if dialog didn't replace wizard contents this is enough
535
            updateDetails
×
536
          else
537
            # otherwise we have to rebuild the complete wizard
538
            CreateDialog(currentGroup, currentModule)
×
539
          end
540
        when "menu_tree" # source -> tree
541
          Builtins.y2debug("change to tree")
×
542
          @show_source = false
×
543
          Wizard.DeleteMenus # FIXME: sucks sucks sucks sucks sucks
×
544
          menus
×
545
          CreateDialog(currentGroup, currentModule)
×
546
        when "menu_open" # OPEN
547
          filename = UI.AskForExistingFile(
×
548
            AutoinstConfig.Repository,
549
            "*",
550
            _("Select a file to load.")
551
          )
552
          if filename != "" && !filename.nil?
×
553
            AutoinstConfig.currentFile = Convert.to_string(filename)
×
554

555
            readOkay = Profile.ReadXML(Convert.to_string(filename))
×
556
            Builtins.y2debug("Profile::ReadXML returned %1", readOkay)
×
557
            if readOkay
×
558
              Popup.ShowFeedback(
×
559
                _("Reading configuration data"),
560
                _("This may take a while")
561
              )
562
              Y2Autoinstallation::Importer.new(Profile.current).import_sections
×
563
              Popup.ClearFeedback
×
564
              Wizard.DeleteMenus # FIXME: sucks sucks sucks sucks sucks
×
565
              menus
×
566
            else
567
              # opening/parsing the xml file failed
568
              Popup.Error(
×
569
                _("An error occurred while opening/parsing the XML file.")
570
              )
571
              Profile.Reset
×
572
            end
573
          end
574
          if UI.WidgetExists(Id(:class_source))
×
575
            ShowSource()
×
576
          else
577
            group = getGroup
×
578
            modulename = getModule
×
579

580
            if group != ""
×
581
              contents = layout(group, modulename)
×
582
              caption = @title
×
583
              currentFile = AutoinstConfig.currentFile
×
584
              currentFile = Builtins.substring(
×
585
                currentFile,
586
                Ops.add(Builtins.findlastof(currentFile, "/"), 1)
587
              )
588
              if Ops.greater_than(Builtins.size(currentFile), 0)
×
589
                caption = Ops.add(Ops.add(caption, " - "), currentFile)
×
590
              end
591
              Wizard.SetContents(
×
592
                caption,
593
                contents,
594
                AutoinstConfig.MainHelp,
595
                true,
596
                true
597
              )
598
              Wizard.SetTitleIcon(
×
599
                Ops.get_string(icons, group, Builtins.tolower(group))
600
              )
601
              updateButtons(modulename)
×
602
            end
603
          end
604
          ret = :menu_open
×
605
        when "menu_source" # Show SOURCE
606
          # save previously selected group and module,
607
          # so we can restore them afterwards
608
          @show_source = true
×
609
          Wizard.DeleteMenus # FIXME: sucks sucks sucks sucks sucks
×
610
          menus
×
611
          currentGroup = getGroup
×
612
          currentModule = getModule
×
613
          ShowSource()
×
614
          ret = :menu_source
×
615
        when "menu_save" # SAVE
616
          if AutoinstConfig.currentFile == ""
×
617
            filename = UI.AskForSaveFileName(
×
618
              AutoinstConfig.Repository,
619
              "*",
620
              _("Save as...")
621
            )
622
            if filename.nil?
×
623
              next
×
624
            else
625
              AutoinstConfig.currentFile = Convert.to_string(filename)
×
626
            end
627
          end
628

629
          if Profile.Save(AutoinstConfig.currentFile)
×
630
            Popup.Message(
×
631
              Builtins.sformat(
632
                _("File %1 was saved successfully."),
633
                AutoinstConfig.currentFile
634
              )
635
            )
636
            Profile.changed = false
×
637
          else
638
            Popup.Warning(_("An error occurred while saving the file."))
×
639
          end
640
          ret = :menu_save
×
641
        when "menu_saveas" # SAVE AS
642
          SaveAs()
×
643
          ret = :menu_saveas
×
644
        when "menu_new" # NEW
645
          Profile.Reset
×
646
          registry = Y2Autoinstallation::Entries::Registry.instance
×
647
          registry.descriptions.each { |d| resetModule(d.resource_name) }
×
648
          AutoinstConfig.currentFile = ""
×
649
          ShowSource() if UI.WidgetExists(Id(:class_source))
×
650
          group = getGroup
×
651
          module_name = getModule
×
652
          Wizard.SetContents(
×
653
            _("Available Modules"),
654
            layout(group, module_name),
655
            AutoinstConfig.MainHelp,
656
            true,
657
            true
658
          )
659
          updateButtons(module_name)
×
660
          ret = :menu_new
×
661
        when "change_encryption"
662
          AutoinstConfig.ProfileEncrypted = !AutoinstConfig.ProfileEncrypted
×
663
          AutoinstConfig.ProfilePassword = ""
×
664
          Wizard.DeleteMenus # FIXME: sucks sucks sucks sucks sucks
×
665
          menus
×
666
        when "write_to_system"
667
          if Popup.YesNo(
×
668
            _(
669
              "Do you really want to apply the settings of the profile to your current system?"
670
            )
671
          )
672
            Profile.Prepare
×
673
            oldMode = Mode.mode
×
674
            oldStage = Stage.stage
×
675
            Mode.SetMode("autoinstallation")
×
676
            Stage.Set("continue")
×
677

678
            WFM.CallFunction("inst_autopost", [])
×
679
            AutoinstSoftware.addPostPackages(
×
680
              Ops.get_list(Profile.current, ["software", "post-packages"], [])
681
            )
682

683
            # the following is needed since 10.3
684
            # otherwise the already configured network gets removed
685
            if !Builtins.haskey(Profile.current, "networking")
×
686
              Profile.current = Builtins.add(
×
687
                Profile.current,
688
                "networking",
689
                "keep_install_network" => true
690
              )
691
            end
692

693
            Pkg.TargetInit("/", false)
×
694
            WFM.CallFunction("inst_rpmcopy", [])
×
695
            WFM.CallFunction("inst_autoconfigure", [])
×
696
            Mode.SetMode(oldMode)
×
697
            Stage.Set(oldStage)
×
698
          end
699
        when "menu_exit", :cancel # EXIT
700
          ret = :menu_exit
×
701
          if Profile.changed
×
702
            current = if AutoinstConfig.currentFile == ""
×
703
              "Untitled"
×
704
            else
705
              AutoinstConfig.currentFile
×
706
            end
707

708
            answer = Popup.AnyQuestion(
×
709
              _("Control file changed."),
710
              Builtins.sformat(_("Save the changes to %1?"), current),
711
              Label.YesButton,
712
              Label.NoButton,
713
              :focus_yes
714
            )
715
            SaveAs() if true == answer
×
716
          end
717
          break
×
718
        else
719
          s = Builtins.toterm(ret)
×
720
          ret = Builtins.symbolof(s)
×
721
          break
×
722
        end
723
      end
724
      Convert.to_symbol(ret)
×
725
    end
726
  end
727
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