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

yast / yast-bootloader / 5783152948

pending completion
5783152948

Pull #683

github

wfeldt
release 6.4.3
Pull Request #683: support 32 bit UEFI firmware on x86_64/i386 architecture (bsc#1208003, jsc#PED-2569)

14 of 14 new or added lines in 4 files covered. (100.0%)

2975 of 3386 relevant lines covered (87.86%)

13.37 hits per line

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

88.0
/src/lib/bootloader/bootloader_factory.rb
1
# frozen_string_literal: true
2

3
require "yast"
1✔
4
require "bootloader/sysconfig"
1✔
5
require "bootloader/none_bootloader"
1✔
6
require "bootloader/grub2"
1✔
7
require "bootloader/grub2efi"
1✔
8
require "bootloader/exceptions"
1✔
9

10
Yast.import "Arch"
1✔
11
Yast.import "Mode"
1✔
12

13
module Bootloader
1✔
14
  # Factory to get instance of bootloader
15
  class BootloaderFactory
1✔
16
    SUPPORTED_BOOTLOADERS = [
1✔
17
      "none", # allows user to manage bootloader itself
18
      "grub2",
19
      "grub2-efi"
20
    ].freeze
21

22
    # Keyword used in autoyast for default bootloader used for given system.
23
    DEFAULT_KEYWORD = "default"
1✔
24

25
    class << self
1✔
26
      include Yast::Logger
1✔
27

28
      attr_writer :current
1✔
29

30
      def proposed
1✔
31
        bootloader_by_name(proposed_name)
×
32
      end
33

34
      def system
1✔
35
        bootloader_by_name(Sysconfig.from_system.bootloader)
16✔
36
      end
37

38
      def current
1✔
39
        @current ||= (system || proposed)
429✔
40
      end
41

42
      def current_name=(name)
1✔
43
        @current = bootloader_by_name(name)
200✔
44
      end
45

46
      def clear_cache
1✔
47
        @cached_bootloaders = nil
178✔
48
      end
49

50
      def supported_names
1✔
51
        if Yast::Mode.config
13✔
52
          # default means bootloader use what it think is the best
53
          return BootloaderFactory::SUPPORTED_BOOTLOADERS + [DEFAULT_KEYWORD]
×
54
        end
55

56
        begin
57
          system_bl = system.name
13✔
58
        # rescue exception if system one is not support
59
        rescue StandardError
60
          system_bl = nil
13✔
61
        end
62
        ret = system_bl ? [system.name] : [] # use current as first
13✔
63
        # grub2 everywhere except aarch64 or riscv64
64
        ret << "grub2" unless Systeminfo.efi_mandatory?
13✔
65
        ret << "grub2-efi" if Systeminfo.efi_supported?
13✔
66
        ret << "none"
13✔
67
        # avoid double entry for selected one
68
        ret.uniq
13✔
69
      end
70

71
      def bootloader_by_name(name)
1✔
72
        # needed to be able to store settings when moving between bootloaders
73
        @cached_bootloaders ||= {}
218✔
74
        case name
218✔
75
        when "grub2"
76
          @cached_bootloaders["grub2"] ||= Grub2.new
184✔
77
        when "grub2-efi"
78
          @cached_bootloaders["grub2-efi"] ||= Grub2EFI.new
12✔
79
        when "none"
80
          @cached_bootloaders["none"] ||= NoneBootloader.new
6✔
81
        when String
82
          raise UnsupportedBootloader, name
1✔
83
        else
84
          log.error "Factory receive nil name"
15✔
85

86
          nil # in other cases it means that read failed
87
        end
88
      end
89

90
    private
1✔
91

92
      def boot_efi?
1✔
93
        Systeminfo.efi?
×
94
      end
95

96
      def proposed_name
1✔
97
        return "grub2-efi" if Systeminfo.efi_mandatory?
×
98

99
        return "grub2-efi" if (Yast::Arch.x86_64 || Yast::Arch.i386) && boot_efi?
×
100

101
        "grub2" # grub2 works(c) everywhere
×
102
      end
103
    end
104
  end
105
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