Class: Yast::PackageInstallationClass
- Inherits:
-
Module
- Object
- Module
- Yast::PackageInstallationClass
- Defined in:
- ../../src/modules/PackageInstallation.rb
Instance Method Summary (collapse)
-
- (Object) Commit(config)
commitPackages marked for deletion or installation Return: [ int successful, list failed, list remaining, list srcremaining ].
-
- (Object) CommitPackages(media_number, packages_installed)
commitPackages marked for deletion or installation Return: [ int successful, list failed, list remaining, list srcremaining ].
- - (Object) DownloadInAdvance
-
- (Object) FakePackager(packages, inst_source, deleting)
Fake progress bars for Mode::test ().
- - (Object) main
- - (Object) SetDownloadInAdvance(enable)
-
- (Object) ShowFailedPackages(a, b)
Show a dialog with either the list of failed packages (string a) or the complete log (string b).
Instance Method Details
- (Object) Commit(config)
commitPackages marked for deletion or installation Return: [ int successful, list failed, list remaining, list srcremaining ]
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 |
# File '../../src/modules/PackageInstallation.rb', line 106 def Commit(config) config = deep_copy(config) if Mode.test FakePackager([], "suse", false) # not deleting packages return [] end # install packages from this media sources = Pkg.SourceGetCurrent(false) source_id = Ops.get(sources, 0, 0) PackageSlideShow.InitPkgData(false) # structure: [ ["source_name", id] ] src_list = Pkg.PkgMediaNames # get ID of the first repository first_source = Ops.get_integer(src_list, [0, 1], 1) Builtins.y2milestone("ID of the first repository: %1", first_source) if Ops.get_integer(config, "medium_nr", 0) == 0 PackageSlideShow.SetCurrentCdNo(first_source, 1) else PackageSlideShow.SetCurrentCdNo( first_source, Ops.get_integer(config, "medium_nr", 0) ) end PackageSlideShow.UpdateAllCdProgress(false) SlideShow.StartTimer start_time = Builtins.time commit_result = [] # returns [ int successful, list failed, list remaining, list srcremaining ] Builtins.y2milestone("Calling Pkg::Commit (%1)", config) commit_result = Pkg.Commit(config) SlideShow.StopTimer if commit_result == nil Builtins.y2error("Commit failed: %1", Pkg.LastError) return [] end installation_time = Ops.subtract(Builtins.time, start_time) Builtins.y2milestone( "Installation took %1 seconds, commit result: %2", installation_time, commit_result ) # see if installation of some packages failed errpacks = Ops.get_list(commit_result, 1, []) if Ops.greater_than(Builtins.size(errpacks), 0) full_log = Ops.get_string( PackagesUI.GetPackageSummary, "install_log", "" ) ShowFailedPackages(Builtins.mergestring(errpacks, "\n"), full_log) old_failed_packs = [] if Ops.greater_than( Convert.to_integer( SCR.Read(path(".target.size"), "/var/lib/YaST2/failed_packages") ), 0 ) old_failed_packs = Convert.convert( SCR.Read(path(".target.ycp"), "/var/lib/YaST2/failed_packages"), :from => "any", :to => "list <string>" ) end SCR.Write( path(".target.ycp"), "/var/lib/YaST2/failed_packages", Builtins.merge(old_failed_packs, errpacks) ) end if Mode.normal # collect and set installation summary data summary = PackageSlideShow.GetPackageSummary Ops.set(summary, "time_seconds", installation_time) Ops.set(summary, "success", Builtins.size(errpacks) == 0) Ops.set(summary, "remaining", Ops.get_list(commit_result, 2, [])) Ops.set(summary, "install_log", SlideShow.inst_log) if Ops.greater_than(Builtins.size(errpacks), 0) Ops.set(summary, "error", Pkg.LastError) Ops.set(summary, "failed", errpacks) end if commit_result == [-1] Ops.set(summary, "error", _("Installation aborted by user.")) Ops.set(summary, "success", false) end PackagesUI.SetPackageSummary(summary) end deep_copy(commit_result) end |
- (Object) CommitPackages(media_number, packages_installed)
commitPackages marked for deletion or installation Return: [ int successful, list failed, list remaining, list srcremaining ]
221 222 223 224 225 226 227 228 229 230 |
# File '../../src/modules/PackageInstallation.rb', line 221 def CommitPackages(media_number, packages_installed) # this is a backward compatible wrapper for Commit() Builtins.y2milestone( "CommitPackages (%1,%2): Pkg::TargetGetDU() %3", media_number, packages_installed, Pkg.TargetGetDU ) Commit({ "medium_nr" => media_number }) end |
- (Object) DownloadInAdvance
32 33 34 |
# File '../../src/modules/PackageInstallation.rb', line 32 def DownloadInAdvance @download_in_advance end |
- (Object) FakePackager(packages, inst_source, deleting)
Fake progress bars for Mode::test ()
NOTE: This is currently completely broken. – sh 2003-12-15
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 |
# File '../../src/modules/PackageInstallation.rb', line 240 def FakePackager(packages, inst_source, deleting) packages = deep_copy(packages) disk_usage = 20 disk_capacity = 10000 ret = nil number = 0 Builtins.y2debug( "FakePackager - handling %1 packages", Builtins.size(packages) ) Builtins.foreach(packages) do |pac| #y2debug( "Fake installing %1 from %2", select(pac,0), inst_source ); pkg_name = Ops.get_string(pac, 0, "") pkg_size = 42 * 1024 bytes_installed = 0 if Ops.less_than(pkg_size, 0) # pkginfo doesn't know anything about the kernel RPM, so its # size can't be obtained, e.g. pkg_size is -1. To make up for # this, let's assume a negative starting size to keep things # going for a while (this is test_mode only, anyway). bytes_installed = -857 * 1024 end while Ops.less_than(bytes_installed, pkg_size) && ret != :cancel && ret != :diskfull percent = Ops.divide(Ops.multiply(100, bytes_installed), pkg_size) # if ( deleting ) # { # // Handle deleting packages # } # else # { # // Handle installing packages # } Builtins.sleep(300) # millisec bytes_installed = Ops.add(bytes_installed, 300 * 1024) end disk_usage = Ops.add(disk_usage, 1) number = Ops.add(number, 1) end if ret == :cancel || ret == :abort ret = :cancel elsif ret == :diskfull ret = :diskfull else ret = :ok end Builtins.y2debug("FakePackager returning with %1", ret) deep_copy(ret) end |
- (Object) main
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File '../../src/modules/PackageInstallation.rb', line 13 def main Yast.import "Pkg" Yast.import "UI" textdomain "packager" Yast.import "Mode" Yast.import "Installation" Yast.import "Directory" Yast.import "Packages" Yast.import "SlideShow" Yast.import "PackageSlideShow" Yast.import "PackagesUI" Yast.import "Label" @download_in_advance = nil end |
- (Object) SetDownloadInAdvance(enable)
36 37 38 39 40 |
# File '../../src/modules/PackageInstallation.rb', line 36 def SetDownloadInAdvance(enable) @download_in_advance = enable nil end |
- (Object) ShowFailedPackages(a, b)
Show a dialog with either the list of failed packages (string a) or the complete log (string b).
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 |
# File '../../src/modules/PackageInstallation.rb', line 45 def ShowFailedPackages(a, b) = RadioButtonGroup( VBox( Left( RadioButton( Id(:a), Opt(:notify), # button label _("&Show Failed Packages List"), true ) ), Left( RadioButton( Id(:b), Opt(:notify), # button label _("&Show Full Log"), false ) ) ) ) UI.OpenDialog( Opt(:decorated), VBox( HSpacing(40), # dialog headline Left(Heading(_("Installation of some Packages Failed"))), , RichText(Id(:text), Opt(:plainText), a), PushButton(Id(:ok), Opt(:default, :key_F10), Label.OKButton) ) ) while true ret = Convert.to_symbol(UI.UserInput) if ret == :a || ret == :b UI.ChangeWidget( Id(:text), :Value, Convert.to_boolean(UI.QueryWidget(Id(:a), :Value)) ? a : b ) next end break if ret == :ok end UI.CloseDialog nil end |