Class: Bootloader::FinishClient

Inherits:
Installation::FinishClient
  • Object
show all
Includes:
Yast::I18n
Defined in:
src/lib/bootloader/finish_client.rb

Overview

Finish client for bootloader configuration

Constant Summary

BASH_PATH =
Yast::Path.new(".target.bash_output")

Instance Method Summary (collapse)

Constructor Details

- (FinishClient) initialize

Returns a new instance of FinishClient



11
12
13
14
15
16
17
18
19
20
21
# File 'src/lib/bootloader/finish_client.rb', line 11

def initialize
  textdomain "bootloader"

  Yast.import "Arch"
  Yast.import "Bootloader"
  Yast.import "Installation"
  Yast.import "Linuxrc"
  Yast.import "Misc"
  Yast.import "Mode"
  Yast.import "BootCommon"
end

Instance Method Details

- (Object) modes



31
32
33
# File 'src/lib/bootloader/finish_client.rb', line 31

def modes
  [:installation, :live_installation, :update, :autoinst]
end

- (Object) steps



23
24
25
# File 'src/lib/bootloader/finish_client.rb', line 23

def steps
  3
end

- (Object) title



27
28
29
# File 'src/lib/bootloader/finish_client.rb', line 27

def title
  _("Saving bootloader configuration...")
end

- (Object) write



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'src/lib/bootloader/finish_client.rb', line 35

def write
  # provide the /dev content from the inst-sys also inside the chroot of just the upgraded system
  # umount of this bind mount will happen in umount_finish
  update_mount

  # message after first round of packet installation
  # now the installed system is run and more packages installed
  # just warn the user that the screen is going back to text mode
  # and yast2 will come up again.
  set_boot_msg

  retcode = false

  if !Yast::Mode.update
    retcode = Yast::Bootloader.WriteInstallation
  else
    # if we do not read nor propose that we have nothing to do
    if Yast::BootCommon.was_read || Yast::BootCommon.was_proposed
      retcode = Yast::Bootloader.Update
    else
      quick_exit = true
    end

    # workaround for packages that forgot to update initrd(bnc#889616)
    # do not use Initrd module as it can also change configuration, which we do not want
    res = Yast::SCR.Execute(BASH_PATH, "/sbin/mkinitrd")
    log.info "Regerate initrd with result #{res}"

    return true if quick_exit
  end

  # FIXME: workaround grub2 need manual rerun of branding due to overwrite by
  # pbl. see bnc#879686 and bnc#901003
  if Yast::Bootloader.getLoaderType =~ /grub2/
    prefix = Yast::Installation.destdir
    branding_activator = Dir["#{prefix}/usr/share/grub2/themes/*/activate-theme"].first
    if branding_activator
      branding_activator = branding_activator[prefix.size..-1]
      res = Yast::SCR.Execute(BASH_PATH, branding_activator)
      log.info "Reactivate branding with #{branding_activator} and result #{res}"
      res = Yast::SCR.Execute(BASH_PATH, "/usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg")
      log.info "Regenerating config for branding with result #{res}"
    end
  end

  if retcode
    # re-read external changes, then boot through to second stage of
    # installation or update
    Yast::Bootloader.Read
    # fate #303395: Use kexec to avoid booting between first and second stage
    # copy vmlinuz, initrd and flush kernel option into /var/lib/YaST2
    ret = false
    if Yast::Linuxrc.InstallInf("kexec_reboot") == "1"
      kexec = ::Bootloader::Kexec.new
      ret = kexec.prepare_environment
    else
      log.info "Installation started with kexec_reboot set 0"
    end

    # (bnc #381192) don't use it if kexec is used
    # update calling onetime boot bnc #339024
    if !ret
      retcode = Yast::Bootloader.FlagOnetimeBoot(Yast::Bootloader.getDefaultSection)
    end
  end

  retcode
end