diff --git a/.rubocop.yml b/.rubocop.yml index 778bf764f..ca633501b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,6 @@ # use the shared Yast defaults inherit_from: - - /usr/share/YaST2/data/devtools/data/rubocop-0.71.0_yast_style.yml + - /usr/share/YaST2/data/devtools/data/rubocop-1.24.1_yast_style.yml # this needs more testing if we can have frozen string literals Style/FrozenStringLiteralComment: @@ -10,46 +10,9 @@ Naming/FileName: Include: - "library/*/src/lib/**/*.rb" -# TODO: enable it, just ENOTIME -# Offense count: 21 -Lint/Loop: - Exclude: - - 'src/clients/files_auto.rb' - - 'src/clients/inst_autosetup.rb' - - 'src/clients/inst_autosetup_upgrade.rb' - - 'src/clients/report_auto.rb' - - 'src/clients/software_auto.rb' - - 'src/include/autoinstall/classes.rb' - - 'src/include/autoinstall/dialogs.rb' - - 'src/include/autoinstall/general_dialogs.rb' - - 'src/include/autoinstall/script_dialogs.rb' - - 'src/modules/Profile.rb' - - 'src/modules/ProfileLocation.rb' - -# TODO: enable it, just ENOTIME -# Offense count: 7 -Lint/ShadowingOuterLocalVariable: - Exclude: - - 'src/clients/inst_autoinit.rb' - - 'src/include/autoinstall/conftree.rb' - - 'src/include/autoinstall/general_dialogs.rb' - -# TODO: enable it, just ENOTIME -# Offense count: 27 -# Configuration parameters: AllowKeywordBlockArguments. -Lint/UnderscorePrefixedVariableName: - Exclude: - - 'src/clients/inst_autoconfigure.rb' - - 'src/clients/inst_autopost.rb' - - 'src/include/autoinstall/classes.rb' - - 'src/include/autoinstall/conftree.rb' - - 'src/modules/AutoInstallRules.rb' - - 'src/modules/Profile.rb' - - 'src/modules/Y2ModuleConfig.rb' - -# Offense count: 95 +# GeneralDialogs.AskDialog rules them all Metrics/AbcSize: - Max: 448 + Max: 455 # Offense count: 105 # Configuration parameters: CountComments, ExcludedMethods. @@ -70,9 +33,9 @@ Metrics/BlockNesting: Metrics/ClassLength: Max: 1000 -# Offense count: 82 +# GeneralDialogs.AskDialog rules them all Metrics/CyclomaticComplexity: - Max: 78 + Max: 86 # Offense count: 112 # Configuration parameters: CountComments, ExcludedMethods. @@ -82,7 +45,7 @@ Metrics/MethodLength: # Offense count: 12 # Configuration parameters: CountComments. Metrics/ModuleLength: - Max: 1062 + Max: 1063 # Offense count: 2 # Configuration parameters: CountKeywordArgs. @@ -110,7 +73,7 @@ Naming/MethodName: # TODO: enable it, just ENOTIME # Offense count: 16 # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. -Naming/UncommunicativeBlockParamName: +Naming/BlockParameterName: Exclude: - 'src/clients/clone_system.rb' - 'src/include/autoinstall/PartitionDialog.rb' @@ -124,7 +87,7 @@ Naming/UncommunicativeBlockParamName: # Offense count: 91 # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. # AllowedNames: io, id, to, by, on, in, at, ip, db -Naming/UncommunicativeMethodParamName: +Naming/MethodParameterName: Enabled: false # Offense count: 573 diff --git a/doc/profile_conversions.md b/doc/profile_conversions.md index 7802c82c6..c7bcf2fc4 100644 --- a/doc/profile_conversions.md +++ b/doc/profile_conversions.md @@ -37,7 +37,7 @@ data types to the old ones. This is useful if you want to use a new profile in an old system (SLE15-SP2 and older). The old AutoYaST cannot read the new data types and it would fail. -The [`old_types.xslt`](../xslt/old_types.xslt) file converts the short +The [old_types.xslt](../xslt/old_types.xslt) file converts the short attributes `t="boolean"` to long attributes `config:type="boolean"`. ```shell diff --git a/src/clients/autoinst_scripts1_finish.rb b/src/clients/autoinst_scripts1_finish.rb index f4582f062..7ecfc31d6 100644 --- a/src/clients/autoinst_scripts1_finish.rb +++ b/src/clients/autoinst_scripts1_finish.rb @@ -36,7 +36,8 @@ def main Builtins.y2debug("func=%1", @func) Builtins.y2debug("param=%1", @param) - if @func == "Info" + case @func + when "Info" return { "steps" => 1, # progress step title @@ -45,7 +46,7 @@ def main ), "when" => [:autoinst, :autoupg] } - elsif @func == "Write" + when "Write" AutoinstScripts.Write("chroot-scripts", false) AutoInstall.Finish(Installation.destdir) else diff --git a/src/clients/autoinst_scripts2_finish.rb b/src/clients/autoinst_scripts2_finish.rb index df6b80fb3..1b306399d 100644 --- a/src/clients/autoinst_scripts2_finish.rb +++ b/src/clients/autoinst_scripts2_finish.rb @@ -35,7 +35,8 @@ def main Builtins.y2debug("func=%1", @func) Builtins.y2debug("param=%1", @param) - if @func == "Info" + case @func + when "Info" return { "steps" => 1, # progress step title @@ -44,7 +45,7 @@ def main ), "when" => [:autoinst, :autoupg] } - elsif @func == "Write" + when "Write" # Calling chroot scripts AutoinstScripts.Write("chroot-scripts", true) diff --git a/src/clients/classes_auto.rb b/src/clients/classes_auto.rb index ca68fdee1..46d7c2480 100644 --- a/src/clients/classes_auto.rb +++ b/src/clients/classes_auto.rb @@ -35,7 +35,8 @@ def main Builtins.y2debug("func=%1", @func) Builtins.y2debug("param=%1", @param) - if @func == "Import" + case @func + when "Import" @ret = AutoinstClass.Import( Convert.convert(@param, from: "list", to: "list ") ) @@ -46,18 +47,18 @@ def main @ret = false end # create a summary - elsif @func == "Summary" + when "Summary" @ret = AutoinstClass.Summary - elsif @func == "Reset" + when "Reset" AutoinstClass.Import([]) @ret = [] - elsif @func == "Change" + when "Change" Wizard.CreateDialog Wizard.SetDesktopIcon("general") @ret = classConfiguration Wizard.CloseDialog return deep_copy(@ret) - elsif @func == "Export" + when "Export" @ret = AutoinstClass.Export else Builtins.y2error("unknown function: %1", @func) diff --git a/src/clients/general_auto.rb b/src/clients/general_auto.rb index 5d6a6c608..c7b7ad527 100644 --- a/src/clients/general_auto.rb +++ b/src/clients/general_auto.rb @@ -35,22 +35,23 @@ def main Builtins.y2debug("func=%1", @func) Builtins.y2debug("param=%1", @param) - if @func == "Import" + case @func + when "Import" @ret = AutoinstGeneral.Import(@param) # create a summary - elsif @func == "Summary" + when "Summary" @ret = AutoinstGeneral.Summary - elsif @func == "GetModified" + when "GetModified" @ret = AutoinstGeneral.GetModified - elsif @func == "SetModified" + when "SetModified" AutoinstGeneral.SetModified - elsif @func == "Reset" + when "Reset" AutoinstGeneral.Import({}) @ret = {} - elsif @func == "Change" + when "Change" @ret = generalSequence return deep_copy(@ret) - elsif @func == "Export" + when "Export" @ret = AutoinstGeneral.Export else Builtins.y2error("unknown function: %1", @func) diff --git a/src/clients/inst_autoconfigure.rb b/src/clients/inst_autoconfigure.rb index e9cdc19a0..1e2c482f8 100644 --- a/src/clients/inst_autoconfigure.rb +++ b/src/clients/inst_autoconfigure.rb @@ -40,8 +40,8 @@ def main # Help text for last dialog of base installation @help_text = _( "

\n" \ - "Please wait while the system is being configured.\n" \ - "

" + "Please wait while the system is being configured.\n" \ + "

" ) log.info "Profile general,mode:#{AutoinstGeneral.mode.inspect}" @@ -193,7 +193,7 @@ def main logStep(_("Restarting all running services")) @cmd = "systemctl --type=service list-units | grep \" running \"" @out = Convert.to_map(SCR.Execute(path(".target.bash_output"), @cmd)) - @sl = Ops.get_string(@out, "stdout", "").split("\n").collect { |c| c.split(" ").first } + @sl = Ops.get_string(@out, "stdout", "").split("\n").collect { |c| c.split.first } Builtins.y2milestone("running services \"%1\"", @sl) # Filtering out all services which must not to be restarted diff --git a/src/clients/inst_autopost.rb b/src/clients/inst_autopost.rb index c9df3657b..f9cd8db06 100644 --- a/src/clients/inst_autopost.rb +++ b/src/clients/inst_autopost.rb @@ -125,12 +125,11 @@ def dirname(filePath) Ops.subtract(Builtins.size(pathComponents), 1), "" ) - ret = Builtins.substring( + Builtins.substring( filePath, 0, Ops.subtract(Builtins.size(filePath), Builtins.size(last)) ) - ret end end end diff --git a/src/clients/inst_store_upgrade_software.rb b/src/clients/inst_store_upgrade_software.rb index 8b8c3ec19..1931bc318 100644 --- a/src/clients/inst_store_upgrade_software.rb +++ b/src/clients/inst_store_upgrade_software.rb @@ -18,16 +18,15 @@ def main p.transact_by == :app_high end - # note: does not matter if it is installed or to be installed, the resulting + # NOTE: does not matter if it is installed or to be installed, the resulting # state is the same; similar for uninstallation (valid for all packages, patterns # and products @patterns_to_remove = [] @patterns_to_install = @patterns.map do |p| - if p.status == :selected || - p.status == :installed + case p.status + when :selected, :installed next p.name - elsif p.status == :removed || - p.status == :available + when :removed, :available @patterns_to_remove << p.name end @@ -56,11 +55,10 @@ def main @products_to_remove = [] @products_to_install = @products.map do |p| - if p.status == :selected || - p.status == :installed + case p.status + when :selected, :installed next p.name - elsif p.status == :removed || - p.status == :available + when :removed, :available @products_to_remove << p.name end diff --git a/src/clients/storage_auto.rb b/src/clients/storage_auto.rb index 81f2b7009..8a8b42b88 100644 --- a/src/clients/storage_auto.rb +++ b/src/clients/storage_auto.rb @@ -40,7 +40,8 @@ def main Builtins.y2debug("param=%1", @param) # Import Data - if @func == "Import" + case @func + when "Import" @ret = AutoinstPartPlan.Import( Convert.convert(@param, from: "list", to: "list ") ) @@ -51,29 +52,29 @@ def main @ret = false end Builtins.y2milestone("Import: %1", @param) - elsif @func == "Read" + when "Read" @ret = AutoinstPartPlan.Read # Create a summary - elsif @func == "Summary" + when "Summary" @ret = AutoinstPartPlan.Summary # Reset configuration - elsif @func == "Reset" + when "Reset" AutoinstPartPlan.Reset @ret = [] # Change configuration (run AutoSequence) - elsif @func == "Change" + when "Change" storage_dialog = build_storage_dialog @ret = storage_dialog.run # After succesfully editing the storage settings, import the result as # the new partition plan. AutoinstPartPlan.Import(storage_dialog.partitioning) if @ret == :next # Return actual state - elsif @func == "Export" + when "Export" @ret = AutoinstPartPlan.Export # Return true if modified - elsif @func == "GetModified" + when "GetModified" @ret = AutoinstPartPlan.GetModified - elsif @func == "SetModified" + when "SetModified" AutoinstPartPlan.SetModified else Builtins.y2error("Unknown function: %1", @func) diff --git a/src/include/autoinstall/classes.rb b/src/include/autoinstall/classes.rb index 69021e71f..b7794d60d 100644 --- a/src/include/autoinstall/classes.rb +++ b/src/include/autoinstall/classes.rb @@ -16,9 +16,9 @@ def initialize_autoinstall_classes(_include_target) # XML_cleanup() # @return [Boolean] - def XML_cleanup(_in, out) + def XML_cleanup(input, out) # Note, inputs should be already valid, so exceptions is not handled here - ycpin = XML.XMLToYCPFile(_in) + ycpin = XML.XMLToYCPFile(input) Builtins.y2debug("Writing clean XML file to %1, YCP is (%2)", out, ycpin) XML.YCPToXMLFile(:profile, ycpin, out) end @@ -26,20 +26,20 @@ def XML_cleanup(_in, out) # class_dialog_contents() # @return [Yast::Term] def class_dialog_contents - classes = Builtins.maplist(AutoinstClass.Classes) do |_class| + classes = Builtins.maplist(AutoinstClass.Classes) do |klass| pathtoClass = Builtins.sformat( "%1/%2", AutoinstConfig.classDir, - Ops.get_string(_class, "name", "Unknown") + Ops.get_string(klass, "name", "Unknown") ) files_in_class = Convert.to_list( SCR.Read(path(".target.dir"), pathtoClass) ) - Builtins.y2milestone("class: %1", _class) + Builtins.y2milestone("class: %1", klass) i = Item( - Id(Ops.get_string(_class, "name", "Unknown")), - Ops.get_string(_class, "name", "No name"), - Ops.get_integer(_class, "order", 0), + Id(Ops.get_string(klass, "name", "Unknown")), + Ops.get_string(klass, "name", "No name"), + Ops.get_integer(klass, "order", 0), Builtins.size(files_in_class) ) deep_copy(i) @@ -76,14 +76,14 @@ def AddEditClasses(mode, name) Ops.get_string(c, "name", "") end - _class = (AutoinstClass.Classes || []).find { |c| c["name"] == name } - _class ||= {} + klass = (AutoinstClass.Classes || []).find { |c| c["name"] == name } + klass ||= {} tmp = Builtins.sformat( "%1", Ops.add(Builtins.size(AutoinstClass.Classes), 1) ) - order = Builtins.tointeger(Ops.get_string(_class, "order", tmp)) + order = Builtins.tointeger(Ops.get_string(klass, "order", tmp)) UI.OpenDialog( Opt(:decorated), @@ -96,7 +96,7 @@ def AddEditClasses(mode, name) TextEntry( Id(:name), _("Na&me"), - Ops.get_string(_class, "name", "") + Ops.get_string(klass, "name", "") ), IntField( Id(:order), @@ -110,7 +110,7 @@ def AddEditClasses(mode, name) Id(:description), Opt(:hstretch), _("Descri&ption:"), - Ops.get_string(_class, "description", "") + Ops.get_string(klass, "description", "") ), VSpacing(1), ButtonBox( @@ -123,7 +123,7 @@ def AddEditClasses(mode, name) ) UI.ChangeWidget(Id(:name), :Enabled, false) if mode == :edit ret = :none - begin + loop do ret = Convert.to_symbol(UI.UserInput) if ret == :save if Convert.to_string(UI.QueryWidget(Id(:name), :Value)) == "" @@ -172,7 +172,8 @@ def AddEditClasses(mode, name) end end end - end until ret == :save || ret == :cancel + break if ret == :save || ret == :cancel + end UI.CloseDialog @@ -193,7 +194,7 @@ def ManageClasses help, _( "

For example, you can define a class of configurations for\n" \ - "a specific department, group, or site in your company environment.

\n" + "a specific department, group, or site in your company environment.

\n" ) ) @@ -201,8 +202,8 @@ def ManageClasses help, _( "

The order (priority) defines the hierarchy of a class\n" \ - "and when it is merged when creating a control file.\n" \ - "

\n" + "and when it is merged when creating a control file.\n" \ + "

\n" ) ) @@ -213,18 +214,18 @@ def ManageClasses Wizard.HideAbortButton ret = nil - begin + loop do if Builtins.size(AutoinstClass.Classes) == 0 UI.ChangeWidget(Id(:edit), :Enabled, false) UI.ChangeWidget(Id(:delete), :Enabled, false) end - _class = Convert.to_string(UI.QueryWidget(Id(:table), :CurrentItem)) + klass = Convert.to_string(UI.QueryWidget(Id(:table), :CurrentItem)) cl = Builtins.filter(AutoinstClass.Classes) do |c| - Ops.get_string(c, "name", "") == _class + Ops.get_string(c, "name", "") == klass end selected_class = Ops.get_map(cl, 0, {}) - if !_class.nil? + if !klass.nil? UI.ChangeWidget( Id(:description), :Value, @@ -234,33 +235,35 @@ def ManageClasses ret = Convert.to_symbol(UI.UserInput) - if ret == :new + case ret + when :new AddEditClasses(ret, "") Wizard.SetContents(title, class_dialog_contents, help, true, true) - elsif ret == :edit - if _class.nil? + when :edit + if klass.nil? Popup.Message(_("Select at least one class\nto edit.\n")) next end - AddEditClasses(ret, _class) + AddEditClasses(ret, klass) Wizard.SetContents(title, class_dialog_contents, help, true, true) - elsif ret == :delete - if _class.nil? + when :delete + if klass.nil? Popup.Message(_("Select at least one class\nto delete.\n")) next end AutoinstClass.Classes = Builtins.filter(AutoinstClass.Classes) do |c| - Ops.get_string(c, "name", "") != _class + Ops.get_string(c, "name", "") != klass end AutoinstClass.deletedClasses = Builtins.add( AutoinstClass.deletedClasses, - _class + klass ) Wizard.SetContents(title, class_dialog_contents, help, true, true) end - end until ret == :back || ret == :next + break if ret == :back || ret == :next + end AutoinstClass.Save if ret == :next Wizard.CloseDialog @@ -272,8 +275,8 @@ def ManageClasses # @return [Fixnum] class order def GetClassOrder(name) order = 0 - Builtins.foreach(AutoinstClass.Classes) do |_class| - order = Ops.get_integer(_class, "order", 0) if Ops.get_string(_class, "name", "") == name + Builtins.foreach(AutoinstClass.Classes) do |klass| + order = Ops.get_integer(klass, "order", 0) if Ops.get_string(klass, "name", "") == name end order end @@ -396,11 +399,11 @@ def MergeDialog title = _("Merge Classes") profiles = {} - _Combo = VBox() + combo = VBox() AutoinstClass.Files Builtins.foreach(AutoinstClass.confs) do |prof| - _class = Ops.get_string(prof, "class", "Default") - ui_list = Ops.get(profiles, _class, []) + klass = Ops.get_string(prof, "class", "Default") + ui_list = Ops.get(profiles, klass, []) ui_list = Builtins.add(ui_list, Item(Id("none"), _("None"))) if Builtins.size(ui_list) == 0 ui_list = Builtins.add( ui_list, @@ -409,13 +412,13 @@ def MergeDialog Ops.get_string(prof, "name", "Unknown") ) ) - Ops.set(profiles, _class, ui_list) + Ops.set(profiles, klass, ui_list) end if Ops.greater_than(Builtins.size(profiles), 0) Builtins.foreach(profiles) do |k, v| - _Combo = Builtins.add( - _Combo, + combo = Builtins.add( + combo, HBox( HWeight( 50, @@ -426,13 +429,13 @@ def MergeDialog ) end else - _Combo = Left(Label(Id(:emptyclasses), _("No control files defined"))) + combo = Left(Label(Id(:emptyclasses), _("No control files defined"))) end contents = Top( Left( VBox( - _Combo, + combo, VSpacing(), RadioButtonGroup( Id(:rbg), @@ -459,10 +462,10 @@ def MergeDialog help = _( "

If you have defined and created \n" \ - "classes, you will be able to merge them using this interface to create\n" \ - "a new Profile, which will contain information from every class\n" \ - "depending on the priority (order) set when\n" \ - "creating the classes.

\n" + "classes, you will be able to merge them using this interface to create\n" \ + "a new Profile, which will contain information from every class\n" \ + "depending on the priority (order) set when\n" \ + "creating the classes.

\n" ) help = Ops.add( @@ -478,7 +481,7 @@ def MergeDialog Wizard.DisableNextButton ret = nil - begin + loop do ret = UI.UserInput base = Convert.to_symbol(UI.QueryWidget(Id(:rbg), :CurrentButton)) n = 0 @@ -537,7 +540,8 @@ def MergeDialog Wizard.EnableNextButton end - end until ret == :next || ret == :back + break if ret == :next || ret == :back + end Wizard.CloseDialog Convert.to_symbol(ret) @@ -547,7 +551,7 @@ def classConfiguration title = _("Class Configuration") help = _( "

Choose one or more of the listed classes to which the current control\n" \ - "file should belong.

\n" + "file should belong.

\n" ) AutoinstClass.Files @@ -555,8 +559,8 @@ def classConfiguration profiles = {} Builtins.foreach(AutoinstClass.confs) do |prof| - _class = Ops.get_string(prof, "class", "default") - ui_list = Ops.get(profiles, _class, []) + klass = Ops.get_string(prof, "class", "default") + ui_list = Ops.get(profiles, klass, []) ui_list = Builtins.add(ui_list, Item(Id("none"), _("None"))) if Builtins.size(ui_list) == 0 ui_list = Builtins.add( ui_list, @@ -565,23 +569,23 @@ def classConfiguration Ops.get_string(prof, "name", "Unknown") ) ) - Ops.set(profiles, _class, ui_list) + Ops.set(profiles, klass, ui_list) end - _Combo = VBox() + combo = VBox() if Ops.greater_than(Builtins.size(profiles), 0) Builtins.foreach(profiles) do |k, v| - _Combo = Builtins.add( - _Combo, + combo = Builtins.add( + combo, Left(ComboBox(Id(k), Opt(:hstretch, :autoShortcut), k, v)) ) end else - _Combo = Left(Label(Id(:emptyclasses), _("No profiles in this class"))) + combo = Left(Label(Id(:emptyclasses), _("No profiles in this class"))) end - contents = Top(Left(VBox(_Combo))) + contents = Top(Left(VBox(combo))) Wizard.SetContents(title, contents, help, true, true) @@ -590,7 +594,7 @@ def classConfiguration ret = nil _next = nil - begin + loop do ret = UI.UserInput n = 0 if ret == :next @@ -623,7 +627,8 @@ def classConfiguration Builtins.y2debug("Selected Profiles: %1", sorted_profiles) AutoinstClass.profile_conf = deep_copy(sorted_profiles) end - end until ret == :next || ret == :back + break if ret == :next || ret == :back + end Convert.to_symbol(ret) end end diff --git a/src/include/autoinstall/common.rb b/src/include/autoinstall/common.rb index 98000bb49..f50592499 100644 --- a/src/include/autoinstall/common.rb +++ b/src/include/autoinstall/common.rb @@ -65,20 +65,20 @@ def prepareStack def callDialogFunction(dialog, function) dialog = deep_copy(dialog) functionTerm = Ops.get(dialog, function) - if nil != functionTerm + if nil == functionTerm Builtins.y2milestone( - "calling function: '%1'->'%2'.", + "Function not found: '%1'->'%2'.", Ops.get_string(dialog, :type, "Unknown"), - functionTerm + function ) - # prepareStack(); - Builtins.eval(functionTerm) else Builtins.y2milestone( - "Function not found: '%1'->'%2'.", + "calling function: '%1'->'%2'.", Ops.get_string(dialog, :type, "Unknown"), - function + functionTerm ) + # prepareStack(); + Builtins.eval(functionTerm) end nil diff --git a/src/include/autoinstall/conftree.rb b/src/include/autoinstall/conftree.rb index e0052d09a..a0151de00 100644 --- a/src/include/autoinstall/conftree.rb +++ b/src/include/autoinstall/conftree.rb @@ -332,81 +332,81 @@ def configureModule(resource) # Sets the menus in the wizard. # @return [void] def menus - _Menu = [] - _Menu = Wizard.AddMenu(_Menu, _("&File"), "file-menu") - _Menu = Wizard.AddMenu(_Menu, _("&View"), "view-menu") - _Menu = Wizard.AddMenu(_Menu, _("&Classes"), "class-menu") - _Menu = Wizard.AddMenu(_Menu, _("&Tools"), "tools-menu") - - _Menu = Wizard.AddMenuEntry(_Menu, "file-menu", _("&New"), "menu_new") - _Menu = Wizard.AddMenuEntry(_Menu, "file-menu", _("&Open"), "menu_open") - _Menu = Wizard.AddMenuEntry(_Menu, "file-menu", _("&Save"), "menu_save") - _Menu = Wizard.AddMenuEntry( - _Menu, + menu = [] + menu = Wizard.AddMenu(menu, _("&File"), "file-menu") + menu = Wizard.AddMenu(menu, _("&View"), "view-menu") + menu = Wizard.AddMenu(menu, _("&Classes"), "class-menu") + menu = Wizard.AddMenu(menu, _("&Tools"), "tools-menu") + + menu = Wizard.AddMenuEntry(menu, "file-menu", _("&New"), "menu_new") + menu = Wizard.AddMenuEntry(menu, "file-menu", _("&Open"), "menu_open") + menu = Wizard.AddMenuEntry(menu, "file-menu", _("&Save"), "menu_save") + menu = Wizard.AddMenuEntry( + menu, "file-menu", _("Save &As"), "menu_saveas" ) - _Menu = Wizard.AddMenuEntry( - _Menu, + menu = Wizard.AddMenuEntry( + menu, "file-menu", _("Settin&gs"), "menu_settings" ) - _Menu = Wizard.AddMenuEntry( - _Menu, + menu = Wizard.AddMenuEntry( + menu, "file-menu", AutoinstConfig.ProfileEncrypted ? _("Change to Decrypted") : _("Change to Encrypted"), "change_encryption" ) - _Menu = Wizard.AddMenuEntry( - _Menu, + menu = Wizard.AddMenuEntry( + menu, "file-menu", _("Apply Profile to this System"), "write_to_system" ) - _Menu = Wizard.AddMenuEntry(_Menu, "file-menu", _("E&xit"), "menu_exit") - _Menu = if @show_source == true + menu = Wizard.AddMenuEntry(menu, "file-menu", _("E&xit"), "menu_exit") + menu = if @show_source == true Wizard.AddMenuEntry( - _Menu, + menu, "view-menu", _("Configu&ration Tree"), "menu_tree" ) else Wizard.AddMenuEntry( - _Menu, + menu, "view-menu", _("So&urce"), "menu_source" ) end - _Menu = Wizard.AddMenuEntry( - _Menu, + menu = Wizard.AddMenuEntry( + menu, "class-menu", _("Cla&sses"), "menu_classes" ) - _Menu = Wizard.AddMenuEntry( - _Menu, + menu = Wizard.AddMenuEntry( + menu, "class-menu", _("Me&rge Classes"), "menu_merge" ) - _Menu = Wizard.AddMenuEntry( - _Menu, + menu = Wizard.AddMenuEntry( + menu, "tools-menu", _("Create Reference Pro&file"), "menu_clone" ) - _Menu = Wizard.AddMenuEntry( - _Menu, + menu = Wizard.AddMenuEntry( + menu, "tools-menu", _("Check &Validity of Profile"), "menu_valid" ) - Wizard.CreateMenu(_Menu) + Wizard.CreateMenu(menu) nil end @@ -458,26 +458,27 @@ def ShowSource # # @return [Symbol] def MainDialog - _Icons = {} - Ops.set(_Icons, "Net_advanced", "network_advanced") + icons = {} + Ops.set(icons, "Net_advanced", "network_advanced") ret = nil currentGroup = "System" currentModule = "general" loop do - if AutoinstConfig.runModule != "" - ret = :configure - setModule(AutoinstConfig.runModule) - else + if AutoinstConfig.runModule == "" event = UI.WaitForEvent ret = Ops.get(event, "ID") + else + ret = :configure + setModule(AutoinstConfig.runModule) end AutoinstConfig.runModule = "" - if ret == :groups + case ret + when :groups updateModules - elsif ret == :modules + when :modules updateDetails - elsif ret == :configure + when :configure currentGroup = getGroup currentModule = getModule Builtins.y2debug("configure module: %1", currentModule) @@ -490,7 +491,7 @@ def MainDialog menus CreateDialog(currentGroup, currentModule) end - elsif ret == :reset + when :reset Profile.prepare = true Builtins.y2debug("reset") currentGroup = getGroup @@ -501,7 +502,7 @@ def MainDialog Builtins.y2debug("resetModule ret : %1", configret) CreateDialog(currentGroup, currentModule) end - elsif ret == :writeNow + when :writeNow modulename = getModule if modulename != "" registry = Y2Autoinstallation::Entries::Registry.instance @@ -510,7 +511,7 @@ def MainDialog Builtins.sformat( _( "Do you really want to apply the settings of the module '%1' " \ - "to your current system?" + "to your current system?" ), modulename ) @@ -524,7 +525,7 @@ def MainDialog Mode.SetMode(oldMode) end end - elsif ret == :read + when :read currentGroup = getGroup currentModule = getModule resetModule(currentModule) @@ -536,13 +537,13 @@ def MainDialog # otherwise we have to rebuild the complete wizard CreateDialog(currentGroup, currentModule) end - elsif ret == "menu_tree" # source -> tree + when "menu_tree" # source -> tree Builtins.y2debug("change to tree") @show_source = false Wizard.DeleteMenus # FIXME: sucks sucks sucks sucks sucks menus CreateDialog(currentGroup, currentModule) - elsif ret == "menu_open" # OPEN + when "menu_open" # OPEN filename = UI.AskForExistingFile( AutoinstConfig.Repository, "*", @@ -595,13 +596,13 @@ def MainDialog true ) Wizard.SetTitleIcon( - Ops.get_string(_Icons, group, Builtins.tolower(group)) + Ops.get_string(icons, group, Builtins.tolower(group)) ) updateButtons(modulename) end end ret = :menu_open - elsif ret == "menu_source" # Show SOURCE + when "menu_source" # Show SOURCE # save previously selected group and module, # so we can restore them afterwards @show_source = true @@ -611,17 +612,17 @@ def MainDialog currentModule = getModule ShowSource() ret = :menu_source - elsif ret == "menu_save" # SAVE + when "menu_save" # SAVE if AutoinstConfig.currentFile == "" filename = UI.AskForSaveFileName( AutoinstConfig.Repository, "*", _("Save as...") ) - if !filename.nil? - AutoinstConfig.currentFile = Convert.to_string(filename) - else + if filename.nil? next + else + AutoinstConfig.currentFile = Convert.to_string(filename) end end @@ -637,10 +638,10 @@ def MainDialog Popup.Warning(_("An error occurred while saving the file.")) end ret = :menu_save - elsif ret == "menu_saveas" # SAVE AS + when "menu_saveas" # SAVE AS SaveAs() ret = :menu_saveas - elsif ret == "menu_new" # NEW + when "menu_new" # NEW Profile.Reset registry = Y2Autoinstallation::Entries::Registry.instance registry.descriptions.each { |d| resetModule(d.resource_name) } @@ -657,12 +658,12 @@ def MainDialog ) updateButtons(module_name) ret = :menu_new - elsif ret == "change_encryption" + when "change_encryption" AutoinstConfig.ProfileEncrypted = !AutoinstConfig.ProfileEncrypted AutoinstConfig.ProfilePassword = "" Wizard.DeleteMenus # FIXME: sucks sucks sucks sucks sucks menus - elsif ret == "write_to_system" + when "write_to_system" if Popup.YesNo( _( "Do you really want to apply the settings of the profile to your current system?" @@ -695,7 +696,7 @@ def MainDialog Mode.SetMode(oldMode) Stage.Set(oldStage) end - elsif ret == "menu_exit" || :cancel == ret # EXIT + when "menu_exit", :cancel # EXIT ret = :menu_exit if Profile.changed current = if AutoinstConfig.currentFile == "" diff --git a/src/include/autoinstall/dialogs.rb b/src/include/autoinstall/dialogs.rb index 9dfed8f82..ad6896799 100644 --- a/src/include/autoinstall/dialogs.rb +++ b/src/include/autoinstall/dialogs.rb @@ -58,16 +58,16 @@ def Settings help = _( "

\n" \ - "Enter the directory where all control files should be stored in\n" \ - "the Repository field.

" + "Enter the directory where all control files should be stored in\n" \ + "the Repository field.

" ) help = Ops.add( help, _( "

If you are using the classes feature\n" \ - "of Autoyast, also enter the class directory. This is where\n" \ - "all class files are stored.

\n" + "of Autoyast, also enter the class directory. This is where\n" \ + "all class files are stored.

\n" ) ) @@ -78,27 +78,28 @@ def Settings changed = false ret = :none - begin + loop do ret = Convert.to_symbol(UI.UserInput) new_rep = Convert.to_string(UI.QueryWidget(Id(:repository), :Value)) new_classdir = Convert.to_string(UI.QueryWidget(Id(:classdir), :Value)) - if ret == :opendir + case ret + when :opendir new_rep = UI.AskForExistingDirectory( AutoinstConfig.Repository, _("Select Directory") ) UI.ChangeWidget(Id(:repository), :Value, new_rep) if new_rep != "" next - elsif ret == :openclassdir + when :openclassdir new_classdir = UI.AskForExistingDirectory( AutoinstConfig.classDir, _("Select Directory") ) UI.ChangeWidget(Id(:classdir), :Value, new_classdir) if new_classdir != "" next - elsif ret == :next + when :next if AutoinstConfig.Repository != new_rep changed = true AutoinstConfig.Repository = new_rep @@ -109,7 +110,8 @@ def Settings AutoinstClass.classDirChanged(new_classdir) end end - end until ret == :back || ret == :next + break if ret == :back || ret == :next + end Wizard.RestoreScreenShotName AutoinstConfig.Save if changed @@ -140,9 +142,9 @@ def checkFileName(name) def invalidFileName _( "Invalid file name.\n" \ - "Names can only contain letters, numbers, and underscore,\n" \ - "must begin with letter, and must be\n" \ - "127 characters long or less.\n" + "Names can only contain letters, numbers, and underscore,\n" \ + "must begin with letter, and must be\n" \ + "127 characters long or less.\n" ) end @@ -176,9 +178,10 @@ def NewFileName(caption, textentry) ret = nil loop do ret = UI.UserInput - if ret == :cancel + case ret + when :cancel break - elsif ret == :ok + when :ok f = Convert.to_string(UI.QueryWidget(Id(:newname), :Value)) if checkFileName(f) != 0 || f == "" Popup.Error(invalidFileName) @@ -220,7 +223,7 @@ def cloneSystem Wizard.SetNextButton(:next, Label.CreateButton) ret = :none - begin + loop do ret = Convert.to_symbol(UI.UserInput) if ret == :next AutoinstClone.additional = Convert.convert( @@ -236,7 +239,8 @@ def cloneSystem Profile.changed = true Popup.ClearFeedback end - end until ret == :next || ret == :back + break if ret == :next || ret == :back + end Wizard.CloseDialog ret end @@ -319,11 +323,11 @@ def ValidDialog summary = Ops.add( summary, if Ops.get_integer(o, "exit", 1) != 0 || - Ops.get_string(i, 2, "") == "jing sucks" && + (Ops.get_string(i, 2, "") == "jing sucks" && Ops.greater_than( Builtins.size(Ops.get_string(o, "stderr", "")), 0 - ) + )) html_ko else html_ok @@ -400,9 +404,8 @@ def ValidDialog ret = nil loop do ret = UI.UserInput - if ret == :next || ret == :back - break - elsif ret == :abort + case ret + when :next, :back, :abort break end end diff --git a/src/include/autoinstall/general_dialogs.rb b/src/include/autoinstall/general_dialogs.rb index 236ae4106..ed05bfd8c 100644 --- a/src/include/autoinstall/general_dialogs.rb +++ b/src/include/autoinstall/general_dialogs.rb @@ -133,30 +133,30 @@ def ModeDialog help_text = _( "

\n" \ - "The options in this dialog control the behavior of the AutoYaST during\n" \ - "automatic installation.\n" \ - "

\n" + "The options in this dialog control the behavior of the AutoYaST during\n" \ + "automatic installation.\n" \ + "

\n" ) help_text = Ops.add( help_text, _( "

\n" \ - "The installation confirmation option is selected by default\n" \ - "to avoid unwanted installation. It stops the system\n" \ - "during installation and shows a summary of requested operations in the\n" \ - "usual proposal screen. Uncheck this option to install " \ - "automatically without interruption.\n" \ - "

\n" + "The installation confirmation option is selected by default\n" \ + "to avoid unwanted installation. It stops the system\n" \ + "during installation and shows a summary of requested operations in the\n" \ + "usual proposal screen. Uncheck this option to install " \ + "automatically without interruption.\n" \ + "

\n" ) ) help_text = Ops.add( help_text, _( "

\n" \ - "If you turn off the second stage of AutoYaST, the " \ - "installation continues in manual mode\n" \ - "after the first reboot (after package installation).\n" \ - "

\n" + "If you turn off the second stage of AutoYaST, the " \ + "installation continues in manual mode\n" \ + "after the first reboot (after package installation).\n" \ + "

\n" ) ) @@ -164,8 +164,8 @@ def ModeDialog help_text, _( "

\n" \ - "For signature handling, read the AutoYaST documentation.\n" \ - "

\n" + "For signature handling, read the AutoYaST documentation.\n" \ + "

\n" ) ) @@ -175,7 +175,7 @@ def ModeDialog Wizard.SetNextButton(:next, Label.NextButton) ret = nil - begin + loop do ret = UI.UserInput if ret == :next confirm = Convert.to_boolean(UI.QueryWidget(Id(:confirm), :Value)) @@ -239,7 +239,8 @@ def ModeDialog ) AutoinstGeneral.signature_handling = deep_copy(signature_handling) end - end until ret == :next || ret == :back || ret == :cancel + break if ret == :next || ret == :back || ret == :cancel + end Convert.to_symbol(ret) end @@ -376,14 +377,15 @@ def newQuestion(stage, dialog, askList, title, defaultValues) UI.ChangeWidget(Id(:selection), :Enabled, false) UI.ChangeWidget(Id(:password), :Enabled, false) - if Ops.get_string(defaultValues, "type", "text") == "text" + case Ops.get_string(defaultValues, "type", "text") + when "text" UI.ChangeWidget(Id(:password), :Enabled, true) - elsif Ops.get_string(defaultValues, "type", "text") == "symbol" + when "symbol" UI.ChangeWidget(Id(:selLabel), :Enabled, true) UI.ChangeWidget(Id(:selValue), :Enabled, true) UI.ChangeWidget(Id(:selection), :Enabled, true) end - begin + loop do if Builtins.size( Convert.to_list(UI.QueryWidget(Id(:selection), :Items)) ) == 0 @@ -402,28 +404,29 @@ def newQuestion(stage, dialog, askList, title, defaultValues) UI.ChangeWidget(Id(:addSelection), :Enabled, true) end ret = Convert.to_symbol(UI.UserInput) - if ret == :addSelection + case ret + when :addSelection label = Convert.to_string(UI.QueryWidget(Id(:selLabel), :Value)) val = Convert.to_string(UI.QueryWidget(Id(:selValue), :Value)) selection = Builtins.add(selection, Item(Id(selId), label, val)) selId = Ops.add(selId, 1) UI.ChangeWidget(Id(:selection), :Items, selection) - elsif ret == :t_symbol + when :t_symbol UI.ChangeWidget(Id(:selLabel), :Enabled, true) UI.ChangeWidget(Id(:selValue), :Enabled, true) UI.ChangeWidget(Id(:selection), :Enabled, true) UI.ChangeWidget(Id(:password), :Enabled, false) - elsif ret == :t_text + when :t_text UI.ChangeWidget(Id(:selLabel), :Enabled, false) UI.ChangeWidget(Id(:selValue), :Enabled, false) UI.ChangeWidget(Id(:selection), :Enabled, false) UI.ChangeWidget(Id(:password), :Enabled, true) - elsif ret == :t_boolean || ret == :t_integer + when :t_boolean, :t_integer UI.ChangeWidget(Id(:selLabel), :Enabled, false) UI.ChangeWidget(Id(:selValue), :Enabled, false) UI.ChangeWidget(Id(:selection), :Enabled, false) UI.ChangeWidget(Id(:password), :Enabled, false) - elsif ret == :delSelection + when :delSelection currSelId = Convert.to_integer( UI.QueryWidget(Id(:selection), :CurrentItem) ) @@ -432,7 +435,7 @@ def newQuestion(stage, dialog, askList, title, defaultValues) Ops.get_term(l, 0) { Id(-1) } != Id(currSelId) end UI.ChangeWidget(Id(:selection), :Items, selection) - elsif ret == :ok + when :ok max = -1 Builtins.foreach(askList) do |m| if Ops.get_string(m, "stage", "initial") == stage && @@ -469,11 +472,12 @@ def newQuestion(stage, dialog, askList, title, defaultValues) Convert.to_integer(UI.QueryWidget(Id(:timeout), :Value)) ) end - if Convert.to_symbol(UI.QueryWidget(Id(:type), :CurrentButton)) == :t_symbol + case Convert.to_symbol(UI.QueryWidget(Id(:type), :CurrentButton)) + when :t_symbol Ops.set(newVal, "type", "symbol") - elsif Convert.to_symbol(UI.QueryWidget(Id(:type), :CurrentButton)) == :t_boolean + when :t_boolean Ops.set(newVal, "type", "boolean") - elsif Convert.to_symbol(UI.QueryWidget(Id(:type), :CurrentButton)) == :t_integer + when :t_integer Ops.set(newVal, "type", "integer") end if Convert.to_string(UI.QueryWidget(Id(:path), :Value)) != "" @@ -526,7 +530,8 @@ def newQuestion(stage, dialog, askList, title, defaultValues) end end end - end until ret == :abort || ret == :ok + break if ret == :abort || ret == :ok + end UI.CloseDialog deep_copy(askList) @@ -571,11 +576,11 @@ def askDialog Ops.get_integer(x, "dialog", -2), Ops.get_integer(y, "dialog", -1) ) || - Ops.get_integer(x, "dialog", -2) == Ops.get_integer(y, "dialog", -1) && + (Ops.get_integer(x, "dialog", -2) == Ops.get_integer(y, "dialog", -1) && Ops.less_than( Ops.get_integer(x, "element", -2), Ops.get_integer(y, "element", -1) - ) + )) end done = { "initial" => [] } Builtins.foreach(askList) do |m| @@ -713,7 +718,7 @@ def askDialog ret = nil dialog_id = -1 element_id = -1 - begin + loop do if Builtins.size(Convert.to_list(UI.QueryWidget(Id(:dialogs), :Items))) == 0 UI.ChangeWidget(Id(:addQuestion), :Enabled, false) UI.ChangeWidget(Id(:editQuestion), :Enabled, false) @@ -766,7 +771,8 @@ def askDialog end deep_copy(dialog) end - if ret == :addQuestion + case ret + when :addQuestion l = Builtins.argsof( Ops.get( dialogs, @@ -781,7 +787,7 @@ def askDialog Ops.get_string(l, 1, ""), {} ) - elsif ret == :editQuestion + when :editQuestion m = {} Builtins.foreach(askList) do |dummy| if Ops.get_integer(dummy, "dialog", -1) == @@ -807,7 +813,7 @@ def askDialog Ops.get_string(l, 1, ""), m ) - elsif ret == :deleteQuestion + when :deleteQuestion dialog_id = Convert.to_integer( UI.QueryWidget(Id(:dialogs), :CurrentItem) ) @@ -818,14 +824,14 @@ def askDialog !(Ops.get_integer(dialog, "dialog", -1) == dialog_id && Ops.get_integer(dialog, "element", -1) == element_id) end - elsif ret == :deleteDialog + when :deleteDialog dialog_id = Convert.to_integer( UI.QueryWidget(Id(:dialogs), :CurrentItem) ) askList = Builtins.filter(askList) do |dialog| Ops.get_integer(dialog, "dialog", -1) != dialog_id end - elsif ret == :applyDialog + when :applyDialog askList = Builtins.maplist(askList) do |d3| if Ops.get_integer(d3, "dialog", -1) == Convert.to_integer(UI.QueryWidget(Id(:dialogs), :CurrentItem)) && @@ -844,7 +850,7 @@ def askDialog end deep_copy(d3) end - elsif ret == :dialogUp + when :dialogUp dialog_id = Convert.to_integer( UI.QueryWidget(Id(:dialogs), :CurrentItem) ) @@ -871,7 +877,7 @@ def askDialog deep_copy(dialog) end UI.ChangeWidget(Id(:dialogs), :CurrentItem, upperDialog) - elsif ret == :dialogDown + when :dialogDown dialog_id = Convert.to_integer( UI.QueryWidget(Id(:dialogs), :CurrentItem) ) @@ -896,7 +902,7 @@ def askDialog deep_copy(dialog) end UI.ChangeWidget(Id(:dialogs), :CurrentItem, lowerDialog) - elsif ret == :questionUp + when :questionUp dialog_id = Convert.to_integer( UI.QueryWidget(Id(:dialogs), :CurrentItem) ) @@ -927,7 +933,7 @@ def askDialog end deep_copy(dialog) end - elsif ret == :questionDown + when :questionDown dialog_id = Convert.to_integer( UI.QueryWidget(Id(:dialogs), :CurrentItem) ) @@ -960,12 +966,12 @@ def askDialog end deep_copy(dialog) end - elsif ret == :addDialog + when :addDialog max = -1 - Builtins.foreach(askList) do |m| - if Ops.get_string(m, "stage", "initial") == stage && - Ops.greater_than(Ops.get_integer(m, "dialog", 0), max) - max = Ops.get_integer(m, "dialog", 0) + Builtins.foreach(askList) do |ask_item| + if Ops.get_string(ask_item, "stage", "initial") == stage && + Ops.greater_than(Ops.get_integer(ask_item, "dialog", 0), max) + max = Ops.get_integer(ask_item, "dialog", 0) end end max = Ops.add(max, 1) @@ -987,25 +993,25 @@ def askDialog Ops.get_integer(x, "dialog", -2), Ops.get_integer(y, "dialog", -1) ) || - Ops.get_integer(x, "dialog", -2) == Ops.get_integer(y, "dialog", -1) && + (Ops.get_integer(x, "dialog", -2) == Ops.get_integer(y, "dialog", -1) && Ops.less_than( Ops.get_integer(x, "element", -2), Ops.get_integer(y, "element", -1) - ) + )) end dialogs = [] done2 = { "initial" => [], "cont" => [] } - Builtins.foreach(askList) do |m| - if Ops.get_string(m, "stage", "initial") == stage && + Builtins.foreach(askList) do |ask_item| + if Ops.get_string(ask_item, "stage", "initial") == stage && !Builtins.contains( Ops.get(done2, stage, []), - Ops.get_integer(m, "dialog", -1) + Ops.get_integer(ask_item, "dialog", -1) ) dialogs = Builtins.add( dialogs, Item( - Id(Ops.get_integer(m, "dialog", -1)), - Ops.get_string(m, "title", "") + Id(Ops.get_integer(ask_item, "dialog", -1)), + Ops.get_string(ask_item, "title", "") ) ) Ops.set( @@ -1013,7 +1019,7 @@ def askDialog stage, Builtins.add( Ops.get(done2, stage, []), - Ops.get_integer(m, "dialog", -1) + Ops.get_integer(ask_item, "dialog", -1) ) ) end @@ -1047,11 +1053,11 @@ def askDialog ) UI.ChangeWidget(Id(:hlp), :Value, Ops.get_string(d2, [0, "help"], "")) id_counter2 = 0 - Builtins.foreach(d2) do |m| - id_counter2 = Ops.get_integer(m, "element", id_counter2) + Builtins.foreach(d2) do |ask_item| + id_counter2 = Ops.get_integer(ask_item, "element", id_counter2) questions = Builtins.add( questions, - Item(Id(id_counter2), Ops.get_string(m, "question", "")) + Item(Id(id_counter2), Ops.get_string(ask_item, "question", "")) ) id_counter2 = Ops.add(id_counter2, 1) end @@ -1059,7 +1065,8 @@ def askDialog UI.ChangeWidget(Id(:dialogs), :CurrentItem, dialog_id) AutoinstGeneral.askList = deep_copy(askList) if ret == :next - end until ret == :next || ret == :back || ret == :cancel + break if ret == :next || ret == :back || ret == :cancel + end Convert.to_symbol(ret) end diff --git a/src/include/autoinstall/helps.rb b/src/include/autoinstall/helps.rb index d3f57141d..3936c50a4 100644 --- a/src/include/autoinstall/helps.rb +++ b/src/include/autoinstall/helps.rb @@ -14,16 +14,16 @@ def initialize_autoinstall_helps(_include_target) "valid" => _("

Profile Validation
") + _( "

This tool uses xmllint to validate the profile against the DTD and\n" \ - "it checks for missing data. Some missing data might be intentional and any\n" \ - "reported errors can be ignored, for example, when creating classes.

\n" + "it checks for missing data. Some missing data might be intentional and any\n" \ + "reported errors can be ignored, for example, when creating classes.

\n" ) + _( "

Load a profile first. Otherwise an empty file\nis validated.

\n" ), "clone" => _( "

This tool creates a reference profile by reading\n" \ - "information from this system. Select the resources to read from this system\n" \ - "in addition to the default resources, like partitioning and package selections.

\n" + "information from this system. Select the resources to read from this system\n" \ + "in addition to the default resources, like partitioning and package selections.

\n" ), "drivedialog" => _("

Partition your hard disks...

") + _( @@ -32,44 +32,44 @@ def initialize_autoinstall_helps(_include_target) _("

Hard disks are designated like this

") + _( "/dev/hda 1st EIDE disk\n" \ - "/dev/hdb 2nd EIDE disk\n" \ - "/dev/hdc 3rd EIDE disk" + "/dev/hdb 2nd EIDE disk\n" \ + "/dev/hdc 3rd EIDE disk" ) + _("

etc.

") + _("

- or -

") + _( "

/dev/sda 1st SCSI disk\n" \ - "/dev/sdb 2nd SCSI disk\n" \ - "/dev/sdc 3rd SCSI disk

" + "/dev/sdb 2nd SCSI disk\n" \ + "/dev/sdc 3rd SCSI disk

" ) + _( "If no partitions are defined and the specified drive is also\n" \ - "the drive where the root partition should reside, the following partitions are\n" \ - "created automatically:" + "the drive where the root partition should reside, the following partitions are\n" \ + "created automatically:" ) + _( " /boot, swap, and a root partition /.\n" \ - "Sizes are calculated automatically.\n" + "Sizes are calculated automatically.\n" ) + _("

Advanced Options

") + _( "By default, AutoYaST will create an extended partition and adds all new " \ - "partitions as logical devices. It is possible, however, to instruct AutoYaST " \ - "to create a certain partition as a primary partition or as extended partition. " \ - "Additionally, it is possible to specify the size of a partition using " \ - "sectors rather than size in MBytes." + "partitions as logical devices. It is possible, however, to instruct AutoYaST " \ + "to create a certain partition as a primary partition or as extended partition. " \ + "Additionally, it is possible to specify the size of a partition using " \ + "sectors rather than size in MBytes." ) + _( "These options and other advanced options cannot be configured using this\n" \ - "interface. Instead, add them manually to the control file.\n" + "interface. Instead, add them manually to the control file.\n" ) + _( "

\n" \ - "For LVM and RAID setup, consult the documentation and add the configuration\n" \ - "to an existing control file. You can only create unformatted LVM " \ - "and RAID partitions as\n" \ - "a preparation.\n" \ - "

\n" + "For LVM and RAID setup, consult the documentation and add the configuration\n" \ + "to an existing control file. You can only create unformatted LVM " \ + "and RAID partitions as\n" \ + "a preparation.\n" \ + "

\n" ) } diff --git a/src/include/autoinstall/io.rb b/src/include/autoinstall/io.rb index 83add5d8a..b664c534f 100644 --- a/src/include/autoinstall/io.rb +++ b/src/include/autoinstall/io.rb @@ -20,9 +20,9 @@ def initialize_autoinstall_io(_include_target) # @return [Boolean] true on success def Get(scheme, host, urlpath, localfile) get_file_from_url(scheme: scheme, host: host, urlpath: urlpath, - localfile: localfile, - urltok: AutoinstConfig.urltok, - destdir: AutoinstConfig.destdir) + localfile: localfile, + urltok: AutoinstConfig.urltok, + destdir: AutoinstConfig.destdir) end # Get a file froma given URL diff --git a/src/include/autoinstall/script_dialogs.rb b/src/include/autoinstall/script_dialogs.rb index 0d83ce8d8..145169cca 100644 --- a/src/include/autoinstall/script_dialogs.rb +++ b/src/include/autoinstall/script_dialogs.rb @@ -60,18 +60,18 @@ def ScriptDialog(mode, name) # help 1/6 help = _( "\n" \ - "

Preinstallation Scripts

\n" \ - "

Add commands to run on the system before the installation begins.

\n" + "

Preinstallation Scripts

\n" \ + "

Add commands to run on the system before the installation begins.

\n" ) # help 2/6 help = Ops.add( help, _( "\n" \ - "

Postinstallation Scripts

\n" \ - "

You can also add commands to execute on the system after the installation\n" \ - "is completed. These scripts are run outside the chroot environment.\n" \ - "

" + "

Postinstallation Scripts

\n" \ + "

You can also add commands to execute on the system after the installation\n" \ + "is completed. These scripts are run outside the chroot environment.\n" \ + "

" ) ) # help 3/6 @@ -79,13 +79,13 @@ def ScriptDialog(mode, name) help, _( "\n" \ - "

Chroot Scripts

\n" \ - "

For your postinstallation script to run inside the chroot\n" \ - "environment, choose the chroot scripts options. Those scripts are\n" \ - "run before the system reboots for the first time. By default, the chroot \n" \ - "scripts are run in the installation system. To access files in the installed \n" \ - "system, always use the mount point \"/mnt\" in your scripts.\n" \ - "

\n" + "

Chroot Scripts

\n" \ + "

For your postinstallation script to run inside the chroot\n" \ + "environment, choose the chroot scripts options. Those scripts are\n" \ + "run before the system reboots for the first time. By default, the chroot \n" \ + "scripts are run in the installation system. To access files in the installed \n" \ + "system, always use the mount point \"/mnt\" in your scripts.\n" \ + "

\n" ) ) # help 4/6 @@ -93,10 +93,10 @@ def ScriptDialog(mode, name) help, _( "\n" \ - "

It is possible to run chroot scripts in a later stage after\n" \ - "the boot loader has been configured using the special boolean tag \"chrooted\".\n" \ - "This runs the scripts in the installed system. \n" \ - "

\n" + "

It is possible to run chroot scripts in a later stage after\n" \ + "the boot loader has been configured using the special boolean tag \"chrooted\".\n" \ + "This runs the scripts in the installed system. \n" \ + "

\n" ) ) # help 5/6 @@ -104,13 +104,13 @@ def ScriptDialog(mode, name) help, _( "\n" \ - "

Init Scripts

\n" \ - "

These scripts are executed during the initial boot process and after\n" \ - "YaST has finished configuring the system. The final scripts are executed \n" \ - "using a special rc script that is executed only once. \n" \ - "The final scripts are executed toward the end of the boot\n" \ - "process and after network has been initialized.\n" \ - "

\n" + "

Init Scripts

\n" \ + "

These scripts are executed during the initial boot process and after\n" \ + "YaST has finished configuring the system. The final scripts are executed \n" \ + "using a special rc script that is executed only once. \n" \ + "The final scripts are executed toward the end of the boot\n" \ + "process and after network has been initialized.\n" \ + "

\n" ) ) @@ -119,22 +119,22 @@ def ScriptDialog(mode, name) help, _( "\n" \ - "

Interpreter:

\n" \ - "

Preinstallation scripts can only be shell scripts. Do not use Perl or \n" \ - "Python for preinstallation scripts.\n" \ - "

\n" + "

Interpreter:

\n" \ + "

Preinstallation scripts can only be shell scripts. Do not use Perl or \n" \ + "Python for preinstallation scripts.\n" \ + "

\n" ) ) help = Ops.add( help, _( "\n" \ - "

Feedback and Debug:

\n" \ - "

All scripts except the init scripts can show STDOUT+STDERR " \ - "in a pop-up box as feedback.\n" \ - "If you turn on debugging, you get more output in the " \ - "feedback dialog that might help\n" \ - "you to debug your script.

\n" + "

Feedback and Debug:

\n" \ + "

All scripts except the init scripts can show STDOUT+STDERR " \ + "in a pop-up box as feedback.\n" \ + "If you turn on debugging, you get more output in the " \ + "feedback dialog that might help\n" \ + "you to debug your script.

\n" ) ) @@ -296,11 +296,10 @@ def ScriptDialog(mode, name) Wizard.HideAbortButton Wizard.SetContents(title, contents, help, true, true) type = Convert.to_string(UI.QueryWidget(Id(:type), :Value)) - if type == "pre-scripts" + case type + when "pre-scripts", "post-scripts" UI.ChangeWidget(Id(:chrooted), :Enabled, false) - elsif type == "post-scripts" - UI.ChangeWidget(Id(:chrooted), :Enabled, false) - elsif type == "init-scripts" + when "init-scripts" UI.ChangeWidget(Id(:chrooted), :Enabled, false) UI.ChangeWidget(Id(:feedback), :Enabled, false) UI.ChangeWidget(Id(:notification), :Enabled, false) @@ -332,9 +331,10 @@ def ScriptDialog(mode, name) UI.ChangeWidget(Id(:filename), :Enabled, false) if mode == :edit ret = :none - begin + loop do ret = Convert.to_symbol(UI.UserInput) - if ret == :save + case ret + when :save scriptName = Convert.to_string(UI.QueryWidget(Id(:filename), :Value)) type2 = Convert.to_string(UI.QueryWidget(Id(:type), :Value)) @@ -353,7 +353,7 @@ def ScriptDialog(mode, name) UI.QueryWidget(Id(:notification), :Value) ) - if source == "" && location == "" || scriptName == "" + if (source == "" && location == "") || scriptName == "" Popup.Message( _( "Provide at least the script\nname and the location or content of the script.\n" @@ -375,7 +375,7 @@ def ScriptDialog(mode, name) notification ) end - elsif ret == :loadsource + when :loadsource filename = UI.AskForExistingFile( AutoinstConfig.Repository, "*", @@ -388,30 +388,26 @@ def ScriptDialog(mode, name) UI.ChangeWidget(Id(:source), :Value, source) next end - elsif ret == :type + when :type type2 = Convert.to_string(UI.QueryWidget(Id(:type), :Value)) - if type2 == "init-scripts" + case type2 + when "init-scripts" UI.ChangeWidget(Id(:feedback), :Enabled, false) UI.ChangeWidget(Id(:chrooted), :Enabled, false) UI.ChangeWidget(Id(:feedback), :Value, false) UI.ChangeWidget(Id(:chrooted), :Value, false) UI.ChangeWidget(Id(:notification), :Enabled, false) - elsif type2 == "chroot-scripts" + when "chroot-scripts" UI.ChangeWidget(Id(:chrooted), :Enabled, true) UI.ChangeWidget(Id(:feedback), :Enabled, true) UI.ChangeWidget(Id(:notification), :Enabled, true) - elsif type2 == "post-scripts" - UI.ChangeWidget(Id(:chrooted), :Enabled, false) - UI.ChangeWidget(Id(:chrooted), :Value, false) - UI.ChangeWidget(Id(:feedback), :Enabled, true) - UI.ChangeWidget(Id(:notification), :Enabled, true) - elsif type2 == "pre-scripts" + when "post-scripts", "pre-scripts" UI.ChangeWidget(Id(:chrooted), :Enabled, false) UI.ChangeWidget(Id(:chrooted), :Value, false) UI.ChangeWidget(Id(:feedback), :Enabled, true) UI.ChangeWidget(Id(:notification), :Enabled, true) end - elsif ret == :feedback + when :feedback UI.ChangeWidget( Id(:feedback_type), :Enabled, @@ -439,7 +435,8 @@ def ScriptDialog(mode, name) else UI.ChangeWidget(Id(:location), :Enabled, true) end - end until ret == :save || ret == :cancel || ret == :back + break if ret == :save || ret == :cancel || ret == :back + end ret end @@ -448,8 +445,8 @@ def ScriptDialog(mode, name) def ScriptsDialog help = _( "

\n" \ - "By adding scripts to the autoinstallation process, customize the installation for\n" \ - "your needs and take control in different stages of the installation.

\n" + "By adding scripts to the autoinstallation process, customize the installation for\n" \ + "your needs and take control in different stages of the installation.

\n" ) title = _("User Script Management") @@ -458,34 +455,36 @@ def ScriptsDialog Wizard.HideAbortButton Wizard.SetNextButton(:next, Label.FinishButton) ret = nil - begin + loop do ret = UI.UserInput - if ret == :new + case ret + when :new Wizard.CreateDialog ScriptDialog(Convert.to_symbol(ret), "") Wizard.CloseDialog - elsif ret == :edit + when :edit name = Convert.to_string(UI.QueryWidget(Id(:table), :CurrentItem)) - if !name.nil? + if name.nil? + Popup.Message(_("Select a script first.")) + next + else Wizard.CreateDialog ScriptDialog(Convert.to_symbol(ret), name) Wizard.CloseDialog - else - Popup.Message(_("Select a script first.")) - next end - elsif ret == :delete + when :delete name = Convert.to_string(UI.QueryWidget(Id(:table), :CurrentItem)) - if !name.nil? - AutoinstScripts.deleteScript(name) - else + if name.nil? Popup.Message(_("Select a script first.")) next + else + AutoinstScripts.deleteScript(name) end end Wizard.SetContents(title, script_dialog_contents, help, true, true) - end until ret == :next || ret == :back || ret == :cancel + break if ret == :next || ret == :back || ret == :cancel + end Convert.to_symbol(ret) end diff --git a/src/lib/autoinstall/ask/runner.rb b/src/lib/autoinstall/ask/runner.rb index a531aba9c..14a0f5d70 100644 --- a/src/lib/autoinstall/ask/runner.rb +++ b/src/lib/autoinstall/ask/runner.rb @@ -72,9 +72,10 @@ def run break if current_dialog.nil? result = run_dialog(current_dialog) - if result == :back + case result + when :back current_dialog = go_back - elsif result == :next + when :next results = current_dialog.questions.map { |q| process_question(q) } current_dialog = go_next unless results.any? { |r| r == :repeat } end @@ -126,7 +127,7 @@ def find_next_dialog_index file_size = File.size(DIALOG_FILE) if !is_file || file_size > MAX_DIALOG_FILE_SIZE log.error "Ignoring #{DIALOG_FILE} because it is not a file (#{is_file}) or " \ - "it is too big (#{file_size}." + "it is too big (#{file_size}." return end diff --git a/src/lib/autoinstall/autoinst_profile/ask_list_section.rb b/src/lib/autoinstall/autoinst_profile/ask_list_section.rb index 18f2e0a7d..ce56f89ce 100644 --- a/src/lib/autoinstall/autoinst_profile/ask_list_section.rb +++ b/src/lib/autoinstall/autoinst_profile/ask_list_section.rb @@ -35,6 +35,7 @@ def new_from_hashes(hash) end def initialize(entries = []) + super() @entries = entries end diff --git a/src/lib/autoinstall/clients/autoyast.rb b/src/lib/autoinstall/clients/autoyast.rb index e165bac35..d47172b1d 100644 --- a/src/lib/autoinstall/clients/autoyast.rb +++ b/src/lib/autoinstall/clients/autoyast.rb @@ -41,6 +41,7 @@ class Autoyast < Yast::Client include Yast::Logger def initialize + super textdomain "autoinst" Yast::Mode.SetMode("autoinst_config") @@ -211,8 +212,8 @@ def import_profile(filename) Yast::Popup.Error( _( "Error while parsing the control file.\n" \ - "Check the log files for more details or fix the\n" \ - "AutoYaST profile and try again.\n" + "Check the log files for more details or fix the\n" \ + "AutoYaST profile and try again.\n" ) ) end @@ -238,7 +239,7 @@ def erb_check(filename, run_erb_option) if !run_erb_option && Process.euid.zero? Yast::CommandLine.Error(_("run-erb=true option is mandatory when checking an ERB " \ - "profile as root.")) + "profile as root.")) return false end diff --git a/src/lib/autoinstall/clients/ayast_setup.rb b/src/lib/autoinstall/clients/ayast_setup.rb index 8eb9f1d0d..43300477f 100644 --- a/src/lib/autoinstall/clients/ayast_setup.rb +++ b/src/lib/autoinstall/clients/ayast_setup.rb @@ -108,8 +108,8 @@ def openFile(options) Yast::CommandLine.Print( _( "Error while parsing the control file.\n" \ - "Check the log files for more details or fix the\n" \ - "control file and try again.\n" + "Check the log files for more details or fix the\n" \ + "control file and try again.\n" ) ) return false diff --git a/src/lib/autoinstall/clients/clone_system.rb b/src/lib/autoinstall/clients/clone_system.rb index a4a89a6db..6885e7d86 100644 --- a/src/lib/autoinstall/clients/clone_system.rb +++ b/src/lib/autoinstall/clients/clone_system.rb @@ -41,6 +41,7 @@ class CloneSystem < Yast::Client include Yast::Logger def initialize + super textdomain "autoinst" end @@ -131,12 +132,9 @@ def clone_system(options) # 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 Yast::Mode.normal && Yast::FileUtils.Exists(filename) - # TRANSLATORS: Warning that an already existing autoyast configuration file - # will be overwritten. - if !Yast::Popup.ContinueCancel(_("File %s exists! Really overwrite?") % filename) - return false - end + if Yast::Mode.normal && Yast::FileUtils.Exists(filename) && + !Yast::Popup.ContinueCancel(_("File %s exists! Really overwrite?") % filename) + return false end Yast::Popup.ShowFeedback( diff --git a/src/lib/autoinstall/clients/files_auto.rb b/src/lib/autoinstall/clients/files_auto.rb index 85690471d..f4336eec3 100644 --- a/src/lib/autoinstall/clients/files_auto.rb +++ b/src/lib/autoinstall/clients/files_auto.rb @@ -27,6 +27,7 @@ class FilesAuto < ::Installation::AutoClient include Yast::I18n def initialize + super textdomain "autoinst" end @@ -130,7 +131,7 @@ def addFileDialog(mode, name) # help 1/2 help = _( "

Using this dialog, copy the contents of the file and specify the final\n" \ - "path on the installed system. YaST will copy this file to the specified location.

" + "path on the installed system. YaST will copy this file to the specified location.

" ) # help 2/2 @@ -138,11 +139,11 @@ def addFileDialog(mode, name) help, _( "

To protect copied files, set the owner and the permissions of the files.\n" \ - "Set the owner using the syntax userid:groupid. "\ - "Permissions can be a symbolic\n" \ - "representation of changes to make or an octal number " \ - "representing the bit pattern for the\n" \ - "new permissions.

" + "Set the owner using the syntax userid:groupid. "\ + "Permissions can be a symbolic\n" \ + "representation of changes to make or an octal number " \ + "representing the bit pattern for the\n" \ + "new permissions.

" ) ) @@ -202,26 +203,27 @@ def addFileDialog(mode, name) ret = nil loop do - if Convert.to_string(UI.QueryWidget(Id(:location), :Value)) != "" - UI.ChangeWidget(Id(:source), :Enabled, false) - else + if Convert.to_string(UI.QueryWidget(Id(:location), :Value)) == "" UI.ChangeWidget(Id(:source), :Enabled, true) - if Convert.to_string(UI.QueryWidget(Id(:source), :Value)) != "" + if Convert.to_string(UI.QueryWidget(Id(:source), :Value)) == "" + UI.ChangeWidget(Id(:location), :Enabled, true) + else UI.ChangeWidget(Id(:location), :Enabled, false) UI.ChangeWidget(Id(:location), :Value, "") - else - UI.ChangeWidget(Id(:location), :Enabled, true) end + else + UI.ChangeWidget(Id(:source), :Enabled, false) end ret = Convert.to_symbol(UI.UserInput) - if ret == :next + case ret + when :next fileName = Convert.to_string(UI.QueryWidget(Id(:filename), :Value)) permissions = Convert.to_string(UI.QueryWidget(Id(:perm), :Value)) owner = Convert.to_string(UI.QueryWidget(Id(:owner), :Value)) source = Convert.to_string(UI.QueryWidget(Id(:source), :Value)) location = Convert.to_string(UI.QueryWidget(Id(:location), :Value)) - if source == "" && location == "" || fileName == "" + if (source == "" && location == "") || fileName == "" Popup.Message( _( "Provide at least the file\nname and the contents of the file.\n" @@ -232,7 +234,7 @@ def addFileDialog(mode, name) else AddEditFile(fileName, source, permissions, owner, location) end - elsif ret == :loadsource + when :loadsource filename = UI.AskForExistingFile("", "*", _("Select a file to load.")) if filename != "" source = Convert.to_string( @@ -281,9 +283,9 @@ def custom_file_dialog help = _( "

For many applications and services, you might have prepared\n" \ - "a configuration file that should be copied in a complete form to a location in the\n" \ - "installed system. For example, this is the case if you are installing a web server\n" \ - "and have an httpd.conf configuration file prepared.

" + "a configuration file that should be copied in a complete form to a location in the\n" \ + "installed system. For example, this is the case if you are installing a web server\n" \ + "and have an httpd.conf configuration file prepared.

" ) Wizard.SetContents(title, dialog_contents, help, true, true) @@ -295,9 +297,10 @@ def custom_file_dialog loop do ret = Convert.to_symbol(UI.UserInput) - if ret == :new + case ret + when :new addFileDialog(Convert.to_symbol(ret), "") - elsif ret == :edit + when :edit name = Convert.to_string(UI.QueryWidget(Id(:table), :CurrentItem)) if name addFileDialog(Convert.to_symbol(ret), name) @@ -305,7 +308,7 @@ def custom_file_dialog Popup.Message(select_msg) next end - elsif ret == :delete + when :delete name = Convert.to_string(UI.QueryWidget(Id(:table), :CurrentItem)) if name AutoinstFile.Files = deleteFile(name) diff --git a/src/lib/autoinstall/clients/inst_autoinit.rb b/src/lib/autoinstall/clients/inst_autoinit.rb index da4b29d9b..9b5122bab 100644 --- a/src/lib/autoinstall/clients/inst_autoinit.rb +++ b/src/lib/autoinstall/clients/inst_autoinit.rb @@ -136,9 +136,9 @@ def run if !(Yast::AutoinstFunctions.selected_product || Yast::Mode.autoupgrade) msg = _("None or wrong base product has been defined " \ - "in the AutoYaST configuration file. " \ - "Please check the products entry in the software section.

" \ - "Following base products are available:
") + "in the AutoYaST configuration file. " \ + "Please check the products entry in the software section.

" \ + "Following base products are available:
") Y2Packager::ProductSpec.base_products.each do |product| msg += "#{product.name} (#{product.display_name})
" end @@ -207,7 +207,7 @@ def check_unsupported_profile_sections .obsolete_sections if unsupported_sections.any? log.error "Could not process these unsupported profile " \ - "sections: #{unsupported_sections}" + "sections: #{unsupported_sections}" Yast::Report.LongWarning( # TRANSLATORS: Error message, %s is replaced by newline-separated # list of unsupported sections of the profile @@ -268,8 +268,8 @@ def processProfile Yast::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" + "Check the log files for more details or fix the\n" \ + "control file and try again.\n" ) ) return :abort @@ -306,12 +306,12 @@ def processProfile def ProfileSourceDialog(original) helptext = _( "

\n" \ - "A profile for this machine could not be found or retrieved.\n" \ - "Check that you entered the correct location\n" \ - "on the command line and try again. Because of this error, you\n" \ - "can only enter a URL to a profile and not to a directory. If you\n" \ - "are using rules or host name-based control files, restart the\n" \ - "installation process and make sure the control files are accessible.

\n" + "A profile for this machine could not be found or retrieved.\n" \ + "Check that you entered the correct location\n" \ + "on the command line and try again. Because of this error, you\n" \ + "can only enter a URL to a profile and not to a directory. If you\n" \ + "are using rules or host name-based control files, restart the\n" \ + "installation process and make sure the control files are accessible.

\n" ) title = _("System Profile Location") @@ -375,8 +375,8 @@ def autoupgrade_profile def report_missing_registration msg = _("Registration is mandatory when using the online " \ - "installation medium. Enable registration in " \ - "the AutoYaST profile or use full installation medium.") + "installation medium. Enable registration in " \ + "the AutoYaST profile or use full installation medium.") Yast::Popup.LongError(msg) # No timeout because we are stopping the installation/upgrade. end diff --git a/src/lib/autoinstall/clients/inst_autosetup_upgrade.rb b/src/lib/autoinstall/clients/inst_autosetup_upgrade.rb index da41b2aed..d588c1cf6 100644 --- a/src/lib/autoinstall/clients/inst_autosetup_upgrade.rb +++ b/src/lib/autoinstall/clients/inst_autosetup_upgrade.rb @@ -236,9 +236,9 @@ def main Product.FindBaseProducts rescue StandardError msg = _("No new base product has been set.\n" \ - "It can be specified in the software/products entry in the " \ - "AutoYaST configuration file.

" \ - "Following base products are available:
") + "It can be specified in the software/products entry in the " \ + "AutoYaST configuration file.

" \ + "Following base products are available:
") Y2Packager::ProductSpec.base_products.each do |prod| msg += "#{prod.name} (#{prod.display_name})
" end diff --git a/src/lib/autoinstall/clients/report_auto.rb b/src/lib/autoinstall/clients/report_auto.rb index 1658c7202..62fa004de 100644 --- a/src/lib/autoinstall/clients/report_auto.rb +++ b/src/lib/autoinstall/clients/report_auto.rb @@ -30,6 +30,7 @@ class ReportAuto < ::Installation::AutoClient include Yast::I18n def initialize + super textdomain "autoinst" end @@ -197,14 +198,14 @@ def ReportingDialog help_text = _( "

Depending on your experience, you can skip, log, and show (with time-out)\n" \ - "installation messages.

\n" + "installation messages.

\n" ) help_text = Ops.add( help_text, _( "

It is recommended to show all messages with time-out.\n" \ - "Warnings can be skipped in some places, but should not be ignored.

\n" + "Warnings can be skipped in some places, but should not be ignored.

\n" ) ) diff --git a/src/lib/autoinstall/clients/scripts_auto.rb b/src/lib/autoinstall/clients/scripts_auto.rb index a4f074334..9c2fdcefd 100644 --- a/src/lib/autoinstall/clients/scripts_auto.rb +++ b/src/lib/autoinstall/clients/scripts_auto.rb @@ -28,6 +28,7 @@ class ScriptsAuto < ::Installation::AutoClient include Yast::I18n def initialize + super textdomain "autoinst" Yast.include self, "autoinstall/script_dialogs.rb" diff --git a/src/lib/autoinstall/clients/software_auto.rb b/src/lib/autoinstall/clients/software_auto.rb index 6f2b68524..1ee569491 100644 --- a/src/lib/autoinstall/clients/software_auto.rb +++ b/src/lib/autoinstall/clients/software_auto.rb @@ -61,26 +61,27 @@ def main # create a summary - if @func == "Summary" + case @func + when "Summary" @ret = Yast::AutoinstSoftware.Summary - elsif @func == "Import" + when "Import" @ret = Yast::AutoinstSoftware.Import(@param) - elsif @func == "Read" + when "Read" # use the previously saved software selection if defined (bsc#956325) @ret = Yast::AutoinstSoftware.SavedPackageSelection || Yast::AutoinstSoftware.Read - elsif @func == "Reset" + when "Reset" Yast::AutoinstSoftware.Import({}) @ret = {} - elsif @func == "Change" + when "Change" @ret = packageSelector - elsif @func == "GetModified" + when "GetModified" packages = Yast::PackagesProposal.GetResolvables("autoyast", :package) + Yast::PackagesProposal.GetTaboos("autoyast", :package) @ret = Yast::AutoinstSoftware.GetModified || !packages.empty? - elsif @func == "SetModified" + when "SetModified" Yast::AutoinstSoftware.SetModified @ret = true - elsif @func == "Export" + when "Export" @ret = Yast::AutoinstSoftware.Export else Yast::Builtins.y2error("unknown function: %1", @func) @@ -163,7 +164,8 @@ def packageSelector UI.ChangeWidget(Id(:localSource), :Enabled, true) end ret = UI.UserInput - if ret == :ok + case ret + when :ok if Yast::Convert.to_boolean(UI.QueryWidget(Id(:localSource), :Value)) Yast::Pkg.TargetInit("/", false) break @@ -177,10 +179,10 @@ def packageSelector Yast::Popup.Error(_("using that installation source failed")) end end - elsif ret == :abort + when :abort UI.CloseDialog return :back - elsif ret == :localSource + when :localSource localSource = Yast::Convert.to_boolean( UI.QueryWidget(Id(:localSource), :Value) ) @@ -250,7 +252,9 @@ def packageSelector ) patadd = [] - if @ret != :back + if @ret == :back + patadd = deep_copy(Yast::AutoinstSoftware.patterns) + else all_patterns = Y2Packager::Resolvable.find( kind: :pattern, status: :selected ).map(&:name) @@ -258,8 +262,6 @@ def packageSelector "available patterns %1", all_patterns ) patadd = all_patterns - else - patadd = deep_copy(Yast::AutoinstSoftware.patterns) end Yast::PackagesProposal.SetResolvables( diff --git a/src/lib/autoinstall/dialogs/disk_selector.rb b/src/lib/autoinstall/dialogs/disk_selector.rb index 06d381e59..ba2d29b0d 100644 --- a/src/lib/autoinstall/dialogs/disk_selector.rb +++ b/src/lib/autoinstall/dialogs/disk_selector.rb @@ -46,6 +46,7 @@ class DiskSelector < UI::Dialog # @param blacklist [Array] Device names that should be omitted. # These disks will be filtered out. def initialize(devicegraph = nil, drive_index: 1, blacklist: []) + super() textdomain "autoinst" @devicegraph = devicegraph || Y2Storage::StorageManager.instance.probed @drive_index = drive_index diff --git a/src/lib/autoinstall/dialogs/question.rb b/src/lib/autoinstall/dialogs/question.rb index 4a5e14f93..d97d8ff74 100644 --- a/src/lib/autoinstall/dialogs/question.rb +++ b/src/lib/autoinstall/dialogs/question.rb @@ -48,6 +48,7 @@ class Question < UI::Dialog # @param timeout [Integer] Countdown (in seconds); 0 means no timeout. # @param buttons_set [Symbol] Buttons set (:abort, :question) def initialize(headline, content, timeout: 10, buttons_set: :question) + super() @headline = headline @content = content @remaining_time = timeout diff --git a/src/lib/autoinstall/dialogs/storage.rb b/src/lib/autoinstall/dialogs/storage.rb index 8514a4850..1c9787dff 100644 --- a/src/lib/autoinstall/dialogs/storage.rb +++ b/src/lib/autoinstall/dialogs/storage.rb @@ -46,6 +46,7 @@ class Storage < CWM::Dialog # @param partitioning [Y2Storage::AutoinstProfile::PartitioningSection] # Partitioning section of the profile def initialize(partitioning = Y2Storage::AutoinstProfile::PartitioningSection.new) + super() textdomain "autoinst" @controller = Y2Autoinstallation::StorageController.new(partitioning) end diff --git a/src/lib/autoinstall/entries/description_sorter.rb b/src/lib/autoinstall/entries/description_sorter.rb index 6a9fcc843..706bd2f67 100644 --- a/src/lib/autoinstall/entries/description_sorter.rb +++ b/src/lib/autoinstall/entries/description_sorter.rb @@ -27,7 +27,7 @@ class DescriptionSorter def initialize(descriptions) @descriptions = descriptions - @descriptions_map = Hash[descriptions.map { |d| [d.module_name, d] }] + @descriptions_map = descriptions.map { |d| [d.module_name, d] }.to_h end # @return [Array] sorted module names. It should be written diff --git a/src/lib/autoinstall/importer.rb b/src/lib/autoinstall/importer.rb index f4298be0d..64cf0ed81 100644 --- a/src/lib/autoinstall/importer.rb +++ b/src/lib/autoinstall/importer.rb @@ -61,11 +61,9 @@ def unhandled_sections managed = registry.descriptions.map(&:managed_keys).flatten profile.keys.select do |name| - if managed.include?(name) - false # Generic sections are handled by AutoYast itself and not mentioned # in any desktop or clients/*_auto.rb file. - elsif GENERIC_PROFILE_SECTIONS.include?(name) + if managed.include?(name) || GENERIC_PROFILE_SECTIONS.include?(name) false else # Sections which are not handled in any desktop file but the diff --git a/src/lib/autoinstall/pkg_gpg_check_handler.rb b/src/lib/autoinstall/pkg_gpg_check_handler.rb index 59f2fc83f..9cd098faa 100644 --- a/src/lib/autoinstall/pkg_gpg_check_handler.rb +++ b/src/lib/autoinstall/pkg_gpg_check_handler.rb @@ -18,8 +18,9 @@ class PkgGpgCheckHandler # This command will produce something which last line will be like: # DSA/SHA1, Mon 05 Oct 2015 04:24:50 PM WEST, Key ID 9b7d32f2d50582e6 FIND_KEY_ID_CMD = "rpm --query --info --queryformat "\ - "\"%%|DSAHEADER?{%%{DSAHEADER:pgpsig}}:{%%|RSAHEADER?{%%{RSAHEADER:pgpsig}}:{(none}|}|\" "\ - " --package %s".freeze + "\"%%|DSAHEADER?{%%{DSAHEADER:pgpsig}}:" \ + "{%%|RSAHEADER?{%%{RSAHEADER:pgpsig}}:{(none}|}|\" "\ + " --package %s".freeze attr_reader :result, :package, :path, :config diff --git a/src/lib/autoinstall/presenters/section.rb b/src/lib/autoinstall/presenters/section.rb index cf7b95e30..1c3507948 100644 --- a/src/lib/autoinstall/presenters/section.rb +++ b/src/lib/autoinstall/presenters/section.rb @@ -37,6 +37,7 @@ class Section < SimpleDelegator # @param section [Y2Storage::AutoinstProfile::SectionWithAttributes] the # concrete type of section depends on the presenter subclass def initialize(section) + super textdomain "autoinst" __setobj__(section) end diff --git a/src/lib/autoinstall/profile_checker.rb b/src/lib/autoinstall/profile_checker.rb index 1f37c3482..190069c84 100644 --- a/src/lib/autoinstall/profile_checker.rb +++ b/src/lib/autoinstall/profile_checker.rb @@ -103,8 +103,8 @@ def import_profile(filename) Yast2::Popup.show( _( "Error while parsing the control file.\n" \ - "Check the log files for more details or fix the\n" \ - "AutoYaST profile and try again.\n" + "Check the log files for more details or fix the\n" \ + "AutoYaST profile and try again.\n" ), headline: :error ) end diff --git a/src/lib/autoinstall/script.rb b/src/lib/autoinstall/script.rb index 5c0680a6d..2d69891da 100644 --- a/src/lib/autoinstall/script.rb +++ b/src/lib/autoinstall/script.rb @@ -282,7 +282,7 @@ def execute(env = {}) params_s = params.join(" ") # shell escaping is up to user, see documentation cmd_line = "#{env_vars(env)} #{cmd} #{debug_flag} #{script_path.shellescape} " \ - "#{params_s} &> #{log_path.shellescape}" + "#{params_s} &> #{log_path.shellescape}" bash_path = Yast::Path.new(".target.bash") res = Yast::SCR.Execute(bash_path, cmd_line) @@ -466,6 +466,7 @@ def script_path class AskDefaultValueScript < Y2Autoinstallation::ExecutedScript # @return [String,nil] Standard output from the last execution attr_reader :stdout + def self.type "ask-default-value-scripts" end diff --git a/src/lib/autoinstall/widgets/ask/check_box.rb b/src/lib/autoinstall/widgets/ask/check_box.rb index d06e6a32a..6dad9da1b 100644 --- a/src/lib/autoinstall/widgets/ask/check_box.rb +++ b/src/lib/autoinstall/widgets/ask/check_box.rb @@ -32,6 +32,7 @@ class CheckBox < CWM::CheckBox # @param question [Y2Autoinstall::Ask::Question] Question to represent def initialize(question) + super() textdomain "autoinst" @question = question end diff --git a/src/lib/autoinstall/widgets/ask/combo_box.rb b/src/lib/autoinstall/widgets/ask/combo_box.rb index 221165ad9..ce016e97c 100644 --- a/src/lib/autoinstall/widgets/ask/combo_box.rb +++ b/src/lib/autoinstall/widgets/ask/combo_box.rb @@ -32,6 +32,7 @@ class ComboBox < CWM::ComboBox # @param question [Y2Autoinstall::Ask::Question] Question to represent def initialize(question) + super() @question = question end diff --git a/src/lib/autoinstall/widgets/ask/dialog.rb b/src/lib/autoinstall/widgets/ask/dialog.rb index 364bfefa9..2a944874f 100644 --- a/src/lib/autoinstall/widgets/ask/dialog.rb +++ b/src/lib/autoinstall/widgets/ask/dialog.rb @@ -54,6 +54,7 @@ class TimeoutWrapper < CWM::CustomWidget # @param widgets [Array] Widgets to wrap # @param timeout [Integer,nil] Time limit. No time out if is set to 0 or nil. def initialize(widgets, timeout: 0) + super() textdomain "autoinst" @timeout = timeout || 0 @remaining = @timeout @@ -130,6 +131,7 @@ def stop # @param dialog [Y2Autoinstall::Ask::Dialog] Dialog specification # @param disable_back_button [Boolean] Whether the :back button should be disabled def initialize(dialog, disable_back_button: false) + super() textdomain "autoinst" @dialog = dialog @disable_buttons = disable_back_button ? ["back_button"] : [] diff --git a/src/lib/autoinstall/widgets/ask/input_field.rb b/src/lib/autoinstall/widgets/ask/input_field.rb index 6133d9c8c..5086f538d 100644 --- a/src/lib/autoinstall/widgets/ask/input_field.rb +++ b/src/lib/autoinstall/widgets/ask/input_field.rb @@ -32,6 +32,7 @@ class InputField < CWM::InputField # @param question [Y2Autoinstall::Ask::Question] Question to represent def initialize(question) + super() textdomain "autoinst" @question = question end diff --git a/src/lib/autoinstall/widgets/ask/password_field.rb b/src/lib/autoinstall/widgets/ask/password_field.rb index b9074f2a0..1d70bb5dc 100644 --- a/src/lib/autoinstall/widgets/ask/password_field.rb +++ b/src/lib/autoinstall/widgets/ask/password_field.rb @@ -34,6 +34,7 @@ class PasswordField < CWM::CustomWidget # @param question [Y2Autoinstall::Ask::Question] Question to represent def initialize(question) + super() textdomain "autoinst" @question = question end diff --git a/src/lib/autoinstall/widgets/storage/add_partition_button.rb b/src/lib/autoinstall/widgets/storage/add_partition_button.rb index 0e1bfb70d..4a39e091f 100644 --- a/src/lib/autoinstall/widgets/storage/add_partition_button.rb +++ b/src/lib/autoinstall/widgets/storage/add_partition_button.rb @@ -29,6 +29,7 @@ class AddPartitionButton < CWM::PushButton # # @param controller [Y2Autoinstallation::StorageController] UI controller def initialize(controller) + super() textdomain "autoinst" @controller = controller end diff --git a/src/lib/autoinstall/widgets/storage/delete_section_button.rb b/src/lib/autoinstall/widgets/storage/delete_section_button.rb index 2469726d4..6d5798ac1 100644 --- a/src/lib/autoinstall/widgets/storage/delete_section_button.rb +++ b/src/lib/autoinstall/widgets/storage/delete_section_button.rb @@ -29,6 +29,7 @@ class DeleteSectionButton < CWM::PushButton # # @param controller [Y2Autoinstallation::StorageController] UI controller def initialize(controller) + super() textdomain "autoinst" @controller = controller end diff --git a/src/lib/autoinstall/widgets/storage/filesystem.rb b/src/lib/autoinstall/widgets/storage/filesystem.rb index a173c7ba4..71363e4df 100644 --- a/src/lib/autoinstall/widgets/storage/filesystem.rb +++ b/src/lib/autoinstall/widgets/storage/filesystem.rb @@ -30,6 +30,7 @@ module Storage class Filesystem < CWM::ComboBox # Constructor def initialize + super textdomain "autoinst" self.widget_id = "filesystem_attr" end diff --git a/src/lib/autoinstall/widgets/storage/overview_tree.rb b/src/lib/autoinstall/widgets/storage/overview_tree.rb index 4290a39ef..dd5ce0adc 100644 --- a/src/lib/autoinstall/widgets/storage/overview_tree.rb +++ b/src/lib/autoinstall/widgets/storage/overview_tree.rb @@ -33,6 +33,7 @@ class OverviewTree < CWM::Tree # # @param items [Array] List of tree items to be included def initialize(items) + super() textdomain "autoinst" @items = items end diff --git a/src/lib/autoinstall/widgets/storage/partition_tab.rb b/src/lib/autoinstall/widgets/storage/partition_tab.rb index d66a0f102..62a85647c 100644 --- a/src/lib/autoinstall/widgets/storage/partition_tab.rb +++ b/src/lib/autoinstall/widgets/storage/partition_tab.rb @@ -31,6 +31,7 @@ class PartitionTab < ::CWM::Tab # # @param partition [Presenters::Partition] presenter for a partition section of the profile def initialize(partition) + super() textdomain "autoinst" @partition = partition diff --git a/src/lib/autoinstall/xml_checks.rb b/src/lib/autoinstall/xml_checks.rb index 97ba69256..ed5a76350 100644 --- a/src/lib/autoinstall/xml_checks.rb +++ b/src/lib/autoinstall/xml_checks.rb @@ -169,15 +169,15 @@ def message(msg, errors, file, schema) # TRANSLATORS: Warn user about using invalid XML _("Using an invalid XML document might result in an unexpected behavior, " \ "crash or even data loss!") + - "

" + _("Details") + "

" \ - "

" + ERB::Util.html_escape(errors.join("
")) + "

" \ - "

" + _("Note") + "

" + + "

" + _("Details") + "

" + + ERB::Util.html_escape(errors.join("
")) + "

" + _("Note") + "

" + # TRANSLATORS: A hint how to check a XML file, displayed as a part of the # validation error message, %{jing} and %{xmllint} are replaced by shell commands, # use HTML tags and entities (non-breaking space) for formatting the message "

" + format(_("You can check the file manually with these commands:

" \ - "  %{jing}
" \ - "  %{xmllint}"), jing: jing_command, xmllint: xmllint_command) + "

" + "  %{jing}
" \ + "  %{xmllint}"), jing: jing_command, xmllint: xmllint_command) + + "

" end end end diff --git a/src/lib/autoinstall/y2erb.rb b/src/lib/autoinstall/y2erb.rb index 42a99adaf..7c8cbb18b 100644 --- a/src/lib/autoinstall/y2erb.rb +++ b/src/lib/autoinstall/y2erb.rb @@ -63,20 +63,20 @@ def network_cards hardware["netcard"].each do |card| resource = card["resource"] mac = begin - resource["hwaddr"].first["addr"] - rescue StandardError - "" - end + resource["hwaddr"].first["addr"] + rescue StandardError + "" + end active = begin - resource["io"].first["active"] - rescue StandardError - false - end + resource["io"].first["active"] + rescue StandardError + false + end link = begin - resource["link"].first["state"] - rescue StandardError - false - end + resource["link"].first["state"] + rescue StandardError + false + end result = { vendor: card["vendor"], device: card["dev_name"], diff --git a/src/modules/AutoInstall.rb b/src/modules/AutoInstall.rb index a4da8a393..07e9fcf25 100644 --- a/src/modules/AutoInstall.rb +++ b/src/modules/AutoInstall.rb @@ -110,7 +110,17 @@ def Continue # First check if there are some other control files availabe # i.e. for post-installation only # - if SCR.Read(path(".target.size"), AutoinstConfig.autoconf_file) != -1 + if SCR.Read(path(".target.size"), AutoinstConfig.autoconf_file) == -1 + ret = Profile.ReadProfileStructure(AutoinstConfig.parsedControlFile) + if Profile.current == {} || !ret + Builtins.y2milestone("No saved autoinstall data found") + false + else + Builtins.y2milestone("Found and read saved autoinst data") + SCR.Execute(path(".target.remove"), AutoinstConfig.parsedControlFile) + true + end + else Builtins.y2milestone( "XML Post installation data found: %1", AutoinstConfig.autoconf_file @@ -125,16 +135,6 @@ def Continue ) ) ret - else - ret = Profile.ReadProfileStructure(AutoinstConfig.parsedControlFile) - if Profile.current == {} || !ret - Builtins.y2milestone("No saved autoinstall data found") - false - else - Builtins.y2milestone("Found and read saved autoinst data") - SCR.Execute(path(".target.remove"), AutoinstConfig.parsedControlFile) - true - end end end @@ -394,23 +394,23 @@ def valid_imported_values publish function: :callbackTrue_boolean_map, type: "boolean (map )" publish function: :callbackFalse_boolean_map, type: "boolean (map )" publish function: :callbackTrue_boolean_map_integer, - type: "boolean (map , integer)" + type: "boolean (map , integer)" publish function: :callbackFalse_boolean_map_integer, - type: "boolean (map , integer)" + type: "boolean (map , integer)" publish function: :callbackTrue_boolean_string_map_integer, - type: "boolean (string, map , integer)" + type: "boolean (string, map , integer)" publish function: :callbackFalse_boolean_string_map_integer, - type: "boolean (string, map , integer)" + type: "boolean (string, map , integer)" publish function: :callbackTrue_boolean_string_string, type: "boolean (string, string)" publish function: :callbackFalse_boolean_string_string, type: "boolean (string, string)" publish function: :callbackTrue_boolean_string_string_integer, - type: "boolean (string, string, integer)" + type: "boolean (string, string, integer)" publish function: :callbackFalse_boolean_string_string_integer, - type: "boolean (string, string, integer)" + type: "boolean (string, string, integer)" publish function: :callbackTrue_boolean_string_string_string, - type: "boolean (string, string, string)" + type: "boolean (string, string, string)" publish function: :callbackFalse_boolean_string_string_string, - type: "boolean (string, string, string)" + type: "boolean (string, string, string)" publish function: :Continue, type: "boolean ()" publish function: :AutoInstall, type: "void ()" publish function: :Save, type: "boolean ()" diff --git a/src/modules/AutoInstallRules.rb b/src/modules/AutoInstallRules.rb index e3584210d..6a31ee8f3 100644 --- a/src/modules/AutoInstallRules.rb +++ b/src/modules/AutoInstallRules.rb @@ -170,7 +170,7 @@ def getNetwork ip_route = SCR.Execute(path(".target.bash_output"), "/usr/sbin/ip route") # Regexp to fetch match the network address. - regexp = /([\h:\.]+)\/\d+ .+src #{hostaddress}/ + regexp = /([\h:.]+)\/\d+ .+src #{hostaddress}/ ret = ip_route["stdout"][regexp, 1] log.warn "Cannot find network address through 'ip': #{ip_route}" unless ret @@ -225,9 +225,10 @@ def ProbeRules boardinfo = {} Builtins.foreach(smbios) do |inf| - if Ops.get_string(inf, "type", "") == "sysinfo" + case Ops.get_string(inf, "type", "") + when "sysinfo" sysinfo = deep_copy(inf) - elsif Ops.get_string(inf, "type", "") == "boardinfo" + when "boardinfo" boardinfo = deep_copy(inf) end end @@ -325,7 +326,7 @@ def ProbeRules Ops.set(@ATTR, "installed_product_version", @installed_product_version) log.info "Installing #{@installed_product}, " \ - "version: #{@installed_product_version}" + "version: #{@installed_product_version}" log.info "ATTR=#{@ATTR}" nil @@ -340,9 +341,10 @@ def ProbeRules # @return [void] def shellseg(match, var, val, op, matchtype) val = deep_copy(val) - if op == "and" + case op + when "and" op = " && " - elsif op == "or" + when "or" op = " || " end @@ -544,18 +546,19 @@ def Read disk = Builtins.splitstring(match, " ") i = 0 t = "" - t = if @shell != "" + t = if @shell == "" + Ops.add(@shell, Builtins.sformat(" ( ")) + else Ops.add( @shell, Builtins.sformat(" %1 ( ", (op == "and") ? "&&" : "||") ) - else - Ops.add(@shell, Builtins.sformat(" ( ")) end Builtins.foreach(@disksize) do |dev| var1 = Builtins.sformat("disksize_size%1", i) var2 = Builtins.sformat("disksize_device%1", i) - if matchtype == "exact" + case matchtype + when "exact" t = Ops.add( t, Builtins.sformat( @@ -566,7 +569,7 @@ def Read Ops.get(disk, 0, "") ) ) - elsif matchtype == "greater" + when "greater" t = Ops.add( t, Builtins.sformat( @@ -577,7 +580,7 @@ def Read Ops.get(disk, 0, "") ) ) - elsif matchtype == "lower" + when "lower" t = Ops.add( t, Builtins.sformat( @@ -864,9 +867,9 @@ def GetRules @tomerge = deep_copy(valid) if Builtins.size(@tomerge) == 0 Builtins.y2milestone("No files from rules found") - return false + false else - return true + true end end @@ -926,7 +929,7 @@ def Merge(result_profile) log.error("Error reading XML file: #{e.inspect}") message = _( "The XML parser reported an error while parsing the autoyast profile. " \ - "The error message is:\n" + "The error message is:\n" ) message += e.message Yast2::Popup.show(message, headline: :error) @@ -965,8 +968,8 @@ def read_xml(profile) 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" + "Check the log files for more details or fix the\n" \ + "control file and try again.\n" ) ) return false @@ -1026,10 +1029,10 @@ def Process(result_profile) Report.Error( _( "\n" \ - "User-defined classes could not be retrieved. Make sure all classes \n" \ - "are defined correctly and available for this system via the network\n" \ - "or locally. The system cannot be installed with the original control \n" \ - "file without using classes.\n" + "User-defined classes could not be retrieved. Make sure all classes \n" \ + "are defined correctly and available for this system via the network\n" \ + "or locally. The system cannot be installed with the original control \n" \ + "file without using classes.\n" ) ) diff --git a/src/modules/AutoinstCommon.rb b/src/modules/AutoinstCommon.rb index 416b9eaa1..7b5982581 100644 --- a/src/modules/AutoinstCommon.rb +++ b/src/modules/AutoinstCommon.rb @@ -104,7 +104,7 @@ def set(objectDefinition, obj, field, value) publish function: :hasValidType, type: "boolean (map , string, any)" publish function: :areEqual, type: "boolean (map , map )" publish function: :set, type: "map " \ - "(map , map , string, any)" + "(map , map , string, any)" end AutoinstCommon = AutoinstCommonClass.new diff --git a/src/modules/AutoinstConfig.rb b/src/modules/AutoinstConfig.rb index 514e87a87..0260dfd3f 100644 --- a/src/modules/AutoinstConfig.rb +++ b/src/modules/AutoinstConfig.rb @@ -391,43 +391,44 @@ def ParseCmdLine(profile_location) # @return [void] def SetProtocolMessage - @message = if @scheme == "floppy" + @message = case @scheme + when "floppy" _("Retrieving control file from floppy.") - elsif @scheme == "tftp" + when "tftp" Builtins.sformat( _("Retrieving control file (%1) from TFTP server: %2."), @filepath, @host ) - elsif @scheme == "nfs" + when "nfs" Builtins.sformat( _("Retrieving control file (%1) from NFS server: %2."), @filepath, @host ) - elsif @scheme == "http" + when "http" Builtins.sformat( _("Retrieving control file (%1) from HTTP server: %2."), @filepath, @host ) - elsif @scheme == "ftp" + when "ftp" Builtins.sformat( _("Retrieving control file (%1) from FTP server: %2."), @filepath, @host ) - elsif @scheme == "file" + when "file" Builtins.sformat( _("Copying control file from file: %1."), @filepath ) - elsif @scheme == "device" + when "device" Builtins.sformat( _("Copying control file from device: /dev/%1."), @filepath ) - elsif @scheme == "default" + when "default" _("Copying control file from default location.") else _("Source unknown.") @@ -497,25 +498,24 @@ def AutoinstConfig end def MainHelp - main_help = _( + _( "

AutoYaST Configuration Management System

\n" \ - "

Almost all resources of the control file can be\n" \ - "configured using the configuration management system.

\n" + "

Almost all resources of the control file can be\n" \ + "configured using the configuration management system.

\n" ) + _( "

Most of the modules used to create the configuration are identical " \ - "to those available\n" \ - "through the YaST Control Center. Instead of configuring this system, the data\n" \ - "entered is collected and exported to the control file that can be used to\n" \ - "install another system using AutoYaST.\n" \ - "

\n" + "to those available\n" \ + "through the YaST Control Center. Instead of configuring this system, the data\n" \ + "entered is collected and exported to the control file that can be used to\n" \ + "install another system using AutoYaST.\n" \ + "

\n" ) + _( "

In addition to the existing and familiar modules,\n" \ - "new interfaces were created for special and complex configurations, including\n" \ - "partitioning, general options, and software.

\n" + "new interfaces were created for special and complex configurations, including\n" \ + "partitioning, general options, and software.

\n" ) - main_help end # Profile path during installation diff --git a/src/modules/AutoinstFile.rb b/src/modules/AutoinstFile.rb index e9d534448..2a844bf2b 100644 --- a/src/modules/AutoinstFile.rb +++ b/src/modules/AutoinstFile.rb @@ -156,13 +156,13 @@ def Write Ops.get_string(file, "file_location", ""), file_location ) - if !GetURL( + if GetURL( Ops.get_string(file, "file_location", ""), file_location ) - Builtins.y2error("file could not be retrieved") - else Builtins.y2milestone("file was retrieved") + else + Builtins.y2error("file could not be retrieved") end end if Ops.get_string(file, "file_permissions", "") != "" @@ -213,13 +213,13 @@ def Write "getting script: %1", Ops.get_string(script, "location", "") ) - if !GetURL(Ops.get_string(script, "location", ""), scriptPath) + if GetURL(Ops.get_string(script, "location", ""), scriptPath) + got_script = true + else Builtins.y2error( "script %1 could not be retrieved", Ops.get_string(script, "location", "") ) - else - got_script = true end end if !got_script @@ -231,7 +231,8 @@ def Write end scriptInterpreter = Ops.get_string(script, "interpreter", "shell") executionString = "" - if scriptInterpreter == "shell" + case scriptInterpreter + when "shell" executionString = Builtins.sformat( "/bin/sh -x %1 2&> %2/%3.log", scriptPath, @@ -239,7 +240,7 @@ def Write scriptName ) SCR.Execute(path(".target.bash"), executionString) - elsif scriptInterpreter == "perl" + when "perl" executionString = Builtins.sformat( "/usr/bin/perl %1 2&> %2/%3.log", scriptPath, @@ -247,7 +248,7 @@ def Write scriptName ) SCR.Execute(path(".target.bash"), executionString) - elsif scriptInterpreter == "python" + when "python" executionString = Builtins.sformat( "/usr/bin/python %1 2&> %2/%3.log", scriptPath, diff --git a/src/modules/AutoinstFunctions.rb b/src/modules/AutoinstFunctions.rb index 835b59a77..e77d42d23 100644 --- a/src/modules/AutoinstFunctions.rb +++ b/src/modules/AutoinstFunctions.rb @@ -64,13 +64,15 @@ def check_second_stage_environment unless registered? if Profile.current["suse_register"] && Profile.current["suse_register"]["do_registration"] == true - error << _("The registration has failed. " \ - "Please check your registration settings in the AutoYaST configuration file.") + error << _( + "The registration has failed. " \ + "Please check your registration settings in the AutoYaST configuration file." + ) log.warn "Registration has been called but has failed." else error << _("You have not registered your system. " \ - "Missing packages can be added by configuring the registration " \ - "in the AutoYaST configuration file.") + "Missing packages can be added by configuring the registration " \ + "in the AutoYaST configuration file.") log.warn "Registration is not configured at all." end end diff --git a/src/modules/AutoinstGeneral.rb b/src/modules/AutoinstGeneral.rb index eb640d407..c84906acf 100644 --- a/src/modules/AutoinstGeneral.rb +++ b/src/modules/AutoinstGeneral.rb @@ -152,7 +152,7 @@ def Summary _("Not accepting unknown GPG Keys") end ) - summary = Summary.AddLine( + Summary.AddLine( summary, if signature_handling["import_gpg_key"] _("Importing new GPG keys") @@ -160,8 +160,6 @@ def Summary _("Not importing new GPG Keys") end ) - - summary end # Import Configuration diff --git a/src/modules/AutoinstScripts.rb b/src/modules/AutoinstScripts.rb index b8cf47c7b..0385fa2b9 100644 --- a/src/modules/AutoinstScripts.rb +++ b/src/modules/AutoinstScripts.rb @@ -106,7 +106,7 @@ def Export groups = scripts.group_by { |s| s.class.type } - groups.each_with_object({}) { |(type, scs), result| result[type] = scs.map(&:to_hash) } + groups.transform_values { |scs| scs.map(&:to_hash) } end # Get all the configuration from a map. @@ -226,15 +226,16 @@ def AddEditScript(scriptName, source, interpreter, type, chrooted, debug, # @return [String] type as translated string def typeString(type) # TODO: move to script class - if type == "pre-scripts" + case type + when "pre-scripts" return _("Pre") - elsif type == "post-scripts" + when "post-scripts" return _("Post") - elsif type == "init-scripts" + when "init-scripts" return _("Init") - elsif type == "chroot-scripts" + when "chroot-scripts" return _("Chroot") - elsif type == "postpartitioning-scripts" + when "postpartitioning-scripts" return _("Postpartitioning") end @@ -272,8 +273,8 @@ def Write(type, special) publish function: :Summary, type: "string ()" publish function: :deleteScript, type: "void (string)" publish function: :AddEditScript, - type: "void (string, string, string, string, boolean, boolean, " \ - "boolean, boolean, string, string, string)" + type: "void (string, string, string, string, boolean, boolean, " \ + "boolean, boolean, string, string, string)" publish function: :typeString, type: "string (string)" publish function: :Write, type: "boolean (string, boolean)" diff --git a/src/modules/AutoinstSoftware.rb b/src/modules/AutoinstSoftware.rb index a1bb9d188..e72d49845 100644 --- a/src/modules/AutoinstSoftware.rb +++ b/src/modules/AutoinstSoftware.rb @@ -418,10 +418,10 @@ def Write if !Pkg.PkgSolve(false) # TRANSLATORS: Error message msg = _("The package resolver run failed. Please check your software " \ - "section in the autoyast profile.") + "section in the autoyast profile.") # TRANSLATORS: Error message, %s is replaced by "/var/log/YaST2/y2log" - msg += "\n" + _("Additional details can be found in the %s file.") % - "/var/log/YaST2/y2log" + msg += "\n" + (_("Additional details can be found in the %s file.") % + "/var/log/YaST2/y2log") # read the details saved by pkg-bindings if File.exist?(BAD_LIST_FILE) @@ -662,8 +662,8 @@ def SelectPackagesForInstallation # TRANSLATORS: Error message, %d is replaced by the amount of failed packages. error_message += _("and %d additional packages") % (failed_count - MAX_PACKAGE_VIEW) # TRANSLATORS: Error message, %s is replaced by "/var/log/YaST2/y2log" - error_message += "\n\n" + _("Details can be found in the %s file.") % - "/var/log/YaST2/y2log" + error_message += "\n\n" + (_("Details can be found in the %s file.") % + "/var/log/YaST2/y2log") end Report.Error(error_message) diff --git a/src/modules/AutoinstStorage.rb b/src/modules/AutoinstStorage.rb index 09ae88641..f372c888d 100644 --- a/src/modules/AutoinstStorage.rb +++ b/src/modules/AutoinstStorage.rb @@ -100,7 +100,7 @@ def ImportAdvanced(settings) # @return [Hash] General settings def export_general_settings # Do not export nil settings - general_settings.reject { |_key, value| value.nil? } + general_settings.compact end # Moved here from RootPart module (used just by this module) @@ -350,7 +350,7 @@ def proposal_settings_from_profile(profile) unless ignored.empty? log.warn( "Ignoring these elements from the general/storage/proposal " \ - "profile section: #{ignored.join(", ")}" + "profile section: #{ignored.join(", ")}" ) end diff --git a/src/modules/Profile.rb b/src/modules/Profile.rb index 995e2de2a..988b20bcc 100644 --- a/src/modules/Profile.rb +++ b/src/modules/Profile.rb @@ -35,6 +35,8 @@ class ProfileHash < Hash # Replace Hash -> ProfileHash recursively. def initialize(default = {}) + super() + default.each_pair do |key, value| self[key] = value.is_a?(Hash) ? ProfileHash.new(value) : value end @@ -70,7 +72,7 @@ def fetch_as(key, type, default = nil) f = caller_locations(2, 1).first if !tmp.nil? log.warn "AutoYaST profile type mismatch (from #{f}): " \ - "#{key}: expected #{type}, got #{tmp.class}" + "#{key}: expected #{type}, got #{tmp.class}" end tmp = default.is_a?(Hash) ? ProfileHash.new(default) : default end @@ -266,10 +268,10 @@ def generalCompat # @return [void] def check_version(properties) version = properties["version"] - if version != "3.0" - log.info("Wrong profile version #{version}") - else + if version == "3.0" log.info("AutoYaST Profile Version #{version} detected.") + else + log.info("Wrong profile version #{version}") end end @@ -287,12 +289,12 @@ def Import(profile) # old style if Builtins.haskey(profile, "configure") || Builtins.haskey(profile, "install") - __configure = Ops.get_map(profile, "configure", {}) - __install = Ops.get_map(profile, "install", {}) + configure = Ops.get_map(profile, "configure", {}) + install = Ops.get_map(profile, "install", {}) @current = Builtins.remove(@current, "configure") if Builtins.haskey(profile, "configure") @current = Builtins.remove(@current, "install") if Builtins.haskey(profile, "install") tmp = Convert.convert( - Builtins.union(__configure, __install), + Builtins.union(configure, install), from: "map", to: "map " ) @@ -414,7 +416,7 @@ def SaveSingleSections(dir) ) rescue XMLSerializationError => e log.error "Could not write section #{sectionName} to file #{sectionFileName}:" \ - "#{e.inspect}" + "#{e.inspect}" end end deep_copy(sectionFiles) @@ -449,42 +451,38 @@ def ReadProfileStructure(parsedControlFile) end # General compatibility issues - # @param __current [Hash] current profile + # @param current [Hash] current profile # @return [Hash] converted profile - def Compat(__current) - __current = deep_copy(__current) + def Compat(current) + current = deep_copy(current) # scripts - if Builtins.haskey(__current, "pre-scripts") || - Builtins.haskey(__current, "post-scripts") || - Builtins.haskey(__current, "chroot-scripts") - pre = Ops.get_list(__current, "pre-scripts", []) - post = Ops.get_list(__current, "post-scripts", []) - chroot = Ops.get_list(__current, "chroot-scripts", []) + if Builtins.haskey(current, "pre-scripts") || + Builtins.haskey(current, "post-scripts") || + Builtins.haskey(current, "chroot-scripts") + pre = Ops.get_list(current, "pre-scripts", []) + post = Ops.get_list(current, "post-scripts", []) + chroot = Ops.get_list(current, "chroot-scripts", []) scripts = { "pre-scripts" => pre, "post-scripts" => post, "chroot-scripts" => chroot } - __current = Builtins.remove(__current, "pre-scripts") - __current = Builtins.remove(__current, "post-scripts") - __current = Builtins.remove(__current, "chroot-scripts") + current = Builtins.remove(current, "pre-scripts") + current = Builtins.remove(current, "post-scripts") + current = Builtins.remove(current, "chroot-scripts") - Ops.set(__current, "scripts", scripts) + Ops.set(current, "scripts", scripts) end # general old = false - general_options = Ops.get_map(__current, "general", {}) - security = Ops.get_map(__current, "security", {}) - report = Ops.get_map(__current, "report", {}) + general_options = Ops.get_map(current, "general", {}) + security = Ops.get_map(current, "security", {}) + report = Ops.get_map(current, "report", {}) Builtins.foreach(general_options) do |k, v| - if k == "keyboard" && Ops.is_string?(v) - old = true - elsif k == "encryption_method" - old = true - elsif k == "timezone" && Ops.is_string?(v) + if k == "encryption_method" || (["keyboard", "timezone"].include?(k) && Ops.is_string?(v)) old = true end end @@ -512,9 +510,10 @@ def Compat(__current) "timezone", Ops.get_string(general_options, "timezone", "") ) - if Ops.get_string(general_options, "hwclock", "") == "localtime" + case Ops.get_string(general_options, "hwclock", "") + when "localtime" Ops.set(clock, "hwclock", "localtime") - elsif Ops.get_string(general_options, "hwclock", "") == "GMT" + when "GMT" Ops.set(clock, "hwclock", "GMT") end Ops.set(new_general, "clock", clock) @@ -541,7 +540,7 @@ def Compat(__current) ) end - net = Ops.get_map(__current, "networking", {}) + net = Ops.get_map(current, "networking", {}) ifaces = Ops.get_list(net, "interfaces", []) newifaces = Builtins.maplist(ifaces) do |iface| @@ -553,22 +552,20 @@ def Compat(__current) Ops.set(net, "interfaces", newifaces) - Ops.set(__current, "general", new_general) - Ops.set(__current, "report", report) - Ops.set(__current, "security", security) - Ops.set(__current, "networking", net) + Ops.set(current, "general", new_general) + Ops.set(current, "report", report) + Ops.set(current, "security", security) + Ops.set(current, "networking", net) end - deep_copy(__current) + deep_copy(current) end # Read XML into YCP data # @param file [String] path to file # @return [Boolean] def ReadXML(file) - if !GPG.encrypted_symmetric?(file) - content = File.read(file) - else + if GPG.encrypted_symmetric?(file) AutoinstConfig.ProfileEncrypted = true label = _("Encrypted AutoYaST profile.") @@ -591,6 +588,8 @@ def ReadXML(file) return false end end + else + content = File.read(file) end @current = XML.XMLToYCPString(content) @@ -610,7 +609,7 @@ def ReadXML(file) # autoyast has read the autoyast configuration file but something went wrong message = _( "The XML parser reported an error while parsing the autoyast profile. " \ - "The error message is:\n" + "The error message is:\n" ) message += e.message log.info "xml parsing error #{e.inspect}" @@ -780,7 +779,7 @@ def edit_profile(modules = nil, target: :default) end next unless export - resource_data = WFM.CallFunction(module_auto, ["Export", "target" => target.to_s]) + resource_data = WFM.CallFunction(module_auto, ["Export", { "target" => target.to_s }]) if tomerge.size < 2 s = (resource_data || {}).size diff --git a/src/modules/ProfileLocation.rb b/src/modules/ProfileLocation.rb index 6381fb0c9..ddfbc68a0 100644 --- a/src/modules/ProfileLocation.rb +++ b/src/modules/ProfileLocation.rb @@ -84,7 +84,9 @@ def Process url_str = InstURL.installInf2Url("") log.info("installation path from install.inf: #{url_str}") - if !url_str.empty? + if url_str.empty? + log.warn("Cannot evaluate ZyppRepoURL from /etc/install.inf") + else url = URL.Parse(url_str) AutoinstConfig.scheme = url["scheme"] AutoinstConfig.host = url["host"] @@ -96,14 +98,14 @@ def Process log.info("relurl for profile changed to: #{ayrelurl}") SCR.Write(path(".etc.install_inf.ayrelurl"), ayrelurl) SCR.Write(path(".etc.install_inf"), nil) - else - log.warn("Cannot evaluate ZyppRepoURL from /etc/install.inf") end end filename = basename(AutoinstConfig.filepath) - if filename != "" + if filename == "" + is_directory = true + else Builtins.y2milestone("File=%1", filename) Builtins.y2milestone( "Get %1://%2/%3 to %4", @@ -162,11 +164,7 @@ def Process end # render erb template - if AutoinstConfig.filepath.end_with?(".erb") - return false unless render_erb(localfile) - end - else - is_directory = true + return false if AutoinstConfig.filepath.end_with?(".erb") && !render_erb(localfile) end AutoinstConfig.directory = dirname(AutoinstConfig.filepath) diff --git a/test/AutoInstallRules_test.rb b/test/AutoInstallRules_test.rb index 141717836..08a07f8e2 100755 --- a/test/AutoInstallRules_test.rb +++ b/test/AutoInstallRules_test.rb @@ -139,7 +139,7 @@ ) expect(Yast::SCR).to receive(:Execute).with(Yast::Path.new(".target.bash_output"), "if ( [ \"$hostaddress\" = \"10.69.57.43\" ] ) || " \ - "( [ \"$mac\" = \"000c2903d288\" ] ); then exit 0; else exit 1; fi", + "( [ \"$mac\" = \"000c2903d288\" ] ); then exit 0; else exit 1; fi", env) .and_return("stdout" => "", "exit" => 0, "stderr" => "") @@ -159,7 +159,7 @@ ) expect(Yast::SCR).to receive(:Execute).with(Yast::Path.new(".target.bash_output"), "if ( [ \"$hostaddress\" = \"10.69.57.43\" ] ) && " \ - "( [ \"$mac\" = \"000c2903d288\" ] ); then exit 0; else exit 1; fi", + "( [ \"$mac\" = \"000c2903d288\" ] ); then exit 0; else exit 1; fi", env) .and_return("stdout" => "", "exit" => 0, "stderr" => "") @@ -178,7 +178,7 @@ ) expect(Yast::SCR).to receive(:Execute).with(Yast::Path.new(".target.bash_output"), "if ( [ \"$hostaddress\" = \"10.69.57.43\" ] ) && " \ - "( [ \"$mac\" = \"000c2903d288\" ] ); then exit 0; else exit 1; fi", + "( [ \"$mac\" = \"000c2903d288\" ] ); then exit 0; else exit 1; fi", env) .and_return("stdout" => "", "exit" => 0, "stderr" => "") @@ -242,9 +242,9 @@ let(:merge_xslt_path) { File.join(root_path, "xslt", "merge.xslt") } let(:xsltproc_command) do "/usr/bin/xsltproc --novalid --maxdepth 10000 --param replace \"'false'\" " \ - "--param with \"'#{to_merge_path}'\" "\ - "--output \"#{output_path}\" " \ - "#{merge_xslt_path} #{base_profile_path}" + "--param with \"'#{to_merge_path}'\" "\ + "--output \"#{output_path}\" " \ + "#{merge_xslt_path} #{base_profile_path}" end before(:each) do @@ -291,10 +291,10 @@ let(:dontmerge) { ["partition"] } let(:xsltproc_command) do "/usr/bin/xsltproc --novalid --maxdepth 10000 --param replace \"'false'\" " \ - "--param dontmerge1 \"'partition'\" " \ - "--param with \"'#{to_merge_path}'\" "\ - "--output \"#{output_path}\" " \ - "#{merge_xslt_path} #{base_profile_path}" + "--param dontmerge1 \"'partition'\" " \ + "--param with \"'#{to_merge_path}'\" "\ + "--output \"#{output_path}\" " \ + "#{merge_xslt_path} #{base_profile_path}" end it "does not merge those elements" do diff --git a/test/AutoinstClass_test.rb b/test/AutoinstClass_test.rb index 554943dd7..55c1b9186 100755 --- a/test/AutoinstClass_test.rb +++ b/test/AutoinstClass_test.rb @@ -242,9 +242,9 @@ let(:conf_to_merge) { { "class" => "swap", "name" => "largeswap.xml" } } let(:xsltproc_command) do "/usr/bin/xsltproc --novalid --maxdepth 10000 --param replace \"'false'\" " \ - "--param with \"'#{subject.findPath("largeswap.xml", "swap")}'\" "\ - "--output #{File.join(tmp_dir, "output.xml")} " \ - "#{merge_xslt_path} #{base_profile_path} " + "--param with \"'#{subject.findPath("largeswap.xml", "swap")}'\" "\ + "--output #{File.join(tmp_dir, "output.xml")} " \ + "#{merge_xslt_path} #{base_profile_path} " end before(:each) do @@ -291,10 +291,10 @@ let(:dontmerge) { ["partition"] } let(:xsltproc_command) do "/usr/bin/xsltproc --novalid --maxdepth 10000 --param replace \"'false'\" " \ - "--param dontmerge1 \"'partition'\" " \ - "--param with \"'#{subject.findPath("largeswap.xml", "swap")}'\" "\ - "--output #{File.join(tmp_dir, "output.xml")} " \ - "#{merge_xslt_path} #{base_profile_path} " + "--param dontmerge1 \"'partition'\" " \ + "--param with \"'#{subject.findPath("largeswap.xml", "swap")}'\" "\ + "--output #{File.join(tmp_dir, "output.xml")} " \ + "#{merge_xslt_path} #{base_profile_path} " end it "does not merge those elements" do diff --git a/test/AutoinstConfig_test.rb b/test/AutoinstConfig_test.rb index c79790a72..b1a348e60 100755 --- a/test/AutoinstConfig_test.rb +++ b/test/AutoinstConfig_test.rb @@ -101,7 +101,7 @@ let(:autoyast_profile_url) { "https://moo:woo@192.168.0.1:8080/path/auto-installation.xml" } it "parses the given profile location and fill internal structures " \ - "and returns boolean whether it succeded" do + "and returns boolean whether it succeded" do expect(subject.ParseCmdLine(autoyast_profile_url)).to eq(true) expect(subject.scheme).to eq("https") diff --git a/test/lib/clients/files_auto_test.rb b/test/lib/clients/files_auto_test.rb index 20b338161..2acb29661 100644 --- a/test/lib/clients/files_auto_test.rb +++ b/test/lib/clients/files_auto_test.rb @@ -71,7 +71,7 @@ end describe "#change" do - # note: It do more testing also of script_dialogs include as it is only user + # NOTE: It do more testing also of script_dialogs include as it is only user before do allow(Yast::UI).to receive(:UserInput).and_return(:next) diff --git a/test/lib/clients/report_auto_test.rb b/test/lib/clients/report_auto_test.rb index da89cebd7..6c8695d26 100644 --- a/test/lib/clients/report_auto_test.rb +++ b/test/lib/clients/report_auto_test.rb @@ -71,7 +71,7 @@ end describe "#change" do - # note: It do more testing also of script_dialogs include as it is only user + # NOTE: It do more testing also of script_dialogs include as it is only user before do allow(Yast::UI).to receive(:UserInput).and_return(:next) diff --git a/test/lib/clients/scripts_auto_test.rb b/test/lib/clients/scripts_auto_test.rb index 57870f9c5..7d803cddf 100644 --- a/test/lib/clients/scripts_auto_test.rb +++ b/test/lib/clients/scripts_auto_test.rb @@ -74,7 +74,7 @@ end describe "#change" do - # note: It do more testing also of script_dialogs include as it is only user + # NOTE: It do more testing also of script_dialogs include as it is only user before do allow(Yast::UI).to receive(:UserInput).and_return(:next) diff --git a/test/lib/package_searcher_test.rb b/test/lib/package_searcher_test.rb index 0ee462597..f94e05e40 100644 --- a/test/lib/package_searcher_test.rb +++ b/test/lib/package_searcher_test.rb @@ -34,13 +34,13 @@ let(:packages) do [ Y2Packager::Resolvable.new("kind" => :package, - "name" => "foo", "source" => 1, - "version" => "1.0", "arch" => "x86_64", "status" => :selected, - "deps" => [{ "provides" => "foo" }]), + "name" => "foo", "source" => 1, + "version" => "1.0", "arch" => "x86_64", "status" => :selected, + "deps" => [{ "provides" => "foo" }]), Y2Packager::Resolvable.new("kind" => :package, - "name" => "yast2-users", "source" => 1, - "version" => "1.0", "arch" => "x86_64", "status" => :selected, - "deps" => [{ "supplements" => "autoyast(groups:users)" }]) + "name" => "yast2-users", "source" => 1, + "version" => "1.0", "arch" => "x86_64", "status" => :selected, + "deps" => [{ "supplements" => "autoyast(groups:users)" }]) ] end diff --git a/test/lib/script_test.rb b/test/lib/script_test.rb index 26081b290..8e6b676bb 100755 --- a/test/lib/script_test.rb +++ b/test/lib/script_test.rb @@ -243,7 +243,7 @@ expect(Yast::SCR).to receive(:Execute).with( path(".target.bash"), " /bin/sh -x /var/adm/autoinstall/scripts/test.sh " \ - "&> /var/adm/autoinstall/logs/test.sh.log" + "&> /var/adm/autoinstall/logs/test.sh.log" ) subject.execute diff --git a/test/lib/xml_checks_test.rb b/test/lib/xml_checks_test.rb index ee8dd8f64..925fa0717 100755 --- a/test/lib/xml_checks_test.rb +++ b/test/lib/xml_checks_test.rb @@ -77,7 +77,7 @@ context "and it is the first time that the errors have been reported" do it "returns true if the user skipped the validation" do - allow(ENV).to receive(:"[]").with("YAST_SKIP_XML_VALIDATION").and_return("1") + allow(ENV).to receive(:[]).with("YAST_SKIP_XML_VALIDATION").and_return("1") expect(Yast2::Popup).to_not receive(:show) expect(subject.check(xml, schema, "title")).to eql(true) diff --git a/test/profile_test.rb b/test/profile_test.rb index a946c38b9..51f7142ab 100755 --- a/test/profile_test.rb +++ b/test/profile_test.rb @@ -342,7 +342,7 @@ def reboot_scripts allow(Yast::WFM).to receive(:CallFunction) .with("custom_auto", ["GetModified"]).and_return(true) allow(Yast::WFM).to receive(:CallFunction) - .with("custom_auto", ["Export", "target" => "default"]).and_return(custom_export) + .with("custom_auto", ["Export", { "target" => "default" }]).and_return(custom_export) allow(Yast::AutoinstClone).to receive(:General) .and_return("mode" => { "confirm" => false }) @@ -358,7 +358,7 @@ def reboot_scripts context "when a 'target' is given" do it "exports the module data using the given 'target'" do expect(Yast::WFM).to receive(:CallFunction) - .with("custom_auto", ["Export", "target" => "compact"]) + .with("custom_auto", ["Export", { "target" => "compact" }]) subject.Prepare(target: :compact) end end @@ -461,7 +461,7 @@ def reboot_scripts reset_singleton(Y2Autoinstallation::Entries::Registry) allow(Yast::WFM).to receive(:CallFunction).and_call_original allow(Yast::WFM).to receive(:CallFunction) - .with("custom_auto", ["Export", "target" => "default"]).and_return(custom_export) + .with("custom_auto", ["Export", { "target" => "default" }]).and_return(custom_export) end it "exports modules data into the current profile" do