Hello community, here is the log from the commit of package yast2 for openSUSE:Factory checked in at 2020-06-19 16:48:48 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2 (Old) and /work/SRC/openSUSE:Factory/.yast2.new.3606 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2" Fri Jun 19 16:48:48 2020 rev:484 rq:815784 version:4.3.8 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2/yast2.changes 2020-06-11 14:44:26.805337889 +0200 +++ /work/SRC/openSUSE:Factory/.yast2.new.3606/yast2.changes 2020-06-19 16:48:57.958247516 +0200 @@ -1,0 +2,16 @@ +Thu Jun 18 15:23:54 UTC 2020 - Ladislav Slezák <[email protected]> + +- Updated Yast::XML.validate arguments +- Distinguish between a String argument (containing a XML + document/schema) and Pathname (path to a file) +- Related to bsc#1170886 +- 4.3.8 + +------------------------------------------------------------------- +Tue Jun 16 14:01:51 UTC 2020 - Imobach Gonzalez Sosa <[email protected]> + +- Add a method to determine the default start mode for a system + service (related to bsc#1172749). +- 4.3.7 + +------------------------------------------------------------------- Old: ---- yast2-4.3.6.tar.bz2 New: ---- yast2-4.3.8.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2.spec ++++++ --- /var/tmp/diff_new_pack.0iqQc8/_old 2020-06-19 16:48:59.530252412 +0200 +++ /var/tmp/diff_new_pack.0iqQc8/_new 2020-06-19 16:48:59.530252412 +0200 @@ -17,7 +17,7 @@ Name: yast2 -Version: 4.3.6 +Version: 4.3.8 Release: 0 Summary: YaST2 Main Package License: GPL-2.0-only ++++++ yast2-4.3.6.tar.bz2 -> yast2-4.3.8.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.3.6/.rubocop.yml new/yast2-4.3.8/.rubocop.yml --- old/yast2-4.3.6/.rubocop.yml 2020-06-10 16:48:18.000000000 +0200 +++ new/yast2-4.3.8/.rubocop.yml 2020-06-18 18:21:31.000000000 +0200 @@ -30,6 +30,8 @@ # ExcludedMethods: refine Metrics/BlockLength: Max: 877 + Exclude: + - "library/*/test/**/*_test.rb" Metrics/PerceivedComplexity: Max: 65 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.3.6/library/systemd/doc/services_and_sockets.md new/yast2-4.3.8/library/systemd/doc/services_and_sockets.md --- old/yast2-4.3.6/library/systemd/doc/services_and_sockets.md 2020-06-10 16:48:18.000000000 +0200 +++ new/yast2-4.3.8/library/systemd/doc/services_and_sockets.md 2020-06-18 18:21:31.000000000 +0200 @@ -7,7 +7,7 @@ When a service is configured by using YaST (e.g., with the Services Manager), all units related to each service must be taken into account. For example, when a service is stopped, the socket -associated to such service should be also stopped. Otherwise, the sevice could be automatically +associated to such service should be also stopped. Otherwise, the service could be automatically activated again via its socket. This file extends the {Yast2::SystemService} class documentation describing how it works with the @@ -24,8 +24,8 @@ on demand or manually) * apply all changes in the "real system" -One goal in this class is to offer an agnostic API. At this moment it uses Systemd in low levels -layers, but in future this could change and the API should remain as much as possible. +One of the goals of this class is to offer an agnostic API. At this moment it uses Systemd in low +levels layers, but in future this could change and the API should remain as much as possible. ## Actions over Systemd units @@ -41,7 +41,7 @@ ## Detailed actions -Here each `SystemService` action is decribed in a more detailed way. +Here each `SystemService` action is described in a more detailed way. First of all, we are going to consider that a `SystemService` is stopped/running as follows: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.3.6/library/systemd/src/lib/yast2/system_service.rb new/yast2-4.3.8/library/systemd/src/lib/yast2/system_service.rb --- old/yast2-4.3.6/library/systemd/src/lib/yast2/system_service.rb 2020-06-10 16:48:18.000000000 +0200 +++ new/yast2-4.3.8/library/systemd/src/lib/yast2/system_service.rb 2020-06-18 18:21:31.000000000 +0200 @@ -205,14 +205,16 @@ def current_start_mode return @current_start_mode unless @current_start_mode.nil? - @current_start_mode = - if service.enabled? - :on_boot - elsif socket&.enabled? - :on_demand - else - :manual - end + @current_start_mode = start_mode_from(service, socket, :enabled?) + end + + # Determines the default start mode for this service + # + # @return [Symbol] :on_boot, :on_demand, :manual + def default_start_mode + return @default_start_mode unless @default_start_mode.nil? + + @default_start_mode = start_mode_from(service, socket, :preset_enabled?) end # Whether the service is currently active in the system @@ -257,6 +259,14 @@ new_value_for(:start_mode) || current_start_mode end + # Determines whether the start mode has been changed from system's default + # + # @see #start_mode + # @see #default_start_mode + def default_start_mode? + default_start_mode == start_mode + end + # Sets the service start mode # # See {#start_modes} to find out the supported modes for a given service (usually :on_boot, @@ -601,5 +611,24 @@ service.disable end + + # Helper method to calculate the start mode using a given method + # + # This method offers a mechanism to get the current and the + # default start_modes. + # + # @param service [Service] Systemd service + # @param socket [Socket,nil] Systemd socket + # @param enabled_method [Symbol] Method to use to determine whether service and socket + # are enabled or not. + def start_mode_from(service, socket, enabled_method) + if service.public_send(enabled_method) + :on_boot + elsif socket&.public_send(enabled_method) + :on_demand + else + :manual + end + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.3.6/library/systemd/src/lib/yast2/systemd/unit.rb new/yast2-4.3.8/library/systemd/src/lib/yast2/systemd/unit.rb --- old/yast2-4.3.6/library/systemd/src/lib/yast2/systemd/unit.rb 2020-06-10 16:48:18.000000000 +0200 +++ new/yast2-4.3.8/library/systemd/src/lib/yast2/systemd/unit.rb 2020-06-18 18:21:31.000000000 +0200 @@ -52,7 +52,8 @@ :active_state, :sub_state, :can_reload?, - :not_found? + :not_found?, + :preset_enabled? ].freeze private_constant :FORWARDED_METHODS diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.3.6/library/systemd/src/lib/yast2/systemd/unit_installation_properties.rb new/yast2-4.3.8/library/systemd/src/lib/yast2/systemd/unit_installation_properties.rb --- old/yast2-4.3.6/library/systemd/src/lib/yast2/systemd/unit_installation_properties.rb 2020-06-10 16:48:18.000000000 +0200 +++ new/yast2-4.3.8/library/systemd/src/lib/yast2/systemd/unit_installation_properties.rb 2020-06-18 18:21:31.000000000 +0200 @@ -2,7 +2,7 @@ module Yast2 module Systemd - # A replacement for {Yast2::Systemd::UnitPropertie} during installation + # A replacement for {Yast2::Systemd::UnitProperties} during installation # # Systemd `show` command (systemctl show) is not available during # installation and will return error "Running in chroot, ignoring request." diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.3.6/library/systemd/src/lib/yast2/systemd/unit_prop_map.rb new/yast2-4.3.8/library/systemd/src/lib/yast2/systemd/unit_prop_map.rb --- old/yast2-4.3.6/library/systemd/src/lib/yast2/systemd/unit_prop_map.rb 2020-06-10 16:48:18.000000000 +0200 +++ new/yast2-4.3.8/library/systemd/src/lib/yast2/systemd/unit_prop_map.rb 2020-06-18 18:21:31.000000000 +0200 @@ -8,15 +8,16 @@ class UnitPropMap < Hash # @return [Yast2::Systemd::UniPropMap] DEFAULT = UnitPropMap[{ - id: "Id", - pid: "MainPID", - description: "Description", - load_state: "LoadState", - active_state: "ActiveState", - sub_state: "SubState", - unit_file_state: "UnitFileState", - path: "FragmentPath", - can_reload: "CanReload" + id: "Id", + pid: "MainPID", + description: "Description", + load_state: "LoadState", + active_state: "ActiveState", + sub_state: "SubState", + unit_file_state: "UnitFileState", + unit_file_preset: "UnitFilePreset", + path: "FragmentPath", + can_reload: "CanReload" }].freeze end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.3.6/library/systemd/src/lib/yast2/systemd/unit_properties.rb new/yast2-4.3.8/library/systemd/src/lib/yast2/systemd/unit_properties.rb --- old/yast2-4.3.6/library/systemd/src/lib/yast2/systemd/unit_properties.rb 2020-06-10 16:48:18.000000000 +0200 +++ new/yast2-4.3.8/library/systemd/src/lib/yast2/systemd/unit_properties.rb 2020-06-18 18:21:31.000000000 +0200 @@ -47,14 +47,15 @@ end extract_properties - self[:active?] = ACTIVE_STATES.include?(active_state) - self[:running?] = sub_state == "running" - self[:loaded?] = load_state == "loaded" - self[:not_found?] = load_state == "not-found" - self[:static?] = unit_file_state == "static" - self[:enabled?] = read_enabled_state - self[:supported?] = SUPPORTED_STATES.include?(unit_file_state) - self[:can_reload?] = can_reload == "yes" + self[:active?] = ACTIVE_STATES.include?(active_state) + self[:running?] = sub_state == "running" + self[:loaded?] = load_state == "loaded" + self[:not_found?] = load_state == "not-found" + self[:static?] = unit_file_state == "static" + self[:preset_enabled?] = read_preset_enabled_state + self[:enabled?] = read_enabled_state + self[:supported?] = SUPPORTED_STATES.include?(unit_file_state) + self[:can_reload?] = can_reload == "yes" end private @@ -76,6 +77,14 @@ end end + # Determines whether the unit should be enabled by default (preset) + # @return [Boolean] True if enabled by default, false otherwise. + def read_preset_enabled_state + return false unless unit_file_preset + + state_name_enabled?(unit_file_preset.strip) + end + # Systemd service unit can have various states like enabled, enabled-runtime, # linked, linked-runtime, masked, masked-runtime, static, disabled, invalid. # We test for the return value 'enabled' and 'enabled-runtime' to consider diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.3.6/library/systemd/test/data/cups_service_properties new/yast2-4.3.8/library/systemd/test/data/cups_service_properties --- old/yast2-4.3.6/library/systemd/test/data/cups_service_properties 2020-06-10 16:48:18.000000000 +0200 +++ new/yast2-4.3.8/library/systemd/test/data/cups_service_properties 2020-06-18 18:21:31.000000000 +0200 @@ -147,7 +147,7 @@ ActiveState=inactive SubState=dead FragmentPath=/usr/lib/systemd/system/cups.service -UnitFileState=disabled +UnitFileState=enabled UnitFilePreset=enabled StateChangeTimestamp=Mon 2018-06-25 13:29:46 CEST StateChangeTimestampMonotonic=19149989334 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.3.6/library/systemd/test/data/sshd_service_properties new/yast2-4.3.8/library/systemd/test/data/sshd_service_properties --- old/yast2-4.3.6/library/systemd/test/data/sshd_service_properties 2020-06-10 16:48:18.000000000 +0200 +++ new/yast2-4.3.8/library/systemd/test/data/sshd_service_properties 2020-06-18 18:21:31.000000000 +0200 @@ -12,6 +12,7 @@ SubState=running FragmentPath=/usr/lib/systemd/system/sshd.service UnitFileState=enabled +UnitFileState=disabled InactiveExitTimestamp=St 2014-02-12 15:22:46 CET InactiveExitTimestampMonotonic=22172625 ActiveEnterTimestamp=St 2014-02-12 15:22:46 CET diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.3.6/library/systemd/test/yast2/system_service_test.rb new/yast2-4.3.8/library/systemd/test/yast2/system_service_test.rb --- old/yast2-4.3.6/library/systemd/test/yast2/system_service_test.rb 2020-06-10 16:48:18.000000000 +0200 +++ new/yast2-4.3.8/library/systemd/test/yast2/system_service_test.rb 2020-06-18 18:21:31.000000000 +0200 @@ -26,25 +26,31 @@ let(:service) do instance_double(Yast2::Systemd::Service, - name: "cups", - enabled?: service_enabled, - active?: service_active, - not_found?: !service_found, - static?: service_static, - refresh!: true) + name: "cups", + enabled?: service_enabled, + active?: service_active, + not_found?: !service_found, + static?: service_static, + preset_enabled?: service_preset_enabled, + refresh!: true) end let(:service_enabled) { true } let(:service_active) { true } let(:service_found) { true } let(:service_static) { false } + let(:service_preset_enabled) { true } let(:service_socket) do - instance_double(Yast2::Systemd::Socket, enabled?: socket_enabled, active?: socket_active) + instance_double( + Yast2::Systemd::Socket, enabled?: socket_enabled, active?: socket_active, + preset_enabled?: socket_preset_enabled + ) end let(:socket_enabled) { true } let(:socket_active) { true } + let(:socket_preset_enabled) { true } let(:socket) { service_socket } @@ -363,6 +369,68 @@ end end end + + describe "#default_start_mode" do + let(:socket_preset_enabled) { true } + let(:service_preset_enabled) { true } + + context "when service should be enabled by default" do + it "returns :on_boot" do + expect(system_service.default_start_mode).to eq(:on_boot) + end + end + + context "when the service should not be enabled" do + let(:service_preset_enabled) { false } + + context "but the socket should be enabled" do + it "returns :on_demand" do + expect(system_service.default_start_mode).to eq(:on_demand) + end + end + + context "and the socket should not be disabled" do + let(:socket_preset_enabled) { false } + + it "returns :manual" do + expect(system_service.default_start_mode).to eq(:manual) + end + end + + context "and there is not socket" do + let(:socket) { nil } + + it "returns :manual" do + expect(system_service.default_start_mode).to eq(:manual) + end + end + end + end + + describe "#default_start_mode?" do + let(:start_mode) { :on_boot } + + before do + allow(system_service).to receive(:default_start_mode).and_return(:on_boot) + allow(system_service).to receive(:start_mode).and_return(start_mode) + end + + context "when the start mode is the same than the default one" do + let(:start_mode) { :on_boot } + + it "returns true" do + expect(system_service.default_start_mode?).to eq(true) + end + end + + context "when the start mode is not the default one" do + let(:start_mode) { :manual } + + it "returns false" do + expect(system_service.default_start_mode?).to eq(false) + end + end + end describe "#support_start_on_demand?" do context "when the service has an associated socket" do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.3.6/library/systemd/test/yast2/systemd_service_test.rb new/yast2-4.3.8/library/systemd/test/yast2/systemd_service_test.rb --- old/yast2-4.3.6/library/systemd/test/yast2/systemd_service_test.rb 2020-06-10 16:48:18.000000000 +0200 +++ new/yast2-4.3.8/library/systemd/test/yast2/systemd_service_test.rb 2020-06-18 18:21:31.000000000 +0200 @@ -78,8 +78,8 @@ before do allow(Yast2::Systemctl).to receive(:execute).with( - "show --property=Id,MainPID,Description,LoadState,ActiveState,SubState,UnitFileState," \ - "FragmentPath,CanReload apparmor.service cups.service" + "show --property=Id,MainPID,Description,LoadState,ActiveState,SubState," \ + "UnitFileState,UnitFilePreset,FragmentPath,CanReload apparmor.service cups.service" ).and_return(systemctl_show) allow(Systemd::Service).to receive(:find).with("apparmor", {}).and_return(apparmor_double) allow(Systemd::Service).to receive(:find).with("cups", {}).and_return(cups_double) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.3.6/library/systemd/test/yast2/unit_properties_test.rb new/yast2-4.3.8/library/systemd/test/yast2/unit_properties_test.rb --- old/yast2-4.3.6/library/systemd/test/yast2/unit_properties_test.rb 2020-06-10 16:48:18.000000000 +0200 +++ new/yast2-4.3.8/library/systemd/test/yast2/unit_properties_test.rb 2020-06-18 18:21:31.000000000 +0200 @@ -47,4 +47,37 @@ end end end + + describe "#preset_enabled?" do + subject(:properties) { described_class.new(service, nil) } + let(:service) { Yast2::Systemd::Service.build(service_name) } + + before do + stub_services(service: service_name) + end + + context "when the service should be enabled by default" do + let(:service_name) { "cups" } + + it "returns true" do + expect(properties.preset_enabled?).to eq(true) + end + end + + context "when the service should be disabled by default" do + let(:service_name) { "sshd" } + + it "returns false" do + expect(properties.preset_enabled?).to eq(false) + end + end + + context "when the service is static" do + let(:service_name) { "tftp" } + + it "returns false" do + expect(properties.preset_enabled?).to eq(false) + end + end + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.3.6/library/xml/src/modules/XML.rb new/yast2-4.3.8/library/xml/src/modules/XML.rb --- old/yast2-4.3.6/library/xml/src/modules/XML.rb 2020-06-10 16:48:18.000000000 +0200 +++ new/yast2-4.3.8/library/xml/src/modules/XML.rb 2020-06-18 18:21:31.000000000 +0200 @@ -23,6 +23,7 @@ require "yast" require "nokogiri" +require "pathname" module Yast # Exception used when trying to serialize a Ruby object that we cannot @@ -191,19 +192,19 @@ # Validates a XML document against a given schema. # - # @param xml [String] path or content of XML (if the string contains a new + # @param xml [Pathname, String] path or content of XML (if the string contains a new # line character it is considered as a XML string, otherwise as a file name) - # @param schema [String] path or content of relax ng schema + # @param schema [Pathname, String] path or content of relax ng schema # @return [Array<String>] array of strings with errors or empty array if # well formed and valid # @raise [Yast::XMLDeserializationError] if the document is not well formed # (there are syntax errors) def validate(xml, schema) - xml = SCR.Read(path(".target.string"), xml) unless xml.include?("\n") - if schema.include?("\n") # content, not path + xml = SCR.Read(path(".target.string"), xml.to_s) if xml.is_a?(Pathname) + if schema.is_a?(::String) validator = Nokogiri::XML::RelaxNG(schema) else - schema_content = SCR.Read(path(".target.string"), schema) + schema_content = SCR.Read(path(".target.string"), schema.to_s) schema_path = File.dirname(schema) # change directory so relative include works Dir.chdir(schema_path) { validator = Nokogiri::XML::RelaxNG(schema_content) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.3.6/library/xml/test/xml_test.rb new/yast2-4.3.8/library/xml/test/xml_test.rb --- old/yast2-4.3.6/library/xml/test/xml_test.rb 2020-06-10 16:48:18.000000000 +0200 +++ new/yast2-4.3.8/library/xml/test/xml_test.rb 2020-06-18 18:21:31.000000000 +0200 @@ -1,4 +1,5 @@ require_relative "test_helper" +require "tempfile" Yast.import "XML" @@ -524,20 +525,22 @@ </element>' end - it "returns empty array for valid xml" do - xml = '<?xml version="1.0"?> - <test> - <person> - <name> - clark - </name> - <voice> - nice - </voice> - </person> - </test>' + let(:valid_xml) do + '<?xml version="1.0"?> + <test> + <person> + <name> + clark + </name> + <voice> + nice + </voice> + </person> + </test>' + end - expect(Yast::XML.validate(xml, schema)).to be_empty + it "returns empty array for valid xml" do + expect(Yast::XML.validate(valid_xml, schema)).to be_empty end it "returns error string in array when xml is not valid for given schema" do @@ -569,5 +572,23 @@ expect { Yast::XML.validate(xml, schema) }.to raise_error(Yast::XMLDeserializationError) end + + it "can read the input from files" do + # create temporary files with the testing content + xml_file = Tempfile.new + schema_file = Tempfile.new + begin + xml_file.write(valid_xml) + xml_file.close + schema_file.write(schema) + schema_file.close + + errors = Yast::XML.validate(Pathname.new(xml_file.path), Pathname.new(schema_file.path)) + expect(errors).to be_empty + ensure + xml_file.unlink + schema_file.unlink + end + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.3.6/package/yast2.changes new/yast2-4.3.8/package/yast2.changes --- old/yast2-4.3.6/package/yast2.changes 2020-06-10 16:48:18.000000000 +0200 +++ new/yast2-4.3.8/package/yast2.changes 2020-06-18 18:21:31.000000000 +0200 @@ -1,4 +1,20 @@ ------------------------------------------------------------------- +Thu Jun 18 15:23:54 UTC 2020 - Ladislav Slezák <[email protected]> + +- Updated Yast::XML.validate arguments +- Distinguish between a String argument (containing a XML + document/schema) and Pathname (path to a file) +- Related to bsc#1170886 +- 4.3.8 + +------------------------------------------------------------------- +Tue Jun 16 14:01:51 UTC 2020 - Imobach Gonzalez Sosa <[email protected]> + +- Add a method to determine the default start mode for a system + service (related to bsc#1172749). +- 4.3.7 + +------------------------------------------------------------------- Tue Jun 9 16:00:19 UTC 2020 - David Diaz <[email protected]> - Fix Xen detection (bsc#1172742). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.3.6/package/yast2.spec new/yast2-4.3.8/package/yast2.spec --- old/yast2-4.3.6/package/yast2.spec 2020-06-10 16:48:18.000000000 +0200 +++ new/yast2-4.3.8/package/yast2.spec 2020-06-18 18:21:31.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2 -Version: 4.3.6 +Version: 4.3.8 Release: 0 Summary: YaST2 Main Package License: GPL-2.0-only
