Class: Yast::InstAddOnClient

Inherits:
Client
  • Object
show all
Defined in:
src/clients/inst_add-on.rb

Overview

Note:

This client should not be called from other clients directly via WFM.call (only from the control.xml file), it can restart the workflow from the next step and return to the caller AFTER the complete workflow is finished (or aborted)

Instance Method Summary (collapse)

Instance Method Details

- (Object) main



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
# File 'src/clients/inst_add-on.rb', line 14

def main
  Yast.import "UI"
  Yast.import "Pkg"
  textdomain "add-on"

  Yast.import "AddOnProduct"
  Yast.import "GetInstArgs"
  Yast.import "Packages"
  Yast.import "PackageCallbacks"
  Yast.import "Popup"
  Yast.import "ProductControl"
  Yast.import "Report"
  Yast.import "Wizard"
  Yast.import "Label"
  Yast.import "Installation"
  Yast.import "Linuxrc"
  Yast.import "String"

  Yast.include self, "add-on/add-on-workflow.rb"

  if AddOnProduct.skip_add_ons
    Builtins.y2milestone("Skipping add-ons (as requested before)")
    return :auto
  end

  @argmap = GetInstArgs.argmap

  Packages.SelectProduct

  PackageCallbacks.SetMediaCallbacks

  # add add-ons specified on the kernel command line
  @addon_opt = Linuxrc.InstallInf("addon")

  # add the add-ons just once, skip adding if any add-on is
  # already present (handle going back and forth properly)
  if @addon_opt != nil && AddOnProduct.add_on_products == []
    Builtins.y2milestone("Specified extra add-ons via kernel cmdline")

    # store the add-ons list into a temporary file
    @tmp_dir = Convert.to_string(SCR.Read(path(".target.tmpdir")))
    @tmp_file = Ops.add(@tmp_dir, "/tmp_addon_list")
    # each add-on on a separate line
    @addons = String.Replace(@addon_opt, ",", "\n")

    # network setup is needed for local media installation (e.g. DVD) with remote Add-ons
    @ret2 = NetworkSetupForAddons(Builtins.splitstring(@addons, "\n"))

    return @ret2 if Builtins.contains([:back, :abort], @ret2)

    SCR.Write(path(".target.string"), @tmp_file, @addons)

    # import the add-ons from the temporary file
    AddOnProduct.AddPreselectedAddOnProducts(
      [{ "file" => @tmp_file, "type" => "plain" }]
    )

    # remove the temporary file
    SCR.Execute(
      path(".target.bash"),
      Builtins.sformat("/bin/rm -rf '%1'", String.Quote(@tmp_file))
    )
  end

  # the module was started because of the kernel command line option
  # so finish it after adding the add-ons, no UI is actually needed
  return :auto if Installation.add_on_selected == false

  @ret = RunAddOnMainDialog(
    GetInstArgs.enable_back,
    GetInstArgs.enable_next,
    true,
    Label.BackButton,
    Label.NextButton,
    Label.AbortButton,
    true
  )

  if @ret == :next
    # be careful when calling this client from other modules, this will
    # start the workflow from the next step and THEN return back
    # to the caller
    @ret = ProductControl.RunFrom(
      Ops.add(ProductControl.CurrentStep, 1),
      true
    )
    @ret = :finish if @ret == :next
  end

  @ret 

  # EOF
end

- (Object) NetworkSetupForAddons(addon_urls)

Ask to user to configure network for installing remote addons. User is aske when there is a remote add-on found and the network is not running yet.

Parameters:

  • addon_urls

    list of URLs

Returns:

  • symbol user input result (next,back or `abort)



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
# File 'src/clients/inst_add-on.rb', line 114

def NetworkSetupForAddons(addon_urls)
  addon_urls = deep_copy(addon_urls)
  # protocols locally available (no network needed)
  local_protocols = ["cd", "dvd", "hd"]

  # is this CD/DVD/HDD installation?
  if Builtins.contains(
      local_protocols,
      Builtins.tolower(Linuxrc.InstallInf("InstMode"))
    )
    # is there any remote addon requiring network setup?
    network_needed = false
    Builtins.foreach(addon_urls) do |url|
      # is it a remote protocol?
      if !Builtins.contains(
          local_protocols,
          Builtins.tolower(Ops.get_string(URL.Parse(url), "scheme", ""))
        )
        network_needed = true
        raise Break
      end
    end 


    if network_needed
      # check and setup network
      ret = Convert.to_symbol(WFM.CallFunction("inst_network_check", []))
      Builtins.y2milestone("inst_network_check ret: %1", ret)

      return ret if Builtins.contains([:back, :abort], ret)
    end
  end

  :next
end