Skip to content

Commit

Permalink
Merge pull request #638 from yast/execute_prescripts_earlier_ga
Browse files Browse the repository at this point in the history
Run pre-scripts just after the profile has been processed (SLE-15-GA)
  • Loading branch information
teclator committed Jul 8, 2020
2 parents cfdf947 + 7d054cd commit ec2e34b
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 83 deletions.
7 changes: 7 additions & 0 deletions package/autoyast2.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Jul 6 23:41:41 UTC 2020 - Knut Anderssen <kanderssen@suse.com>

- Move pre-scriptis to the autoinit client running them just after
the profile has been processed (bsc#1110413)
- 4.0.74

-------------------------------------------------------------------
Tue Mar 31 09:29:30 CEST 2020 - schubi@suse.de

Expand Down
2 changes: 1 addition & 1 deletion package/autoyast2.spec
Expand Up @@ -22,7 +22,7 @@
%endif

Name: autoyast2
Version: 4.0.73
Version: 4.0.74
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
49 changes: 49 additions & 0 deletions src/clients/inst_autoinit.rb
Expand Up @@ -7,9 +7,13 @@
#
# $Id$
#
require "autoinstall/autosetup_helpers"

module Yast
class InstAutoinitClient < Client
include Yast::Logger
include Y2Autoinstallation::AutosetupHelpers

def main
Yast.import "UI"

Expand All @@ -20,6 +24,7 @@ def main
Yast.import "AutoinstConfig"
Yast.import "AutoinstFunctions"
Yast.import "AutoinstGeneral"
Yast.import "AutoinstScripts"
Yast.import "ProfileLocation"
Yast.import "AutoInstallRules"
Yast.import "Progress"
Expand All @@ -33,6 +38,7 @@ def main
Yast.import "Popup"

Yast.include self, "autoinstall/autoinst_dialogs.rb"
Yast.include self, "autoinstall/ask.rb"

Console.Init

Expand All @@ -44,6 +50,7 @@ def main
_("Retrieve & Read Control File"),
_("Parse control file"),
_("Initial Configuration"),
_("Execute pre-install user scripts")
]
@profileFetched = false

Expand Down Expand Up @@ -84,6 +91,15 @@ def main
return @ret if @ret != :ok
end

# Run pre-scripts as soon as possible as we could modify the profile by
# them or by the ask dialog (bsc#1114013)
Yast::Progress.NextStage
Yast::Progress.Title(_("Executing pre-install user scripts..."))
log.info("Executing pre-scripts")

@ret = autoinit_scripts
return @ret if @ret != :ok

Progress.Finish

if !(Mode.autoupgrade && AutoinstConfig.ProfileInRootPart)
Expand Down Expand Up @@ -127,6 +143,39 @@ def main

private

# Import and write the profile pre-scripts running then the ask dialog when
# an ask-list is declared redoing the import and write of the pre-scripts as
# many times as needed.
def autoinit_scripts
# Pre-Scripts
AutoinstScripts.Import(Profile.current["scripts"] || {})
AutoinstScripts.Write("pre-scripts", false)

# Reread Profile in case it was modified in pre-script
# User has to create the new profile in a pre-defined
# location for easy processing in pre-script.

return :abort if readModified == :abort

return :abort if UI.PollInput == :abort && Popup.ConfirmAbort(:painless)

loop do
askDialog
# Pre-Scripts
AutoinstScripts.Import(Ops.get_map(Profile.current, "scripts", {}))
AutoinstScripts.Write("pre-scripts", false)
ret = readModified
return :abort if ret == :abort

return :restart_yast if File.exist?("/var/lib/YaST2/restart_yast")
break if ret == :not_found
end

# reimport scripts, for the case <ask> has changed them
AutoinstScripts.Import(Ops.get_map(Profile.current, "scripts", {}))
:ok
end

# Checking profile for unsupported sections.
def check_unsupported_profile_sections
unsupported_sections = Y2ModuleConfig.unsupported_profile_sections
Expand Down
49 changes: 4 additions & 45 deletions src/clients/inst_autosetup.rb
Expand Up @@ -46,13 +46,10 @@ def main
Yast.import "AutoinstFunctions"
Yast.import "Wizard"

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

@help_text = _(
"<P>Please wait while the system is prepared for autoinstallation.</P>"
)
@progress_stages = [
_("Execute pre-install user scripts"),
_("Configure General Settings "),
_("Set up language"),
_("Configure security settings"),
Expand All @@ -67,7 +64,6 @@ def main
]

@progress_descriptions = [
_("Executing pre-install user scripts..."),
_("Configuring general settings..."),
_("Setting up language..."),
_("Configuring security settings"),
Expand All @@ -90,48 +86,8 @@ def main
@help_text
)


return :abort if UI.PollInput == :abort && Popup.ConfirmAbort(:painless)


Progress.NextStage

# Pre-Scripts
AutoinstScripts.Import(Ops.get_map(Profile.current, "scripts", {}))
AutoinstScripts.Write("pre-scripts", false)

# Reread Profile in case it was modified in pre-script
# User has to create the new profile in a pre-defined
# location for easy processing in pre-script.

return :abort if readModified == :abort

return :abort if UI.PollInput == :abort && Popup.ConfirmAbort(:painless)

#
# Partitioning and Storage
#//////////////////////////////////////////////////////////////////////

@modified = true
begin
askDialog
# Pre-Scripts
AutoinstScripts.Import(Ops.get_map(Profile.current, "scripts", {}))
AutoinstScripts.Write("pre-scripts", false)
@ret2 = readModified
return :abort if @ret2 == :abort
@modified = false if @ret2 == :not_found
if Ops.greater_or_equal(
SCR.Read(path(".target.size"), "/var/lib/YaST2/restart_yast"),
0
)
return :restart_yast
end
end while @modified == true


# reimport scripts, for the case <ask> has changed them
AutoinstScripts.Import(Ops.get_map(Profile.current, "scripts", {}))
#
# Set workflow variables
#
Expand Down Expand Up @@ -255,7 +211,6 @@ def main
Builtins.y2milestone("y2confirm found and confirm turned on")
end


return :abort if UI.PollInput == :abort && Popup.ConfirmAbort(:painless)

# moved here from autoinit for fate #301193
Expand All @@ -282,6 +237,10 @@ def main
autosetup_security
return :abort if UI.PollInput == :abort && Popup.ConfirmAbort(:painless)

#
# Partitioning and Storage
#//////////////////////////////////////////////////////////////////////

Progress.NextStage

probe_storage if modified_profile? || dasd_or_zfcp
Expand Down
37 changes: 0 additions & 37 deletions src/clients/inst_autosetup_upgrade.rb
Expand Up @@ -45,7 +45,6 @@ def main
)
@progress_stages = [
_("Configure General Settings "),
_("Execute pre-install user scripts"),
_("Set up language"),
_("Registration"),
_("Configure Software selections"),
Expand All @@ -55,7 +54,6 @@ def main

@progress_descriptions = [
_("Configuring general settings..."),
_("Executing pre-install user scripts..."),
_("Setting up language..."),
_("Registering the system..."),
_("Configuring Software selections..."),
Expand All @@ -73,47 +71,12 @@ def main
)


return :abort if Popup.ConfirmAbort(:painless) if UI.PollInput == :abort
Progress.NextStage


# configure general settings





return :abort if Popup.ConfirmAbort(:painless) if UI.PollInput == :abort

Progress.NextStage

# Pre-Scripts
AutoinstScripts.Import(Ops.get_map(Profile.current, "scripts", {}))
AutoinstScripts.Write("pre-scripts", false)

# Reread Profile in case it was modified in pre-script
# User has to create the new profile in a pre-defined
# location for easy processing in pre-script.

return :abort if readModified == :abort

#
# Partitioning and Storage
#//////////////////////////////////////////////////////////////////////

@modified = true
begin
askDialog
# Pre-Scripts
AutoinstScripts.Import(Ops.get_map(Profile.current, "scripts", {}))
AutoinstScripts.Write("pre-scripts", false)
@ret2 = readModified
return :abort if @ret2 == :abort
@modified = false if @ret2 == :not_found
end while @modified == true

# reimport scripts, for the case <ask> has changed them
AutoinstScripts.Import(Ops.get_map(Profile.current, "scripts", {}))
#
# Set workflow variables
#
Expand Down

0 comments on commit ec2e34b

Please sign in to comment.