Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package yast2 for openSUSE:Factory checked in at 2022-12-02 13:12:21 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2 (Old) and /work/SRC/openSUSE:Factory/.yast2.new.1835 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2" Fri Dec 2 13:12:21 2022 rev:545 rq:1039367 version:4.5.20 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2/yast2.changes 2022-11-18 15:42:42.278343699 +0100 +++ /work/SRC/openSUSE:Factory/.yast2.new.1835/yast2.changes 2022-12-02 13:12:31.377649268 +0100 @@ -1,0 +2,9 @@ +Thu Dec 1 16:12:54 UTC 2022 - Josef Reidinger <jreidin...@suse.com> + +- ArchFilter: Add new class to allow unified definition of hardware + architecture filter. The main use case is to read arch + specific configuration in various configuration files like + control.xml or d-installer.yml (gh#yast/d-installer#279) +- 4.5.20 + +------------------------------------------------------------------- Old: ---- yast2-4.5.19.tar.bz2 New: ---- yast2-4.5.20.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2.spec ++++++ --- /var/tmp/diff_new_pack.7nvyJ5/_old 2022-12-02 13:12:32.061653004 +0100 +++ /var/tmp/diff_new_pack.7nvyJ5/_new 2022-12-02 13:12:32.069653048 +0100 @@ -17,9 +17,9 @@ Name: yast2 -Version: 4.5.19 -Release: 0 +Version: 4.5.20 +Release: 0 Summary: YaST2 Main Package License: GPL-2.0-only Group: System/YaST ++++++ yast2-4.5.19.tar.bz2 -> yast2-4.5.20.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.5.19/library/general/src/lib/yast2/arch_filter.rb new/yast2-4.5.20/library/general/src/lib/yast2/arch_filter.rb --- old/yast2-4.5.19/library/general/src/lib/yast2/arch_filter.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-4.5.20/library/general/src/lib/yast2/arch_filter.rb 2022-12-01 17:36:45.000000000 +0100 @@ -0,0 +1,112 @@ +# Copyright (c) [2022] 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 "yast" + +Yast.import "Arch" + +module Yast2 + # Represents filtering based on hardware architecture like x86_64 or ppc64. + # Original code lived in Y2Storage::SubvolSpecification + # @example + # Yast2::ArchFilter.from_string("x86_64,aarch64").match? + class ArchFilter + # Error when invalid specification for filter is used + class Invalid < RuntimeError + def initialize(spec) + super("Invalid part of architecture specification '#{spec}'") + end + end + + # @return [Array<Hash>] list of specifications where each entry is hash with key `:method` and + # `:negate`, where method is Yast::Arch method and negate specify if + # method have to return false. There is one specific method `:all` that is not in Yast::Arch, + # but can be used to always return true. + attr_reader :specifications + + # creates new architecture filter from passed list of individual specifications + # @param specs [Array<String>] + # @raise Invalid when architecture specification is invalid + def initialize(specs) + @specifications = [] + specs.each do |spec| + method = spec.downcase + negate = spec.start_with?("!") + method = spec[1..-1] if negate + raise Invalid, spec unless valid_method?(method) + + @specifications << { method: method.to_sym, negate: negate } + end + end + + # Parses architecture filter specification from a string. + # + # Supported values are methods from {Yast::ArchClass Arch} with possible `!` in front of it. + # + # When a `!` is used it is called a *negative* method and without it is a *positive* one. + # + # A list of methods is separated with commas `,`. + # To match, + # at least one positive specified method has to return true and + # all negative methods have to return false. + # If there are no positive methods then only negatives are evaluated. + # + # Whitespaces are allowed. Only `!` and method has to be without space. + # Also it is case insensitive, so acronyms can be in upper case. + # + # @example various format and how it behave in given situations + # "x86_64,ppc64" # returns true on either x86_64 or ppc64 + # "ppc,!board_powernv" # returns false on powernv_board or non-ppc + # "ppc, !board_powernv" # spaces are allowed + # "!ppc64,!aarch64" # returns false on ppc64 and arm and true for others + # "s390, !is_zKVM" # return true on s390 when not running in zKVM hypervisor + # "" # always return true + # "all" # always return true + # "invalid" # raises ArchFilter::Invalid exception + def self.from_string(value) + new(value.split(",").map(&:strip)) + end + + # checks if filter match current hardware + # @return [Boolean] + def match? + negative, positive = @specifications.partition { |s| s[:negate] } + return false if negative.any? { |s| invoke_method(s[:method]) } + + # handle case when there is only negative conditions + return true if positive.empty? + + positive.any? { |s| invoke_method(s[:method]) } + end + + private + + def invoke_method(name) + return true if name == :all + + Yast::Arch.public_send(name) + end + + def valid_method?(name) + return true if name.to_s == "all" + + Yast::Arch.respond_to?(name) + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.5.19/library/general/test/yast2/arch_filter_test.rb new/yast2-4.5.20/library/general/test/yast2/arch_filter_test.rb --- old/yast2-4.5.19/library/general/test/yast2/arch_filter_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-4.5.20/library/general/test/yast2/arch_filter_test.rb 2022-12-01 17:36:45.000000000 +0100 @@ -0,0 +1,156 @@ +#!/usr/bin/env rspec + +# Copyright (c) [2022] 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 "yast2/arch_filter" + +describe Yast2::ArchFilter do + describe "#match?" do + context "at least one positive methods return true" do + context "all negative methods return false" do + it "returns true" do + filter = described_class.from_string("x86_64,ppc,!board_powernv") + allow(Yast::Arch).to receive(:x86_64).and_return(false) + allow(Yast::Arch).to receive(:ppc).and_return(true) + allow(Yast::Arch).to receive(:board_powernv).and_return(false) + + expect(filter.match?).to eq true + end + end + + context "there are no negative methods" do + it "returns true" do + filter = described_class.from_string("x86_64,board_powernv") + allow(Yast::Arch).to receive(:x86_64).and_return(false) + allow(Yast::Arch).to receive(:board_powernv).and_return(true) + + expect(filter.match?).to eq true + end + end + + context "at least one negative method returns true" do + it "returns false" do + filter = described_class.from_string("x86_64,ppc,!board_powernv") + allow(Yast::Arch).to receive(:x86_64).and_return(false) + allow(Yast::Arch).to receive(:ppc).and_return(true) + allow(Yast::Arch).to receive(:board_powernv).and_return(true) + + expect(filter.match?).to eq false + end + end + end + + context "all positive methods return false" do + it "returns false" do + filter = described_class.from_string("x86_64,ppc,!board_powernv") + allow(Yast::Arch).to receive(:x86_64).and_return(false) + allow(Yast::Arch).to receive(:ppc).and_return(false) + allow(Yast::Arch).to receive(:board_powernv).and_return(false) + + expect(filter.match?).to eq false + end + end + + context "there are no positive methods" do + context "all negative methods return false" do + it "returns true" do + filter = described_class.from_string("!x86_64,!board_powernv") + allow(Yast::Arch).to receive(:x86_64).and_return(false) + allow(Yast::Arch).to receive(:board_powernv).and_return(false) + + expect(filter.match?).to eq true + end + end + + context "at least one negative method returns true" do + it "returns false" do + filter = described_class.from_string("!x86_64,!board_powernv") + allow(Yast::Arch).to receive(:x86_64).and_return(false) + allow(Yast::Arch).to receive(:board_powernv).and_return(true) + + expect(filter.match?).to eq false + end + end + end + + context "there are no methods" do + it "returns true" do + filter = described_class.from_string("") + + expect(filter.match?).to eq true + end + end + + it "supports special 'all' method" do + filter = described_class.from_string("all") + + expect(filter.match?).to eq true + end + end + + describe ".new" do + it "parses each element of list to specification" do + filter = described_class.new(["x86_64"]) + expect(filter.specifications).to eq([{ method: :x86_64, negate: false }]) + end + + it "parses negative methods" do + filter = described_class.new(["!x86_64"]) + expect(filter.specifications).to eq([{ method: :x86_64, negate: true }]) + end + + it "is case insensitive" do + filter = described_class.new(["PPC"]) + expect(filter.specifications).to eq([{ method: :ppc, negate: false }]) + end + + it "raises Yast2::ArchFilter::Invalid for invalid methods" do + expect { described_class.new(["InvalidArch"]) }.to raise_error(Yast2::ArchFilter::Invalid) + end + end + + describe ".from_string" do + it "parses string into list of specifications" do + filter = described_class.from_string("x86_64") + expect(filter.specifications).to eq([{ method: :x86_64, negate: false }]) + end + + it "parses list separated by comma" do + filter = described_class.from_string("x86_64,ppc") + expect(filter.specifications).to eq( + [ + { method: :x86_64, negate: false }, + { method: :ppc, negate: false } + ] + ) + end + + it "allows whitespaces" do + filter = described_class.from_string("x86_64, ppc") + expect(filter.specifications).to eq( + [ + { method: :x86_64, negate: false }, + { method: :ppc, negate: false } + ] + ) + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.5.19/package/yast2.changes new/yast2-4.5.20/package/yast2.changes --- old/yast2-4.5.19/package/yast2.changes 2022-11-04 11:15:57.000000000 +0100 +++ new/yast2-4.5.20/package/yast2.changes 2022-12-01 17:36:45.000000000 +0100 @@ -1,4 +1,13 @@ ------------------------------------------------------------------- +Thu Dec 1 16:12:54 UTC 2022 - Josef Reidinger <jreidin...@suse.com> + +- ArchFilter: Add new class to allow unified definition of hardware + architecture filter. The main use case is to read arch + specific configuration in various configuration files like + control.xml or d-installer.yml (gh#yast/d-installer#279) +- 4.5.20 + +------------------------------------------------------------------- Mon Oct 31 13:07:35 UTC 2022 - Martin Vidner <mvid...@suse.com> - Fix hash vs keyword arguments in RSpec expectations (bsc#1204871) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.5.19/package/yast2.spec new/yast2-4.5.20/package/yast2.spec --- old/yast2-4.5.19/package/yast2.spec 2022-11-04 11:15:57.000000000 +0100 +++ new/yast2-4.5.20/package/yast2.spec 2022-12-01 17:36:45.000000000 +0100 @@ -17,7 +17,7 @@ Name: yast2 -Version: 4.5.19 +Version: 4.5.20 Release: 0 Summary: YaST2 Main Package