Class: Yast::YastInfFinishClient
- Inherits:
-
Client
- Object
- Client
- Yast::YastInfFinishClient
- Defined in:
- src/lib/installation/clients/yast_inf_finish.rb
Instance Method Summary collapse
-
#LoadKexec ⇒ Object
fate #303395: Use kexec to avoid booting between first and second stage run new kernel via kexec instead of reboot.
- #main ⇒ Object
Instance Method Details
#LoadKexec ⇒ Object
fate #303395: Use kexec to avoid booting between first and second stage run new kernel via kexec instead of reboot
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'src/lib/installation/clients/yast_inf_finish.rb', line 143 def LoadKexec # command for reading kernel_params cmd = Builtins.sformat("ls '%1/kernel_params' |tr -d '\n'", String.Quote(Directory.vardir)) Builtins.y2milestone("Checking existing file kernel_params via command %1", cmd) out = Convert.to_map(WFM.Execute(path(".local.bash_output"), cmd)) cmd = Builtins.sformat("%1/kernel_params", Directory.vardir) # check output if Ops.get_string(out, "stdout", "") != cmd Builtins.y2milestone("File kernel_params was not found, output: %1", out) return false end # command for reading kernel_params cmd = Builtins.sformat("cat '%1/kernel_params' |tr -d '\n'", String.Quote(Directory.vardir)) Builtins.y2milestone("Reading kernel arguments via command %1", cmd) # read data from /var/lib/YaST2/kernel_params out = Convert.to_map(WFM.Execute(path(".local.bash_output"), cmd)) # check output if Ops.get(out, "exit") != 0 Builtins.y2error("Reading kernel arguments failed, output: %1", out) return false end kernel_args = Ops.get_string(out, "stdout", "") # check if kernel_params contains any data if Ops.less_than(Builtins.size(kernel_args), 2) Builtins.y2error("%1/kernel_params is empty, kernel_params=%2 ", Directory.vardir, kernel_args) return false end # command for finding initrd file cmd = Builtins.sformat("ls %1/initrd-* |tr -d '\n'", Directory.vardir) Builtins.y2milestone("Finding initrd file via command: %1", cmd) # find inird file out = Convert.to_map(WFM.Execute(path(".local.bash_output"), cmd)) # check output if Ops.get(out, "exit") != 0 Builtins.y2error("Finding initrd file failed, output: %1", out) return false end initrd = Ops.get_string(out, "stdout", "") # check if initrd (string) contains any data if Ops.less_than(Builtins.size(initrd), 2) Builtins.y2error("initrd was not found: %1", initrd) return false end # command for finding vmlinuz file cmd = Builtins.sformat("ls %1/vmlinuz-* |tr -d '\n'", Directory.vardir) Builtins.y2milestone("Finding vmlinuz file via command: %1", cmd) # find inird file out = Convert.to_map(WFM.Execute(path(".local.bash_output"), cmd)) # check output if Ops.get(out, "exit") != 0 Builtins.y2error("Finding vmlinuz file failed, output: %1", out) return false end vmlinuz = Ops.get_string(out, "stdout", "") # check if initrd (string) contains any data if Ops.less_than(Builtins.size(vmlinuz), 2) Builtins.y2error("vmlinuz was not found: %1", vmlinuz) return false end # command for calling kexec cmd = Builtins.sformat( "kexec -l --command-line='%1' --initrd='%2' '%3'", String.Quote(kernel_args), String.Quote(initrd), String.Quote(vmlinuz) ) Builtins.y2milestone("Calling kexec via command: %1", cmd) # call kexec out = Convert.to_map(WFM.Execute(path(".local.bash_output"), cmd)) # check output if Ops.get(out, "exit") != 0 Builtins.y2error("Calling kexec failed, output: %1", out) return false end Builtins.y2milestone("Loading new kernel was succesful") true end |
#main ⇒ Object
33 34 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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'src/lib/installation/clients/yast_inf_finish.rb', line 33 def main Yast.import "UI" textdomain "installation" Yast.import "Mode" Yast.import "Linuxrc" Yast.import "AutoinstConfig" Yast.import "Language" Yast.import "Directory" Yast.import "String" Yast.import "Arch" Yast.include self, "installation/misc.rb" @ret = nil @func = "" @param = {} # Check arguments if Ops.greater_than(Builtins.size(WFM.Args), 0) && Ops.is_string?(WFM.Args(0)) @func = Convert.to_string(WFM.Args(0)) if Ops.greater_than(Builtins.size(WFM.Args), 1) && Ops.is_map?(WFM.Args(1)) @param = Convert.to_map(WFM.Args(1)) end end Builtins.y2milestone("starting yast_inf_finish") Builtins.y2debug("func=%1", @func) Builtins.y2debug("param=%1", @param) case @func when "Info" return { "steps" => 1, # progress step title "title" => _("Writing YaST configuration..."), "when" => [:installation, :update, :autoinst] } when "Write" # write boot information for linuxrc # collect data for linuxrc, will be written to /etc/yast.inf @linuxrc = {} # always do hard reboot to ensure that all stuff is initializes # correctly. but no reboot message form linuxrc. Ops.set(@linuxrc, "Root", "reboot") Ops.set(@linuxrc, "RebootMsg", "0") Ops.set(@linuxrc, "Root", "kexec") if LoadKexec() # Override linuxrc settings in autoinst mode if Mode.autoinst if AutoinstConfig.ForceBoot Ops.set(@linuxrc, "Root", "reboot") elsif AutoinstConfig.RebootMsg Ops.set(@linuxrc, "RebootMsg", "1") elsif AutoinstConfig.Halt Ops.set(@linuxrc, "Root", "halt") end end if Ops.get(@linuxrc, "Root", "") == "kexec" # flag for inst_finish -> kerel was successful loaded by kexec @cmd = Builtins.sformat("touch \"%1/kexec_done\"", Directory.vardir) # call command WFM.Execute(path(".local.bash_output"), @cmd) if !UI.TextMode Builtins.y2milestone("Printing message about loading kernel via kexec") SCR.Write( path(".dev.tty.stderr"), _( "\n" \ "**************************************************************\n" \ "\n" \ "Loading installed kernel using kexec.\n" \ "\n" \ "Trying to load installed kernel via kexec instead of rebooting\n" \ "Please, wait.\n" \ "\n" \ "**************************************************************\n" \ "\t\t" ) ) end end Ops.set(@linuxrc, "Language", Language.language) Linuxrc.WriteYaSTInf(@linuxrc) # -------------------------------------------------------------- # Copy blinux configuration InjectFile("/etc/suse-blinux.conf") if Linuxrc.braille else Builtins.y2error("unknown function: %1", @func) @ret = nil end Builtins.y2debug("ret=%1", @ret) Builtins.y2milestone("yast_inf_finish finished") deep_copy(@ret) end |