commit yast2-update for openSUSE:Factory
Hello community, here is the log from the commit of package yast2-update for openSUSE:Factory checked in at 2014-05-17 22:01:45 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-update (Old) and /work/SRC/openSUSE:Factory/.yast2-update.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "yast2-update" Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-update/yast2-update.changes 2014-05-06 13:40:43.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-update.new/yast2-update.changes 2014-05-17 22:01:51.000000000 +0200 @@ -1,0 +2,8 @@ +Thu May 15 09:17:19 CEST 2014 - locilka@suse.com + +- Added handling for desktop upgrade (bnc#874116). Moved from code + to control file as packages and patterns might have different + names in different prducts. +- 3.1.8 + +------------------------------------------------------------------- Old: ---- yast2-update-3.1.7.tar.bz2 New: ---- yast2-update-3.1.8.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-update.spec ++++++ --- /var/tmp/diff_new_pack.5y8XKe/_old 2014-05-17 22:01:52.000000000 +0200 +++ /var/tmp/diff_new_pack.5y8XKe/_new 2014-05-17 22:01:52.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-update -Version: 3.1.7 +Version: 3.1.8 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build ++++++ yast2-update-3.1.7.tar.bz2 -> yast2-update-3.1.8.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-update-3.1.7/package/yast2-update.changes new/yast2-update-3.1.8/package/yast2-update.changes --- old/yast2-update-3.1.7/package/yast2-update.changes 2014-05-02 14:43:50.000000000 +0200 +++ new/yast2-update-3.1.8/package/yast2-update.changes 2014-05-15 11:23:47.000000000 +0200 @@ -1,4 +1,12 @@ ------------------------------------------------------------------- +Thu May 15 09:17:19 CEST 2014 - locilka@suse.com + +- Added handling for desktop upgrade (bnc#874116). Moved from code + to control file as packages and patterns might have different + names in different prducts. +- 3.1.8 + +------------------------------------------------------------------- Fri May 2 12:36:53 UTC 2014 - jreidinger@suse.com - Fix internal error caused by wrong type passed as string append diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-update-3.1.7/package/yast2-update.spec new/yast2-update-3.1.8/package/yast2-update.spec --- old/yast2-update-3.1.7/package/yast2-update.spec 2014-05-02 14:43:50.000000000 +0200 +++ new/yast2-update-3.1.8/package/yast2-update.spec 2014-05-15 11:23:47.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-update -Version: 3.1.7 +Version: 3.1.8 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-update-3.1.7/src/modules/Update.rb new/yast2-update-3.1.8/src/modules/Update.rb --- old/yast2-update-3.1.7/src/modules/Update.rb 2014-05-02 14:43:50.000000000 +0200 +++ new/yast2-update-3.1.8/src/modules/Update.rb 2014-05-15 11:23:47.000000000 +0200 @@ -743,69 +743,60 @@ Builtins.maplist(patterns) { |p| Ops.get_string(p, "name", "") } end + # 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 + # + # @return [Boolean] whether selecting resolvables have succeeded + def SetDesktopPattern + upgrade_settings = ProductFeatures.GetFeature("software", "upgrade") - def ReadInstalledDesktop - SCR.Execute( - path(".target.bash"), - "/bin/mv -f /etc/sysconfig/windowmanager /etc/sysconfig/windowmanager.old" - ) - SCR.Execute( - path(".target.bash"), - "/bin/ln -s /mnt/etc/sysconfig/windowmanager /etc/sysconfig/windowmanager" - ) - ret = Convert.to_string( - SCR.Read(path(".sysconfig.windowmanager.DEFAULT_WM")) - ) - SCR.Execute( - path(".target.bash"), - "/bin/rm -f /etc/sysconfig/windowmanager" - ) - SCR.Execute( - path(".target.bash"), - "/bin/mv -f /etc/sysconfig/windowmanager.old /etc/sysconfig/windowmanager" - ) - ret - end + 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 - # check if given package is installed in the system selected for update - # (currently mounted under /mnt) - def PackageInstalled(package) - SCR.Execute( - path(".target.bash"), - Builtins.sformat("rpm -q %1 --root /mnt", package) - ) == 0 - end + current_desktop = installed_desktop - def SetDesktopPattern - desktop = ReadInstalledDesktop() - if Builtins.contains( - ["kde", "kde4", "xfce", "lxde", "gnome", "startkde", "startkde4"], - desktop - ) - # 'gnome'/'startkde' could be default values even if not installed, - # check the real state (bnc#737402) - if desktop == "gnome" - if !PackageInstalled("gnome-session") - Builtins.y2milestone( - "GNOME not present: not installing new desktop" - ) - return - end - elsif desktop == "startkde" || desktop == "startkde4" - if PackageInstalled("kdebase3-session") || - PackageInstalled("kdebase4-session") - desktop = "kde4" - else - Builtins.y2milestone("KDE not present: not installing new desktop") - return - end + 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 - Builtins.y2milestone("Selecting pattern to install: %1", desktop) - Pkg.ResolvableInstall(desktop, :pattern) + if !selected_desktop + log.info "No matching desktop found for #{current_desktop}" + return true end - nil + # 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 # @@ -817,13 +808,6 @@ nil end - def TextsUsedInFuture - # TRANSLATORS: check-box, it might happen that we need to downgrade some packages during update - aaa = _("Allow Package Downgrade") - - nil - end - # Returns product installed on root partition mounted to Installation.destdir # If not found, nil is returned # @@ -879,6 +863,79 @@ publish :function => :SetDesktopPattern, :type => "void ()" publish :function => :Detach, :type => "void ()" publish :function => :installed_product, :type => "string ()" + + private + + # Reads the currently selected default desktop from sysconfig + # and returns it + # + # @return [String] current default desktop + def installed_desktop + windowmanager_sysconfig = File.join( + Installation.destdir, "/etc/sysconfig/windowmanager" + ) + + if !FileUtils.Exists(windowmanager_sysconfig) + log.warn "Sysconfig file #{windowmanager_sysconfig} does not exist, " << + "desktop upgrade will not be handled" + return nil + end + + Misc.CustomSysconfigRead("DEFAULT_WM", "", windowmanager_sysconfig).strip + end + + # Selects resolvables for installation and returns list of failed resolvables + # + # @param [Symbol] resolvable type + # @param [Array] list of resolvables for installation + # @return [Array] list of failed resolvables + def select_for_installation(resolvable_type, resolvables) + failed_resolvables = [] + return failed_resolvables if resolvables.empty? + + log.info "Selecting required #{resolvable_type}s #{resolvables}" + + resolvables.each do |resolvable| + next if resolvable.nil? || resolvable.empty? + + unless Pkg.ResolvableInstall(resolvable, resolvable_type) + failed_resolvables << resolvable + log.error "Cannot select #{resolvable_type} #{resolvable} for installation" + end + end + + failed_resolvables + end + + # check if given package is installed in the system selected for update + # (currently mounted under Installation.destdir) + # + # @param [String] package name + # @return [Boolean] whether the given package is installed + def package_installed?(package) + package_installed = SCR.Execute( + path(".target.bash"), + Builtins.sformat("rpm -q '#{package}' --root '#{Installation.destdir}'") + ) == 0 + + log.info "Package #{package} installed: #{package_installed}" + package_installed + end + + # Returns whether all packages given as parameter are installed on the system + # + # @param [Array] list of packages + # @return [Boolean] whether all of packages are installed + def packages_installed?(packages) + desktop_installed = packages.all? do |package| + package_installed?(package) + end + + log.info "Not all packages from list #{packages} are installed" unless desktop_installed + + desktop_installed + end + end Update = UpdateClass.new diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-update-3.1.7/test/data/control-files/desktop-upgrade.xml new/yast2-update-3.1.8/test/data/control-files/desktop-upgrade.xml --- old/yast2-update-3.1.7/test/data/control-files/desktop-upgrade.xml 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-update-3.1.8/test/data/control-files/desktop-upgrade.xml 2014-05-15 11:23:47.000000000 +0200 @@ -0,0 +1,15 @@ +<?xml version="1.0"?> +<productDefines xmlns="http://www.suse.com/1.0/yast2ns" xmlns:config="http://www.suse.com/1.0/configns"> + <software> + <upgrade> + <window_managers config:type="list"> + <window_manager> + <sysconfig_wm>sysconfig-desktop</sysconfig_wm> + <check_packages>check-package-1 check-package-2</check_packages> + <install_patterns>install-pattern-1 install-pattern-2</install_patterns> + <install_packages>install-package-1 install-package-2</install_packages> + </window_manager> + </window_managers> + </upgrade> + </software> +</productDefines> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-update-3.1.7/test/update_test.rb new/yast2-update-3.1.8/test/update_test.rb --- old/yast2-update-3.1.7/test/update_test.rb 2014-05-02 14:43:51.000000000 +0200 +++ new/yast2-update-3.1.8/test/update_test.rb 2014-05-15 11:23:47.000000000 +0200 @@ -6,27 +6,140 @@ Yast.import "Update" Yast.import "Installation" +Yast.import "ProductControl" +Yast.import "ProductFeatures" +Yast.import "FileUtils" +Yast.import "Misc" +Yast.import "SCR" +Yast.import "Pkg" +Yast.import "Report" + +include Yast::Logger DATA_DIR = File.join( File.expand_path(File.dirname(__FILE__)), "data" ) +def default_product_control + Yast::ProductControl.custom_control_file = File.join(DATA_DIR, "control-files", "desktop-upgrade.xml") + Yast::ProductControl.Init +end + +def default_SetDesktopPattern_stubs + default_product_control + Yast::Update.stub(:installed_desktop).and_return("sysconfig-desktop") + Yast::Update.stub(:packages_installed?).and_return(true) + Yast::Pkg.stub(:ResolvableInstall).with(kind_of(String), :pattern).and_return(true) + Yast::Pkg.stub(:ResolvableInstall).with(kind_of(String), :package).and_return(true) +end + describe Yast::Update do + before(:each) do + log.info "--- test ---" + end + describe "#installed_product" do it "returns `nil` if neither os-release nor SuSE-release files exist in Installation.destdir" do - Yast::Installation.destdir = File.join(DATA_DIR, "update-test-1") + Yast::Installation.stub(:destdir).and_return(File.join(DATA_DIR, "update-test-1")) expect(Yast::Update.installed_product).to be_nil end it "returns product name from SUSE-release if os-release is missing and SUSE-release exists in Installation.destdir" do - Yast::Installation.destdir = File.join(DATA_DIR, "update-test-2") + Yast::Installation.stub(:destdir).and_return(File.join(DATA_DIR, "update-test-2")) expect(Yast::Update.installed_product).to eq("SUSE Linux Enterprise Server 11") end it "returns product name from os-release if such file exists in Installation.destdir" do - Yast::Installation.destdir = File.join(DATA_DIR, "update-test-3") + Yast::Installation.stub(:destdir).and_return(File.join(DATA_DIR, "update-test-3")) expect(Yast::Update.installed_product).to eq("openSUSE 13.1") end end + + describe "#SetDesktopPattern" do + context "if there is no definition of window manager upgrade path in control file" do + it "returns true as there is no upgrade path defined" do + Yast::ProductFeatures.stub(:GetFeature).with("software","upgrade").and_return(nil) + + expect(Yast::Y2Logger.instance).to receive(:info) do |msg| + expect(msg).to match(/upgrade is not handled by this product/i) + end.and_call_original + + expect(Yast::Update.SetDesktopPattern).to be_true + end + end + + context "if there is no windowmanager sysconfig file present on the system selected for upgrade" do + it "returns true as there is nothing to do" do + default_product_control + Yast::FileUtils.stub(:Exists).with(/windowmanager/).and_return(false) + + expect(Yast::Y2Logger.instance).to receive(:warn) do |msg| + expect(msg).to match(/(Sysconfig file .* does not exist|cannot read default window manager)/i) + end.twice.and_call_original + + expect(Yast::Update.SetDesktopPattern).to be_true + end + end + + context "if no upgrade path for the current windowmanager is defined" do + it "returns true as there is nothing to do" do + default_product_control + installed_desktop = "desktop-not-supported-for-upgrade" + Yast::Update.stub(:installed_desktop).and_return(installed_desktop) + + expect(Yast::Y2Logger.instance).to receive(:info) do |msg| + expect(msg).to match(/no matching desktop found .* #{installed_desktop}/i) + end.and_call_original + + expect(Yast::Update.SetDesktopPattern).to be_true + end + end + + context "if desktop packages are not installed" do + it "returns true as there is nothing to upgrade" do + default_product_control + Yast::Update.stub(:installed_desktop).and_return("sysconfig-desktop") + Yast::SCR.stub(:Execute).and_return(0) + Yast::SCR.stub(:Execute).with(kind_of(Yast::Path), /rpm -q/).and_return(-1) + + expect(Yast::Y2Logger.instance).to receive(:info) do |msg| + expect(msg).to match(/(package .* installed: false|not all packages .* are installed)/i) + end.twice.and_call_original + + expect(Yast::Update.SetDesktopPattern).to be_true + end + end + + context "all desktop packages are installed" do + context "and cannot select all patterns for installation" do + it "returns false" do + default_SetDesktopPattern_stubs + Yast::Pkg.stub(:ResolvableInstall).with(kind_of(String), :pattern).and_return(false) + + expect(Yast::Report).to receive(:Error).with(/cannot select these patterns/i) + expect(Yast::Update.SetDesktopPattern).to be_false + end + end + + context "and cannot select all packages for installation" do + it "returns false" do + default_SetDesktopPattern_stubs + Yast::Pkg.stub(:ResolvableInstall).with(kind_of(String), :package).and_return(false) + + expect(Yast::Report).to receive(:Error).with(/cannot select these packages/i) + expect(Yast::Update.SetDesktopPattern).to be_false + end + end + + context "and selecting all resolvables succeeds" do + it "returns true" do + default_SetDesktopPattern_stubs + + expect(Yast::Update.SetDesktopPattern).to be_true + end + end + end + + end end -- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org
participants (1)
-
root@hilbert.suse.de