Hello community,
here is the log from the commit of package autoyast2 for openSUSE:Factory checked in at 2015-04-02 16:01:22
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
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-02-03 11:38:17.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.autoyast2.new/autoyast2.changes 2015-04-02 16:01:23.000000000 +0200
@@ -1,0 +2,8 @@
+Thu Mar 26 17:00:32 CET 2015 - schubi@suse.de
+
+- New autoinst flag in general/mode section: final_restart_services.
+ Restarting all services after finishing the installation.
+ The default is "true" which is a backward compatible value.
+ (bnc#923992)
+
+-------------------------------------------------------------------
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ autoyast2-3.1.72.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-3.1.72/package/autoyast2.changes new/autoyast2-3.1.72/package/autoyast2.changes
--- old/autoyast2-3.1.72/package/autoyast2.changes 2015-01-30 10:39:49.000000000 +0100
+++ new/autoyast2-3.1.72/package/autoyast2.changes 2015-03-27 09:54:14.000000000 +0100
@@ -1,4 +1,12 @@
-------------------------------------------------------------------
+Thu Mar 26 17:00:32 CET 2015 - schubi@suse.de
+
+- New autoinst flag in general/mode section: final_restart_services.
+ Restarting all services after finishing the installation.
+ The default is "true" which is a backward compatible value.
+ (bnc#923992)
+
+-------------------------------------------------------------------
Fri Jan 30 07:43:13 UTC 2015 - jsrain@suse.cz
- load release notes of extensions also during AutoYaST
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-3.1.72/src/clients/inst_autoconfigure.rb new/autoyast2-3.1.72/src/clients/inst_autoconfigure.rb
--- old/autoyast2-3.1.72/src/clients/inst_autoconfigure.rb 2015-01-30 10:39:50.000000000 +0100
+++ new/autoyast2-3.1.72/src/clients/inst_autoconfigure.rb 2015-03-27 09:54:15.000000000 +0100
@@ -40,8 +40,11 @@
Ops.get_map(Profile.current, ["general", "mode"], {})
)
@need_systemd_isolate = true
- @max_steps = Ops.add(Builtins.size(Y2ModuleConfig.ModuleMap), 4)
+ final_restart_services = Ops.get_boolean(
+ Profile.current,["general", "mode", "final_restart_services"], true)
+ @max_steps = Y2ModuleConfig.ModuleMap.size + 3 # additional for scripting and finished message
@max_steps = Ops.add(@max_steps, 1) if @need_systemd_isolate
+ @max_steps += 1 if final_restart_services
Builtins.y2milestone(
"max steps: %1 need_isolate:%2",
@max_steps,
@@ -264,26 +267,29 @@
"YaST2-Second-Stage.service",
"autoyast-initscripts.service"
]
-
- logStep(_("Restarting all running services"))
- @cmd = "systemctl --type=service list-units | grep \" running \" | sed s/[[:space:]].*//"
- @out = Convert.to_map(SCR.Execute(path(".target.bash_output"), @cmd))
- @sl = Builtins.filter(
- Builtins.splitstring(Ops.get_string(@out, "stdout", ""), "\n")
- ) { |s| Ops.greater_than(Builtins.size(s), 0) }
- Builtins.y2milestone("running services \"%1\"", @sl)
- @sl = Builtins.filter(@sl) do |s|
- !Builtins.contains(@ser_ignore, s)
+ if final_restart_services
+ logStep(_("Restarting all running services"))
+ @cmd = "systemctl --type=service list-units | grep \" running \" | sed s/[[:space:]].*//"
+ @out = Convert.to_map(SCR.Execute(path(".target.bash_output"), @cmd))
+ @sl = Builtins.filter(
+ Builtins.splitstring(Ops.get_string(@out, "stdout", ""), "\n")
+ ) { |s| Ops.greater_than(Builtins.size(s), 0) }
+ Builtins.y2milestone("running services \"%1\"", @sl)
+ @sl = Builtins.filter(@sl) do |s|
+ !Builtins.contains(@ser_ignore, s)
+ end
+ Builtins.y2milestone("restarting services \"%1\"", @sl)
+ @cmd = Ops.add(
+ "systemctl --no-block restart ",
+ Builtins.mergestring(@sl, " ")
+ )
+ Builtins.y2milestone("before calling \"%1\"", @cmd)
+ @out = Convert.to_map(SCR.Execute(path(".target.bash_output"), @cmd))
+ Builtins.y2milestone("after calling \"%1\"", @cmd)
+ wait_systemd_finished(@max_wait, @ser_ignore)
+ else
+ Builtins.y2milestone("Do not restart all services (defined in autoyast.xml)")
end
- Builtins.y2milestone("restarting services \"%1\"", @sl)
- @cmd = Ops.add(
- "systemctl --no-block restart ",
- Builtins.mergestring(@sl, " ")
- )
- Builtins.y2milestone("before calling \"%1\"", @cmd)
- @out = Convert.to_map(SCR.Execute(path(".target.bash_output"), @cmd))
- Builtins.y2milestone("after calling \"%1\"", @cmd)
- wait_systemd_finished(@max_wait, @ser_ignore)
if @need_systemd_isolate
logStep(_("Activating systemd default target"))
#string cmd = "systemctl disable YaST2-Second-Stage.service; systemctl --ignore-dependencies isolate default.target";
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-3.1.72/src/modules/AutoinstClass.rb new/autoyast2-3.1.72/src/modules/AutoinstClass.rb
--- old/autoyast2-3.1.72/src/modules/AutoinstClass.rb 2015-01-30 10:39:50.000000000 +0100
+++ new/autoyast2-3.1.72/src/modules/AutoinstClass.rb 2015-03-27 09:54:15.000000000 +0100
@@ -17,133 +17,87 @@
module Yast
class AutoinstClassClass < Module
- def main
+ include Yast::Logger
+ def main
Yast.import "AutoinstConfig"
Yast.import "XML"
Yast.import "Summary"
Yast.include self, "autoinstall/xml.rb"
-
-
-
@classDir = AutoinstConfig.classDir
-
@ClassConf = "/etc/autoinstall"
-
@profile_conf = []
-
@Profiles = []
-
@Classes = []
@deletedClasses = []
@confs = []
-
@class_file = "classes.xml"
+ @classPath = File.join(@classDir, @class_file)
- #string classPath = sformat("%1/%2", ClassConf, class_file);
- @classPath = Builtins.sformat(
- "%1/%2",
- AutoinstConfig.classDir,
- @class_file
- )
AutoinstClass()
end
# find a profile path
# @param string profile name
# @return [String] profile Path
- #
- def findPath(name, _class)
- result = Ops.get(Builtins.filter(@confs) do |c|
- Ops.get_string(c, "name", "") == name &&
- Ops.get_string(c, "class", "") == _class
- end, 0, {})
-
- profile_path = Builtins.sformat(
- "%1/%2/%3",
- AutoinstConfig.classDir,
- Ops.get_string(result, "class", ""),
- Ops.get_string(result, "name", "default")
- )
- profile_path
+ def findPath(name, class_)
+ result = @confs.find { |c| c['name'] == name && c['class'] == class_ }
+ result ||= { 'class' => '', 'name' => 'default' }
+ File.join(@classDir, result['class'], result['name'])
end
-
# Read classes
def Read
if SCR.Read(path(".target.size"), @classPath) != -1
# TODO: use XML module
- tmp = Convert.to_map(SCR.Read(path(".xml"), @classPath))
- @Classes = Ops.get_list(tmp, "classes", [])
+ classes_map = Convert.to_map(SCR.Read(path(".xml"), @classPath))
+ @Classes = (classes_map && classes_map['classes']) || []
else
@Classes = []
end
nil
end
-
# we are doing some compatibility fixes here and move
# from one /etc/autoinstall/classes.xml to multiple
# classes.xml files, one for each repository
def Compat
- if Ops.less_or_equal(SCR.Read(path(".target.size"), @classPath), 0) &&
- Ops.greater_than(
- SCR.Read(
- path(".target.size"),
- Ops.add(Ops.add(@ClassConf, "/"), @class_file)
- ),
- 0
- )
- Builtins.y2milestone(
- "Compat: %1 not found but %2 exists",
- @classPath,
- Ops.add(Ops.add(@ClassConf, "/"), @class_file)
- )
- tmp = Convert.to_map(
- SCR.Read(path(".xml"), Ops.add(Ops.add(@ClassConf, "/"), @class_file))
- )
- oldClasses = Ops.get_list(tmp, "classes", [])
- newClasses = []
- Builtins.foreach(oldClasses) do |_class|
- Builtins.y2milestone(
- "looking for %1",
- Ops.add(
- Ops.add(AutoinstConfig.classDir, "/"),
- Ops.get_string(_class, "name", "")
- )
- )
- if SCR.Read(
- path(".target.dir"),
- Ops.add(
- Ops.add(AutoinstConfig.classDir, "/"),
- Ops.get_string(_class, "name", "")
- )
- ) != nil
- newClasses = Builtins.add(newClasses, _class)
- end
- end
- tmp2 = { "classes" => newClasses }
- Builtins.y2milestone("creating %1", tmp2)
- XML.YCPToXMLFile(:class, tmp2, @classPath)
+ if !class_file_exists? && compat_class_file_exists?
+ log.info "Compat: #{@classPath} no found but #{compat_class_file} exists"
+ new_classes_map = { 'classes' => read_old_classes }
+ log.info "creating #{new_classes_map}"
+ XML.YCPToXMLFile(:class, new_classes_map, @classPath)
end
-
nil
end
+ # Change the directory and read the class definitions
+ #
+ # @param [String] Path of the new directory
+ # @return nil
+ # @see class_dir=
def classDirChanged(newdir)
- AutoinstConfig.classDir = newdir
- @classDir = newdir
- @classPath = Builtins.sformat(
- "%1/%2",
- AutoinstConfig.classDir,
- @class_file
- )
+ self.class_dir = newdir
Compat()
Read()
nil
end
+ # Change the directory of classes definitions.
+ #
+ # AutoinstConfig#classDir= is called to set the new value
+ # in the configuration. It does not check if the directory
+ # exists or is accessible.
+ #
+ # @return [String] path of the new directory.
+ def class_dir=(newdir)
+ AutoinstConfig.classDir = newdir
+ @classDir = newdir
+ @classPath = File.join(@classDir, @class_file)
+ newdir
+ end
+
# Constructor
# @return void
@@ -154,13 +108,8 @@
nil
end
-
-
-
-
# Merge Classes
#
-
def MergeClasses(configuration, base_profile, resultFileName)
configuration = deep_copy(configuration)
dontmerge_str = ""
@@ -215,54 +164,28 @@
deep_copy(out)
end
-
-
-
-
# Read files from class directories
# @return [void]
def Files
@confs = []
- Builtins.foreach(@Classes) do |_class|
- files = Convert.convert(
- SCR.Read(
- path(".target.dir"),
- Ops.add(
- Ops.add(@classDir, "/"),
- Ops.get_string(_class, "name", "xxx")
- )
- ),
- :from => "any",
- :to => "list <string>"
- )
- if files != nil
- Builtins.y2milestone(
- "Files in class %1: %2",
- Ops.get_string(_class, "name", "xxx"),
- files
- )
- tmp_confs = Builtins.maplist(files) do |file|
- conf = {}
- Ops.set(conf, "class", Ops.get_string(_class, "name", "xxx"))
- Ops.set(conf, "name", file)
- deep_copy(conf)
- end
- Builtins.y2milestone("Configurations: %1", tmp_confs)
- @confs = Convert.convert(
- Builtins.union(@confs, tmp_confs),
- :from => "list",
- :to => "list <map>"
- )
- end
+ @Classes.each do |class_|
+ class_name_ = class_['name'] || 'xxx'
+ files_path = File.join(@classDir, class_name_)
+ files = Convert.convert(SCR.Read(path('.target.dir'), files_path),
+ :from => "any", :to => "list <string>")
+
+ next if files.nil?
+
+ log.info "Files in class #{class_name_}: #{files}"
+ new_confs = files.map { |f| { 'class' => class_name_, 'name' => f } }
+ log.info "Configurations: #{new_confs}"
+ @confs.concat(new_confs)
end
- Builtins.y2milestone("Configurations: %1", @confs)
+ log.info "Configurations: #{@confs}"
nil
end
-
-
# Save Class definitions
-
def Save
Builtins.foreach(@deletedClasses) do |c|
toDel = Builtins.sformat(
@@ -274,14 +197,12 @@
end
@deletedClasses = []
tmp = { "classes" => @Classes }
- Builtins.y2debug("saving classes: %1", @classPath)
+ log.debug "saving classes: #{@classPath}"
XML.YCPToXMLFile(:class, tmp, @classPath)
end
-
# Import configuration
-
def Import(settings)
settings = deep_copy(settings)
@profile_conf = deep_copy(settings)
@@ -289,13 +210,11 @@
end
# Export configuration
-
def Export
deep_copy(@profile_conf)
end
# Configuration Summary
-
def Summary
summary = ""
@@ -331,6 +250,40 @@
publish :function => :Import, :type => "boolean (list <map>)"
publish :function => :Export, :type => "list <map> ()"
publish :function => :Summary, :type => "string ()"
+
+ private
+
+ # Checks if a classes.xml exists
+ # @return [true,false] Returns true when present (false otherwise).
+ def class_file_exists?
+ SCR.Read(path(".target.size"), @classPath) > 0
+ end
+
+ # Checks if an old classes.xml exists
+ # @return [true,false] Returns true when present (false otherwise).
+ # @see compat_class_file
+ def compat_class_file_exists?
+ SCR.Read(path(".target.size"), compat_class_file) > 0
+ end
+
+ # Returns the path of the old classes.xml file
+ # By default, it is called /etc/autoinstall/classes.xml.
+ # @return [String] Path to the old classes.xml file.
+ def compat_class_file
+ File.join(@ClassConf, @class_file)
+ end
+
+ # Builds a map of classes to import from /etc/autoinstall/classes.xml
+ # @return [Array<Hash>] Classes defined in the file.
+ def read_old_classes
+ old_classes_map = Convert.to_map(SCR.Read(path('.xml'), compat_class_file))
+ old_classes = old_classes_map['classes'] || []
+ old_classes.each_with_object([]) do |class_, new_classes|
+ class_path_ = File.join(@classDir, class_['name'] || '')
+ log.info "looking for #{class_path_}"
+ new_classes << class_ unless SCR.Read(path(".target.dir"), class_path_).nil?
+ end
+ end
end
AutoinstClass = AutoinstClassClass.new
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-3.1.72/test/AutoinstClass_test.rb new/autoyast2-3.1.72/test/AutoinstClass_test.rb
--- old/autoyast2-3.1.72/test/AutoinstClass_test.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/autoyast2-3.1.72/test/AutoinstClass_test.rb 2015-03-27 09:54:15.000000000 +0100
@@ -0,0 +1,201 @@
+#!/usr/bin/env rspec
+
+root_path = File.expand_path('../..', __FILE__)
+ENV["Y2DIR"] = File.join(root_path, 'src')
+
+require "yast"
+
+Yast.import "AutoinstClass"
+
+describe Yast::AutoinstClass do
+ subject { Yast::AutoinstClass }
+
+ let(:test_xml_dir) { File.join(root_path, 'test', 'fixtures') }
+ let(:class_dir) { File.join(test_xml_dir, 'classes') }
+ let(:class_path) { File.join(class_dir, 'classes.xml') }
+ let(:faked_autoinstall_dir) { File.join(test_xml_dir, 'etc', 'autoinstall') }
+
+ before(:each) do
+ subject.class_dir = class_dir
+ end
+
+ describe '#Read' do
+ context 'when some class definition exists' do
+ it 'read content into @Classes' do
+ subject.Read
+ expect(subject.Classes).to_not be_empty
+ end
+
+ it 'returns nil' do
+ expect(subject.Read).to be_nil
+ end
+ end
+
+ context 'when classes definition file does not exist' do
+ before(:each) do
+ allow(Yast::SCR).to receive(:Read).with(Yast::Path.new('.target.size'), class_path).and_return(-1)
+ end
+
+ it 'sets Classes to []' do
+ subject.Read
+ expect(subject.Classes).to eq([])
+ end
+
+ it 'returns nil' do
+ expect(subject.Read).to be_nil
+ end
+ end
+
+ context 'when classes definition is empty or not valid XML' do
+ before(:each) do
+ allow(Yast::SCR).to receive(:Read).and_call_original
+ allow(Yast::SCR).to receive(:Read).with(Yast::Path.new('.xml'), class_path).and_return(nil)
+ end
+
+ it 'set Classes to []' do
+ subject.Read
+ expect(subject.Classes).to eq([])
+ end
+
+ it 'returns nil' do
+ expect(subject.Read).to be_nil
+ end
+ end
+ end
+
+ describe '#Files' do
+ before(:each) do
+ subject.Read
+ end
+
+ context 'when some class definition exists' do
+ it 'sets confs to an array containing classes configurations' do
+ subject.Files
+ expect(subject.confs).to match_array([
+ { "class" => "swap", "name" => "largeswap.xml" },
+ { "class" => "swap", "name" => "largeswap_noroot.xml" }
+ ])
+ end
+ end
+
+ context 'when classes definitions are not found' do
+ let(:swap_class_dir) { File.join(class_dir, 'swap') }
+
+ before(:each) do
+ allow(Yast::SCR).to receive(:Read).
+ with(Yast::Path.new('.target.dir'), swap_class_dir).and_return(directory_content)
+ end
+
+ context 'when directory does not exist' do
+ let(:directory_content) { nil }
+
+ it 'sets confs to an empty array' do
+ subject.Files
+ expect(subject.confs).to be_kind_of(Array)
+ expect(subject.confs).to be_empty
+ end
+ end
+
+ context 'when directory is empty' do
+ let(:directory_content) { [] }
+
+ it 'sets confs to an empty array' do
+ subject.Files
+ expect(subject.confs).to be_kind_of(Array)
+ expect(subject.confs).to be_empty
+ end
+ end
+ end
+ end
+
+ describe '#classDirChanged' do
+ let(:new_class_dir) { File.join(test_xml_dir, 'new_classes') }
+
+ after(:each) do
+ # Restore original configuration after the test
+ allow(Yast::AutoinstConfig).to receive(:classDir=).with(class_dir).and_call_original
+ allow(subject).to receive(:Read)
+ subject.classDirChanged(class_dir)
+ end
+
+ it 'reads again the classes definitions' do
+ expect(Yast::AutoinstConfig).to receive(:classDir=).with(new_class_dir).and_call_original
+ expect(subject).to receive(:Read)
+ subject.classDirChanged(new_class_dir)
+ end
+ end
+
+ describe '#findPath' do
+ let(:_class) { 'swap' }
+ let(:name) { 'largeswap.xml' }
+
+ before(:each) do |example|
+ subject.Files
+ end
+
+ context 'when class and configuration exists' do
+ it 'returns string with path to classes directory, class name and configuration' do
+ expect(subject.findPath(name, _class)).to eq(File.join(class_dir, _class, name))
+ end
+ end
+
+ context 'when class does not exist' do
+ let(:_class) { 'not-existent-class' }
+
+ it 'returns string with path to a default directory below the classes directory' do
+ expect(subject.findPath(name, _class)).to eq(File.join(class_dir, 'default'))
+ end
+ end
+
+ context 'when name does not exist' do
+ let(:name) { 'not-existent-name' }
+
+ it 'returns string with path to a default directory below the classes directory' do
+ expect(subject.findPath(name, _class)).to eq(File.join(class_dir, 'default'))
+ end
+ end
+ end
+
+ describe '#Compat' do
+ let(:faked_autoinstall_dir) { File.join(test_xml_dir, 'etc', 'autoinstall') }
+
+ context 'when /etc/autoinstall/classes.xml exists' do
+ around(:each) do |example|
+ subject.ClassConf = faked_autoinstall_dir
+ example.call
+ subject.ClassConf = '/etc/autoinstall'
+ end
+
+ context 'and a classes.xml file does not exist in the new location' do
+ before(:each) do
+ allow(Yast::SCR).to receive(:Read).and_call_original
+ allow(Yast::SCR).to receive(:Read).
+ with(Yast::Path.new('.target.size'), class_path).and_return(-1)
+ end
+
+ it 'creates a classes.xml file in the new location' do
+ expect(Yast::XML).to receive(:YCPToXMLFile) do |type, data, path|
+ expect(type).to eq(:class)
+ expect(data['classes']).to be_kind_of(Array)
+ expect(path).to eq(File.join(class_dir, 'classes.xml'))
+ end
+ subject.Compat
+ end
+ end
+
+ context 'and a classes.xml file exists in the new location' do
+ it 'does not create a classes.xml file' do
+ expect(Yast::XML).to_not receive(:YCPToXMLFile)
+ subject.Compat
+ end
+ end
+ end
+ end
+
+ describe '#class_dir=' do
+ it 'sets the classes definitions directory' do
+ subject.class_dir = test_xml_dir
+ expect(subject.classDir).to eq(test_xml_dir)
+ end
+ end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-3.1.72/test/fixtures/classes/classes.xml new/autoyast2-3.1.72/test/fixtures/classes/classes.xml
--- old/autoyast2-3.1.72/test/fixtures/classes/classes.xml 1970-01-01 01:00:00.000000000 +0100
+++ new/autoyast2-3.1.72/test/fixtures/classes/classes.xml 2015-03-27 09:54:15.000000000 +0100
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<profile xmlns="http://www.suse.com/1.0/yast2ns" xmlns:config="http://www.suse.com/1.0/configns">
+ <general>
+ <mode>
+ <confirm xmlns:config="http://www.suse.com/1.0/configns" config:type="boolean">true</confirm>
+ </mode>
+ </general>
+ <networking>
+ <dns>
+