Module: Yast::SupportComplexInclude

Defined in:
../../src/include/support/complex.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) initialize_support_complex(include_target)



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File '../../src/include/support/complex.rb', line 30

def initialize_support_complex(include_target)
  Yast.import "UI"

  textdomain "support"

  Yast.import "Label"
  Yast.import "Popup"
  Yast.import "Wizard"
  Yast.import "Confirm"
  Yast.import "Support"


  Yast.include include_target, "support/helps.rb"
end

- (Object) Modified

Return a modification status

Returns:

  • true if data was modified



47
48
49
# File '../../src/include/support/complex.rb', line 47

def Modified
  Support.Modified
end

- (Object) PollAbort



55
56
57
# File '../../src/include/support/complex.rb', line 55

def PollAbort
  UI.PollInput == :abort
end

- (Object) ReadDialog

Read settings dialog

Returns:

  • abort if aborted andnext otherwise



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/include/support/complex.rb', line 61

def ReadDialog
  Wizard.RestoreHelp(Ops.get_string(@HELPS, "read", ""))
  # Support::SetAbortFunction(PollAbort);
  #    if (!Confirm::MustBeRoot()) return `abort;
  if Support.WhoAmI != 0
    # use configuration file in home directory
    cmd = Builtins.sformat("ls %1", "~/.supportconfig")
    out = Convert.to_map(SCR.Execute(path(".target.bash_output"), cmd))
    file = Ops.get_string(out, "stdout", "")
    file = Ops.get(Builtins.splitstring(file, "\n"), 0, "")
    return :abort if !Confirm.MustBeRoot if file == "" || file == nil
    Builtins.y2milestone("Using configuration file %1", file)
    Builtins.setenv("SC_CONF", file)
    # ensure ~/.supportconfig does exist
    if Ops.less_than(SCR.Read(path(".target.size"), file), 0)
      cmd2 = Builtins.sformat(
        "/bin/cp %1 %2",
        "/etc/supportconfig.conf",
        file
      )
      SCR.Execute(path(".target.bash"), cmd2)
    end
    SCR.UnregisterAgent(path(".etc.supportconfig"))
    SCR.RegisterAgent(
      path(".etc.supportconfig"),
      term(
        :ag_ini,
        term(
          :IniAgent,
          file,
          {
            "options"  => [
              "global_values",
              "comments_last",
              "line_can_continue",
              "join_multiline"
            ],
            "comments" =>
              # like above, but followed by non a-z nor blank nor '=' chars
              [
                "^[ \t]*$",
                # empty line
                "^[ \t]+[;#].*$",
                # comment char is not first char
                "^[#][ \t]*$",
                # only comment chars
                "^[#][ \t]*\\[[^]]*$",
                # comment chars followed by '[' without matching ']'
                "^[#][^ \t[]",
                # comment char followed by non-blank nor '['
                "^[#][ \t]+[^[a-z \t].*$",
                # comment chars followed by non a-z char nor '[' nor blank
                "^[#][ \t]+[a-z ]*[a-z][ \t]*$",
                # comment chars followed by a-z or blank chars
                "^[#][ \t]+[a-z ]*[a-z][ \t]*[^a-z \t=].*$"
              ],
            #         "sections" : [
            #             $[
            #                 "begin" : [ "^[ \t]*\\[[ \t]*(.*[^ \t])[ \t]*\\][ \t]*", "[%s]" ],
            #             ], $[
            #                 // this is a special type for commenting out the values
            #                 "begin" : [ "^[#;][ \t]*\\[[ \t]*(.*[^ \t])[ \t]*\\][ \t]*", "# [%s]" ],
            #             ]
            #         ],
            # we need to exclude ; because of the second matching rule
            "params"   => [
              # Options with one value ('yes' / 'no')
              #                $[ "match" : [ "^[#;][ \t]*([^ \t]+)[ \t]+([^ \t]+)[ \t]+$", "%s %s" ]],
              #                $[ "match" : [ "^[#;][ \t]*([^ \t\=]+)[ \t\=]?(.+)[ \t]*$", "; %s %s" ]],
              # Options with more possible values
              #                  $[ "match" :   [ "^[ \t]*([^ \t\=]+)[ \t\=]+[ ]*\"(.*)\"[ \t]*$", "%s=\"%s\"" ]],
              # string
              {
                "match" => [
                  "^[ \t]*([^ \t=]+)[ \t=]+[ ]*\"(.*)\"[[:space:]]*#[-[:space:][:alnum:]]*$",
                  "%s=\"%s\""
                ]
              },
              {
                "match" => [
                  "^[ \t]*([^ \t=]+)[ \t=]+[ ]*\"(.*)\"[[:space:]]*$",
                  "%s=\"%s\""
                ]
              },
              # number
              {
                "match" => [
                  "^[ \t]*([^ \t=]+)[ \t=]+[ ]*([[:digit:]]+)[[:space:]]*#[-[:alnum:][:space:]]*$",
                  "%s=%s"
                ]
              },
              {
                "match" => [
                  "^[ \t]*([^ \t=]+)[ \t=]+[ ]*(.+)[[:space:]]*$",
                  "%s=%s"
                ]
              }
            ]
          }
        )
      )
    )
  end
  Builtins.y2milestone(
    "Read 2: %1",
    SCR.Read(path(".etc.supportconfig.all"))
  )

  ret = Support.Read
  ret ? :next : :abort
end

- (Object) ReallyAbort



51
52
53
# File '../../src/include/support/complex.rb', line 51

def ReallyAbort
  !Support.Modified || Popup.ReallyAbort(true)
end

- (Object) WriteDialog

Write settings dialog

Returns:

  • abort if aborted andnext otherwise



175
176
177
178
179
# File '../../src/include/support/complex.rb', line 175

def WriteDialog
  Wizard.RestoreHelp(Ops.get_string(@HELPS, "write", ""))
  ret = Support.Write
  ret ? :next : :abort
end