Hello community, here is the log from the commit of package yast2 for openSUSE:Factory checked in at 2019-11-20 10:27:12 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2 (Old) and /work/SRC/openSUSE:Factory/.yast2.new.26869 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2" Wed Nov 20 10:27:12 2019 rev:466 rq:749338 version:4.2.34 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2/yast2.changes 2019-11-03 10:32:58.289165739 +0100 +++ /work/SRC/openSUSE:Factory/.yast2.new.26869/yast2.changes 2019-11-20 10:27:15.750562584 +0100 @@ -1,0 +2,28 @@ +Fri Nov 15 09:30:20 UTC 2019 - Josef Reidinger <jreidin...@suse.com> + +- Fix crash in upgrade caused by wrong parameter to snapper + (bsc#1156819) +- 4.2.34 + +------------------------------------------------------------------- +Tue Nov 05 14:15:16 UTC 2019 - José Iván López González <jlo...@suse.com> + +- Use new snapper machine-readable output to retrieve snapshots + information (related to bsc#1149322). +- 4.2.33 + +------------------------------------------------------------------- +Tue Nov 05 13:24:40 UTC 2019 - Oliver Kurz <ok...@suse.com> + +- Add linuxrc option "reboot_timeout" to configure the timeout + before reboot (bsc#1122493) +- 4.2.32 + +------------------------------------------------------------------- +Thu Oct 31 12:59:33 UTC 2019 - Knut Anderssen <kanders...@suse.com> + +- Network: During an installation, check which backend is in use + when Systemd is running. (bsc#1151291) +- 4.2.31 + +------------------------------------------------------------------- Old: ---- yast2-4.2.30.tar.bz2 New: ---- yast2-4.2.34.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2.spec ++++++ --- /var/tmp/diff_new_pack.P9mjcO/_old 2019-11-20 10:27:16.446562723 +0100 +++ /var/tmp/diff_new_pack.P9mjcO/_new 2019-11-20 10:27:16.450562724 +0100 @@ -17,7 +17,7 @@ Name: yast2 -Version: 4.2.30 +Version: 4.2.34 Release: 0 Summary: YaST2 Main Package License: GPL-2.0-only @@ -119,6 +119,8 @@ Conflicts: yast2-mail < 3.1.7 # Older packager use removed API Conflicts: yast2-packager < 4.0.33 +# Older snapper does not provide machine-readable output +Conflicts: snapper < 0.8.6 Obsoletes: yast2-devel-doc ++++++ yast2-4.2.30.tar.bz2 -> yast2-4.2.34.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.30/library/general/src/lib/ui/text_helpers.rb new/yast2-4.2.34/library/general/src/lib/ui/text_helpers.rb --- old/yast2-4.2.30/library/general/src/lib/ui/text_helpers.rb 2019-10-29 08:31:56.000000000 +0100 +++ new/yast2-4.2.34/library/general/src/lib/ui/text_helpers.rb 2019-11-18 17:33:38.000000000 +0100 @@ -20,36 +20,47 @@ module UI # Provides a set of methods to manipulate and transform UI text module TextHelpers - # Wrap given text breaking lines longer than given wrap size. It supports - # custom separator, max number of lines to split in and cut text to add - # as last line if cut was needed. - # - # @param [String] text to be wrapped - # @param [String] wrap size - # @param [Hash <String>] optional parameters as separator and prepend_text. - # @return [String] wrap text - def wrap_text(text, wrap = 76, separator: " ", prepend_text: "", - n_lines: nil, cut_text: nil) - lines = [] - message_line = prepend_text - text.split(/\s+/).each_with_index do |t, i| - if !message_line.empty? && "#{message_line}#{t}".size > wrap - lines << message_line - message_line = "" - end + # Wrap text breaking lines in the first whitespace that does not exceed given line width + # + # Additionally, it also allows retrieving only an excerpt of the wrapped text according to the + # maximum number of lines indicated, adding one more with the cut_text text when it is given. + # + # @param text [String] text to be wrapped + # @param line_width [Integer] max line length + # @param n_lines [Integer, nil] the maximum number of lines + # @param cut_text [String] the omission text to be used when the text should be cut + # + # @return [String] + def wrap_text(text, line_width = 76, n_lines: nil, cut_text: "") + return text if line_width > text.length - message_line << separator if !message_line.empty? && i != 0 - message_line << t + wrapped_text = text.lines.collect! do |line| + l = (line.length > line_width) ? line.gsub(/(.{1,#{line_width}})(?:\s+|$)/, "\\1\n") : line + l.strip end - lines << message_line if !message_line.empty? + result = wrapped_text.join("\n") + result = head(result, n_lines, omission: cut_text) if n_lines + result + end - if n_lines && lines.size > n_lines - lines = lines[0..n_lines - 1] - lines << cut_text if cut_text - end + # Returns only the first requested lines of the given text + # + # If the omission param is given, an extra line holding it will be included + # + # @param text [String] + # @param max_lines [Integer] + # @param omission [String] the text to be added + # + # @return [String] the first requested lines if the text has more; full text otherwise + def head(text, max_lines, omission: "") + lines = text.lines + + return text if lines.length <= max_lines - lines.join("\n") + result = text.lines[0...max_lines] + result << omission unless omission.empty? + result.join end # Wrap a given text in direction markers diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.30/library/general/src/modules/Linuxrc.rb new/yast2-4.2.34/library/general/src/modules/Linuxrc.rb --- old/yast2-4.2.30/library/general/src/modules/Linuxrc.rb 2019-10-29 08:31:56.000000000 +0100 +++ new/yast2-4.2.34/library/general/src/modules/Linuxrc.rb 2019-11-18 17:33:38.000000000 +0100 @@ -141,6 +141,12 @@ InstallInf("Textmode") == "1" end + def reboot_timeout + return nil unless InstallInf("reboot_timeout") + + InstallInf("reboot_timeout").to_i + end + # end of install.inf reading routines # Write /etc/yast.inf during installation @@ -286,6 +292,7 @@ publish function: :keys, type: "list <string> ()" publish function: :value_for, type: "string (string)" publish function: :disable_remote, type: "list <string> ()" + publish function: :reboot_timeout, type: "integer ()" private diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.30/library/general/test/linuxrc_test.rb new/yast2-4.2.34/library/general/test/linuxrc_test.rb --- old/yast2-4.2.30/library/general/test/linuxrc_test.rb 2019-10-29 08:31:56.000000000 +0100 +++ new/yast2-4.2.34/library/general/test/linuxrc_test.rb 2019-11-18 17:33:38.000000000 +0100 @@ -279,4 +279,16 @@ end end end + + describe "#reboot_timeout" do + it "returns integer value if 'reboot_timeout' is found in install.inf" do + load_install_inf("reboot_timeout" => "15") + expect(subject.reboot_timeout).to eq(15) + end + + it "returns nil if 'reboot_timeout' is not found in install.inf" do + load_install_inf({}) + expect(subject.reboot_timeout).to eq(nil) + end + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.30/library/general/test/text_helpers_test.rb new/yast2-4.2.34/library/general/test/text_helpers_test.rb --- old/yast2-4.2.30/library/general/test/text_helpers_test.rb 2019-10-29 08:31:56.000000000 +0100 +++ new/yast2-4.2.34/library/general/test/text_helpers_test.rb 2019-11-18 17:33:38.000000000 +0100 @@ -10,45 +10,90 @@ describe ::UI::TextHelpers do subject { TestTextHelpers.new } + let(:text) do + "This is a long paragraph. + It contains a not_real_but_really_long_word which must not be broken + and the length of its longer lines is a little git greater than the default line width. + Let's see if it's work." + end describe "#wrap_text" do - let(:devices) { ["eth0", "eth1", "eth2", "eth3", "a_very_long_device_name"] } - let(:more_devices) do - [ - "enp5s0", "enp5s1", "enp5s2", "enp5s3", - "enp5s4", "enp5s5", "enp5s6", "enp5s7" - ] + context "when the text does not exceed the line width" do + let(:text) { "A very short text." } + + it "returns the same text" do + expect(subject.wrap_text(text)).to eq(text) + end end - context "given a text" do - it "returns same text if it does not exceed the wrap size" do - text = "eth0, eth1, eth2, eth3, a_very_long_device_name" + context "when the text exceed the given line width" do + it "produces a text with lines no longer than given line width" do + line_width = 60 + wrapped_text = subject.wrap_text(text, line_width) - expect(subject.wrap_text(devices.join(", "))).to eql(text) + expect(wrapped_text.lines.map(&:length)).to all(be < line_width) end - context "and a line size" do - it "returns given text splitted in lines by given line size" do - text = "eth0, eth1, eth2,\n" \ - "eth3,\n" \ - "a_very_long_device_name" + it "respect present carriage returns" do + current_lines = text.lines.size + + expect(subject.wrap_text(text).lines.size).to be > current_lines + end - expect(subject.wrap_text(devices.join(", "), 16)).to eql(text) + it "does not break words" do + wrapped_text = subject.wrap_text(text) + + expect(wrapped_text).to match(/it\'s/) + expect(wrapped_text).to match(/not_real_but_really_long_word/) + end + + context "and a max number of lines is set (n_lines)" do + it "returns only the first n_lines" do + wrapped_text = subject.wrap_text(text, n_lines: 2) + + expect(wrapped_text.lines.size).to eq(2) + expect(wrapped_text).to match(/^This is/) + expect(wrapped_text).to match(/broken$/) + end + + context "with an ommission text (cut_text)" do + it "includes an additional line with the cut_text" do + omission = "..." + wrapped_text = subject.wrap_text(text, n_lines: 2, cut_text: omission) + + expect(wrapped_text.lines.size).to eq(3) + expect(wrapped_text).to match(/^This is/) + expect(wrapped_text.lines.last).to eq("...") + end end end + end + end + + describe "#head" do + let(:omission_text) { "read more" } - context "and a number of lines and '...' as cut text" do - it "returns wrapped text until given line's number adding '...' as a new line" do - devices_s = (devices + more_devices).join(", ") - text = "eth0, eth1, eth2,\n" \ - "eth3,\n" \ - "a_very_long_device_name,\n" \ - "..." + context "when the text has less lines than requested" do + it "returns the full text" do + expect(subject.head(text, 10)).to eq(text) + end - expect(subject.wrap_text(devices_s, 20, n_lines: 3, cut_text: "...")).to eql(text) + context "and the omision text is given" do + it "does not include the omission text" do + expect(subject.head(text, 10, omission: omission_text)).to_not include(omission_text) end end end + + context "when the text has more lines than requested" do + it "returns only the first requested lines" do + head = subject.head(text, 2) + + expect(head.lines.size).to eq(2) + expect(head).to match(/^This is/) + expect(head).to match(/broken$/) + end + end end describe "#div_with_direction" do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.30/library/network/src/modules/NetworkService.rb new/yast2-4.2.34/library/network/src/modules/NetworkService.rb --- old/yast2-4.2.30/library/network/src/modules/NetworkService.rb 2019-10-29 08:31:56.000000000 +0100 +++ new/yast2-4.2.34/library/network/src/modules/NetworkService.rb 2019-11-18 17:33:38.000000000 +0100 @@ -76,6 +76,7 @@ Yast.import "Mode" Yast.import "Stage" Yast.import "PackageSystem" + Yast.import "Systemd" textdomain "base" @@ -186,19 +187,30 @@ Read() end - # Initialize module data - def Read - return if @initialized - - if Stage.initial - @current_name = DEFAULT_BACKEND - log.info "Running in installer/AutoYaST, use default: #{@current_name}" + # Determines which backend is in use based on the network service. In an + # (auto)installation it returns the default backend except if systemd is + # running (live) where the systemd service can be checked. + # + # @return [Symbol,nil] backend in use or nil + def backend_in_use + backend = nil + + if Stage.initial && !Systemd.Running + backend = DEFAULT_BACKEND + log.info "Running in installer/AutoYaST, use default: #{backend}" else service = Yast2::Systemd::Service.find("network") - @current_name = BACKENDS.invert[service.name] if service + backend = BACKENDS.invert[service.name] if service end - @cached_name = @current_name + backend + end + + # Initialize module data + def Read + return if @initialized + + @cached_name = @current_name = backend_in_use log.info "Current backend: #{@current_name}" @initialized = true @@ -206,6 +218,12 @@ nil end + def reset! + @initialized = false + @current_name = nil + @cached_name = nil + end + # Helper to apply a change of the network service def EnableDisableNow return if !Modified() @@ -215,7 +233,7 @@ disable_service(current_name) end - RunSystemCtl(BACKENDS[cached_name], "enable", force: true) if cached_name + enable_service(cached_name) if cached_name @initialized = false Read() @@ -432,6 +450,10 @@ RunSystemCtl(BACKENDS[service], "disable") end + def enable_service(service) + RunSystemCtl(BACKENDS[service], "enable", force: true) + end + publish function: :Read, type: "void ()" publish function: :Modified, type: "boolean ()" publish function: :is_backend_available, type: "boolean (symbol)" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.30/library/network/test/network_service_test.rb new/yast2-4.2.34/library/network/test/network_service_test.rb --- old/yast2-4.2.30/library/network/test/network_service_test.rb 2019-10-29 08:31:56.000000000 +0100 +++ new/yast2-4.2.34/library/network/test/network_service_test.rb 2019-11-18 17:33:38.000000000 +0100 @@ -91,4 +91,63 @@ end end end + + describe "#backend_in_use" do + let(:initial_stage) { true } + let(:systemd_running) { true } + let(:service_name) { "NetworkManager" } + let(:service) { instance_double("Yast2::Systemd::Service", name: service_name) } + before do + allow(Yast::Stage).to receive(:initial).and_return(initial_stage) + allow(Yast::Systemd).to receive(:Running).and_return(systemd_running) + allow(Yast2::Systemd::Service).to receive(:find).and_return(service) + end + + context "when running on the initial Stage" do + context "and systemd is not running" do + let(:systemd_running) { false } + + it "returns the default backend symbol" do + expect(subject.backend_in_use).to eq(Yast::NetworkServiceClass::DEFAULT_BACKEND) + end + end + + context "and systemd is running" do + context "and wicked is linked to the network service" do + let(:service_name) { "wicked" } + + it "returns :wicked" do + expect(subject.backend_in_use).to eq(:wicked) + end + end + + context "and NetworkManager is linked to the network service" do + it "returns :network_manager" do + expect(subject.backend_in_use).to eq(:network_manager) + end + end + + context "and no service is linked to the network service" do + let(:service) { nil } + + it "returns nil" do + expect(subject.backend_in_use).to be_nil + end + end + end + end + end + + describe "#Read" do + before do + allow(subject).to receive(:backend_in_use).and_return(:wicked) + subject.reset! + end + + it "reads the current state and caches it" do + expect(subject).to receive(:backend_in_use).once.and_return(:wicked) + expect(subject.wicked?).to eq(true) + expect(subject.wicked?).to eq(true) + end + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.30/library/system/src/lib/yast2/fs_snapshot.rb new/yast2-4.2.34/library/system/src/lib/yast2/fs_snapshot.rb --- old/yast2-4.2.30/library/system/src/lib/yast2/fs_snapshot.rb 2019-10-29 08:31:56.000000000 +0100 +++ new/yast2-4.2.34/library/system/src/lib/yast2/fs_snapshot.rb 2019-11-18 17:33:38.000000000 +0100 @@ -1,6 +1,6 @@ # *************************************************************************** # -# Copyright (c) 2015 SUSE LLC +# Copyright (c) [2015-2019] SUSE LLC # All Rights Reserved. # # This program is free software; you can redistribute it and/or @@ -28,6 +28,7 @@ require "date" require "yast2/execute" require "shellwords" +require "csv" module Yast2 # Represents the fact that Snapper is not configured for "/" (root). @@ -70,16 +71,21 @@ Yast.import "Linuxrc" Yast.import "Mode" - FIND_CONFIG_CMD = "/usr/bin/snapper --no-dbus --root=%{root} list-configs | /usr/bin/grep \"^root \" >/dev/null".freeze - CREATE_SNAPSHOT_CMD = "/usr/lib/snapper/installation-helper --step 5 --root-prefix=%{root} --snapshot-type %{snapshot_type} --description %{description}".freeze - LIST_SNAPSHOTS_CMD = "LANG=en_US.UTF-8 /usr/bin/snapper --no-dbus --root=%{root} list --disable-used-space".freeze - VALID_LINE_REGEX = /\A\s*\d+[-+*]?\s*\|\s*\w+/.freeze + FIND_CONFIG_CMD = + "/usr/bin/snapper --no-dbus --root=%{root} --csvout list-configs " \ + "--columns config,subvolume | /usr/bin/grep \"^root,\" >/dev/null".freeze + + CREATE_SNAPSHOT_CMD = "/usr/lib/snapper/installation-helper --step 5 --root-prefix=%{root} " \ + "--snapshot-type %{snapshot_type} --description %{description}".freeze + + LIST_SNAPSHOTS_CMD = + "/usr/bin/snapper --no-dbus --root=%{root} --utc --csvout list --disable-used-space " \ + "--columns number,type,pre-number,date,user,cleanup,description".freeze # Predefined snapshot cleanup strategies (the user can define custom ones, too) CLEANUP_STRATEGY = { number: "number", timeline: "timeline" }.freeze - attr_reader :number, :snapshot_type, :previous_number, :timestamp, :user, - :cleanup_algo, :description + attr_reader :number, :snapshot_type, :previous_number, :timestamp, :user, :cleanup_algo, :description # FsSnapshot constructor # @@ -88,11 +94,13 @@ # # @param number [Fixnum] Snapshot's number. # @param snapshot_type [Symbol] Snapshot's type: :pre, :post or :single. - # @param previous_number [Fixnum] Previous snapshot's number. - # @param timestamp [DateTime] Timestamp - # @param user [String] Snapshot's owner username. - # @param cleanup_algo [String] Clean-up algorithm. - # @param description [String] Snapshot's description. + # @param previous_number [Fixnum, nil] Previous snapshot's number; nil if the snapshot has no pre + # snapshot associated to it. + # @param timestamp [DateTime, nil] Timestamp; nil if the datetime is unknown. + # @param user [String, nil] Snapshot's owner username; nil if the owner is unknown. + # @param cleanup_algo [Symbol, nil] Clean-up algorithm; nil if the algorithm is unknown. + # @param description [String, nil] Snapshot's description; nil if the snapshot has no + # description. # @return [FsSnapshot] New FsSnapshot object. def initialize(number, snapshot_type, previous_number, timestamp, user, cleanup_algo, description) @number = number @@ -120,7 +128,7 @@ class << self # Determines whether snapper is configured or not # - # @return [true,false] true if it's configured; false otherwise. + # @return [Boolean] true if it's configured; false otherwise. def configured? return @configured unless @configured.nil? @@ -256,21 +264,25 @@ Yast::Path.new(".target.bash_output"), format(LIST_SNAPSHOTS_CMD, root: target_root.shellescape) ) - lines = out["stdout"].lines.grep(VALID_LINE_REGEX) # relevant lines from output. + log.info("Retrieving snapshots list: #{LIST_SNAPSHOTS_CMD} returned: #{out}") - lines.each_with_object([]) do |line, snapshots| - data = line.split("|").map(&:strip) - next if data[0] == "0" # Ignores 'current' snapshot (id = 0) because it's not a real snapshot - - begin - timestamp = DateTime.parse(data[3]) - rescue ArgumentError - log.warn("Error when parsing date/time: #{timestamp}") - timestamp = nil + + csv = CSV.parse(out["stdout"], headers: true, converters: [:date_time, :numeric]) + + csv.each_with_object([]) do |row, snapshots| + next if row[0] == 0 # Ignores 'current' snapshot (id = 0) because it's not a real snapshot + + fields = row.fields + + if !fields[3].is_a?(DateTime) + log.warn("Error when parsing date/time: #{fields[3]}") + fields[3] = nil end - previous_number = (data[2] == "") ? nil : data[2].to_i - snapshots << new(data[0].to_i, data[1].to_sym, previous_number, timestamp, - data[4], data[5].to_sym, data[6]) + + fields[1] = fields[1].to_sym # type + fields[5] = fields[5].to_sym if fields[5] # cleanup + + snapshots << new(*fields) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.30/library/system/test/fixtures/empty-snapper-list.txt new/yast2-4.2.34/library/system/test/fixtures/empty-snapper-list.txt --- old/yast2-4.2.30/library/system/test/fixtures/empty-snapper-list.txt 2019-10-29 08:31:56.000000000 +0100 +++ new/yast2-4.2.34/library/system/test/fixtures/empty-snapper-list.txt 2019-11-18 17:33:38.000000000 +0100 @@ -1,2 +1 @@ - # | Type | Pre # | Date | User | Cleanup | Description | Userdata ----+--------+-------+----------------------------------+------+---------+--------------+-------------- +number,type,pre-number,date,user,cleanup,description diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.30/library/system/test/fixtures/snapper-list.txt new/yast2-4.2.34/library/system/test/fixtures/snapper-list.txt --- old/yast2-4.2.30/library/system/test/fixtures/snapper-list.txt 2019-10-29 08:31:56.000000000 +0100 +++ new/yast2-4.2.34/library/system/test/fixtures/snapper-list.txt 2019-11-18 17:33:38.000000000 +0100 @@ -1,7 +1,6 @@ - # | Type | Pre # | Date | User | Cleanup | Description | Userdata -----+--------+-------+----------------------------------+------+---------+--------------+-------------- - 0 | single | | | root | | current | - 1 | pre | | Wed 13 May 2015 04:14:14 PM WEST | root | number | zypp(y2base) | important=no - 3 | pre | | Wed 13 May 2015 05:01:47 PM WEST | root | number | zypp(zypper) | important=no - 4 | post | 3 | Wed 13 May 2015 05:03:13 PM WEST | root | number | zypp(zypper) | important=no -15* | single | | Wed 13 May 2015 05:11:25 PM WEST | root | | | +number,type,pre-number,date,user,cleanup,description +0,single,,,root,,current +1,pre,,2015-05-13 04:14:14,root,number,zypp(y2base) +3,pre,,2015-05-15 05:01:47,root,number,zypp(zypper) +4,post,3,2015-05-13 05:03:13,root,number,zypp(zypper) +15,single,,2015-05-13 05:11:25,root,, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.30/library/system/test/fs_snapshot_test.rb new/yast2-4.2.34/library/system/test/fs_snapshot_test.rb --- old/yast2-4.2.30/library/system/test/fs_snapshot_test.rb 2019-10-29 08:31:56.000000000 +0100 +++ new/yast2-4.2.34/library/system/test/fs_snapshot_test.rb 2019-11-18 17:33:38.000000000 +0100 @@ -1,5 +1,24 @@ #!/usr/bin/env rspec +# Copyright (c) [2015-2019] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + require_relative "test_helper" require "yast2/fs_snapshot" @@ -8,10 +27,6 @@ described_class.log end - FIND_CONFIG = "/usr/bin/snapper --no-dbus --root=/ list-configs | /usr/bin/grep \"^root \" >/dev/null".freeze - FIND_IN_ROOT_CONFIG = "/usr/bin/snapper --no-dbus --root=/mnt list-configs | /usr/bin/grep \"^root \" >/dev/null".freeze - LIST_SNAPSHOTS = "LANG=en_US.UTF-8 /usr/bin/snapper --no-dbus --root=/ list --disable-used-space".freeze - let(:dummy_snapshot) { double("snapshot") } before do @@ -20,9 +35,11 @@ end describe ".configured?" do + let(:command) { format(Yast2::FsSnapshot::FIND_CONFIG_CMD, root: "/") } + before do allow(Yast::SCR).to receive(:Execute) - .with(path(".target.bash_output"), FIND_CONFIG) + .with(path(".target.bash_output"), command) .and_return("stdout" => "", "exit" => find_code) end @@ -44,7 +61,10 @@ end context "in initial stage before scr switched" do + let(:command) { format(Yast2::FsSnapshot::FIND_CONFIG_CMD, root: "/mnt") } + let(:find_code) { 0 } + before do Yast.import "Installation" Yast::Installation.destdir = "/mnt" @@ -53,13 +73,13 @@ allow(Yast::Stage).to receive(:initial).and_return true allow(Yast::SCR).to receive(:Execute) - .with(path(".target.bash_output"), FIND_IN_ROOT_CONFIG) + .with(path(".target.bash_output"), command) .and_return("stdout" => "", "exit" => 0) end it "detects snapper configuration in installation target dir" do expect(Yast::SCR).to receive(:Execute) - .with(path(".target.bash_output"), FIND_IN_ROOT_CONFIG) + .with(path(".target.bash_output"), command) .and_return("stdout" => "", "exit" => 0) expect(described_class.configured?).to eq(true) @@ -429,15 +449,17 @@ context "when snapper is configured" do let(:configured) { true } - let(:output) { File.read(output_path) } + + let(:command) { format(Yast2::FsSnapshot::LIST_SNAPSHOTS_CMD, root: "/") } before do allow(Yast::SCR).to receive(:Execute) - .with(path(".target.bash_output"), LIST_SNAPSHOTS) + .with(path(".target.bash_output"), command) .and_return("stdout" => output, "exit" => 0) end context "given some snapshots exist" do + let(:output) { File.read(output_path) } let(:output_path) { File.expand_path("fixtures/snapper-list.txt", __dir__) } it "should return the snapshots and log about how many were found" do @@ -449,12 +471,26 @@ end context "given no snapshots exist" do + let(:output) { File.read(output_path) } let(:output_path) { File.expand_path("fixtures/empty-snapper-list.txt", __dir__) } it "should return an empty array" do expect(described_class.all).to eq([]) end end + + context "when an snapshot contains a wrong date" do + let(:output) do + "number,type,pre-number,date,user,cleanup,description\n" \ + "1,single,,bad-date,root,,\n" + end + + it "sets timestamp to nil" do + snapshot = described_class.all.first + + expect(snapshot.timestamp).to be_nil + end + end end context "when snapper is not configured" do @@ -477,9 +513,11 @@ let(:output) { File.read(output_path) } let(:output_path) { File.expand_path("fixtures/snapper-list.txt", __dir__) } + let(:command) { format(Yast2::FsSnapshot::LIST_SNAPSHOTS_CMD, root: "/") } + before do allow(Yast::SCR).to receive(:Execute) - .with(path(".target.bash_output"), LIST_SNAPSHOTS) + .with(path(".target.bash_output"), command) .and_return("stdout" => output, "exit" => 0) end @@ -489,7 +527,7 @@ expect(snapshot.number).to eq(4) expect(snapshot.snapshot_type).to eq(:post) expect(snapshot.previous_number).to eq(3) - expect(snapshot.timestamp).to eq(DateTime.parse("Wed 13 May 2015 05:03:13 PM WEST")) + expect(snapshot.timestamp).to eq(DateTime.parse("2015-05-13 05:03:13")) expect(snapshot.user).to eq("root") expect(snapshot.cleanup_algo).to eq(:number) expect(snapshot.description).to eq("zypp(zypper)") @@ -517,10 +555,12 @@ let(:output) { File.read(output_path) } let(:output_path) { File.expand_path("fixtures/snapper-list.txt", __dir__) } + let(:command) { format(Yast2::FsSnapshot::LIST_SNAPSHOTS_CMD, root: "/") } + before do allow(Yast2::FsSnapshot).to receive(:configured?).and_return(true) allow(Yast::SCR).to receive(:Execute) - .with(path(".target.bash_output"), LIST_SNAPSHOTS) + .with(path(".target.bash_output"), command) .and_return("stdout" => output, "exit" => 0) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.30/library/systemd/src/lib/yast2/systemd/unit.rb new/yast2-4.2.34/library/systemd/src/lib/yast2/systemd/unit.rb --- old/yast2-4.2.30/library/systemd/src/lib/yast2/systemd/unit.rb 2019-10-29 08:31:56.000000000 +0100 +++ new/yast2-4.2.34/library/systemd/src/lib/yast2/systemd/unit.rb 2019-11-18 17:33:38.000000000 +0100 @@ -35,6 +35,7 @@ # class Unit Yast.import "Stage" + Yast.import "Systemd" include Yast::Logger SUPPORTED_TYPES = %w[service socket target].freeze @@ -105,7 +106,7 @@ # @return [Yast2::Systemd::UnitProperties] def show(property_text = nil) # Using different handler during first stage (installation, update, ...) - if Yast::Stage.initial + if Yast::Stage.initial && !Yast::Systemd.Running UnitInstallationProperties.new(self) else UnitProperties.new(self, property_text) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.30/library/systemd/test/yast2/systemd_unit_test.rb new/yast2-4.2.34/library/systemd/test/yast2/systemd_unit_test.rb --- old/yast2-4.2.30/library/systemd/test/yast2/systemd_unit_test.rb 2019-10-29 08:31:56.000000000 +0100 +++ new/yast2-4.2.34/library/systemd/test/yast2/systemd_unit_test.rb 2019-11-18 17:33:38.000000000 +0100 @@ -22,6 +22,7 @@ context "Installation system without full support of systemd" do before do allow(Yast::Stage).to receive(:initial).and_return(true) + allow(Yast::Systemd).to receive(:Running).and_return(false) end describe "#properties" do @@ -71,6 +72,11 @@ end describe "#properties" do + let(:properties_methods) do + [:supported?, :not_found?, :static?, :error, :raw] + delegated_methods + end + let(:delegated_methods) { [:enabled?, :active?, :loaded?, :path, :can_reload?] } + it "always returns struct including default properties" do unit = Systemd::Unit.new("iscsi.socket") expect(unit.properties.to_h.keys).to include(*Yast2::Systemd::UnitPropMap::DEFAULT.keys) @@ -78,25 +84,12 @@ it "provides status properties methods" do unit = Systemd::Unit.new("iscsid.socket") - expect(unit.properties[:enabled?]).not_to be_nil - expect(unit.properties[:active?]).not_to be_nil - expect(unit.properties[:loaded?]).not_to be_nil - expect(unit.properties[:supported?]).not_to be_nil - expect(unit.properties[:not_found?]).not_to be_nil - expect(unit.properties[:static?]).not_to be_nil - expect(unit.properties[:path]).not_to be_nil - expect(unit.properties[:error]).not_to be_nil - expect(unit.properties[:raw]).not_to be_nil - expect(unit.properties[:can_reload?]).not_to be_nil + properties_methods.each { |m| expect(unit.properties[m]).not_to be_nil } end it "delegates the status properties onto the unit object" do unit = Systemd::Unit.new("iscsid.socket") - expect(unit).to respond_to(:enabled?) - expect(unit).to respond_to(:active?) - expect(unit).to respond_to(:loaded?) - expect(unit).to respond_to(:path) - expect(unit).to respond_to(:can_reload?) + delegated_methods.each { |m| expect(unit).to respond_to(m) } end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.30/package/yast2.changes new/yast2-4.2.34/package/yast2.changes --- old/yast2-4.2.30/package/yast2.changes 2019-10-29 08:31:56.000000000 +0100 +++ new/yast2-4.2.34/package/yast2.changes 2019-11-18 17:33:38.000000000 +0100 @@ -1,4 +1,32 @@ ------------------------------------------------------------------- +Fri Nov 15 09:30:20 UTC 2019 - Josef Reidinger <jreidin...@suse.com> + +- Fix crash in upgrade caused by wrong parameter to snapper + (bsc#1156819) +- 4.2.34 + +------------------------------------------------------------------- +Tue Nov 05 14:15:16 UTC 2019 - José Iván López González <jlo...@suse.com> + +- Use new snapper machine-readable output to retrieve snapshots + information (related to bsc#1149322). +- 4.2.33 + +------------------------------------------------------------------- +Tue Nov 05 13:24:40 UTC 2019 - Oliver Kurz <ok...@suse.com> + +- Add linuxrc option "reboot_timeout" to configure the timeout + before reboot (bsc#1122493) +- 4.2.32 + +------------------------------------------------------------------- +Thu Oct 31 12:59:33 UTC 2019 - Knut Anderssen <kanders...@suse.com> + +- Network: During an installation, check which backend is in use + when Systemd is running. (bsc#1151291) +- 4.2.31 + +------------------------------------------------------------------- Tue Oct 29 07:22:13 UTC 2019 - Josef Reidinger <jreidin...@suse.com> - fix showing release notes for online upgrade (bsc#1155134) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-4.2.30/package/yast2.spec new/yast2-4.2.34/package/yast2.spec --- old/yast2-4.2.30/package/yast2.spec 2019-10-29 08:31:56.000000000 +0100 +++ new/yast2-4.2.34/package/yast2.spec 2019-11-18 17:33:38.000000000 +0100 @@ -17,7 +17,7 @@ Name: yast2 -Version: 4.2.30 +Version: 4.2.34 Release: 0 Summary: YaST2 Main Package License: GPL-2.0-only @@ -119,6 +119,8 @@ Conflicts: yast2-mail < 3.1.7 # Older packager use removed API Conflicts: yast2-packager < 4.0.33 +# Older snapper does not provide machine-readable output +Conflicts: snapper < 0.8.6 Obsoletes: yast2-devel-doc