Class: Yast::AutoinstFileClass
- Inherits:
-
Module
- Object
- Module
- Yast::AutoinstFileClass
- Defined in:
- ../../src/modules/AutoinstFile.rb
Instance Method Summary (collapse)
-
- (Object) Export
Export Settings.
-
- (Boolean) GetModified
Functions which returns if the settings were modified.
-
- (Object) Import(settings)
Import Settings.
- - (Object) main
-
- (Object) SetModified
Function sets internal variable, which indicates, that any settings were modified, to “true”.
-
- (Object) Summary
Settings Summary.
-
- (Object) Write
Write Settings.
Instance Method Details
- (Object) Export
Export Settings
71 72 73 |
# File '../../src/modules/AutoinstFile.rb', line 71 def Export deep_copy(@Files) end |
- (Boolean) GetModified
Functions which returns if the settings were modified
38 39 40 |
# File '../../src/modules/AutoinstFile.rb', line 38 def GetModified @modified end |
- (Object) Import(settings)
Import Settings
64 65 66 67 68 |
# File '../../src/modules/AutoinstFile.rb', line 64 def Import(settings) settings = deep_copy(settings) @Files = deep_copy(settings) true end |
- (Object) main
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File '../../src/modules/AutoinstFile.rb', line 13 def main textdomain "autoinst" Yast.import "AutoinstConfig" Yast.import "Summary" Yast.include self, "autoinstall/io.rb" # default value of settings modified @modified = false @Files = [] end |
- (Object) SetModified
Function sets internal variable, which indicates, that any settings were modified, to "true"
29 30 31 32 33 34 |
# File '../../src/modules/AutoinstFile.rb', line 29 def SetModified Builtins.y2milestone("SetModified") @modified = true nil end |
- (Object) Summary
Settings Summary
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File '../../src/modules/AutoinstFile.rb', line 44 def Summary summary = "" summary = Summary.AddHeader(summary, _("Configured Files:")) if Ops.greater_than(Builtins.size(@Files), 0) summary = Summary.OpenList(summary) Builtins.foreach(@Files) do |file| summary = Summary.AddListItem( summary, Ops.get_string(file, "file_path", "") ) end summary = Summary.CloseList(summary) else summary = Summary.AddLine(summary, Summary.NotConfigured) end summary end |
- (Object) Write
Write Settings
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 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File '../../src/modules/AutoinstFile.rb', line 76 def Write Yast.import "AutoInstall" Builtins.y2milestone("Writing Files to the system") return true if Builtins.size(@Files) == 0 counter = 0 success = false Builtins.foreach(@Files) do |file| alternate_location = Builtins.sformat( "%1/%2", AutoinstConfig.files_dir, counter ) alter_file = Builtins.sformat("file_%1", counter) if Ops.subtract( Builtins.size(Ops.get_string(file, "file_path", "dummy")), 1 ) == Builtins.findlastof(Ops.get_string(file, "file_path", ""), "/") # directory SCR.Execute( path(".target.mkdir"), Ops.get_string(file, "file_path", alternate_location) ) elsif Ops.get_string(file, "file_contents", "") != "" Builtins.y2milestone( "AutoInstall: Copying file %1", Ops.get_string(file, "file_path", alternate_location) ) t = Builtins.splitstring( Ops.get_string(file, "file_path", alternate_location), "/" ) pos = Ops.subtract(Builtins.size(t), 1) # SCR::Write (.target.string, AutoInstall::var_dir + "/files" + t[pos]:alter_file, file["file_contents"]:""); SCR.Write( path(".target.string"), Ops.get_string(file, "file_path", alternate_location), Ops.get_string(file, "file_contents", "") ) elsif Ops.get_string(file, "file_location", "") != "" if Builtins.issubstring( Ops.get_string(file, "file_location", ""), "relurl://" ) l = Ops.get_string(file, "file_location", "") l = Builtins.substring(l, 9) newloc = "" if AutoinstConfig.scheme == "relurl" Builtins.y2milestone("autoyast profile was relurl too") newloc = Convert.to_string( SCR.Read(path(".etc.install_inf.ayrelurl")) ) tok = URL.Parse(newloc) Builtins.y2milestone("tok = %1", tok) newloc = Ops.add( Ops.add( Ops.add( Ops.add( Ops.add(Ops.get_string(tok, "scheme", ""), "://"), Ops.get_string(tok, "host", "") ), "/" ), dirname(Ops.get_string(tok, "path", "")) ), l ) else newloc = Ops.add( Ops.add( Ops.add( Ops.add( Ops.add(AutoinstConfig.scheme, "://"), AutoinstConfig.host ), "/" ), AutoinstConfig.directory ), l ) end Ops.set(file, "file_location", newloc) Builtins.y2milestone("changed relurl to %1 for file", newloc) end Builtins.y2milestone( "trying to get file from %1 storing in %2", Ops.get_string(file, "file_location", ""), Ops.get_string(file, "file_path", alternate_location) ) if !GetURL( Ops.get_string(file, "file_location", ""), Ops.get_string(file, "file_path", alternate_location) ) Builtins.y2error("file could not be retrieved") else Builtins.y2milestone("file was retrieved") end end if Ops.get_string(file, "file_permissions", "") != "" SCR.Execute( path(".target.bash"), Builtins.sformat( "chmod %1 %2", Ops.get_string(file, "file_permissions", ""), Ops.get_string(file, "file_path", alternate_location) ) ) end if Ops.get_string(file, "file_owner", "") != "" SCR.Execute( path(".target.bash"), Builtins.sformat( "chown %1 %2", Ops.get_string(file, "file_owner", ""), Ops.get_string(file, "file_path", alternate_location) ) ) end script = Ops.get_map(file, "file_script", {}) if script != {} current_logdir = AutoinstConfig.logs_dir name_tok = Builtins.splitstring( Ops.get_string(file, "file_path", alternate_location), "/" ) scriptName = "" if Ops.greater_than(Builtins.size(name_tok), 0) name = Ops.get_string( name_tok, Ops.subtract(Builtins.size(name_tok), 1), "" ) scriptName = Ops.add("script_", name) end scriptPath = Builtins.sformat( "%1/%2", AutoinstConfig.scripts_dir, scriptName ) Builtins.y2milestone("Writing (file) script into %1", scriptPath) got_script = false if Ops.get_string(script, "location", "") != "" Builtins.y2milestone( "getting script: %1", Ops.get_string(script, "location", "") ) if !GetURL(Ops.get_string(script, "location", ""), scriptPath) Builtins.y2error( "script %1 could not be retrieved", Ops.get_string(script, "location", "") ) else got_script = true end end if !got_script SCR.Write( path(".target.string"), scriptPath, Ops.get_string(script, "source", "echo Empty script!") ) end scriptInterpreter = Ops.get_string(script, "interpreter", "shell") executionString = "" if scriptInterpreter == "shell" executionString = Builtins.sformat( "/bin/sh -x %1 2&> %2/%3.log", scriptPath, current_logdir, scriptName ) SCR.Execute(path(".target.bash"), executionString) elsif scriptInterpreter == "perl" executionString = Builtins.sformat( "/usr/bin/perl %1 2&> %2/%3.log", scriptPath, current_logdir, scriptName ) SCR.Execute(path(".target.bash"), executionString) elsif scriptInterpreter == "python" executionString = Builtins.sformat( "/usr/bin/python %1 2&> %2/%3.log", scriptPath, current_logdir, scriptName ) SCR.Execute(path(".target.bash"), executionString) else Builtins.y2error("Unknown interpreter: %1", scriptInterpreter) end Builtins.y2milestone("Script Execution command: %1", executionString) end success = SCR.Execute( path(".target.bash"), Builtins.sformat( "cp %1 %2", Ops.get_string(file, "file_path", alternate_location), AutoinstConfig.files_dir ) ) == 0 counter = Ops.add(counter, 1) end success end |