Skip to content

Commit

Permalink
Merge 896b348 into 115707b
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Jul 10, 2020
2 parents 115707b + 896b348 commit c56c32c
Show file tree
Hide file tree
Showing 16 changed files with 1,051 additions and 410 deletions.
15 changes: 15 additions & 0 deletions package/autoyast2.changes
@@ -1,3 +1,18 @@
-------------------------------------------------------------------
Fri Jul 10 08:20:20 UTC 2020 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

- Fix 'autoyast' and 'clone_system' command line interfaces
(bsc#1172548):
- autoyast: add a list-modules command to list all known modules.
- autoyast: display the correct client name in the help text.
- autoyast: 'file' and 'module' command are now equivalent.
Both of them support setting 'filename' and 'modname'
arguments.
- clone_system: add a 'filename' option instead of always using
'/root/autoinst.xml'.
- clone_system: move the logic to find the clonable modules
- 4.2.41

-------------------------------------------------------------------
Wed Jul 8 23:41:41 UTC 2020 - Knut Anderssen <kanderssen@suse.com>

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

Name: autoyast2
Version: 4.2.40
Version: 4.2.41
Release: 0
Summary: YaST2 - Automated Installation
License: GPL-2.0-only
Expand Down Expand Up @@ -181,7 +181,6 @@ done
%{yast_yncludedir}/autoinstall/dialogs.rb
%{yast_yncludedir}/autoinstall/script_dialogs.rb
%{yast_yncludedir}/autoinstall/general_dialogs.rb
%{yast_yncludedir}/autoinstall/wizards.rb
%{yast_yncludedir}/autoinstall/helps.rb
%dir %{yast_schemadir}
%dir %{yast_schemadir}/autoyast
Expand Down
140 changes: 2 additions & 138 deletions src/clients/autoyast.rb
@@ -1,142 +1,6 @@
# File: clients/autoyast.ycp
# Summary: Main file for client call
# Authors: Anas Nashif <nashif@suse.de>
#
# $Id$
module Yast
class AutoyastClient < Client
def main
Yast.import "Pkg"
Yast.import "UI"
textdomain "autoinst"
Yast.import "Wizard"
Yast.import "Mode"
Mode.SetMode("autoinst_config")

Yast.import "Profile"
Yast.import "AutoinstConfig"
Yast.import "Y2ModuleConfig"
Yast.import "Label"
Yast.import "Sequencer"
Yast.import "Popup"
Yast.import "AddOnProduct"
Yast.import "CommandLine"
Yast.import "AutoInstall"

Yast.include self, "autoinstall/dialogs.rb"
Yast.include self, "autoinstall/conftree.rb"
Yast.include self, "autoinstall/wizards.rb"

if Builtins.size(Y2ModuleConfig.GroupMap) == 0
Wizard.CreateDialog
Popup.Error(_("Error while reading configuration data."))
Wizard.CloseDialog
return :abort
end

Pkg.CallbackImportGpgKey(
fun_ref(
AutoInstall.method(:callbackTrue_boolean_map_integer),
"boolean (map <string, any>, integer)"
)
)
Pkg.CallbackAcceptUnknownGpgKey(
fun_ref(
AutoInstall.method(:callbackTrue_boolean_string_string_integer),
"boolean (string, string, integer)"
)
)
Pkg.CallbackAcceptFileWithoutChecksum(
fun_ref(
AutoInstall.method(:callbackTrue_boolean_string),
"boolean (string)"
)
)
Pkg.CallbackAcceptUnsignedFile(
fun_ref(
AutoInstall.method(:callbackTrue_boolean_string_integer),
"boolean (string, integer)"
)
)

@cmdline = {
"id" => "autoyast2",
"help" => _("AutoYaST"),
"guihandler" => fun_ref(method(:AutoSequence), "any ()"),
"actions" => {
"file" => {
"handler" => fun_ref(
method(:openFile),
"boolean (map <string, string>)"
),
"help" => "file operations"
},
"module" => {
"handler" => fun_ref(
method(:runModule),
"boolean (map <string, string>)"
),
"help" => "module specific operations"
}
},
"options" => {
"filename" => { "type" => "string", "help" => "filename=XML_PROFILE" },
"modname" => { "type" => "string", "help" => "modname=AYAST_MODULE" }
},
"mappings" => { "file" => ["filename"], "module" => ["modname"] }
}

# command line options
# Init variables
@command = ""
@flags = []
@options = {}
@exit = ""
@l = []

@ret = nil
@ret = CommandLine.Run(@cmdline)

AddOnProduct.CleanModeConfigSources
:exit
end

def openFile(options)
options = deep_copy(options)
if !Profile.ReadXML(Ops.get(options, "filename", ""))
Popup.Error(
_(
"Error while parsing the control file.\n" \
"Check the log files for more details or fix the\n" \
"control file and try again.\n"
)
)
end
Popup.ShowFeedback(
_("Reading configuration data"),
_("This may take a while")
)
Builtins.foreach(Profile.ModuleMap) do |p, d|
# Set resource name, if not using default value
resource = Ops.get_string(d, "X-SuSE-YaST-AutoInstResource", "")
resource = p if resource == ""
Builtins.y2debug("resource: %1", resource)
module_auto = Ops.get_string(d, "X-SuSE-YaST-AutoInstClient", "none")
rd = Y2ModuleConfig.getResourceData(d, resource)
WFM.CallFunction(module_auto, ["Import", rd]) if !rd.nil?
end
Popup.ClearFeedback
AutoSequence()
true
end

def runModule(options)
options = deep_copy(options)
AutoinstConfig.runModule = Ops.get(options, "modname", "")
AutoSequence()
true
end
end
end

Yast::AutoyastClient.new.main
require "autoinstall/clients/autoyast"
Y2Autoinstallation::Clients::Autoyast.new.main
134 changes: 2 additions & 132 deletions src/clients/clone_system.rb
Expand Up @@ -3,136 +3,6 @@
# Author: Uwe Gansert <ug@suse.de>
# Summary: This client is clones some settings of the
# system.
#
# Changes: * initial - just do a simple clone
# $Id$
module Yast
class CloneSystemClient < Client
# FIXME: unify with conftree.rb
ALWAYS_CLONABLE_MODULES ||= ["software", "partitioning", "bootloader"].freeze

def main
Yast.import "AutoinstClone"
Yast.import "Profile"
Yast.import "XML"
Yast.import "Popup"
Yast.import "ProductControl"
Yast.import "CommandLine"
Yast.import "Y2ModuleConfig"
Yast.import "Mode"
Yast.import "FileUtils"
Yast.import "Report"
Yast.import "Installation"
Yast.import "PackageSystem"

textdomain "autoinst"

@moduleList = ""

if Mode.normal
if !PackageSystem.Installed("autoyast2")
ret = PackageSystem.InstallAll(["autoyast2"])
# The modules/clients has to be reloaded. So the export
# will be restarted.
if ret
SCR.Execute(
path(".target.bash"),
"touch #{Installation.restart_file}"
)
end
return
elsif FileUtils.Exists(Installation.restart_file)
SCR.Execute(path(".target.remove"), Installation.restart_file)
end
end

Builtins.foreach(Y2ModuleConfig.ModuleMap) do |def_resource, resourceMap|
clonable = resourceMap["X-SuSE-YaST-AutoInstClonable"] == "true"

if clonable || ALWAYS_CLONABLE_MODULES.include?(def_resource)
@moduleList << " " << def_resource
end
end

# if we get no argument or map of options we are not in command line
if [NilClass, Hash].any? { |c| WFM.Args.first.is_a?(c) }
params = WFM.Args.first || {}
doClone(params)
else
cmdline = {
"id" => "clone_system",
"help" => _(
"Client for creating an AutoYaST profile based on the currently running system"
),
"guihandler" => fun_ref(method(:GUI), "symbol ()"),
"actions" => {
"modules" => {
"handler" => fun_ref(
method(:doClone),
"boolean (map <string, any>)"
),
"help" => Builtins.sformat(_("known modules: %1"), @moduleList),
"example" => "modules clone=software,partitioning"
}
},
"options" => {
"clone" => {
"type" => "string",
"help" => _("comma separated list of modules to clone")
}
},
"mappings" => { "modules" => ["clone"] }
}

ret = CommandLine.Run(cmdline)
Builtins.y2debug("ret = %1", ret)

end
Builtins.y2milestone("----------------------------------------")
Builtins.y2milestone("clone_system finished")

nil
end

def GUI
Mode.SetUI("commandline")
CommandLine.Error(_("Empty parameter list"))
:dummy
end

def doClone(options)
target_path = options["target_path"] || "/root/autoinst.xml"

# Autoyast overwriting an already existing config file.
# The warning is only needed while calling "yast clone_system". It is not
# needed in the installation workflow where it will be checked by the file selection box
# directly. (bnc#888546)
if Mode.normal && FileUtils.Exists(target_path)
# TRANSLATORS: Warning that an already existing autoyast configuration file
# will be overwritten.
return false if !Popup.ContinueCancel(_("File %s exists! Really overwrite?") % target_path)
end

Popup.ShowFeedback(
_("Cloning the system..."),
# TRANSLATORS: %s is path where profile can be found
_("The resulting autoyast profile can be found in %s.") % target_path
)

AutoinstClone.additional = if Ops.get_string(options, "clone", "") != ""
Builtins.splitstring(
Ops.get_string(options, "clone", ""),
","
)
else
deep_copy(ProductControl.clone_modules)
end
AutoinstClone.Process
XML.YCPToXMLFile(:profile, Profile.current, target_path)
Popup.ClearFeedback
true
end
end
end

Yast::CloneSystemClient.new.main
require "autoinstall/clients/clone_system"
Y2Autoinstallation::Clients::CloneSystem.new.main
65 changes: 0 additions & 65 deletions src/include/autoinstall/wizards.rb

This file was deleted.

0 comments on commit c56c32c

Please sign in to comment.