Class: Yast::LinuxrcClass

Inherits:
Module
  • Object
show all
Defined in:
../../library/general/src/modules/Linuxrc.rb

Constant Summary

DISABLE_SNAPSHOTS =

Disables filesystem snapshots (fate#317973) Possible values: all, post, pre, single

"disable_snapshots"

Instance Method Summary (collapse)

Instance Method Details

- (Object) braille

braille mode ?



111
112
113
# File '../../library/general/src/modules/Linuxrc.rb', line 111

def braille
  !InstallInf("Braille").nil?
end

- (Object) display_ip

remote X mode ?



120
121
122
# File '../../library/general/src/modules/Linuxrc.rb', line 120

def display_ip
  !InstallInf("Display_IP").nil?
end

- (Object) InstallInf(key)



78
79
80
81
# File '../../library/general/src/modules/Linuxrc.rb', line 78

def InstallInf(key)
  ReadInstallInf()
  @install_inf[key]
end

- (Object) keys



83
84
85
86
# File '../../library/general/src/modules/Linuxrc.rb', line 83

def keys
  ReadInstallInf()
  @install_inf.keys
end

- (Object) main



38
39
40
41
42
43
44
45
# File '../../library/general/src/modules/Linuxrc.rb', line 38

def main
  Yast.import "Mode"
  Yast.import "Stage"

  @install_inf = nil

  @_manual = nil
end

- (Object) manual

installation mode wrappers



90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File '../../library/general/src/modules/Linuxrc.rb', line 90

def manual
  return @_manual if !@_manual.nil?
  @_manual = InstallInf("Manual") == "1"
  if !@_manual
    tmp = Convert.to_string(
      SCR.Read(path(".target.string"), "/proc/cmdline")
    )
    if !tmp.nil? &&
        Builtins.contains(Builtins.splitstring(tmp, " \n"), "manual")
      @_manual = true
    end
  end
  @_manual
end

- (Object) ReadInstallInf

routines for reading data from /etc/install.inf



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File '../../library/general/src/modules/Linuxrc.rb', line 49

def ReadInstallInf
  return if !@install_inf.nil?

  @install_inf = {}
  # don't read anything if the file doesn't exist
  if SCR.Read(path(".target.size"), "/etc/install.inf") == -1
    Builtins.y2error("Reading install.inf, but file doesn't exist!!!")
    return
  end
  entries = SCR.Dir(path(".etc.install_inf"))
  if entries.nil?
    Builtins.y2error("install.inf is empty")
    return
  end
  Builtins.foreach(entries) do |e|
    val = Convert.to_string(
      SCR.Read(Builtins.add(path(".etc.install_inf"), e))
    )
    Ops.set(@install_inf, e, val)
  end

  nil
end

- (Object) ResetInstallInf



73
74
75
76
# File '../../library/general/src/modules/Linuxrc.rb', line 73

def ResetInstallInf
  @install_inf = nil
  nil
end

- (Object) SaveInstallInf(root)

Copy /etc/install.inf into built system so that the second phase of the installation can find it.

Parameters:

  • root

    mount point of system

Returns:

  • boolean true on success



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
# File '../../library/general/src/modules/Linuxrc.rb', line 166

def SaveInstallInf(root)
  if Stage.initial && !Mode.test
    inst_if_file = "/etc/install.inf"

    if !root.nil? && root != "" && root != "/"
      if WFM.Read(path(".local.size"), inst_if_file) != -1
        Builtins.y2milestone("Copying %1 to %2", inst_if_file, root)
        if Convert.to_integer(
          WFM.Execute(
            path(".local.bash"),
            Builtins.sformat(
              "grep -vi '^Sourcemounted' '%1' > %2/%1; chmod 0600 %2/%1",
              inst_if_file,
              root
            )
          )
          ) != 0
          Builtins.y2error(
            "Cannot SaveInstallInf %1 to %2",
            inst_if_file,
            root
          )
        end
      else
        Builtins.y2error(
          "Can't SaveInstallInf, file %1 doesn't exist",
          inst_if_file
        )
      end
    else
      Builtins.y2error("Can't SaveInstallInf, root is %1", root)
    end

    # just for debug so we can see the original install.inf later
    SCR.Execute(
      path(".target.bash"),
      Ops.add(
        Ops.add("/bin/cp /etc/install.inf ", root),
        "/var/lib/YaST2/install.inf"
      )
    )
    SCR.Execute(
      path(".target.bash"),
      Ops.add(
        Ops.add("/bin/chmod 0600 ", root),
        "/var/lib/YaST2/install.inf"
      )
    )
  end
  true
end

- (Object) serial_console

running via serial console



106
107
108
# File '../../library/general/src/modules/Linuxrc.rb', line 106

def serial_console
  !InstallInf("Console").nil?
end

- (Object) text

we're running in textmode (-> UI::GetDisplayInfo())



138
139
140
# File '../../library/general/src/modules/Linuxrc.rb', line 138

def text
  InstallInf("Textmode") == "1"
end

- (Object) useiscsi

Returns if iSCSI has been requested in Linuxrc.



133
134
135
# File '../../library/general/src/modules/Linuxrc.rb', line 133

def useiscsi
  InstallInf("WithiSCSI") == "1"
end

- (Object) usessh

ssh mode ? if booted with 'vnc=1 usessh=1', keep vnc mode, but start sshd if booted with 'display_ip=1.2.3.4 usessh=1', keep remote X mode, but start sshd this has to be checked by the caller, not here



128
129
130
# File '../../library/general/src/modules/Linuxrc.rb', line 128

def usessh
  InstallInf("UseSSH") == "1"
end

- (String?) value_for(feature_key)

Returns value of a given Linxurc key/feature defined on commandline and written into install.inf

Parameters:

  • key (String)

Returns:

  • (String, nil)

    value of a given key or nil if not found



223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File '../../library/general/src/modules/Linuxrc.rb', line 223

def value_for(feature_key)
  ReadInstallInf()
  feature_key = polish(feature_key)

  # at first check the keys in install.inf
  install_inf_key, install_inf_val = @install_inf.find { |k, _v| polish(k) == feature_key }
  return install_inf_val if install_inf_key

  # then check the command line
  ret = nil
  @install_inf.fetch("Cmdline", "").split.each do |cmdline_entry|
    key, val = cmdline_entry.split("=", 2)
    ret = val if polish(key) == feature_key
  end

  ret
end

- (Object) vnc

vnc mode ?



116
117
118
# File '../../library/general/src/modules/Linuxrc.rb', line 116

def vnc
  InstallInf("VNC") == "1"
end

- (void) WriteYaSTInf(linuxrc)

This method returns an undefined value.

Write /etc/yast.inf during installation

Parameters:

  • linuxrc (Hash{String => String})

    map of key value pairs for /etc/yast.inf



147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File '../../library/general/src/modules/Linuxrc.rb', line 147

def WriteYaSTInf(linuxrc)
  linuxrc = deep_copy(linuxrc)
  yast_inf = ""
  Builtins.foreach(linuxrc) do |ykey, yvalue|
    yast_inf = Ops.add(
      Ops.add(Ops.add(Ops.add(yast_inf, ykey), ": "), yvalue),
      "\n"
    )
  end
  Builtins.y2milestone("WriteYaSTInf(%1) = %2", linuxrc, yast_inf)

  WFM.Write(path(".local.string"), "/etc/yast.inf", yast_inf) if !Mode.test
  nil
end