Skip to content

Commit

Permalink
Merge pull request #714 from yast/backport-fix_self_update_overwrite
Browse files Browse the repository at this point in the history
Backport Driver Updates precedence fix
  • Loading branch information
imobachgs committed Jun 6, 2018
2 parents 598194a + 44e6233 commit 70b2b3e
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 15 deletions.
7 changes: 7 additions & 0 deletions package/yast2-installation.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue Jun 5 09:29:50 UTC 2018 - igonzalezsosa@suse.com

- Installer Updates does not overwrite Driver Updates
(bsc#1088685).
- 3.2.57

-------------------------------------------------------------------
Thu May 31 10:17:19 UTC 2018 - jreidinger@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-installation.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-installation
Version: 3.2.56
Version: 3.2.57
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
20 changes: 14 additions & 6 deletions src/lib/installation/driver_update.rb
Expand Up @@ -55,8 +55,16 @@ class << self
def find(update_dirs)
dirs = Array(update_dirs)
log.info("Searching for Driver Updates at #{dirs.map(&:to_s)}")
globs = dirs.map { |d| d.join("dud_*") }
Pathname.glob(globs).map do |path|

# DUD as directories
duds_globs = dirs.map { |d| d.join("*", "dud.config") }
duds = Pathname.glob(duds_globs).map(&:dirname)

# DUD as files (squashfs filesystems)
archives_globs = dirs.map { |d| d.join("dud_*") }
archives = Pathname.glob(archives_globs)

(duds + archives).uniq.map do |path|
log.info("Found a Driver Update at #{path}")
new(path)
end
Expand Down Expand Up @@ -97,7 +105,7 @@ def apply
private

# LOSETUP command
LOSETUP_CMD = "/sbin/losetup".freeze
LOSETUP_CMD = "/sbin/losetup -j '%<file>s'".freeze

# Returns the instsys_path for updates of type :archive
#
Expand All @@ -106,10 +114,10 @@ def apply
#
# @return [Pathname] Update's mountpoint
def archive_instsys_path
out = Yast::SCR.Execute(Yast::Path.new(".target.bash_output"), LOSETUP_CMD)
cmd = format(LOSETUP_CMD, file: path.to_s)
out = Yast::SCR.Execute(Yast::Path.new(".target.bash_output"), cmd)
log.info("Reading loopback devices: #{out}")
regexp = %r{(/dev/loop\d+)[^\n]+#{path.to_s}\n}
lodevice = out["stdout"][regexp, 1]
lodevice = out["stdout"].split(":").first
mount = Yast::SCR.Read(Yast::Path.new(".proc.mounts")).find { |m| m["spec"] == lodevice }
if mount.nil?
log.warn("Driver Update at #{path} is not mounted")
Expand Down
38 changes: 30 additions & 8 deletions test/driver_update_test.rb
Expand Up @@ -9,16 +9,14 @@
describe Installation::DriverUpdate do
subject(:update) { Installation::DriverUpdate.new(update_path) }

let(:update_path) { FIXTURES_DIR.join("updates", "dud_000") }
let(:update_path) { FIXTURES_DIR.join("self-update", "update", "000") }
let(:losetup_content) do
"NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE\n" \
"/dev/loop5 0 0 0 0 /download/dud_000\n" \
"/dev/loop6 0 0 0 0 #{FIXTURES_DIR.join("updates", "dud_002")}\n"
"/dev/loop6: [0017]:63402 (#{update_path})\n"
end

before do
allow(Yast::SCR).to receive(:Execute)
.with(Yast::Path.new(".target.bash_output"), "/sbin/losetup")
.with(Yast::Path.new(".target.bash_output"), String)
.and_return("exit" => 0, "stdout" => losetup_content)
allow(Yast::SCR).to receive(:Read)
.with(Yast::Path.new(".proc.mounts"))
Expand All @@ -34,7 +32,9 @@

context "when updates exist" do
it "returns an array of driver updates" do
updates = described_class.find([FIXTURES_DIR.join("updates")])
updates = described_class.find(
[FIXTURES_DIR.join("self-update/update"), FIXTURES_DIR.join("self-update/download")]
)
expect(updates).to all(be_an(described_class))
expect(updates.size).to eq(3)
end
Expand All @@ -53,22 +53,44 @@

describe "#kind" do
context "when is a driver update disk" do
let(:update_path) { FIXTURES_DIR.join("updates", "dud_000") }
let(:update_path) { FIXTURES_DIR.join("self-update", "update", "000") }

it "returns :dud" do
expect(update.kind).to eq(:dud)
end
end

context "when is an archive" do
let(:update_path) { FIXTURES_DIR.join("updates", "dud_002") }
let(:update_path) { FIXTURES_DIR.join("self-update", "download", "dud_0000") }

it "returns :archive" do
expect(update.kind).to eq(:archive)
end
end
end

describe "#instsys_path" do
context "when is a driver update disk" do
let(:update_path) { FIXTURES_DIR.join("self-update", "update", "000") }

it "returns the path to the 'inst-sys' directory within the update" do
expect(update.instsys_path)
.to eq(FIXTURES_DIR.join("self-update", "update", "000", "inst-sys"))
end
end

context "when is an archive" do
let(:update_path) { FIXTURES_DIR.join("self-update", "download", "dud_0000") }

it "returns the path where the DUD is mounted on" do
expect(Yast::SCR).to receive(:Execute)
.with(Yast::Path.new(".target.bash_output"), "/sbin/losetup -j '#{update_path}'")
.and_return("exit" => 0, "stdout" => losetup_content)
expect(update.instsys_path).to eq(Pathname.new("/mounts/mp_0005"))
end
end
end

describe "#path" do
it "returns the path where the DUD is located" do
expect(update.path).to eq(update_path)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 70b2b3e

Please sign in to comment.