Skip to content

Commit

Permalink
Self-update control file (#839)
Browse files Browse the repository at this point in the history
* Update control file during self-update
* Bump version and update changes file
  • Loading branch information
imobachgs committed Feb 20, 2020
1 parent d8a4a38 commit b89ffa3
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
7 changes: 7 additions & 0 deletions package/yast2-installation.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu Feb 20 11:24:41 UTC 2020 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

- Allow to modify the control file at installation time using a
skelcd-* package (bsc#1164468).
- 4.2.33

-------------------------------------------------------------------
Wed Feb 19 09:40:45 UTC 2020 - Steffen Winterfeldt <snwint@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 @@ -16,7 +16,7 @@
#

Name: yast2-installation
Version: 4.2.32
Version: 4.2.33
Release: 0
Group: System/YaST
License: GPL-2.0-only
Expand Down
14 changes: 14 additions & 0 deletions src/lib/installation/updates_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
require "pathname"
require "installation/driver_update"
require "installation/update_repository"
require "yast2/execute"

module Installation
# This class takes care of managing installer updates
Expand Down Expand Up @@ -110,14 +111,27 @@ def add_repository(uri)
# @see Installation::UpdateRepository#apply
# @see Installation::DriverUpdate#apply
# @see #repositories
# @raise CouldNotUpdateControlFile
def apply_all
(repositories + driver_updates).each(&:apply)
repositories.each(&:cleanup)
replace_control_file
end

# Determines whether the manager has repositories with updates
def repositories?
!repositories.empty?
end

private

NEW_CONTROL_FILE_PATH = "/usr/lib/skelcd/CD1/control.xml".freeze

# Replaces the control file with the updated one (if it exists)
def replace_control_file
return unless File.exist?(NEW_CONTROL_FILE_PATH)
log.info("Updating control.xml file in inst-sys")
Yast::Execute.locally!("/sbin/adddir", File.dirname(NEW_CONTROL_FILE_PATH), "/")
end
end
end
20 changes: 20 additions & 0 deletions test/updates_manager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,12 @@
end

describe "#apply_all" do
let(:new_control_file?) { false }

before do
allow(manager).to receive(:repositories).and_return([repo0, repo1])
allow(File).to receive(:exist?).with("/usr/lib/skelcd/CD1/control.xml")
.and_return(new_control_file?)
end

it "applies all the updates" do
Expand All @@ -124,6 +128,22 @@
manager.apply_all
end
end

context "when a new control file is available" do
let(:new_control_file?) { true }

it "updates the control file" do
expect(Yast::Execute).to receive(:locally!)
.with("/sbin/adddir", "/usr/lib/skelcd/CD1", "/")
manager.apply_all
end
end

it "does not replace the control file" do
expect(Yast::Execute).to_not receive(:locally!)
.with("/sbin/adddir", /skelcd/, "/")
manager.apply_all
end
end

describe "#repositories?" do
Expand Down

0 comments on commit b89ffa3

Please sign in to comment.