Hello community, here is the log from the commit of package yast2 for openSUSE:Factory checked in at 2013-11-25 16:04:29 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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-22 07:29:37.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.yast2.new/yast2.changes 2013-11-25 16:04:30.000000000 +0100 @@ -1,0 +2,9 @@ +Mon Nov 25 11:48:21 UTC 2013 - [email protected] + +- Make sure the system ruby is used (BNC#845897) + ( thanks to Marc Schütz <[email protected]>) +- Add hooks module (FATE#315992) (vmoravec) +- Fix rspec run on OS-12.3 +- 3.1.5 + +------------------------------------------------------------------- Old: ---- yast2-3.1.4.tar.bz2 New: ---- yast2-3.1.5.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2.spec ++++++ --- /var/tmp/diff_new_pack.y8XNRu/_old 2013-11-25 16:04:31.000000000 +0100 +++ /var/tmp/diff_new_pack.y8XNRu/_new 2013-11-25 16:04:31.000000000 +0100 @@ -17,7 +17,7 @@ Name: yast2 -Version: 3.1.4 +Version: 3.1.5 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build ++++++ yast2-3.1.4.tar.bz2 -> yast2-3.1.5.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.4/VERSION new/yast2-3.1.5/VERSION --- old/yast2-3.1.4/VERSION 2013-11-21 15:12:02.000000000 +0100 +++ new/yast2-3.1.5/VERSION 2013-11-25 14:17:12.000000000 +0100 @@ -1 +1 @@ -3.1.4 +3.1.5 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.4/library/control/src/Makefile.am new/yast2-3.1.5/library/control/src/Makefile.am --- old/yast2-3.1.4/library/control/src/Makefile.am 2013-11-21 15:12:02.000000000 +0100 +++ new/yast2-3.1.5/library/control/src/Makefile.am 2013-11-25 14:17:12.000000000 +0100 @@ -5,7 +5,7 @@ modules/InstExtensionImage.rb \ modules/AutoinstData.rb \ modules/GetInstArgs.rb \ - modules/Hooks.rb \ + modules/DebugHooks.rb \ modules/InstError.rb \ modules/ProductControl.rb \ modules/ProductFeatures.rb \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.4/library/control/src/modules/DebugHooks.rb new/yast2-3.1.5/library/control/src/modules/DebugHooks.rb --- old/yast2-3.1.4/library/control/src/modules/DebugHooks.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-3.1.5/library/control/src/modules/DebugHooks.rb 2013-11-25 14:17:12.000000000 +0100 @@ -0,0 +1,167 @@ +# encoding: utf-8 + +# *************************************************************************** +# +# Copyright (c) 2002 - 2012 Novell, Inc. +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact Novell, Inc. +# +# To contact Novell about this file by physical or electronic mail, +# you may find current contact information at www.novell.com +# +# *************************************************************************** +# File: modules/DebugHooks.rb +# Package: yast2 +# Summary: Provide debug hooks during installation +# Authors: Klaus Kaempf <[email protected]> +# +# $Id$ +require "yast" + +module Yast + class DebugHooksClass < Module + def main + + Yast.import "Popup" + Yast.import "Directory" + + @tmp_dir = Convert.to_string(WFM.Read(path(".local.tmpdir"), [])) + @log_dir = Directory.logdir + + # script types, ycp does not make sense, it can be added directly + # to the workflow. + @supported_types = ["sh", "pl"] + end + + # called whenever an inst_*.ycp file is called during + # installation. + # checks if /tmp/<filename> exists and pops up a "Entry: <filename>" + # or "Exit: <filename>" box + # + # @param [String] filename == name of .ycp file + # @param [Boolean] at_entry == true before call of file == false after call of file + # @return [void] + + def Checkpoint(filename, at_entry) + if Ops.greater_or_equal( + WFM.Read(path(".local.size"), Ops.add("/tmp/", filename)), + 0 + ) + if at_entry + Popup.Message(Builtins.sformat("Entry: %1", filename)) + else + Popup.Message(Builtins.sformat("Exit: %1", filename)) + end + end + nil + end + + + # Execute Script + # @param [String] script name + # @param [String] type + def ExecuteScript(script, type) + Builtins.y2milestone("Executing script: %1", script) + # string message = sformat(_("Executing user supplied script: %1"), scriptName); + executionString = "" + scriptPath = Builtins.sformat("%1/%2", @tmp_dir, script) + if type == "shell" + executionString = Builtins.sformat( + "/bin/sh -x %1 2&> %2/%3.log", + scriptPath, + @log_dir, + script + ) + WFM.Execute(path(".local.bash"), executionString) + elsif type == "perl" + executionString = Builtins.sformat( + "/usr/bin/perl %1 2&> %2/%3.log", + scriptPath, + @log_dir, + script + ) + WFM.Execute(path(".local.bash"), executionString) + else + Builtins.y2error("Unknown interpreter: %1", type) + end + Builtins.y2milestone("Script Execution command: %1", executionString) + + nil + end + + # Run Script + # @param [String] filename == name of .ycp file + # @param [Boolean] at_entry == true before call of file == false after call of file + def Run(filename, at_entry) + Builtins.y2debug("Running debug hook: %1", filename) + # do not run scripts twice + if at_entry + if Ops.greater_than( + WFM.Read( + path(".local.size"), + Builtins.sformat("%1/%2_pre.sh", @tmp_dir, filename) + ), + 0 + ) + ExecuteScript(Builtins.sformat("%1_pre.sh", filename), "shell") + elsif Ops.greater_than( + WFM.Read( + path(".local.size"), + Builtins.sformat("%1/%2_pre.pl", @tmp_dir, filename) + ), + 0 + ) + ExecuteScript(Builtins.sformat("%1_pre.pl", filename), "perl") + else + Builtins.y2debug( + "Debug hook not found: %1/%2_pre.{sh,pl}", + @tmp_dir, + filename + ) + end + else + if Ops.greater_than( + WFM.Read( + path(".local.size"), + Builtins.sformat("%1/%2_post.sh", @tmp_dir, filename) + ), + 0 + ) + ExecuteScript(Builtins.sformat("%1_post.sh", filename), "shell") + elsif Ops.greater_than( + WFM.Read( + path(".local.size"), + Builtins.sformat("%1/%2_post.pl", @tmp_dir, filename) + ), + 0 + ) + ExecuteScript(Builtins.sformat("%1_post.pl", filename), "perl") + else + Builtins.y2debug( + "Debug hook not found: %1/%2_post.{sh,pl}", + @tmp_dir, + filename + ) + end + end + nil + end + + publish :function => :Checkpoint, :type => "void (string, boolean)" + publish :function => :Run, :type => "void (string, boolean)" + end + + DebugHooks = DebugHooksClass.new + DebugHooks.main +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.4/library/control/src/modules/Hooks.rb new/yast2-3.1.5/library/control/src/modules/Hooks.rb --- old/yast2-3.1.4/library/control/src/modules/Hooks.rb 2013-11-21 15:12:02.000000000 +0100 +++ new/yast2-3.1.5/library/control/src/modules/Hooks.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,167 +0,0 @@ -# encoding: utf-8 - -# *************************************************************************** -# -# Copyright (c) 2002 - 2012 Novell, Inc. -# All Rights Reserved. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of version 2 of the GNU General Public License as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, contact Novell, Inc. -# -# To contact Novell about this file by physical or electronic mail, -# you may find current contact information at www.novell.com -# -# *************************************************************************** -# File: modules/Hooks.ycp -# Package: yast2 -# Summary: Provide debug hooks during installation -# Authors: Klaus Kaempf <[email protected]> -# -# $Id$ -require "yast" - -module Yast - class HooksClass < Module - def main - - Yast.import "Popup" - Yast.import "Directory" - - @tmp_dir = Convert.to_string(WFM.Read(path(".local.tmpdir"), [])) - @log_dir = Directory.logdir - - # script types, ycp does not make sense, it can be added directly - # to the workflow. - @supported_types = ["sh", "pl"] - end - - # called whenever an inst_*.ycp file is called during - # installation. - # checks if /tmp/<filename> exists and pops up a "Entry: <filename>" - # or "Exit: <filename>" box - # - # @param [String] filename == name of .ycp file - # @param [Boolean] at_entry == true before call of file == false after call of file - # @return [void] - - def Checkpoint(filename, at_entry) - if Ops.greater_or_equal( - WFM.Read(path(".local.size"), Ops.add("/tmp/", filename)), - 0 - ) - if at_entry - Popup.Message(Builtins.sformat("Entry: %1", filename)) - else - Popup.Message(Builtins.sformat("Exit: %1", filename)) - end - end - nil - end - - - # Execute Script - # @param [String] script name - # @param [String] type - def ExecuteScript(script, type) - Builtins.y2milestone("Executing script: %1", script) - # string message = sformat(_("Executing user supplied script: %1"), scriptName); - executionString = "" - scriptPath = Builtins.sformat("%1/%2", @tmp_dir, script) - if type == "shell" - executionString = Builtins.sformat( - "/bin/sh -x %1 2&> %2/%3.log", - scriptPath, - @log_dir, - script - ) - WFM.Execute(path(".local.bash"), executionString) - elsif type == "perl" - executionString = Builtins.sformat( - "/usr/bin/perl %1 2&> %2/%3.log", - scriptPath, - @log_dir, - script - ) - WFM.Execute(path(".local.bash"), executionString) - else - Builtins.y2error("Unknown interpreter: %1", type) - end - Builtins.y2milestone("Script Execution command: %1", executionString) - - nil - end - - # Run Script - # @param [String] filename == name of .ycp file - # @param [Boolean] at_entry == true before call of file == false after call of file - def Run(filename, at_entry) - Builtins.y2debug("Running Hook: %1", filename) - # do not run scripts twice - if at_entry - if Ops.greater_than( - WFM.Read( - path(".local.size"), - Builtins.sformat("%1/%2_pre.sh", @tmp_dir, filename) - ), - 0 - ) - ExecuteScript(Builtins.sformat("%1_pre.sh", filename), "shell") - elsif Ops.greater_than( - WFM.Read( - path(".local.size"), - Builtins.sformat("%1/%2_pre.pl", @tmp_dir, filename) - ), - 0 - ) - ExecuteScript(Builtins.sformat("%1_pre.pl", filename), "perl") - else - Builtins.y2debug( - "Hook not found: %1/%2_pre.{sh,pl}", - @tmp_dir, - filename - ) - end - else - if Ops.greater_than( - WFM.Read( - path(".local.size"), - Builtins.sformat("%1/%2_post.sh", @tmp_dir, filename) - ), - 0 - ) - ExecuteScript(Builtins.sformat("%1_post.sh", filename), "shell") - elsif Ops.greater_than( - WFM.Read( - path(".local.size"), - Builtins.sformat("%1/%2_post.pl", @tmp_dir, filename) - ), - 0 - ) - ExecuteScript(Builtins.sformat("%1_post.pl", filename), "perl") - else - Builtins.y2debug( - "Hook not found: %1/%2_post.{sh,pl}", - @tmp_dir, - filename - ) - end - end - nil - end - - publish :function => :Checkpoint, :type => "void (string, boolean)" - publish :function => :Run, :type => "void (string, boolean)" - end - - Hooks = HooksClass.new - Hooks.main -end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.4/library/control/src/modules/ProductControl.rb new/yast2-3.1.5/library/control/src/modules/ProductControl.rb --- old/yast2-3.1.4/library/control/src/modules/ProductControl.rb 2013-11-21 15:12:02.000000000 +0100 +++ new/yast2-3.1.5/library/control/src/modules/ProductControl.rb 2013-11-25 14:17:12.000000000 +0100 @@ -46,7 +46,7 @@ Yast.import "Label" Yast.import "Wizard" Yast.import "Report" - Yast.import "Hooks" + Yast.import "DebugHooks" Yast.import "Popup" Yast.import "FileUtils" Yast.import "Installation" @@ -275,7 +275,7 @@ Ops.get_string(mod, "proposal", "") ) return true - end + end # Normal step elsif Ops.get_string(mod, "name", "") != nil && Ops.get_string(mod, "name", "") != "" @@ -397,7 +397,7 @@ # Defined custom control file if @custom_control_file != "" - return name + return name # All standard clients start with "inst_" else @@ -678,7 +678,7 @@ # modules if Ops.get_string(one_module, "name", "") != nil && Ops.get_string(one_module, "name", "") != "" - next true + next true # proposals elsif Ops.get_string(one_module, "proposal", "") != nil && Ops.get_string(one_module, "proposal", "") != "" @@ -796,7 +796,7 @@ Builtins.y2milestone("Enabling proposal: %1", m) @DisabledProposals = Builtins.filter(@DisabledProposals) do |one_proposal| Ops.get_string(m, "proposal", "") != one_proposal - end + end # A module # Enable it only if it was enabled before elsif Ops.get_string(m, "name", "") != nil && @@ -898,7 +898,7 @@ Builtins.dgettext( wizard_textdomain, Ops.get_string(m, "label", "") - ) + ) # Label elsif Ops.get_string(m, "label", "") != "" @@ -916,7 +916,7 @@ id = Ops.get_string(m, "id", "") last_label = Ops.get_string(m, "label", "") - last_domain = Ops.get_string(m, "textdomain", "") + last_domain = Ops.get_string(m, "textdomain", "") # The rest else @@ -1370,8 +1370,8 @@ Builtins.y2milestone("Calling %1", argterm) if !wasRun(step_name) - Hooks.Checkpoint(Builtins.sformat("%1", module_name), true) - Hooks.Run(step_name, true) + DebugHooks.Checkpoint(Builtins.sformat("%1", module_name), true) + DebugHooks.Run(step_name, true) end args = [] @@ -1422,18 +1422,18 @@ end end - # Dont call hook scripts after installation is done. (#36831) + # Dont call debug hook scripts after installation is done. (#36831) if Ops.less_than(@current_step, Ops.subtract(Builtins.size(modules), 1)) && !wasRun(step_name) - Hooks.Run(step_name, false) + DebugHooks.Run(step_name, false) else Builtins.y2milestone( - "Not running hooks at the end of the installation" + "Not running debug hooks at the end of the installation" ) end # This should be safe (#36831) - Hooks.Checkpoint(step_name, false) # exit hook + DebugHooks.Checkpoint(step_name, false) # exit hook addToStack(step_name) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.4/library/general/src/modules/Hooks.rb new/yast2-3.1.5/library/general/src/modules/Hooks.rb --- old/yast2-3.1.4/library/general/src/modules/Hooks.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-3.1.5/library/general/src/modules/Hooks.rb 2013-11-25 14:17:12.000000000 +0100 @@ -0,0 +1,207 @@ +require 'pathname' +require 'ostruct' + +## Description +# +# Main goal of hooks is to execute a third party code within the workflow of +# installation, system update or some other process. Hook files must be executable +# files written in bash, ruby or anything else available in inst-sys environment. +# +# The module provides method #run which creates a hook and executes it instantly. +# +# This includes following actions: +# * adding the hook into the hooks collection - every hook is identified by unique +# name which should be self-descriptive +# * looking up the files matching the hook script pattern: hook_name_[0-9][0-9]_* +# * executing the identified hook files +# * storing the results returned by the scripts for further inspection later if needed; +# this might be useful if some of the files has failed and we want to show it the user. +# +# If a hook script returns non-zero result, the whole hook is considered as failed. +# By default the hooks are searched for in /var/lib/YaST2/hooks directory. This path +# can be modified globally for all hooks before they get called. +# +## Example +# +# * using a hook within a yast client +# +# module Yast +# import 'Hooks' +# +# class MyFavoriteClient < Client +# def main +# # this will change the search path to /var/lib/YaST2/hooks/personal +# 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 +# # Lot of beautiful and useful code follows here. +# # If needed make use of: +# # * hook.failed? +# # * hook.succeeded? +# # * hook.name +# # * hook.results +# # * hook.files +# # * hook.search_path +# # * Hooks.last.failed? +# # * Hooks.last.succeeded? +# # * Hooks.last.name +# # * Hooks.last.search_path +# # * Hooks.last.results +# # * Hooks.last.files +# Hooks.run :after_showing_ui +# # reset the search path if needed +# Hooks.search_path.reset +# end +# end +# end + +module Yast + class HooksClass < Module + + attr_reader :hooks, :last, :search_path + + def initialize + textdomain 'base' + @hooks = {} + @search_path = SearchPath.new + end + + def run hook_name + hook = create(hook_name, caller.first) + hook.execute + @last = hook + end + + def find hook_name + hooks[hook_name] + end + + def all + hooks + end + + def exists? hook_name + !!find(hook_name) + end + + private + + def create hook_name, source_file + if hooks[hook_name] + Builtins.y2warning "Hook '#{hook_name}' has already been run from #{hooks[hook_name].caller_path}" + hooks[hook_name] + else + hooks[hook_name] = Hook.new(hook_name, source_file, search_path) + end + end + + class SearchPath + DEFAULT_DIR = '/var/lib/YaST2/hooks' + + attr_reader :path + + def initialize + set_default_path + end + + def join! new_path + @path = path.join(new_path) + end + + def reset + set_default_path + end + + def set new_path + @path = Pathname.new(new_path) + end + + def children + path.children + end + + def to_s + path.to_s + end + + private + + def set_default_path + @path = Pathname.new(DEFAULT_DIR) + end + end + + + class Hook + attr_reader :name, :results, :files, :caller_path, :search_path + + def initialize name, caller_path, search_path + @name = name + @search_path = search_path + @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}'" + end + + def execute + Builtins.y2milestone "Executing hook '#{name}'" + files.each &:execute + end + + def results + files.map &:result + end + + def succeeded? + files.all? &:succeeded? + end + + def failed? + !succeeded? + end + + private + + def find_hook_files hook_name + Builtins.y2milestone "Searching for hook files in '#{search_path}'..." + hook_files = search_path.children.select do |file| + file.basename.fnmatch?("#{hook_name}_[0-9][0-9]_*") + end + Builtins.y2milestone "Found #{hook_files.size} hook files: " + + "#{hook_files.map {|f| f.basename.to_s}.join(', ')}" + hook_files.sort + end + end + + class HookFile + attr_reader :path, :content, :result + + def initialize path + @path = path + end + + def execute + Builtins.y2milestone "Executing hook file '#{path}'" + @result = OpenStruct.new(SCR.Execute(Path.new(".target.bash_output"), path.to_s)) + if failed? + Builtins.y2error "Hook file '#{path.basename}' failed with stderr: #{result.stderr}" + end + result + end + + def content + @content ||= ::File.read(path) + end + + def succeeded? + result.exit.zero? + end + + def failed? + !succeeded? + end + end + end + Hooks = HooksClass.new +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.4/library/general/test/hooks/before_hook_00_failed new/yast2-3.1.5/library/general/test/hooks/before_hook_00_failed --- old/yast2-3.1.4/library/general/test/hooks/before_hook_00_failed 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-3.1.5/library/general/test/hooks/before_hook_00_failed 2013-11-25 14:17:12.000000000 +0100 @@ -0,0 +1,3 @@ +#! /usr/bin/env bash +echo "failure" >&2 +exit 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.4/library/general/test/hooks/before_hook_01_success new/yast2-3.1.5/library/general/test/hooks/before_hook_01_success --- old/yast2-3.1.4/library/general/test/hooks/before_hook_01_success 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-3.1.5/library/general/test/hooks/before_hook_01_success 2013-11-25 14:17:12.000000000 +0100 @@ -0,0 +1,2 @@ +#! /usr/bin/env ruby +puts "success" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.4/library/general/test/hooks_test.rb new/yast2-3.1.5/library/general/test/hooks_test.rb --- old/yast2-3.1.4/library/general/test/hooks_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-3.1.5/library/general/test/hooks_test.rb 2013-11-25 14:17:12.000000000 +0100 @@ -0,0 +1,66 @@ +#! /usr/bin/env rspec + +ENV["Y2DIR"] = File.expand_path("../../src", __FILE__) + +require "yast" + +module Yast + import 'Hooks' + + # test hook files are located in test/hooks directory + + TEST_HOOK_SEARCH_PATH = File.join(__dir__, 'hooks') + + describe Hooks do + before do + Hooks.all.clear + Hooks.search_path.set(TEST_HOOK_SEARCH_PATH) + end + + it "executes single hook specified by a name" do + hook = Hooks.run :before_hook + expect(hook).not_to be_nil + 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 + 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.all).to be_empty + + 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.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) + end + + it "tracks the results of the run hook files" do + hook = Hooks.run :before_hook + expect(Hooks.last.results.size).to eq(2) + 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 + expect(succeeded_hook_file.exit).to eq(0) + expect(succeeded_hook_file.stdout).to match(/success/) + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.4/library/types/src/modules/IP.rb new/yast2-3.1.5/library/types/src/modules/IP.rb --- old/yast2-3.1.4/library/types/src/modules/IP.rb 2013-11-21 15:12:02.000000000 +0100 +++ new/yast2-3.1.5/library/types/src/modules/IP.rb 2013-11-25 14:17:12.000000000 +0100 @@ -374,6 +374,54 @@ CheckNetwork4(network) || CheckNetwork6(network) end + # Checks if given IPv4 address is reserved by any related RFC. + # + # RFCs covered by this method are #1700, #1918, #2544, #3068, #5735, #5737, + # 5771, #6333 and #6598 + # + # @param[String] ip IPv4 address + # @return[true,false] if address is reserved + # + # @raise [RuntimeError] if ip address is invalid + def reserved4(ip) + if !Check4(ip) + raise "Invalid IP address passed '#{ip}'" + end + + # RFC#1700 + return true if ip.start_with?("0.") + + # RFC#6598 + return true if private_carrier_grade_nat?(ip) + + # RFC#5735 + return true if ip.start_with?("127.") + return true if ip.start_with?("169.254") + + # RFC#1918 + return true if private_network?(ip) + + # RFC#6333 + return true if ds_lite_address?(ip) + + # RFC#5737 + return true if ip.start_with?("192.0.2.") + return true if ip.start_with?("198.51.100.") + return true if ip.start_with?("203.0.113.") + + # RFC#3068 + return true if ip.start_with?("192.88.99.") + + # RFC#2544 + return true if ip.start_with?("192.18.") + return true if ip.start_with?("192.19.") + + # all from 224. is covered by RFC#5771 and RFC#5735 + return true if (224..255).include?(ip.split(".").first.to_i) + + return false + end + publish :variable => :ValidChars, :type => "string" publish :variable => :ValidChars4, :type => "string" publish :variable => :ValidChars6, :type => "string" @@ -394,6 +442,38 @@ publish :function => :CheckNetwork4, :type => "boolean (string)" publish :function => :CheckNetwork6, :type => "boolean (string)" publish :function => :CheckNetwork, :type => "boolean (string)" + publish :function => :reserved4, :type => "boolean (string)" + + + private + + def private_carrier_grade_nat?(ip) + return false unless ip.start_with?("100.") + + second_part = ip.split(".")[1].to_i + return (64..127).include?(second_part) + end + + def private_network?(ip) + # 10.0.0.0/8 + return true if ip.start_with?("10.") + + # 192.168.0.0/8 + return true if ip.start_with?("192.168.") + + # 172.16.0.0/12 + return false unless ip.start_with?("172.") + + second_part = ip.split(".")[1].to_i + return (16..31).include?(second_part) + end + + def ds_lite_address?(ip) + return false unless ip.start_with?("192.0.0.") + + fourth_part = ip.split(".")[3].to_i + return (0..7).include?(fourth_part) + end end IP = IPClass.new diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.4/library/types/test/ip_test.rb new/yast2-3.1.5/library/types/test/ip_test.rb --- old/yast2-3.1.4/library/types/test/ip_test.rb 2013-11-21 15:12:02.000000000 +0100 +++ new/yast2-3.1.5/library/types/test/ip_test.rb 2013-11-25 14:17:12.000000000 +0100 @@ -190,4 +190,115 @@ expect( IP.BitsToIPv4("foobar")).to be_equal nil end end + + describe "#reserved4" do + + it "raises exception for invalid IPv4 address" do + expect{IP.reserved4(nil)}.to raise_error(RuntimeError) + expect{IP.reserved4("0.0.0")}.to raise_error(RuntimeError) + end + + it "returns true for address in 0.0.0.0/8 (RFC#1700)" do + expect(IP.reserved4("0.0.0.0")).to be_equal true + expect(IP.reserved4("0.1.0.0")).to be_equal true + expect(IP.reserved4("0.0.1.0")).to be_equal true + expect(IP.reserved4("0.0.0.1")).to be_equal true + expect(IP.reserved4("0.255.255.255")).to be_equal true + end + + it "returns true for address in 10.0.0.0/8 (RFC#1918)" do + expect(IP.reserved4("10.0.0.0")).to be_equal true + expect(IP.reserved4("10.1.0.0")).to be_equal true + expect(IP.reserved4("10.0.1.0")).to be_equal true + expect(IP.reserved4("10.0.0.1")).to be_equal true + expect(IP.reserved4("10.255.255.255")).to be_equal true + end + + it "returns true for address in 172.16.0.0/12 (RFC#1918)" do + expect(IP.reserved4("172.16.0.0")).to be_equal true + expect(IP.reserved4("172.25.152.153")).to be_equal true + expect(IP.reserved4("172.31.255.255")).to be_equal true + end + + it "returns true for address in 192.168.0.0/16 (RFC#1918)" do + expect(IP.reserved4("192.168.0.0")).to be_equal true + expect(IP.reserved4("192.168.152.153")).to be_equal true + expect(IP.reserved4("192.168.255.255")).to be_equal true + end + + it "returns true for address in 100.64.0.0/10 (RFC#6598)" do + expect(IP.reserved4("100.64.0.0")).to be_equal true + expect(IP.reserved4("100.100.0.0")).to be_equal true + expect(IP.reserved4("100.111.111.111")).to be_equal true + expect(IP.reserved4("100.127.255.255")).to be_equal true + end + + it "returns true for address in 127.0.0.0/8 (RFC#5735)" do + expect(IP.reserved4("127.168.0.0")).to be_equal true + expect(IP.reserved4("127.100.0.0")).to be_equal true + expect(IP.reserved4("127.111.111.111")).to be_equal true + expect(IP.reserved4("127.255.255.255")).to be_equal true + end + + it "returns true for address in 169.254.0.0/16 (RFC#5735)" do + expect(IP.reserved4("169.254.0.0")).to be_equal true + expect(IP.reserved4("169.254.0.0")).to be_equal true + expect(IP.reserved4("169.254.111.111")).to be_equal true + expect(IP.reserved4("169.254.255.255")).to be_equal true + end + + it "returns true for address in 192.0.0.0/29 (RFC#6333)" do + expect(IP.reserved4("192.0.0.0")).to be_equal true + expect(IP.reserved4("192.0.0.4")).to be_equal true + expect(IP.reserved4("192.0.0.7")).to be_equal true + end + + it "returns true for address in 192.0.2.0/24 (RFC#5737)" do + expect(IP.reserved4("192.0.2.0")).to be_equal true + expect(IP.reserved4("192.0.2.124")).to be_equal true + expect(IP.reserved4("192.0.2.255")).to be_equal true + end + + it "returns true for address in 192.88.99.0/24 (RFC#3068)" do + expect(IP.reserved4("192.88.99.0")).to be_equal true + expect(IP.reserved4("192.88.99.124")).to be_equal true + expect(IP.reserved4("192.88.99.255")).to be_equal true + end + + it "returns true for address in 192.18.0.0/15 (RFC#2544)" do + expect(IP.reserved4("192.18.0.0")).to be_equal true + expect(IP.reserved4("192.19.0.0")).to be_equal true + expect(IP.reserved4("192.19.255.255")).to be_equal true + end + + it "returns true for address in 198.51.100.0/24 (RFC#5737)" do + expect(IP.reserved4("198.51.100.0")).to be_equal true + expect(IP.reserved4("198.51.100.124")).to be_equal true + expect(IP.reserved4("198.51.100.255")).to be_equal true + end + + it "returns true for address in 203.0.113.0/24 (RFC#5737)" do + expect(IP.reserved4("203.0.113.0")).to be_equal true + expect(IP.reserved4("203.0.113.124")).to be_equal true + expect(IP.reserved4("203.0.113.255")).to be_equal true + end + + it "returns true for address in 224.0.0.0/4 (RFC#5771)" do + expect(IP.reserved4("224.0.0.0")).to be_equal true + expect(IP.reserved4("230.0.113.124")).to be_equal true + expect(IP.reserved4("239.255.255.255")).to be_equal true + end + + it "returns true for address in 240.0.0.0/4 (RFC#5735)" do + expect(IP.reserved4("240.0.0.0")).to be_equal true + expect(IP.reserved4("250.0.113.124")).to be_equal true + expect(IP.reserved4("255.255.255.255")).to be_equal true + end + + it "returns false for address not reserved by any RFC" do + expect(IP.reserved4("8.8.8.8")).to be_equal false + expect(IP.reserved4("77.75.76.3")).to be_equal false + expect(IP.reserved4("130.57.5.70")).to be_equal false + end + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.4/package/yast2.changes new/yast2-3.1.5/package/yast2.changes --- old/yast2-3.1.4/package/yast2.changes 2013-11-21 15:12:02.000000000 +0100 +++ new/yast2-3.1.5/package/yast2.changes 2013-11-25 14:17:12.000000000 +0100 @@ -1,4 +1,13 @@ ------------------------------------------------------------------- +Mon Nov 25 11:48:21 UTC 2013 - [email protected] + +- Make sure the system ruby is used (BNC#845897) + ( thanks to Marc Schütz <[email protected]>) +- Add hooks module (FATE#315992) (vmoravec) +- Fix rspec run on OS-12.3 +- 3.1.5 + +------------------------------------------------------------------- Thu Nov 21 08:48:50 UTC 2013 - [email protected] - PKGMGR_ACTION_AT_EXIT: change the default action to "summary", @@ -14,12 +23,12 @@ ------------------------------------------------------------------- Fri Nov 15 16:23:46 CET 2013 - [email protected] -- Warn the user if Chef could overwrite her changes (bnc#803358). +- Warn the user if Chef could overwrite her changes (bnc#803358). ------------------------------------------------------------------- Fri Nov 15 13:59:06 UTC 2013 - [email protected] -- Removed unused API from NetworkInterfaces +- Removed unused API from NetworkInterfaces ------------------------------------------------------------------- Wed Nov 13 17:08:09 CET 2013 - [email protected] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.4/package/yast2.spec new/yast2-3.1.5/package/yast2.spec --- old/yast2-3.1.4/package/yast2.spec 2013-11-21 15:12:02.000000000 +0100 +++ new/yast2-3.1.5/package/yast2.spec 2013-11-25 14:17:12.000000000 +0100 @@ -17,7 +17,7 @@ Name: yast2 -Version: 3.1.4 +Version: 3.1.5 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-3.1.4/scripts/yast2 new/yast2-3.1.5/scripts/yast2 --- old/yast2-3.1.4/scripts/yast2 2013-11-21 15:12:02.000000000 +0100 +++ new/yast2-3.1.5/scripts/yast2 2013-11-25 14:17:12.000000000 +0100 @@ -15,6 +15,9 @@ export PATH=/sbin:/usr/sbin:$PATH +# make sure the system ruby is used, bnc#845897 +unset GEM_HOME GEM_PATH RUBYLIB RUBYPATH RUBYOPT + # we need input methods for many locales bnc#776567 export QT_IM_MODULE=xim GTK_IM_MODULE=xim -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
