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



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

def autoinst
  mode == "autoinstallation"
end

- (Object) autoupgrade

doing auto-upgrade



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

def autoupgrade
  mode == "autoupgrade"
end

- (Object) commandline

we're running in command line interface

Returns:

  • true if command-line is running



249
250
251
# File '../../library/general/src/modules/Mode.rb', line 249

def commandline
  ui == "commandline"
end

- (Object) config

configuration for auto-installation, only in running system



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

def config
  mode == "autoinst_config"
end

- (Object) Depeche



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

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
# 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
  end

  nil
end

- (Object) installation

we're doing a fresh installation



182
183
184
185
# File '../../library/general/src/modules/Mode.rb', line 182

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

- (Object) live_installation

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



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

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"



101
102
103
104
105
# File '../../library/general/src/modules/Mode.rb', line 101

def mode
  Initialize() if @_mode == nil

  @_mode
end

- (Object) normal

normal, running system



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

def normal
  mode == "normal"
end

- (Object) repair

start repair module



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

def repair
  mode == "repair"
end

- (Object) screen_shot

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



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

def screen_shot
  testMode == "screenshot"
end

- (Object) SetMode(new_mode)



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File '../../library/general/src/modules/Mode.rb', line 107

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)



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

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)



170
171
172
173
174
175
176
177
# File '../../library/general/src/modules/Mode.rb', line 170

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*



230
231
232
# File '../../library/general/src/modules/Mode.rb', line 230

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

- (Object) testMode

test mode definitions



134
135
136
137
138
139
140
141
142
143
144
145
146
# File '../../library/general/src/modules/Mode.rb', line 134

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.



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

def testsuite
  testMode == "testsuite"
end

- (Object) ui

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



166
167
168
# File '../../library/general/src/modules/Mode.rb', line 166

def ui
  @_ui
end

- (Object) update

we're doing an update



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

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