Skip to content

Commit

Permalink
Merge pull request #367 from teclator/disk_activation
Browse files Browse the repository at this point in the history
Skipped disk activation step in case of installer updated (bsc#974409)
  • Loading branch information
teclator committed Apr 22, 2016
2 parents b592f6d + 821e3e4 commit 8c3552d
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 19 deletions.
9 changes: 9 additions & 0 deletions package/yast2-installation.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
-------------------------------------------------------------------
Wed Apr 20 10:47:12 UTC 2016 - knut.anderssen@suse.com

- Disk Activation step will be skipped in case of installer update
success (bsc#974409)
- License agreement will be remembered in case of going back after
a installer update.
- 3.1.182

-------------------------------------------------------------------
Tue Apr 19 09:08:35 UTC 2016 - igonzalezsosa@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-installation.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-installation
Version: 3.1.181
Version: 3.1.182
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
27 changes: 17 additions & 10 deletions src/lib/installation/clients/inst_complex_welcome.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ def main

textdomain "installation"

@license_id = Ops.get(Pkg.SourceGetCurrent(true), 0, 0)

# ------------------------------------- main part of the client -----------
if data_stored? && !GetInstArgs.going_back
if Installation.restarting? && data_stored?
apply_data
return :next
end
Expand All @@ -53,8 +55,6 @@ def main
@language = Language.language
@keyboard = ""

@license_id = Ops.get(Pkg.SourceGetCurrent(true), 0, 0)

# ----------------------------------------------------------------------
# Build dialog
# ----------------------------------------------------------------------
Expand Down Expand Up @@ -100,7 +100,8 @@ def event_loop
Keyboard.Set(@keyboard)
Keyboard.user_decision = true
when :license_agreement
InstData.product_license_accepted = UI.QueryWidget(Id(:license_agreement), :Value)
read_ui_state
InstData.product_license_accepted = @license_accepted
when :language
next if Mode.config
read_ui_state
Expand Down Expand Up @@ -144,6 +145,7 @@ def initialize_widgets
Wizard.EnableAbortButton

UI.ChangeWidget(Id(:language), :Value, @language)
UI.ChangeWidget(Id(:license_agreement), :Value, @license_accepted)

if Keyboard.user_decision
UI.ChangeWidget(Id(:keyboard), :Value, Keyboard.current_kbd)
Expand Down Expand Up @@ -286,8 +288,9 @@ def warn_license_required
end

def read_ui_state
@language = UI.QueryWidget(Id(:language), :Value)
@keyboard = UI.QueryWidget(Id(:keyboard), :Value)
@language = UI.QueryWidget(Id(:language), :Value)
@keyboard = UI.QueryWidget(Id(:keyboard), :Value)
@license_accepted = UI.QueryWidget(Id(:license_agreement), :Value)
end

def retranslate_yast
Expand Down Expand Up @@ -321,6 +324,7 @@ def change_language

def setup_final_choice
Keyboard.Set(@keyboard)
InstData.product_license_accepted = @license_accepted

# Language has been set already.
# On first run store users decision as default.
Expand Down Expand Up @@ -357,17 +361,20 @@ def data_stored?

def store_data
data = {
"language" => @language,
"keyboard" => @keyboard
"language" => @language,
"keyboard" => @keyboard,
"license_accepted" => @license_accepted
}

File.write(DATA_PATH, data.to_yaml)
end

def apply_data
data = YAML.load(File.read(DATA_PATH))
@language = data["language"]
@keyboard = data["keyboard"]
@language = data["language"]
@keyboard = data["keyboard"]
@license_accepted = data["license_accepted"]
ProductLicense.info_seen!(@license_id)

change_language
setup_final_choice
Expand Down
5 changes: 5 additions & 0 deletions src/lib/installation/clients/inst_disks_activate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#
# $Id$
#

require "installation/clients/inst_update_installer"

module Yast
class InstDisksActivateClient < Client
def main
Expand Down Expand Up @@ -55,6 +58,8 @@ def main
@have_zfcp = false
@want_fcoe = false

return :next if Installation.restarting?

if Arch.s390
# popup label
UI.OpenDialog(Label(_("Detecting Available Controllers")))
Expand Down
6 changes: 4 additions & 2 deletions src/lib/installation/clients/inst_update_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@ def main
textdomain "installation"

return :back if GetInstArgs.going_back

Installation.finish_restarting! if Installation.restarting?

return :next unless try_to_update?

log.info("Trying installer update")

if update_installer
::FileUtils.touch(update_flag_file) # Indicates that the installer was updated.
::FileUtils.touch(Installation.restart_file)
:restart_yast # restart YaST to apply modifications.
Installation.restart!
else
:next
end
Expand Down
19 changes: 16 additions & 3 deletions test/inst_complex_welcome_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@

before do
stub_const("Yast::InstComplexWelcomeClient::DATA_PATH", store_path)
allow(Yast::ProductLicense).to receive(:info_seen?) { true }
end

after do
FileUtils.rm(store_path) if File.exist?(store_path)
end

describe "#main" do
let(:restarting) { false }
context "when installation Mode is auto" do
it "returns :auto" do
expect(Yast::Mode).to receive(:autoinst) { true }
Expand All @@ -31,18 +33,29 @@
context "when installation mode is not auto" do
before do
expect(Yast::Mode).to receive(:autoinst) { false }
allow(Yast::Installation).to receive(:restarting?) { restarting }
end

context "and previous data exist" do
it "applies data and returns :next" do
context "and installer is restarting" do
let(:restarting) { true }
it "applies data if exists and returns next" do
allow(subject).to receive(:data_stored?) { true }
expect(subject).to receive(:apply_data)

expect(subject.main).to eql(:next)
end

it "does not apply data if not exists and continues as not restarting" do
allow(subject).to receive(:data_stored?) { false }
expect(subject).not_to receive(:apply_data)
allow(subject).to receive(:event_loop)
expect(subject).to receive(:initialize_dialog)

subject.main
end
end

context "and no previous data exist" do
context "and installer is not restarting" do
before do
allow(subject).to receive(:data_stored?) { false }
end
Expand Down
15 changes: 13 additions & 2 deletions test/inst_disks_activate_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,30 @@
Yast.import "GetInstArgs"
Yast.import "UI"
Yast.import "Popup"
Yast.import "Storage"

describe "#main" do
let(:probed_disks) { [] }
let(:s390) { false }
let(:restarting) { false }

before do
allow(Yast::Linuxrc).to receive(:InstallInf).with("WithFCoE").and_return("0")
allow(Yast::UI).to receive(:OpenDialog)
allow(Yast::UI).to receive(:CloseDialog)
allow(Yast::Popup).to receive(:ConfirmAbort).with(:painless).and_return(true)
allow(Yast::Arch).to receive(:s390).and_return(s390)
allow(Yast::Storage).to receive(:ReReadTargetMap)
allow(Yast::GetInstArgs).to receive(:going_back) { going_back }
allow(Yast::Installation).to receive(:restarting?) { restarting }
stub_const("Yast::Storage", double("Yast::Storage", ReReadTargetMap: true))
end

context "when installation is restarting" do
let(:restarting) { true }
it "returns next" do
expect(Yast::Arch).to_not receive(:s390)

expect(subject.main).to eql(:next)
end
end

context "when architecture is s390" do
Expand Down
4 changes: 3 additions & 1 deletion test/inst_update_installer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
allow(Yast::Mode).to receive(:auto).and_return(false)
allow(Yast::NetworkService).to receive(:isNetworkRunning).and_return(network_running)
allow(::Installation::UpdatesManager).to receive(:new).and_return(manager)
allow(Yast::Installation).to receive(:restarting?)
allow(Yast::Installation).to receive(:restart!) { :restart_yast }

# stub the Profile module to avoid dependency on autoyast2-installation
ay_profile = double("Yast::Profile")
Expand Down Expand Up @@ -51,7 +53,7 @@
end

it "creates update file and returns :restart_yast" do
expect(::FileUtils).to receive(:touch).twice
expect(::FileUtils).to receive(:touch).once
allow(subject).to receive(:self_update_enabled?).and_return(true)
expect(subject.main).to eq(:restart_yast)
end
Expand Down

0 comments on commit 8c3552d

Please sign in to comment.