Class: Yast::ProductControlClass

Inherits:
Module
  • Object
show all
Defined in:
../../src/modules/ProductControl.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) addToStack(name)



1381
1382
1383
1384
# File '../../src/modules/ProductControl.rb', line 1381

def addToStack(name)
  @stack = Builtins.add(@stack, name)
  nil
end

- (void) AddWizardSteps(stagemode)

This method returns an undefined value.

Add Wizard Steps

Parameters:

  • stagemode (Array<Hash>)

    A List of maps containing info about complete installation workflow.



877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
# File '../../src/modules/ProductControl.rb', line 877

def AddWizardSteps(stagemode)
  stagemode = deep_copy(stagemode)
  debug_workflow = ProductFeatures.GetBooleanFeature(
    "globals",
    "debug_workflow"
  )

  @last_stage_mode = deep_copy(stagemode)

  # UI::WizardCommand() can safely be called even if the respective UI
  # doesn't support the wizard widget, but for optimization it makes sense
  # to do expensive operations only when it is available.

  # if ( ! UI::HasSpecialWidget(`Wizard ) )
  # return;

  wizard_textdomain = Ops.get_string(
    @productControl,
    "textdomain",
    "control"
  )
  Builtins.y2debug(
    "Using textdomain '%1' for wizard steps",
    wizard_textdomain
  )

  first_id = ""
  # UI::WizardCommand(`SetVerboseCommands( true ) );
  Builtins.foreach(stagemode) do |sm|
    Builtins.y2debug("Adding wizard steps for %1", sm)
    # only for debugging
    Builtins.y2milestone("Adding wizard steps for %1", sm)
    slabel = getWorkflowLabel(
      Ops.get_string(sm, "stage", ""),
      Ops.get_string(sm, "mode", ""),
      wizard_textdomain
    )
    UI.WizardCommand(term(:AddStepHeading, slabel)) if slabel != ""
    # just to check whether there are some steps to display
    enabled_modules = getModules(
      Ops.get_string(sm, "stage", ""),
      Ops.get_string(sm, "mode", ""),
      :enabled
    )
    enabled_modules = Builtins.filter(enabled_modules) do |m|
      Ops.get_string(m, "heading", "") == ""
    end
    if Builtins.size(enabled_modules) == 0
      Builtins.y2milestone(
        "There are no (more) steps for %1, section will be disabled",
        sm
      )
      next
    end
    last_label = ""
    last_domain = ""
    Builtins.foreach(
      getModules(
        Ops.get_string(sm, "stage", ""),
        Ops.get_string(sm, "mode", ""),
        :enabled
      )
    ) do |m|
      # only for debugging
      Builtins.y2debug("Adding wizard step: %1", m)
      heading = ""
      label = ""
      id = ""
      # Heading
      if Builtins.haskey(m, "heading") &&
          Ops.get_string(m, "label", "") != ""
        heading = Builtins.haskey(m, "textdomain") ?
          Builtins.dgettext(
            Ops.get_string(m, "textdomain", ""),
            Ops.get_string(m, "label", "")
          ) :
          Builtins.dgettext(
            wizard_textdomain,
            Ops.get_string(m, "label", "")
          ) 

        # Label
      elsif Ops.get_string(m, "label", "") != ""
        first_id = Ops.get_string(m, "id", "") if first_id == ""

        label = Builtins.haskey(m, "textdomain") ?
          Builtins.dgettext(
            Ops.get_string(m, "textdomain", ""),
            Ops.get_string(m, "label", "")
          ) :
          Builtins.dgettext(
            wizard_textdomain,
            Ops.get_string(m, "label", "")
          )

        id = Ops.get_string(m, "id", "")
        last_label = Ops.get_string(m, "label", "")
        last_domain = Ops.get_string(m, "textdomain", "") 

        # The rest
      else
        first_id = Ops.get_string(m, "id", "") if first_id == ""

        if last_label != ""
          if last_domain != ""
            label = Builtins.dgettext(last_domain, last_label)
            id = Ops.get_string(m, "id", "")
          else
            label = Builtins.dgettext(wizard_textdomain, last_label)
          end
          id = Ops.get_string(m, "id", "")
        end
      end
      if heading != nil && heading != ""
        UI.WizardCommand(term(:AddStepHeading, heading))
      end
      if label != nil && label != ""
        if debug_workflow == true
          label = Ops.add(
            label,
            Builtins.sformat(" [%1]", Ops.get_string(m, "name", ""))
          )
        end
        Builtins.y2debug("AddStep: %1/%2", label, id)
        UI.WizardCommand(term(:AddStep, label, id))
      end
    end
  end

  UI.WizardCommand(term(:SetCurrentStep, @CurrentWizardStep))

  nil
end

- (Object) Check(allowed, current)



399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
# File '../../src/modules/ProductControl.rb', line 399

def Check(allowed, current)
  # create allowed list
  allowedlist = Builtins.filter(
    Builtins.splitstring(Builtins.deletechars(allowed, " "), ",")
  ) { |s| s != "" }
  Builtins.y2debug("allowedlist: %1", allowedlist)
  Builtins.y2debug("current: %1", current)
  if Builtins.size(allowedlist) == 0
    return true
  elsif Builtins.contains(allowedlist, current)
    return true
  else
    return false
  end
end

- (Object) CheckAdditionalParams(check_workflow)

Checks all params set by SetAdditionalWorkflowParams() whether they match the workfow got as parameter.

Parameters:

  • check_workflow (map &)

See Also:

  • #SetAdditionalWorkflowParams()


521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
# File '../../src/modules/ProductControl.rb', line 521

def CheckAdditionalParams(check_workflow)
  if @_additional_workflow_params == nil ||
      @_additional_workflow_params == {}
    return true
  end

  ret = true

  Builtins.foreach(@_additional_workflow_params) do |key_to_check, value_to_check|
    # exception
    # If 'add_on_mode' key is not set in the workflow at all
    # it is considered to be matching that parameter
    if key_to_check == "add_on_mode" &&
        !Builtins.haskey(check_workflow.value, key_to_check)
      Builtins.y2debug(
        "No 'add_on_mode' defined, matching %1",
        value_to_check
      )
    elsif Ops.get(check_workflow.value, key_to_check) != value_to_check
      ret = false
      raise Break
    end
  end

  ret
end

- (Boolean) checkArch(mod, _def)

Check if valid architecture

Parameters:

  • map

    module data

  • map

    default data

Returns:

  • (Boolean)

    true if arch match



419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
# File '../../src/modules/ProductControl.rb', line 419

def checkArch(mod, _def)
  mod = deep_copy(mod)
  _def = deep_copy(_def)
  Builtins.y2debug("Checking architecture: %1", mod)
  archs = Ops.get_string(mod, "archs", "")
  archs = Ops.get_string(_def, "archs", "all") if archs == ""

  return true if archs == "all"

  Builtins.y2milestone("short arch desc: %1", Arch.arch_short)
  Builtins.y2milestone("supported archs: %1", archs)
  return true if Builtins.issubstring(archs, Arch.arch_short)

  false
end

- (Boolean) checkDisabled(mod)

Check if a module is disabled

Parameters:

  • map

    module map

Returns:

  • (Boolean)


318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
# File '../../src/modules/ProductControl.rb', line 318

def checkDisabled(mod)
  mod = deep_copy(mod)
  if mod == nil
    Builtins.y2error("Unknown module %1", mod)
    return nil
  end

  # Proposal
  if Ops.get_string(mod, "proposal", "") != nil &&
      Ops.get_string(mod, "proposal", "") != ""
    if Builtins.contains(
        @DisabledProposals,
        Ops.get_string(mod, "proposal", "")
      )
      return true
    end 
    # Normal step
  elsif Ops.get_string(mod, "name", "") != nil &&
      Ops.get_string(mod, "name", "") != ""
    if Builtins.contains(@DisabledModules, Ops.get_string(mod, "name", ""))
      return true
    end
  end

  false
end

- (Object) checkHeading(mod)



345
346
347
348
# File '../../src/modules/ProductControl.rb', line 345

def checkHeading(mod)
  mod = deep_copy(mod)
  Builtins.haskey(mod, "heading")
end

- (Object) CurrentStep



159
160
161
# File '../../src/modules/ProductControl.rb', line 159

def CurrentStep
  @current_step
end

- (Object) DisableACItem(unique_id, disable_ac_item)



290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# File '../../src/modules/ProductControl.rb', line 290

def DisableACItem(unique_id, disable_ac_item)
  if Builtins.haskey(@DisabledACItems, unique_id)
    Ops.set(
      @DisabledACItems,
      unique_id,
      Convert.convert(
        Builtins.union(
          Ops.get(@DisabledACItems, unique_id, []),
          [disable_ac_item]
        ),
        :from => "list",
        :to   => "list <string>"
      )
    )
  else
    Ops.set(@DisabledACItems, unique_id, [disable_ac_item])
  end

  deep_copy(@DisabledACItems)
end

- (Object) DisableAllModulesAndProposals(mode, stage)



771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
# File '../../src/modules/ProductControl.rb', line 771

def DisableAllModulesAndProposals(mode, stage)
  this_workflow = { "mode" => mode, "stage" => stage }

  if Builtins.contains(@already_disabled_workflows, this_workflow)
    Builtins.y2milestone("Workflow %1 already disabled", this_workflow)
    return
  end

  # stores modules and proposals disabled before
  # this 'general' disabling
  @localDisabledProposals = deep_copy(@DisabledProposals)
  @localDisabledModules = deep_copy(@DisabledModules)

  Builtins.y2milestone(
    "localDisabledProposals: %1",
    @localDisabledProposals
  )
  Builtins.y2milestone("localDisabledModules: %1", @localDisabledModules)

  Builtins.foreach(getModules(stage, mode, :all)) do |m|
    if Ops.get_string(m, "proposal", "") != nil &&
        Ops.get_string(m, "proposal", "") != ""
      Builtins.y2milestone("Disabling proposal: %1", m)
      @DisabledProposals = Convert.convert(
        Builtins.union(
          @DisabledProposals,
          [Ops.get_string(m, "proposal", "")]
        ),
        :from => "list",
        :to   => "list <string>"
      )
    elsif Ops.get_string(m, "name", "") != nil &&
        Ops.get_string(m, "name", "") != ""
      Builtins.y2milestone("Disabling module: %1", m)
      @DisabledModules = Convert.convert(
        Builtins.union(@DisabledModules, [Ops.get_string(m, "name", "")]),
        :from => "list",
        :to   => "list <string>"
      )
    end
  end

  @already_disabled_workflows = Convert.convert(
    Builtins.union(@already_disabled_workflows, [this_workflow]),
    :from => "list",
    :to   => "list <map>"
  )

  nil
end

- (Object) DisableModule(modname)

Disable given module in installation workflow

Returns:

  • current list of disabled modules



182
183
184
185
186
187
188
189
190
191
192
193
194
# File '../../src/modules/ProductControl.rb', line 182

def DisableModule(modname)
  if modname == nil || modname == ""
    Builtins.y2error("Module to disable is '%1'", modname)
  else
    @DisabledModules = Convert.convert(
      Builtins.union(@DisabledModules, [modname]),
      :from => "list",
      :to   => "list <string>"
    )
  end

  deep_copy(@DisabledModules)
end

- (Object) DisableProposal(disable_proposal)

Disable given proposal in installation workflow

Returns:

  • current list of disabled proposals



215
216
217
218
219
220
221
222
223
224
225
226
227
# File '../../src/modules/ProductControl.rb', line 215

def DisableProposal(disable_proposal)
  if disable_proposal == nil || disable_proposal == ""
    Builtins.y2error("Module to disable is '%1'", disable_proposal)
  else
    @DisabledProposals = Convert.convert(
      Builtins.union(@DisabledProposals, [disable_proposal]),
      :from => "list",
      :to   => "list <string>"
    )
  end

  deep_copy(@DisabledProposals)
end

- (Object) DisableSubProposal(unique_id, disable_subproposal)



249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# File '../../src/modules/ProductControl.rb', line 249

def DisableSubProposal(unique_id, disable_subproposal)
  if Builtins.haskey(@DisabledSubProposals, unique_id)
    Ops.set(
      @DisabledSubProposals,
      unique_id,
      Convert.convert(
        Builtins.union(
          Ops.get(@DisabledSubProposals, unique_id, []),
          [disable_subproposal]
        ),
        :from => "list",
        :to   => "list <string>"
      )
    )
  else
    Ops.set(@DisabledSubProposals, unique_id, [disable_subproposal])
  end

  deep_copy(@DisabledSubProposals)
end

- (Object) EnableACItem(unique_id, enable_ac_item)



274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# File '../../src/modules/ProductControl.rb', line 274

def EnableACItem(unique_id, enable_ac_item)
  if Builtins.haskey(@DisabledACItems, unique_id)
    Ops.set(
      @DisabledACItems,
      unique_id,
      Builtins.filter(Ops.get(@DisabledACItems, unique_id, [])) do |one_ac_item|
        one_ac_item != enable_ac_item
      end
    )
  else
    Builtins.y2error("AC step with id %1 does not exist", unique_id)
  end

  deep_copy(@DisabledACItems)
end

- (Object) EnableModule(modname)

Enable given disabled module

Returns:

  • current list of disabled modules



172
173
174
175
176
177
178
# File '../../src/modules/ProductControl.rb', line 172

def EnableModule(modname)
  @DisabledModules = Builtins.filter(@DisabledModules) do |mod|
    mod != modname
  end

  deep_copy(@DisabledModules)
end

- (Object) EnableProposal(enable_proposal)

Enable given disabled proposal

Returns:

  • current list of disabled proposals



205
206
207
208
209
210
211
# File '../../src/modules/ProductControl.rb', line 205

def EnableProposal(enable_proposal)
  @DisabledProposals = Builtins.filter(@DisabledProposals) do |one_proposal|
    one_proposal != enable_proposal
  end

  deep_copy(@DisabledProposals)
end

- (Object) EnableSubProposal(unique_id, enable_subproposal)



236
237
238
239
240
241
242
243
244
245
246
247
# File '../../src/modules/ProductControl.rb', line 236

def EnableSubProposal(unique_id, enable_subproposal)
  if Builtins.haskey(@DisabledSubProposals, unique_id)
    Ops.set(
      @DisabledSubProposals,
      unique_id,
      Builtins.filter(Ops.get(@DisabledSubProposals, unique_id, [])) do |one_subproposal|
        one_subproposal != enable_subproposal
      end
    )
  end
  deep_copy(@DisabledSubProposals)
end

- (Hash) FindMatchingWorkflow(stage, mode)

Returns workflow matching the selected stage and mode and additiona parameters if set by SetAdditionalWorkflowParams()

Parameters:

  • stage (String)
  • mode (String)

Returns:

  • (Hash)

    workflow



554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
# File '../../src/modules/ProductControl.rb', line 554

def FindMatchingWorkflow(stage, mode)
  Builtins.y2debug("workflows: %1", @workflows)

  tmp = Builtins.filter(@workflows) do |wf|
    Check(Ops.get_string(wf, "stage", ""), stage) &&
      Check(Ops.get_string(wf, "mode", ""), mode) &&
      (
        wf_ref = arg_ref(wf);
        _CheckAdditionalParams_result = CheckAdditionalParams(wf_ref);
        wf = wf_ref.value;
        _CheckAdditionalParams_result
      )
  end

  Builtins.y2debug("Workflow: %1", Ops.get(tmp, 0, {}))

  Ops.get(tmp, 0, {})
end

- (Object) getClientName(name, execute)

Returns name of the script to call. If 'execute' is defined, the client name is taken from there. Then, if a custom control file is defined, client name is defined as 'name'. Then, inst<em>'name' or just 'name' is returned if it does not match the 'inst</em>' regexp.

Parameters:

  • name (String)
  • execute (String)

See Also:

  • #custom_control_file


443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
# File '../../src/modules/ProductControl.rb', line 443

def getClientName(name, execute)
  return "inst_test_workflow" if Mode.test

  # BNC #401319
  # 'execute; is defined and thus returned
  if execute != nil && execute != ""
    Builtins.y2milestone("Step name '%1' executes '%2'", name, execute)
    return execute
  end

  # Defined custom control file
  if @custom_control_file != ""
    return name 

    # All standard clients start with "inst_"
  else
    if Builtins.issubstring(name, @_client_prefix)
      return name
    else
      return Ops.add(@_client_prefix, name)
    end
  end
end

- (Yast::Term) getClientTerm(step, _def, former_result)

Return term to be used to run module with CallFunction

Parameters:

  • map

    module data

  • map

    default data

Returns:

  • (Yast::Term)

    module data with params



471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
# File '../../src/modules/ProductControl.rb', line 471

def getClientTerm(step, _def, former_result)
  step = deep_copy(step)
  _def = deep_copy(_def)
  former_result = deep_copy(former_result)
  client = getClientName(
    Ops.get_string(step, "name", "dummy"),
    Ops.get_string(step, "execute", "")
  )
  result = Builtins.toterm(client)
  arguments = {}

  Builtins.foreach(["enable_back", "enable_next"]) do |button|
    default_setting = Ops.get_string(_def, button, "yes")
    Ops.set(
      arguments,
      button,
      Ops.get_string(step, button, default_setting) == "yes"
    )
  end

  if Builtins.haskey(step, "proposal")
    Ops.set(arguments, "proposal", Ops.get_string(step, "proposal", ""))
  end
  other_args = Ops.get_map(step, "arguments", {})

  if Ops.greater_than(Builtins.size(other_args), 0)
    arguments = Convert.convert(
      Builtins.union(arguments, other_args),
      :from => "map",
      :to   => "map <string, any>"
    )
  end

  if Ops.is_symbol?(former_result) && former_result == :back
    Ops.set(arguments, "going_back", true)
  end

  if Mode.test
    Ops.set(arguments, "step_name", Ops.get_string(step, "name", ""))
    Ops.set(arguments, "step_id", Ops.get_string(step, "id", ""))
  end
  result = Builtins.add(result, arguments)
  deep_copy(result)
end

- (Hash) getCompleteWorkflow(stage, mode)

Get Workflow

Parameters:

  • stage (String)

    Stage

  • mode (String)

    Mode

Returns:

  • (Hash)

    Workflow map



675
676
677
# File '../../src/modules/ProductControl.rb', line 675

def getCompleteWorkflow(stage, mode)
  FindMatchingWorkflow(stage, mode)
end

- (Object) GetDisabledACItems



311
312
313
# File '../../src/modules/ProductControl.rb', line 311

def GetDisabledACItems
  deep_copy(@DisabledACItems)
end

- (Array<String>) GetDisabledModules

Returns list of modules disabled in workflow

Returns:

  • (Array<String>)

    DisabledModules



199
200
201
# File '../../src/modules/ProductControl.rb', line 199

def GetDisabledModules
  deep_copy(@DisabledModules)
end

- (Array<String>) GetDisabledProposals

Returns list of proposals disabled in workflow

Returns:

  • (Array<String>)

    DisabledProposals



232
233
234
# File '../../src/modules/ProductControl.rb', line 232

def GetDisabledProposals
  deep_copy(@DisabledProposals)
end

- (Object) GetDisabledSubProposals



270
271
272
# File '../../src/modules/ProductControl.rb', line 270

def GetDisabledSubProposals
  deep_copy(@DisabledSubProposals)
end

- (Array<String>) getLockedProposals(stage, mode, proptype)

Get Proposal list that can not be changed by the user.

Returns:

  • (Array<String>)

    list of locked proposals



1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
# File '../../src/modules/ProductControl.rb', line 1243

def getLockedProposals(stage, mode, proptype)
  props = getMatchingProposal(stage, mode, proptype)
  locked_proposals = Builtins.maplist(
    Ops.get_list(props, [0, "locked_modules"], [])
  ) do |p|
    if !Builtins.issubstring(p, "_proposal")
      next Ops.add(p, "_proposal")
    else
      next p
    end
  end
  deep_copy(locked_proposals)
end

- (Object) getMatchingProposal(stage, mode, proptype)



1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
# File '../../src/modules/ProductControl.rb', line 1103

def getMatchingProposal(stage, mode, proptype)
  Builtins.y2milestone(
    "Stage: %1 Mode: %2, Type: %3",
    stage,
    mode,
    proptype
  )

  # First we search for proposals for current stage if there are
  # any.
  props = Builtins.filter(@proposals) do |p|
    Check(Ops.get_string(p, "stage", ""), stage)
  end
  Builtins.y2debug("1. proposals: %1", props)

  # Then we check for mode: installation or update
  props = Builtins.filter(props) do |p|
    Check(Ops.get_string(p, "mode", ""), mode)
  end

  Builtins.y2debug("2. proposals: %1", props)

  # Now we check for architecture
  Builtins.y2debug(
    "Architecture: %1, Proposals: %2",
    Arch.architecture,
    props
  )

  arch_proposals = Builtins.filter(props) do |p|
    Ops.get_string(p, "name", "") == proptype &&
      Builtins.issubstring(
        Ops.get_string(p, "archs", "dummy"),
        Arch.arch_short
      )
  end

  Builtins.y2debug("3. arch proposals: %1", arch_proposals)

  props = Builtins.filter(props) do |p|
    Ops.get_string(p, "archs", "") == "" ||
      Ops.get_string(p, "archs", "") == "all"
  end

  Builtins.y2debug("4. other proposals: %1", props)
  # If architecture specific proposals are available, we continue with those
  # and check for proposal type, else we continue with pre arch proposal
  # list
  if Ops.greater_than(Builtins.size(arch_proposals), 0)
    props = Builtins.filter(arch_proposals) do |p|
      Ops.get_string(p, "name", "") == proptype
    end
    Builtins.y2debug("5. arch proposals: %1", props)
  else
    props = Builtins.filter(props) do |p|
      Ops.get_string(p, "name", "") == proptype
    end
    Builtins.y2debug("5. other proposals: %1", props)
  end

  if Ops.greater_than(Builtins.size(props), 1)
    Builtins.y2error(
      "Something Wrong happened, more than one proposal after filter:\n                %1",
      props
    )
  end

  # old style proposal
  Builtins.y2milestone(
    "Proposal modules: %1",
    Ops.get(props, [0, "proposal_modules"])
  )
  deep_copy(props)
end

- (Hash) getModeDefaults(stage, mode)

Get workflow defaults

Parameters:

  • stage (String)
  • mode (String)

Returns:

  • (Hash)

    defaults



577
578
579
580
# File '../../src/modules/ProductControl.rb', line 577

def getModeDefaults(stage, mode)
  workflow = FindMatchingWorkflow(stage, mode)
  Ops.get_map(workflow, "defaults", {})
end

- (Array<Hash>) getModules(stage, mode, which)

Get modules of current Workflow

Parameters:

  • stage (String)
  • mode (String)
  • boolean

    all enabled and disabled or enabled only

Returns:

  • (Array<Hash>)

    modules



686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
# File '../../src/modules/ProductControl.rb', line 686

def getModules(stage, mode, which)
  workflow = FindMatchingWorkflow(stage, mode)

  modules = Ops.get_list(workflow, "modules", [])
  Builtins.y2debug("M1: %1", modules)

  # Unique IDs have to always keep the same because some steps
  # can be disabled while YaST is running
  # @see BNC #575092
  id = 1
  modules = Builtins.maplist(modules) do |m|
    Ops.set(m, "id", Builtins.sformat("%1_%2", stage, id))
    id = Ops.add(id, 1)
    deep_copy(m)
  end

  modules = Builtins.filter(modules) do |m|
    Ops.get_boolean(m, "enabled", true) && !checkDisabled(m)
  end if which == :enabled

  Builtins.y2debug("M2: %1", modules)

  modules = Builtins.maplist(modules) do |m|
    PrepareScripts(m)
    deep_copy(m)
  end

  Builtins.y2debug("M3: %1", modules)
  Builtins.y2debug("Log files: %1", @logfiles)
  deep_copy(modules)
end

- (Object) getProposalProperties(stage, mode, proptype)

Return proposal Label



1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
# File '../../src/modules/ProductControl.rb', line 1274

def getProposalProperties(stage, mode, proptype)
  got_proposals = getMatchingProposal(stage, mode, proptype)
  proposal = Ops.get(got_proposals, 0, {})

  if Builtins.haskey(proposal, "proposal_tabs")
    text_domain = Ops.get_string(@productControl, "textdomain", "control")
    Ops.set(
      proposal,
      "proposal_tabs",
      Builtins.maplist(Ops.get_list(proposal, "proposal_tabs", [])) do |tab|
        domain = Ops.get_string(tab, "textdomain", text_domain)
        Ops.set(
          tab,
          "label",
          Builtins.dgettext(domain, Ops.get_string(tab, "label", ""))
        )
        deep_copy(tab)
      end
    )
  end

  deep_copy(proposal)
end

- (Array<String>) getProposals(stage, mode, proptype)

Get modules of current Workflow

Parameters:

  • stage (String)
  • mode (String)

Returns:

  • (Array<String>)

    modules



1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
# File '../../src/modules/ProductControl.rb', line 1184

def getProposals(stage, mode, proptype)
  props = getMatchingProposal(stage, mode, proptype)
  unique_id = Ops.get_string(props, [0, "unique_id"], "")
  disabled_subprops = GetDisabledSubProposals()

  final_proposals = []
  Builtins.foreach(Ops.get_list(props, [0, "proposal_modules"], [])) do |p|
    proposal_name = ""
    order_value = 50
    if Ops.is_string?(p)
      proposal_name = Convert.to_string(p)
    else
      pm = Convert.convert(p, :from => "any", :to => "map <string, string>")
      proposal_name = Ops.get(pm, "name", "")
      proposal_order = Ops.get(pm, "presentation_order", "50")

      order_value = Builtins.tointeger(proposal_order)
      if order_value == nil
        Builtins.y2error(
          "Unable to use '%1' as proposal order, using %2 instead",
          proposal_order,
          50
        )
        order_value = 50
      end
    end
    is_disabled = Builtins.haskey(disabled_subprops, unique_id) &&
      Builtins.contains(
        Ops.get(disabled_subprops, unique_id, []),
        proposal_name
      )
    # All proposal file names end with _proposal
    if !is_disabled
      if !Builtins.issubstring(proposal_name, "_proposal")
        final_proposals = Builtins.add(
          final_proposals,
          [Ops.add(proposal_name, "_proposal"), order_value]
        )
      else
        final_proposals = Builtins.add(
          final_proposals,
          [proposal_name, order_value]
        )
      end
    else
      Builtins.y2milestone(
        "Proposal module %1 found among disabled subproposals",
        proposal_name
      )
    end
  end

  Builtins.y2debug("final proposals: %1", final_proposals)
  deep_copy(final_proposals)
end

- (Object) getProposalTextDomain

Return text domain



1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
# File '../../src/modules/ProductControl.rb', line 1258

def getProposalTextDomain
  current_proposal_textdomain = Ops.get_string(
    @productControl,
    "textdomain",
    "control"
  )

  Builtins.y2debug(
    "Using textdomain '%1' for proposals",
    current_proposal_textdomain
  )
  current_proposal_textdomain
end

- (Object) GetTranslatedText(key)



1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
# File '../../src/modules/ProductControl.rb', line 1298

def GetTranslatedText(key)
  controlfile_texts = ProductFeatures.GetSection("texts")

  if !Builtins.haskey(controlfile_texts, key)
    Builtins.y2error("No such text %1", key)
    return ""
  end

  text = Ops.get_map(controlfile_texts, key, {})

  label = Ops.get(text, "label", "")

  # an empty string doesn't need to be translated
  return "" if label == ""

  domain = Ops.get(
    text,
    "textdomain",
    Ops.get_string(@productControl, "textdomain", "control")
  )
  if domain == ""
    Builtins.y2warning("The text domain for label %1 not set", key)
    return label
  end

  Builtins.dgettext(domain, label)
end

- (Boolean) GetUseAutomaticConfiguration

Returns whether automatic configuration will be enabled.

Returns:

  • (Boolean)

    if enabled



1057
1058
1059
1060
1061
1062
# File '../../src/modules/ProductControl.rb', line 1057

def GetUseAutomaticConfiguration
  # lazy loading
  InitAutomaticConfiguration()

  @use_automatic_configuration
end

- (String) getWorkflowLabel(stage, mode, wz_td)

Get Workflow Label

Parameters:

  • stage (String)
  • mode (String)

Returns:

  • (String)


756
757
758
759
760
761
762
763
764
765
766
767
768
769
# File '../../src/modules/ProductControl.rb', line 756

def getWorkflowLabel(stage, mode, wz_td)
  workflow = FindMatchingWorkflow(stage, mode)

  label = Ops.get_string(workflow, "label", "")
  return "" if label == ""
  if Builtins.haskey(workflow, "textdomain")
    return Builtins.dgettext(
      Ops.get_string(workflow, "textdomain", ""),
      label
    )
  else
    return Builtins.dgettext(wz_td, label)
  end
end

- (Boolean) Init

Initialize Product Control

Returns:

  • (Boolean)

    True on success



1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
# File '../../src/modules/ProductControl.rb', line 1329

def Init
  ret = false
  @current_control_file = ""
  order = [
    @y2update_control_file, # /y2update/control.xml
    @default_control_file, # /control.xml
    @saved_control_file, # /etc/YaST2/control.xml
    @packaged_control_file
  ] # /usr/share/YaST2/control/control.xml

  if @custom_control_file != ""
    order = Builtins.prepend(order, @custom_control_file)
  end

  Builtins.y2milestone("Candidates: %1", order)
  Builtins.foreach(order) do |control_file|
    if FileUtils.Exists(control_file) && @current_control_file == ""
      @current_control_file = control_file
      raise Break
    end
  end

  if @current_control_file == ""
    Builtins.y2error("No control file found")

    return false
  end

  Builtins.y2milestone("Reading control file: %1", @current_control_file)
  ReadControlFile(@current_control_file)

  @current_control_file != ""
end

- (Object) InitAutomaticConfiguration

Inits the default value for use_automatic_configuration



1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
# File '../../src/modules/ProductControl.rb', line 1012

def InitAutomaticConfiguration
  return if @use_automatic_configuration != nil

  # AytoYaST default - not to use Automatic configuration at all
  if Mode.autoinst || Mode.config
    @use_automatic_configuration = false 
    # The rest is on user
    # FIXME: read the default value from control file
  else
    @use_automatic_configuration = false
  end

  Builtins.y2milestone(
    "Default 'UseAutomaticConfiguration': %1",
    @use_automatic_configuration
  )

  nil
end

- (Object) main



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
# File '../../src/modules/ProductControl.rb', line 37

def main
  Yast.import "UI"
  textdomain "base"

  Yast.import "XML"
  Yast.import "ProductFeatures"
  Yast.import "Mode"
  Yast.import "Arch"
  Yast.import "Stage"
  Yast.import "Directory"
  Yast.import "Label"
  Yast.import "Wizard"
  Yast.import "Report"
  Yast.import "Hooks"
  Yast.import "Popup"
  Yast.import "FileUtils"
  Yast.import "Installation"

  # The complete parsed control file
  @productControl = {}

  # all workflows
  @workflows = []

  # all proposals
  @proposals = []

  # inst_finish steps
  @inst_finish = []

  # modules to be offered to clone configuration at the end of installation
  @clone_modules = []

  # additional workflow parameters
  # workflow doesn't only match mode and stage but also these params
  # bnc #427002
  @_additional_workflow_params = {}

  # Location of a custom control file
  @custom_control_file = ""

  # Control file in service packs
  @y2update_control_file = "/y2update/control.xml"

  # The custom control file location, usually copied from
  # the root of the CD to the installation directory by linuxrc
  @default_control_file = "/control.xml"

  # The file above get saved into the installed system for later
  # processing
  @saved_control_file = Ops.add(Directory.etcdir, "/control.xml")

  # The packaged file which contains all default worklfows
  @packaged_control_file = "/usr/share/YaST2/control/control.xml"

  # The control file we are using for this session.
  @current_control_file = ""


  # Current Wizard Step
  @CurrentWizardStep = ""


  # Last recently used stage_mode for RetranslateWizardSteps
  @last_stage_mode = []


  # -->

  # Currently only local variables, they have their own API

  # List of module to disable in the current run
  @DisabledModules = []

  # List of proposals to disable in the current run
  @DisabledProposals = []

  @DisabledACItems = {}

  @DisabledSubProposals = {}

  # <--

  # Log files for hooks
  @logfiles = []

  @first_step = nil

  @restarting_step = nil




  @_client_prefix = "inst_"

  @stack = []


  @first_id = ""

  @current_step = 0

  @localDisabledProposals = []
  @localDisabledModules = []

  @already_disabled_workflows = []

  # Forces UpdateWizardSteps to redraw steps even if nothing seem to be changed
  @force_UpdateWizardSteps = false

  # -->
  # Installation without second stage
  # "Automatic Configuration"

  @use_automatic_configuration = nil

  # <--

  @lastDisabledModules = deep_copy(@DisabledModules)
  ProductControl()
end

- (void) PrepareScripts(m)

This method returns an undefined value.

Prepare Workflow Scripts

Parameters:

  • m (Hash)

    Workflow module map



585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
# File '../../src/modules/ProductControl.rb', line 585

def PrepareScripts(m)
  m = deep_copy(m)
  tmp_dir = Convert.to_string(WFM.Read(path(".local.tmpdir"), []))
  if Builtins.haskey(m, "prescript")
    interpreter = Ops.get_string(m, ["prescript", "interpreter"], "shell")
    source = Ops.get_string(m, ["prescript", "source"], "")
    type = interpreter == "shell" ? "sh" : "pl"
    f = Builtins.sformat(
      "%1/%2_pre.%3",
      tmp_dir,
      Ops.get_string(m, "name", ""),
      type
    )
    WFM.Write(path(".local.string"), f, source)
    @logfiles = Builtins.add(
      @logfiles,
      Builtins.sformat(
        "%1.log",
        Builtins.sformat("%1_pre.%2", Ops.get_string(m, "name", ""), type)
      )
    )
  end
  if Builtins.haskey(m, "postscript")
    interpreter = Ops.get_string(m, ["postscript", "interpreter"], "shell")
    source = Ops.get_string(m, ["postscript", "source"], "")
    type = interpreter == "shell" ? "sh" : "pl"
    f = Builtins.sformat(
      "%1/%2_post.%3",
      tmp_dir,
      Ops.get_string(m, "name", ""),
      type
    )
    WFM.Write(path(".local.string"), f, source)
    @logfiles = Builtins.add(
      @logfiles,
      Builtins.sformat(
        "%1.log",
        Builtins.sformat("%1_post.%2", Ops.get_string(m, "name", ""), type)
      )
    )
  end
  nil
end

- (void) ProductControl

This method returns an undefined value.

ProductControl Constructor



1724
1725
1726
1727
# File '../../src/modules/ProductControl.rb', line 1724

def ProductControl
  Builtins.y2error("control file missing") if !Init()
  nil
end

- (Boolean) ReadControlFile(controlfile)

Read XML Control File

Parameters:

  • string

    control file

Returns:

  • (Boolean)


353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
# File '../../src/modules/ProductControl.rb', line 353

def ReadControlFile(controlfile)
  @productControl = XML.XMLToYCPFile(controlfile)

  return false if @productControl == nil

  @workflows = Ops.get_list(@productControl, "workflows", [])
  @proposals = Ops.get_list(@productControl, "proposals", [])
  @inst_finish = Ops.get_list(@productControl, "inst_finish_stages", [])
  @clone_modules = Ops.get_list(@productControl, "clone_modules", [])

  Builtins.foreach(
    ["software", "globals", "network", "partitioning", "texts"]
  ) do |section|
    if Builtins.haskey(@productControl, section)
      ProductFeatures.SetSection(
        section,
        Ops.get_map(@productControl, section, {})
      )
    end
  end

  # FIXME would be nice if it could be done generic way
  if Ops.greater_than(
      Builtins.size(
        Ops.get_list(@productControl, ["partitioning", "partitions"], [])
      ),
      0
    )
    partitioning = Ops.get_map(@productControl, "partitioning", {})
    ProductFeatures.SetBooleanFeature(
      "partitioning",
      "flexible_partitioning",
      true
    )
    ProductFeatures.SetFeature(
      "partitioning",
      "FlexiblePartitioning",
      partitioning
    )
  end

  true
end

- (Array<String>) RequiredFiles(stage, mode)

Get list of required files for the workflow. TODO FIXME: this function seems to be unused, remove it?

Returns:

  • (Array<String>)

    Required files list.



634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
# File '../../src/modules/ProductControl.rb', line 634

def RequiredFiles(stage, mode)
  # Files needed during installation.
  needed_client_files = []

  workflow = FindMatchingWorkflow(stage, mode)

  modules = Ops.get_list(workflow, "modules", [])
  id = 1
  modules = Builtins.filter(modules) do |m|
    Ops.get_boolean(m, "enabled", true)
  end

  Builtins.foreach(modules) do |m|
    client = ""
    if Stage.firstboot
      client = Ops.get_string(m, "name", "dummy")
    else
      if Builtins.issubstring(Ops.get_string(m, "name", "dummy"), "inst_")
        client = Ops.get_string(m, "name", "dummy")
      else
        client = Ops.add("inst_", Ops.get_string(m, "name", "dummy"))
      end
    end
    # TODO FIXME: what about the ruby files?
    client = Ops.add(
      Ops.add(Ops.add(Directory.clientdir, "/"), client),
      ".ycp"
    )
    needed_client_files = Builtins.add(needed_client_files, client)
  end

  needed_client_files = Builtins.toset(needed_client_files)
  deep_copy(needed_client_files)
end

- (Object) ResetAdditionalWorkflowParams

Resets all additional params for selecting the workflow

See Also:

  • #SetAdditionalWorkflowParams()


1748
1749
1750
1751
1752
# File '../../src/modules/ProductControl.rb', line 1748

def ResetAdditionalWorkflowParams
  @_additional_workflow_params = {}

  nil
end

- (Object) RestartingStep

Return step which restarted YaST (or rebooted the system)

Returns:

  • a map describing the step



1715
1716
1717
1718
1719
# File '../../src/modules/ProductControl.rb', line 1715

def RestartingStep
  return nil if @restarting_step == nil
  modules = getModules(Stage.stage, Mode.mode, :enabled)
  Ops.get(modules, @restarting_step, {})
end

- (Object) retranslateWizardDialog

Re-translate static part of wizard dialog and other predefined messages after language change



1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
# File '../../src/modules/ProductControl.rb', line 1365

def retranslateWizardDialog
  Builtins.y2milestone("Retranslating messages, redrawing wizard steps")

  # Make sure the labels for default function keys are retranslated, too.
  # Using Label::DefaultFunctionKeyMap() from Label module.
  UI.SetFunctionKeys(Label.DefaultFunctionKeyMap)

  # Activate language changes on static part of wizard dialog
  RetranslateWizardSteps()
  Wizard.RetranslateButtons
  Wizard.SetFocusToNextButton
  nil
end

- (Object) RetranslateWizardSteps

Retranslate Wizard Steps



1089
1090
1091
1092
1093
1094
1095
1096
1097
# File '../../src/modules/ProductControl.rb', line 1089

def RetranslateWizardSteps
  if Ops.greater_than(Builtins.size(@last_stage_mode), 0)
    Builtins.y2debug("Retranslating wizard steps")
    @force_UpdateWizardSteps = true
    UpdateWizardSteps(@last_stage_mode)
  end

  nil
end

- (Object) Run

Run Workflow



1690
1691
1692
1693
1694
# File '../../src/modules/ProductControl.rb', line 1690

def Run
  ret = RunFrom(0, false)
  Builtins.y2milestone("Run() returning %1", ret)
  ret
end

- (Object) RunFrom(from, allow_back)



1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
# File '../../src/modules/ProductControl.rb', line 1390

def RunFrom(from, allow_back)
  former_result = :next
  final_result = nil
  @current_step = from # current module

  Wizard.SetFocusToNextButton

  Builtins.y2debug(
    "Starting Workflow with  \"%1\" \"%2\"",
    Stage.stage,
    Mode.mode
  )

  modules = getModules(Stage.stage, Mode.mode, :enabled)

  defaults = getModeDefaults(Stage.stage, Mode.mode)

  Builtins.y2debug("modules: %1", modules)

  if Builtins.size(modules) == 0
    Builtins.y2error("No workflow found: %1", modules)
    # error report
    Report.Error(_("No workflow defined for this installation mode."))
    return :abort
  end

  minimum_step = allow_back ? 0 : from

  if Ops.less_than(minimum_step, from)
    Builtins.y2warning(
      "Minimum step set to: %1 even if running from %2, fixing",
      minimum_step,
      from
    )
    minimum_step = from
  end

  while Ops.greater_or_equal(@current_step, 0) &&
      Ops.less_than(@current_step, Builtins.size(modules))
    step = Ops.get(modules, @current_step, {})
    Builtins.y2milestone("Current step: %1", step)

    step_name = Ops.get_string(step, "name", "")
    # BNC #401319
    # if "execute" is defined, it's called without modifications
    step_execute = Ops.get_string(step, "execute", "")
    step_id = Ops.get_string(step, "id", "")
    run_in_update_mode = Ops.get_boolean(step, "update", true) # default is true
    retranslate = Ops.get_boolean(step, "retranslate", false)

    # The very first dialog has back button disabled
    if Ops.less_or_equal(@current_step, minimum_step)
      # Don't mark back button disabled when back button status
      # is forced in the control file
      if !Builtins.haskey(step, "enable_back")
        Ops.set(step, "enable_back", "no")
        Builtins.y2milestone(
          "Disabling back: %1 %2 %3",
          @current_step,
          minimum_step,
          Ops.get(step, "enable_back")
        )
      end
    end

    do_continue = false

    do_continue = true if !checkArch(step, defaults)

    do_continue = true if checkDisabled(step)

    do_continue = true if checkHeading(step)

    do_continue = true if !run_in_update_mode && Mode.update

    if do_continue
      if former_result == :next
        if Ops.less_or_equal(@current_step, minimum_step) && !allow_back
          minimum_step = Ops.add(minimum_step, 1)
        end
        @current_step = Ops.add(@current_step, 1)
      else
        @current_step = Ops.subtract(@current_step, 1)
      end
    end
    # Continue in 'while' means 'next step'
    next if do_continue

    argterm = getClientTerm(step, defaults, former_result)
    Builtins.y2milestone("Running module: %1 (%2)", argterm, @current_step)

    module_name = Builtins.symbolof(argterm)

    Builtins.y2milestone("Calling %1", argterm)

    if !wasRun(step_name)
      Hooks.Checkpoint(Builtins.sformat("%1", module_name), true)
      Hooks.Run(step_name, true)
    end

    args = []
    i = 0
    while Ops.less_than(i, Builtins.size(argterm))
      _def = nil
      Ops.set(args, i, Ops.get(argterm, i, _def))
      i = Ops.add(i, 1)
    end

    UI.WizardCommand(term(:SetCurrentStep, step_id))
    @CurrentWizardStep = step_id

    # Register what step we are going to run
    if !Stage.initial
      if !SCR.Write(
          path(".target.string"),
          Installation.current_step,
          step_id
        )
        Builtins.y2error("Error writing step identifier")
      end
    end

    result = Convert.to_symbol(
      WFM.CallFunction(getClientName(step_name, step_execute), args)
    )
    Builtins.y2milestone("Calling %1 returned %2", argterm, result)

    # bnc #369846
    if result == :accept || result == :ok
      Builtins.y2milestone("Evaluating %1 as it was `next", result)
      result = :next
    end

    # Clients can break the installation/workflow
    Wizard.RestoreNextButton
    Wizard.RestoreAbortButton
    Wizard.RestoreBackButton

    # Remove file if step was run and returned (without a crash);
    if Ops.less_than(@current_step, Ops.subtract(Builtins.size(modules), 1)) &&
        !Stage.initial
      if !Convert.to_boolean(
          SCR.Execute(path(".target.remove"), Installation.current_step)
        )
        Builtins.y2error("Error removing step identifier")
      end
    end

    # Dont call hook scripts after installation is done. (#36831)
    if Ops.less_than(@current_step, Ops.subtract(Builtins.size(modules), 1)) &&
        !wasRun(step_name)
      Hooks.Run(step_name, false)
    else
      Builtins.y2milestone(
        "Not running hooks at the end of the installation"
      )
    end

    # This should be safe (#36831)
    Hooks.Checkpoint(step_name, false) # exit hook

    addToStack(step_name)

    if retranslate
      Builtins.y2milestone("retranslate")
      retranslateWizardDialog
      retranslate = false
    end

    # If the module return nil, something basic went wrong.
    # We show a stub dialog instead.
    if result == nil
      # If workflow module is marked as optional, skip if it returns nil,
      # For example, if it is not installed.
      if Ops.get_boolean(step, "optional", false)
        Builtins.y2milestone(
          "Skipping optional %1",
          Builtins.symbolof(argterm)
        )
        @current_step = Ops.add(@current_step, 1)
        next
      end

      r = nil
      r = Popup.ModuleError(
        Builtins.sformat(
          # TRANSLATORS: an error message
          # this should not happen, but life is cruel...
          # %1 - (failed) module name
          # %2 - logfile, possibly with errors
          # %3 - link to our bugzilla
          # %4 - directory where YaST logs are stored
          # %5 - link to the Yast Bug Reporting HOWTO Web page
          "Calling the YaST module %1 has failed.\n" +
            "More information can be found near the end of the '%2' file.\n" +
            "\n" +
            "This is worth reporting a bug at %3.\n" +
            "Please, attach also all YaST logs stored in the '%4' directory.\n" +
            "See %5 for more information about YaST logs.",
          Builtins.symbolof(argterm),
          "/var/log/YaST2/y2log",
          "http://bugzilla.novell.com/",
          "/var/log/YaST2/",
          # link to the Yast Bug Reporting HOWTO
          # for translators: use the localized page for your language if it exists,
          # check the combo box "In other laguages" on top of the page
          _("http://en.opensuse.org/Bugs/YaST")
        )
      )

      if r == :next
        @current_step = Ops.add(@current_step, 1)
      elsif r == :back
        @current_step = Ops.subtract(@current_step, 1)
      elsif r != :again
        UI.CloseDialog
        return nil
      end
      next
    end

    # BNC #468677
    # The very first dialog must not exit with `back
    # or `auto
    if @current_step == 0 &&
        (result == :back || result == :auto && former_result == :back)
      Builtins.y2warning(
        "Returned %1, Current step %2 (%3). The current step will be called again...",
        result,
        @current_step,
        step_name
      )
      former_result = :next
      result = :again
    end

    if result == :next
      @current_step = Ops.add(@current_step, 1)
    elsif result == :back
      @current_step = Ops.subtract(@current_step, 1)
    elsif result == :cancel
      break
    elsif result == :abort
      # handling when user aborts the workflow (FATE #300422, bnc #406401, bnc #247552)
      final_result = result

      break
    elsif result == :finish
      break
    elsif result == :again
      next # Show same dialog again
    # BNC #475650: Adding `reboot_same_step
    elsif result == :restart_yast || result == :restart_same_step ||
        result == :reboot ||
        result == :reboot_same_step
      final_result = result
      break
    elsif result == :auto
      if former_result != nil
        if former_result == :next
          # if the first client just returns `auto, the back button
          # of the next client must be disabled
          if Ops.less_or_equal(@current_step, minimum_step) && !allow_back
            minimum_step = Ops.add(minimum_step, 1)
          end
          @current_step = Ops.add(@current_step, 1)
        elsif former_result == :back
          @current_step = Ops.subtract(@current_step, 1)
        end
      end
      next
    end
    former_result = result
  end
  final_result = :abort if former_result == :abort

  Builtins.y2milestone(
    "Former result: %1, Final result: %2",
    former_result,
    final_result
  )

  if final_result != nil
    Builtins.y2milestone("Final result already set.")
  elsif Ops.less_or_equal(@current_step, -1)
    final_result = :back
  else
    final_result = :next
  end

  Builtins.y2milestone(
    "Current step: %1, Returning: %2",
    @current_step,
    final_result
  )
  final_result
end

- (Boolean) RunRequired(stage, mode)

Returns whether is is required to run YaST in the defined stage and mode

Parameters:

  • stage (String)
  • mode (String)

Returns:

  • (Boolean)

    if needed



724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
# File '../../src/modules/ProductControl.rb', line 724

def RunRequired(stage, mode)
  modules = getModules(stage, mode, :enabled)

  if modules == nil
    Builtins.y2error("Undefined %1/%2", stage, mode)
    return nil
  end

  modules = Builtins.filter(modules) do |one_module|
    # modules
    if Ops.get_string(one_module, "name", "") != nil &&
        Ops.get_string(one_module, "name", "") != ""
      next true 
      # proposals
    elsif Ops.get_string(one_module, "proposal", "") != nil &&
        Ops.get_string(one_module, "proposal", "") != ""
      next true
    end
    # the rest
    false
  end

  # for debugging purposes
  Builtins.y2milestone("Enabled: (%1) %2", Builtins.size(modules), modules)

  Ops.greater_than(Builtins.size(modules), 0)
end

- (Object) SetAdditionalWorkflowParams(params)

Sets additional params for selecting the workflow

Examples:

SetAdditionalWorkflowParams ($[“add_on_mode”:“update”]);

SetAdditionalWorkflowParams ($[“add_on_mode”:“installation”]);

Parameters:

  • params (Hash{String => Object})


1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
# File '../../src/modules/ProductControl.rb', line 1734

def SetAdditionalWorkflowParams(params)
  params = deep_copy(params)
  Builtins.y2milestone(
    "Adjusting new additional workflow params: %1",
    params
  )

  @_additional_workflow_params = deep_copy(params)

  nil
end

- (Object) setClientPrefix(prefix)

Set Client Prefix



165
166
167
168
# File '../../src/modules/ProductControl.rb', line 165

def setClientPrefix(prefix)
  @_client_prefix = prefix
  nil
end

- (Object) SetUseAutomaticConfiguration(set_param)

Adjust the automatic configuration to be either enabled or disabled. Enabling it means that second stage will be disabled.

Parameters:

  • boolean

    enabled



1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
# File '../../src/modules/ProductControl.rb', line 1036

def SetUseAutomaticConfiguration(set_param)
  if set_param == nil
    Builtins.y2error(
      "Automatic configuration can be either enabled or disabled, not nil!"
    )
    return
  end

  @use_automatic_configuration = set_param

  Builtins.y2milestone(
    "UseAutomaticConfiguration has been set to: %1",
    @use_automatic_configuration
  )

  nil
end

- (Object) SkippedSteps

List steps which were skipped since last restart of YaST

Returns:

  • a list of maps describing the steps



1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
# File '../../src/modules/ProductControl.rb', line 1700

def SkippedSteps
  modules = getModules(Stage.stage, Mode.mode, :enabled)
  return nil if @first_step == nil
  return nil if Ops.greater_or_equal(@first_step, Builtins.size(modules))
  index = 0
  ret = []
  while Ops.less_than(index, @first_step)
    ret = Builtins.add(ret, Ops.get(modules, index, {}))
    index = Ops.add(index, 1)
  end
  deep_copy(ret)
end

- (Object) UnDisableAllModulesAndProposals(mode, stage)



822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
# File '../../src/modules/ProductControl.rb', line 822

def UnDisableAllModulesAndProposals(mode, stage)
  this_workflow = { "mode" => mode, "stage" => stage }

  # Such mode/stage not disabled
  if !Builtins.contains(@already_disabled_workflows, this_workflow)
    Builtins.y2milestone(
      "Not yet disabled, not un-disabling: %1",
      this_workflow
    )
    return
  end

  Builtins.y2milestone("Un-Disabling workflow %1", this_workflow)
  @already_disabled_workflows = Builtins.filter(@already_disabled_workflows) do |one_workflow|
    one_workflow != this_workflow
  end

  # Note: This might be done by a simple reverting with 'X = localX'
  #       but some of these modules don't need to be in a defined mode and stage

  Builtins.foreach(getModules(stage, mode, :all)) do |m|
    # A proposal
    # Enable it only if it was enabled before
    if Ops.get_string(m, "proposal", "") != nil &&
        Ops.get_string(m, "proposal", "") != "" &&
        !Builtins.contains(
          @localDisabledProposals,
          Ops.get_string(m, "proposal", "")
        )
      Builtins.y2milestone("Enabling proposal: %1", m)
      @DisabledProposals = Builtins.filter(@DisabledProposals) do |one_proposal|
        Ops.get_string(m, "proposal", "") != one_proposal
      end 
      # A module
      # Enable it only if it was enabled before
    elsif Ops.get_string(m, "name", "") != nil &&
        Ops.get_string(m, "name", "") != "" &&
        !Builtins.contains(
          @localDisabledModules,
          Ops.get_string(m, "name", "")
        )
      Builtins.y2milestone("Enabling module: %1", m)
      @DisabledModules = Builtins.filter(@DisabledModules) do |one_module|
        Ops.get_string(m, "name", "") != one_module
      end
    end
  end

  nil
end

- (Object) UpdateWizardSteps(stagemode)

Update Steps



1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
# File '../../src/modules/ProductControl.rb', line 1065

def UpdateWizardSteps(stagemode)
  stagemode = deep_copy(stagemode)
  if @force_UpdateWizardSteps == true
    Builtins.y2milestone("UpdateWizardSteps forced")
    @force_UpdateWizardSteps = false
  elsif @DisabledModules != @lastDisabledModules
    Builtins.y2milestone("Disabled modules were changed")
  elsif @last_stage_mode == stagemode
    Builtins.y2milestone("No changes in Wizard steps")
    return
  end

  @last_stage_mode = deep_copy(stagemode)
  @lastDisabledModules = deep_copy(@DisabledModules)

  UI.WizardCommand(term(:DeleteSteps))
  # Also redraws the wizard and sets the current step
  AddWizardSteps(stagemode)

  nil
end

- (Object) wasRun(name)



1386
1387
1388
# File '../../src/modules/ProductControl.rb', line 1386

def wasRun(name)
  Builtins.contains(@stack, name)
end