Skip to content

Commit

Permalink
Merge pull request #241 from yast/installer_extension
Browse files Browse the repository at this point in the history
Search for y2update.tgz also in the "installerextension()" package
  • Loading branch information
lslezak committed Mar 27, 2017
2 parents 2245ef4 + 6c2c499 commit 0ba3bd9
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 2 deletions.
7 changes: 7 additions & 0 deletions package/yast2-packager.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Fri Mar 24 16:17:23 UTC 2017 - lslezak@suse.cz

- Download the addon y2update.tgz file from a package referenced
by the "installerextension()" provides dependency (FATE#320772)
- 3.2.19

-------------------------------------------------------------------
Mon Mar 20 12:33:35 UTC 2017 - jreidinger@suse.com

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


Name: yast2-packager
Version: 3.2.18
Version: 3.2.19
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
27 changes: 26 additions & 1 deletion src/modules/AddOnProduct.rb
Expand Up @@ -595,13 +595,19 @@ def DoInstall_NoControlFile
end

def IntegrateY2Update(src_id)
# this works only with the SUSE tags repositories
binaries = GetCachedFileFromSource(
src_id, # optional
1,
"/y2update.tgz",
"digested",
true
)

# try the package containing the installer update, works with all repositories,
# including RPM-MD
binaries ||= y2update_path(src_id)

# File /y2update.tgz exists
if binaries != nil
# Try to extract files from the archive
Expand Down Expand Up @@ -1170,7 +1176,7 @@ def IntegrateReleaseNotes(repo_id)
def Integrate(srcid)
Builtins.y2milestone("Integrating repository %1", srcid)

# Updating inst-sys
# Updating inst-sys, this works only with the SUSE tags repositories
y2update = GetCachedFileFromSource(
srcid, # optional
1,
Expand All @@ -1179,6 +1185,10 @@ def Integrate(srcid)
true
)

# try the package containing the installer update, works with all repositories,
# including RPM-MD
y2update ||= y2update_path(srcid)

if y2update == nil
Builtins.y2milestone("No YaST update found on the media")
else
Expand Down Expand Up @@ -2404,6 +2414,21 @@ def parse_add_on_products_file(filename, type, base_url)
false
end
end

private

# Download the y2update from the addon package.
# @param src_id [Fixnum] repository ID
# @return [String,nil] full path to the `y2update.tgz` file or nil if not found
def y2update_path(src_id)
# fetch and extract the "installerextension" package
WorkflowManager.GetCachedWorkflowFilename(:addon, src_id, nil)
y2update = File.join(WorkflowManager.addon_control_dir(src_id), "y2update.tgz")
return nil unless File.exist?(y2update)

log.info("Found y2update.tgz file from the installer extension package: #{y2update}")
y2update
end
end

AddOnProduct = AddOnProductClass.new
Expand Down
46 changes: 46 additions & 0 deletions test/addon_product_test.rb
Expand Up @@ -419,4 +419,50 @@
end
end
end

describe "#Integrate" do
let(:src_id) { 3 }

before do
allow(subject).to receive(:GetCachedFileFromSource)
allow(subject).to receive(:HandleProductPATTERNS)
allow(subject).to receive(:IntegrateReleaseNotes)
allow(Yast::WorkflowManager).to receive(:GetCachedWorkflowFilename)
allow(Yast::WorkflowManager).to receive(:AddWorkflow)
end

it "updates the inst-sys with the y2update.tgz file from the installer extension package" do
expect(File).to receive(:exist?).with(/\/y2update\.tgz\z/).and_return(true)
expect(subject).to receive(:UpdateInstSys).with(/\/y2update\.tgz\z/)
subject.Integrate(src_id)
end

it "does not update inst-sys when y2update.tgz was not found in the installer extension package" do
expect(File).to receive(:exist?).with(/\/y2update\.tgz\z/).and_return(false)
expect(subject).to_not receive(:UpdateInstSys)
subject.Integrate(src_id)
end
end

describe "#IntegrateY2Update" do
let(:src_id) { 3 }

before do
allow(Yast::WorkflowManager).to receive(:GetCachedWorkflowFilename)
allow(subject).to receive(:GetCachedFileFromSource)
allow(subject).to receive(:RereadAllSCRAgents)
end

it "updates the inst-sys with the y2update.tgz file from the installer extension package" do
expect(File).to receive(:exist?).with(/\/y2update\.tgz\z/).and_return(true)
expect(Yast::SCR).to receive(:Execute).and_return("exit" => 0)
subject.IntegrateY2Update(src_id)
end

it "does not update inst-sys when y2update.tgz was not found in the installer extension package" do
expect(File).to receive(:exist?).with(/\/y2update\.tgz\z/).and_return(false)
expect(Yast::SCR).to_not receive(:Execute)
subject.IntegrateY2Update(src_id)
end
end
end

0 comments on commit 0ba3bd9

Please sign in to comment.