diff --git a/package/yast2-registration.spec b/package/yast2-registration.spec index eb931811f..e7b92a723 100644 --- a/package/yast2-registration.spec +++ b/package/yast2-registration.spec @@ -31,18 +31,18 @@ Requires: yast2 >= 3.1.26 Requires: yast2-pkg-bindings >= 2.17.20 # N_() method Requires: yast2-ruby-bindings >= 3.1.12 -Requires: rubygem-suse-connect +Requires: rubygem-suse-connect >= 0.0.16 Requires: yast2-slp >= 3.1.2 Requires: yast2-add-on >= 3.1.3 -Requires: yast2-packager >= 3.1.14 +Requires: yast2-packager >= 3.1.16 BuildRequires: yast2 >= 3.1.26 BuildRequires: update-desktop-files BuildRequires: yast2-devtools >= 3.1.6 BuildRequires: rubygem-rspec -BuildRequires: rubygem-suse-connect +BuildRequires: rubygem-suse-connect >= 0.0.16 BuildRequires: yast2-slp >= 3.1.2 -BuildRequires: yast2-packager >= 3.1.14 +BuildRequires: yast2-packager >= 3.1.16 BuildArch: noarch diff --git a/src/lib/registration/registration.rb b/src/lib/registration/registration.rb index 8439cc7f3..6bafa8e31 100644 --- a/src/lib/registration/registration.rb +++ b/src/lib/registration/registration.rb @@ -106,6 +106,7 @@ def connect_params(params) :language => ::Registration::Helpers.language, :debug => ENV["SCCDEBUG"], :verbose => ENV["Y2DEBUG"] == "1", + :product => {}, #SwMgmt.base_product_to_register, # pass a verify_callback to get details about failed SSL verification :verify_callback => lambda do |verify_ok, context| # we cannot raise an exception with details here (all exceptions in diff --git a/src/lib/registration/ui/addon_eula_dialog.rb b/src/lib/registration/ui/addon_eula_dialog.rb index 3c2421701..22b99177c 100644 --- a/src/lib/registration/ui/addon_eula_dialog.rb +++ b/src/lib/registration/ui/addon_eula_dialog.rb @@ -10,11 +10,17 @@ module UI class AddonEulaDialog include Yast::Logger include Yast::I18n + include Yast::UIShortcuts attr_accessor :addons - Yast.import "Report" + # name of the index file with list of available licenses + INDEX_FILE = "directory.yast" + + Yast.import "Popup" Yast.import "ProductLicense" + Yast.import "Report" + Yast.import "Wizard" # create a new dialog for accepting importing a SSL certificate and run it def self.run(selected_addons) @@ -31,8 +37,17 @@ def initialize(selected_addons) # display the EULA for each dialog and wait for a button click # @return [Symbol] user input (:import, :cancel) def run + Yast::Wizard.SetContents( + # dialog title + _("License Agreement"), + Label(_("Downloading Licenses...")), + "", + false, + false + ) + all_accepted = addons.all? do |addon| - if addon.eula.url + if addon.eula_url log.info "Addon '#{addon.short_name}' has an EULA at #{addon.eula_url}" accept_eula(addon) else @@ -40,26 +55,31 @@ def run true end end - + # go back if any EULA has not been accepted, let the user deselect the # not accepted extension all_accepted ? :next : :back end - + private - + def accept_eula(addon) Dir.mktmpdir("extension-eula-") do |tmpdir| begin - download_liceses(addon.eula_url, tmpdir, insecure) + Yast::Popup.Feedback( + _("Downloading License Agreement..."), + addon.short_name + ) do + download_liceses(addon.eula_url, tmpdir) + end rescue Exception => e - log.error "Download failed: #{e.message}" + log.error "Download failed: #{e.message}: #{e.backtrace}" # %s is an extension name, e.g. "SUSE Linux Enterprise Software Development Kit" Yast::Report.Error(_("Downloading the license for\n%s\nfailed.") % addon.short_name) return false end - Yast::ProductLicense.AskLicensesAgreement( + Yast::ProductLicense.AskLicensesAgreementWithHeading( [tmpdir], Yast::ProductLicense.license_patterns, # do not continue if not accepted @@ -69,11 +89,15 @@ def accept_eula(addon) # base product false, # require agreement - true - ) == :next + true, + # dialog title + _("Extension or Module License Agreement"), + # %s is an extension name, e.g. "SUSE Linux Enterprise Software Development Kit" + _("%s License Agreement") % addon.short_name + ) == :accepted end end - + def download_file(file_url, insecure: false) url = file_url.is_a?(URI) ? file_url : URI(file_url) http = Net::HTTP.new(url.host, url.port) @@ -81,7 +105,7 @@ def download_file(file_url, insecure: false) # switch to HTTPS connection if needed if url.is_a? URI::HTTPS http.use_ssl = true - insecure = Registration::Helpers.insecure_registration + insecure = Helpers.insecure_registration http.verify_mode = insecure ? OpenSSL::SSL::VERIFY_NONE : OpenSSL::SSL::VERIFY_PEER log.warn("Warning: SSL certificate verification disabled") if insecure else @@ -103,31 +127,32 @@ def download_file(file_url, insecure: false) def download_liceses(license_url, target_dir) # download the index file (directory.yast) index_url = URI(license_url) - + # add the index file to the URL - index_url.path = File.join(index_url.path, "directory.yast") - + index_url.path = File.join(index_url.path, INDEX_FILE) + # download the index log.info "Downloading license index: #{index_url}" licenses = download_file(index_url).split + # the index file itself might be also present in the list, just remove it + licenses.reject!{|license| license == INDEX_FILE} log.info "Downloaded license index: #{licenses}" - + # download the files listed in the index licenses.each do |license| license_file_url = URI(license_url) - license_file_url.path = File.join(index_url.path, license) + license_file_url.path = File.join(license_file_url.path, license) log.info "Downloading license from #{license_file_url}..." license_text = download_file(license_file_url) log.info "Downloaded license size: #{license_text.size}" - + license_file_name = File.join(target_dir, license) - + log.info "Saving the license to file: #{license_file_name}" File.write(license_file_name, license_text) end end - end