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

yast / yast-bootloader / 11682390511

05 Nov 2024 10:36AM UTC coverage: 87.378%. Remained the same
11682390511

Pull #706

github

web-flow
Merge 99cd95a5a into f0d423c7a
Pull Request #706: S390 sec boot master

3226 of 3692 relevant lines covered (87.38%)

13.15 hits per line

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

50.0
/src/lib/bootloader/config_dialog.rb
1
# frozen_string_literal: true
2

3
require "yast"
1✔
4

5
require "bootloader/bootloader_factory"
1✔
6
require "bootloader/none_bootloader"
1✔
7
require "bootloader/grub2_widgets"
1✔
8
require "bootloader/systemdboot_widgets"
1✔
9

10
Yast.import "BootStorage"
1✔
11
Yast.import "CWMTab"
1✔
12
Yast.import "CWM"
1✔
13
Yast.import "Mode"
1✔
14
Yast.import "Popup"
1✔
15

16
module Bootloader
1✔
17
  # Dialog for whole bootloader configuration
18
  class ConfigDialog
1✔
19
    include Yast::Logger
1✔
20
    include Yast::I18n
1✔
21
    include Yast::UIShortcuts
1✔
22

23
    # param initial_tab [:boot_code|:kernel|:bootloader] initial tab when dialog open
24
    def initialize(initial_tab: :boot_code)
1✔
25
      @initial_tab = initial_tab
2✔
26
    end
27

28
    def run
1✔
29
      guarded_run
2✔
30
    rescue ::Bootloader::NoRoot
31
      Yast::Report.Error(
2✔
32
        _("YaST cannot configure the bootloader because it failed to find the root file system.")
33
      )
34
      :abort
2✔
35
    rescue ::Bootloader::BrokenConfiguration, ::Bootloader::UnsupportedOption => e
36
      msg = if e.is_a?(::Bootloader::BrokenConfiguration)
×
37
        # TRANSLATORS: %s stands for readon why yast cannot process it
38
        _("YaST cannot process current bootloader configuration (%s). " \
×
39
          "Propose new configuration from scratch?") % e.reason
40
      else
41
        e.message
×
42
      end
43

44
      ret = Yast::Report.AnyQuestion(_("Unsupported Configuration"),
×
45
        msg,
46
        _("Propose"),
47
        _("Quit"),
48
        :yes) # focus proposing new one
49
      return :abort unless ret
×
50

51
      ::Bootloader::BootloaderFactory.current = ::Bootloader::BootloaderFactory.proposed
×
52
      ::Bootloader::BootloaderFactory.current.propose
×
53

54
      retry
×
55
    end
56

57
  private
1✔
58

59
    def guarded_run
1✔
60
      textdomain "bootloader"
2✔
61

62
      log.info "Running Main Dialog"
2✔
63

64
      # F#300779 - Install diskless client (NFS-root)
65
      # additional warning that root partition is nfs type -> bootloader will not be installed
66
      nfs = Yast::BootStorage.boot_filesystem.is?(:nfs)
2✔
67

68
      if nfs && Yast::Mode.installation
×
69
        Yast::Popup.Message(
×
70
          _(
71
            "The boot partition is of type NFS. Bootloader cannot be installed."
72
          )
73
        )
74
        log.info "Boot partition is nfs type, bootloader will not be installed."
×
75
        return :next
×
76
      end
77
      # F#300779: end
78

79
      Yast::CWM.show(
×
80
        contents,
81
        caption:        _("Boot Loader Settings"),
82
        back_button:    "",
83
        abort_button:   Yast::Label.CancelButton,
84
        next_button:    Yast::Label.OKButton,
85
        skip_store_for: [:redraw]
86
      )
87
    end
88

89
    def contents
1✔
90
      return VBox(LoaderTypeWidget.new) if BootloaderFactory.current.is_a?(NoneBootloader)
×
91

92
      if BootloaderFactory.current.is_a?(SystemdBoot)
×
93
        boot_code_tab = ::Bootloader::SystemdBootWidget::BootCodeTab.new
×
94
        kernel_tab = ::Bootloader::SystemdBootWidget::KernelTab.new
×
95
        bootloader_tab = ::Bootloader::SystemdBootWidget::BootloaderTab.new
×
96
      else
97
        boot_code_tab = ::Bootloader::Grub2Widget::BootCodeTab.new
×
98
        kernel_tab = ::Bootloader::Grub2Widget::KernelTab.new
×
99
        bootloader_tab = ::Bootloader::Grub2Widget::BootloaderTab.new
×
100
      end
101
      case @initial_tab
×
102
      when :boot_code then boot_code_tab.initial = true
×
103
      when :kernel then kernel_tab.initial = true
×
104
      when :bootloader then bootloader_tab.initial = true
×
105
      else
106
        raise "unknown initial tab #{@initial_tab.inspect}"
×
107
      end
108

109
      VBox(CWM::Tabs.new(boot_code_tab, kernel_tab, bootloader_tab))
×
110
    end
111
  end
112
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