Skip to content

Commit

Permalink
Update installer is called earlier. Data store is not needed anymore. (
Browse files Browse the repository at this point in the history
…#59)

* Update installer is called earlier. Data store is not needed anymore.

* Bumped version and updated change log.
  • Loading branch information
teclator committed Aug 26, 2016
1 parent 195dd2a commit 351ecf0
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 72 deletions.
8 changes: 8 additions & 0 deletions package/yast2-update.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Fri Aug 26 08:54:40 UTC 2016 - kanderssen@suse.com

- The update installer has been moved earlier in the workflow. We
don't need to store data to remember selected target/partitions
anymore. (bsc#988287)
- 3.1.42

-------------------------------------------------------------------
Fri Aug 5 08:55:42 UTC 2016 - kanderssen@suse.com

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


Name: yast2-update
Version: 3.1.41
Version: 3.1.42
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
42 changes: 0 additions & 42 deletions src/lib/update/clients/inst_update_partition_auto.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ def main

Yast.include self, "update/rootpart.rb"

# In case of restarting after a installer update, we restore previous
# data if exists (bsc#988287)
load_data if Installation.restarting? && data_stored?

if RootPart.Mounted
log.debug("RootPart is mounted, detaching Update & unmounting partitions")
Update.Detach
Expand Down Expand Up @@ -80,53 +76,15 @@ def main
UmountMountedPartition()
Pkg.TargetFinish
else
store_data

return :next
end
end

@ret = RootPartitionDialog(:update_dialog)

store_data if @ret == :next

@ret
end

private

# @return [Boolean] true if dumped file data exists.
def data_stored?
::File.exist?(DATA_PATH)
end

# Save some important RootPart attributes into a yaml file.
def store_data
data = {
"activated" => RootPart.GetActivated,
"selected" => RootPart.selectedRootPartition,
"previous" => RootPart.previousRootPartition,
"partitions" => RootPart.rootPartitions
}

File.write(DATA_PATH, data.to_yaml)
end

# Loads RootPart data from a dump yaml file and delete the file after that.
# It also remember the current root selection as the target_system
def load_data
data = YAML.load(File.read(DATA_PATH))

log.debug("Loading data from dump file: #{data}")
RootPart.load_saved(data)

root_target = RootPart.selectedRootPartition || ""

@target_system = root_target unless root_target.empty?

::FileUtils.rm_rf(DATA_PATH)
end

# Obtains the target system from the install.inf file or use the current
# partitions if there is only 1 valid.
#
Expand Down
1 change: 0 additions & 1 deletion test/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ def stub_subject(subject)
allow(subject).to receive(:target_distribution).and_return("sle-12-x86_64")
allow(subject).to receive(:initialize_update_rootpart)
allow(subject).to receive(:load_data)
allow(subject).to receive(:store_data)
end
end
28 changes: 0 additions & 28 deletions test/inst_update_partition_auto_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@
describe Yast::InstUpdatePartitionAutoClient do

describe "#main" do
let(:restarting) { false }

before do
stub_root_part
stub_const("Yast::FileSystems", double)
allow(Yast::Update)
allow(Yast::Installation).to receive(:restarting?) { restarting }
allow(Yast::Installation).to receive(:destdir).and_return("/mnt")
allow(Yast::Report).to receive(:error)
allow(Yast::Pkg).to receive(:TargetInitializeOptions)
Expand All @@ -25,17 +22,6 @@
stub_subject(subject)
end

context "when installation is restarting" do
let(:restarting) { true }

it "loads data if it was stored" do
expect(subject).to receive(:data_stored?).and_return(true)
expect(subject).to receive(:load_data)

subject.main
end
end

context "when root partition is mounted" do
before do
allow(Yast::RootPart).to receive(:Mounted).and_return(true)
Expand Down Expand Up @@ -117,7 +103,6 @@
context "when the target system is mounted successfully" do
before do
allow(Yast::RootPart).to receive(:mount_target).and_return(true)
allow(subject).to receive(:store_data)
end

context "when it detects an incomplete installation" do
Expand Down Expand Up @@ -174,13 +159,6 @@
allow(Yast::Pkg).to receive(:TargetInitializeOptions).and_return(true)
end

it "saves current data" do
expect(subject).not_to receive(:RootPartitionDialog)
expect(subject).to receive(:store_data)

subject.main
end

it "returns :next without shown selection dialog" do
expect(subject).not_to receive(:RootPartitionDialog)

Expand All @@ -197,12 +175,6 @@
allow(subject).to receive(:target_system_candidate).and_return(nil)
end

it "stores current data" do
expect(subject).to receive(:store_data)

subject.main
end

it "returns :next" do
expect(subject.main).to eql(:next)
end
Expand Down

0 comments on commit 351ecf0

Please sign in to comment.