Class: Yast::AddOnClient

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) main



10
11
12
13
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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'src/clients/add-on.rb', line 10

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

  Yast.import "AddOnProduct"
  Yast.import "Confirm"
  Yast.import "PackageLock"
  Yast.import "PackageCallbacks"
  Yast.import "Report"
  Yast.import "Wizard"
  Yast.import "GetInstArgs"
  Yast.import "Mode"
  Yast.import "CommandLine"
  Yast.import "Directory"
  Yast.import "XML"

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

  @wfm_args = WFM.Args
  Builtins.y2milestone("ARGS: %1", @wfm_args)

  @commands = CommandLine.Parse(@wfm_args)
  Builtins.y2debug("Commands: %1", @commands)

  # bnc #430852
  if Ops.get_string(@commands, "command", "") == "help" ||
      Ops.get_string(@commands, "command", "") == "longhelp"
    Mode.SetUI("commandline")
    # TRANSLATORS: commandline help
    CommandLine.Print(
      _(
        "\n" +
          "Add-on Module Help\n" +
          "------------------\n" +
          "\n" +
          "To add a new add-on product via the command-line, use this syntax:\n" +
          "    /sbin/yast2 add-on URL\n" +
          "URL is the path to the add-on source.\n" +
          "\n" +
          "Examples of URL:\n" +
          "http://server.name/directory/Lang-AddOn-10.2-i386/\n" +
          "ftp://server.name/directory/Lang-AddOn-10.2-i386/\n" +
          "nfs://server.name/directory/SDK1-SLE-i386/\n" +
          "disk://dev/sda5/directory/Product/CD1/\n" +
          "cd://\n" +
          "dvd://\n"
      )
    )
    return :auto
  elsif Ops.get_string(@commands, "command", "") == "xmlhelp"
    Mode.SetUI("commandline")
    if !Builtins.haskey(Ops.get_map(@commands, "options", {}), "xmlfile")
      CommandLine.Print(
        _(
          "Target file name ('xmlfile' option) is missing. Use xmlfile=<target_XML_file> command line option."
        )
      )
      return :auto
    else
      @doc = {}

      Ops.set(
        @doc,
        "listEntries",
        {
          "commands" => "command",
          "options"  => "option",
          "examples" => "example"
        }
      )
      Ops.set(
        @doc,
        "systemID",
        Ops.add(Directory.schemadir, "/commandline.dtd")
      )
      Ops.set(@doc, "typeNamespace", "http://www.suse.com/1.0/configns")
      Ops.set(@doc, "rootElement", "commandline")
      XML.xmlCreateDoc(:xmlhelp, @doc)

      @exportmap = { "module" => "add-on" }
      XML.YCPToXMLFile(
        :xmlhelp,
        @exportmap,
        Ops.get_string(@commands, ["options", "xmlfile"], "")
      )
      Builtins.y2milestone("exported XML map: %1", @exportmap)
      return :auto
    end
  end

  Wizard.CreateDialog

  Wizard.SetContents(
    # dialog caption
    _("Add-On Products"),
    # busy message (dialog)
    VBox(Label(_("Initializing..."))),
    # help
    _("<p>Initializing add-on products...</p>"),
    false,
    false
  )

  Wizard.SetDesktopTitleAndIcon("add-on")

  Wizard.DisableBackButton
  Wizard.DisableAbortButton
  Wizard.DisableNextButton

  # --> Initialization start

  # check whether running as root
  # and having the packager for ourselves
  if !Confirm.MustBeRoot || !PackageLock.Check
    UI.CloseDialog
    return :abort
  end

  # initialize target to import all trusted keys (#165849)
  Pkg.TargetInitialize("/")
  Pkg.TargetLoad

  PackageCallbacks.InitPackageCallbacks

  # Initialize current sources
  Read()
  @ret = nil

  # <-- Initialization finish

  Wizard.EnableAbortButton
  Wizard.EnableNextButton

  if Builtins.size(WFM.Args) == 0
    Builtins.y2milestone(
      "Url not specified in cmdline, starting full-featured module"
    )
    @ret = RunAddOnsOverviewDialog()
  else
    @url = Convert.to_string(WFM.Args(0))
    Builtins.y2milestone("Specified URL %1", @url)
    begin
      @createResult = SourceManager.createSource(@url)
      Builtins.y2milestone("Source creating result: %1", @createResult)
    end while @createResult == :again
    AddOnProduct.last_ret = :next
    @ret = RunAutorunWizard()
  end

  Pkg.SourceSaveAll if @ret == :next

  # bugzilla #293428
  # Release all sources before adding a new one
  # because of CD/DVD + url cd://
  Pkg.SourceReleaseAll

  UI.CloseDialog
  @ret 

  # EOF
end