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

yast / yast-installation / 8705582428

16 Apr 2024 12:27PM UTC coverage: 40.913% (-0.2%) from 41.105%
8705582428

Pull #1114

github

shundhammer
Version bump and change log
Pull Request #1114: WIP: Handle autoinst AND autoupgrade (bsc#1222153)

0 of 1 new or added line in 1 file covered. (0.0%)

95 existing lines in 13 files now uncovered.

4489 of 10972 relevant lines covered (40.91%)

6.24 hits per line

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

0.0
/src/lib/installation/clients/yast_inf_finish.rb
1
# ------------------------------------------------------------------------------
2
# Copyright (c) 2006-2012 Novell, Inc. All Rights Reserved.
3
#
4
#
5
# This program is free software; you can redistribute it and/or modify it under
6
# the terms of version 2 of the GNU General Public License as published by the
7
# Free Software Foundation.
8
#
9
# This program is distributed in the hope that it will be useful, but WITHOUT
10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License along with
14
# this program; if not, contact Novell, Inc.
15
#
16
# To contact Novell about this file by physical or electronic mail, you may find
17
# current contact information at www.novell.com.
18
# ------------------------------------------------------------------------------
19

20
# File:
21
#  yast_inf_finish.ycp
22
#
23
# Module:
24
#  Step of base installation finish
25
#
26
# Authors:
27
#  Jiri Srain <jsrain@suse.cz>
28
#
29
# $Id$
30
#
31
module Yast
×
32
  class YastInfFinishClient < Client
×
33
    def main
×
34
      Yast.import "UI"
×
35

36
      textdomain "installation"
×
37

38
      Yast.import "Mode"
×
39
      Yast.import "Linuxrc"
×
40
      Yast.import "AutoinstConfig"
×
41
      Yast.import "Language"
×
42
      Yast.import "Directory"
×
43
      Yast.import "String"
×
44
      Yast.import "Arch"
×
45

46
      Yast.include self, "installation/misc.rb"
×
47

48
      @ret = nil
×
49
      @func = ""
×
50
      @param = {}
×
51

52
      # Check arguments
53
      if Ops.greater_than(Builtins.size(WFM.Args), 0) &&
×
54
          Ops.is_string?(WFM.Args(0))
×
55
        @func = Convert.to_string(WFM.Args(0))
×
56
        if Ops.greater_than(Builtins.size(WFM.Args), 1) &&
×
57
            Ops.is_map?(WFM.Args(1))
×
58
          @param = Convert.to_map(WFM.Args(1))
×
59
        end
×
60
      end
×
61

62
      Builtins.y2milestone("starting yast_inf_finish")
×
63
      Builtins.y2debug("func=%1", @func)
×
64
      Builtins.y2debug("param=%1", @param)
×
65

66
      case @func
×
67
      when "Info"
×
68
        return {
×
69
          "steps" => 1,
×
70
          # progress step title
71
          "title" => _("Writing YaST configuration..."),
×
72
          "when"  => [:installation, :update, :autoinst]
×
73
        }
×
74
      when "Write"
×
75
        # write boot information for linuxrc
76
        # collect data for linuxrc, will be written to /etc/yast.inf
77
        @linuxrc = {}
×
78

79
        # always do hard reboot to ensure that all stuff is initializes
80
        # correctly. but no reboot message form linuxrc.
81
        Ops.set(@linuxrc, "Root", "reboot")
×
82
        Ops.set(@linuxrc, "RebootMsg", "0")
×
83

84
        Ops.set(@linuxrc, "Root", "kexec") if LoadKexec()
×
85

86
        # Override linuxrc settings in autoinst mode
NEW
87
        if Mode.auto
×
88
          if AutoinstConfig.ForceBoot
×
89
            Ops.set(@linuxrc, "Root", "reboot")
×
90
          elsif AutoinstConfig.RebootMsg
×
91
            Ops.set(@linuxrc, "RebootMsg", "1")
×
92
          elsif AutoinstConfig.Halt
×
93
            Ops.set(@linuxrc, "Root", "halt")
×
94
          end
×
95
        end
×
96

97
        if Ops.get(@linuxrc, "Root", "") == "kexec"
×
98
          # flag for inst_finish -> kerel was successful loaded by kexec
99
          @cmd = Builtins.sformat("touch \"%1/kexec_done\"", Directory.vardir)
×
100
          # call command
101
          WFM.Execute(path(".local.bash_output"), @cmd)
×
102
          if !UI.TextMode
×
103
            Builtins.y2milestone("Printing message about loading kernel via kexec")
×
104
            SCR.Write(
×
105
              path(".dev.tty.stderr"),
×
106
              _(
×
107
                "\n" \
×
108
                "**************************************************************\n" \
×
109
                "\n" \
×
110
                "Loading installed kernel using kexec.\n" \
×
111
                "\n" \
×
112
                "Trying to load installed kernel via kexec instead of rebooting\n" \
×
113
                "Please, wait.\n" \
×
114
                "\n" \
×
115
                "**************************************************************\n" \
×
116
                "\t\t"
×
117
              )
×
118
            )
×
119
          end
×
120
        end
×
121

122
        Ops.set(@linuxrc, "Language", Language.language)
×
123

124
        Linuxrc.WriteYaSTInf(@linuxrc)
×
125

126
        # --------------------------------------------------------------
127
        # Copy blinux configuration
128

129
        InjectFile("/etc/suse-blinux.conf") if Linuxrc.braille
×
130
      else
×
131
        Builtins.y2error("unknown function: %1", @func)
×
132
        @ret = nil
×
133
      end
×
134

135
      Builtins.y2debug("ret=%1", @ret)
×
136
      Builtins.y2milestone("yast_inf_finish finished")
×
137
      deep_copy(@ret)
×
138
    end
×
139

140
    # fate #303395: Use kexec to avoid booting between first and second stage
141
    # run new kernel via kexec instead of reboot
142

143
    def LoadKexec
×
144
      # command for reading kernel_params
145
      cmd = Builtins.sformat("ls '%1/kernel_params' |tr -d '\n'", String.Quote(Directory.vardir))
×
146
      Builtins.y2milestone("Checking existing file kernel_params via command %1", cmd)
×
147

148
      out = Convert.to_map(WFM.Execute(path(".local.bash_output"), cmd))
×
149

150
      cmd = Builtins.sformat("%1/kernel_params", Directory.vardir)
×
151
      # check output
152
      if Ops.get_string(out, "stdout", "") != cmd
×
153
        Builtins.y2milestone("File kernel_params was not found, output: %1", out)
×
154
        return false
×
155
      end
×
156

157
      # command for reading kernel_params
158
      cmd = Builtins.sformat("cat '%1/kernel_params' |tr -d '\n'", String.Quote(Directory.vardir))
×
159
      Builtins.y2milestone("Reading kernel arguments via command %1", cmd)
×
160
      # read data from /var/lib/YaST2/kernel_params
161
      out = Convert.to_map(WFM.Execute(path(".local.bash_output"), cmd))
×
162
      # check output
163
      if Ops.get(out, "exit") != 0
×
164
        Builtins.y2error("Reading kernel arguments failed, output: %1", out)
×
165
        return false
×
166
      end
×
167

168
      kernel_args = Ops.get_string(out, "stdout", "")
×
169
      # check if kernel_params contains any data
170
      if Ops.less_than(Builtins.size(kernel_args), 2)
×
171
        Builtins.y2error("%1/kernel_params is empty, kernel_params=%2 ", Directory.vardir,
×
172
          kernel_args)
×
173
        return false
×
174
      end
×
175

176
      # command for finding initrd file
177
      cmd = Builtins.sformat("ls %1/initrd-* |tr -d '\n'", Directory.vardir)
×
178
      Builtins.y2milestone("Finding initrd file via command: %1", cmd)
×
179
      # find inird file
180
      out = Convert.to_map(WFM.Execute(path(".local.bash_output"), cmd))
×
181
      # check output
182
      if Ops.get(out, "exit") != 0
×
183
        Builtins.y2error("Finding initrd file failed, output: %1", out)
×
184
        return false
×
185
      end
×
186

187
      initrd = Ops.get_string(out, "stdout", "")
×
188
      # check if initrd (string) contains any data
189
      if Ops.less_than(Builtins.size(initrd), 2)
×
190
        Builtins.y2error("initrd was not found: %1", initrd)
×
191
        return false
×
192
      end
×
193

194
      # command for finding vmlinuz file
195
      cmd = Builtins.sformat("ls %1/vmlinuz-* |tr -d '\n'", Directory.vardir)
×
196
      Builtins.y2milestone("Finding vmlinuz file via command: %1", cmd)
×
197
      # find inird file
198
      out = Convert.to_map(WFM.Execute(path(".local.bash_output"), cmd))
×
199
      # check output
200
      if Ops.get(out, "exit") != 0
×
201
        Builtins.y2error("Finding vmlinuz file failed, output: %1", out)
×
202
        return false
×
203
      end
×
204

205
      vmlinuz = Ops.get_string(out, "stdout", "")
×
206
      # check if initrd (string) contains any data
207
      if Ops.less_than(Builtins.size(vmlinuz), 2)
×
208
        Builtins.y2error("vmlinuz was not found: %1", vmlinuz)
×
209
        return false
×
210
      end
×
211

212
      # command for calling kexec
213
      cmd = Builtins.sformat(
×
214
        "kexec -l --command-line='%1' --initrd='%2' '%3'",
×
215
        String.Quote(kernel_args),
×
216
        String.Quote(initrd),
×
217
        String.Quote(vmlinuz)
×
218
      )
×
219
      Builtins.y2milestone("Calling kexec via command: %1", cmd)
×
220

221
      # call kexec
222
      out = Convert.to_map(WFM.Execute(path(".local.bash_output"), cmd))
×
223
      # check output
224
      if Ops.get(out, "exit") != 0
×
225
        Builtins.y2error("Calling kexec failed, output: %1", out)
×
226
        return false
×
227
      end
×
228

229
      Builtins.y2milestone("Loading new kernel was succesful")
×
230
      true
×
231
    end
×
232
  end
×
233
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