Class: Yast::VendorClient
- Inherits:
-
Client
- Object
- Client
- Yast::VendorClient
- Defined in:
- src/clients/vendor.rb
Instance Method Summary (collapse)
- - (Object) main
-
- (Object) run_inst(fpath, fname)
run .inst file return 0 on success.
-
- (Object) wrong_cd(reason, must_umount)
display message if the CD seems to be wrong.
Instance Method Details
- (Object) main
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 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 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
# File 'src/clients/vendor.rb', line 11 def main Yast.import "Pkg" Yast.import "UI" textdomain "add-on" Yast.import "Arch" Yast.import "Installation" Yast.import "Label" Yast.import "Popup" Yast.import "StorageDevices" Yast.import "Wizard" Yast.import "GetInstArgs" Yast.import "Mode" Yast.import "CommandLine" # Bugzilla #269911, CommanLine "support" # argmap is only a map, CommandLine uses string parameters if Builtins.size(GetInstArgs.argmap) == 0 && Ops.greater_than(Builtins.size(WFM.Args), 0) Mode.SetUI("commandline") Builtins.y2milestone("Mode CommandLine not supported, exiting...") # TRANSLATORS: error message - the module does not provide command line interface CommandLine.Print( _("There is no user interface available for this module.") ) return :auto end @language = UI.GetLanguage(true) @is_mounted = false #------------------------------------------------------------ @arg_n = Ops.subtract(Builtins.size(WFM.Args), 1) @default_device = "/dev/cdrom" @alternate_device = StorageDevices.FloppyDevice while Ops.greater_or_equal(@arg_n, 0) if Builtins.substring(Convert.to_string(WFM.Args(@arg_n)), 0, 1) == "/" @default_device = Convert.to_string(WFM.Args(@arg_n)) end @arg_n = Ops.subtract(@arg_n, 1) end @result = nil Wizard.CreateDialog Wizard.SetDesktopTitleAndIcon("vendor") Wizard.HideAbortButton # VENDOR: main screen heading @title = _("Vendor Driver CD") Wizard.SetContents(@title, Empty(), "", true, true) # free mount point SCR.Execute(path(".target.umount"), Installation.sourcedir) # try to mount device while SCR.Execute( path(".target.mount"), [@default_device, Installation.sourcedir] ) == false if @alternate_device != @default_device && SCR.Execute( path(".target.mount"), [@alternate_device, Installation.sourcedir] ) == true break end # VENDOR: cant mount /dev/cdrom popup if !Popup.ContinueCancel(_("Please insert the vendor CD-ROM")) UI.CloseDialog return :abort end end @is_mounted = true # CD is mounted. Check contents. @cdpath = Installation.sourcedir # get directory on update disk from installation (value from install.inf) # # if not set, determine directory from installed products # @update_dir = Convert.to_string( SCR.Read(path(".target.string"), ["/var/lib/YaST2/vendor_update", ""]) ) if @update_dir != "" @cdpath = Ops.add(@cdpath, @update_dir) else Pkg.TargetInit("/", false) @products = Pkg.ResolvableProperties("", :product, "") @products = [] if @products == nil @products = Builtins.filter(@products) do |p| Ops.get(p, "status") == :installed end @base = Builtins.filter(@products) do |p| Ops.get_string(p, "category", "") == "base" end @base = deep_copy(@products) if Builtins.size(@base) == 0 @product = Ops.get(@base, 0, {}) @version = Ops.get_string(@product, "version", "") @version = Ops.get(Builtins.splitstring(@version, "-"), 0, "") # split off release Builtins.y2milestone("Trying %1", @cdpath) @dirlist2 = Convert.to_list(SCR.Read(path(".target.dir"), @cdpath)) if Ops.less_or_equal(Builtins.size(@dirlist2), 0) || !Builtins.contains(@dirlist2, "linux") # VENDOR: vendor cd contains wrong data return wrong_cd( _("Could not find driver data on the CD-ROM.\nAborting now."), @is_mounted ) end @cdpath = Ops.add(@cdpath, "/linux") Builtins.y2milestone("Trying %1", @cdpath) @dirlist2 = Convert.to_list(SCR.Read(path(".target.dir"), @cdpath)) if Ops.less_or_equal(Builtins.size(@dirlist2), 0) || !(Builtins.contains(@dirlist2, "suse") || Builtins.contains(@dirlist2, "unitedlinux")) # VENDOR: vendor cd contains wrong data return wrong_cd( _("Could not find driver data on the CD-ROM.\nAborting now."), @is_mounted ) end @vendordir = "/suse/" if Ops.greater_than( SCR.Read(path(".target.size"), "/etc/UnitedLinux-release"), 0 ) @vendordir = "/UnitedLinux/" @version = "ul1" end @cdpath = Ops.add( Ops.add(Ops.add(Ops.add(@cdpath, @vendordir), Arch.architecture), "-"), @version ) end Builtins.y2milestone("Trying %1", @cdpath) @dirlist = Convert.convert( SCR.Read(path(".target.dir"), @cdpath), :from => "any", :to => "list <string>" ) if Ops.less_or_equal(Builtins.size(@dirlist), 0) # VENDOR: vendor cd doesn't contain data for current system and linux version return wrong_cd( _( "The CD-ROM data does not match the running Linux system.\nAborting now.\n" ), @is_mounted ) end Builtins.y2milestone("found %1", @dirlist) # filter files ending in .inst (allow .ins for dos :-}) @instlist = [] Builtins.foreach(@dirlist) do |fname| splitted = Builtins.splitstring(fname, ".") if Builtins.size(splitted) == 2 && Builtins.substring(Ops.get(splitted, 1, ""), 0, 3) == "ins" @instlist = Builtins.add(@instlist, Ops.get(splitted, 0, "")) end end Builtins.y2milestone("inst %1", @instlist) if Ops.less_or_equal(Builtins.size(@dirlist), 0) # VENDOR: vendor cd contains wrong data return wrong_cd( _("Could not find driver data on the CD-ROM.\nAborting now."), @is_mounted ) end @inst_count = 0 @short_lang = "" if Ops.greater_than(Builtins.size(@language), 2) @short_lang = Builtins.substring(@language, 0, 2) end # try to load .inst files, try with (xx_XX) ISO language first, # then with 2 char language code # show data from matching files Builtins.foreach(@instlist) do |fname| # try full ISO language code first description = Convert.to_string( SCR.Read( path(".target.string"), Ops.add( Ops.add( Ops.add(Ops.add(Ops.add(@cdpath, "/"), fname), "-"), @language ), ".desc" ) ) ) # try with 2 char language code if Ops.less_or_equal(Builtins.size(description), 0) description = Convert.to_string( SCR.Read( path(".target.string"), Ops.add( Ops.add( Ops.add(Ops.add(Ops.add(@cdpath, "/"), fname), "-"), @short_lang ), ".desc" ) ) ) end # try without language code if Ops.less_or_equal(Builtins.size(description), 0) description = Convert.to_string( SCR.Read( path(".target.string"), Ops.add(Ops.add(Ops.add(@cdpath, "/"), fname), ".desc") ) ) end # show contents if Ops.greater_than(Builtins.size(description), 0) if Popup.YesNo(description) # VENDOR: dialog heading Wizard.SetContents( @title, HVCenter(Label(_("Installing driver..."))), "", true, true ) inst_result = run_inst(@cdpath, Ops.add(fname, ".inst")) if inst_result == 0 @inst_count = Ops.add(@inst_count, 1) else # VENDOR: popup if installation of driver failed Popup.Message( _( "The installation failed.\nContact the address on the CD-ROM.\n" ) ) end Wizard.SetContents(@title, Empty(), "", true, true) end end end @result_message = "" if Ops.greater_than(@inst_count, 0) # VENDOR: message box with number of drivers installed @result_message = Builtins.sformat( _("Installed %1 drivers from CD"), @inst_count ) else # VENDOR: message box with error text @result_message = _( "No driver data found on the CD-ROM.\nAborting now." ) end Popup.Message(@result_message) # free mount point SCR.Execute(path(".target.umount"), Installation.sourcedir) UI.CloseDialog :ok # EOF end |
- (Object) run_inst(fpath, fname)
run <name>.inst file return 0 on success
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
# File 'src/clients/vendor.rb', line 323 def run_inst(fpath, fname) Builtins.y2milestone("run_inst %1/%2", fpath, fname) tmpdir = Convert.to_string(SCR.Read(path(".target.tmpdir"))) SCR.Execute( path(".target.bash"), Ops.add( Ops.add(Ops.add(Ops.add(Ops.add("/bin/cp ", fpath), "/"), fname), " "), tmpdir ) ) # force it to be readable and executable SCR.Execute( path(".target.bash"), Ops.add(Ops.add(Ops.add("/bin/chmod 774 ", tmpdir), "/"), fname) ) result = Convert.to_integer( SCR.Execute( path(".target.bash"), Ops.add( Ops.add( Ops.add( Ops.add(Ops.add(Ops.add("(cd ", tmpdir), "; ./"), fname), " " ), fpath ), ")" ) ) ) SCR.Execute(path(".target.remove"), Ops.add(Ops.add(tmpdir, "/"), fname)) result end |
- (Object) wrong_cd(reason, must_umount)
display message if the CD seems to be wrong
310 311 312 313 314 315 316 317 318 |
# File 'src/clients/vendor.rb', line 310 def wrong_cd(reason, must_umount) Popup.Message(reason) if must_umount # free mount point SCR.Execute(path(".target.umount"), Installation.sourcedir) end UI.CloseDialog :abort end |