17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
139
140
141
142
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
|
# File 'src/clients/bootloader_finish.rb', line 17
def main
textdomain "bootloader"
Yast.import "Arch"
Yast.import "Bootloader"
Yast.import "Installation"
Yast.import "Linuxrc"
Yast.import "Misc"
Yast.import "Mode"
Yast.import "BootCommon"
@ret = nil
@func = ""
@param = {}
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 bootloader_finish")
Builtins.y2debug("func=%1", @func)
Builtins.y2debug("param=%1", @param)
if @func == "Info"
return {
"steps" => 3,
"title" => _(
"Saving bootloader configuration..."
),
"when" => [:installation, :live_installation, :update, :autoinst]
}
elsif @func == "Write"
if Mode.update
@cmd = Ops.add(
Ops.add("targetdir=", Installation.destdir),
"\n" +
"if test ${targetdir} = / ; then echo targetdir is / ; exit 1 ; fi\n" +
"grep -E \"^[^ ]+ ${targetdir}/dev \" < /proc/mounts\n" +
"if test $? = 0\n" +
"then\n" +
"\techo targetdir ${targetdir} already mounted.\n" +
"\texit 1\n" +
"else\n" +
"\tmkdir -vp ${targetdir}/dev\n" +
"\tcp --preserve=all --recursive --remove-destination /lib/udev/devices/* ${targetdir}/dev\n" +
"\tmount -v --bind /dev ${targetdir}/dev\n" +
"fi\n"
)
Builtins.y2milestone("mount --bind cmd: %1", @cmd)
@out = Convert.to_map(WFM.Execute(path(".local.bash_output"), @cmd))
if Ops.get_integer(@out, "exit", 0) != 0
Builtins.y2error("unable to bind mount /dev in chroot")
end
Builtins.y2milestone("mount --bind /dev /mnt/dev output: %1", @out)
end
@finish_ret = nil
if Arch.s390
@reipl_client = "reipl_bootloader_finish"
if WFM.ClientExists(@reipl_client)
@finish_ret = Convert.to_map(WFM.call(@reipl_client))
Builtins.y2milestone(
"result of reipl_bootloader_finish [%1, %2]",
Ops.get_boolean(@finish_ret, "different", true),
Ops.get_string(@finish_ret, "ipl_msg", "N/A2")
)
Builtins.y2milestone(
"finish_ret[\"different\"]:true == true : %1",
Ops.get_boolean(@finish_ret, "different", true) == true
)
if Ops.get_boolean(@finish_ret, "different", false) == true
Builtins.y2milestone("finish_ret[\"different\"] is true")
else
Builtins.y2milestone(
"finish_ret[\"different\"] is not true (either undefined or false)"
)
end
else
Builtins.y2error("No such client: %1", @reipl_client)
end
end
if Arch.s390 && Ops.get_boolean(@finish_ret, "different", true) == true
@ipl_msg = ""
@ipl_msg = Ops.get_string(@finish_ret, "ipl_msg", "")
Misc.boot_msg = Builtins.sformat(
_(
"\n" +
"Your system will now shut down.%1\n" +
"For details, read the related chapter \n" +
"in the documentation. \n"
),
@ipl_msg
)
else
Misc.boot_msg = _("The system will reboot now...")
end
Bootloader.RunDelayedUpdates
@retcode = false
if !Mode.update
@retcode = Bootloader.WriteInstallation
else
@retcode = Bootloader.Update
res = SCR.Execute(path(".target.bash_output"), "/sbin/mkinitrd")
Builtins.y2milestone("Regerate initrd with result #{res}")
end
if Bootloader.getLoaderType =~ /grub2/
prefix = Installation.destdir
branding_activator = Dir["#{prefix}/usr/share/grub2/themes/*/activate-theme"].first
if branding_activator
branding_activator = branding_activator[prefix.size..-1]
res = SCR.Execute(path(".target.bash_output"), branding_activator)
Builtins.y2milestone("Reactivate branding with #{branding_activator} and result #{res}")
res = SCR.Execute(path(".target.bash_output"), "/usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg")
Builtins.y2milestone("Grub mkconfig with result #{res}")
else
Builtins.y2milestone("No branding_activator")
end
end
if @retcode
Bootloader.Read
@retcode = false
if Linuxrc.InstallInf("kexec_reboot") == "1"
@retcode = Bootloader.CopyKernelInird
else
@retcode = true
Builtins.y2milestone("Installation started with kexec_reboot set 0")
end
if !@retcode
@bl = Bootloader.getLoaderType
return Bootloader.FlagOnetimeBoot(Bootloader.getDefaultSection)
end
else
return @retcode
end
else
Builtins.y2error("unknown function: %1", @func)
@ret = nil
end
Builtins.y2debug("ret=%1", @ret)
Builtins.y2milestone("bootloader_finish finished")
deep_copy(@ret)
end
|