Hello community,

here is the log from the commit of package autoyast2 for openSUSE:Factory 
checked in at 2015-09-13 09:44:16
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/autoyast2 (Old)
 and      /work/SRC/openSUSE:Factory/.autoyast2.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "autoyast2"

Changes:
--------
--- /work/SRC/openSUSE:Factory/autoyast2/autoyast2.changes      2015-08-29 
20:03:08.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.autoyast2.new/autoyast2.changes 2015-09-13 
09:44:17.000000000 +0200
@@ -1,0 +2,17 @@
+Mon Sep  7 22:32:50 UTC 2015 - [email protected]
+
+- Fix premature loading of AutoInstall which prevented running
+  configuration clients during 2nd stage (bsc#944770)
+- 3.1.93
+
+-------------------------------------------------------------------
+Tue Sep  1 15:25:44 UTC 2015 - [email protected]
+
+- Move users creation to the first stage, so it is not needed
+  to run the 2nd stage to have a minimal system.
+- Do no add AutoYaST packages if the second stage won't be
+  executed.
+- Fixes bnc#892091
+- 3.1.92
+
+-------------------------------------------------------------------

Old:
----
  autoyast2-3.1.91.tar.bz2

New:
----
  autoyast2-3.1.93.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ autoyast2.spec ++++++
--- /var/tmp/diff_new_pack.N80NRA/_old  2015-09-13 09:44:18.000000000 +0200
+++ /var/tmp/diff_new_pack.N80NRA/_new  2015-09-13 09:44:18.000000000 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           autoyast2
-Version:        3.1.91
+Version:        3.1.93
 Release:        0
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
@@ -57,6 +57,7 @@
 Requires:       yast2-storage >= 3.1.59
 Requires:       yast2-transfer >= 2.21.0
 Requires:       yast2-xml
+Conflicts:      yast2-installation < 3.1.158
 
 Provides:       yast2-config-autoinst
 Provides:       yast2-module-autoinst
@@ -204,6 +205,8 @@
 %{yast_moduledir}/Kickstart.rb
 %dir %{yast_agentdir}
 %{yast_agentdir}/ag_ksimport
+%dir %{yast_libdir}/autoinstall
+%{yast_libdir}/autoinstall/*.rb
 
 # additional files
 
@@ -263,6 +266,7 @@
 %{yast_moduledir}/AutoinstDrive.rb
 %{yast_moduledir}/AutoinstPartPlan.rb
 %{yast_moduledir}/AutoinstPartition.rb
+%{yast_moduledir}/AutoinstFunctions.rb
 
 #clients
 %{yast_clientdir}/inst_autoinit.rb

++++++ autoyast2-3.1.91.tar.bz2 -> autoyast2-3.1.93.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autoyast2-3.1.91/.travis.yml 
new/autoyast2-3.1.93/.travis.yml
--- old/autoyast2-3.1.91/.travis.yml    2015-08-26 14:00:12.000000000 +0200
+++ new/autoyast2-3.1.93/.travis.yml    2015-09-09 07:24:10.000000000 +0200
@@ -5,10 +5,11 @@
     # disable rvm, use system Ruby
     - rvm reset
     - wget 
https://raw.githubusercontent.com/yast/yast-devtools/master/travis-tools/travis_setup.sh
-    - sh ./travis_setup.sh -p "rake yast2-devtools yast2-testsuite yast2 
yast2-storage yast2-xml yast2-transfer yast2-services-manager 
yast2-installation-control yast2-packager trang" -g "rspec:3.3.0 yast-rake 
gettext"
+    - sh ./travis_setup.sh -p "rake yast2-devtools yast2-testsuite yast2 
yast2-storage yast2-xml yast2-transfer yast2-services-manager 
yast2-installation yast2-installation-control yast2-packager trang" -g 
"rspec:3.3.0 yast-rake gettext"
 script:
     - rake check:syntax
     - rake check:pot
+    - rake test:unit
     - make -f Makefile.cvs
     - make
     - sudo make install
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autoyast2-3.1.91/package/autoyast2.changes 
new/autoyast2-3.1.93/package/autoyast2.changes
--- old/autoyast2-3.1.91/package/autoyast2.changes      2015-08-26 
14:00:12.000000000 +0200
+++ new/autoyast2-3.1.93/package/autoyast2.changes      2015-09-09 
07:24:10.000000000 +0200
@@ -1,4 +1,21 @@
 -------------------------------------------------------------------
+Mon Sep  7 22:32:50 UTC 2015 - [email protected]
+
+- Fix premature loading of AutoInstall which prevented running
+  configuration clients during 2nd stage (bsc#944770)
+- 3.1.93
+
+-------------------------------------------------------------------
+Tue Sep  1 15:25:44 UTC 2015 - [email protected]
+
+- Move users creation to the first stage, so it is not needed
+  to run the 2nd stage to have a minimal system.
+- Do no add AutoYaST packages if the second stage won't be
+  executed.
+- Fixes bnc#892091
+- 3.1.92
+
+-------------------------------------------------------------------
 Tue Aug 25 14:49:13 CEST 2015 - [email protected]
 
 - Do not restart dbus service after installation. Otherwise some
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autoyast2-3.1.91/package/autoyast2.spec 
new/autoyast2-3.1.93/package/autoyast2.spec
--- old/autoyast2-3.1.91/package/autoyast2.spec 2015-08-26 14:00:12.000000000 
+0200
+++ new/autoyast2-3.1.93/package/autoyast2.spec 2015-09-09 07:24:10.000000000 
+0200
@@ -17,7 +17,7 @@
 
 
 Name:           autoyast2
-Version:        3.1.91
+Version:        3.1.93
 Release:        0
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
@@ -57,6 +57,7 @@
 Requires:       yast2-storage >= 3.1.59
 Requires:       yast2-transfer >= 2.21.0
 Requires:       yast2-xml
+Conflicts:      yast2-installation < 3.1.158
 
 Provides:       yast2-config-autoinst
 Provides:       yast2-module-autoinst
@@ -204,6 +205,8 @@
 %{yast_moduledir}/Kickstart.rb
 %dir %{yast_agentdir}
 %{yast_agentdir}/ag_ksimport
+%dir %{yast_libdir}/autoinstall
+%{yast_libdir}/autoinstall/*.rb
 
 # additional files
 
@@ -263,6 +266,7 @@
 %{yast_moduledir}/AutoinstDrive.rb
 %{yast_moduledir}/AutoinstPartPlan.rb
 %{yast_moduledir}/AutoinstPartition.rb
+%{yast_moduledir}/AutoinstFunctions.rb
 
 #clients
 %{yast_clientdir}/inst_autoinit.rb
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autoyast2-3.1.91/src/Makefile.am 
new/autoyast2-3.1.93/src/Makefile.am
--- old/autoyast2-3.1.91/src/Makefile.am        2015-08-26 14:00:12.000000000 
+0200
+++ new/autoyast2-3.1.93/src/Makefile.am        2015-09-09 07:24:10.000000000 
+0200
@@ -21,7 +21,8 @@
   modules/AutoinstGeneral.rb \
   modules/AutoinstSoftware.rb \
   modules/AutoinstDrive.rb \
-  modules/AutoinstClass.rb
+  modules/AutoinstClass.rb \
+  modules/AutoinstFunctions.rb
 
 client_DATA = \
   clients/classes_auto.rb \
@@ -70,6 +71,10 @@
   include/autoinstall/helps.rb \
   include/autoinstall/general_dialogs.rb
 
+ylibdir = @ylibdir@/autoinstall
+ylib_DATA = \
+  lib/autoinstall/module_config_builder.rb
+
 scrconf_DATA = \
   scrconf/cfg_autoinstall.scr \
   scrconf/autoinstall.scr \
@@ -103,6 +108,6 @@
 fillup_DATA = \
   fillup/sysconfig.autoinstall
 
-EXTRA_DIST = $(module_DATA) $(client_DATA) $(ynclude_DATA) $(scrconf_DATA) 
$(agent_SCRIPTS) $(schemafiles_DATA) $(ybin_SCRIPTS) $(desktop_DATA) 
$(fillup_DATA)
+EXTRA_DIST = $(module_DATA) $(client_DATA) $(ynclude_DATA) $(scrconf_DATA) 
$(agent_SCRIPTS) $(schemafiles_DATA) $(ybin_SCRIPTS) $(desktop_DATA) 
$(fillup_DATA) $(ylib_DATA)
 
-include $(top_srcdir)/Makefile.am.common
\ No newline at end of file
+include $(top_srcdir)/Makefile.am.common
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autoyast2-3.1.91/src/clients/inst_autosetup.rb 
new/autoyast2-3.1.93/src/clients/inst_autosetup.rb
--- old/autoyast2-3.1.91/src/clients/inst_autosetup.rb  2015-08-26 
14:00:12.000000000 +0200
+++ new/autoyast2-3.1.93/src/clients/inst_autosetup.rb  2015-09-09 
07:24:10.000000000 +0200
@@ -7,6 +7,7 @@
 #          Uwe Gansert <[email protected]>
 #
 # $Id$
+require "autoinstall/module_config_builder"
 module Yast
   import "AutoinstConfig"
 
@@ -43,6 +44,8 @@
       Yast.import "Language"
       Yast.import "Console"
       Yast.import "ServicesManager"
+      Yast.import "Y2ModuleConfig"
+      Yast.import "AutoinstFunctions"
 
       Yast.include self, "bootloader/routines/autoinstall.rb"
       Yast.include self, "autoinstall/ask.rb"
@@ -58,7 +61,8 @@
         _("Configure Bootloader"),
         _("Registration"),
         _("Configure Software selections"),
-        _("Configure Systemd Default Target")
+        _("Configure Systemd Default Target"),
+        _("Configure users and groups")
       ]
 
       @progress_descriptions = [
@@ -69,7 +73,8 @@
         _("Configuring Bootloader..."),
         _("Registering the system..."),
         _("Configuring Software selections..."),
-        _("Configuring Systemd Default Target...")
+        _("Configuring Systemd Default Target..."),
+        _("Importing users and groups configuration...")
       ]
 
       Progress.New(
@@ -176,7 +181,6 @@
         @use_utf8 = false # fallback to ascii
       end
 
-
       #
       # Set it in the Language module.
       #
@@ -206,7 +210,6 @@
         Keyboard.Import(Profile.current["language"] || {}, :language)
       end
 
-
       # one can override the <confirm> option by the commandline parameter 
y2confirm
       @tmp = Convert.to_string(
         SCR.Read(path(".target.string"), "/proc/cmdline")
@@ -321,10 +324,6 @@
 
       Progress.NextStage
       AutoinstSoftware.Import(Ops.get_map(Profile.current, "software", {}))
-      keys = Profile.current.keys.select do |k|
-        Profile.current[k].is_a?(Array)||Profile.current[k].is_a?(Hash)
-      end
-      AutoinstSoftware.AddYdepsFromProfile(keys)
 
       if !AutoinstSoftware.Write
         Report.Error(
@@ -368,8 +367,16 @@
         ServicesManager.import({})
       end
 
+      #
+      # Import users configuration from the profile
+      #
+      Progress.NextStage
+      autosetup_users
+
       Progress.Finish
 
+      add_yast2_dependencies if AutoinstFunctions.second_stage_required?
+
       @ret = ProductControl.RunFrom(
         Ops.add(ProductControl.CurrentStep, 1),
         true
@@ -413,6 +420,23 @@
       end
       :not_found
     end
+
+    # Import Users configuration from profile
+    def autosetup_users
+      users_config = 
ModuleConfigBuilder.build(Y2ModuleConfig.getModuleConfig("users"), 
Profile.current)
+      if users_config
+        Profile.remove_sections(users_config.keys)
+        Call.Function("users_auto", ["Import", users_config])
+      end
+    end
+
+    # Add YaST2 packages dependencies
+    def add_yast2_dependencies
+      keys = Profile.current.keys.select do |k|
+        Profile.current[k].is_a?(Array)||Profile.current[k].is_a?(Hash)
+      end
+      AutoinstSoftware.AddYdepsFromProfile(keys)
+    end
   end
 end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/autoyast2-3.1.91/src/lib/autoinstall/module_config_builder.rb 
new/autoyast2-3.1.93/src/lib/autoinstall/module_config_builder.rb
--- old/autoyast2-3.1.91/src/lib/autoinstall/module_config_builder.rb   
1970-01-01 01:00:00.000000000 +0100
+++ new/autoyast2-3.1.93/src/lib/autoinstall/module_config_builder.rb   
2015-09-09 07:24:10.000000000 +0200
@@ -0,0 +1,86 @@
+module Yast
+  # Builds configuration for an AutoYaST module
+  #
+  # This class builds a module configuration according to its specification (in
+  # a .desktop file) and an AutoYaST profile.
+  #
+  # @see #build
+  class ModuleConfigBuilder
+    MERGE_KEYS = "X-SuSE-YaST-AutoInstMerge"
+    MERGE_TYPES = "X-SuSE-YaST-AutoInstMergeTypes"
+    DEFAULT_TYPES = { "map" => {}, "list" => [] }
+
+    # Builds a module configuration
+    #
+    # This is just a convenience method which relies on #build.
+    #
+    # @see #build
+    def self.build(modspec, profile)
+      new.build(modspec, profile)
+    end
+
+    # Builds a module configuration according to its specification and a 
profile
+    #
+    # It relies on X-SuSE-YaST-AutoInstMerge and X-SuSE-YaST-AutoInstMergeTypes
+    # to merge configuration from related profile sections.
+    #
+    # @param [Hash] modspec Module specification (containin +res+ and +data+ 
keys).
+    # @param [Hash] profile   AutoYaST profile to read documentation from.
+    # @return [Hash] Module configuration.
+    def build(modspec, profile)
+      return false if profile[resource_name(modspec)].nil?
+      types_map(modspec).each_with_object({}) do |section, hsh|
+        key, type = section
+        hsh[key] = profile[key] || default_value_for(type)
+      end
+    end
+
+    # Returns the resource name from the module configuration
+    #
+    # It tries to find the name under the key
+    # Yast::Y2ModuleConfigClass::RESOURCE_NAME_KEY. If it's not defined,
+    # just take the default one.
+    #
+    # @param [Hash] modspec Module specification (containing +res+ and +data+ 
keys).
+    # @return [String] Resource name
+    def resource_name(modspec)
+      resource = modspec["data"][Yast::Y2ModuleConfigClass::RESOURCE_NAME_KEY]
+      if resource && !resource.empty?
+        resource
+      else
+        modspec["res"]
+      end
+    end
+
+    private
+
+    # Builds a map containing keys to merge and its corresponding types.
+    #
+    # @param [Hash] modspec Module specification (containing +res+ and +data+ 
keys).
+    # @return [Hash] Hash containing keys => types.
+    #
+    # @example
+    #   types_map("res" => "users", "data" =>
+    #     { MERGE_KEYS => "users,user_defaults", MERGE_TYPES => "map,list"})
+    #   #=> { "users" => "map", "user_defaults" => "list" }
+    def types_map(modspec)
+      keys = modspec["data"][MERGE_KEYS].split(",").map(&:strip)
+      types = modspec["data"][MERGE_TYPES].split(",").map(&:strip)
+      Hash[keys.zip(types)]
+    end
+
+    # Returns the default value for a configuration parameter type.
+    #
+    # Default types are defined in DEFAULT_TYPES constant.
+    #
+    # @param [String] Type name.
+    # @return [Hash,Array] It returns the default value for the given type.
+    def default_value_for(type)
+      if DEFAULT_TYPES[type]
+        DEFAULT_TYPES[type].clone
+      else
+        raise "Not default value defined for type #{type}"
+      end
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autoyast2-3.1.91/src/modules/AutoinstFunctions.rb 
new/autoyast2-3.1.93/src/modules/AutoinstFunctions.rb
--- old/autoyast2-3.1.91/src/modules/AutoinstFunctions.rb       1970-01-01 
01:00:00.000000000 +0100
+++ new/autoyast2-3.1.93/src/modules/AutoinstFunctions.rb       2015-09-09 
07:24:10.000000000 +0200
@@ -0,0 +1,36 @@
+module Yast
+  # Helper methods to be used on autoinstallation.
+  class AutoinstFunctionsClass < Module
+    def main
+      textdomain "installation"
+
+      Yast.import "Stage"
+      Yast.import "Mode"
+      Yast.import "AutoinstConfig"
+      Yast.import "ProductControl"
+    end
+
+    # Determines if the second stage should be executed
+    #
+    # Checks Mode, AutoinstConfig and ProductControl to decide if it's
+    # needed.
+    #
+    # FIXME: It's almost equal to InstFunctions.second_stage_required?
+    # defined in yast2-installation, but exists to avoid a circular dependency
+    # between packages (yast2-installation -> autoyast2-installation).
+    #
+    # @return [Boolean] 'true' if it's needed; 'false' otherwise.
+    def second_stage_required?
+      return false unless Stage.initial
+      if (Mode.autoinst || Mode.autoupgrade) && !AutoinstConfig.second_stage
+        Builtins.y2milestone("Autoyast: second stage is disabled")
+        false
+      else
+        ProductControl.RunRequired("continue", Mode.mode)
+      end
+    end
+  end
+
+  AutoinstFunctions = AutoinstFunctionsClass.new
+  AutoinstFunctions.main
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autoyast2-3.1.91/src/modules/Profile.rb 
new/autoyast2-3.1.93/src/modules/Profile.rb
--- old/autoyast2-3.1.91/src/modules/Profile.rb 2015-08-26 14:00:12.000000000 
+0200
+++ new/autoyast2-3.1.93/src/modules/Profile.rb 2015-09-09 07:24:10.000000000 
+0200
@@ -31,6 +31,16 @@
       "sshd",
     ]
 
+    # Sections that are handled by AutoYaST clients included in autoyast2 
package.
+    AUTOYAST_CLIENTS = [
+      "files",
+      "general",
+      "partitioning",
+      "report",
+      "scripts",
+      "software"
+    ]
+
     def main
       Yast.import "UI"
       textdomain "autoinst"
@@ -45,6 +55,7 @@
       Yast.import "Directory"
       Yast.import "FileUtils"
       Yast.import "PackageSystem"
+      Yast.import "AutoinstFunctions"
 
       Yast.include self, "autoinstall/xml.rb"
 
@@ -126,34 +137,15 @@
 
     def softwareCompat
       Ops.set(@current, "software", Ops.get_map(@current, "software", {}))
-      if !Builtins.contains(
-          Ops.get_list(@current, ["software", "packages"], []),
-          "autoyast2-installation"
-        )
-        Ops.set(
-          @current,
-          ["software", "packages"],
-          Builtins.add(
-            Ops.get_list(@current, ["software", "packages"], []),
-            "autoyast2-installation"
-          )
-        )
-      end
 
-      # without autoyast2, <files ...> does not work
-      if Builtins.haskey(@current, "files") &&
-          !Builtins.contains(
-            Ops.get_list(@current, ["software", "packages"], []),
-            "autoyast2"
-          )
-        Ops.set(
-          @current,
-          ["software", "packages"],
-          Builtins.add(
-            Ops.get_list(@current, ["software", "packages"], []),
-            "autoyast2"
-          )
-        )
+      # We need to check if second stage was disabled in the profile itself
+      # because AutoinstConfig is not initialized at this point
+      # and InstFuntions#second_stage_required? depends on that module
+      # to check if 2nd stage is required (chicken-and-egg problem).
+      mode = @current.fetch("general", {}).fetch("mode", {})
+      second_stage_enabled = mode.has_key?("second_stage") ? 
mode["second_stage"] : true
+      if AutoinstFunctions.second_stage_required? && second_stage_enabled
+        add_autoyast_packages
       end
 
       # workaround for missing "REQUIRES" in content file to stay backward 
compatible
@@ -866,6 +858,49 @@
       nil
     end
 
+    # Removes the given sections from the profile
+    #
+    # @param [String,Array<String>] keys Section names.
+    # @rerturn [Hash] The profile without the removed sections.
+    def remove_sections(sections)
+      keys_to_delete = Array(sections)
+      @current.delete_if { |k, v| keys_to_delete.include?(k) }
+    end
+
+    private
+
+    def add_autoyast_packages
+      if !Builtins.contains(
+          Ops.get_list(@current, ["software", "packages"], []),
+          "autoyast2-installation"
+        )
+        Ops.set(
+          @current,
+          ["software", "packages"],
+          Builtins.add(
+            Ops.get_list(@current, ["software", "packages"], []),
+            "autoyast2-installation"
+          )
+        )
+      end
+
+      # without autoyast2, <files ...> does not work
+      if !(@current.keys & AUTOYAST_CLIENTS).empty? &&
+          !Builtins.contains(
+            Ops.get_list(@current, ["software", "packages"], []),
+            "autoyast2"
+          )
+        Ops.set(
+          @current,
+          ["software", "packages"],
+          Builtins.add(
+            Ops.get_list(@current, ["software", "packages"], []),
+            "autoyast2"
+          )
+        )
+      end
+    end
+
     publish :variable => :current, :type => "map <string, any>"
     publish :variable => :ModuleMap, :type => "map <string, map>"
     publish :variable => :changed, :type => "boolean"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autoyast2-3.1.91/src/modules/Y2ModuleConfig.rb 
new/autoyast2-3.1.93/src/modules/Y2ModuleConfig.rb
--- old/autoyast2-3.1.91/src/modules/Y2ModuleConfig.rb  2015-08-26 
14:00:12.000000000 +0200
+++ new/autoyast2-3.1.93/src/modules/Y2ModuleConfig.rb  2015-09-09 
07:24:10.000000000 +0200
@@ -13,6 +13,7 @@
     # Key for AutoYaST client name in desktop file
     RESOURCE_NAME_KEY = "X-SuSE-YaST-AutoInstResource"
     RESOURCE_NAME_MERGE_KEYS = "X-SuSE-YaST-AutoInstMerge"
+    MODES = %w(all configure write)
 
     include Yast::Logger
 
@@ -385,6 +386,22 @@
       unhandled_profile_sections & 
Yast::ProfileClass::OBSOLETE_PROFILE_SECTIONS
     end
 
+    # Returns configuration for a given module
+    #
+    # @param [String] name Module name.
+    # @return [Hash] Module configuration using the same structure as
+    #                #Deps method (with "res" and "data" keys).
+    # @see #ReadMenuEntries
+    def getModuleConfig(name)
+      entries = ReadMenuEntries(MODES).first # entries, groups
+      entry = entries.find { |k, v| k == name } # name, entry
+      if entry
+        { "res" => name, "data" => entry.last }
+      else
+        nil
+      end
+    end
+
     publish :variable => :GroupMap, :type => "map <string, map>"
     publish :variable => :ModuleMap, :type => "map <string, map>"
     publish :variable => :MenuTreeData, :type => "list <map>"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autoyast2-3.1.91/test/AutoinstFunctions_test.rb 
new/autoyast2-3.1.93/test/AutoinstFunctions_test.rb
--- old/autoyast2-3.1.91/test/AutoinstFunctions_test.rb 1970-01-01 
01:00:00.000000000 +0100
+++ new/autoyast2-3.1.93/test/AutoinstFunctions_test.rb 2015-09-09 
07:24:10.000000000 +0200
@@ -0,0 +1,66 @@
+#!/usr/bin/env rspec
+
+require_relative "test_helper"
+
+Yast.import "AutoinstFunctions"
+Yast.import "Stage"
+Yast.import "Mode"
+Yast.import "AutoinstConfig"
+
+describe Yast::AutoinstFunctions do
+  subject { Yast::AutoinstFunctions }
+
+  let(:stage) { "initial" }
+  let(:mode) { "autoinst" }
+  let(:second_stage) { true }
+
+  before do
+    Yast::Mode.SetMode(mode)
+    Yast::Stage.Set(stage)
+    allow(Yast::AutoinstConfig).to 
receive(:second_stage).and_return(second_stage)
+  end
+
+  describe "#second_stage_required?" do
+    context "when not in initial stage" do
+      let(:stage) { "continue" }
+
+      it "returns false" do
+        expect(subject.second_stage_required?).to eq(false)
+      end
+    end
+
+    context "when not in autoinst or autoupgrade mode" do
+      let(:mode) { "normal" }
+
+      it "returns false" do
+        expect(subject.second_stage_required?).to eq(false)
+      end
+    end
+
+    context "when second stage is disabled" do
+      let(:second_stage) { false }
+
+      it "returns false" do
+        expect(subject.second_stage_required?).to eq(false)
+      end
+    end
+
+    context "when in autoinst mode and second stage is enabled" do
+      it "relies on ProductControl.RunRequired" do
+        expect(Yast::ProductControl).to receive(:RunRequired)
+          .with("continue", mode).and_return(true)
+        expect(subject.second_stage_required?).to eq(true)
+      end
+    end
+
+    context "when in autoupgrade mode and second stage is enabled" do
+      let(:mode) { "autoupgrade" }
+
+      it "relies on ProductControl.RunRequired" do
+        expect(Yast::ProductControl).to receive(:RunRequired)
+          .with("continue", mode).and_return(true)
+        expect(subject.second_stage_required?).to eq(true)
+      end
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autoyast2-3.1.91/test/Y2ModuleConfig_test.rb 
new/autoyast2-3.1.93/test/Y2ModuleConfig_test.rb
--- old/autoyast2-3.1.91/test/Y2ModuleConfig_test.rb    2015-08-26 
14:00:12.000000000 +0200
+++ new/autoyast2-3.1.93/test/Y2ModuleConfig_test.rb    2015-09-09 
07:24:10.000000000 +0200
@@ -62,4 +62,34 @@
       )
     end
   end
+
+  describe "#getModuleConfig" do
+    let(:modules) do
+      [
+        # modules
+        { "add-on"     => { "Name" => "Add-On Products" },
+          "bootloader" => { "Name" => "Boot Loader" } },
+        # groups
+        {}
+      ]
+    end
+
+    before do
+      allow(Yast::Y2ModuleConfig).to receive(:ReadMenuEntries).with(%w(all 
configure write))
+        .and_return(modules)
+    end
+
+    context "if the module is defined" do
+      it "returns module config" do
+        expect(Yast::Y2ModuleConfig.getModuleConfig("bootloader")).to eq(
+          "res" => "bootloader", "data" => { "Name" => "Boot Loader" })
+      end
+    end
+
+    context "if the module is undefined" do
+      it "returns nil" do
+        expect(Yast::Y2ModuleConfig.getModuleConfig("non-existant-module")).to 
be_nil
+      end
+    end
+  end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/autoyast2-3.1.91/test/lib/module_config_builder_spec.rb 
new/autoyast2-3.1.93/test/lib/module_config_builder_spec.rb
--- old/autoyast2-3.1.91/test/lib/module_config_builder_spec.rb 1970-01-01 
01:00:00.000000000 +0100
+++ new/autoyast2-3.1.93/test/lib/module_config_builder_spec.rb 2015-09-09 
07:24:10.000000000 +0200
@@ -0,0 +1,58 @@
+#!/usr/bin/env rspec
+
+require_relative "../test_helper"
+require_relative "../../src/lib/autoinstall/module_config_builder"
+
+require "yast"
+Yast.import "Y2ModuleConfig"
+
+describe Yast::ModuleConfigBuilder do
+  describe "#build" do
+    let(:profile) do
+      {
+        "users" => [ {"username" => "root", "uid" => 0}, {"username" => 
"test", "uid" => 1000} ],
+        "user_defaults" => {"group" => "1000"}
+      }
+    end
+
+    let(:modspec) do
+      {
+        "res" => "users",
+        "data" => {
+          "Name"=>"User and Group Management",
+          "GenericName"=>"Add, Edit, Delete Users or User Groups",
+          "Icon"=>"yast-users",
+          "X-SuSE-YaST-AutoInst"=>"all",
+          "X-SuSE-YaST-Group"=>"Security",
+          
"X-SuSE-YaST-AutoInstMerge"=>"users,groups,user_defaults,login_settings",
+          "X-SuSE-YaST-AutoInstMergeTypes"=>"list,list,map,map",
+          "X-SuSE-YaST-AutoInstClonable"=>"true",
+          "X-SuSE-YaST-AutoInstRequires"=>"security",
+          "X-SuSE-DocTeamID"=>"ycc_users",
+          "X-SuSE-YaST-AutoInstClient"=>"users_auto"}
+      }
+    end
+
+    it "returns a profile with the sections defined in 
X-SuSE-YaST-AutoInstMerge" do
+      result = subject.build(modspec, profile)
+      expect(result["users"]).to eq(profile["users"])
+      expect(result["user_defaults"]).to eq(profile["user_defaults"])
+    end
+
+    context "when some section is not defined" do
+      it "replaces that section with its default value (map or list)" do
+        result = subject.build(modspec, profile)
+        expect(result["groups"]).to eq([])
+        expect(result["login_settings"]).to eq({})
+      end
+    end
+
+    context "when base section is not defined" do
+      let(:profile) { {} }
+
+      it "returns false" do
+        expect(subject.build(modspec,profile)).to eq(false)
+      end
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autoyast2-3.1.91/test/profile_test.rb 
new/autoyast2-3.1.93/test/profile_test.rb
--- old/autoyast2-3.1.91/test/profile_test.rb   1970-01-01 01:00:00.000000000 
+0100
+++ new/autoyast2-3.1.93/test/profile_test.rb   2015-09-09 07:24:10.000000000 
+0200
@@ -0,0 +1,205 @@
+#!/usr/bin/env rspec
+
+require_relative "test_helper"
+
+Yast.import "Profile"
+
+describe Yast::Profile do
+  subject { Yast::Profile }
+
+  def items_list(items)
+    Yast::Profile.current["software"][items] || []
+  end
+
+  def packages_list
+    items_list("packages")
+  end
+
+  def patterns_list
+    items_list("patterns")
+  end
+
+  describe "#softwareCompat" do
+    before do
+      Yast::Profile.current = profile
+      allow(Yast::AutoinstFunctions).to 
receive(:second_stage_required?).and_return(second_stage_required)
+    end
+
+    let(:second_stage_required) { true }
+
+    context "when autoyast2-installation is not selected to be installed" do
+      let(:profile) { { "software" => { "packages" => [] } } }
+
+      context "and second stage is required" do
+        it "adds 'autoyast2-installation' to packages list" do
+          Yast::Profile.softwareCompat
+          expect(packages_list).to include("autoyast2-installation")
+        end
+      end
+
+      context "and second stage is not required" do
+        let(:second_stage_required) { false }
+
+        it "does not add 'autoyast2-installation' to packages list" do
+          Yast::Profile.softwareCompat
+          expect(packages_list).to_not eq(["autoyast2-installation"])
+        end
+      end
+
+      context "and second stage is disabled on the profile itself" do
+        let(:profile) do
+          { "general" => { "mode" => { "second_stage" => false } },
+            "software" => { "packages" => [] } }
+        end
+
+        it "does not add 'autoyast2-installation' to packages list" do
+          Yast::Profile.softwareCompat
+          expect(packages_list).to_not include(["autoyast2-installation"])
+        end
+      end
+    end
+
+    context "when some section handled by a client included in autoyast2 
package is present" do
+      let(:profile) { { "scripts" => [] } }
+
+      context "and second stage is required" do
+        it "adds 'autoyast2' to packages list" do
+          Yast::Profile.softwareCompat
+          expect(packages_list).to include("autoyast2")
+        end
+      end
+
+      context "and second stage is not required" do
+        let(:second_stage_required) { false }
+
+        it "does not add 'autoyast2' to packages list" do
+          Yast::Profile.softwareCompat
+          expect(packages_list).to_not include("autoyast2")
+        end
+      end
+
+      context "and second stage is disabled on the profile itself" do
+        let(:profile) do
+          { "general" => { "mode" => { "second_stage" => false } },
+            "files" => [] }
+        end
+
+        it "does not add 'autoyast2' to packages list" do
+          Yast::Profile.softwareCompat
+          expect(packages_list).to_not include(["autoyast2-installation"])
+        end
+      end
+    end
+
+    context "when the software patterns section is empty" do
+      let(:profile) { { "software" => { "patterns" => [] } } }
+
+      it "adds 'base' pattern" do
+        Yast::Profile.softwareCompat
+        expect(patterns_list).to include("base")
+      end
+    end
+
+    context "when the software patterns section is missing" do
+      let(:profile) { {} }
+
+      it "adds 'base' pattern" do
+        Yast::Profile.softwareCompat
+        expect(patterns_list).to include("base")
+      end
+    end
+  end
+
+  describe "#Import" do
+    let(:profile) { {} }
+
+    context "when profile is given in the old format" do
+      context "and 'install' key is present" do
+        let(:profile) { { "install" =>  { "section1" => ["val1"] } } }
+
+        it "move 'install' items to the root of the profile" do
+          Yast::Profile.Import(profile)
+          expect(Yast::Profile.current["section1"]).to eq(["val1"])
+          expect(Yast::Profile.current["install"]).to be_nil
+        end
+      end
+
+      context "and 'configure' key is present" do
+        let(:profile) { { "configure" =>  { "section2" => ["val2"] } } }
+
+        it "move 'configure' items to the root of the profile" do
+          Yast::Profile.Import(profile)
+          expect(Yast::Profile.current["section2"]).to eq(["val2"])
+          expect(Yast::Profile.current["configure"]).to be_nil
+        end
+      end
+
+      context "when both keys are present" do
+        let(:profile) do
+          { "configure" =>  { "section2" => ["val2"] },
+            "install" =>    { "section1" => ["val1"] } }
+        end
+
+        it "merge them into the root of the profile" do
+          Yast::Profile.Import(profile)
+          expect(Yast::Profile.current["section1"]).to eq(["val1"])
+          expect(Yast::Profile.current["section2"]).to eq(["val2"])
+          expect(Yast::Profile.current["install"]).to be_nil
+          expect(Yast::Profile.current["configure"]).to be_nil
+        end
+      end
+
+      context "when both keys are present and some section is duplicated" do
+        let(:profile) do
+          { "configure" =>  { "section1" => "val3", "section2" => ["val2"] },
+            "install" =>    { "section1" => ["val1"] } }
+        end
+
+        it "merges them into the root of the profile giving precedence to 
'installation' section" do
+          Yast::Profile.Import(profile)
+          expect(Yast::Profile.current["section1"]).to eq(["val1"])
+          expect(Yast::Profile.current["section2"]).to eq(["val2"])
+          expect(Yast::Profile.current["install"]).to be_nil
+          expect(Yast::Profile.current["configure"]).to be_nil
+        end
+      end
+    end
+
+    it "sets storage compatibility options" do
+      expect(Yast::Profile).to receive(:storageLibCompat)
+      Yast::Profile.Import(profile)
+    end
+
+    it "sets general compatibility options" do
+      expect(Yast::Profile).to receive(:generalCompat)
+      Yast::Profile.Import(profile)
+    end
+
+    it "sets software compatibility options" do
+      expect(Yast::Profile).to receive(:softwareCompat)
+      Yast::Profile.Import(profile)
+    end
+  end
+
+  describe "#remove_sections" do
+    before do
+      Yast::Profile.Import("section1" => "val1", "section2" => "val2")
+    end
+
+    context "when a single section is given" do
+      it "removes that section" do
+        Yast::Profile.remove_sections("section1")
+        expect(Yast::Profile.current.keys).to_not include("section1")
+        expect(Yast::Profile.current.keys).to include("section2")
+      end
+    end
+
+    context "when multiple sections are given" do
+      it "removes every given section" do
+        Yast::Profile.remove_sections(%w(section1 section2))
+        expect(Yast::Profile.current.keys).to_not include("section1")
+        expect(Yast::Profile.current.keys).to_not include("section2")
+      end
+    end
+  end
+end


Reply via email to