diff --git a/package/yast2-kdump.changes b/package/yast2-kdump.changes index 244bb84..7bbba58 100644 --- a/package/yast2-kdump.changes +++ b/package/yast2-kdump.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Thu Sep 26 12:25:08 UTC 2019 - Josef Reidinger + +- fix installing kdump to first stage when kdump enabled in + AutoYaST (bsc#1149208) +- 4.2.5 + ------------------------------------------------------------------- Wed Aug 28 09:52:34 CEST 2019 - schubi@suse.de diff --git a/package/yast2-kdump.spec b/package/yast2-kdump.spec index 522383c..059a4d7 100644 --- a/package/yast2-kdump.spec +++ b/package/yast2-kdump.spec @@ -17,7 +17,7 @@ Name: yast2-kdump -Version: 4.2.4 +Version: 4.2.5 Release: 0 Summary: Configuration of kdump License: GPL-2.0-only diff --git a/src/clients/kdump_auto.rb b/src/clients/kdump_auto.rb index f37b648..9177222 100644 --- a/src/clients/kdump_auto.rb +++ b/src/clients/kdump_auto.rb @@ -1,109 +1,3 @@ -# encoding: utf-8 +require "kdump/clients/auto" -# File: -# kdump_auto.ycp -# -# Module: -# Kdump installation and configuration -# -# Summary: -# Kdump autoinstallation preparation -# -# Authors: -# Jozef Uhliarik -# -# -module Yast - class KdumpAutoClient < Client - def main - Yast.import "UI" - textdomain "kdump" - - Builtins.y2milestone("----------------------------------------") - Builtins.y2milestone("kdump auto started") - - Yast.import "Kdump" - Yast.import "Mode" - Yast.import "Progress" - - Yast.include self, "kdump/wizards.rb" - - @progress_orig = Progress.set(false) - - @ret = nil - @func = "" - @param = {} - - # Check arguments - if Ops.greater_than(Builtins.size(WFM.Args), 0) && - Ops.is_string?(WFM.Args(0)) - @func = Convert.to_string(WFM.Args(0)) - if Ops.greater_than(Builtins.size(WFM.Args), 1) && - Ops.is_map?(WFM.Args(1)) - @param = Convert.to_map(WFM.Args(1)) - end - end - Builtins.y2debug("func=%1", @func) - Builtins.y2debug("param=%1", @param) - - if @func == "Import" - @ret = Kdump.Import(@param) - # Create a summary - # return string - elsif @func == "Summary" - @ret = Ops.add( - Ops.add( - "" - ) - # did configuration changed - # return boolean - elsif @func == "GetModified" - @ret = Kdump.GetModified - # set configuration as changed - # return boolean - elsif @func == "SetModified" - Kdump.SetModified - @ret = true - # Reset configuration - # return map or list - elsif @func == "Reset" - Kdump.Import({}) - @ret = {} - # Change configuration - # return symbol (i.e. `finish || `accept || `next || `cancel || `abort) - elsif @func == "Change" - @ret = KdumpAutoSequence() - return deep_copy(@ret) - # Return configuration data - # return map or list - elsif @func == "Export" - @ret = Kdump.Export - # Write configuration data - # return boolean - elsif @func == "Write" - @ret = Kdump.Write - elsif @func == "Read" - @ret = Kdump.Read - else - Builtins.y2error("unknown function: %1", @func) - @ret = false - end - Progress.set(@progress_orig) - - Builtins.y2debug("ret=%1", @ret) - Builtins.y2milestone("kdump_auto finished") - Builtins.y2milestone("----------------------------------------") - - deep_copy(@ret) - - # EOF - end - end -end - -Yast::KdumpAutoClient.new.main +Y2Kdump::Clients::Auto.run diff --git a/src/lib/kdump/clients/auto.rb b/src/lib/kdump/clients/auto.rb new file mode 100644 index 0000000..c4bc5f4 --- /dev/null +++ b/src/lib/kdump/clients/auto.rb @@ -0,0 +1,88 @@ +# encoding: utf-8 + +# ------------------------------------------------------------------------------ +# 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. +# +# ------------------------------------------------------------------------------ + +require "installation/auto_client" + +Yast.import "Kdump" +Yast.import "Mode" +Yast.import "Progress" +Yast.import "PackagesProposal" + +module Y2Kdump + module Clients + # Client to communicate with autoyast + class Auto < ::Installation::AutoClient + def initialize + textdomain "kdump" + + Yast.include self, "kdump/wizards.rb" # needed for auto sequence + end + + def import(profile) + Yast::Kdump.Import(profile) + # add packages needed to proposal, as it is needed already in first stage (bsc#1149208) + Yast::PackagesProposal.AddResolvables("yast2-kdump", :package, packages["install"]) + end + + def export + Yast::Kdump.Export + end + + def summary + items = Yast::Kdump.Summary.map { |s| "
  • #{s}
  • " } + "" + end + + def modified? + Yast::Kdump.GetModified + end + + def modified + Yast::Kdump.SetModified + end + + def reset + Yast::Kdump.Import({}) + end + + def change + KdumpAutoSequence() + end + + def write + progress_orig = Yast::Progress.set(false) + Yast::Kdump.Write + Yast::Progress.set(progress_orig) + end + + def read + progress_orig = Yast::Progress.set(false) + Yast::Kdump.Read + Yast::Progress.set(progress_orig) + end + + def packages + if Yast::Kdump.add_crashkernel_param + { + "install" => Yast::KdumpClass::KDUMP_PACKAGES, + "remove" => [] + } + else + {} + end + end + end + end +end diff --git a/test/auto_test.rb b/test/auto_test.rb new file mode 100644 index 0000000..ee42c72 --- /dev/null +++ b/test/auto_test.rb @@ -0,0 +1,76 @@ +#!/usr/bin/env rspec + +require_relative "./test_helper" + +require "kdump/clients/auto" + +describe Y2Kdump::Clients::Auto do + describe "#import" do + it "imports given hash" do + expect(Yast::Kdump).to receive(:Import).with({}) + subject.import({}) + end + end + + describe "#export" do + it "returns hash" do + expect(subject.export).to be_a ::Hash + end + end + + describe "#summary" do + it "returns a string" do + expect(subject.summary).to be_a ::String + end + end + + describe "#modified" do + it "sets modified flag" do + subject.modified + expect(subject.modified?).to eq true + end + end + + describe "#reset" do + it "import empty data" do + expect(Yast::Kdump).to receive(:Import).with({}) + subject.reset + end + end + + describe "#read" do + it "reads system kdump settings" do + expect(Yast::Kdump).to receive(:Read) + subject.read + end + end + + describe "#write" do + it "writes settings to system" do + expect(Yast::Kdump).to receive(:Write) + subject.write + end + end + + describe "#packages" do + before do + allow(Yast::Kdump).to receive(:add_crashkernel_param).and_return(enabled) + end + + context "kdump is enabled" do + let(:enabled) { true } + + it "returns list of packages to install" do + expect(subject.packages).to eq("install" => ["kexec-tools", "kdump"], "remove" => []) + end + end + + context "kdump is disabled" do + let(:enabled) { false } + + it "returns empty list" do + expect(subject.packages).to eq({}) + end + end + end +end