Module: Yast::ProductCreatorRoutinesInclude

Defined in:
../../src/include/product-creator/routines.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) get_bootdir(config, task)

get the value of boot image directory



94
95
96
97
98
99
100
101
102
103
104
# File '../../src/include/product-creator/routines.rb', line 94

def get_bootdir(config, task)
  config = deep_copy(config)
  dir = ""
  Builtins.foreach(Ops.get_list(config, ["preferences", 0, "type"], [])) do |typemap|
    if task == Ops.get_string(typemap, "image", "")
      dir = Ops.get_string(typemap, "boot", "")
      raise Break
    end
  end
  dir
end

- (Object) get_current_size_map(config, task)

return the size info for current image type



81
82
83
84
85
86
87
88
89
90
# File '../../src/include/product-creator/routines.rb', line 81

def get_current_size_map(config, task)
  config = deep_copy(config)
  ret = {}
  Builtins.foreach(Ops.get_list(config, ["preferences", 0, "type"], [])) do |typemap|
    if task == Ops.get_string(typemap, "image", "")
      ret = Ops.get_map(typemap, ["size", 0], {})
    end
  end
  deep_copy(ret)
end

- (Object) get_current_task(config)

get the primary value of image type to be built ('type' from 'preferences')



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File '../../src/include/product-creator/routines.rb', line 61

def get_current_task(config)
  config = deep_copy(config)
  task = ""
  Builtins.foreach(Ops.get_list(config, ["preferences", 0, "type"], [])) do |typemap|
    if task == "" # take the 1st one if none is default
      task = Ops.get_string(typemap, "image", task)
    end
    if Builtins.tolower(Ops.get_string(typemap, "primary", "false")) == "true"
      task = Ops.get_string(typemap, "image", task)
      raise Break
    end
  end
  if task == ""
    Builtins.y2milestone("no task found, setting to 'iso'")
    task = "iso"
  end
  task
end

- (Object) get_description(config, key)

shortcut for returning “descripton” value from a map describing config.xml



38
39
40
41
# File '../../src/include/product-creator/routines.rb', line 38

def get_description(config, key)
  config = deep_copy(config)
  Ops.get_string(config, ["description", 0, key, 0, Kiwi.content_key], "")
end

- (Object) get_preferences(config, key, defval)

shortcut for returning “preferences” value from a map describing config.xml



44
45
46
47
48
49
50
51
# File '../../src/include/product-creator/routines.rb', line 44

def get_preferences(config, key, defval)
  config = deep_copy(config)
  defval = deep_copy(defval)
  Builtins.sformat(
    "%1",
    Ops.get(config, ["preferences", 0, key, 0, Kiwi.content_key], defval)
  )
end

- (Object) initialize_product_creator_routines(include_target)



30
31
32
33
34
35
# File '../../src/include/product-creator/routines.rb', line 30

def initialize_product_creator_routines(include_target)
  textdomain "product-creator"

  Yast.import "Kiwi"
  Yast.import "Progress"
end

- (Object) save_preferences(config, key, val)

update the whole map with a new key in preferences section



54
55
56
57
58
# File '../../src/include/product-creator/routines.rb', line 54

def save_preferences(config, key, val)
  config = deep_copy(config)
  Ops.set(config, ["preferences", 0, key], [{ Kiwi.content_key => val }])
  deep_copy(config)
end