Hello community, here is the log from the commit of package yast2-online-update for openSUSE:Factory checked in at 2014-02-16 10:28:30 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-online-update (Old) and /work/SRC/openSUSE:Factory/.yast2-online-update.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "yast2-online-update" Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-online-update/yast2-online-update.changes 2013-11-15 14:24:52.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.yast2-online-update.new/yast2-online-update.changes 2014-02-16 10:28:31.000000000 +0100 @@ -1,0 +2,9 @@ +Mon Feb 10 10:44:16 CET 2014 - locilka@suse.com + +- Added functionality which informs user that some of the selected + patches (listed) will need rebooting. User can then continue, + skip all those patches, or tune the selection of patches manually + (FATE#312509). +- 3.1.2 + +------------------------------------------------------------------- Old: ---- yast2-online-update-3.1.1.tar.bz2 New: ---- yast2-online-update-3.1.2.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-online-update.spec ++++++ --- /var/tmp/diff_new_pack.oTK5gX/_old 2014-02-16 10:28:32.000000000 +0100 +++ /var/tmp/diff_new_pack.oTK5gX/_new 2014-02-16 10:28:32.000000000 +0100 @@ -1,7 +1,7 @@ # # spec file for package yast2-online-update # -# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: yast2-online-update -Version: 3.1.1 +Version: 3.1.2 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -25,8 +25,9 @@ BuildRequires: gcc-c++ BuildRequires: libtool +BuildRequires: rubygem-rspec BuildRequires: update-desktop-files -BuildRequires: yast2-devtools >= 3.0.6 +BuildRequires: yast2-devtools >= 3.1.10 BuildRequires: yast2-packager # patch contents Requires: yast2-pkg-bindings >= 2.23.0 @@ -45,7 +46,8 @@ Obsoletes: yast2-trans-online-update BuildArch: noarch -Requires: yast2-ruby-bindings >= 1.0.0 +# Added Logger (replacement for y2error, y2milestone, ...) +Requires: yast2-ruby-bindings >= 3.1.7 Summary: YaST2 - Online Update (YOU) License: GPL-2.0 ++++++ yast2-online-update-3.1.1.tar.bz2 -> yast2-online-update-3.1.2.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-online-update-3.1.1/SUBDIRS new/yast2-online-update-3.1.2/SUBDIRS --- old/yast2-online-update-3.1.1/SUBDIRS 2013-11-15 13:10:25.000000000 +0100 +++ new/yast2-online-update-3.1.2/SUBDIRS 2014-02-10 17:38:02.000000000 +0100 @@ -1 +1 @@ -conf doc src testsuite +conf doc src testsuite test diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-online-update-3.1.1/VERSION new/yast2-online-update-3.1.2/VERSION --- old/yast2-online-update-3.1.1/VERSION 2013-11-15 13:10:25.000000000 +0100 +++ new/yast2-online-update-3.1.2/VERSION 1970-01-01 01:00:00.000000000 +0100 @@ -1 +0,0 @@ -3.1.1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-online-update-3.1.1/package/yast2-online-update.changes new/yast2-online-update-3.1.2/package/yast2-online-update.changes --- old/yast2-online-update-3.1.1/package/yast2-online-update.changes 2013-11-15 13:10:25.000000000 +0100 +++ new/yast2-online-update-3.1.2/package/yast2-online-update.changes 2014-02-10 17:38:02.000000000 +0100 @@ -1,4 +1,13 @@ ------------------------------------------------------------------- +Mon Feb 10 10:44:16 CET 2014 - locilka@suse.com + +- Added functionality which informs user that some of the selected + patches (listed) will need rebooting. User can then continue, + skip all those patches, or tune the selection of patches manually + (FATE#312509). +- 3.1.2 + +------------------------------------------------------------------- Wed Nov 13 15:56:18 UTC 2013 - jreidinger@suse.com - Add explicit COPYING file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-online-update-3.1.1/package/yast2-online-update.spec new/yast2-online-update-3.1.2/package/yast2-online-update.spec --- old/yast2-online-update-3.1.1/package/yast2-online-update.spec 2013-11-15 13:10:25.000000000 +0100 +++ new/yast2-online-update-3.1.2/package/yast2-online-update.spec 2014-02-10 17:38:02.000000000 +0100 @@ -17,7 +17,7 @@ Name: yast2-online-update -Version: 3.1.1 +Version: 3.1.2 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -26,7 +26,8 @@ Group: System/YaST License: GPL-2.0 BuildRequires: gcc-c++ libtool update-desktop-files yast2-packager -BuildRequires: yast2-devtools >= 3.0.6 +BuildRequires: yast2-devtools >= 3.1.10 +BuildRequires: rubygem-rspec # patch contents Requires: yast2-pkg-bindings >= 2.23.0 # Kernel::InformAboutKernelChange @@ -40,7 +41,8 @@ Obsoletes: yast2-trans-online-update y2t_online_update BuildArchitectures: noarch -Requires: yast2-ruby-bindings >= 1.0.0 +# Added Logger (replacement for y2error, y2milestone, ...) +Requires: yast2-ruby-bindings >= 3.1.7 Summary: YaST2 - Online Update (YOU) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-online-update-3.1.1/src/clients/online_update.rb new/yast2-online-update-3.1.2/src/clients/online_update.rb --- old/yast2-online-update-3.1.1/src/clients/online_update.rb 2013-11-15 13:10:25.000000000 +0100 +++ new/yast2-online-update-3.1.2/src/clients/online_update.rb 2014-02-10 17:38:02.000000000 +0100 @@ -232,11 +232,10 @@ id = 0 result = :next - while Ops.greater_or_equal(id, 0) && - Ops.less_than(id, Builtins.size(dialog)) - page = Ops.get_list(dialog, id, []) - module_name = Ops.get_string(page, 0, "") - module_args = Ops.get_list(page, 1, []) + while id >= 0 && id < dialog.size + page = dialog[id] + module_name = page.fetch(0, "") + module_args = page.fetch(1, []) Builtins.y2debug( "ONLINE: Module: %1 Args: %2", @@ -257,12 +256,12 @@ elsif result == :cancel || result == :abort break elsif result == :next || result == :auto - id = Ops.add(id, 1) + id += 1 elsif result == :back - id = Ops.subtract(id, 1) + id -= 1 elsif result == :finish if !Mode.installation && !Mode.update - id = Ops.subtract(Builtins.size(dialog), 1) # call last module + id = dialog.size - 1 # call last module else result = :next break diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-online-update-3.1.1/src/clients/online_update_select.rb new/yast2-online-update-3.1.2/src/clients/online_update_select.rb --- old/yast2-online-update-3.1.1/src/clients/online_update_select.rb 2013-11-15 13:10:25.000000000 +0100 +++ new/yast2-online-update-3.1.2/src/clients/online_update_select.rb 2014-02-10 17:38:02.000000000 +0100 @@ -41,6 +41,7 @@ Yast.import "Wizard" Yast.import "PackageSystem" Yast.import "Report" + Yast.import "OnlineUpdateDialogs" if OnlineUpdate.cd_update @canceled = false @@ -142,10 +143,22 @@ @ret = nil @current = "simple" + begin @ret = Convert.to_symbol(UI.RunPkgSelection(Id(:selector))) Builtins.y2milestone("RunPkgSelection returned %1", @ret) + + # FATE#312509: Show if patch needs a reboot and offer + # to delay the patch installation + if @ret == :accept + if ! OnlineUpdateDialogs.validate_selected_patches + @ret = nil + next + end + end + UI.CloseDialog + if @ret == :details UI.OpenDialog( Opt(:defaultsize), @@ -213,6 +226,7 @@ PackageSelector(Id(:selector), @widget_options) ) end + if @ret == :accept @restart_yast = false @normal_patches_selected = false diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-online-update-3.1.1/src/modules/OnlineUpdateDialogs.rb new/yast2-online-update-3.1.2/src/modules/OnlineUpdateDialogs.rb --- old/yast2-online-update-3.1.1/src/modules/OnlineUpdateDialogs.rb 2013-11-15 13:10:25.000000000 +0100 +++ new/yast2-online-update-3.1.2/src/modules/OnlineUpdateDialogs.rb 2014-02-10 17:38:02.000000000 +0100 @@ -25,13 +25,15 @@ module Yast class OnlineUpdateDialogsClass < Module + include Yast::Logger + def main + Yast.import "Pkg" Yast.import "UI" textdomain "online-update" Yast.import "Label" - Yast.import "Mode" Yast.import "Package" Yast.import "Popup" Yast.import "Wizard" @@ -375,6 +377,125 @@ end end + MAX_PATCHES_WIDGET_HEIGHT = 12 + + module RebootingPatches + module Buttons + CONTINUE = :continue + BACK = :cancel + SKIP = :skip + end + end + + def patches_needing_reboot + Pkg.ResolvableProperties("", :patch, "").select do |patch| + patch["status"] == :selected && patch["reboot_needed"] + end + end + + # Returns formatted list of patches that need rebooting + # + # @param options [Hash], :use_html defines whether HTML can be used (default: false) + # @return [Array] of patches (name: summary) + def formatted_rebooting_patches(options = {}) + patches_needing_reboot.map do |patch| + if options[:use_html] + "<b>#{patch["name"]}</b>: #{patch["summary"]}" + else + "#{patch["name"]}: #{patch["summary"]}" + end + end + end + + # Returns dialog definition for listing all patches that need rebooting + # + # @return dialog layout + def rebooting_patches_dialog + patches_desc = formatted_rebooting_patches(:use_html => true) + + # 2 is an additional constant for borders + min_richtext_heigth = [patches_desc.size, MAX_PATCHES_WIDGET_HEIGHT].min + 2 + + return HBox( + HSpacing(2), + VBox( + HSpacing(70), + # Dialog label above a list of patches + Label(_("These patches will need rebooting after instalation")), + MinHeight( + min_richtext_heigth, + RichText(Opt(:vstretch), patches_desc.join("<br>")) + ), + ButtonBox( + PushButton(Id(RebootingPatches::Buttons::CONTINUE), Opt(:default), Label.ContinueButton), + PushButton(Id(RebootingPatches::Buttons::BACK), Label.BackButton), + # Push button for Skipping all patches that require rebooting + PushButton(Id(RebootingPatches::Buttons::SKIP), _("&Skip All")) + ) + ), + HSpacing(2) + ) + end + + # Tries to neutralize all patches that need rebooting. + # Returns whether it was successful. + # + # @return [Boolean] whether skipping rebooting patches was successful + def skip_rebooting_patches + patches_needing_reboot.each do |patch| + log.info "Removing patch #{patch["name"]} from selection" + Pkg.ResolvableNeutral(patch["name"], :patch, true) + end + + # Solver can't solve it automatically + return false unless Pkg.PkgSolve(true) + + rebooting_patches = formatted_rebooting_patches + + if ! rebooting_patches.empty? + Popup.MessageDetails( + _("Online update was unable to unselect some patches that need rebooting."), + rebooting_patches.join("\n") + ) + return false + end + + true + end + + # Shows dialog with patches that need rebooting and wait for user's decision + # whether to continue + # + # @return [Boolean] whether to continue installing patches (true: continue, false: go_back) + def confirm_rebooting_patches + UI.OpenDialog(rebooting_patches_dialog) + user_ret = UI.UserInput + UI.CloseDialog + + case user_ret + when RebootingPatches::Buttons::CONTINUE + return true + when RebootingPatches::Buttons::BACK + return false + when RebootingPatches::Buttons::SKIP + return skip_rebooting_patches + else + raise RuntimeError.new "Unhandled return value: #{user_ret}" + end + end + + # Returns boolean whether to continue with patches installation + # + # @return [Boolean] whether to continue + def validate_selected_patches + patches = patches_needing_reboot + log.info "Patches that need rebooting: #{patches.map{|p| p["name"]}}" + + return true if patches.empty? + + confirm_rebooting_patches + end + publish :function => :IgnoreWarningPopup, :type => "symbol (string, string)" publish :function => :IgnorePopup, :type => "symbol (string, string)" publish :function => :SkipPopup, :type => "symbol (string, string)" @@ -383,6 +504,7 @@ publish :function => :DisplayMsgYou, :type => "boolean (string, string, string, string)" publish :function => :DisplayMsgYouOk, :type => "boolean (string, string, string)" publish :function => :MessagePopup, :type => "boolean (list <map>, boolean)" + publish :function => :validate_selected_patches, :type => "boolean ()" end OnlineUpdateDialogs = OnlineUpdateDialogsClass.new diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-online-update-3.1.1/test/Makefile.am new/yast2-online-update-3.1.2/test/Makefile.am --- old/yast2-online-update-3.1.1/test/Makefile.am 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-online-update-3.1.2/test/Makefile.am 2014-02-10 17:38:02.000000000 +0100 @@ -0,0 +1,7 @@ +TESTS = \ + online_update_dialogs_test.rb + +TEST_EXTENSIONS = .rb +RB_LOG_COMPILER = rspec +VERBOSE = 1 +EXTRA_DIST = $(TESTS) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-online-update-3.1.1/test/online_update_dialogs_test.rb new/yast2-online-update-3.1.2/test/online_update_dialogs_test.rb --- old/yast2-online-update-3.1.1/test/online_update_dialogs_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-online-update-3.1.2/test/online_update_dialogs_test.rb 2014-02-10 17:38:02.000000000 +0100 @@ -0,0 +1,109 @@ +#! /usr/bin/env rspec + +ENV["Y2DIR"] = File.expand_path("../../src", __FILE__) + +require "yast" + +Yast.import "OnlineUpdateDialogs" +Yast.import "Pkg" +Yast.import "UI" + +DEFAULT_PATCH = { + "status" => :selected, + "name" => "patch_#{$patch_id}", + "reboot_needed" => false, + "description" => "...", + "arch" => "noarch", +} + +def patch(args = {}) + $patch_id ||= 0 + $patch_id += 1 + DEFAULT_PATCH.merge(args) +end + +# Two patches have "reboot_needed" => true +PATCHES = Array.new(2){ patch("reboot_needed" => true) } + Array.new(2){ patch } + +# All patches are "reboot_needed" => false +PATCHES_WITHOUT_REBOOTING = Array.new(4){ patch } + +describe "OnlineUpdateDialogs" do + before(:each) do + Yast::Pkg.stub(:ResolvableProperties).and_return(PATCHES) + Yast::Pkg.stub(:ResolvableNeutral).and_return(true) + Yast::Pkg.stub(:PkgSolve).and_return(true) + end + + describe "#patches_needing_reboot" do + it "returns list of selected patches that need rebooting" do + expect(Yast::OnlineUpdateDialogs.patches_needing_reboot.size).to eq 2 + end + end + + describe "#formatted_rebooting_patches" do + it "returns list of strings describing patch in HTML when :use_html is set" do + patches = Yast::OnlineUpdateDialogs.formatted_rebooting_patches(:use_html => true) + expect(patches.size).to eq 2 + expect(patches[0]).to match(/) + expect(patches[0]).to match(/>/) + end + + it "returns list of strings describing patch in plain text when :use_html is not set" do + patches = Yast::OnlineUpdateDialogs.formatted_rebooting_patches(:use_html => false) + expect(patches.size).to eq 2 + expect(patches[0]).not_to match(/) + expect(patches[0]).not_to match(/>/) + end + end + + describe "#rebooting_patches_dialog" do + it "returns dialog layout" do + expect(Yast::OnlineUpdateDialogs.rebooting_patches_dialog).not_to eq nil + end + end + + describe "#confirm_rebooting_patches" do + before(:each) do + Yast::UI.stub(:OpenDialog).and_return(true) + Yast::UI.stub(:CloseDialog).and_return(true) + end + + it "returns true if user decides to continue" do + Yast::UI.stub(:UserInput).and_return(Yast::OnlineUpdateDialogsClass::RebootingPatches::Buttons::CONTINUE) + expect(Yast::OnlineUpdateDialogs.confirm_rebooting_patches).to be_true + end + + it "returns false if user decides to go back" do + Yast::UI.stub(:UserInput).and_return(Yast::OnlineUpdateDialogsClass::RebootingPatches::Buttons::BACK) + expect(Yast::OnlineUpdateDialogs.confirm_rebooting_patches).to be_false + end + + it "returns true if user decides to skip rebooting patches and they are automatically unselected" do + # At first, there are some rebooting patches selected, later there are none + Yast::Pkg.stub(:ResolvableProperties).and_return(PATCHES, PATCHES_WITHOUT_REBOOTING) + Yast::UI.stub(:UserInput).and_return(Yast::OnlineUpdateDialogsClass::RebootingPatches::Buttons::SKIP) + expect(Yast::OnlineUpdateDialogs.confirm_rebooting_patches).to be_true, "Selected patches: #{Yast::Pkg.ResolvableProperties()}" + end + + it "returns false if user decides to skip rebooting patches but they are not automatically unselected" do + # At first, there are some rebooting patches selected, later there still the same ones + Yast::Pkg.stub(:ResolvableProperties).and_return(PATCHES) + Yast::UI.stub(:UserInput).and_return(Yast::OnlineUpdateDialogsClass::RebootingPatches::Buttons::SKIP) + expect(Yast::OnlineUpdateDialogs.confirm_rebooting_patches).to be_false, "Selected patches: #{Yast::Pkg.ResolvableProperties()}" + end + + it "returns false if user decides to skip rebooting patches but there are solver errors preset" do + # At first, there are some rebooting patches selected, later there are none + Yast::Pkg.stub(:ResolvableProperties).and_return(PATCHES, PATCHES_WITHOUT_REBOOTING) + Yast::UI.stub(:UserInput).and_return(Yast::OnlineUpdateDialogsClass::RebootingPatches::Buttons::SKIP) + Yast::Pkg.stub(:PkgSolve).and_return(false) + expect(Yast::OnlineUpdateDialogs.confirm_rebooting_patches).to be_false, "Selected patches: #{Yast::Pkg.ResolvableProperties()}" + end + + it "raises an exception if UI returns unexpected return value" do + Yast::UI.stub(:UserInput).and_return(:unknown_user_input) + expect { Yast::OnlineUpdateDialogs.confirm_rebooting_patches }.to raise_error + end + end +end -- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org