Class: Yast::ModeClass

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) autoinst

doing auto-installation



217
218
219
# File '../../library/general/src/modules/Mode.rb', line 217

def autoinst
  mode == "autoinstallation"
end

- (Object) autoupgrade

doing auto-upgrade



222
223
224
# File '../../library/general/src/modules/Mode.rb', line 222

def autoupgrade
  mode == "autoupgrade"
end

- (Object) commandline

we're running in command line interface

Returns:

  • true if command-line is running



254
255
256
# File '../../library/general/src/modules/Mode.rb', line 254

def commandline
  ui == "commandline"
end

- (Object) config

configuration for auto-installation, only in running system



227
228
229
# File '../../library/general/src/modules/Mode.rb', line 227

def config
  mode == "autoinst_config"
end

- (Object) Depeche



202
203
204
# File '../../library/general/src/modules/Mode.rb', line 202

def Depeche
  true
end

- (Object) Initialize

initialize everything from command-line of y2base



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

def Initialize
  @_mode = "normal"
  @_test = "none"
  arg_count = Builtins.size(WFM.Args)
  arg_no = 0
  while Ops.less_than(arg_no, arg_count)
    # parsing for main mode
    if WFM.Args(arg_no) == "initial" || WFM.Args(arg_no) == "continue" ||
        WFM.Args(arg_no) == "firstboot"
      @_mode = "installation"
    # parsing for test mode
    elsif WFM.Args(arg_no) == "test" || WFM.Args(arg_no) == "demo"
      @_test = "test"
      Builtins.y2warning("***** Test mode enabled *****")
    elsif WFM.Args(arg_no) == "screenshots"
      @_test = "screenshot"
      Builtins.y2warning("***** Screen shot mode enabled *****")
    end

    arg_no = Ops.add(arg_no, 1)
  end

  # only use the /etc/install.inf agent when file is present
  # and installation is being processed
  # FIXME remove the part below and let it be set in clients
  if @_mode == "installation" &&
      SCR.Read(path(".target.size"), "/etc/install.inf") != -1

    autoinst = SCR.Read(path(".etc.install_inf.AutoYaST")) != nil
    @_mode = "autoinstallation" if autoinst

    repair = SCR.Read(path(".etc.install_inf.Repair")) != nil
    @_mode = "repair" if repair

    # FIXME according to what Linuxrc really writes
    autoupgrade = SCR.Read(path(".etc.install_inf.AutoUpgrade")) != nil
    @_mode = "autoupgrade" if autoupgrade

    update = SCR.Read(path(".etc.install_inf.Upgrade")) != nil
    @_mode = "update" if update
  end

  nil
end

- (Object) installation

we're doing a fresh installation



187
188
189
190
# File '../../library/general/src/modules/Mode.rb', line 187

def installation
  mode == "installation" || mode == "autoinstallation" ||
    mode == "live_installation"
end

- (Object) live_installation

we're doing a fresh installation from live CD/DVD



193
194
195
# File '../../library/general/src/modules/Mode.rb', line 193

def live_installation
  mode == "live_installation"
end

- (Object) main



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File '../../library/general/src/modules/Mode.rb', line 39

def main

  textdomain "base"

  # Current mode
  @_mode = nil

  # Current testing mode
  @_test = nil

  # We do one automatic check whether _test should be set to testsuite.
  @test_autochecked = false

  # Current UI mode
  @_ui = "dialog"
end

- (Object) mode

Returns the current mode name. It's one of "installation", "normal", "update", "repair", "autoinstallation", "autoinst_config"



106
107
108
109
110
# File '../../library/general/src/modules/Mode.rb', line 106

def mode
  Initialize() if @_mode == nil

  @_mode
end

- (Object) normal

normal, running system



207
208
209
# File '../../library/general/src/modules/Mode.rb', line 207

def normal
  mode == "normal"
end

- (Object) repair

start repair module



212
213
214
# File '../../library/general/src/modules/Mode.rb', line 212

def repair
  mode == "repair"
end

- (Object) screen_shot

dump screens to /tmp. Implies #demo . See installation/Test-Scripts/yast2-screen-shots*



241
242
243
# File '../../library/general/src/modules/Mode.rb', line 241

def screen_shot
  testMode == "screenshot"
end

- (Object) SetMode(new_mode)



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File '../../library/general/src/modules/Mode.rb', line 112

def SetMode(new_mode)
  Initialize() if @_mode == nil

  if !Builtins.contains(
      [
        "installation",
        "update",
        "normal",
        "repair",
        "autoinstallation",
        "autoinst_config",
        "live_installation",
        "autoupgrade"
      ],
      new_mode
    )
    Builtins.y2error("Unknown mode %1", new_mode)
  end

  Builtins.y2milestone("setting mode to %1", new_mode)
  @_mode = new_mode

  nil
end

- (Object) SetTest(new_test_mode)



153
154
155
156
157
158
159
160
161
162
163
164
165
# File '../../library/general/src/modules/Mode.rb', line 153

def SetTest(new_test_mode)
  Initialize() if @_test == nil

  if !Builtins.contains(
      ["none", "test", "demo", "screenshot", "testsuite"],
      new_test_mode
    )
    Builtins.y2error("Unknown test mode %1", new_test_mode)
  end
  @_test = new_test_mode

  nil
end

- (Object) SetUI(new_ui)



175
176
177
178
179
180
181
182
# File '../../library/general/src/modules/Mode.rb', line 175

def SetUI(new_ui)
  if !Builtins.contains(["commandline", "dialog", "none"], new_ui)
    Builtins.y2error("Unknown UI mode %1", new_ui)
  end
  @_ui = new_ui

  nil
end

- (Object) test

Just testing. See installation/Test-Scripts/doit*



235
236
237
# File '../../library/general/src/modules/Mode.rb', line 235

def test
  testMode == "test" || testMode == "screenshot" || testMode == "testsuite"
end

- (Object) testMode

test mode definitions



139
140
141
142
143
144
145
146
147
148
149
150
151
# File '../../library/general/src/modules/Mode.rb', line 139

def testMode
  Initialize() if @_test == nil
  if !@test_autochecked
    # bnc#243624#c13: Y2ALLGLOBAL is set by yast2-testsuite/skel/runtest.sh
    if Builtins.getenv("Y2MODETEST") != nil ||
        Builtins.getenv("Y2ALLGLOBAL") != nil
      @_test = "testsuite"
    end
    @test_autochecked = true
  end

  @_test
end

- (Object) testsuite

Returns whether running in testsuite.



246
247
248
# File '../../library/general/src/modules/Mode.rb', line 246

def testsuite
  testMode == "testsuite"
end

- (Object) ui

Returns the current UI mode. It's one of "commandline", "dialog", "none"



171
172
173
# File '../../library/general/src/modules/Mode.rb', line 171

def ui
  @_ui
end

- (Object) update

we're doing an update



198
199
200
# File '../../library/general/src/modules/Mode.rb', line 198

def update
  mode == "update" || mode == "autoupgrade"
end