Skip to content

Commit

Permalink
Merge pull request #146 from imobach/fix-autoconfigure
Browse files Browse the repository at this point in the history
Fix premature loading of AutoInstall
  • Loading branch information
imobachgs committed Sep 8, 2015
2 parents afa0e62 + 57edba1 commit 96c5476
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 33 deletions.
7 changes: 7 additions & 0 deletions package/autoyast2.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Sep 7 22:32:50 UTC 2015 - igonzalezsosa@suse.com

- 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 - igonzalezsosa@suse.com

Expand Down
3 changes: 2 additions & 1 deletion package/autoyast2.spec
Expand Up @@ -17,7 +17,7 @@


Name: autoyast2
Version: 3.1.92
Version: 3.1.93
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down Expand Up @@ -266,6 +266,7 @@ rmdir $RPM_BUILD_ROOT/%{_prefix}/share/doc/packages/autoyast2/html/autoyast
%{yast_moduledir}/AutoinstDrive.rb
%{yast_moduledir}/AutoinstPartPlan.rb
%{yast_moduledir}/AutoinstPartition.rb
%{yast_moduledir}/AutoinstFunctions.rb

#clients
%{yast_clientdir}/inst_autoinit.rb
Expand Down
3 changes: 2 additions & 1 deletion src/Makefile.am
Expand Up @@ -21,7 +21,8 @@ module_DATA = \
modules/AutoinstGeneral.rb \
modules/AutoinstSoftware.rb \
modules/AutoinstDrive.rb \
modules/AutoinstClass.rb
modules/AutoinstClass.rb \
modules/AutoinstFunctions.rb

client_DATA = \
clients/classes_auto.rb \
Expand Down
3 changes: 2 additions & 1 deletion src/clients/inst_autosetup.rb
Expand Up @@ -45,6 +45,7 @@ def main
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"
Expand Down Expand Up @@ -374,7 +375,7 @@ def main

Progress.Finish

add_yast2_dependencies if AutoInstall.second_stage_required?
add_yast2_dependencies if AutoinstFunctions.second_stage_required?

@ret = ProductControl.RunFrom(
Ops.add(ProductControl.CurrentStep, 1),
Expand Down
24 changes: 0 additions & 24 deletions src/modules/AutoInstall.rb
Expand Up @@ -20,8 +20,6 @@ def main
Yast.import "AutoInstallRules"
Yast.import "Report"
Yast.import "TFTP"
Yast.import "ProductControl"
Yast.import "Mode"

@autoconf = false
AutoInstall()
Expand Down Expand Up @@ -303,27 +301,6 @@ def PXELocalBoot
true
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
alias_method :second_stage_required, :second_stage_required?

publish :variable => :autoconf, :type => "boolean"
publish :function => :callbackTrue_boolean_string, :type => "boolean (string)"
publish :function => :callbackFalse_boolean_string, :type => "boolean (string)"
Expand All @@ -347,7 +324,6 @@ def second_stage_required?
publish :function => :Save, :type => "boolean ()"
publish :function => :Finish, :type => "void (string)"
publish :function => :PXELocalBoot, :type => "boolean ()"
publish function: :second_stage_required, type: "boolean ()"
end

AutoInstall = AutoInstallClass.new
Expand Down
36 changes: 36 additions & 0 deletions src/modules/AutoinstFunctions.rb
@@ -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
4 changes: 2 additions & 2 deletions src/modules/Profile.rb
Expand Up @@ -55,7 +55,7 @@ def main
Yast.import "Directory"
Yast.import "FileUtils"
Yast.import "PackageSystem"
Yast.import "AutoInstall"
Yast.import "AutoinstFunctions"

Yast.include self, "autoinstall/xml.rb"

Expand Down Expand Up @@ -144,7 +144,7 @@ def softwareCompat
# 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 AutoInstall.second_stage_required? && second_stage_enabled
if AutoinstFunctions.second_stage_required? && second_stage_enabled
add_autoyast_packages
end

Expand Down
6 changes: 3 additions & 3 deletions test/AutoInstall_test.rb → test/AutoinstFunctions_test.rb
Expand Up @@ -2,13 +2,13 @@

require_relative "test_helper"

Yast.import "AutoInstall"
Yast.import "AutoinstFunctions"
Yast.import "Stage"
Yast.import "Mode"
Yast.import "AutoinstConfig"

describe Yast::AutoInstall do
subject { Yast::AutoInstall }
describe Yast::AutoinstFunctions do
subject { Yast::AutoinstFunctions }

let(:stage) { "initial" }
let(:mode) { "autoinst" }
Expand Down
2 changes: 1 addition & 1 deletion test/profile_test.rb
Expand Up @@ -22,7 +22,7 @@ def patterns_list
describe "#softwareCompat" do
before do
Yast::Profile.current = profile
allow(Yast::AutoInstall).to receive(:second_stage_required?).and_return(second_stage_required)
allow(Yast::AutoinstFunctions).to receive(:second_stage_required?).and_return(second_stage_required)
end

let(:second_stage_required) { true }
Expand Down

0 comments on commit 96c5476

Please sign in to comment.