Skip to content

Commit

Permalink
Merge pull request #311 from imobach/move-second-stage-required
Browse files Browse the repository at this point in the history
Move second_stage_required?
  • Loading branch information
imobachgs committed Sep 2, 2015
2 parents 7bbf5bd + d2d1121 commit d7327f6
Show file tree
Hide file tree
Showing 10 changed files with 271 additions and 249 deletions.
7 changes: 7 additions & 0 deletions package/yast2-installation.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Sep 2 09:43:21 UTC 2015 - igonzalezsosa@suse.com

- Move #second_stage_required? method to InstFunctions module
to be used by AutoYaST (bnc#892091)
- 3.1.157

-------------------------------------------------------------------
Tue Aug 25 10:17:24 CEST 2015 - schubi@suse.de

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-installation.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-installation
Version: 3.1.156
Version: 3.1.157
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
3 changes: 2 additions & 1 deletion src/include/installation/inst_inc_first.rb
Expand Up @@ -45,6 +45,7 @@ def initialize_installation_inst_inc_first(include_target)
Yast.import "Mode"
Yast.import "ProductFeatures"
Yast.import "AutoinstConfig"
Yast.import "InstFunctions"

Yast.include include_target, "installation/misc.rb"
end
Expand Down Expand Up @@ -175,7 +176,7 @@ def HandleSecondStageRequired
# file name
run_yast_at_boot = "#{Installation.destdir}/#{Installation.run_yast_at_boot}"

if second_stage_required?
if InstFunctions.second_stage_required?
Builtins.y2milestone("Running the second stage is required")
WFM.Write(path(".local.string"), run_yast_at_boot, "")
WriteSecondStageRequired(true)
Expand Down
25 changes: 0 additions & 25 deletions src/include/installation/misc.rb
Expand Up @@ -365,30 +365,5 @@ def WriteSecondStageRequired(scst_required)

nil
end

def second_stage_required?
return false unless Stage.initial

# the current one is 'initial'
if (Mode.autoinst || Mode.autoupgrade) && !AutoinstConfig.second_stage
run_second_stage = false
Builtins.y2milestone("Autoyast: second stage is disabled")
else
# after reboot/kexec it would be 'continue'
stage_to_check = "continue"

# for matching the control file
mode_to_check = Mode.mode

Builtins.y2milestone(
"Checking RunRequired (%1, %2)",
stage_to_check,
mode_to_check
)
run_second_stage = ProductControl.RunRequired(stage_to_check, mode_to_check)
end

run_second_stage
end
end
end
3 changes: 2 additions & 1 deletion src/lib/installation/clients/copy_files_finish.rb
Expand Up @@ -53,6 +53,7 @@ def main
Yast.import "WorkflowManager"
Yast.import "SystemFilesCopy"
Yast.import "ProductFeatures"
Yast.import "InstFunctions"

Yast.include self, "installation/misc.rb"

Expand Down Expand Up @@ -127,7 +128,7 @@ def main
# --------------------------------------------------------------
# Copy /etc/install.inf into built system so that the
# second phase of the installation can find it.
if second_stage_required?
if InstFunctions.second_stage_required?
Linuxrc.SaveInstallInf(Installation.destdir)
else
SCR.Execute(path(".target.remove"), "/etc/install.inf")
Expand Down
3 changes: 2 additions & 1 deletion src/lib/installation/snapshots_finish.rb
Expand Up @@ -12,6 +12,7 @@ def initialize

Yast.import "Mode"
Yast.import "StorageSnapper"
Yast.import "InstFunctions"
Yast.include self, "installation/misc.rb"
end

Expand All @@ -23,7 +24,7 @@ def initialize
# @return [TrueClass,FalseClass] True if snapshot was created;
# otherwise it returns false.
def write
if !second_stage_required? && Yast2::FsSnapshot.configured?
if !InstFunctions.second_stage_required? && Yast2::FsSnapshot.configured?
log.info("Creating root filesystem snapshot")
if Mode.update
create_post_snapshot
Expand Down
37 changes: 37 additions & 0 deletions src/modules/InstFunctions.rb
Expand Up @@ -34,6 +34,10 @@ def main
textdomain "installation"

Yast.import "Linuxrc"
Yast.import "AutoinstConfig"
Yast.import "Stage"
Yast.import "Mode"
Yast.import "ProductControl"
end

# Returns list of ignored features defined via Linuxrc commandline
Expand Down Expand Up @@ -95,8 +99,41 @@ def feature_ignored?(feature_name)
ignored_features.include?(feature)
end

# Determines if the second stage should be executed
#
# Checks Mode, AutoinstConfig and ProductControl to decide if it's
# needed.
#
# @return [Boolean] 'true' if it's needed; 'false' otherwise.
def second_stage_required?
return false unless Stage.initial

# the current one is 'initial'
if (Mode.autoinst || Mode.autoupgrade) && !AutoinstConfig.second_stage
run_second_stage = false
Builtins.y2milestone("Autoyast: second stage is disabled")
else
# after reboot/kexec it would be 'continue'
stage_to_check = "continue"

# for matching the control file
mode_to_check = Mode.mode

Builtins.y2milestone(
"Checking RunRequired (%1, %2)",
stage_to_check,
mode_to_check
)
run_second_stage = ProductControl.RunRequired(stage_to_check, mode_to_check)
end

run_second_stage
end
alias_method :second_stage_required, :second_stage_required?

publish function: :ignored_features, type: "list ()"
publish function: :feature_ignored?, type: "boolean (string)"
publish function: :second_stage_required, type: "boolean ()"

private

Expand Down

0 comments on commit d7327f6

Please sign in to comment.