Module: Yast::RestoreUiInclude
- Defined in:
- ../../src/include/restore/ui.rb
Instance Method Summary (collapse)
-
- (Symbol) ArchiveContentsDialog
Display content of backup archive in the table.
-
- (Symbol) ArchivePropertyDialog
Display archive property - date of backup, user comment…
-
- (Symbol) ArchiveSelectionDialog(multivolume, askformore, input)
Backup archive is selected in this dialog.
-
- (Symbol) AtExit
This function should be called only once before end of client.
-
- (String) ComboToDevice(selected, dev)
Convert selected device name in combobox to URL-like equivalent.
-
- (Array) CreateArchiveContentTable(packagesinfo)
Return content for table widget - list of backup files.
-
- (Array) CreateArchiveContentTree(packagesinfo)
Return content for table widget - list of backup files.
-
- (Array) CreateDeviceList(dev, sel)
Create list of removable devices for combo box widget.
-
- (Array) CreateTableContents(contents, selected, defaultval)
Create content for table widget - columns: selection mark, package name, version, description.
-
- (Array) CreateTableContentsRestoreSelection(restoreselection)
Return table widget contens - files and packages selected for restoration.
-
- (Array) CreateTableContentsWithMismatched(contents, selected, defaultval)
Create content for table widget - columns: selection mark, package name, backup version, installed version, description.
-
- (Hash) DetectRemovable
Try to detect all removable devices present in the system.
-
- (Symbol) FileSelectionDialog(packagename)
Display all files in backup archive which belong to package.
- - (Object) initialize_restore_ui(include_target)
-
- (Boolean) InstallQuestion(package, version)
Ask wheter missing package should be installed and restored.
-
- (Symbol) PackageSelectionRestoreDialog
Packages (and files) for restoration can be selected in this archive.
-
- (String) ProposeNextVolume(volume)
Propose next file name of volume from file name.
-
- (Object) RestoreAutoSequence
Restoration without reading and writing.
-
- (Object) RestoreOptionsDialog
Dialog with options.
-
- (Symbol) RestoreProgressDialog
Restore packages from backup archive - display progress of restoring process.
-
- (Object) RestoreSequence
Whole restoration.
-
- (String) SelectFromList(label, inputlist, selected)
Select item from list.
-
- (Symbol) SelectionInstallDialog
Dialog for package selection - packages to install.
-
- (Symbol) SelectionUninstallDialog
Dialog for package selection - packages to uninstall.
-
- (Object) ShadowButtons(type)
Enable/disable widget in file selction dialog according to selected input type.
-
- (String) StatusToString(status)
Convert programm status to string.
-
- (Symbol) SummaryDialog
Display summary of restoration.
-
- (Symbol) SWsingleDialog
Start Yast2 package manager.
Instance Method Details
- (Symbol) ArchiveContentsDialog
Display content of backup archive in the table.
890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 |
# File '../../src/include/restore/ui.rb', line 890 def ArchiveContentsDialog Wizard.ClearContents if @archivecontentscache == nil @archivecontentscache = CreateArchiveContentTree(Restore.GetArchiveInfo) end contents = HBox( HSpacing(2), VBox( VSpacing(1), # tree label Tree( Id(:tree), _("Archive &Contents"), CreateArchiveContentTree(Restore.GetArchiveInfo) ), VSpacing(1.5) ), HSpacing(2) ) Wizard.SetNextButton(:next, Label.OKButton) # dialog header Wizard.SetContents( _("Archive Contents"), contents, ArchiveContentHelp(), true, true ) ret = nil begin ret = UI.UserInput ret = :abort if ret == :cancel end while ret != :next && ret != :abort && ret != :back Wizard.RestoreNextButton Convert.to_symbol(ret) end |
- (Symbol) ArchivePropertyDialog
Display archive property - date of backup, user comment…
760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 |
# File '../../src/include/restore/ui.rb', line 760 def ArchivePropertyDialog if Mode.config == false Builtins.y2milestone( "missing packages %1: ", Restore.GetMissingPackages ) Builtins.y2milestone("extra packages %1: ", Restore.GetExtraPackages) Builtins.y2milestone( "mismatched packages %1: ", Restore.GetMismatchedPackages ) end date = Restore.GetArchiveDate hostname = Restore.GetArchiveHostname comment = Restore.GetArchiveComment archname = Restore.GetInputName multivolume = Restore.IsMultiVolume == true ? _("Yes") : _("No") contents = HBox( HSpacing(2), VBox( VSpacing(1), # label text Left( HBox( Label(Id(:flabel), _("Archive Filename:")), HSpacing(2), Label(Id(:flabel2), archname) ) ), VSpacing(0.5), # label text Left( HBox( Label(Id(:dlabel), _("Date of Backup:")), HSpacing(2), Label(Id(:dlabel2), date) ) ), VSpacing(0.5), # label text Left( HBox( Label(Id(:hlabel), _("Backup Hostname:")), HSpacing(2), Label(Id(:hlabel2), hostname) ) ), VSpacing(0.5), # label text Left( HBox( Label(Id(:mlabel), _("Multivolume Archive:")), HSpacing(2), Label(Id(:mlabel2), multivolume) ) ), VSpacing(1.0), # multi line widget label Left(Label(_("Archive &Description:"))), RichText(Id(:description), Opt(:plainMode), comment), VSpacing(1.0), # push button label PushButton(Id(:details), Opt(:key_F2), _("&Archive Content...")), VSpacing(1), # push button label PushButton(Id(:options), Opt(:key_F7), _("E&xpert Options...")), VSpacing(1.5) ), HSpacing(2) ) # dialog header Wizard.SetContents( _("Archive Properties"), contents, ArchivePropertyHelp(), true, true ) ret = nil begin ret = UI.UserInput ret = :abort if ret == :cancel end while ret != :next && ret != :abort && ret != :back && ret != :details && ret != :options if Restore.IsMultiVolume == true && Restore.TestAllVolumes == false && ret == :next # ask for next volumes ret = :multi end @lastret = Convert.to_symbol(ret) Convert.to_symbol(ret) end |
- (Symbol) ArchiveSelectionDialog(multivolume, askformore, input)
Backup archive is selected in this dialog.
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 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 |
# File '../../src/include/restore/ui.rb', line 303 def ArchiveSelectionDialog(multivolume, askformore, input) Builtins.y2debug("input: %1", input) # cache removable devices if @removabledevices == nil @removabledevices = DetectRemovable() Builtins.y2milestone( "Detected removable devices: %1", @removabledevices ) end if multivolume == false && Mode.config == false # clear previous selection Restore.ResetArchiveSelection end file_name = "" nfs_server = "" nfs_file = "" cd_file = "" type = :file dev = "" urlinput = input != nil && input != "" ? input : Restore.inputname proposal = "" if urlinput != nil Builtins.y2debug("urlinput: %1", urlinput) parsed_url = URL.Parse(urlinput) scheme = Ops.get_string(parsed_url, "scheme", "file") if scheme == "nfs" type = :nfs nfs_server = Ops.get_string(parsed_url, "host", "") nfs_file = Ops.get_string(parsed_url, "path", "") proposal = nfs_file elsif Builtins.regexpmatch(scheme, "^cd[0-9]*") || Builtins.regexpmatch(scheme, "^fd[0-9]*") type = :removable devindex = Builtins.regexpsub(scheme, "[cf]d0*([0-9]*)", "\\1") devindex = "0" if devindex == nil || devindex == "" if Mode.test == false devpath = Builtins.regexpmatch(scheme, "^cd[0-9]*") ? path(".probe.cdrom") : path(".probe.floppy") devicemaps = Convert.convert( SCR.Read(devpath), :from => "any", :to => "list <map>" ) devicemap = Ops.get(devicemaps, Builtins.tointeger(devindex), {}) dev = Ops.get_string(devicemap, "dev_name", "") # dev = lookup(select((list<map>) SCR::Read(devpath), tointeger(devindex), $[]), "dev_name", ""); end cd_file = Ops.get_string(parsed_url, "path", "") proposal = cd_file elsif scheme == "dev" type = :removable dev = Ops.add("/dev/", Ops.get_string(parsed_url, "host", "")) file_name = Ops.get_string(parsed_url, "path", "") proposal = file_name else type = :file file_name = Ops.get_string(parsed_url, "path", "") proposal = file_name end if urlinput == input && multivolume == true proposal = ProposeNextVolume(proposal) if proposal != "" if type == :removable cd_file = proposal elsif type == :nfs nfs_file = proposal else file_name = proposal end end end end # unmount previous file system Restore.Umount contents = VBox( # frame label Frame( multivolume == false ? _("Backup Archive") : _("Multivolume Archive"), HBox( RadioButtonGroup( Id(:source), Opt(:notify), VBox( VSpacing(0.5), # radio button label Left( RadioButton( Id(:file), Opt(:notify), _("&Local File"), type == :file ) ), VSquash( HBox( HSpacing(2), # text entry label Bottom( TextEntry( Id(:filename), _("Archive Filena&me"), file_name ) ), HSpacing(1), # push button label Bottom(PushButton(Id(:selectfile), _("&Select..."))) ) ), VSpacing(1), # radio button label Left( RadioButton( Id(:nfs), Opt(:notify), _("Network (N&FS)"), type == :nfs ) ), VSquash( HBox( HSpacing(2), # text entry label Bottom( TextEntry( Id(:nfsserver), _("I&P Address or Name of NFS Server"), nfs_server ) ), HSpacing(1), # push button label Bottom(PushButton(Id(:selecthost), _("Select &Host..."))) ) ), HBox( HSpacing(2), # text entry label TextEntry(Id(:nfsfilename), _("&Archive Filename"), nfs_file) ), VSpacing(1), # radio button label Left( RadioButton( Id(:removable), Opt(:notify), _("Rem&ovable Device"), type == :removable ) ), HBox( HSpacing(2), # combo box label Left( ComboBox( Id(:device), Opt(:editable), _("&Device"), CreateDeviceList(@removabledevices, dev) ) ) ), VSquash( HBox( HSpacing(2), # text entry label Bottom( TextEntry( Id(:remfilename), _("Archi&ve Filename"), cd_file ) ), HSpacing(1), # push button label Bottom(PushButton(Id(:remfile), _("S&elect..."))) ) ), VSpacing(1) ) ), HSpacing(1) ) ), VSpacing(1) ) # dialog header title = multivolume == false ? _("Archive Selection") : _("Multivolume Archive Selection") Wizard.SetContents( title, contents, multivolume == true ? ArchiveMultiSelectionHelp() : ArchiveSelectionHelp(), true, true ) ShadowButtons(type) ret = nil begin ret = UI.UserInput if ret == :selectfile file = UI.AskForExistingFile("/", "*.tar", _("Select Archive File")) if file != nil && file != "" UI.ChangeWidget(Id(:filename), :Value, file) end end if ret == :selecthost selectedhost = NetworkPopup.NFSServer( Convert.to_string(UI.QueryWidget(Id(:nfsserver), :Value)) ) if selectedhost != "" && selectedhost != nil UI.ChangeWidget(Id(:nfsserver), :Value, selectedhost) end elsif ret == :nfs || ret == :removable || ret == :file ShadowButtons( Convert.to_symbol(UI.QueryWidget(Id(:source), :CurrentButton)) ) elsif ret == :remfile selected = Convert.to_string(UI.QueryWidget(Id(:device), :Value)) device = ComboToDevice(selected, @removabledevices) fname = Convert.to_string(UI.QueryWidget(Id(:remfilename), :Value)) # file selection from removable device - mount device mount = Restore.MountInput(Ops.add(device, fname)) if Ops.get_boolean(mount, "success", false) == true mountpnt = Ops.get_string(mount, "mpoint", "/") file = UI.AskForExistingFile( Ops.add(mountpnt, "/"), "*.tar", _("Select Archive File") ) if file != nil && file != "" # check if file is under mountpoint directory if Builtins.substring(file, 0, Builtins.size(mountpnt)) != mountpnt # error message - selected file is out of mounted file system Popup.Error( _("The selected file is not on the mounted device.") ) else # set file name UI.ChangeWidget( Id(:remfilename), :Value, Builtins.substring(file, Builtins.size(mountpnt)) ) end end # umount file system SCR.Execute(path(".target.umount"), mountpnt) else # error message Popup.Error(_("Cannot mount file system.")) end elsif ret == :next type2 = Convert.to_symbol(UI.QueryWidget(Id(:source), :CurrentButton)) if Mode.test == true input = "file:///tmp/archive.tar" elsif type2 == :file fname = Convert.to_string(UI.QueryWidget(Id(:filename), :Value)) if fname == "" # error message - file name is missing Popup.Error(_("Enter a valid filename.")) input = "" else input = Ops.add("file://", fname) end elsif type2 == :nfs server = Convert.to_string(UI.QueryWidget(Id(:nfsserver), :Value)) file = Convert.to_string(UI.QueryWidget(Id(:nfsfilename), :Value)) if server == "" || file == "" # error message - file or server name is missing Popup.Error(_("Enter a valid server and filename.")) input = "" else input = Ops.add(Ops.add(Ops.add("nfs://", server), ":"), file) end elsif type2 == :removable selected = Convert.to_string(UI.QueryWidget(Id(:device), :Value)) device = ComboToDevice(selected, @removabledevices) fname = Convert.to_string(UI.QueryWidget(Id(:remfilename), :Value)) Builtins.y2milestone("Selected removable device: %1", device) if device == "" || fname == "" # error message - file or device name is missing Popup.Error(_("Enter a valid device and filename.")) input = "" else input = Ops.add(device, fname) end else Builtins.y2error("Unknown source type %1", type2) end if input != "" configure = true if Mode.config # popup question answer = Popup.YesNo( _( "Detailed configuration requires reading the archive.\n" + "If an archive is not read, full restoration will be configured.\n" + "\n" + "Read the selected archive?\n" ) ) configure = answer Restore.completerestoration = !answer Builtins.y2debug( "completerestoration: %1", Restore.completerestoration ) if !configure Restore.runbootloader = true Restore.restoreRPMdb = true Restore.inputname = input end end if configure readresult = false lastvolume = false # progress message UI.OpenDialog(Label(_("Reading archive contents..."))) Builtins.y2debug( "Restore::IsMultiVolume(): %1", Restore.IsMultiVolume ) if Restore.IsMultiVolume == false readresult = Restore.Read(input) else # read next volume nextresult = Restore.ReadNextVolume(input) readresult = Ops.get_boolean(nextresult, "success", false) lastvolume = Ops.get_boolean(nextresult, "lastvolume", false) end UI.CloseDialog if readresult == false # error message - %1 is archive file name Popup.Error( Builtins.sformat( _("Cannot read backup archive file %1."), input ) ) Restore.Umount ret = :dummy else @restoredfiles = [] @failedfiles = [] if Restore.IsMultiVolume == true && askformore == true # umount source and ask for next volume Restore.Umount if lastvolume == false if multivolume == true = nil if type2 == :file = :filename elsif type2 == :removable = :remfilename elsif type2 == :nfs = :nfsfilename else Builtins.y2warning("Unknown source type: %1", type2) end fn = Convert.to_string(UI.QueryWidget(Id(), :Value)) prop = ProposeNextVolume(fn) UI.ChangeWidget(Id(), :Value, prop) if prop != "" ret = :dummy end else # last volume - test all volumes together testall = Restore.TestAllVolumes Builtins.y2debug("TestAllVolumes(): %1", testall) if testall == false Builtins.y2error("Test Restore::TestAllVolumes() failed") # error message - multi volume archive consistency check failed Popup.Error( _( "Test of all volumes failed.\n" + "\tAn archive file is probably corrupted.\n" + "\t" ) ) ret = :back end end end end else ret = :noconfig end else ret = :dummy end elsif ret == :cancel ret = :abort end end while ret != :next && ret != :abort && ret != :back && ret != :multi && ret != :noconfig Convert.to_symbol(ret) end |
- (Symbol) AtExit
This function should be called only once before end of client. This function cleans up the system - unmounts mounted files systems.
2010 2011 2012 2013 2014 2015 |
# File '../../src/include/restore/ui.rb', line 2010 def AtExit # unmount file system Restore.Umount :next end |
- (String) ComboToDevice(selected, dev)
Convert selected device name in combobox to URL-like equivalent
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
# File '../../src/include/restore/ui.rb', line 279 def ComboToDevice(selected, dev) dev = deep_copy(dev) ret = "" Builtins.foreach(dev) do |d, info| if selected == Ops.add( Ops.add(Ops.add(Ops.get_string(info, "device", ""), " ("), d), ")" ) ret = Ops.get_string(info, "type", "cd://") end end ret = Ops.add(Ops.add("dev://", selected), ":") if ret == "" ret end |
- (Array) CreateArchiveContentTable(packagesinfo)
Return content for table widget - list of backup files
2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 |
# File '../../src/include/restore/ui.rb', line 2258 def CreateArchiveContentTable(packagesinfo) packagesinfo = deep_copy(packagesinfo) ret = [] num = 0 Builtins.foreach(packagesinfo) do |p, info| files = Ops.get_list(info, "files", []) version = Ops.get_string(info, "vers", "") Builtins.foreach(files) do |file| ret = Builtins.add(ret, Item(Id(num), p, version, file)) num = Ops.add(num, 1) end end if packagesinfo != nil deep_copy(ret) end |
- (Array) CreateArchiveContentTree(packagesinfo)
Return content for table widget - list of backup files
864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 |
# File '../../src/include/restore/ui.rb', line 864 def CreateArchiveContentTree(packagesinfo) packagesinfo = deep_copy(packagesinfo) ret = [] num = 0 Builtins.foreach(packagesinfo) do |p, info| files = Ops.get_list(info, "files", []) itemfiles = [] version = Ops.get_string(info, "vers", "") itemfiles = Builtins.maplist(files) { |s| Item(s) } if p == "" # package name for files not owned by any package p = _("--No package--") end ret = Builtins.add( ret, Item(Id(num), Ops.add(Ops.add(p, "-"), version), itemfiles) ) num = Ops.add(num, 1) end if packagesinfo != nil deep_copy(ret) end |
- (Array) CreateDeviceList(dev, sel)
Create list of removable devices for combo box widget.
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 |
# File '../../src/include/restore/ui.rb', line 222 def CreateDeviceList(dev, sel) dev = deep_copy(dev) ret = [] # add selected device list if it's missing in map if sel != nil && sel != "" && !Builtins.haskey(dev, sel) ret = [Item(Id(sel), sel)] end Builtins.foreach(dev) do |d, info| ret = Builtins.add( ret, Item( Id( Ops.add( Ops.add(Ops.add(Ops.get_string(info, "device", ""), " ("), d), ")" ) ), Ops.add( Ops.add(Ops.add(Ops.get_string(info, "device", ""), " ("), d), ")" ), sel == d ) ) end deep_copy(ret) end |
- (Array) CreateTableContents(contents, selected, defaultval)
Create content for table widget - columns: selection mark, package name, version, description
1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 |
# File '../../src/include/restore/ui.rb', line 1186 def CreateTableContents(contents, selected, defaultval) contents = deep_copy(contents) selected = deep_copy(selected) ret = [] num = 0 defval = defaultval == true ? "X" : " " Builtins.foreach(contents) do |p, m| ver = Ops.get(m, "ver", "") descr = Ops.get(m, "descr", "") defval = Builtins.haskey(selected, p) ? "X" : " " if selected != nil ret = Builtins.add(ret, Item(Id(num), defval, p, ver, descr)) num = Ops.add(num, 1) end if contents != nil deep_copy(ret) end |
- (Array) CreateTableContentsRestoreSelection(restoreselection)
Return table widget contens - files and packages selected for restoration
1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 |
# File '../../src/include/restore/ui.rb', line 1412 def CreateTableContentsRestoreSelection(restoreselection) restoreselection = deep_copy(restoreselection) ret = [] # id of item in the table num = 0 Builtins.foreach(restoreselection) do |p, m| ver = Ops.get_string(m, "vers", "") descr = Ops.get_string(m, "descr", "") seltype = Ops.get_string(m, "sel_type", " ") numfiles = "" if seltype == "X" # all files selected for restoration numfiles = _("All") elsif seltype == " " numfiles = "" elsif seltype == "P" total = Builtins.size(Ops.get_list(m, "files", [])) sel = Builtins.size(Ops.get_list(m, "sel_file", [])) # selected %1 (number of files) of %2 (number of files) numfiles = Builtins.sformat(_("%1 of %2"), sel, total) else Builtins.y2error("Unknown selection type: %1", seltype) end if p == "" # name for "no package" - files not owned by any package p = _("--No package--") end ret = Builtins.add(ret, Item(Id(num), seltype, numfiles, p, ver, descr)) num = Ops.add(num, 1) end if restoreselection != nil deep_copy(ret) end |
- (Array) CreateTableContentsWithMismatched(contents, selected, defaultval)
Create content for table widget - columns: selection mark, package name, backup version, installed version, description
1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 |
# File '../../src/include/restore/ui.rb', line 1014 def CreateTableContentsWithMismatched(contents, selected, defaultval) contents = deep_copy(contents) selected = deep_copy(selected) ret = [] num = 0 defval = defaultval == true ? "X" : " " Builtins.foreach(contents) do |p, m| ver = Ops.get(m, "ver", "") descr = Ops.get(m, "descr", "") installed = Ops.get(m, "inst", "") defval = Builtins.haskey(selected, p) ? "X" : " " if selected != nil ret = Builtins.add(ret, Item(Id(num), defval, p, ver, installed, descr)) num = Ops.add(num, 1) end if contents != nil deep_copy(ret) end |
- (Hash) DetectRemovable
Try to detect all removable devices present in the system
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 |
# File '../../src/include/restore/ui.rb', line 90 def DetectRemovable ret = {} # detect floppy devices devices = Mode.test == false ? Convert.convert( SCR.Read(path(".probe.floppy")), :from => "any", :to => "list <map>" ) : [ { "bus" => "Floppy", "class_id" => 262, "dev_name" => "/dev/fd0", "notready" => true, "old_unique_key" => "xjDN.oZ89vuho4Y3", "resource" => { "size" => [ { "unit" => "cinch", "x" => 350, "y" => 0 }, { "unit" => "sectors", "x" => 2880, "y" => 512 } ] }, "sub_class_id" => 3, "unique_key" => "sPPV.oZ89vuho4Y3" } ] num = 0 Builtins.foreach(devices) do |dev| dev_name = Ops.get_string(dev, "dev_name", "") device = Ops.get_string(dev, "device", "") if device == "" if Ops.get_string(dev, "bus", "") == "Floppy" # floppy disk drive - combo box item device = _("Floppy") end end if dev_name != "" ret = Builtins.add( ret, dev_name, { "device" => device, "type" => Ops.add(Ops.add("fd", num), "://") } ) end num = Ops.add(num, 1) end # detect cdrom devices devices = Mode.test == false ? Convert.convert( SCR.Read(path(".probe.cdrom")), :from => "any", :to => "list <map>" ) : [ { "bus" => "IDE", "cdtype" => "cdrom", "class_id" => 262, "dev_name" => "/dev/hdc", "device" => "CD-540E", "driver" => "ide-cdrom", "notready" => true, "old_unique_key" => "3JYE.3LYJ0fijWD1", "resource" => { "size" => [{ "unit" => "sectors", "x" => 0, "y" => 512 }] }, "rev" => "1.0A", "sub_class_id" => 2, "unique_key" => "hY5p.ZxKxy3YdB66" } ] num = 0 Builtins.foreach(devices) do |dev| dev_name = Ops.get_string(dev, "dev_name", "") device = Ops.get_string(dev, "device", "") if dev_name != "" ret = Builtins.add( ret, dev_name, { "device" => device, "type" => Ops.add(Ops.add("cd", num), "://") } ) end num = Ops.add(num, 1) end deep_copy(ret) end |
- (Symbol) FileSelectionDialog(packagename)
Display all files in backup archive which belong to package. User can select which files will be resored.
1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 |
# File '../../src/include/restore/ui.rb', line 1830 def FileSelectionDialog(packagename) # create multiselection widget contents restore_info = Restore.GetArchiveInfo pkginfo = Ops.get_map(restore_info, packagename, {}) # map pkginfo = lookup(Restore::GetArchiveInfo(), packagename, $[]); sel_type = Ops.get_string(pkginfo, "sel_type", " ") files = Ops.get_list(pkginfo, "files", []) sel_file = Ops.get_list(pkginfo, "sel_file", []) cont = [] Builtins.foreach(files) do |f| selected = false if sel_type == "X" selected = true elsif sel_type == " " selected = false elsif sel_type == "P" selected = Builtins.contains(sel_file, f) else Builtins.y2error( "Unknown selection type %1 in package %2", sel_type, packagename ) end cont = Builtins.add(cont, Item(Id(f), f, selected)) end # multi selection box label mlabel = _("&Files to Restore") contents = HBox( HSpacing(2), VBox( VSpacing(1), ReplacePoint(Id(:rp), MultiSelectionBox(Id(:mbox), mlabel, cont)), VSpacing(1), HBox( # push button label PushButton(Id(:all), _("&Select All")), # push button label PushButton(Id(:none), _("&Deselect All")) ), VSpacing(1.5) ), HSpacing(2) ) Wizard.SetNextButton(:next, Label.OKButton) # dialog header - %1 is name of package (e.g. "aaa_base") Wizard.SetContents( Builtins.sformat(_("File Selection: Package %1"), packagename), contents, FileSelectionHelp(), true, true ) ret = nil begin ret = UI.UserInput if ret == :all || ret == :none cont = [] selected = ret == :all Builtins.foreach(files) do |f| cont = Builtins.add(cont, Item(Id(f), f, selected)) end UI.ReplaceWidget(Id(:rp), MultiSelectionBox(Id(:mbox), mlabel, cont)) elsif ret == :cancel ret = :abort end end while ret != :next && ret != :abort && ret != :back if ret == :next sel_type_new = "" sel = Convert.to_list(UI.QueryWidget(Id(:mbox), :SelectedItems)) if Builtins.size(sel) == 0 sel_type_new = " " elsif Builtins.size(sel) == Builtins.size(files) sel_type_new = "X" # clear list of selected files to save memory, "X" as sel_type is enough sel = [] else sel_type_new = "P" end Restore.SetRestoreSelection( packagename, { "sel_type" => sel_type_new, "sel_file" => sel } ) end Wizard.RestoreNextButton Convert.to_symbol(ret) end |
- (Object) initialize_restore_ui(include_target)
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 |
# File '../../src/include/restore/ui.rb', line 42 def initialize_restore_ui(include_target) Yast.import "Pkg" Yast.import "UI" textdomain "restore" Yast.import "Wizard" Yast.import "Progress" Yast.import "Restore" Yast.import "Mode" Yast.import "URL" Yast.import "Popup" Yast.import "Report" Yast.import "Label" Yast.import "Package" Yast.import "PackageSystem" Yast.import "Sequencer" Yast.include include_target, "restore/helps.rb" Yast.include include_target, "restore/summary_dialog.rb" Yast.import "NetworkPopup" @restorepackagename = nil @archivecontentscache = nil @restoredfiles = [] @failedfiles = [] @restoredpackages = 0 @bloaderstatus = nil @susestatus = nil @packagestoinstall = {} @packagestouninstall = {} # mounted directory @mountdir = "" # map with detected removable devices @removabledevices = nil # last user input, used for dialog skipping @lastret = nil end |
- (Boolean) InstallQuestion(package, version)
Ask wheter missing package should be installed and restored
1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 |
# File '../../src/include/restore/ui.rb', line 1453 def InstallQuestion(package, version) ret = false if Mode.config == true # do not ask in autoinstall config mode return true end if package != "" && !Builtins.haskey(Restore.GetActualInstalledPackages, package) && !Builtins.haskey(@packagestoinstall, package) # popup question - %1 is package name ret = Popup.AnyQuestion( "", Builtins.sformat( _("Package %1 is not installed in your system.\nInstall it?\n"), Ops.add(Ops.add(package, "-"), version) ), Label.YesButton, Label.NoButton, :focus_yes ) if ret == true # add package to the map of installed packages @packagestoinstall = Builtins.add( @packagestoinstall, package, { "ver" => version } ) end end ret end |
- (Symbol) PackageSelectionRestoreDialog
Packages (and files) for restoration can be selected in this archive.
1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 |
# File '../../src/include/restore/ui.rb', line 1491 def PackageSelectionRestoreDialog = PushButton(Id(:files), Opt(:key_F7), _("S&elect Files")) tablecontents = CreateTableContentsRestoreSelection( Restore.GetArchiveInfo ) position = 0 # refresh previous selection Builtins.foreach(tablecontents) do |t| # if (restorepackagename == select(t, 3, "")) if @restorepackagename == Ops.get_string(t, 3, "") position = Ops.get_integer(t, [0, 0], 0) end end if @restorepackagename != nil proposedRPMrestoration = Restore.ProposeRPMdbRestoration Builtins.y2milestone( "Proposed RPM restoration: %1", proposedRPMrestoration ) _RPMoption = Restore.restoreRPMdb Builtins.y2warning("RPMoption: %1", _RPMoption) if _RPMoption == nil # BNC #553400, Comment #19: Use the proposed 'Restore RPM DB' only if proposal is valid if Builtins.haskey(proposedRPMrestoration, "proposed") && Ops.get_boolean(proposedRPMrestoration, "proposed", false) != nil _RPMoption = Ops.get_boolean( proposedRPMrestoration, "proposed", false ) else _RPMoption = false end end Builtins.y2warning("RPMoption: %1", _RPMoption) _RPMoption = false if _RPMoption == nil contents = HBox( HSpacing(2), VBox( VSpacing(1), # table header Table( Id(:pkgtable), Opt(:notify), Header( " ", _("Files"), _("Package"), _("Version"), _("Description") ), tablecontents ), VSpacing(0.2), # push button label HBox( PushButton(Id(:select), _("&Select All")), PushButton(Id(:deselect), _("&Deselect All")), ), VSpacing(1.0), # check box label - restore option CheckBox( Id(:rpmdb), Opt(:notify), _("Restore RPM &Database (if present in archive)"), _RPMoption ), VSpacing(1.5) ), HSpacing(2) ) # description of symbols in the table 1/2 helptext = _( "X: Restore all files from backup, P: Partial restore of manually selected files" ) # description of symbols in the table 2/2 helptext = Ops.add( helptext, _( "<P>To select files to restore from the archive, press <B>Select Files</B>.</P>" ) ) # dialog header Wizard.SetContents( _("Packages to Restore"), contents, RestoreSelectionHelp(false), true, true ) if Mode.config == true Wizard.SetNextButton(:next, Label.FinishButton) else Wizard.SetNextButton(:next, Label.OKButton) end if Restore.RPMrestorable == false # RPM DB cannot be restored (it is not contained in the archive) Restore.restoreRPMdb = false UI.ChangeWidget(Id(:rpmdb), :Enabled, false) Builtins.y2warning( "RPM DB is not present in the archive - cannot be restored" ) end # set currnet item in the table if Ops.greater_than(Builtins.size(tablecontents), 0) UI.ChangeWidget(Id(:pkgtable), :CurrentItem, position) end ret = nil begin ret = UI.UserInput current = 0 current_value = "" current_pkgname = "" current_version = "" if Ops.greater_than(Builtins.size(tablecontents), 0) current = Convert.to_integer( UI.QueryWidget(Id(:pkgtable), :CurrentItem) ) current_item = Convert.to_term( UI.QueryWidget(Id(:pkgtable), term(:Item, current)) ) current_value = Ops.get_string(current_item, 1, " ") current_pkgname = Ops.get_string(current_item, 3, "") current_version = Ops.get_string(current_item, 4, "") # current_value = (string) select((term) UI::QueryWidget(`id(`pkgtable), `Item(current)), 1, " "); # current_pkgname = (string) select((term) UI::QueryWidget(`id(`pkgtable), `Item(current)), 3, ""); # current_version = (string) select((term) UI::QueryWidget(`id(`pkgtable), `Item(current)), 4, ""); end @restorepackagename = current_pkgname # package name "none" - files not owned by any package current_pkgname = "" if current_pkgname == _("--No package--") if ret == :pkgtable # toggle restore selection: "X" -> " ", " " -> "X", "P" -> " " if current_value == " " # check if package is installed # TODO check versions if current_pkgname != "" && !Builtins.haskey( Restore.GetActualInstalledPackages, current_pkgname ) && !Builtins.haskey(@packagestoinstall, current_pkgname) current_value = InstallQuestion(current_pkgname, current_version) ? "X" : " " else current_value = "X" end else current_value = " " end # files are selected to restore - all selectionstring = current_value == "X" ? _("All") : "" UI.ChangeWidget(Id(:pkgtable), term(:Item, current, 0), current_value) UI.ChangeWidget( Id(:pkgtable), term(:Item, current, 1), selectionstring ) Restore.SetRestoreSelection( current_pkgname, { "sel_type" => current_value } ) elsif ret == :files # check if package is installed # TODO check versions if current_value == " " && current_pkgname != "" && !Builtins.haskey( Restore.GetActualInstalledPackages, current_pkgname ) && !Builtins.haskey(@packagestoinstall, current_pkgname) if InstallQuestion(current_pkgname, current_version) == false ret = :dummy end end @restorepackagename = current_pkgname elsif (ret == :select || ret == :deselect) && Ops.greater_than(Builtins.size(tablecontents), 0) # set selection type sel_type = ret == :select ? "X" : " " if sel_type == "X" # check whether some packages are missing, ask if they should be selected too missing = Restore.GetMissingPackages selmissing = Mode.config # select all packages in autoinstall config mode if missing != {} && Mode.config == false # user selected to restore all packages, # but some packages are not installed # ask to restore them question = _( "Some packages are not installed.\nSelect them for restoration?\n" ) selmissing = Popup.AnyQuestion( "", question, Label.YesButton, Label.NoButton, :focus_no ) end # ask about mismatched packages mismatched = Restore.GetMismatchedPackages selmismatch = Mode.config # select all packages in autoinstall config mode if mismatched != {} && Mode.config == false # user selected to restore all packages, # but some installed packages have different version than at backup # ask to restore them question = _( "Some installed packages have a different\n" + "version than in the backup archive.\n" + "Select them for restoration?\n" ) selmismatch = Popup.AnyQuestion( "", question, Label.YesButton, Label.NoButton, :focus_no ) end # set selection type for packages Builtins.foreach(Restore.GetArchiveInfo) do |p, info| sel = sel_type if selmissing == false && Builtins.haskey(missing, p) == true sel = " " elsif selmismatch == false && Builtins.haskey(mismatched, p) == true sel = " " end Restore.SetRestoreSelection( p, { "sel_type" => sel, "sel_file" => [] } ) end else # set selection type for all packages Builtins.foreach(Restore.GetArchiveInfo) do |p, info| Restore.SetRestoreSelection( p, { "sel_type" => sel_type, "sel_file" => [] } ) end end # change table contents UI.ChangeWidget( Id(:pkgtable), :Items, CreateTableContentsRestoreSelection(Restore.GetArchiveInfo) ) # set previous selection if current != nil UI.ChangeWidget(Id(:pkgtable), :CurrentItem, current) end elsif ret == :rpmdb # check current RPM rezstoration status with proposed selectedRPM = Convert.to_boolean(UI.QueryWidget(Id(:rpmdb), :Value)) proposedRPMrestoration = Restore.ProposeRPMdbRestoration _RPMoption = Ops.get_boolean(proposedRPMrestoration, "proposed") if selectedRPM != _RPMoption # display warning if _RPMoption == true Popup.Warning(_("Restoring the RPM database is recommended.")) elsif _RPMoption == false Popup.Warning(_("Not restoring the RPM database is recommended.")) else # RPMoption is nil Popup.Warning( _( "There is a conflict between selected\n" + "packages and the RPM database restoration option.\n" + "Try changing the selection or the RPM database restoration status." ) ) end Restore.restoreRPMdb = selectedRPM end elsif ret == :cancel ret = :abort end end while ret != :next && ret != :abort && ret != :back && ret != :files if ret == :next final = Restore.GetArchiveInfo final = Builtins.filter(final) do |p, i| Ops.get_string(i, "sel_type", " ") != " " end Restore.restoreRPMdb = Convert.to_boolean( UI.QueryWidget(Id(:rpmdb), :Value) ) Builtins.y2debug("Final restore selection: %1", final) end Wizard.RestoreNextButton if Mode.config == true @lastret = Convert.to_symbol(ret) Convert.to_symbol(ret) end |
- (String) ProposeNextVolume(volume)
Propose next file name of volume from file name
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 |
# File '../../src/include/restore/ui.rb', line 187 def ProposeNextVolume(volume) # increase number in file name pos = Builtins.findlastof(volume, "/") volumedir = pos != nil ? Builtins.substring(volume, 0, Ops.add(pos, 1)) : "" volumefile = pos != nil ? Builtins.substring(volume, Ops.add(pos, 1)) : volume # ignore leading zeroes, 0xxx means octal number in tointeger() builtin = Builtins.tointeger( Builtins.regexpsub(volumefile, "0*([0-9]+)([^0-9]*)", "\\1") ) volumebase = Builtins.regexpsub(volumefile, "([0-9]+)([^0-9]*)", "\\2") newvolume = "" if != nil = Ops.add(, 1) newvolume = Builtins.sformat("%1", ) newvolume = Ops.add("0", newvolume) if Builtins.size(newvolume) == 1 return Ops.add(Ops.add(volumedir, newvolume), volumebase) else return "" end end |
- (Object) RestoreAutoSequence
Restoration without reading and writing. For use with autoinstallation.
2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 |
# File '../../src/include/restore/ui.rb', line 2207 def RestoreAutoSequence aliases = { "archive" => lambda { ArchiveSelectionDialog(false, false, "") }, "property" => lambda { ArchivePropertyDialog() }, "marchive" => [lambda { ArchiveSelectionDialog(true, true, "") }, true], "contents" => [lambda { ArchiveContentsDialog() }, true], "options" => [lambda { RestoreOptionsDialog() }, true], "select" => lambda { PackageSelectionRestoreDialog() }, "atexit" => lambda { AtExit() }, "selectfile" => [lambda { FileSelectionDialog(@restorepackagename) }, true] } sequence = { "ws_start" => "archive", "archive" => { :next => "property", :noconfig => "atexit", :abort => :abort }, "marchive" => { :next => "select", :abort => :abort }, "property" => { :details => "contents", :options => "options", :multi => "marchive", :next => "select", :abort => :abort }, "contents" => { :next => "property", :abort => :abort }, "options" => { :next => "property", :abort => :abort }, "select" => { :files => "selectfile", :abort => :abort, :next => :next }, "selectfile" => { :next => "select", :abort => :abort }, "atexit" => { :next => :next } } Wizard.CreateDialog Wizard.SetDesktopTitleAndIcon("restore") ret = Sequencer.Run(aliases, sequence) UI.CloseDialog deep_copy(ret) end |
- (Object) RestoreOptionsDialog
Dialog with options.
937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 |
# File '../../src/include/restore/ui.rb', line 937 def RestoreOptionsDialog contents = HBox( HSpacing(2), VBox( VSpacing(1), # check box label - restore option Left( CheckBox( Id(:lilo), _("Activate &Boot Loader Configuration after Restoration"), Restore.runbootloader ) ), VSpacing(1), # check box label - restore option Left( TextEntry( Id(:target), _("Target Directory"), Restore.targetDirectory ) ), VSpacing(1.5) ), HSpacing(2) ) Wizard.SetNextButton(:next, Label.OKButton) # dialog header Wizard.SetContents( _("Restore Options"), contents, RestoreOptionsHelp(), true, true ) ret = nil target_dir = "/" begin ret = UI.UserInput target_dir = Convert.to_string(UI.QueryWidget(Id(:target), :Value)) if Builtins.size(target_dir) == 0 || Builtins.substring(target_dir, 0, 1) != "/" # error message - entered directory is empty or doesn't start with / character Popup.Error( _("The target directory is invalid or the path is not absolute.") ) ret = nil end end while ret != :next && ret != :abort && ret != :back if ret == :cancel ret = :abort else Restore.runbootloader = Convert.to_boolean( UI.QueryWidget(Id(:lilo), :Value) ) Restore.targetDirectory = Convert.to_string( UI.QueryWidget(Id(:target), :Value) ) end Wizard.RestoreNextButton Convert.to_symbol(ret) end |
- (Symbol) RestoreProgressDialog
Restore packages from backup archive - display progress of restoring process
1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 |
# File '../../src/include/restore/ui.rb', line 1939 def RestoreProgressDialog ret = nil = :progress bootloaderstep = Restore.runbootloader == true ? 1 : 0 contents = HBox( HSpacing(2), VBox( VSpacing(1), ProgressBar( Id(), " ", Ops.add(Restore.TotalPackagesToRestore, bootloaderstep), 0 ), VSpacing(1.5) ), HSpacing(2) ) # callback function for abort callback = lambda do Yast.import "Label" ret2 = UI.PollInput abort = false if ret2 == :abort || ret2 == :cancel # abort popup question abort = Popup.AnyQuestion( _("Abort Confirmation"), _("Really abort restore?"), Label.YesButton, Label.NoButton, :focus_no ) end abort end # dialog header Wizard.SetContents( _("Restoring Files"), contents, RestoreProgressHelp(), false, false ) # start restoration result = Restore.Write(callback, , Restore.targetDirectory) # set values from restoration ret = Ops.get_boolean(result, "aborted", false) ? :abort : :next # get lilo status @bloaderstatus = Ops.get_boolean(result, "bootloader", false) if ret == :next @restoredfiles = Ops.get_list(result, "restored", []) @failedfiles = Ops.get_list(result, "failed", []) @restoredpackages = Ops.get_integer(result, "packages", 0) end @lastret = ret ret end |
- (Object) RestoreSequence
Whole restoration
2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 |
# File '../../src/include/restore/ui.rb', line 2144 def RestoreSequence aliases = { "archive" => lambda { ArchiveSelectionDialog(false, false, "") }, "property" => lambda { ArchivePropertyDialog() }, "marchive" => [lambda { ArchiveSelectionDialog(true, true, "") }, true], "contents" => [lambda { ArchiveContentsDialog() }, true], "options" => [lambda { RestoreOptionsDialog() }, true], "install" => lambda { SelectionInstallDialog() }, "uninstall" => lambda { SelectionUninstallDialog() }, "sw_single" => lambda { SWsingleDialog() }, "select" => lambda { PackageSelectionRestoreDialog() }, "selectfile" => [lambda { FileSelectionDialog(@restorepackagename) }, true], "restore" => [lambda { RestoreProgressDialog() }, true], "atexit" => lambda { AtExit() }, "summary" => lambda { SummaryDialog() } } sequence = { "ws_start" => "archive", "archive" => { :next => "property", :noconfig => "atexit", :abort => "atexit" }, "marchive" => { :next => "install", :abort => "atexit" }, "property" => { :details => "contents", :options => "options", :multi => "marchive", :next => "install", :abort => "atexit" }, "contents" => { :next => "property", :abort => "atexit" }, "options" => { :next => "property", :abort => "atexit" }, "install" => { :next => "uninstall", :abort => "atexit" }, "uninstall" => { :next => "sw_single", :abort => "atexit" }, "sw_single" => { :next => "select", :abort => "atexit" }, "select" => { :files => "selectfile", :abort => "atexit", :next => "restore" }, "restore" => { :next => "summary", :abort => "atexit" }, "selectfile" => { :next => "select", :abort => "atexit" }, "summary" => { :abort => "atexit", :next => "atexit" }, "atexit" => { :next => :next } } Wizard.CreateDialog Wizard.SetDesktopTitleAndIcon("restore") ret = Sequencer.Run(aliases, sequence) UI.CloseDialog ret end |
- (String) SelectFromList(label, inputlist, selected)
Select item from list
2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 |
# File '../../src/include/restore/ui.rb', line 2281 def SelectFromList(label, inputlist, selected) inputlist = deep_copy(inputlist) UI.OpenDialog( HBox( VSpacing(10), VBox( HSpacing(40), SelectionBox(Id(:selbox), label, inputlist), ButtonBox( PushButton(Id(:ok), Opt(:default), Label.OKButton), PushButton(Id(:cancel), Label.CancelButton) ) ) ) ) if Builtins.contains(inputlist, selected) UI.ChangeWidget(Id(:selbox), :CurrentItem, selected) end UI.SetFocus(Id(:ok)) uinput = nil begin uinput = UI.UserInput end while uinput != :ok && uinput != :cancel ret = uinput == :cancel ? "" : Convert.to_string(UI.QueryWidget(Id(:selbox), :CurrentItem)) UI.CloseDialog ret end |
- (Symbol) SelectionInstallDialog
Dialog for package selection - packages to install
1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 |
# File '../../src/include/restore/ui.rb', line 1037 def SelectionInstallDialog missingpackages = Restore.GetMissingPackages # add mismatched packages Builtins.foreach(Restore.GetMismatchedPackages) do |p, info| missingpackages = Builtins.add(missingpackages, p, info) end # if all packages are installed return `next (or `back) return @lastret if Builtins.size(missingpackages) == 0 missing = CreateTableContentsWithMismatched( missingpackages, @packagestoinstall, true ) # table header header = Header( " ", _("Package"), _("Version"), _("Installed Version"), _("Description") ) contents = HBox( HSpacing(2), VBox( VSpacing(1), Table(Id(:pkg), Opt(:notify), header, missing), VSpacing(1), HBox( # push button label PushButton(Id(:all), _("&Select All")), # push button label PushButton(Id(:none), _("&Deselect All")) ), VSpacing(1.5) ), HSpacing(2) ) # dialog header Wizard.SetContents( _("Package Restoration: Installation"), contents, InstallPackageHelp(), true, true ) ret = nil begin ret = UI.UserInput if ret == :all UI.ChangeWidget( Id(:pkg), :Items, CreateTableContentsWithMismatched(missingpackages, nil, true) ) elsif ret == :none UI.ChangeWidget( Id(:pkg), :Items, CreateTableContentsWithMismatched(missingpackages, nil, false) ) elsif ret == :pkg current = Convert.to_integer(UI.QueryWidget(Id(:pkg), :CurrentItem)) current_item = Convert.to_term( UI.QueryWidget(Id(:pkg), term(:Item, current)) ) current_value = Ops.get_string(current_item, 1, " ") # string current_value = (string) select((term) UI::QueryWidget(`id(`pkg), `Item(current)), 1, " "); if current_value == " " current_value = "X" else current_value = " " end UI.ChangeWidget(Id(:pkg), term(:Item, current, 0), current_value) elsif ret == :cancel ret = :abort end end while ret != :next && ret != :abort && ret != :back if ret != :abort num = Builtins.size(missingpackages) i = 0 @packagestoinstall = {} while Ops.less_than(i, num) current_item = Convert.to_term( UI.QueryWidget(Id(:pkg), term(:Item, i)) ) s = Ops.get_string(current_item, 1, " ") p = Ops.get_string(current_item, 2, " ") # string s = (string) select((term) UI::QueryWidget(`id(`pkg), `Item(i)), 1, " "); # string p = (string) select((term) UI::QueryWidget(`id(`pkg), `Item(i)), 2, " "); if s == "X" i2 = Ops.get(missingpackages, p, {}) v = Ops.get_string(i2, "ver", "") @packagestoinstall = Builtins.add( @packagestoinstall, p, { "ver" => v } ) # change default restore status to 'restore' for packages which will be installed if Builtins.haskey(Restore.GetArchiveInfo, p) Restore.SetRestoreSelection(p, { "sel_type" => "X" }) end else # change default restore status to 'do not restore' for packages which will not be installed if Builtins.haskey(Restore.GetArchiveInfo, p) Restore.SetRestoreSelection(p, { "sel_type" => " " }) end if Builtins.haskey(@packagestoinstall, p) @packagestoinstall = Builtins.remove(@packagestoinstall, p) end end i = Ops.add(i, 1) end Builtins.y2milestone( "Selected packages to install: %1", @packagestoinstall ) end # TODO: warn if some packages are not available on CDs and display path selection dialog to packages # LATER: allow to select package from backup archive (YOU stores packages to /var/... and they can be used) @lastret = Convert.to_symbol(ret) Convert.to_symbol(ret) end |
- (Symbol) SelectionUninstallDialog
Dialog for package selection - packages to uninstall
1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 |
# File '../../src/include/restore/ui.rb', line 1208 def SelectionUninstallDialog extrapackages = Restore.GetExtraPackages # if none extra package is installed return `next (or `back) return @lastret if Builtins.size(extrapackages) == 0 extra = CreateTableContents(extrapackages, @packagestouninstall, true) # table header header = Header(" ", _("Package"), _("Version"), _("Description")) contents = HBox( HSpacing(2), VBox( VSpacing(1), Table(Id(:pkg), Opt(:notify), header, extra), VSpacing(1), HBox( # push button label PushButton(Id(:all), _("&Select All")), # push button label PushButton(Id(:none), _("&Deselect All")) ), VSpacing(1.5) ), HSpacing(2) ) # dialog header Wizard.SetContents( _("Package Restoration: Uninstallation"), contents, UninstallPackageHelp(), true, true ) ret = nil begin ret = UI.UserInput if ret == :all UI.ChangeWidget( Id(:pkg), :Items, CreateTableContents(extrapackages, nil, true) ) elsif ret == :none UI.ChangeWidget( Id(:pkg), :Items, CreateTableContents(extrapackages, nil, false) ) elsif ret == :pkg current = Convert.to_integer(UI.QueryWidget(Id(:pkg), :CurrentItem)) current_item = Convert.to_term( UI.QueryWidget(Id(:pkg), term(:Item, current)) ) current_value = Ops.get_string(current_item, 1, " ") # string current_value = (string) select((term) UI::QueryWidget(`id(`pkg), `Item(current)), 1, " "); if current_value == " " current_value = "X" else current_value = " " end UI.ChangeWidget(Id(:pkg), term(:Item, current, 0), current_value) elsif ret == :cancel ret = :abort end end while ret != :next && ret != :abort && ret != :back if ret != :abort num = Builtins.size(extrapackages) i = 0 @packagestouninstall = {} while Ops.less_than(i, num) current_item = Convert.to_term( UI.QueryWidget(Id(:pkg), term(:Item, i)) ) s = Ops.get_string(current_item, 1, " ") p = Ops.get_string(current_item, 2, " ") # string s = (string) select((term) UI::QueryWidget(`id(`pkg), `Item(i)), 1, " "); # string p = (string) select((term) UI::QueryWidget(`id(`pkg), `Item(i)), 2, " "); if s == "X" i2 = Ops.get(extrapackages, p, {}) v = Ops.get_string(i2, "ver", "") @packagestouninstall = Builtins.add( @packagestouninstall, p, { "ver" => v } ) elsif p != nil && Builtins.haskey(@packagestouninstall, p) @packagestouninstall = Builtins.remove(@packagestouninstall, p) end i = Ops.add(i, 1) end Builtins.y2milestone( "Selected packages to uninstall: %1", @packagestouninstall ) end @lastret = Convert.to_symbol(ret) Convert.to_symbol(ret) end |
- (Object) ShadowButtons(type)
Enable/disable widget in file selction dialog according to selected input type
258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
# File '../../src/include/restore/ui.rb', line 258 def ShadowButtons(type) UI.ChangeWidget(Id(:filename), :Enabled, type == :file) UI.ChangeWidget(Id(:selectfile), :Enabled, type == :file) UI.ChangeWidget(Id(:nfsserver), :Enabled, type == :nfs) UI.ChangeWidget(Id(:nfsfilename), :Enabled, type == :nfs) UI.ChangeWidget(Id(:selecthost), :Enabled, type == :nfs) UI.ChangeWidget(Id(:device), :Enabled, type == :removable) UI.ChangeWidget(Id(:remfilename), :Enabled, type == :removable) UI.ChangeWidget(Id(:remfile), :Enabled, type == :removable) nil end |
- (String) StatusToString(status)
Convert programm status to string
2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 |
# File '../../src/include/restore/ui.rb', line 2021 def StatusToString(status) # program return status - program was not started ret = "<I>" + _("Not started") + "</I>" if status == true # program return status - success ret = _("OK") elsif status == false # program return status - failed ret = "<B>" + _("Failed") + "</B>" end ret end |
- (Symbol) SummaryDialog
Display summary of restoration
2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 |
# File '../../src/include/restore/ui.rb', line 2039 def SummaryDialog # summary information texts basicinfo = Ops.add( Ops.add( Ops.add( Ops.add( Ops.add( Ops.add( Ops.add( Ops.add( Ops.add( Ops.add( Ops.add( "<P>" + _("Number of Installed Packages: "), Builtins.size(@packagestoinstall) ), "<BR>" ), _("Number of Uninstalled Packages: ") ), Builtins.size(@packagestouninstall) ), "</P><P>" ), _("Total Restored Packages: ") ), @restoredpackages ), "<BR>" ), _("Total Restored Files: ") ), @restoredfiles != nil ? Builtins.size(@restoredfiles) : 0 ), "</P>" ) # display failed files if any if Ops.greater_than(Builtins.size(@failedfiles), 0) # summary information text - header basicinfo = Ops.add( Ops.add( Ops.add( Ops.add(Ops.add(basicinfo, "<P><B>"), _("Failed Files")), "</B><BR>" ), Builtins.mergestring(@failedfiles, "<BR>") ), "</P>" ) end # set lilo result string lilostr = StatusToString(@bloaderstatus) filelist = "" if @restoredfiles != nil && Ops.greater_than(Builtins.size(@restoredfiles), 0) prefix = Restore.targetDirectory if Builtins.substring(prefix, Ops.subtract(Builtins.size(prefix), 1), 1) != "/" prefix = Ops.add(prefix, "/") end filelist = Ops.add( prefix, Builtins.mergestring(@restoredfiles, Ops.add("<BR>", prefix)) ) end # summary information texts - details extendedinfo = Ops.add( Ops.add( Ops.add( Ops.add( Ops.add( Ops.add( "<P><BR><B>" + _("Details:") + "</B></P><P>" + _("Boot Loader Configuration: "), lilostr ), " </P><P><B>" ), _("Restored Files:") ), "</B><BR>" ), filelist ), "</P>" ) # dialog header DisplaySummaryDialog( basicinfo, Ops.add(basicinfo, extendedinfo), SummaryHelp(), _("Summary of Restoration"), :finish ) end |
- (Symbol) SWsingleDialog
Start Yast2 package manager
1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 |
# File '../../src/include/restore/ui.rb', line 1322 def SWsingleDialog install = [] uninstall = [] return :back if @lastret == :back if Ops.greater_than(Builtins.size(@packagestoinstall), 0) Builtins.foreach(@packagestoinstall) do |k, v| install = Builtins.add(install, k) end end if Ops.greater_than(Builtins.size(@packagestouninstall), 0) Builtins.foreach(@packagestouninstall) do |k, v| uninstall = Builtins.add(uninstall, k) end end Builtins.y2milestone("install: %1", install) Builtins.y2milestone("uninstall: %1", uninstall) unavailable_packages = [] # Initialize the package manager (the same way it is used later) # before checking for packages availability PackageSystem.EnsureSourceInit # BNC #553400: Checking for all packages to install whether they are available Builtins.foreach(install) do |one_package| # Package is not available - cannot be installed if Pkg.IsAvailable(one_package) != true if Popup.AnyQuestion( # Headline _("Error"), # Error message Builtins.sformat( _( "Package %1 is not available on any of the subscribed repositories.\nWould you like to got back and deselect the package or skip it?\n" ), one_package ), _("Yes, Go &Back"), _("&Skip"), :focus_yes ) Builtins.y2milestone( "User has decided to go back an unselect the package (%1)", one_package ) @lastret = :back raise Break else unavailable_packages = Builtins.add( unavailable_packages, one_package ) Builtins.y2warning( "User decided to skip missing package (%1)", one_package ) end end end # Remove all unavailable packages from list of packages to install Builtins.foreach(unavailable_packages) do |do_not_install_package| install = Builtins.filter(install) do |one_package| one_package != do_not_install_package end end return :back if @lastret == :back if Ops.greater_than(Builtins.size(install), 0) || Ops.greater_than(Builtins.size(uninstall), 0) if Package.DoInstallAndRemove(install, uninstall) != true Report.Error( _("Installation or removal of some packages has failed.") ) end Restore.ReadActualInstalledPackages end @lastret end |