Hello community, here is the log from the commit of package yast2 for openSUSE:Factory checked in at 2013-11-28 16:53:52 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2 (Old) and /work/SRC/openSUSE:Factory/.yast2.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2" Changes: -------- --- /work/SRC/openSUSE:Factory/yast2/yast2.changes 2013-11-25 16:04:30.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.yast2.new/yast2.changes 2013-11-28 16:53:54.000000000 +0100 @@ -1,0 +2,6 @@ +Thu Nov 28 12:42:12 UTC 2013 - [email protected] + +- Add hook into installation workflow +- 3.1.6 + +------------------------------------------------------------------- Old: ---- yast2-3.1.5.tar.bz2 New: ---- yast2-3.1.6.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2.spec ++++++ --- /var/tmp/diff_new_pack.7VrK2i/_old 2013-11-28 16:53:55.000000000 +0100 +++ /var/tmp/diff_new_pack.7VrK2i/_new 2013-11-28 16:53:55.000000000 +0100 @@ -17,7 +17,7 @@ Name: yast2 -Version: 3.1.5 +Version: 3.1.6 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -177,6 +177,7 @@ mkdir -p "$RPM_BUILD_ROOT"%{yast_ydatadir} mkdir -p "$RPM_BUILD_ROOT"%{yast_yncludedir} mkdir -p "$RPM_BUILD_ROOT"%{yast_vardir} +mkdir -p "$RPM_BUILD_ROOT"%{yast_vardir}/hooks mkdir -p "$RPM_BUILD_ROOT"%{yast_schemadir}/control/rnc mkdir -p "$RPM_BUILD_ROOT"%{yast_schemadir}/autoyast/rnc mkdir -p "$RPM_BUILD_ROOT"/etc/YaST2 @@ -211,6 +212,7 @@ %dir %{yast_schemadir}/autoyast %dir %{yast_schemadir}/autoyast/rnc %dir %{_sysconfdir}/YaST2 +%dir %{yast_vardir}/hooks # yast2 @@ -228,6 +230,7 @@ %doc %dir %{yast_docdir} %doc %{yast_docdir}/COPYING %doc %{_mandir}/*/* +%doc %{yast_vardir}/hooks/README.md /sbin/* %{_sbindir}/* @@ -266,5 +269,6 @@ %doc %{yast_docdir}/types %doc %{yast_docdir}/wizard %doc %{yast_docdir}/xml +%doc %{yast_docdir}/general %changelog ++++++ yast2-3.1.5.tar.bz2 -> yast2-3.1.6.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.5/VERSION new/yast2-3.1.6/VERSION --- old/yast2-3.1.5/VERSION 2013-11-25 14:17:12.000000000 +0100 +++ new/yast2-3.1.6/VERSION 2013-11-28 13:57:35.000000000 +0100 @@ -1 +1 @@ -3.1.5 +3.1.6 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.5/library/control/src/modules/ProductControl.rb new/yast2-3.1.6/library/control/src/modules/ProductControl.rb --- old/yast2-3.1.5/library/control/src/modules/ProductControl.rb 2013-11-25 14:17:12.000000000 +0100 +++ new/yast2-3.1.6/library/control/src/modules/ProductControl.rb 2013-11-28 13:57:35.000000000 +0100 @@ -50,6 +50,7 @@ Yast.import "Popup" Yast.import "FileUtils" Yast.import "Installation" + Yast.import "Hooks" # The complete parsed control file @productControl = {} @@ -88,19 +89,12 @@ # The control file we are using for this session. @current_control_file = nil - # Current Wizard Step @CurrentWizardStep = "" - # Last recently used stage_mode for RetranslateWizardSteps @last_stage_mode = [] - - # --> - - # Currently only local variables, they have their own API - # List of module to disable in the current run @DisabledModules = [] @@ -109,8 +103,6 @@ @DisabledSubProposals = {} - # <-- - # Log files for hooks @logfiles = [] @@ -118,19 +110,16 @@ @restarting_step = nil - - - @_client_prefix = "inst_" @stack = [] - @first_id = "" @current_step = 0 @localDisabledProposals = [] + @localDisabledModules = [] @already_disabled_workflows = [] @@ -139,6 +128,9 @@ @force_UpdateWizardSteps = false @lastDisabledModules = deep_copy(@DisabledModules) + + @installation_hooks = [] + ProductControl() end @@ -1396,9 +1388,18 @@ end end + before_hook_name = "before_#{step_name}" + before_hook = Hooks.run(before_hook_name) + @installation_hooks << before_hook + result = Convert.to_symbol( WFM.CallFunction(getClientName(step_name, step_execute), args) ) + + after_hook_name = "after_#{step_name}" + after_hook = Hooks.run(after_hook_name) + @installation_hooks << after_hook + Builtins.y2milestone("Calling %1 returned %2", argterm, result) # bnc #369846 @@ -1548,6 +1549,18 @@ end former_result = result end + + failed_hooks = @installation_hooks.select {|hook| hook.failed? } + if !failed_hooks.empty? + Report.Error _("#{failed_hooks.size} installation hooks have failed: " + + "#{failed_hooks.map {|h| h.name}.join(', ')}") + #TODO + # show some structured widget for the user to see: + # * all run hooks + # * all succeeded hooks + # * all failed hooks with the error output + end + final_result = :abort if former_result == :abort Builtins.y2milestone( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.5/library/general/Makefile.am new/yast2-3.1.6/library/general/Makefile.am --- old/yast2-3.1.5/library/general/Makefile.am 2013-11-25 14:17:12.000000000 +0100 +++ new/yast2-3.1.6/library/general/Makefile.am 2013-11-28 13:57:35.000000000 +0100 @@ -1,3 +1,3 @@ # Makefile.am for library/general -SUBDIRS = src testsuite test +SUBDIRS = src testsuite test hooks doc diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.5/library/general/doc/Hooks.md new/yast2-3.1.6/library/general/doc/Hooks.md --- old/yast2-3.1.5/library/general/doc/Hooks.md 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-3.1.6/library/general/doc/Hooks.md 2013-11-28 13:57:35.000000000 +0100 @@ -0,0 +1,2 @@ +# Detailed manual about hooks for users and customers about how to use hooks +and what they are diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.5/library/general/doc/Makefile.am new/yast2-3.1.6/library/general/doc/Makefile.am --- old/yast2-3.1.5/library/general/doc/Makefile.am 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-3.1.6/library/general/doc/Makefile.am 2013-11-28 13:57:35.000000000 +0100 @@ -0,0 +1,7 @@ +# Makefile.am for ../doc + +generaldir = $(docdir)/general + +general_DATA = $(wildcard *.md) + +EXTRA_DIST = $(general_DATA) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.5/library/general/hooks/Makefile.am new/yast2-3.1.6/library/general/hooks/Makefile.am --- old/yast2-3.1.5/library/general/hooks/Makefile.am 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-3.1.6/library/general/hooks/Makefile.am 2013-11-28 13:57:35.000000000 +0100 @@ -0,0 +1,5 @@ +hooksdir = /var/lib/YaST2/hooks + +hooks_DATA = README.md + +EXTRA_DIST = $(hooks_DATA) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.5/library/general/hooks/README.md new/yast2-3.1.6/library/general/hooks/README.md --- old/yast2-3.1.5/library/general/hooks/README.md 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-3.1.6/library/general/hooks/README.md 2013-11-28 13:57:35.000000000 +0100 @@ -0,0 +1,3 @@ +Hooks document to be put into the directory /var/lib/YaST2/hooks +as a short reference for users and customers who might make use of hooks + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.5/library/general/src/Makefile.am new/yast2-3.1.6/library/general/src/Makefile.am --- old/yast2-3.1.5/library/general/src/Makefile.am 2013-11-25 14:17:12.000000000 +0100 +++ new/yast2-3.1.6/library/general/src/Makefile.am 2013-11-28 13:57:35.000000000 +0100 @@ -34,7 +34,8 @@ modules/Stage.rb \ modules/RegistrationStatus.pm \ modules/MailTable.pm \ - modules/MailTableInclude.pm + modules/MailTableInclude.pm \ + modules/Hooks.rb scrconf_DATA = \ scrconf/content.scr \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.5/library/general/src/modules/Hooks.rb new/yast2-3.1.6/library/general/src/modules/Hooks.rb --- old/yast2-3.1.5/library/general/src/modules/Hooks.rb 2013-11-25 14:17:12.000000000 +0100 +++ new/yast2-3.1.6/library/general/src/modules/Hooks.rb 2013-11-28 13:57:35.000000000 +0100 @@ -34,7 +34,7 @@ # Hooks.search_path.join!('personal') # # and this will set a completely different path # Hooks.search_path.set "/root/hooks" -# hook = Hooks.run :before_showing_ui +# hook = Hooks.run 'before_showing_ui' # # Lot of beautiful and useful code follows here. # # If needed make use of: # # * hook.failed? @@ -49,7 +49,7 @@ # # * Hooks.last.search_path # # * Hooks.last.results # # * Hooks.last.files -# Hooks.run :after_showing_ui +# Hooks.run 'after_showing_ui' # # reset the search path if needed # Hooks.search_path.reset # end @@ -68,6 +68,9 @@ end def run hook_name + hook_name = hook_name.to_s + raise "Hook name not specified" if hook_name.empty? + hook = create(hook_name, caller.first) hook.execute @last = hook @@ -125,6 +128,14 @@ path.to_s end + def verify! + if path.exist? + path + else + raise "Hook search path #{path} does not exists" + end + end + private def set_default_path @@ -132,16 +143,16 @@ end end - class Hook attr_reader :name, :results, :files, :caller_path, :search_path def initialize name, caller_path, search_path - @name = name + search_path.verify! @search_path = search_path + @name = name @files = find_hook_files(name).map {|path| HookFile.new(path) } @caller_path = caller_path.split(':in').first - Builtins.y2milestone "Creating hook '#{self.name}' from '#{self.caller_path}'" + Builtins.y2milestone "Creating hook '#{name}' from '#{self.caller_path}'" end def execute diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.5/library/general/test/hooks_test.rb new/yast2-3.1.6/library/general/test/hooks_test.rb --- old/yast2-3.1.5/library/general/test/hooks_test.rb 2013-11-25 14:17:12.000000000 +0100 +++ new/yast2-3.1.6/library/general/test/hooks_test.rb 2013-11-28 13:57:35.000000000 +0100 @@ -18,49 +18,57 @@ end it "executes single hook specified by a name" do - hook = Hooks.run :before_hook + hook = Hooks.run 'before_hook' expect(hook).not_to be_nil - expect(Hooks.find(:before_hook)).not_to be_nil + expect(Hooks.last).not_to be_nil + expect(Hooks.last).to equal(hook) + expect(Hooks.find('before_hook')).not_to be_nil expect(Hooks.last.files.size).to eq(2) expect(hook.search_path.to_s).to eq(TEST_HOOK_SEARCH_PATH) expect(hook.search_path.reset).not_to eq(TEST_HOOK_SEARCH_PATH) end it "executes the same hook if running multiple times" do - hook_first = Hooks.run :test_hook - hook_second = Hooks.run :test_hook + hook_first = Hooks.run 'test_hook' + hook_second = Hooks.run 'test_hook' expect(hook_second).to be(hook_first) end it "allows to retrieve information about hooks" do - expect(Hooks.exists?(:before_hook)).to eq(false) - expect(Hooks.find(:before_hook)).to eq(nil) + expect(Hooks.exists?('before_hook')).to eq(false) + expect(Hooks.find('before_hook')).to eq(nil) expect(Hooks.all).to be_empty - hook = Hooks.run :before_hook + hook = Hooks.run 'before_hook' expect(hook).not_to be_nil expect(hook.failed?).to eq(true) expect(hook.succeeded?).to eq(false) expect(hook.files).not_to be_empty expect(hook.files.map(&:content)).not_to be_empty - expect(Hooks.exists?(:before_hook)).to eq(true) - expect(Hooks.find(:before_hook)).not_to eq(nil) + expect(Hooks.exists?('before_hook')).to eq(true) + expect(Hooks.find('before_hook')).not_to eq(nil) expect(Hooks.all).not_to be_empty expect(Hooks.all.size).to eq(1) - expect(Hooks.find(:before_hook).failed?).to eq(true) - expect(Hooks.find(:before_hook).succeeded?).to eq(false) + expect(Hooks.find('before_hook').failed?).to eq(true) + expect(Hooks.find('before_hook').succeeded?).to eq(false) end it "tracks the results of the run hook files" do - hook = Hooks.run :before_hook + hook = Hooks.run 'before_hook' expect(Hooks.last.results.size).to eq(2) - failed_hook_file = Hooks.find(:before_hook).results.first + failed_hook_file = Hooks.find('before_hook').results.first expect(failed_hook_file.exit).not_to eq(0) expect(failed_hook_file.stderr).to match(/failure/) - succeeded_hook_file = Hooks.find(:before_hook).results.last + succeeded_hook_file = Hooks.find('before_hook').results.last expect(succeeded_hook_file.exit).to eq(0) expect(succeeded_hook_file.stdout).to match(/success/) end + + it "raises exception if the search path for hooks does not exist" do + Hooks.search_path.set "no/way/this/path/exists" + expect { Hooks.run('fail_hard') }.to raise_error + expect { Hooks.search_path.verify! }.to raise_error + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.5/package/yast2.changes new/yast2-3.1.6/package/yast2.changes --- old/yast2-3.1.5/package/yast2.changes 2013-11-25 14:17:12.000000000 +0100 +++ new/yast2-3.1.6/package/yast2.changes 2013-11-28 13:57:36.000000000 +0100 @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Thu Nov 28 12:42:12 UTC 2013 - [email protected] + +- Add hook into installation workflow +- 3.1.6 + +------------------------------------------------------------------- Mon Nov 25 11:48:21 UTC 2013 - [email protected] - Make sure the system ruby is used (BNC#845897) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.5/package/yast2.spec new/yast2-3.1.6/package/yast2.spec --- old/yast2-3.1.5/package/yast2.spec 2013-11-25 14:17:12.000000000 +0100 +++ new/yast2-3.1.6/package/yast2.spec 2013-11-28 13:57:36.000000000 +0100 @@ -17,7 +17,7 @@ Name: yast2 -Version: 3.1.5 +Version: 3.1.6 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -163,6 +163,7 @@ mkdir -p "$RPM_BUILD_ROOT"%{yast_ydatadir} mkdir -p "$RPM_BUILD_ROOT"%{yast_yncludedir} mkdir -p "$RPM_BUILD_ROOT"%{yast_vardir} +mkdir -p "$RPM_BUILD_ROOT"%{yast_vardir}/hooks mkdir -p "$RPM_BUILD_ROOT"%{yast_schemadir}/control/rnc mkdir -p "$RPM_BUILD_ROOT"%{yast_schemadir}/autoyast/rnc mkdir -p "$RPM_BUILD_ROOT"/etc/YaST2 @@ -198,6 +199,7 @@ %dir %{yast_schemadir}/autoyast %dir %{yast_schemadir}/autoyast/rnc %dir %{_sysconfdir}/YaST2 +%dir %{yast_vardir}/hooks # yast2 @@ -215,6 +217,7 @@ %doc %dir %{yast_docdir} %doc %{yast_docdir}/COPYING %doc %{_mandir}/*/* +%doc %{yast_vardir}/hooks/README.md /sbin/* %{_sbindir}/* @@ -253,5 +256,6 @@ %doc %{yast_docdir}/types %doc %{yast_docdir}/wizard %doc %{yast_docdir}/xml +%doc %{yast_docdir}/general %changelog -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
