Class: Yast::UpdateClass
- Inherits:
-
Module
- Object
- Module
- Yast::UpdateClass
- Includes:
- Logger
- Defined in:
- ../../src/modules/Update.rb
Constant Summary
- BACKUP_DIR =
"var/adm/backup/system-upgrade"
Instance Method Summary (collapse)
-
- (Object) clean_backup
clean backup content.
-
- (Object) create_backup(name, paths)
Creates backup with name based on
name
contaings everything matching globs inpaths
. - - (Object) Detach
-
- (Object) DropObsoletePackages
Drops packages defined in control file (string) software->dropped_packages.
- - (Object) fill_version_map(data)
- - (Object) GetBasePatterns
-
- (Object) GetProductName
Read product name and version for the old and new release.
- - (Object) IgnoreProductCompatibility
-
- (Object) InitUpdate
Set initial values for variables that user can't change.
-
- (String) installed_product
Returns product installed on root partition mounted to Installation.destdir If not found, nil is returned.
-
- (Object) IsProductSupportedForUpgrade
Returns whether the installed product is supported for upgrade.
-
- (Object) ListOfRegexpsMatchesProduct(regexp_items, product)
———————————————————————– FATE #301844 - Tuning Update Features ———————————————————————–.
- - (Object) main
-
- (Object) OnlyUpdateInstalled
Returns whether upgrade process should only update installed packages or also install new packages.
-
- (Boolean) ProductsCompatible
Check if installed product and product to upgrade to are compatible.
- - (Object) Reset
-
- (Object) restore_backup
restores backup.
- - (Object) SelectedProducts
-
- (Boolean) SetDesktopPattern
Searches the mounted system ready for ugrade for current desktop and selects resolvables matching this desktop in new product as it is defined in control file software->upgrade->window_managers.
-
- (Object) SilentlyDowngradePackages
Returns whether upgrade process should silently downgrade packages if needed.
Instance Method Details
- (Object) clean_backup
clean backup content. Usefull to clean up all content before creating new backup
870 871 872 873 874 875 |
# File '../../src/modules/Update.rb', line 870 def clean_backup log.info "Cleaning backup dir" mounted_root = Installation.destdir ::FileUtils.rm_r(File.join(mounted_root, BACKUP_DIR), :force => true, :secure => true) end |
- (Object) create_backup(name, paths)
Can be called only after target root is mounted.
Creates backup with name based on name
contaings everything
matching globs in paths
.
857 858 859 860 861 862 863 864 865 866 867 |
# File '../../src/modules/Update.rb', line 857 def create_backup(name, paths) log.info "Creating tarball for #{name} including #{paths}" mounted_root = Installation.destdir tarball_path = File.join(BACKUP_DIR, "#{name}.tar.gz") root_tarball_path = File.join(mounted_root, tarball_path) create_tarball(root_tarball_path, mounted_root, paths) script_path = File.join(mounted_root, BACKUP_DIR, "restore-#{name}.sh") create_restore_script(script_path, tarball_path, paths) end |
- (Object) Detach
804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 |
# File '../../src/modules/Update.rb', line 804 def Detach # release mounted devices Pkg.SourceReleaseAll # remove all repos except the initial installation repository # to close the solv files and allow unmounting the target repos_to_delete = Pkg.SourceGetCurrent(false) repos_to_delete.delete(0) log.info "Removing repositories: #{repos_to_delete}" # the changes are not saved to the target system, the repositories # are removed only from pkg-bindings repos_to_delete.each do |repo_to_delete| Pkg.SourceDelete(repo_to_delete) end Pkg.TargetFinish @did_init1 = false @did_init2 = false nil end |
- (Object) DropObsoletePackages
Drops packages defined in control file (string) software->dropped_packages
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
# File '../../src/modules/Update.rb', line 390 def DropObsoletePackages packages_to_drop = ProductFeatures.GetStringFeature( "software", "dropped_packages" ) if packages_to_drop == nil || packages_to_drop == "" Builtins.y2milestone("No obsolete packages to drop") return end l_packages_to_drop = Builtins.splitstring(packages_to_drop, ", \n") Builtins.y2milestone("Packages to drop: %1", l_packages_to_drop) Builtins.foreach(l_packages_to_drop) do |one_package| if Pkg.PkgInstalled(one_package) || Pkg.IsSelected(one_package) Builtins.y2milestone("Package to delete: %1", one_package) Pkg.PkgDelete(one_package) end end nil end |
- (Object) fill_version_map(data)
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 |
# File '../../src/modules/Update.rb', line 443 def fill_version_map(data) if Ops.get_string(data.value, "name", "?") == "?" && Ops.get_string(data.value, "version", "?") == "?" Ops.set(data.value, "nameandversion", "?") else Ops.set( data.value, "nameandversion", Ops.add( Ops.add(Ops.get_string(data.value, "name", "?"), " "), Ops.get_string(data.value, "version", "?") ) ) end tmp0 = [] if Builtins.regexpmatch(Ops.get_string(data.value, "version", ""), " -") Builtins.splitstring(Ops.get_string(data.value, "version", ""), " -") end tmp1 = [] if Builtins.regexpmatch(Ops.get(tmp0, 0, ""), ".") Builtins.splitstring(Ops.get(tmp0, 0, ""), ".") end tmp2 = Builtins.tointeger(Ops.get(tmp1, 0, "-1")) Ops.set(data.value, "major", tmp2) if Ops.greater_or_equal(tmp2, 0) tmp3 = Builtins.tointeger(Ops.get(tmp1, 1, "-1")) Ops.set(data.value, "minor", tmp3) if Ops.greater_or_equal(tmp3, 0) nil end |
- (Object) GetBasePatterns
733 734 735 736 737 738 739 740 741 742 743 744 745 |
# File '../../src/modules/Update.rb', line 733 def GetBasePatterns # get available base patterns patterns = Pkg.ResolvableProperties("", :pattern, "") patterns = Builtins.filter(patterns) do |p| if Ops.get(p, "status") != :selected && Ops.get(p, "status") != :available next false end # if type != base true end Builtins.maplist(patterns) { |p| Ops.get_string(p, "name", "") } end |
- (Object) GetProductName
Read product name and version for the old and new release. Fill Installation::installedVersion and Installation::updateVersion.
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 |
# File '../../src/modules/Update.rb', line 481 def GetProductName Installation.installedVersion = {} Installation.updateVersion = {} # get old product name # cannot use product information from package manager # for pre-zypp products # #153576 old_name = installed_product Builtins.y2milestone("OSRelease::ReleaseInformation: %1", old_name) # Remove 'Beta...' from product release if Builtins.regexpmatch(old_name, "Beta") old_name = Builtins.regexpsub(old_name, "^(.*)[ \t]+Beta.*$", "\\1") # Remove 'Alpha...' from product release elsif Builtins.regexpmatch(old_name, "Alpha") old_name = Builtins.regexpsub(old_name, "^(.*)[ \t]+Alpha.*$", "\\1") end p = Builtins.findlastof(old_name, " ") if p == nil Builtins.y2error("release info <%1> is screwed", old_name) Installation.installedVersion = {} else Ops.set(Installation.installedVersion, "show", old_name) Ops.set( Installation.installedVersion, "name", Builtins.substring(old_name, 0, p) ) Ops.set( Installation.installedVersion, "version", Builtins.substring(old_name, Ops.add(p, 1)) ) installedVersion_ref = arg_ref(Installation.installedVersion) fill_version_map(installedVersion_ref) Installation.installedVersion = installedVersion_ref.value end # "minor" and "major" version keys # bug #153576, "version" == "9" or "10.1" or ... inst_ver = Ops.get_string(Installation.installedVersion, "version", "") if inst_ver != "" && inst_ver != nil # SLE, SLD, OES... if Builtins.regexpmatch(inst_ver, "^[0123456789]+$") Ops.set( Installation.installedVersion, "major", Builtins.tointeger(inst_ver) ) # openSUSE elsif Builtins.regexpmatch(inst_ver, "^[0123456789]+.[0123456789]+$") Ops.set( Installation.installedVersion, "major", Builtins.tointeger( Builtins.regexpsub( inst_ver, "^([0123456789]+).[0123456789]+$", "\\1" ) ) ) Ops.set( Installation.installedVersion, "minor", Builtins.tointeger( Builtins.regexpsub( inst_ver, "^[0123456789]+.([0123456789]+)$", "\\1" ) ) ) else Builtins.y2error("Cannot find out major/minor from >%1<", inst_ver) end else Builtins.y2error( "Cannot find out version: %1", Installation.installedVersion ) end if Mode.test Builtins.y2error("Skipping detection of new system") return true end # get new product name num = Builtins.size(Packages.theSources) if Ops.less_or_equal(num, 0) Builtins.y2error("No source") Ops.set(Installation.updateVersion, "name", "?") Ops.set(Installation.updateVersion, "version", "?") updateVersion_ref = arg_ref(Installation.updateVersion) fill_version_map(updateVersion_ref) Installation.updateVersion = updateVersion_ref.value return false end update_to_source = nil Builtins.y2milestone("Known sources: %1", Packages.theSources) # So-called System Update Builtins.foreach(Packages.theSources) do |source_id| source_map = Pkg.SourceProductData(source_id) # source need to be described if source_map != {} if Ops.get_string(source_map, "productversion", "A") == Ops.get_string(Installation.installedVersion, "version", "B") Builtins.y2milestone("Found matching product: %1", source_map) update_to_source = source_id else Builtins.y2error("Found non-matching product: %1", source_map) # every invalid product is selected update_to_source = source_id if update_to_source == nil end end end if Stage.normal( ) # fallback for Stage::normal() if Stage.normal if update_to_source == nil update_to_source = Ops.get( Packages.theSources, Ops.subtract(num, 1), 0 ) end # default for !Stage::normal else update_to_source = Packages.GetBaseSourceID end new_product = Pkg.SourceProductData(update_to_source) new_source = Pkg.SourceGeneralData(update_to_source) Builtins.y2milestone( "Product to update to: %1 %2 %3", update_to_source, new_product, new_source ) if new_product == nil Ops.set(Installation.updateVersion, "name", "?") Ops.set(Installation.updateVersion, "version", "?") Builtins.y2error( "Cannot find out source details: %1", Installation.updateVersion ) updateVersion_ref = arg_ref(Installation.updateVersion) fill_version_map(updateVersion_ref) Installation.updateVersion = updateVersion_ref.value return false end # bugzilla #225256, use "label" first, then a "productname" Ops.set(Installation.updateVersion, "show", Ops.get(new_product, "label")) if Ops.get(Installation.updateVersion, "show") == nil Builtins.y2warning("No 'label' defined in product") if Ops.get_string(new_product, "productname", "?") == "?" && Ops.get_string(new_product, "productversion", "?") == "?" Ops.set(Installation.updateVersion, "show", "?") else Ops.set( Installation.updateVersion, "show", Ops.add( Ops.add(Ops.get_string(new_product, "productname", "?"), " "), Ops.get_string(new_product, "productversion", "?") ) ) end end Ops.set( Installation.updateVersion, "name", Ops.get_string( new_product, "label", Ops.get_string(new_product, "productname", "?") ) ) Ops.set( Installation.updateVersion, "version", Ops.get_string(new_product, "productversion", "?") ) updateVersion_ref = arg_ref(Installation.updateVersion) fill_version_map(updateVersion_ref) Installation.updateVersion = updateVersion_ref.value new_ver = Ops.get_string(Installation.updateVersion, "version", "") if new_ver != "" && new_ver != nil # SLE, SLD, OES... if Builtins.regexpmatch(new_ver, "^[0123456789]+$") Ops.set( Installation.updateVersion, "major", Builtins.tointeger(new_ver) ) # openSUSE elsif Builtins.regexpmatch(new_ver, "^[0123456789]+.[0123456789]$") Ops.set( Installation.updateVersion, "major", Builtins.tointeger( Builtins.regexpsub( new_ver, "^([0123456789]+).[0123456789]$", "\\1" ) ) ) Ops.set( Installation.updateVersion, "minor", Builtins.tointeger( Builtins.regexpsub( new_ver, "^[0123456789]+.([0123456789])$", "\\1" ) ) ) else Builtins.y2error("Cannot find out major/minor from %1", new_ver) end else Builtins.y2error( "Cannot find out version: %1", Installation.updateVersion ) end Builtins.y2milestone( "update from %1 to %2", Installation.installedVersion, Installation.updateVersion ) true end |
- (Object) IgnoreProductCompatibility
367 368 369 370 371 |
# File '../../src/modules/Update.rb', line 367 def IgnoreProductCompatibility @_products_compatible = true nil end |
- (Object) InitUpdate
Set initial values for variables that user can't change. They are defined in the control file.
375 376 377 378 379 380 381 382 383 384 385 |
# File '../../src/modules/Update.rb', line 375 def InitUpdate Builtins.y2milestone("Calling: InitUpdate()") @silentlyDowngradePackages = SilentlyDowngradePackages() Builtins.y2milestone( "silentlyDowngradePackages: %1", @silentlyDowngradePackages ) nil end |
- (String) installed_product
Returns product installed on root partition mounted to Installation.destdir If not found, nil is returned
831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 |
# File '../../src/modules/Update.rb', line 831 def installed_product begin return OSRelease.ReleaseInformation(Installation.destdir) rescue OSReleaseFileMissingError => e log.info "Cannot read release information #{e.}, trying SUSERelease" end begin return SUSERelease.ReleaseInformation(Installation.destdir) rescue SUSEReleaseFileMissingError => e log.info "Cannot read release information: #{e.}" rescue IOError => e log.error "Error reading SuSE-release in #{Installation.destdir}: #{e.}" end return nil end |
- (Object) IsProductSupportedForUpgrade
Returns whether the installed product is supported for upgrade. (Functionality for FATE #301844).
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 |
# File '../../src/modules/Update.rb', line 251 def IsProductSupportedForUpgrade installed_system = installed_product Builtins.y2milestone( "Processing '%1' from '%2'", installed_system, Installation.destdir ) if installed_system == nil || installed_system == "" Builtins.y2error("Cannot find out installed system name") return false end supported_products_a = ProductFeatures.GetFeature( "software", "products_supported_for_upgrade" ) # No products defined if supported_products_a == "" Builtins.y2warning("No products_supported_for_upgrade defined") return true end # not a list or empty list supported_products = Convert.convert( supported_products_a, :from => "any", :to => "list <string>" ) return true if supported_products == nil || supported_products == [] if ListOfRegexpsMatchesProduct(supported_products, installed_system) return true end false end |
- (Object) ListOfRegexpsMatchesProduct(regexp_items, product)
———————————————————————– FATE #301844 - Tuning Update Features ———————————————————————–
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File '../../src/modules/Update.rb', line 124 def ListOfRegexpsMatchesProduct(regexp_items, product) regexp_items = deep_copy(regexp_items) return false if regexp_items == nil || regexp_items == [] if product == nil Builtins.y2error("Product is nil") return false end ret = false Builtins.foreach(regexp_items) do |one_regexp| if Builtins.regexpmatch(product, one_regexp) Builtins.y2milestone(">%1< is matching >%2<", product, one_regexp) ret = true raise Break end end Builtins.y2milestone("Returning %1", ret) ret end |
- (Object) main
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 |
# File '../../src/modules/Update.rb', line 39 def main Yast.import "Pkg" textdomain "update" Yast.import "Installation" Yast.import "Packages" Yast.import "ProductFeatures" Yast.import "ProductControl" Yast.import "Stage" Yast.import "OSRelease" Yast.import "SUSERelease" Yast.import "Mode" # number of packages to install @packages_to_install = 0 # number of packages to update @packages_to_update = 0 # number of packages to remove @packages_to_remove = 0 # number of packages unknown (problematic) by update @unknown_packages = 0 # number of errors (packages?) returned by solver @solve_errors = 0 # // Flag is set true if the user decides to delete unmaintained packages # global boolean deleteOldPackages = nil; # Flag is set to true when package downgrade is allowed @silentlyDowngradePackages = nil # Flag is set to true if installed packages should be kept @keepInstalledPatches = nil # don't allow upgrade only update @disallow_upgrade = false @did_init1 = false @did_init2 = false @last_runlevel = -1 # Only an update, NOT an upgrade @onlyUpdateInstalled = nil @selected_selection = "" @products_incompatible = false # Version of the targetsystem # # !!! moved to Installation::installedVersion !!! # # global map <string, any> installedVersion = $[]; # Version of the source medium # # !!! moved to Installation::updateVersion !!! # # global map <string, any> updateVersion = $[]; # Flag, if the basesystem have to be installed @updateBasePackages = false # counter for installed packages @packagesInstalled = 0 # see bug #40358 @manual_interaction = false # are the products (installed and to update) compatible? @_products_compatible = nil end |
- (Object) OnlyUpdateInstalled
Returns whether upgrade process should only update installed packages or also install new packages. True means - do not upgrade, only update packages. (Functionality for FATE #301844).
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 |
# File '../../src/modules/Update.rb', line 148 def OnlyUpdateInstalled # changes onlyUpdateInstalled variable default_ous_a = ProductFeatures.GetFeature( "software", "only_update_selected" ) default_ous = nil if default_ous_a == nil || default_ous_a == "" Builtins.y2error("software/only_update_selected not defined") return false end if Ops.is_boolean?(default_ous_a) default_ous = Convert.to_boolean(default_ous_a) end installed_system = installed_product Builtins.y2milestone( "Processing '%1' from '%2'", installed_system, Installation.destdir ) if installed_system == nil || installed_system == "" Builtins.y2error("Cannot find out installed system name") return default_ous end reverse_ous_a = ProductFeatures.GetFeature( "software", "only_update_selected_reverse_list" ) # No reverse rules defined return default_ous if reverse_ous_a == "" # not a list or empty list reverse_ous = Convert.convert( reverse_ous_a, :from => "any", :to => "list <string>" ) return default_ous if reverse_ous == nil || reverse_ous == [] if ListOfRegexpsMatchesProduct(reverse_ous, installed_system) return !default_ous end default_ous end |
- (Boolean) ProductsCompatible
Check if installed product and product to upgrade to are compatible
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 |
# File '../../src/modules/Update.rb', line 318 def ProductsCompatible if @_products_compatible == nil if Stage.normal # check if name of one of the products on the installation # media is same as one of the installed products # assuming that multiple products on installation media # are compatible and compatibility is transitive inst = Pkg.ResolvableProperties("", :product, "") inst = Builtins.filter(inst) { |p| Ops.get(p, "status") == :installed } inst_names = Builtins.maplist(inst) do |p| Ops.get_string(p, "name", "") end to_install = Builtins.maplist(Pkg.SourceGetCurrent(true)) do |src| prod_info = Pkg.SourceProductData(src) Ops.get_string(prod_info, "name", "") end # filter out empty products to_install = Builtins.filter(to_install) { |o_p| o_p != "" } Builtins.y2milestone("Installed products: %1", inst_names) Builtins.y2milestone("Products on installation media: %1", to_install) # at least one product name found if Ops.greater_than(Builtins.size(to_install), 0) equal_product = Builtins.find(inst_names) do |i| found = Builtins.find(to_install) { |u| u == i } found != nil end @_products_compatible = equal_product != nil # no product name found # bugzilla #218720, valid without testing according to comment #10 else Builtins.y2warning( "No products found, setting product-compatible to 'true'" ) @_products_compatible = true end else @_products_compatible = true # FIXME this is temporary end Builtins.y2milestone( "Products found compatible: %1", @_products_compatible ) end @_products_compatible end |
- (Object) Reset
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 |
# File '../../src/modules/Update.rb', line 415 def Reset Builtins.y2milestone("Calling: UpdateReset()") InitUpdate() # deleteOldPackages = DeleteOldPackages(); # y2milestone ("deleteOldPackages %1", deleteOldPackages); @onlyUpdateInstalled = OnlyUpdateInstalled() @default_onlyUpdateInstalled = deep_copy(@onlyUpdateInstalled) Builtins.y2milestone("onlyUpdateInstalled %1", @onlyUpdateInstalled) @disallow_upgrade = false @manual_interaction = false @products_incompatible = false @_products_compatible = nil Installation.update_backup_modified = true Installation.update_backup_sysconfig = true Installation.update_remove_old_backups = false Installation.update_backup_path = "/var/adm/backup" nil end |
- (Object) restore_backup
restores backup
878 879 880 881 882 883 884 885 886 887 |
# File '../../src/modules/Update.rb', line 878 def restore_backup log.info "Restoring backup" mounted_root = Installation.destdir script_glob = File.join(mounted_root, BACKUP_DIR,"restore-*.sh") ::Dir.glob(script_glob).each do |path| cmd = "sh #{path} #{File.join("/", mounted_root)}" res = SCR.Execute(path(".target.bash_output"), cmd) log.info "Restoring with script #{cmd} result: #{res}" end end |
- (Object) SelectedProducts
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
# File '../../src/modules/Update.rb', line 294 def SelectedProducts selected = Pkg.ResolvableProperties("", :product, "") selected = Builtins.filter(selected) do |p| Ops.get(p, "status") == :selected end Builtins.maplist(selected) do |p| Ops.get_locale( p, "display_name", Ops.get_locale( p, "summary", Ops.get_locale( p, "name", Ops.get_locale(p, "version", _("Unknown Product")) ) ) ) end end |
- (Boolean) SetDesktopPattern
Searches the mounted system ready for ugrade for current desktop and selects resolvables matching this desktop in new product as it is defined in control file software->upgrade->window_managers
752 753 754 755 756 757 758 759 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 |
# File '../../src/modules/Update.rb', line 752 def SetDesktopPattern upgrade_settings = ProductFeatures.GetFeature("software", "upgrade") if !upgrade_settings.kind_of?(Hash) || !upgrade_settings.has_key?("window_managers") log.info "Desktop upgrade is not handled by this product (settings: #{upgrade_settings})" return true end current_desktop = installed_desktop if current_desktop.nil? || current_desktop.empty? log.warn "Cannot read default window manager from sysconfig" return true end selected_desktop = upgrade_settings["window_managers"].find do |wm| unless wm["sysconfig_wm"] log.error "'sysconfig_wm' must be defined in #{wm}" next end wm["sysconfig_wm"].strip == current_desktop end if !selected_desktop log.info "No matching desktop found for #{current_desktop}" return true end # If the current default desktop is not installed, it's a valid use case # and we don't continue further return true unless packages_installed?(selected_desktop.fetch("check_packages", "").split) install_patterns = selected_desktop.fetch("install_patterns", "").split failed_patterns = select_for_installation(:pattern, install_patterns) install_packages = selected_desktop.fetch("install_packages", "").split failed_packages = select_for_installation(:package, install_packages) failed_patterns.empty? or Report.Error( _("Cannot select these patterns required for installation:\n%{patterns}") % {:patterns => failed_patterns.join("\n")} ) failed_packages.empty? or Report.Error( _("Cannot select these packages required for installation:\n%{packages}") % {:packages => failed_packages.join("\n")} ) failed_patterns.empty? && failed_packages.empty? end |
- (Object) SilentlyDowngradePackages
Returns whether upgrade process should silently downgrade packages if needed. 'true' means that packages might be downgraded, 'nil' is returned when the feature is not supported in the control file.
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 |
# File '../../src/modules/Update.rb', line 200 def SilentlyDowngradePackages # returns empty string if not defined, buggy GetBooleanFeature default_sdp_a = ProductFeatures.GetFeature( "software", "silently_downgrade_packages" ) default_sdp = nil if default_sdp_a == nil || default_sdp_a == "" Builtins.y2milestone("software/silently_downgrade_packages not defined") return nil end if Ops.is_boolean?(default_sdp_a) default_sdp = Convert.to_boolean(default_sdp_a) end installed_system = installed_product Builtins.y2milestone( "Processing '%1' from '%2'", installed_system, Installation.destdir ) if installed_system == nil || installed_system == "" Builtins.y2error("Cannot find out installed system name") return default_sdp end reverse_sdp_a = ProductFeatures.GetFeature( "software", "silently_downgrade_packages_reverse_list" ) # No reverse rules defined return default_sdp if reverse_sdp_a == "" # not a list or empty list reverse_sdp = Convert.convert( reverse_sdp_a, :from => "any", :to => "list <string>" ) return default_sdp if reverse_sdp == nil || reverse_sdp == [] if ListOfRegexpsMatchesProduct(reverse_sdp, installed_system) return !default_sdp end default_sdp end |