Hello community, here is the log from the commit of package autoyast2 for openSUSE:Factory checked in at 2019-12-14 12:04:25 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/autoyast2 (Old) and /work/SRC/openSUSE:Factory/.autoyast2.new.4691 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "autoyast2" Sat Dec 14 12:04:25 2019 rev:267 rq:756887 version:4.2.24 Changes: -------- --- /work/SRC/openSUSE:Factory/autoyast2/autoyast2.changes 2019-11-20 10:27:09.270561293 +0100 +++ /work/SRC/openSUSE:Factory/.autoyast2.new.4691/autoyast2.changes 2019-12-14 12:05:28.883382128 +0100 @@ -1,0 +2,21 @@ +Fri Dec 13 14:26:11 UTC 2019 - Josef Reidinger <[email protected]> + +- Allow to run autoupgrade on registered system with almost empty + profile (jsc#SLE-7101) +- 4.2.24 + +------------------------------------------------------------------- +Fri Dec 6 13:14:34 UTC 2019 - Josef Reidinger <[email protected]> + +- Improve message when registration missing for autoupgrade with + online medium (jsc#SLE-7101) +- 4.2.23 + +------------------------------------------------------------------- +Mon Nov 18 16:42:31 CET 2019 - [email protected] + +- Using Y2Packager::Resolvable.any? and Y2Packager::Resolvable.find + in order to decrease the required memory (bsc#1132650, bsc#1140037). +- 4.2.22 + +------------------------------------------------------------------- Old: ---- autoyast2-4.2.21.tar.bz2 New: ---- autoyast2-4.2.24.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ autoyast2.spec ++++++ --- /var/tmp/diff_new_pack.Qfz4lb/_old 2019-12-14 12:05:29.855381959 +0100 +++ /var/tmp/diff_new_pack.Qfz4lb/_new 2019-12-14 12:05:29.855381959 +0100 @@ -22,7 +22,7 @@ %endif Name: autoyast2 -Version: 4.2.21 +Version: 4.2.24 Release: 0 Summary: YaST2 - Automated Installation License: GPL-2.0-only @@ -226,7 +226,6 @@ %{yast_moduledir}/AutoinstClone.rb %dir %{yast_yncludedir}/autoinstall %{yast_yncludedir}/autoinstall/io.rb -%{yast_yncludedir}/autoinstall/autoinst_dialogs.rb %{yast_yncludedir}/autoinstall/AdvancedPartitionDialog.rb %{yast_yncludedir}/autoinstall/DriveDialog.rb %{yast_yncludedir}/autoinstall/PartitionDialog.rb ++++++ autoyast2-4.2.21.tar.bz2 -> autoyast2-4.2.24.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.2.21/README.md new/autoyast2-4.2.24/README.md --- old/autoyast2-4.2.21/README.md 2019-11-15 16:35:19.000000000 +0100 +++ new/autoyast2-4.2.24/README.md 2019-12-13 18:56:19.000000000 +0100 @@ -61,6 +61,60 @@ ``` +Auto Upgrade +============= + +Beside unattended installation this module provide also ability to do unattended upgrade. + +### Features + +- Semi automatic mode +- Without autoyast profile on the boot command line it reads the profile from `/root/autoupg.xml` file +- When using the Online installation medium the AutoYaST XML profile can be empty + +### Testing + +To test autoupgrade run upgrade with parameters `autoupgrade=1` and profile e.g. +`autoyast=ftp://example.com/ay_upgrade.xml`. Following example profiles used +for testing online and full media. + +Online on registered system: +```xml +<?xml version="1.0"?> +<!DOCTYPE profile> +<profile xmlns="http://www.suse.com/1.0/yast2ns" xmlns:config="http://www.suse.com/1.0/configns"> +</profile> +``` + +Full on system without registration: +```xml +<?xml version="1.0"?> +<!DOCTYPE profile> +<profile xmlns="http://www.suse.com/1.0/yast2ns" xmlns:config="http://www.suse.com/1.0/configns"> + <upgrade> + <stop_on_solver_conflict config:type="boolean">true</stop_on_solver_conflict> + </upgrade> + + <software> + <products config:type="list"> + <listentry>SLES</listentry> + </products> + </software> + + <add-on> + <add_on_products config:type="list"> + <listentry> + <name>Basesystem</name> + <product>Basesystem</product> + <product_dir>/Module-Basesystem</product_dir> + <media_url>relurl://</media_url> + <ask_on_error config:type="boolean">false</ask_on_error> + </listentry> + </add_on_products> + </add-on> +</profile> +``` + Contact ======= diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.2.21/package/autoyast2.changes new/autoyast2-4.2.24/package/autoyast2.changes --- old/autoyast2-4.2.21/package/autoyast2.changes 2019-11-15 16:35:19.000000000 +0100 +++ new/autoyast2-4.2.24/package/autoyast2.changes 2019-12-13 18:56:19.000000000 +0100 @@ -1,4 +1,25 @@ ------------------------------------------------------------------- +Fri Dec 13 14:26:11 UTC 2019 - Josef Reidinger <[email protected]> + +- Allow to run autoupgrade on registered system with almost empty + profile (jsc#SLE-7101) +- 4.2.24 + +------------------------------------------------------------------- +Fri Dec 6 13:14:34 UTC 2019 - Josef Reidinger <[email protected]> + +- Improve message when registration missing for autoupgrade with + online medium (jsc#SLE-7101) +- 4.2.23 + +------------------------------------------------------------------- +Mon Nov 18 16:42:31 CET 2019 - [email protected] + +- Using Y2Packager::Resolvable.any? and Y2Packager::Resolvable.find + in order to decrease the required memory (bsc#1132650, bsc#1140037). +- 4.2.22 + +------------------------------------------------------------------- Thu Nov 14 07:43:39 UTC 2019 - Imobach Gonzalez Sosa <[email protected]> - Do not override all storage proposal settings when importing diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.2.21/package/autoyast2.spec new/autoyast2-4.2.24/package/autoyast2.spec --- old/autoyast2-4.2.21/package/autoyast2.spec 2019-11-15 16:35:19.000000000 +0100 +++ new/autoyast2-4.2.24/package/autoyast2.spec 2019-12-13 18:56:19.000000000 +0100 @@ -22,7 +22,7 @@ %endif Name: autoyast2 -Version: 4.2.21 +Version: 4.2.24 Release: 0 Summary: YaST2 - Automated Installation License: GPL-2.0-only @@ -226,7 +226,6 @@ %{yast_moduledir}/AutoinstClone.rb %dir %{yast_yncludedir}/autoinstall %{yast_yncludedir}/autoinstall/io.rb -%{yast_yncludedir}/autoinstall/autoinst_dialogs.rb %{yast_yncludedir}/autoinstall/AdvancedPartitionDialog.rb %{yast_yncludedir}/autoinstall/DriveDialog.rb %{yast_yncludedir}/autoinstall/PartitionDialog.rb diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.2.21/src/clients/inst_autoinit.rb new/autoyast2-4.2.24/src/clients/inst_autoinit.rb --- old/autoyast2-4.2.21/src/clients/inst_autoinit.rb 2019-11-15 16:35:19.000000000 +0100 +++ new/autoyast2-4.2.24/src/clients/inst_autoinit.rb 2019-12-13 18:56:19.000000000 +0100 @@ -1,288 +1,3 @@ -# File: clients/inst_autoinit.ycp -# Package: Auto-installation -# Summary: Parses XML Profile for automatic installation -# Authors: Anas Nashif <[email protected]> -# -# $Id$ -# +require "autoinstall/clients/inst_autoinit" -require "autoinstall/autosetup_helpers" -require "y2packager/medium_type" - -module Yast - class InstAutoinitClient < Client - include Y2Autoinstallation::AutosetupHelpers - include Yast::Logger - - def main - Yast.import "UI" - - textdomain "autoinst" - - Yast.import "AutoInstall" - Yast.import "AutoInstallRules" - Yast.import "AutoinstConfig" - Yast.import "AutoinstFunctions" - Yast.import "AutoinstGeneral" - Yast.import "Call" - Yast.import "Console" - Yast.import "InstURL" - Yast.import "Installation" - Yast.import "Mode" - Yast.import "Popup" - Yast.import "Profile" - Yast.import "ProfileLocation" - Yast.import "Progress" - Yast.import "Report" - Yast.import "URL" - Yast.import "Y2ModuleConfig" - - Yast.include self, "autoinstall/autoinst_dialogs.rb" - - Console.Init - - @help_text = _( - "<p>\nPlease wait while the system is prepared for autoinstallation.</p>\n" - ) - @progress_stages = [ - _("Probe hardware"), - _("Retrieve & Read Control File"), - _("Parse control file"), - _("Initial Configuration") - ] - @profileFetched = false - - Progress.New( - _("Preparing System for Automatic Installation"), - "", # progress_title - 6, # progress bar length - @progress_stages, - [], - @help_text - ) - Progress.NextStage - Progress.Title(_("Preprobing stage")) - Builtins.y2milestone("pre probing") - - @tmp = Convert.to_string( - SCR.Read(path(".target.string"), "/etc/install.inf") - ) - if [email protected]? && Builtins.issubstring(Builtins.tolower(@tmp), "iscsi: 1") - WFM.CallFunction("inst_iscsi-client", []) - end - - Progress.NextStep - Progress.Title(_("Probing hardware...")) - Builtins.y2milestone("Probing hardware...") - - if !@profileFetched - # if profile is defined, first read it, then probe hardware - @autoinstall = SCR.Read(path(".etc.install_inf.AutoYaST")) - if Mode.autoupgrade && - !([email protected]? && Ops.is_string?(@autoinstall) && - Convert.to_string(@autoinstall) != "") - AutoinstConfig.ParseCmdLine("file:///mnt/root/autoupg.xml") - AutoinstConfig.ProfileInRootPart = true - end - - @ret = processProfile - return @ret if @ret != :ok - end - - Progress.Finish - - # when installing from the online installation medium we need to - # register the system earlier because the medium does not contain any - # repositories, we need the repositories from the registration server - # TODO: maybe we will need it also in the autoupgrade case... - if Y2Packager::MediumType.online? - # check that the registration section is defined and registration is enabled - reg_section = Yast::Profile.current.fetch(REGISTER_SECTION, {}) - reg_enabled = reg_section["do_registration"] - - if !reg_enabled - msg = _("Registration is mandatory when using the online " \ - "installation medium. Enable registration in " \ - "the AutoYaST profile.") - Popup.LongError(msg) # No timeout because we are stopping the installation/upgrade. - - return :abort - end - - suse_register if !Mode.autoupgrade - # offline registration need here to init software management according to picked product - elsif Y2Packager::MediumType.offline? - product = AutoinstFunctions.selected_product - - # duplicite code, but for offline medium we need to do it before system is initialized as - # we get need product for initialize libzypp, but for others we need first init libzypp - # to get available products. - if !product - msg = _("None or wrong base product has been defined " \ - "in the AutoYaST configuration file. " \ - "Please check the <b>products</b> entry in the <b>software</b> section.<br><br>" \ - "Following base products are available:<br>") - AutoinstFunctions.available_base_products.each do |product| - # FIXME: here we abuse knowledge that base product is ProductLocation and not Product - msg += "#{product.details.product} (#{product.details.summary})<br>" - end - Popup.LongError(msg) # No timeout because we are stopping the installation/upgrade. - return :abort - end - - show_popup = true - base_url = Yast::InstURL.installInf2Url("") - log_url = Yast::URL.HidePassword(base_url) - Yast::Packages.Initialize_StageInitial(show_popup, base_url, log_url, product.dir) - # select the product to install - Yast::Pkg.ResolvableInstall(product.details.product, :product, "") - # initialize addons and the workflow manager - Yast::AddOnProduct.SetBaseProductURL(base_url) - Yast::WorkflowManager.SetBaseWorkflow(false) - Yast::AutoinstFunctions.reset_product - end - - if !(Mode.autoupgrade && AutoinstConfig.ProfileInRootPart) - @ret = WFM.CallFunction("inst_system_analysis", []) - return @ret if @ret == :abort - end - - if Builtins.haskey(Profile.current, "iscsi-client") - Builtins.y2milestone("iscsi-client found") - WFM.CallFunction( - "iscsi-client_auto", - ["Import", Ops.get_map(Profile.current, "iscsi-client", {})] - ) - WFM.CallFunction("iscsi-client_auto", ["Write"]) - end - - if Builtins.haskey(Profile.current, "fcoe-client") - Builtins.y2milestone("fcoe-client found") - WFM.CallFunction( - "fcoe-client_auto", - ["Import", Ops.get_map(Profile.current, "fcoe-client", {})] - ) - WFM.CallFunction("fcoe-client_auto", ["Write"]) - end - - if !Y2Packager::MediumType.offline? && !AutoinstFunctions.selected_product - msg = _("None or wrong base product has been defined in the AutoYaST configuration file. " \ - "Please check the <b>products</b> entry in the <b>software</b> section.<br><br>" \ - "Following base products are available:<br>") - AutoinstFunctions.available_base_products.each do |product| - msg += "#{product.name} (#{product.display_name})<br>" - end - Popup.LongError(msg) # No timeout because we are stopping the installation/upgrade. - return :abort - end - - return :abort if UI.PollInput == :abort && Popup.ConfirmAbort(:painless) - - :next - end - - private - - # Checking profile for unsupported sections. - def check_unsupported_profile_sections - unsupported_sections = Y2ModuleConfig.unsupported_profile_sections - if unsupported_sections.any? - log.error "Could not process these unsupported profile " \ - "sections: #{unsupported_sections}" - Report.LongWarning( - # TRANSLATORS: Error message, %s is replaced by newline-separated - # list of unsupported sections of the profile - # Do not translate words in brackets - _( - "These sections of AutoYaST profile are not supported " \ - "anymore:<br><br>%s<br><br>" \ - "Please, use, e.g., <scripts/> or <files/>" \ - " to change the configuration." - ) % unsupported_sections.map { |section| "<#{section}/>" }.join("<br>") - ) - end - end - - def processProfile - Progress.NextStage - Builtins.y2milestone("Starting processProfile msg:%1", AutoinstConfig.message) - Progress.Title(AutoinstConfig.message) - Progress.NextStep - loop do - r = ProfileLocation.Process - if r - break - else - newURI = ProfileSourceDialog(AutoinstConfig.OriginalURI) - if newURI == "" - return :abort - else - # Updating new URI in /etc/install.inf (bnc#963487) - # SCR.Write does not work in inst-sys here. - WFM.Execute( - path(".local.bash"), - "sed -i \'/AutoYaST:/c\AutoYaST: #{newURI}\' /etc/install.inf" - ) - - AutoinstConfig.ParseCmdLine(newURI) - AutoinstConfig.SetProtocolMessage - next - end - end - end - - return :abort if UI.PollInput == :abort && Popup.ConfirmAbort(:painless) - - # - # Set reporting behaviour to default, changed later if required - # - Report.LogMessages(true) - Report.LogErrors(true) - Report.LogWarnings(true) - - return :abort if UI.PollInput == :abort && Popup.ConfirmAbort(:painless) - - Progress.NextStage - Progress.Title(_("Parsing control file")) - Builtins.y2milestone("Parsing control file") - if !Profile.ReadXML(AutoinstConfig.xml_tmpfile) || Profile.current == {} || - Profile.current.nil? - 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" - ) - ) - return :abort - end - - Builtins.y2debug("Autoinstall control file %1", Profile.current) - - # Checking profile for unsupported sections. - check_unsupported_profile_sections - - Progress.NextStage - Progress.Title(_("Initial Configuration")) - Builtins.y2milestone("Initial Configuration") - Report.Import(Profile.current.fetch("report", {})) - AutoinstGeneral.Import(Profile.current.fetch("general", {})) - - # - # Copy the control file for easy access by user to a pre-defined - # directory - # - SCR.Execute( - path(".target.bash"), - Builtins.sformat( - "cp %1 %2/autoinst.xml", - AutoinstConfig.xml_tmpfile, - AutoinstConfig.profile_dir - ) - ) - :ok - end - end -end - -Yast::InstAutoinitClient.new.main +Y2Autoinstallation::Clients::InstAutoinit.run diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.2.21/src/clients/inst_store_upgrade_software.rb new/autoyast2-4.2.24/src/clients/inst_store_upgrade_software.rb --- old/autoyast2-4.2.21/src/clients/inst_store_upgrade_software.rb 2019-11-15 16:35:19.000000000 +0100 +++ new/autoyast2-4.2.24/src/clients/inst_store_upgrade_software.rb 2019-12-13 18:56:19.000000000 +0100 @@ -1,3 +1,5 @@ +require "y2packager/resolvable" + module Yast class InstStoreUpgradeSoftwareClient < Client def main @@ -10,10 +12,10 @@ return :auto if GetInstArgs.going_back # find out status of patterns - @patterns = Pkg.ResolvableProperties("", :pattern, "") || [] + @patterns = Y2Packager::Resolvable.find(kind: :pattern) || [] @patterns.select! do |p| - Ops.get(p, "transact_by") == :user || - Ops.get(p, "transact_by") == :app_high + p.transact_by == :user || + p.transact_by == :app_high end # note: does not matter if it is installed or to be installed, the resulting @@ -21,15 +23,12 @@ # and products @patterns_to_remove = [] @patterns_to_install = @patterns.map do |p| - if Ops.get(p, "status") == :selected || - Ops.get(p, "status") == :installed - next Ops.get_string(p, "name", "") - elsif Ops.get(p, "status") == :removed || - Ops.get(p, "status") == :available - @patterns_to_remove = Builtins.add( - @patterns_to_remove, - Ops.get_string(p, "name", "") - ) + if p.status == :selected || + p.status == :installed + next p.name + elsif p.status == :removed || + p.status == :available + @patterns_to_remove << p.name end nil @@ -49,23 +48,20 @@ Builtins.y2milestone("Packages to remove: %1", @packages_to_remove) # find out status of products - @products = Pkg.ResolvableProperties("", :product, "") || [] + @products = Y2Packager::Resolvable.find(kind: :product) || [] @products.select! do |p| - Ops.get(p, "transact_by") == :user || - Ops.get(p, "transact_by") == :app_high + p.transact_by == :user || + p.transact_by == :app_high end @products_to_remove = [] @products_to_install = @products.map do |p| - if Ops.get(p, "status") == :selected || - Ops.get(p, "status") == :installed - next Ops.get_string(p, "name", "") - elsif Ops.get(p, "status") == :removed || - Ops.get(p, "status") == :available - @products_to_remove = Builtins.add( - @products_to_remove, - Ops.get_string(p, "name", "") - ) + if p.status == :selected || + p.status == :installed + next p.name + elsif p.status == :removed || + p.status == :available + @products_to_remove << p.name end nil diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.2.21/src/clients/software_auto.rb new/autoyast2-4.2.24/src/clients/software_auto.rb --- old/autoyast2-4.2.21/src/clients/software_auto.rb 2019-11-15 16:35:19.000000000 +0100 +++ new/autoyast2-4.2.24/src/clients/software_auto.rb 2019-12-13 18:56:19.000000000 +0100 @@ -4,6 +4,9 @@ # Summary: Handle Package selections and packages # # $Id$ + +require "y2packager/resolvable" + module Yast class SoftwareAutoClient < Client def main @@ -183,7 +186,7 @@ false, true ) - patterns = Pkg.ResolvableProperties("", :pattern, "") + patterns = Y2Packager::Resolvable.find(kind: :pattern) Builtins.y2milestone("available patterns %1", patterns) # sort available_base_selections by order # $[ "order" : [ "name", "summary" ], .... ] @@ -228,15 +231,13 @@ patadd = [] if @ret != :back + all_patterns = Y2Packager::Resolvable.find( + kind: :pattern, status: :selected + ).map(&:name) Builtins.y2milestone( - "available patterns %1", - Pkg.ResolvableProperties("", :pattern, "") + "available patterns %1", all_patterns ) - Builtins.foreach(Pkg.ResolvableProperties("", :pattern, "")) do |p| - if Ops.get_symbol(p, "status", :nothing) == :selected - patadd = Builtins.add(patadd, Ops.get_string(p, "name", "")) - end - end + patadd = all_patterns else patadd = deep_copy(AutoinstSoftware.patterns) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.2.21/src/include/autoinstall/autoinst_dialogs.rb new/autoyast2-4.2.24/src/include/autoinstall/autoinst_dialogs.rb --- old/autoyast2-4.2.21/src/include/autoinstall/autoinst_dialogs.rb 2019-11-15 16:35:19.000000000 +0100 +++ new/autoyast2-4.2.24/src/include/autoinstall/autoinst_dialogs.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,75 +0,0 @@ -# File: modules/ProfileLocation.ycp -# Package: Auto-installation -# Summary: Process Auto-Installation Location -# Author: Anas Nashif <[email protected]> -# -# $Id$ -module Yast - module AutoinstallAutoinstDialogsInclude - def initialize_autoinstall_autoinst_dialogs(_include_target) - textdomain "autoinst" - Yast.import "Label" - Yast.import "Popup" - end - - # Shows a dialog when 'control file' can't be found - # @param [String] original Original value - # @return [String] new value - def ProfileSourceDialog(original) - helptext = _( - "<p>\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.</p>\n" - ) - title = _("System Profile Location") - - UI.OpenDialog( - Opt(:decorated), - HBox( - HWeight(30, RichText(helptext)), - HStretch(), - HSpacing(1), - HWeight( - 70, - VBox( - Heading(title), - VSpacing(1), - VStretch(), - MinWidth(60, - Left(TextEntry(Id(:uri), _("&Profile Location:"), original))), - VSpacing(1), - VStretch(), - HBox( - PushButton(Id(:retry), Opt(:default), Label.RetryButton), - PushButton(Id(:abort), Label.AbortButton) - ) - ) - ) - ) - ) - - uri = "" - loop do - ret = Convert.to_symbol(UI.UserInput) - - if ret == :abort && Popup.ConfirmAbort(:painless) - break - elsif ret == :retry - uri = Convert.to_string(UI.QueryWidget(Id(:uri), :Value)) - if uri == "" - next - else - break - end - end - end - - UI.CloseDialog - uri - end - end -end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.2.21/src/lib/autoinstall/autosetup_helpers.rb new/autoyast2-4.2.24/src/lib/autoinstall/autosetup_helpers.rb --- old/autoyast2-4.2.21/src/lib/autoinstall/autosetup_helpers.rb 2019-11-15 16:35:19.000000000 +0100 +++ new/autoyast2-4.2.24/src/lib/autoinstall/autosetup_helpers.rb 2019-12-13 18:56:19.000000000 +0100 @@ -82,8 +82,9 @@ return true unless registration_module_available? # do nothing general_section = Yast::Profile.current["general"] || {} - if Yast::Profile.current[REGISTER_SECTION] - return false unless Yast::WFM.CallFunction( + # autoupgrade detects itself if system is registered and if needed do migration via scc + if Yast::Profile.current[REGISTER_SECTION] || Yast::Mode.autoupgrade + Yast::WFM.CallFunction( "scc_auto", ["Import", Yast::Profile.current[REGISTER_SECTION]] ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.2.21/src/lib/autoinstall/clients/inst_autoinit.rb new/autoyast2-4.2.24/src/lib/autoinstall/clients/inst_autoinit.rb --- old/autoyast2-4.2.21/src/lib/autoinstall/clients/inst_autoinit.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/autoyast2-4.2.24/src/lib/autoinstall/clients/inst_autoinit.rb 2019-12-13 18:56:19.000000000 +0100 @@ -0,0 +1,382 @@ +require "autoinstall/autosetup_helpers" +require "y2packager/medium_type" + +Yast.import "AutoInstall" +Yast.import "AutoInstallRules" +Yast.import "AutoinstConfig" +Yast.import "AutoinstFunctions" +Yast.import "AutoinstGeneral" +Yast.import "Call" +Yast.import "Console" +Yast.import "InstURL" +Yast.import "Installation" +Yast.import "Linuxrc" +Yast.import "Mode" +Yast.import "Popup" +Yast.import "Profile" +Yast.import "ProfileLocation" +Yast.import "Progress" +Yast.import "Report" +Yast.import "UI" +Yast.import "URL" +Yast.import "Y2ModuleConfig" + +module Y2Autoinstallation + module Clients + class InstAutoinit + include Y2Autoinstallation::AutosetupHelpers + include Yast::Logger + include Yast::UIShortcuts + include Yast::I18n + extend Yast::I18n + + def self.run + new.run + end + + def initialize + textdomain "autoinst" + end + + def run + Yast::Console.Init + + help_text = _( + "<p>\nPlease wait while the system is prepared for autoinstallation.</p>\n" + ) + progress_stages = [ + _("Probe hardware"), + _("Retrieve & Read Control File"), + _("Parse control file"), + _("Initial Configuration") + ] + + Yast::Progress.New( + _("Preparing System for Automatic Installation"), + "", # progress_title + 6, # progress bar length + progress_stages, + [], + help_text + ) + Yast::Progress.NextStage + Yast::Progress.Title(_("Preprobing stage")) + log.info "pre probing" + + Yast::WFM.CallFunction("inst_iscsi-client", []) if Yast::Linuxrc.useiscsi + + Yast::Progress.NextStep + Yast::Progress.Title(_("Probing hardware...")) + log.info "Probing hardware..." + + autoupgrade_profile + + ret = processProfile + return ret if ret != :ok + + Yast::Progress.Finish + + # when installing from the online installation medium we need to + # register the system earlier because the medium does not contain any + # repositories, we need the repositories from the registration server + if Y2Packager::MediumType.online? && !Yast::Mode.autoupgrade + res = register_system + return res if res + # offline registration need here to init software management according to picked product + # or autoupgrade without scc + elsif Y2Packager::MediumType.offline? + res = offline_product + return res if res + end + + if !(Yast::Mode.autoupgrade && Yast::AutoinstConfig.ProfileInRootPart) + @ret = Yast::WFM.CallFunction("inst_system_analysis", []) + return @ret if @ret == :abort + end + + if Yast::Profile.current["iscsi-client"] + log.info "iscsi-client found" + Yast::WFM.CallFunction( + "iscsi-client_auto", + ["Import", Yast::Profile.current["iscsi-client"]] + ) + Yast::WFM.CallFunction("iscsi-client_auto", ["Write"]) + end + + if Yast::Profile.current["fcoe-client"] + log.info "fcoe-client found" + Yast::WFM.CallFunction( + "fcoe-client_auto", + ["Import", Yast::Profile.current["fcoe-client"]] + ) + Yast::WFM.CallFunction("fcoe-client_auto", ["Write"]) + end + + if !(Y2Packager::MediumType.offline? || Yast::AutoinstFunctions.selected_product || + Yast::Mode.autoupgrade) + msg = _("None or wrong base product has been defined " \ + "in the AutoYaST configuration file. " \ + "Please check the <b>products</b> entry in the <b>software</b> section.<br><br>" \ + "Following base products are available:<br>") + Yast::AutoinstFunctions.available_base_products.each do |product| + msg += "#{product.name} (#{product.display_name})<br>" + end + Yast::Popup.LongError(msg) # No timeout because we are stopping the installation/upgrade. + return :abort + end + + return :abort if Yast::UI.PollInput == :abort && Yast::Popup.ConfirmAbort(:painless) + + :next + end + + private + + # Checking profile for unsupported sections. + def check_unsupported_profile_sections + unsupported_sections = Yast::Y2ModuleConfig.unsupported_profile_sections + if unsupported_sections.any? + log.error "Could not process these unsupported profile " \ + "sections: #{unsupported_sections}" + Yast::Report.LongWarning( + # TRANSLATORS: Error message, %s is replaced by newline-separated + # list of unsupported sections of the profile + # Do not translate words in brackets + _( + "These sections of AutoYaST profile are not supported " \ + "anymore:<br><br>%s<br><br>" \ + "Please, use, e.g., <scripts/> or <files/>" \ + " to change the configuration." + ) % unsupported_sections.map { |section| "<#{section}/>" }.join("<br>") + ) + end + end + + def processProfile + Yast::Progress.NextStage + log.info "Starting processProfile msg:#{Yast::AutoinstConfig.message}" + Yast::Progress.Title(Yast::AutoinstConfig.message) + Yast::Progress.NextStep + loop do + r = Yast::ProfileLocation.Process + if r + break + else + newURI = ProfileSourceDialog(Yast::AutoinstConfig.OriginalURI) + if newURI == "" + return :abort + else + # Updating new URI in /etc/install.inf (bnc#963487) + # SCR.Write does not work in inst-sys here. + Yast::WFM.Execute( + Yast::Path.new(".local.bash"), + "sed -i \'/AutoYaST:/c\AutoYaST: #{newURI}\' /etc/install.inf" + ) + + Yast::AutoinstConfig.ParseCmdLine(newURI) + Yast::AutoinstConfig.SetProtocolMessage + next + end + end + end + + return :abort if Yast::UI.PollInput == :abort && Yast::Popup.ConfirmAbort(:painless) + + # + # Set reporting behaviour to default, changed later if required + # + Yast::Report.LogMessages(true) + Yast::Report.LogErrors(true) + Yast::Report.LogWarnings(true) + + return :abort if Yast::UI.PollInput == :abort && Yast::Popup.ConfirmAbort(:painless) + + Yast::Progress.NextStage + Yast::Progress.Title(_("Parsing control file")) + log.info "Parsing control file" + if !Yast::Profile.ReadXML(Yast::AutoinstConfig.xml_tmpfile) || Yast::Profile.current.nil? + 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" + ) + ) + return :abort + end + + Yast::Builtins.y2debug("Autoinstall control file %1", Yast::Profile.current) + + # Checking profile for unsupported sections. + check_unsupported_profile_sections + + Yast::Progress.NextStage + Yast::Progress.Title(_("Initial Configuration")) + log.info "Initial Configuration" + Yast::Report.Import(Yast::Profile.current.fetch("report", {})) + Yast::AutoinstGeneral.Import(Yast::Profile.current.fetch("general", {})) + + # + # Copy the control file for easy access by user to a pre-defined + # directory + # + Yast::SCR.Execute( + Yast::Path.new(".target.bash"), + Yast::Builtins.sformat( + "cp %1 %2/autoinst.xml", + Yast::AutoinstConfig.xml_tmpfile, + Yast::AutoinstConfig.profile_dir + ) + ) + :ok + end + + # Shows a dialog when 'control file' can't be found + # @param [String] original Original value + # @return [String] new value + def ProfileSourceDialog(original) + helptext = _( + "<p>\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.</p>\n" + ) + title = _("System Profile Location") + + Yast::UI.OpenDialog( + Opt(:decorated), + HBox( + HWeight(30, RichText(helptext)), + HStretch(), + HSpacing(1), + HWeight( + 70, + VBox( + Heading(title), + VSpacing(1), + VStretch(), + MinWidth(60, + Left(TextEntry(Id(:uri), _("&Profile Location:"), original))), + VSpacing(1), + VStretch(), + HBox( + PushButton(Id(:retry), Opt(:default), Yast::Label.RetryButton), + PushButton(Id(:abort), Yast::Label.AbortButton) + ) + ) + ) + ) + ) + + uri = "" + loop do + ret = Yast::Convert.to_symbol(Yast::UI.UserInput) + + if ret == :abort && Yast::Popup.ConfirmAbort(:painless) + break + elsif ret == :retry + uri = Yast::Convert.to_string(UI.QueryWidget(Id(:uri), :Value)) + if uri == "" + next + else + break + end + end + end + + Yast::UI.CloseDialog + uri + end + + # Sets on disk autoyast profile for autoupgrade if autoyast profile is not specified. + def autoupgrade_profile + return unless Yast::Mode.autoupgrade + + # if profile is defined, first read it, then probe hardware + autoinstall = Yast::Linuxrc.InstallInf("AutoYaST") + # feature that allows to have file on upgraded system at /root/autoupg.xml + return if !autoinstall.nil? && !autoinstall.empty? + + Yast::AutoinstConfig.ParseCmdLine("file:///mnt/root/autoupg.xml") + Yast::AutoinstConfig.ProfileInRootPart = true + end + + # Register system acoording to profile + # @return nil if all is fine or :abort if unrecoverable error found + def register_system + # check that the registration section is defined and registration is enabled + reg_section = Yast::Profile.current.fetch(REGISTER_SECTION, {}) + reg_enabled = reg_section["do_registration"] + + if !reg_enabled + msg = _("Registration is mandatory when using the online " \ + "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. + + return :abort + end + + suse_register + + nil + end + + # sets product and initialize it for offline installation + # @return nil if all is fine or :abort if unrecoverable error found + def offline_product + product = Yast::AutoinstFunctions.selected_product + + # if addons contain relurl. If so, then product have to defined, otherwise relurl + # cannot be expanded in autoupgrade + addon_profile = (Yast::Profile.current["add-on"] || {}) + addons = (addon_profile["add_on_products"] || []) + (addon_profile["add_on_others"] || []) + addons_relurl = addons.find { |a| (a["relurl"] || "") =~ /relurl:\/\// } + + # duplicite code, but for offline medium we need to do it before system is initialized as + # we get need product for initialize libzypp, but for others we need first init libzypp + # to get available products. + if product + show_popup = true + base_url = Yast::InstURL.installInf2Url("") + log_url = Yast::URL.HidePassword(base_url) + Yast::Packages.Initialize_StageInitial(show_popup, base_url, log_url, product.dir) + # select the product to install + Yast::Pkg.ResolvableInstall(product.details.product, :product, "") + # initialize addons and the workflow manager + Yast::AddOnProduct.SetBaseProductURL(base_url) + Yast::WorkflowManager.SetBaseWorkflow(false) + Yast::AutoinstFunctions.reset_product + # report error only for installation or if autoupgrade contain addon with relative url. + # This way autoupgrade for Full medium on registered system + # can autoupgrade with empty profile. + elsif !Yast::Mode.autoupgrade || addons_relurl + msg = if Yast::Mode.autoupgrade && addons_relurl + _("None or wrong base product has been defined " \ + "in the AutoYaST configuration file. " \ + "It needs to be specified as base for addons that use relurl scheme." \ + "Please check the <b>products</b> entry in the <b>software</b> section.<br><br>" \ + "Following base products are available:<br>") + else + _("None or wrong base product has been defined " \ + "in the AutoYaST configuration file. " \ + "Please check the <b>products</b> entry in the <b>software</b> section.<br><br>" \ + "Following base products are available:<br>") + end + Yast::AutoinstFunctions.available_base_products.each do |bp| + # FIXME: here we abuse knowledge that base product is ProductLocation and not Product + # so we access that details which is not available in Product + msg += "#{bp.details.product} (#{bp.details.summary})<br>" + end + Yast::Popup.LongError(msg) # No timeout because we are stopping the installation/upgrade. + return :abort + end + + nil + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.2.21/src/modules/AutoinstSoftware.rb new/autoyast2-4.2.24/src/modules/AutoinstSoftware.rb --- old/autoyast2-4.2.21/src/modules/AutoinstSoftware.rb 2019-11-15 16:35:19.000000000 +0100 +++ new/autoyast2-4.2.24/src/modules/AutoinstSoftware.rb 2019-12-13 18:56:19.000000000 +0100 @@ -8,6 +8,7 @@ require "yast" require "y2storage" require "y2packager/product" +require "y2packager/resolvable" module Yast class AutoinstSoftwareClass < Module @@ -108,12 +109,10 @@ @instsource = settings.fetch("instsource", "") @packagesAvailable = Pkg.GetPackages(:available, true) - @patternsAvailable = [] - allPatterns = Pkg.ResolvableDependencies("", :pattern, "") - Builtins.filter(allPatterns) do |m| - @patternsAvailable.push(m.fetch("name", "")) if m.fetch("user_visible", false) - m.fetch("user_visible", false) - end + @patternsAvailable = Y2Packager::Resolvable.find( + kind: :pattern, + user_visible: true + ).map(&:name) regexFound = [] Ops.set( @@ -863,8 +862,8 @@ # switch for recommended patterns installation (workaround for our very weird pattern design) if sw_settings.fetch("install_recommended", false) == false # set SoftLock to avoid the installation of recommended patterns (#159466) - Builtins.foreach(Pkg.ResolvableProperties("", :pattern, "")) do |p| - Pkg.ResolvableSetSoftLock(Ops.get_string(p, "name", ""), :pattern) + Y2Packager::Resolvable.find(kind: :pattern).each do |p| + Pkg.ResolvableSetSoftLock(p.name, :pattern) end end @@ -1020,23 +1019,15 @@ Pkg.SourceStartManager(true) Pkg.PkgSolve(false) - all_patterns = Pkg.ResolvableProperties("", :pattern, "") - @all_xpatterns = Pkg.ResolvableDependencies("", :pattern, "") + @all_xpatterns = Y2Packager::Resolvable.find(kind: :pattern) to_install_packages = install_packages patterns = [] - # FIXME: filter method but it use only side effect of filling patterns - Builtins.filter(all_patterns) do |p| - ret2 = false - if Ops.get_symbol(p, "status", :none) == :installed && - !Builtins.contains(patterns, Ops.get_string(p, "name", "no name")) - patterns = Builtins.add( - patterns, - Ops.get_string(p, "name", "no name") - ) - ret2 = true + @all_xpatterns.each do |p| + if p.status == :installed && + !patterns.include?(p.name) + (patterns << p.name.empty?) ? "no name" : p.name end - ret2 end Pkg.TargetFinish @@ -1051,7 +1042,7 @@ new_p = [] Builtins.foreach(patterns) do |tmp_pattern| xpattern = Builtins.filter(@all_xpatterns) do |p| - Ops.get_string(p, "name", "") == tmp_pattern + p.name == tmp_pattern end found = Ops.get(xpattern, 0, {}) req = false @@ -1092,15 +1083,13 @@ # "packages" -> list<string> user selected packages # "remove-packages" -> list<string> packages to remove def read_initial_stage - install_patterns = Pkg.ResolvableProperties("", :pattern, "").collect do |pattern| - # Do not take care about if the pattern has been selected by the user or the product - # definition, cause we need a base selection here for the future - # autoyast installation. (bnc#882886) - if pattern["user_visible"] && - (pattern["status"] == :selected || pattern["status"] == :installed) - pattern["name"] + install_patterns = + Y2Packager::Resolvable.find(kind: :pattern, user_visible: true).map do |pattern| + # Do not take care about if the pattern has been selected by the user or the product + # definition, cause we need a base selection here for the future + # autoyast installation. (bnc#882886) + pattern.name if pattern.status == :selected || pattern.status == :installed end - end software = {} software["packages"] = install_packages diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.2.21/src/modules/AutoinstStorage.rb new/autoyast2-4.2.24/src/modules/AutoinstStorage.rb --- old/autoyast2-4.2.21/src/modules/AutoinstStorage.rb 2019-11-15 16:35:19.000000000 +0100 +++ new/autoyast2-4.2.24/src/modules/AutoinstStorage.rb 2019-12-13 18:56:19.000000000 +0100 @@ -43,8 +43,6 @@ # general/storage settings self.general_settings = {} - - Yast.include self, "autoinstall/autoinst_dialogs.rb" end # Get all the configuration from a map. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.2.21/src/modules/ProfileLocation.rb new/autoyast2-4.2.24/src/modules/ProfileLocation.rb --- old/autoyast2-4.2.21/src/modules/ProfileLocation.rb 2019-11-15 16:35:19.000000000 +0100 +++ new/autoyast2-4.2.24/src/modules/ProfileLocation.rb 2019-12-13 18:56:19.000000000 +0100 @@ -24,7 +24,6 @@ Yast.import "URL" Yast.import "InstURL" - Yast.include self, "autoinstall/autoinst_dialogs.rb" Yast.include self, "autoinstall/io.rb" ProfileLocation() end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.2.21/test/lib/clients/inst_autoinit_test.rb new/autoyast2-4.2.24/test/lib/clients/inst_autoinit_test.rb --- old/autoyast2-4.2.21/test/lib/clients/inst_autoinit_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/autoyast2-4.2.24/test/lib/clients/inst_autoinit_test.rb 2019-12-13 18:56:19.000000000 +0100 @@ -0,0 +1,136 @@ +#!/usr/bin/env rspec +# Copyright (c) [2019] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require_relative "../../test_helper" +require "autoinstall/clients/inst_autoinit" + +describe Y2Autoinstallation::Clients::InstAutoinit do + before do + allow(Yast::UI).to receive(:UserInput).and_return(:next) + allow(Yast::WFM).to receive(:CallFunction).and_return(true) + # can easily ends up in endless loop + allow(subject).to receive(:ProfileSourceDialog).and_return("") + allow(Yast::Linuxrc).to receive(:useiscsi).and_return(false) + allow(Yast::Linuxrc).to receive(:InstallInf).and_return(nil) + allow(Yast::ProfileLocation).to receive(:Process).and_return(true) + allow(Yast::Profile).to receive(:ReadXML).and_return(true) + allow(Yast::Profile).to receive(:current).and_return({}) + allow(Yast::Mode).to receive(:autoupgrade).and_return(true) + allow(Yast::AutoinstFunctions).to receive(:available_base_products).and_return([]) + allow(Y2Packager::MediumType).to receive(:online?).and_return(true) + Yast::AutoinstConfig.ProfileInRootPart = false + + end + + describe "#run" do + it "inits console module" do + expect(Yast::Console).to receive(:Init) + + subject.run + end + + it "shows progress" do + expect(Yast::Progress).to receive(:New) + + subject.run + end + + it "calls iscsi client if linuxrc wants iscsi" do + expect(Yast::Linuxrc).to receive(:useiscsi).and_return(true) + + expect(Yast::WFM).to receive(:CallFunction).with("inst_iscsi-client", []) + + subject.run + end + + it "reads profile from root for autoupgrade when linuxrc does not specify profile" do + allow(Yast::Mode).to receive(:autoupgrade).and_return(true) + allow(Yast::Linuxrc).to receive(:InstallInf).with("AutoYaST").and_return(nil) + + subject.run + + expect(Yast::AutoinstConfig.ProfileInRootPart).to eq true + end + + it "analyses system if it is not done already for profile in root" do + expect(Yast::WFM).to receive(:CallFunction).with("inst_system_analysis", []) + allow(Yast::Linuxrc).to receive(:InstallInf).with("AutoYaST") + .and_return("ftp://test.conf/AY.xml") + + subject.run + end + + it "calls iscsci client import and write if profile contain it" do + map = { "enabled" => false } + allow(Yast::Profile).to receive(:current).and_return("iscsi-client" => map) + expect(Yast::WFM).to receive(:CallFunction).with("iscsi-client_auto", ["Import", map]) + expect(Yast::WFM).to receive(:CallFunction).with("iscsi-client_auto", ["Write"]) + + subject.run + end + + it "calls fcoe client import and write if profile contain it" do + map = { "enabled" => false } + allow(Yast::Profile).to receive(:current).and_return("fcoe-client" => map) + expect(Yast::WFM).to receive(:CallFunction).with("fcoe-client_auto", ["Import", map]) + expect(Yast::WFM).to receive(:CallFunction).with("fcoe-client_auto", ["Write"]) + + subject.run + end + + it "reports error for installation with full medium without specified product" do + allow(Y2Packager::MediumType).to receive(:online?).and_return(false) + allow(Y2Packager::MediumType).to receive(:offline?).and_return(true) + allow(Yast::Mode).to receive(:autoupgrade).and_return(false) + + expect(Yast::Popup).to receive(:LongError) + + expect(subject.run).to eq :abort + end + + it "registers system for installation with online medium" do + map = { "suse_register" => { "do_registration" => true } } + allow(Yast::Mode).to receive(:autoupgrade).and_return(false) + allow(Yast::Profile).to receive(:current).and_return(map) + expect(Yast::WFM).to receive(:CallFunction) + .with("scc_auto", ["Import", map["suse_register"]]) + expect(Yast::WFM).to receive(:CallFunction).with("scc_auto", ["Write"]) + # fake that registration is available to avoid build requires + allow(subject).to receive(:registration_module_available?).and_return(true) + allow(Yast::Profile).to receive(:remove_sections) + + subject.run + end + + it "reports error for installation with online medium without register section" do + map = { "suse_register" => { "do_registration" => false } } + allow(Yast::Mode).to receive(:autoupgrade).and_return(false) + allow(Yast::Profile).to receive(:current).and_return(map) + expect(Yast::WFM).to_not receive(:CallFunction) + .with("scc_auto", ["Import", map["suse_register"]]) + expect(Yast::WFM).to_not receive(:CallFunction).with("scc_auto", ["Write"]) + expect(Yast::Popup).to receive(:LongError) + + expect(subject.run).to eq :abort + end + + # TODO: more test for profile processing + end +end
