/
BootArch.rb
139 lines (125 loc) · 4 KB
/
BootArch.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
# encoding: utf-8
# File:
# modules/BootArch.ycp
#
# Module:
# Bootloader installation and configuration
#
# Summary:
# Module containing specific data for differnt architecturese
# (as some architectures support multiple bootloaders, some bootloaders
# support multiple architectures)
#
# Authors:
# Jiri Srain <jsrain@suse.cz>
# Olaf Dabrunz <od@suse.de>
#
# $Id$
#
require "yast"
module Yast
class BootArchClass < Module
include Yast::Logger
def main
textdomain "bootloader"
Yast.import "Arch"
Yast.import "Kernel"
Yast.import "Linuxrc"
Yast.import "ProductFeatures"
Yast.import "Stage"
end
# Get parameters for the default kernel
# @param [String] resume string device to resume from (or empty not to set it)
# @return [String] parameters for default kernel
def DefaultKernelParams(resume)
features = ProductFeatures.GetStringFeature(
"globals",
"additional_kernel_parameters"
)
kernel_cmdline = Kernel.GetCmdLine.dup
if Arch.i386 || Arch.x86_64
ret = kernel_cmdline
ret << " resume=#{resume}" unless resume.empty?
ret << " #{features}" unless features.empty?
ret.gsub!(/(?:\A|\s)splash=\S*/, "")
ret << " splash=silent quiet showopts"
return ret
elsif Arch.s390
# TODO maybe use ENV directly?
file_desc = SCR.Execute(path(".target.bash_output"), "echo $TERM")
env_term = file_desc["stdout"]
if env_term == "linux\n"
termparm = "TERM=linux console=ttyS0 console=ttyS1"
else
termparm = "hvc_iucv=8 TERM=dumb"
end
parameters = "#{features} #{termparm}"
parameters << " resume=#{resume}" unless resume.empty?
return parameters
else
log.warn "Default kernel parameters not defined"
return kernel_cmdline
end
end
# Get parameters for the failsafe kernel
# @return [String] parameters for failsafe kernel
def FailsafeKernelParams
if Arch.i386
ret = "showopts apm=off noresume nosmp maxcpus=0 edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 nomodeset"
elsif Arch.x86_64
ret = "showopts apm=off noresume edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 nomodeset"
elsif Arch.s390
ret = "#{DefaultKernelParams("")} noresume"
else
log.warn "Parameters for Failsafe boot option not defined"
ret = ""
end
if Stage.initial
ret << " NOPCMCIA" if Linuxrc.InstallInf("NOPCMCIA") == "1"
else
saved_params = SCR.Read(path(".target.ycp"), "/var/lib/YaST2/bootloader.ycp")
ret << (saved_params["additional_failsafe_params"] || "")
end
ret << " x11failsafe"
end
# Is VGA parameter setting available
# @return true if vga= can be set
def VgaAvailable
Arch.i386 || Arch.x86_64
end
# Is Suspend to Disk available?
# @return true if STD is available
def ResumeAvailable
Arch.i386 || Arch.x86_64 || Arch.s390
end
# Return architecture as string
# @return [String] type of architecture e.g. "i386"
def StrArch
ret = Arch.architecture
if ret == "ppc" || ret == "ppc64"
if Arch.board_iseries
ret = "iseries"
elsif Arch.board_prep
ret = "prep"
elsif Arch.board_chrp
ret = "chrp"
elsif Arch.board_mac_new
ret = "pmac"
elsif Arch.board_mac_old
ret = "pmac"
else
ret = "unknown"
end
end
log.info "Type of architecture: #{ret}"
ret
end
publish :function => :DefaultKernelParams, :type => "string (string)"
publish :function => :FailsafeKernelParams, :type => "string ()"
publish :function => :VgaAvailable, :type => "boolean ()"
publish :function => :ResumeAvailable, :type => "boolean ()"
publish :function => :StrArch, :type => "string ()"
end
BootArch = BootArchClass.new
BootArch.main
end