Hello community, here is the log from the commit of package yast2 for openSUSE:Factory checked in at 2019-09-23 13:17:22 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2 (Old) and /work/SRC/openSUSE:Factory/.yast2.new.7948 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2" Mon Sep 23 13:17:22 2019 rev:460 rq:732625 version:4.2.23 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2/yast2.changes 2019-09-04 08:58:40.659072095 +0200 +++ /work/SRC/openSUSE:Factory/.yast2.new.7948/yast2.changes 2019-09-23 13:17:24.613105028 +0200 @@ -1,0 +2,27 @@ +Mon Sep 23 07:27:27 UTC 2019 - Ladislav Slezák <[email protected]> + +- Use "display_name" tag for the product label, "label" marks a + translatable text (jsc#SLE-7214) +- 4.2.23 + +------------------------------------------------------------------- +Thu Sep 19 12:05:17 UTC 2019 - Ladislav Slezák <[email protected]> + +- Added support for reading products from control.xml file + (jsc#SLE-7104) +- 4.2.22 + +------------------------------------------------------------------- +Tue Sep 10 07:57:34 UTC 2019 - Steffen Winterfeldt <[email protected]> + +- support reading licenses from tar archive (jsc#SLE-7214) +- 4.2.21 + +------------------------------------------------------------------- +Fri Sep 6 11:15:40 UTC 2019 - Imobach Gonzalez Sosa <[email protected]> + +- Fix a problem when long warnings reports in command line + (bsc#1149776). +- 4.2.20 + +------------------------------------------------------------------- Old: ---- yast2-4.2.19.tar.bz2 New: ---- yast2-4.2.23.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2.spec ++++++ --- /var/tmp/diff_new_pack.kCzutQ/_old 2019-09-23 13:17:25.457104876 +0200 +++ /var/tmp/diff_new_pack.kCzutQ/_new 2019-09-23 13:17:25.465104875 +0200 @@ -17,8 +17,9 @@ Name: yast2 -Version: 4.2.19 +Version: 4.2.23 Release: 0 + Summary: YaST2 Main Package License: GPL-2.0-only Group: System/YaST ++++++ yast2-4.2.19.tar.bz2 -> yast2-4.2.23.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/library/general/src/modules/Report.rb new/yast2-4.2.23/library/general/src/modules/Report.rb --- old/yast2-4.2.19/library/general/src/modules/Report.rb 2019-08-30 11:55:44.000000000 +0200 +++ new/yast2-4.2.23/library/general/src/modules/Report.rb 2019-09-23 09:58:23.000000000 +0200 @@ -566,7 +566,7 @@ if @display_warnings if Mode.commandline - CommandLine.Print("Warning: #{error_string}") + CommandLine.Print("Warning: #{warning_string}") elsif Ops.greater_than(@timeout_warnings, 0) Popup.TimedLongWarningGeometry(warning_string, @timeout_warnings, width, height) else diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/library/general/test/report_test.rb new/yast2-4.2.23/library/general/test/report_test.rb --- old/yast2-4.2.19/library/general/test/report_test.rb 2019-08-30 11:55:44.000000000 +0200 +++ new/yast2-4.2.23/library/general/test/report_test.rb 2019-09-23 09:58:23.000000000 +0200 @@ -108,6 +108,17 @@ subject.LongWarning("Message") expect(subject.GetMessages(0, 1, 0, 0)).to match(/Message/) end + + context "when running on command line mode" do + before do + allow(Yast::Mode).to receive(:commandline).and_return(true) + end + + it "prints the message" do + expect(Yast::CommandLine).to receive(:Print).with("Warning: message") + subject.LongWarning("message") + end + end end describe ".LongError" do @@ -128,6 +139,17 @@ subject.LongError("Message") expect(subject.GetMessages(0, 1, 0, 0)).to match(/Message/) end + + context "when running on command line mode" do + before do + allow(Yast::Mode).to receive(:commandline).and_return(true) + end + + it "prints the message" do + expect(Yast::CommandLine).to receive(:Print).with("Error: message") + subject.LongError("message") + end + end end describe ".Settings" do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/library/packages/src/lib/y2packager/licenses_fetchers/archive.rb new/yast2-4.2.23/library/packages/src/lib/y2packager/licenses_fetchers/archive.rb --- old/yast2-4.2.19/library/packages/src/lib/y2packager/licenses_fetchers/archive.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-4.2.23/library/packages/src/lib/y2packager/licenses_fetchers/archive.rb 2019-09-23 09:58:23.000000000 +0200 @@ -0,0 +1,167 @@ +# ------------------------------------------------------------------------------ +# Copyright (c) 2018 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. +# ------------------------------------------------------------------------------ + +require "y2packager/licenses_fetchers/base" +require "tmpdir" + +Yast.import "Pkg" + +module Y2Packager + module LicensesFetchers + # Base class for licenses fetchers based on some kind of license + # archive. + # + # It takes care of looking up the licenses in the unpacked + # archive and manages a temporary cache directory. + # + # The actual unpacking and provisioning of the archive file itself must + # be done in a derived class. + class Archive < Base + # Acceptance is not needed if the file exists + NO_ACCEPTANCE_FILE = "no-acceptance-needed".freeze + + # Fallback license file + FALLBACK_LICENSE_FILE = "LICENSE.TXT".freeze + + # Return available locales for product's license + # + # @return [Array<String>] Language codes ("de_DE", "en_US", etc.) + def locales + return [] if !archive_exists? + + @locales ||= + begin + unpack_archive + + license_files = Dir.glob(File.join(archive_dir, "**", "LICENSE.*.TXT"), File::FNM_CASEFOLD) + # NOTE: despite the use of the case-insensitive flag, the captured group will be + # returned as it is. + languages = license_files.map { |path| path[/LICENSE.(\w*).TXT/i, 1] } + languages << DEFAULT_LANG + languages.compact.uniq + end + end + + # Determine whether the license should be accepted or not + # + # @return [Boolean] true if the license acceptance is required + def confirmation_required? + unpack_archive + + find_path_for(archive_dir, NO_ACCEPTANCE_FILE).nil? + end + + # Explicit destructor to clean up temporary dir + # + # @param dir [String] Temporary directory where licenses were unpacked + def self.finalize(dir) + proc { FileUtils.remove_entry_secure(dir) } + end + + private + + attr_reader :archive_dir + + # Check if a license archive exists + # + # Will be overloaded by the actual implementation. + # + # @return [Boolean] True, if an archive exists + def archive_exists? + false + end + + # Unpack license archive + # + # The idea is to unpack the archive once and keep the temporary directory. + # + # This is only a stub that provides the temporary directory. The + # actual archive unpacking has to be done by the derived class. + # + # @return [String] Archive directory + def unpack_archive + return @archive_dir if @archive_dir + + @archive_dir = Dir.mktmpdir("yast-licenses-") + ObjectSpace.define_finalizer(self, self.class.finalize(@archive_dir)) + @archive_dir + end + + # Return the license content for a language + # + # The license archive is extracted to a temporary directory. When a + # license for a language "xx_XX" is not found, fall back to "xx". + # + # @see license_file + # + # @param lang [String] Language code + # + # @return [Array<String, String>, nil] Array containing content and language code + def license_content_for(lang) + return nil if !archive_exists? + + unpack_archive + + license_file = license_path(archive_dir, lang) || fallback_path(archive_dir) + + if license_file.nil? + log.error("#{lang} license file not found for #{product_name}") + + return nil + end + + File.read(license_file) + end + + # Return license file path for the given languages + # + # When a license for a language "xx_XX" is not found, it will fallback to "xx". + # + # @param directory [String] Directory where licenses were unpacked + # @param lang [String] Language code + # + # @return [String, nil] The first licence path for given languages or nil + def license_path(directory, lang) + candidate_langs = [lang] + candidate_langs << lang.split("_", 2).first if lang + candidate_langs.uniq! + + log.info("Searching for a #{candidate_langs.join(",")} license translation in #{directory}") + + find_path_for(directory, "LICENSE.{#{candidate_langs.join(",")}}.TXT") + end + + # Return the fallback license file path + # + # Looking for a license file without language code + # + # @param directory [String] Directory where licenses were unpacked + # + # @return [String, nil] The fallback license path + def fallback_path(directory) + log.info("Searching for a fallback #{FALLBACK_LICENSE_FILE} file in #{directory}") + + find_path_for(directory, FALLBACK_LICENSE_FILE) + end + + # Return the path for the given file in specified directory + # + # @param directory [String] Directory where licenses were unpacked + # @param file [String] File name (without directory component) + # + # @return [String, nil] The file path; nil if was not found + def find_path_for(directory, file) + Dir.glob(File.join(directory, "**", file), File::FNM_CASEFOLD).first + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/library/packages/src/lib/y2packager/licenses_fetchers/base.rb new/yast2-4.2.23/library/packages/src/lib/y2packager/licenses_fetchers/base.rb --- old/yast2-4.2.19/library/packages/src/lib/y2packager/licenses_fetchers/base.rb 2019-08-30 11:55:44.000000000 +0200 +++ new/yast2-4.2.23/library/packages/src/lib/y2packager/licenses_fetchers/base.rb 2019-09-23 09:58:23.000000000 +0200 @@ -11,7 +11,6 @@ # ------------------------------------------------------------------------------ require "yast" -require "y2packager/licenses_fetchers/base" Yast.import "Pkg" @@ -28,30 +27,74 @@ # Constructor # - # @param product_name [String] to get licenses for + # @param product_name [String] Product for which to get licenses def initialize(product_name, _options = {}) @product_name = product_name end - # Check if is a valid fecher based on content for default language + # Check if this is a valid fecher based on the existence of license content for default language # - # @return [Booelan] true if there is content for the default language; false otherwise. + # @return [Booelan] true if there is license content for the default language; false otherwise def found? !default_content.empty? end + # Return the license content + # + # @param lang [String] Language + # + # @return [String, nil] Product's license; nil if no license was found + def content(lang) + # FIXME: not #default_content at some place? + if default_lang?(lang) && @default_content + return (@default_content&.empty?) ? nil : @default_content + end + + license_content_for(lang) + end + + # Return available language codes for the license of the product + # + # @return [Array<String>] Language codes ("de_DE", "en_US", etc.) + def locales + [] + end + + # Determine whether the license should be accepted or not + # + # @return [Boolean] true if license acceptance is required + def confirmation_required? + true + end + private - # Return (and caches) the content found for the default language + # Return (and cache) the license content for the default language # - # @return [String] the license content for the default language; empty if nothing was found. + # @return [String] license content for the default language; empty if nothing was found def default_content @default_content ||= content(DEFAULT_LANG).to_s end + # Check for default language + # + # @param lang [String] Language + # + # @return [Boolean] True, if this was the default language def default_lang?(lang) lang == DEFAULT_LANG end + + # Return the license content for a specific language + # + # When a license for language "xx_XX" is not found, fall back to "xx". + # + # @param lang [String] Language + # + # @return [Array<String, String>, nil] Array containing license content and language code + def license_content_for(_lang) + nil + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/library/packages/src/lib/y2packager/licenses_fetchers/libzypp.rb new/yast2-4.2.23/library/packages/src/lib/y2packager/licenses_fetchers/libzypp.rb --- old/yast2-4.2.19/library/packages/src/lib/y2packager/licenses_fetchers/libzypp.rb 2019-08-30 11:55:44.000000000 +0200 +++ new/yast2-4.2.23/library/packages/src/lib/y2packager/licenses_fetchers/libzypp.rb 2019-09-23 09:58:23.000000000 +0200 @@ -17,17 +17,6 @@ # This class is responsible for obtaining the license and license content # of a given product from libzypp. class Libzypp < Base - # Return the license text to be confirmed - # - # @param lang [String] Language - # - # @return [String, nil] Product's license; nil if the product or the license were not found. - def content(lang) - return @default_content if default_lang?(lang) && @default_content - - Yast::Pkg.PrdGetLicenseToConfirm(product_name, lang) - end - # Return available locales for product's license # # @return [Array<String>] Language codes ("de_DE", "en_US", etc.) @@ -43,6 +32,19 @@ locales[empty_idx] = DEFAULT_LANG if empty_idx locales end + + # Determine whether the license should be accepted or not + # + # @return [Boolean] true if license acceptance is required + def confirmation_required? + Yast::Pkg.PrdNeedToAcceptLicense(product_name) + end + + private + + def license_content_for(lang) + Yast::Pkg.PrdGetLicenseToConfirm(product_name, lang) + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/library/packages/src/lib/y2packager/licenses_fetchers/rpm.rb new/yast2-4.2.23/library/packages/src/lib/y2packager/licenses_fetchers/rpm.rb --- old/yast2-4.2.19/library/packages/src/lib/y2packager/licenses_fetchers/rpm.rb 2019-08-30 11:55:44.000000000 +0200 +++ new/yast2-4.2.23/library/packages/src/lib/y2packager/licenses_fetchers/rpm.rb 2019-09-23 09:58:23.000000000 +0200 @@ -10,136 +10,54 @@ # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. # ------------------------------------------------------------------------------ -require "y2packager/licenses_fetchers/base" +require "y2packager/licenses_fetchers/archive" module Y2Packager module LicensesFetchers # This class is responsible for obtaining the license and license content # of a given product from a RPM package - class Rpm < Base - # Return the license text to be confirmed - # - # @param lang [String] Language - # - # @return [String, nil] Product's license; nil if the product or the license were not found - def content(lang) - return @default_content if default_lang?(lang) && @default_content - - if package.nil? - log.info("No package found for #{product_name}") - - return nil - end - - license_content_for(lang) - end - - # Return available locales for product's license - # - # @return [Array<String>] Language codes ("de_DE", "en_US", etc.) - def locales - if package.nil? - log.error "Error getting license translations: no package found for #{product_name}" - - return [] - end - - @locales ||= - begin - tmpdir = Dir.mktmpdir - package.extract_to(tmpdir) - # TODO: Use rpm -qpl file.rpm instead? - license_files = Dir.glob(File.join(tmpdir, "**", "LICENSE.*.TXT"), File::FNM_CASEFOLD) - # NOTE: despite the use of the case-insensitive flag, the captured group will be - # returned as it is. - languages = license_files.map { |path| path[/LICENSE.(\w*).TXT/i, 1] } - languages << DEFAULT_LANG - languages.compact.uniq - ensure - FileUtils.remove_entry_secure(tmpdir) - end - end + class Rpm < Archive + # FIXME: there's (ATM) no way to indent the 'private' below so rubocop accepts it + # rubocop:disable Layout/IndentationWidth private - # Return the license content for a package and language - # - # Package is extracted to a work directory. When a license for a language "xx_XX" is not - # found, it will fallback to "xx". - # - # @see license_file - # - # @param package [Y2Packager::Package] Product package - # @param lang [String] Searched language - # - # @return [Array<String, String>, nil] Array containing content and language code - def license_content_for(lang) - tmpdir = Dir.mktmpdir - package.extract_to(tmpdir) - license_file = license_path(tmpdir, lang) || fallback_path(tmpdir) + # rubocop:enable Layout/IndentationWidth - if license_file.nil? - log.error("#{lang} license file not found for #{product_name}") - - return - end - - File.read(license_file) - ensure - FileUtils.remove_entry_secure(tmpdir) - end - - # Return license file path for the given languages - # - # When a license for a language "xx_XX" is not found, it will fallback to "xx". + # Check if a license archive exists # - # @param directory [String] Directory where licenses were uncompressed - # @param lang [String] Searched translation - # - # @return [String, lang] The first licence path for given languages or nil - def license_path(directory, lang) - candidate_langs = [lang] - candidate_langs << lang.split("_", 2).first if lang - candidate_langs.uniq! - - log.info("Searching for a #{candidate_langs.join(",")} license translations in #{directory}") - - find_path_for(directory, "LICENSE.{#{candidate_langs.join(",")}}.TXT") + # @return [Boolean] True, if an archive exists + def archive_exists? + !package.nil? end - # Fallback license file - FALLBACK_LICENSE_FILE = "LICENSE.TXT".freeze - - # Return the fallback license file path + # Unpack license archive # - # Looking for a license file without language code + # This will unpack the archive once and keep the temporary directory. # - # @param directory [String] Directory where licenses were uncompressed - # - # @return [String, nil] The fallback license path - def fallback_path(directory) - log.info("Searching for a fallback #{FALLBACK_LICENSE_FILE} file in #{directory}") - - find_path_for(directory, FALLBACK_LICENSE_FILE) - end - - # Return the path for the given file in specified directory + # If the unpacking fails, the directory is still returned but the + # directory is empty. # - # @param directory [String] Directory where licenses were uncompressed - # @param file [String] Searched file + # The provisioning of a temporary dir is done be the parent class. # - # @return [String, nil] The file path; nil if was not found - def find_path_for(directory, file) - Dir.glob(File.join(directory, "**", file), File::FNM_CASEFOLD).first + # @return [String] Unpacked archive directory + def unpack_archive + if !archive_dir + archive_dir = super + package&.extract_to(archive_dir) + end + archive_dir end # Find the highest version of available/selected product package # # @return [Y2Packager::Package, nil] Package containing licenses; nil if not found def package - return nil if package_name.nil? + @package ||= Y2Packager::Package.last_version(package_name) if !package_name.nil? + + log.info("No license package found for #{product_name}") if @package.nil? - @package ||= Y2Packager::Package.last_version(package_name) + @package end # Find the package name diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/library/packages/src/lib/y2packager/licenses_fetchers/tarball.rb new/yast2-4.2.23/library/packages/src/lib/y2packager/licenses_fetchers/tarball.rb --- old/yast2-4.2.19/library/packages/src/lib/y2packager/licenses_fetchers/tarball.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-4.2.23/library/packages/src/lib/y2packager/licenses_fetchers/tarball.rb 2019-09-23 09:58:23.000000000 +0200 @@ -0,0 +1,79 @@ +# ------------------------------------------------------------------------------ +# Copyright (c) 2018 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. +# ------------------------------------------------------------------------------ + +require "y2packager/licenses_fetchers/archive" + +require "shellwords" + +Yast.import "InstURL" + +module Y2Packager + module LicensesFetchers + # This class is responsible for obtaining the license and license content + # of a given product from a tar archive (.tar.gz) + class Tarball < Archive + # FIXME: there's (ATM) no way to indent the 'private' below so rubocop accepts it + # rubocop:disable Layout/IndentationWidth + + private + + # rubocop:enable Layout/IndentationWidth + + attr_reader :archive_file_name + + # Check if a license archive exists + # + # @return [Boolean] True, if an archive exists + def archive_exists? + unpack_archive + !@archive_file_name.nil? + end + + # Download and unpack license archive + # + # This will download and unpack the archive once and keep the + # temporary directory. + # + # If the unpacking fails, the directory is still returned but the + # directory is empty. + # + # The provisioning of a temporary dir is done be the parent class. + # + # @return [String] Unpacked archive directory + def unpack_archive + return archive_dir if archive_dir + + archive_dir = super + + url = Yast::InstURL.installInf2Url("") + expanded_url = Yast::Pkg.ExpandedUrl(url) + + src = Yast::Pkg.RepositoryAdd("base_urls" => [expanded_url]) + @archive_file_name = Yast::Pkg.SourceProvideFile(src, 1, archive_name) + + system("tar -C #{archive_dir.shellescape} -x -f #{@archive_file_name.shellescape}") if @archive_file_name + + archive_dir + ensure + # remove the temporary repository + Yast::Pkg.SourceDelete(src) if src + end + + # The expected file name of the license archive + # + # @return [String] Archive file name + def archive_name + "license-#{product_name}.tar.gz" + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/library/packages/src/lib/y2packager/licenses_fetchers.rb new/yast2-4.2.23/library/packages/src/lib/y2packager/licenses_fetchers.rb --- old/yast2-4.2.19/library/packages/src/lib/y2packager/licenses_fetchers.rb 2019-08-30 11:55:44.000000000 +0200 +++ new/yast2-4.2.23/library/packages/src/lib/y2packager/licenses_fetchers.rb 2019-09-23 09:58:23.000000000 +0200 @@ -13,6 +13,7 @@ require "yast" require "y2packager/licenses_fetchers/libzypp" require "y2packager/licenses_fetchers/rpm" +require "y2packager/licenses_fetchers/tarball" module Y2Packager # This module contains licenses fetchers @@ -24,7 +25,7 @@ # Candidate sources to retrieve the license content. Note that order matters because it will be # chosen the first source able to fetch the content. - KNOWN_SOURCES = [:libzypp, :rpm].freeze + KNOWN_SOURCES = [:libzypp, :rpm, :tarball].freeze # Return the proper license fetcher # diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/library/packages/src/lib/y2packager/licenses_handlers/libzypp.rb new/yast2-4.2.23/library/packages/src/lib/y2packager/licenses_handlers/libzypp.rb --- old/yast2-4.2.19/library/packages/src/lib/y2packager/licenses_handlers/libzypp.rb 2019-08-30 11:55:44.000000000 +0200 +++ new/yast2-4.2.23/library/packages/src/lib/y2packager/licenses_handlers/libzypp.rb 2019-09-23 09:58:23.000000000 +0200 @@ -19,13 +19,6 @@ # This class is responsible for interacting with libzypp in order to get/set # the license acceptance status for a given product class Libzypp < Base - # Determine whether the license should be accepted or not - # - # @return [Boolean] true if the license acceptance is required - def confirmation_required? - Yast::Pkg.PrdNeedToAcceptLicense(product_name) - end - # Set the license confirmation for the product # # @param confirmed [Boolean] true if it should be accepted; false otherwise diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/library/packages/src/lib/y2packager/licenses_handlers/rpm.rb new/yast2-4.2.23/library/packages/src/lib/y2packager/licenses_handlers/rpm.rb --- old/yast2-4.2.19/library/packages/src/lib/y2packager/licenses_handlers/rpm.rb 2019-08-30 11:55:44.000000000 +0200 +++ new/yast2-4.2.23/library/packages/src/lib/y2packager/licenses_handlers/rpm.rb 2019-09-23 09:58:23.000000000 +0200 @@ -19,24 +19,6 @@ # This class is responsible for interacting with an rpm in order to get/set # the license acceptance status for a given product class Rpm < Base - NO_ACCEPTANCE_FILE = "no-acceptance-needed".freeze - - # Determine whether the license should be accepted or not - # - # @return [Boolean] true if the license acceptance is required - def confirmation_required? - return false unless package - - begin - tmpdir = Dir.mktmpdir - package.extract_to(tmpdir) - - Dir.glob(File.join(tmpdir, "**", NO_ACCEPTANCE_FILE), File::FNM_CASEFOLD).empty? - ensure - FileUtils.remove_entry_secure(tmpdir) - end - end - # Set the license confirmation for the product # # @param confirmed [Boolean] true if it should be accepted; false otherwise @@ -47,30 +29,6 @@ log.info("License was not accepted") end end - - private - - # Find the highest version of available/selected product package - # - # @return [Y2Packager::Package, nil] Package containing licenses; nil if not found - def package - return nil if package_name.nil? - - @package ||= Y2Packager::Package.last_version(package_name) - end - - # Find the package name - # - # @return [String, nil] the package name for the product; nil if not found - def package_name - return @package_name if @package_name - - package_properties = Yast::Pkg.ResolvableProperties(product_name, :product, "") - package_properties = package_properties.find { |props| props.key?("product_package") } - package_properties ||= {} - - @package_name = package_properties.fetch("product_package", nil) - end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/library/packages/src/lib/y2packager/licenses_handlers/tarball.rb new/yast2-4.2.23/library/packages/src/lib/y2packager/licenses_handlers/tarball.rb --- old/yast2-4.2.19/library/packages/src/lib/y2packager/licenses_handlers/tarball.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-4.2.23/library/packages/src/lib/y2packager/licenses_handlers/tarball.rb 2019-09-23 09:58:23.000000000 +0200 @@ -0,0 +1,35 @@ +# ------------------------------------------------------------------------------ +# Copyright (c) 2018 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. +# ------------------------------------------------------------------------------ + +require "y2packager/licenses_handlers/base" + +Yast.import "Pkg" +Yast.import "InstURL" + +module Y2Packager + module LicensesHandlers + # This class is responsible for interacting with an rpm in order to get/set + # the license acceptance status for a given product + class Tarball < Base + # Set the license confirmation for the product + # + # @param confirmed [Boolean] true if it should be accepted; false otherwise + def confirmation=(confirmed) + if confirmed + log.info("License was accepted") + else + log.info("License was not accepted") + end + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/library/packages/src/lib/y2packager/licenses_handlers.rb new/yast2-4.2.23/library/packages/src/lib/y2packager/licenses_handlers.rb --- old/yast2-4.2.19/library/packages/src/lib/y2packager/licenses_handlers.rb 2019-08-30 11:55:44.000000000 +0200 +++ new/yast2-4.2.23/library/packages/src/lib/y2packager/licenses_handlers.rb 2019-09-23 09:58:23.000000000 +0200 @@ -12,6 +12,7 @@ require "y2packager/licenses_handlers/libzypp" require "y2packager/licenses_handlers/rpm" +require "y2packager/licenses_handlers/tarball" module Y2Packager # This module contains licenses handlers diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/library/packages/src/lib/y2packager/product.rb new/yast2-4.2.23/library/packages/src/lib/y2packager/product.rb --- old/yast2-4.2.19/library/packages/src/lib/y2packager/product.rb 2019-08-30 11:55:44.000000000 +0200 +++ new/yast2-4.2.23/library/packages/src/lib/y2packager/product.rb 2019-09-23 09:58:23.000000000 +0200 @@ -13,7 +13,7 @@ Yast.import "Pkg" require "y2packager/product_reader" require "y2packager/release_notes_reader" -require "y2packager/product_license" +require "y2packager/product_license_mixin" module Y2Packager # Represent a product which is present in a repository. At this @@ -22,6 +22,7 @@ # repositories). class Product include Yast::Logger + include ProductLicenseMixin # @return [String] Name attr_reader :name @@ -223,69 +224,6 @@ display_name || short_name || name end - # Return the license to confirm - # - # @param lang [String] Language - # @return [ProductLicense,nil] Product's license; nil if the license was not found. - def license - @license ||= ProductLicense.find(name) - end - - # Return the license text to be confirmed - # - # @param lang [String] Language - # @return [String] Product's license; empty string ("") if no license was found. - def license_content(lang) - return "" unless license? - - license.content_for(lang) - end - - # Determines whether the product has a license - # - # @param lang [String] Language - # @return [Boolean] true if the product has a license - def license? - !!license - end - - # Determine whether the license should be accepted or not - # - # @return [Boolean] true if the license acceptance is required - def license_confirmation_required? - return false unless license? - - license.confirmation_required? - end - - # Set license confirmation for the product - # - # @param confirmed [Boolean] determines whether the license should be accepted or not - def license_confirmation=(confirmed) - return unless license - - confirmed ? license.accept! : license.reject! - end - - # Determine whether the license is confirmed - # - # @return [Boolean] true if the license was confirmed (or acceptance was not needed) - def license_confirmed? - return false unless license - - license.accepted? || !license_confirmation_required? - end - - # [String] Default license language. - DEFAULT_LICENSE_LANG = "en_US".freeze - - # Return available locales for product's license - # - # @return [Array<String>] Language codes ("de_DE", "en_US", etc.) - def license_locales - license.locales - end - # Return product's release notes # # @param format [Symbol] Release notes format (use :txt as default) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/library/packages/src/lib/y2packager/product_control_product.rb new/yast2-4.2.23/library/packages/src/lib/y2packager/product_control_product.rb --- old/yast2-4.2.19/library/packages/src/lib/y2packager/product_control_product.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-4.2.23/library/packages/src/lib/y2packager/product_control_product.rb 2019-09-23 09:58:23.000000000 +0200 @@ -0,0 +1,107 @@ +# ------------------------------------------------------------------------------ +# Copyright (c) 2019 SUSE LLC +# +# 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. +# +# To contact SUSE about this file by physical or electronic mail, you may find +# current contact information at www.suse.com. +# ------------------------------------------------------------------------------ + +require "yast" +require "y2packager/product_license_mixin" + +Yast.import "Arch" +Yast.import "Linuxrc" +Yast.import "ProductFeatures" + +module Y2Packager + # This class implements a base product read from the control.xml file. + class ProductControlProduct + extend Yast::Logger + include ProductLicenseMixin + + attr_reader :name, :version, :arch, :label, :license_url, :register_target + + # map the Arch.architecture to the arch expected by SCC + REG_ARCH = { + "s390_32" => "s390", + "s390_64" => "s390x", + # ppc64le is the only supported PPC arch, we do not have to distinguish the BE/LE variants + "ppc64" => "ppc64le" + }.freeze + + class << self + attr_accessor :selected + + # + # Read the base products from the control.xml file. The products for the incompatible + # machine architecture and the hidden products are filtered out. + # + # @return [Array<Installation::ProductControlProduct>] List of the products + def products + return @products if @products + + control_products = Yast::ProductFeatures.GetFeature("software", "base_products") + arch = REG_ARCH[Yast::Arch.architecture] || Yast::Arch.architecture + linuxrc_products = (Yast::Linuxrc.InstallInf("specialproduct") || "").split(",").map(&:strip) + + @products = control_products.each_with_object([]) do |p, array| + # a hidden product requested? + if p["special_product"] && !linuxrc_products.include?(p["name"]) + log.info "Skipping special hidden product #{p["name"]}" + next + end + + # compatible arch? + if p["archs"] && !p["archs"].split(",").map(&:strip).include?(arch) + log.info "Skipping product #{p["name"]} - not compatible with arch #{arch}" + next + end + + array << new( + name: p["name"], + version: p["version"], + arch: arch, + label: p["display_name"], + license_url: p["license_url"], + # expand the "$arch" placeholder + register_target: (p["register_target"] || "").gsub("$arch", arch) + ) + end + end + end + + # Constructor + # @param name [String] product name (the identifier, e.g. "SLES") + # @param version [String] version ("15.2") + # @param arch [String] The architecture ("x86_64") + # @param label [String] The user visible name ("SUSE Linux Enterprise Server 15 SP2") + # @param license_url [String] License URL + # @param register_target [String] The registration target name used + # for registering the product, the $arch variable is replaced + # by the current machine architecture + def initialize(name:, version:, arch:, label:, license_url:, register_target:) + @name = name + @version = version + @arch = arch + @label = label + @license_url = license_url + @register_target = register_target + end + + # Is the product selected? + # @return [Boolean] true if the product is the selected base product + def selected? + self == self.class.selected + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/library/packages/src/lib/y2packager/product_license.rb new/yast2-4.2.23/library/packages/src/lib/y2packager/product_license.rb --- old/yast2-4.2.19/library/packages/src/lib/y2packager/product_license.rb 2019-08-30 11:55:44.000000000 +0200 +++ new/yast2-4.2.23/library/packages/src/lib/y2packager/product_license.rb 2019-09-23 09:58:23.000000000 +0200 @@ -34,11 +34,12 @@ # @!method license_confirmation_required? # Determine whether the license should be accepted or not # @return [Boolean] true if the license acceptance is required - # + def_delegator :@fetcher, :confirmation_required? + # @!method license_confirmation=(confirmed) # Set the license confirmation for the product # @param confirmed [Boolean] true if it should be accepted; false otherwise - def_delegators :@handler, :confirmation_required?, :confirmation= + def_delegator :@handler, :confirmation= # @return [License] Product's license attr_reader :license @@ -78,6 +79,7 @@ @product_name = product_name @license = license @handler = license.handler + @fetcher = license.fetcher end # Determine whether the license have been accepted or not diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/library/packages/src/lib/y2packager/product_license_mixin.rb new/yast2-4.2.23/library/packages/src/lib/y2packager/product_license_mixin.rb --- old/yast2-4.2.19/library/packages/src/lib/y2packager/product_license_mixin.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-4.2.23/library/packages/src/lib/y2packager/product_license_mixin.rb 2019-09-23 09:58:23.000000000 +0200 @@ -0,0 +1,82 @@ +# ------------------------------------------------------------------------------ +# 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. +# ------------------------------------------------------------------------------ + +require "y2packager/product_license" + +module Y2Packager + # This module is used for sharing the license related methods + # for several types of products. + module ProductLicenseMixin + # Return the license to confirm + # + # @param lang [String] Language + # @return [ProductLicense,nil] Product's license; nil if the license was not found. + def license + @license ||= ProductLicense.find(name) + end + + # Return the license text to be confirmed + # + # @param lang [String] Language + # @return [String] Product's license; empty string ("") if no license was found. + def license_content(lang) + return "" unless license? + + license.content_for(lang) + end + + # Determines whether the product has a license + # + # @param lang [String] Language + # @return [Boolean] true if the product has a license + def license? + !!license + end + + # Determine whether the license should be accepted or not + # + # @return [Boolean] true if the license acceptance is required + def license_confirmation_required? + return false unless license? + + license.confirmation_required? + end + + # Set license confirmation for the product + # + # @param confirmed [Boolean] determines whether the license should be accepted or not + def license_confirmation=(confirmed) + return unless license + + confirmed ? license.accept! : license.reject! + end + + # Determine whether the license is confirmed + # + # @return [Boolean] true if the license was confirmed (or acceptance was not needed) + def license_confirmed? + return false unless license + + license.accepted? || !license_confirmation_required? + end + + # [String] Default license language. + DEFAULT_LICENSE_LANG = "en_US".freeze + + # Return available locales for product's license + # + # @return [Array<String>] Language codes ("de_DE", "en_US", etc.) + def license_locales + license.locales + end + end +end Binary files old/yast2-4.2.19/library/packages/test/data/rpm/dummy.tar.gz and new/yast2-4.2.23/library/packages/test/data/rpm/dummy.tar.gz differ Binary files old/yast2-4.2.19/library/packages/test/data/rpm/fallback_licenses_test.tar.gz and new/yast2-4.2.23/library/packages/test/data/rpm/fallback_licenses_test.tar.gz differ Binary files old/yast2-4.2.19/library/packages/test/data/rpm/licenses_test.tar.gz and new/yast2-4.2.23/library/packages/test/data/rpm/licenses_test.tar.gz differ Binary files old/yast2-4.2.19/library/packages/test/data/rpm/licenses_test_package-0.1-0.noarch.rpm and new/yast2-4.2.23/library/packages/test/data/rpm/licenses_test_package-0.1-0.noarch.rpm differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/library/packages/test/data/rpm/licenses_test_package.spec new/yast2-4.2.23/library/packages/test/data/rpm/licenses_test_package.spec --- old/yast2-4.2.19/library/packages/test/data/rpm/licenses_test_package.spec 2019-08-30 11:55:44.000000000 +0200 +++ new/yast2-4.2.23/library/packages/test/data/rpm/licenses_test_package.spec 2019-09-23 09:58:23.000000000 +0200 @@ -40,10 +40,10 @@ mkdir -p $RPM_BUILD_ROOT/%{LicensesDir} echo "Just a package to test licenses" > $RPM_BUILD_ROOT/%{ReadmeDir}/README -echo "Dummy content for the English license" > $RPM_BUILD_ROOT/%{LicensesDir}/LICENCE.en_US.TXT -echo "Dummy obsah" > $RPM_BUILD_ROOT/%{LicensesDir}/LICENCE.cz_CZ.TXT -echo "Contenido de ejemplo" > $RPM_BUILD_ROOT/%{LicensesDir}/LICENCE.es_ES.TXT - +echo "Dummy content for the English license" > $RPM_BUILD_ROOT/%{LicensesDir}/LICENSE.en_US.TXT +echo "Dummy obsah" > $RPM_BUILD_ROOT/%{LicensesDir}/LICENSE.cz_CZ.TXT +echo "Contenido de ejemplo" > $RPM_BUILD_ROOT/%{LicensesDir}/LICENSE.es_ES.TXT +touch $RPM_BUILD_ROOT/%{LicensesDir}/no-acceptance-needed %files %defattr(644,root,root,755) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/library/packages/test/test_helper.rb new/yast2-4.2.23/library/packages/test/test_helper.rb --- old/yast2-4.2.19/library/packages/test/test_helper.rb 2019-08-30 11:55:44.000000000 +0200 +++ new/yast2-4.2.23/library/packages/test/test_helper.rb 2019-09-23 09:58:23.000000000 +0200 @@ -2,3 +2,15 @@ require "pathname" PACKAGES_FIXTURES_PATH = Pathname.new(File.dirname(__FILE__)).join("data") + +# mock missing YaST modules +module Yast + # we cannot depend on this module (circular dependency) + class InstURLClass + def installInf2Url(_extra_dir = "") + "" + end + end + + InstURL = InstURLClass.new +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/library/packages/test/y2packager/licenses_fetchers/libzypp_test.rb new/yast2-4.2.23/library/packages/test/y2packager/licenses_fetchers/libzypp_test.rb --- old/yast2-4.2.19/library/packages/test/y2packager/licenses_fetchers/libzypp_test.rb 2019-08-30 11:55:44.000000000 +0200 +++ new/yast2-4.2.23/library/packages/test/y2packager/licenses_fetchers/libzypp_test.rb 2019-09-23 09:58:23.000000000 +0200 @@ -77,4 +77,27 @@ end end end + + describe "#license_confirmation_required?" do + before do + allow(Yast::Pkg).to receive(:PrdNeedToAcceptLicense) + .with(product_name).and_return(needed) + end + + context "when according to libzypp the license is required to be confirmed" do + let(:needed) { true } + + it "returns true" do + expect(fetcher.confirmation_required?).to eq(true) + end + end + + context "when according to libzypp the license is not required to be confirmed" do + let(:needed) { false } + + it "returns false" do + expect(fetcher.confirmation_required?).to eq(false) + end + end + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/library/packages/test/y2packager/licenses_fetchers/rpm_test.rb new/yast2-4.2.23/library/packages/test/y2packager/licenses_fetchers/rpm_test.rb --- old/yast2-4.2.19/library/packages/test/y2packager/licenses_fetchers/rpm_test.rb 2019-08-30 11:55:44.000000000 +0200 +++ new/yast2-4.2.23/library/packages/test/y2packager/licenses_fetchers/rpm_test.rb 2019-09-23 09:58:23.000000000 +0200 @@ -28,20 +28,20 @@ let(:lang) { "cz_CZ" } let(:product_name) { "SLES" } - let(:tmpdir) { "/tmp/licenses_fetcher_rpm_tests" } let(:package_name) { "sles-release" } let(:package_properties) { [{ "product_package" => package_name }] } let(:package_status) { :selected } let(:package_path) { rpm_path_for("licenses_test_package-0.1-0.noarch.rpm") } - let(:package) { instance_double(Y2Packager::Package, status: package_status, extract_to: nil) } + let(:package) do + double = instance_double(Y2Packager::Package, status: package_status) + allow(double).to receive(:extract_to) do |dir| + Packages::PackageExtractor.new(package_path).extract(dir) + end + double + end let(:found_packages) { [package] } before do - Dir.mkdir(tmpdir) - Packages::PackageExtractor.new(package_path).extract(tmpdir) - - allow(Dir).to receive(:mktmpdir).and_return(tmpdir) - allow(Yast::Pkg).to receive(:ResolvableProperties) .with(product_name, :product, "") .and_return(package_properties) @@ -51,10 +51,6 @@ .and_return(found_packages) end - after do - FileUtils.rm_r(tmpdir, force: true) - end - it_behaves_like "a fetcher" describe "#content" do @@ -122,4 +118,20 @@ end end end + + describe "#confirmation_required?" do + context "when 'no-acceptance-neeed' file is present" do + it "returns false" do + expect(fetcher.confirmation_required?).to eq(false) + end + end + + context "when 'no-acceptance-neeed' file is not found" do + let(:package_path) { rpm_path_for("dummy_package-0.1-0.noarch.rpm") } + + it "returns true" do + expect(fetcher.confirmation_required?).to eq(true) + end + end + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/library/packages/test/y2packager/licenses_fetchers/tarball_test.rb new/yast2-4.2.23/library/packages/test/y2packager/licenses_fetchers/tarball_test.rb --- old/yast2-4.2.19/library/packages/test/y2packager/licenses_fetchers/tarball_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-4.2.23/library/packages/test/y2packager/licenses_fetchers/tarball_test.rb 2019-09-23 09:58:23.000000000 +0200 @@ -0,0 +1,119 @@ +#!/usr/bin/env rspec +# ------------------------------------------------------------------------------ +# Copyright (c) 2018 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. +# ------------------------------------------------------------------------------ + +require_relative "../../test_helper" +require_relative "./shared_examples" + +require "y2packager/licenses_fetchers/tarball" +require "y2packager/package" + +require "fileutils" + +describe Y2Packager::LicensesFetchers::Tarball do + subject(:fetcher) { described_class.new(product_name) } + + def tar_path_for(package) + File.expand_path("../../../data/rpm/#{package}", __FILE__) + end + + let(:lang) { "cz_CZ" } + let(:product_name) { "SLES" } + let(:tar_path) { tar_path_for("licenses_test.tar.gz") } + + before do + allow(Yast::InstURL).to receive(:installInf2Url) + .with("").and_return("file:///Foo") + + allow(Yast::Pkg).to receive(:RepositoryAdd) + .and_return nil + + allow(Yast::Pkg).to receive(:SourceProvideFile) + .and_return tar_path + end + + it_behaves_like "a fetcher" + + describe "#content" do + context "when a tar archive is found" do + context "and there are license files available" do + it "returns the requested license file content" do + expect(fetcher.content(lang)).to match(/Dummy obsah/) + end + end + + context "and there is only the fallback license file available" do + let(:tar_path) { tar_path_for("fallback_licenses_test.tar.gz") } + + it "returns the default license file content" do + expect(fetcher.content(lang)).to match(/Dummy content for the fallback license file/) + end + end + + context "and there are none license files available" do + let(:tar_path) { tar_path_for("dummy.tar.gz") } + + it "returns nil" do + expect(fetcher.content(lang)).to be_nil + end + end + end + + context "when a tar archive is not found" do + let(:tar_path) { nil } + + it "returns nil" do + expect(fetcher.content(lang)).to be_nil + end + end + end + + describe "#locales" do + context "when a tar archive is not found" do + let(:tar_path) { nil } + + it "returns an empty list" do + expect(fetcher.locales).to eq([]) + end + end + + context "when license translation files are found" do + it "returns a list with available locales" do + expect(fetcher.locales).to match_array(["cz_CZ", "en_US", "es_ES"]) + end + end + + context "when license translation files are not found" do + let(:tar_path) { tar_path_for("dummy.tar.gz") } + + it "returns a list with the default language" do + expect(fetcher.locales).to eq([described_class::DEFAULT_LANG]) + end + end + end + + describe "#confirmation_required?" do + context "when 'no-acceptance-neeed' file is present" do + it "returns false" do + expect(fetcher.confirmation_required?).to eq(false) + end + end + + context "when 'no-acceptance-neeed' file is not found" do + let(:tar_path) { tar_path_for("dummy.tar.gz") } + + it "returns true" do + expect(fetcher.confirmation_required?).to eq(true) + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/library/packages/test/y2packager/licenses_handlers/libzypp_test.rb new/yast2-4.2.23/library/packages/test/y2packager/licenses_handlers/libzypp_test.rb --- old/yast2-4.2.19/library/packages/test/y2packager/licenses_handlers/libzypp_test.rb 2019-08-30 11:55:44.000000000 +0200 +++ new/yast2-4.2.23/library/packages/test/y2packager/licenses_handlers/libzypp_test.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,45 +0,0 @@ -#!/usr/bin/env rspec -# ------------------------------------------------------------------------------ -# Copyright (c) 2018 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. -# ------------------------------------------------------------------------------ - -require_relative "../../test_helper" - -require "y2packager/licenses_handlers/libzypp" - -describe Y2Packager::LicensesHandlers::Libzypp do - subject(:handler) { described_class.new(product_name) } - - let(:product_name) { "SLES" } - - describe "#license_confirmation_required?" do - before do - allow(Yast::Pkg).to receive(:PrdNeedToAcceptLicense) - .with(product_name).and_return(needed) - end - - context "when according to libzypp the license is required to be confirmed" do - let(:needed) { true } - - it "returns true" do - expect(handler.confirmation_required?).to eq(true) - end - end - - context "when according to libzypp the license is not required to be confirmed" do - let(:needed) { false } - - it "returns false" do - expect(handler.confirmation_required?).to eq(false) - end - end - end -end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/library/packages/test/y2packager/licenses_handlers/rpm_test.rb new/yast2-4.2.23/library/packages/test/y2packager/licenses_handlers/rpm_test.rb --- old/yast2-4.2.19/library/packages/test/y2packager/licenses_handlers/rpm_test.rb 2019-08-30 11:55:44.000000000 +0200 +++ new/yast2-4.2.23/library/packages/test/y2packager/licenses_handlers/rpm_test.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,50 +0,0 @@ -#!/usr/bin/env rspec -# ------------------------------------------------------------------------------ -# Copyright (c) 2018 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. -# ------------------------------------------------------------------------------ - -require_relative "../../test_helper" - -require "y2packager/package" -require "y2packager/licenses_handlers/rpm" - -describe Y2Packager::LicensesHandlers::Rpm do - subject(:handler) { described_class.new(product_name) } - - let(:product_name) { "SLES" } - let(:package) { instance_double(Y2Packager::Package, extract_to: nil) } - - describe "#confirmation_required?" do - before do - allow(Dir).to receive(:mktmpdir) - allow(Dir).to receive(:glob).and_return(found_paths) - allow(File).to receive(:join) - allow(FileUtils).to receive(:remove_entry_secure) - allow(subject).to receive(:package).and_return(package) - end - - context "when 'no-acceptance-neeed' file is present" do - let(:found_paths) { ["/fake/no-acceptance-file-path"] } - - it "returns false" do - expect(handler.confirmation_required?).to eq(false) - end - end - - context "when 'no-acceptance-neeed' file is not found" do - let(:found_paths) { [] } - - it "returns true" do - expect(handler.confirmation_required?).to eq(true) - end - end - end -end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/library/packages/test/y2packager/product_control_product_test.rb new/yast2-4.2.23/library/packages/test/y2packager/product_control_product_test.rb --- old/yast2-4.2.19/library/packages/test/y2packager/product_control_product_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-4.2.23/library/packages/test/y2packager/product_control_product_test.rb 2019-09-23 09:58:23.000000000 +0200 @@ -0,0 +1,95 @@ +#!/usr/bin/env rspec +# ------------------------------------------------------------------------------ +# Copyright (c) 2018 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. +# ------------------------------------------------------------------------------ + +require_relative "../test_helper" + +require "y2packager/product_control_product" + +describe Y2Packager::ProductControlProduct do + let(:product_data) do + { + "display_name" => "SUSE Linux Enterprise Server 15 SP2", + "name" => "SLES", + "version" => "15.2", + "register_target" => "sle-15-$arch" + } + end + + describe ".products" do + before do + allow(Yast::Linuxrc).to receive(:InstallInf).with("specialproduct").and_return("") + allow(Yast::ProductFeatures).to receive(:GetFeature) + .with("software", "base_products").and_return([]) + allow(Yast::Arch).to receive(:architecture).and_return("x86_64") + end + + after do + # the read products are cached, we need to reset them manually for the next test + described_class.instance_variable_set(:@products, nil) + end + + it "reads the products from the control.xml" do + expect(Yast::ProductFeatures).to receive(:GetFeature) + .with("software", "base_products").and_return([product_data]) + + products = Y2Packager::ProductControlProduct.products + expect(products).to_not be_empty + expect(products.first).to be_a(Y2Packager::ProductControlProduct) + expect(products.first.name).to eq("SLES") + end + + it "ignores the hidden products" do + data = product_data.merge("special_product" => true) + expect(Yast::ProductFeatures).to receive(:GetFeature) + .with("software", "base_products").and_return([data]) + + products = Y2Packager::ProductControlProduct.products + expect(products).to be_empty + end + + it "ignores the products for incompatible archs" do + data = product_data.merge("archs" => "aarch64") + expect(Yast::ProductFeatures).to receive(:GetFeature) + .with("software", "base_products").and_return([data]) + + products = Y2Packager::ProductControlProduct.products + expect(products).to be_empty + end + + it "expands the $arch variable in the register_target value" do + expect(Yast::ProductFeatures).to receive(:GetFeature) + .with("software", "base_products").and_return([product_data]) + + product = Y2Packager::ProductControlProduct.products.first + expect(product.register_target).to eq("sle-15-x86_64") + end + end + + describe ".selected" do + after do + # ensure the selected product is reset after each test + described_class.instance_variable_set(:@selected, nil) + end + + it "returns nil by default" do + expect(described_class.selected).to be_nil + end + + it "returns the selected product" do + product = described_class.new(name: "SLES", version: "15.2", arch: "x86_64", + label: "SUSE Linux Enterprise Server 15 SP2", license_url: "", register_target: "") + described_class.selected = product + expect(described_class.selected).to be(product) + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/library/packages/test/y2packager/product_license_test.rb new/yast2-4.2.23/library/packages/test/y2packager/product_license_test.rb --- old/yast2-4.2.19/library/packages/test/y2packager/product_license_test.rb 2019-08-30 11:55:44.000000000 +0200 +++ new/yast2-4.2.23/library/packages/test/y2packager/product_license_test.rb 2019-09-23 09:58:23.000000000 +0200 @@ -22,8 +22,9 @@ let(:product_name) { "SLES" } let(:handler) { instance_double(Y2Packager::LicensesHandlers::Libzypp, :confirmation= => nil) } + let(:fetcher) { instance_double(Y2Packager::LicensesFetchers::Libzypp) } let(:license) do - instance_double(Y2Packager::License, accept!: true, reject!: false, handler: handler) + instance_double(Y2Packager::License, accept!: true, reject!: false, handler: handler, fetcher: fetcher) end before do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/library/packages/test/y2packager/product_reader_test.rb new/yast2-4.2.23/library/packages/test/y2packager/product_reader_test.rb --- old/yast2-4.2.19/library/packages/test/y2packager/product_reader_test.rb 2019-08-30 11:55:44.000000000 +0200 +++ new/yast2-4.2.23/library/packages/test/y2packager/product_reader_test.rb 2019-09-23 09:58:23.000000000 +0200 @@ -77,7 +77,7 @@ end end - context "and more than 1 product exsits" do + context "and more than 1 product exists" do let(:products) { [prod1, prod2] } it "returns an empty array" do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/package/yast2.changes new/yast2-4.2.23/package/yast2.changes --- old/yast2-4.2.19/package/yast2.changes 2019-08-30 11:55:44.000000000 +0200 +++ new/yast2-4.2.23/package/yast2.changes 2019-09-23 09:58:23.000000000 +0200 @@ -1,4 +1,31 @@ ------------------------------------------------------------------- +Mon Sep 23 07:27:27 UTC 2019 - Ladislav Slezák <[email protected]> + +- Use "display_name" tag for the product label, "label" marks a + translatable text (jsc#SLE-7214) +- 4.2.23 + +------------------------------------------------------------------- +Thu Sep 19 12:05:17 UTC 2019 - Ladislav Slezák <[email protected]> + +- Added support for reading products from control.xml file + (jsc#SLE-7104) +- 4.2.22 + +------------------------------------------------------------------- +Tue Sep 10 07:57:34 UTC 2019 - Steffen Winterfeldt <[email protected]> + +- support reading licenses from tar archive (jsc#SLE-7214) +- 4.2.21 + +------------------------------------------------------------------- +Fri Sep 6 11:15:40 UTC 2019 - Imobach Gonzalez Sosa <[email protected]> + +- Fix a problem when long warnings reports in command line + (bsc#1149776). +- 4.2.20 + +------------------------------------------------------------------- Fri Aug 30 09:30:26 UTC 2019 - Steffen Winterfeldt <[email protected]> - yast completions have to be named after their respective command diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.19/package/yast2.spec new/yast2-4.2.23/package/yast2.spec --- old/yast2-4.2.19/package/yast2.spec 2019-08-30 11:55:44.000000000 +0200 +++ new/yast2-4.2.23/package/yast2.spec 2019-09-23 09:58:23.000000000 +0200 @@ -17,7 +17,8 @@ Name: yast2 -Version: 4.2.19 +Version: 4.2.23 + Release: 0 Summary: YaST2 Main Package License: GPL-2.0-only
