Module: Yast::UpdateRootpartInclude
- Defined in:
- ../../src/include/update/rootpart.rb
Instance Method Summary (collapse)
-
- (Object) CanBeLinuxRootFS(partition_fs)
Returns boolean whether partition can be a Linux 'root' file system.
-
- (Object) DoArchitecturesMatch(arch_1, arch_2)
Returns whether wanted and selected architectures match bnc #372309.
- - (Object) initialize_update_rootpart(include_target)
-
- (Object) make_partition_list(withall, flavor)
flavor is either
update or
boot. -
- (Symbol) RootPartitionDialog(flavor)
This dialog comes in several different flavors:
update_dialog - used to show partitions available for upgrade,
update_popup - obsolete, used to be used as a pop-up in proposal dialog (MakeProposal),update_dialog_proposal - obsolete, used to be used as a pop-up in proposal dialog (AskUser),
boot_popup - obsolete, used to be used as a dilaog offering to boot to a selected partition,. - - (Object) UmountMountedPartition
Instance Method Details
- (Object) CanBeLinuxRootFS(partition_fs)
Returns boolean whether partition can be a Linux 'root' file system
52 53 54 55 56 57 58 59 60 |
# File '../../src/include/update/rootpart.rb', line 52 def CanBeLinuxRootFS(partition_fs) if partition_fs == nil Builtins.y2error("partition_fs not defined!") return false end # possible_root_fs contains list of supported FSs Builtins.contains(FileSystems.possible_root_fs, partition_fs) end |
- (Object) DoArchitecturesMatch(arch_1, arch_2)
Returns whether wanted and selected architectures match bnc #372309
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File '../../src/include/update/rootpart.rb', line 136 def DoArchitecturesMatch(arch_1, arch_2) ppc_archs = ["ppc", "ppc64"] # exact match if arch_1 == arch_2 return true # ppc exception elsif Builtins.contains(ppc_archs, arch_1) && Builtins.contains(ppc_archs, arch_2) return true end # else false end |
- (Object) initialize_update_rootpart(include_target)
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File '../../src/include/update/rootpart.rb', line 33 def initialize_update_rootpart(include_target) Yast.import "UI" Yast.import "Pkg" textdomain "update" Yast.import "Wizard" Yast.import "Popup" Yast.import "Label" Yast.import "RootPart" Yast.import "GetInstArgs" Yast.import "Report" Yast.import "Update" Yast.import "Installation" Yast.import "FileSystems" Yast.import "Mode" end |
- (Object) make_partition_list(withall, flavor)
flavor is either update or
boot
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 |
# File '../../src/include/update/rootpart.rb', line 63 def make_partition_list(withall, flavor) part_list = [] Builtins.foreach(RootPart.rootPartitions) do |partition, i| # see https://bugzilla.novell.com/attachment.cgi?id=96783&action=view # see bugzilla #288201 # architecture needs to be valid when updating, not booting arch_is_valid = flavor == :boot ? true : Ops.get_boolean(i, :arch_valid, false) if withall || Ops.get_boolean(i, :valid, false) && arch_is_valid # `ext2, `jfs, ... part_fs = Ops.get_symbol(i, :fs) part_fs_name = Builtins.tostring(part_fs) if part_fs_name != nil && Builtins.regexpmatch(part_fs_name, "^`(.*)$") part_fs_name = Builtins.regexpsub(part_fs_name, "^`(.*)$", "\\1") end system = Ops.get_string(i, :name, "error") # unknown system if system == "unknown" if part_fs != nil if CanBeLinuxRootFS(part_fs) # Table item (unknown system) system = _("Unknown Linux") else # Table item (unknown system) system = _("Unknown or Non-Linux") end else # Table item (unknown system [neither openSUSE 11.1 nor SLES 14 nor ...]) system = _("Unknown") if system == "unknown" end end arch = Ops.get_string(i, :arch, "error") # Table item (unknown architecture) arch = _("Unknown") if arch == "unknown" # fist, use the name of file system (with short name for Linux) # then the file system short name # then "Unknown" fs = "" # is a linux fs, can be a root fs, has a fs name if part_fs != nil && Ops.get(i, :fstype) != nil && CanBeLinuxRootFS(part_fs) && part_fs_name != nil fs = Builtins.sformat( _("%1 (%2)"), Ops.get_string(i, :fstype, ""), part_fs_name ) else fs = Ops.get_string(i, :fstype, Ops.get_string(i, :fs, "")) end # Table item (unknown file system) fs = _("Unknown") if fs == "" label = Ops.get_string(i, :label, "") part_list = Builtins.add( part_list, Item(Id(partition), system, partition, arch, fs, label) ) end end deep_copy(part_list) end |
- (Symbol) RootPartitionDialog(flavor)
This dialog comes in several different flavors: <code>update_dialog - used to show partitions available for upgrade, </code>update_popup - obsolete, used to be used as a pop-up in proposal dialog (MakeProposal), <code>update_dialog_proposal - obsolete, used to be used as a pop-up in proposal dialog (AskUser), </code>boot_popup - obsolete, used to be used as a dilaog offering to boot to a selected partition,
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 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 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 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 |
# File '../../src/include/update/rootpart.rb', line 167 def RootPartitionDialog(flavor) # FIXME: Most of the code in this function is obsolete partition_list = make_partition_list( RootPart.showAllPartitions, flavor == :boot_popup ? :boot : :update ) title = "" label = "" help_text = "" if flavor == :boot_popup # label for selection of root partition (for boot) label = _("Partition or System to Boot:") # help text for root partition dialog (for boot) help_text = _( "<p>\n" + "Select the partition or system to boot.\n" + "</p>\n" ) else # label for selection of root partition (for update) label = _("Partition or System to Update:") # help text for root partition dialog (for update) help_text = _( "<p>\n" + "Select the partition or system to update.\n" + "</p>\n" ) if flavor == :update_dialog || flavor == :update_dialog_proposal # headline for dialog "Select for update" title = _("Select for Update") end end # help text for root partition dialog (general part) help_text = Ops.add( help_text, _( "<p>\n" + "<b>Show All Partitions</b> expands the list to a\n" + "general overview of your system's partitions.\n" + "</p>\n" ) ) contents = HBox( VBox( VSpacing(1), Left(Label(label)), MinSize( 70, 14, Table( Id(:partition), Opt(:hstretch), Header( # table header _("System"), # table header item _("Partition"), # table header item _("Architecture"), # table header item _("File System"), # table header item _("Label") ), partition_list ) ), Left( CheckBox( Id(:showall), Opt(:notify), # check box _("&Show All Partitions"), false ) ), VSpacing(1) ) ) # bnc #429080 # finishing the target before selecting a new system to load Pkg.TargetFinish if flavor == :update_dialog if flavor == :update_dialog Wizard.SetContents(title, contents, help_text, true, true) Wizard.EnableAbortButton if Mode.autoupgrade elsif flavor == :update_dialog_proposal Wizard.CreateDialog Wizard.SetContentsButtons( title, contents, help_text, Label.BackButton, Label.OKButton ) else = PushButton(Id(:next), Opt(:default), Label.OKButton) if flavor == :boot_popup = HBox( HStretch(), # pushbutton to (rightaway) boot the system selected above HWeight(1, PushButton(Id(:next), Opt(:default), _("&Boot"))), HSpacing(1), HWeight(1, PushButton(Id(:cancel), Label.CancelButton)), HStretch() ) end full = MinHeight( 16, HBox( HSquash(MinWidth(26, RichText(Opt(:vstretch), help_text))), HSpacing(2), VBox(MinHeight(15, contents), ), HSpacing(2) ) ) UI.OpenDialog(full) end if Ops.greater_than(Builtins.size(RootPart.selectedRootPartition), 0) UI.ChangeWidget( Id(:partition), :CurrentItem, RootPart.selectedRootPartition ) end UI.ChangeWidget(Id(:showall), :Value, RootPart.showAllPartitions) ret = nil while true if flavor == :update_dialog || flavor == :update_dialog_proposal ret = Wizard.UserInput else ret = UI.UserInput end ret = :abort if ret == :cancel break if ret == :abort && Popup.ConfirmAbort(:painless) if ret == :showall tmp = Convert.to_string(UI.QueryWidget(Id(:partition), :CurrentItem)) partition_list = make_partition_list( Convert.to_boolean(UI.QueryWidget(Id(:showall), :Value)), flavor == :boot_popup ? :boot : :update ) UI.ChangeWidget(Id(:partition), :Items, partition_list) UI.ChangeWidget(Id(:partition), :CurrentItem, tmp) if tmp != nil next end if (flavor == :update_dialog || flavor == :update_popup || flavor == :update_dialog_proposal) && ret == :next selected = Convert.to_string( UI.QueryWidget(Id(:partition), :CurrentItem) ) freshman = Ops.get(RootPart.rootPartitions, selected, {}) cont = true Builtins.y2milestone( "Selected root partition: %1 %2", selected, freshman ) if Ops.get_string(freshman, :name, "unknown") == "unknown" cont = Popup.ContinueCancel( # continue-cancel popup _( "No installed system that can be upgraded with this product was found\non the selected partition." ) ) elsif !DoArchitecturesMatch( Ops.get_string(freshman, :arch, ""), RootPart.GetDistroArch ) cont = Popup.ContinueCancel( # continue-cancel popup _( "The architecture of the system installed in the selected partition\nis different from the one of this product.\n" ) ) end ret = nil if !cont end if ret == :next RootPart.selectedRootPartition = Convert.to_string( UI.QueryWidget(Id(:partition), :CurrentItem) ) RootPart.showAllPartitions = Convert.to_boolean( UI.QueryWidget(Id(:showall), :Value) ) if flavor == :update_dialog RootPart.targetOk = RootPart.mount_target # Not mounted correctly if !RootPart.targetOk # error report Report.Error(_("Failed to mount target system")) UmountMountedPartition() next # Correctly mounted but incomplete installation found elsif RootPart.IncompleteInstallationDetected(Installation.destdir) if Popup.AnyQuestion( Label.WarningMsg, # pop-up question _( "A possibly incomplete installation has been detected on the selected partition.\nAre sure you want to use it anyway?" ), # button label _("&Yes, Use It"), Label.CancelButton, :focus_no ) Builtins.y2milestone( "User wants to update possibly incomplete system" ) else Builtins.y2milestone( "User decided not to update incomplete system" ) UmountMountedPartition() next end end end break end break if ret == :cancel || ret == :back || ret == :next end if flavor != :update_dialog UI.CloseDialog elsif Mode.autoupgrade Wizard.DisableAbortButton end # New partition has been mounted if flavor == :update_dialog && ret == :next # Target load failed, #466803 if Pkg.TargetInitialize(Installation.destdir) != true Builtins.y2error("Pkg::TargetInitialize failed") if Popup.AnyQuestion( Label.ErrorMsg, _( "Initializing the system for upgrade has failed for unknown reason.\n" + "It is highly recommended not to continue the upgrade process.\n" + "\n" + "Are you sure you want to continue?" ), _("&Yes, Continue"), Label.CancelButton, :focus_no ) ret = :back else Builtins.y2warning( "User decided to continue despite the error above (Pkg::TargetInit() failed)" ) end end # not aborted if ret != :back # Target load failed, #466803 if Pkg.TargetLoad != true Builtins.y2error("Pkg::TargetLoad failed") if Popup.AnyQuestion( Label.ErrorMsg, _( "Initializing the system for upgrade has failed for unknown reason.\n" + "It is highly recommended not to continue the upgrade process.\n" + "\n" + "Are you sure you want to continue?" ), _("&Yes, Continue"), Label.CancelButton, :focus_no ) ret = :back else Builtins.y2warning( "User decided to continue despite the error above (Pkg::TargetLoad() failed)" ) end end end end Convert.to_symbol(ret) end |
- (Object) UmountMountedPartition
152 153 154 155 156 157 |
# File '../../src/include/update/rootpart.rb', line 152 def UmountMountedPartition Update.Detach RootPart.UnmountPartitions(false) nil end |