Hello community,
here is the log from the commit of package yast2-installation for
openSUSE:Factory checked in at 2017-03-29 13:23:24
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-installation (Old)
and /work/SRC/openSUSE:Factory/.yast2-installation.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-installation"
Wed Mar 29 13:23:24 2017 rev:383 rq:483199 version:3.2.34
Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-installation/yast2-installation.changes
2017-03-21 22:47:34.975460677 +0100
+++
/work/SRC/openSUSE:Factory/.yast2-installation.new/yast2-installation.changes
2017-03-29 13:23:26.933977897 +0200
@@ -1,0 +2,20 @@
+Mon Mar 27 13:39:38 UTC 2017 - [email protected]
+
+- Move CaaSP specific code to yast2-caasp (bsc#1030874)
+- 3.2.34
+
+-------------------------------------------------------------------
+Mon Mar 27 06:50:29 UTC 2017 - [email protected]
+
+- Use the shared package download and extraction functionality
+ from FATE#320772
+- 3.2.33
+
+-------------------------------------------------------------------
+Tue Mar 21 11:59:26 UTC 2017 - [email protected]
+
+- Added some extra space to the openSUSE desktop/roles selection
+ dialog (improvement on the fix for poo#14936, bsc#1025415).
+- 3.2.32
+
+-------------------------------------------------------------------
Old:
----
yast2-installation-3.2.31.tar.bz2
New:
----
yast2-installation-3.2.34.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ yast2-installation.spec ++++++
--- /var/tmp/diff_new_pack.ME5SXD/_old 2017-03-29 13:23:28.325781061 +0200
+++ /var/tmp/diff_new_pack.ME5SXD/_new 2017-03-29 13:23:28.329780495 +0200
@@ -17,7 +17,7 @@
Name: yast2-installation
-Version: 3.2.31
+Version: 3.2.34
Release: 0
BuildRoot: %{_tmppath}/%{name}-%{version}-build
@@ -40,14 +40,14 @@
BuildRequires: rubygem(rspec)
BuildRequires: rubygem(yast-rake)
-# ProductControl.system_roles
-BuildRequires: yast2 >= 3.2.15
+# CWM::RadioButtons#vspacing
+BuildRequires: yast2 >= 3.2.20
# AutoinstSoftware.SavePackageSelection()
Requires: autoyast2-installation >= 3.1.105
-# ProductControl.system_roles
-Requires: yast2 >= 3.2.15
+# PackageDownloader and PackageExtractor
+Requires: yast2 >= 3.2.19
# Language::GetLanguageItems and other API
# Language::Set (handles downloading the translation extensions)
++++++ yast2-installation-3.2.31.tar.bz2 -> yast2-installation-3.2.34.tar.bz2
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-installation-3.2.31/doc/system-role-handlers.md
new/yast2-installation-3.2.34/doc/system-role-handlers.md
--- old/yast2-installation-3.2.31/doc/system-role-handlers.md 1970-01-01
01:00:00.000000000 +0100
+++ new/yast2-installation-3.2.34/doc/system-role-handlers.md 2017-03-28
23:05:44.325840292 +0200
@@ -0,0 +1,42 @@
+# System Role Handlers
+
+This is a mechanism that allows to execute specific code depending on the
system
+role selected during the installation which was introduced in version 3.2.21
+(originally in 3.1.217.20 in the `SLE-12-SP2-CASP` branch).
+
+If you prefer, you could think of them as *hooks for system roles*.
+
+## Types of handlers
+
+Currently only one type of handlers exist: `finish`. Those handlers will be
+executed through the
+[roles_finish](https://github.com/yast/yast-installation/blob/master/src/lib/installation/clients/roles_finish.rb)
+
+## Defining a new handler
+
+Handlers are just plain classes which implement a `run` method and live in the
+`lib/y2system_role_handlers`. The name of the file/class depends on the type of
+handler they implement.
+
+For instance, if you want to define a *finish* handler for an *ExampleRole*
role,
+just drop a file like this into `lib/y2system_role_handlers`.
+
+```ruby
+module Y2SystemRoleHandlers
+ class ExampleRoleFinish
+ def run
+ # Handler implementation goes here
+ end
+ end
+end
+
+```
+
+The `run` method won't receive any argument and is also not expected to return
+any special value. Finally, exceptions will be handled like any other YaST
+exception.
+
+## Examples
+
+Please, check out the [yast2-caasp package](https://github.com/yast/yast-caasp)
+for examples.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-installation-3.2.31/package/yast2-installation.changes
new/yast2-installation-3.2.34/package/yast2-installation.changes
--- old/yast2-installation-3.2.31/package/yast2-installation.changes
2017-03-20 15:24:58.037124529 +0100
+++ new/yast2-installation-3.2.34/package/yast2-installation.changes
2017-03-28 23:05:44.333840292 +0200
@@ -1,4 +1,24 @@
-------------------------------------------------------------------
+Mon Mar 27 13:39:38 UTC 2017 - [email protected]
+
+- Move CaaSP specific code to yast2-caasp (bsc#1030874)
+- 3.2.34
+
+-------------------------------------------------------------------
+Mon Mar 27 06:50:29 UTC 2017 - [email protected]
+
+- Use the shared package download and extraction functionality
+ from FATE#320772
+- 3.2.33
+
+-------------------------------------------------------------------
+Tue Mar 21 11:59:26 UTC 2017 - [email protected]
+
+- Added some extra space to the openSUSE desktop/roles selection
+ dialog (improvement on the fix for poo#14936, bsc#1025415).
+- 3.2.32
+
+-------------------------------------------------------------------
Thu Mar 16 13:07:44 UTC 2017 - [email protected]
- Allow proceeding with the installation after a blocking condition
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-installation-3.2.31/package/yast2-installation.spec
new/yast2-installation-3.2.34/package/yast2-installation.spec
--- old/yast2-installation-3.2.31/package/yast2-installation.spec
2017-03-20 15:24:58.037124529 +0100
+++ new/yast2-installation-3.2.34/package/yast2-installation.spec
2017-03-28 23:05:44.333840292 +0200
@@ -17,7 +17,7 @@
Name: yast2-installation
-Version: 3.2.31
+Version: 3.2.34
Release: 0
BuildRoot: %{_tmppath}/%{name}-%{version}-build
@@ -40,14 +40,14 @@
BuildRequires: rubygem(rspec)
BuildRequires: rubygem(yast-rake)
-# ProductControl.system_roles
-BuildRequires: yast2 >= 3.2.15
+# CWM::RadioButtons#vspacing
+BuildRequires: yast2 >= 3.2.20
# AutoinstSoftware.SavePackageSelection()
Requires: autoyast2-installation >= 3.1.105
-# ProductControl.system_roles
-Requires: yast2 >= 3.2.15
+# PackageDownloader and PackageExtractor
+Requires: yast2 >= 3.2.19
# Language::GetLanguageItems and other API
# Language::Set (handles downloading the translation extensions)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-installation-3.2.31/src/lib/installation/cfa/salt.rb
new/yast2-installation-3.2.34/src/lib/installation/cfa/salt.rb
--- old/yast2-installation-3.2.31/src/lib/installation/cfa/salt.rb
2017-03-20 15:24:58.125124529 +0100
+++ new/yast2-installation-3.2.34/src/lib/installation/cfa/salt.rb
1970-01-01 01:00:00.000000000 +0100
@@ -1,28 +0,0 @@
-require "cfa/base_model"
-require "cfa/augeas_parser"
-require "cfa/matcher"
-
-module Installation
- module CFA
- # Represents a Salt Minion master configuration file.
- class MinionMasterConf < ::CFA::BaseModel
- attributes(master: "master")
-
- # Configuration parser
- #
- # FIXME: At this time, we're using Augeas' cobblersettings lense because,
- # although the file is in yaml format, it doesn't have a YAML header
- # which is required by the yaml lense.
- PARSER = ::CFA::AugeasParser.new("cobblersettings.lns")
- # Path to configuration file
- PATH = "/etc/salt/minion.d/master.conf".freeze
-
- # Constructor
- #
- # @param file_handler [.read, .write, nil] an object able to read/write
a string.
- def initialize(file_handler: nil)
- super(PARSER, PATH, file_handler: file_handler)
- end
- end
- end
-end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-installation-3.2.31/src/lib/installation/system_role.rb
new/yast2-installation-3.2.34/src/lib/installation/system_role.rb
--- old/yast2-installation-3.2.31/src/lib/installation/system_role.rb
2017-03-20 15:24:58.173124529 +0100
+++ new/yast2-installation-3.2.34/src/lib/installation/system_role.rb
2017-03-28 23:05:44.357840292 +0200
@@ -21,7 +21,7 @@
require "yast"
require "installation/services"
-require "installation/system_roles/handlers"
+require "installation/system_role_handlers_runner"
Yast.import "ProductControl"
Yast.import "ProductFeatures"
@@ -165,15 +165,7 @@
log.info("There is no role selected so nothing to do")
return
end
-
- class_name_role = current.split("_").map(&:capitalize).join
- handler =
"::Installation::SystemRoleHandlers::#{class_name_role}Finish"
-
- if Object.const_defined?(handler)
- Object.const_get(handler).run
- else
- log.info("There is no special finisher for #{current}")
- end
+ SystemRoleHandlersRunner.new.finish(current)
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-installation-3.2.31/src/lib/installation/system_role_handlers_runner.rb
new/yast2-installation-3.2.34/src/lib/installation/system_role_handlers_runner.rb
---
old/yast2-installation-3.2.31/src/lib/installation/system_role_handlers_runner.rb
1970-01-01 01:00:00.000000000 +0100
+++
new/yast2-installation-3.2.34/src/lib/installation/system_role_handlers_runner.rb
2017-03-28 23:05:44.357840292 +0200
@@ -0,0 +1,61 @@
+# encoding: utf-8
+
+#
------------------------------------------------------------------------------
+# Copyright (c) 2017 SUSE LLC
+#
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of version 2 of the GNU General Public License as published by the
+# Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, contact SUSE.
+#
+# To contact SUSE about this file by physical or electronic mail, you may find
+# current contact information at www.suse.com.
+#
------------------------------------------------------------------------------
+
+require "yast"
+
+module Installation
+ # Run system roles handlers
+ #
+ # System role handlers are a mechanism to execute code depending on the
+ # selected role. Currently those handlers are only used in the inst_finish
+ # client, but they could be extended in the future.
+ class SystemRoleHandlersRunner
+ include Yast::Logger
+
+ # Run the finish handler for a given role
+ def finish(role_id)
+ return unless require_handler(role_id)
+
+ class_name_role = role_id.split("_").map(&:capitalize).join
+ handler = "Y2SystemRoleHandlers::#{class_name_role}Finish"
+
+ if Object.const_defined?(handler)
+ Object.const_get(handler).new.run
+ else
+ log.info("There is no special finisher for #{role_id}
('#{class_name_role}' not defined)")
+ end
+ end
+
+ private
+
+ # Try to require the file where a handler is supposed to be defined
+ #
+ # @return [Boolean] True if the file was loaded; false otherwise.
+ def require_handler(role_id)
+ filename = "y2system_role_handlers/#{role_id}_finish"
+ require filename
+ true
+ rescue LoadError
+ log.info("There is no special finisher for #{role_id} ('#{filename}' not
found)")
+ false
+ end
+ end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-installation-3.2.31/src/lib/installation/system_roles/handlers.rb
new/yast2-installation-3.2.34/src/lib/installation/system_roles/handlers.rb
--- old/yast2-installation-3.2.31/src/lib/installation/system_roles/handlers.rb
2017-03-20 15:24:58.173124529 +0100
+++ new/yast2-installation-3.2.34/src/lib/installation/system_roles/handlers.rb
1970-01-01 01:00:00.000000000 +0100
@@ -1,48 +0,0 @@
-# encoding: utf-8
-
-#
------------------------------------------------------------------------------
-# Copyright (c) 2017 SUSE LLC
-#
-#
-# This program is free software; you can redistribute it and/or modify it under
-# the terms of version 2 of the GNU General Public License as published by the
-# Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, contact SUSE.
-#
-# To contact SUSE about this file by physical or electronic mail, you may find
-# current contact information at www.suse.com.
-#
------------------------------------------------------------------------------
-
-require "yast"
-require "installation/cfa/salt"
-
-module Installation
- module SystemRoleHandlers
- class WorkerRoleFinish
- include Yast::Logger
-
- def self.run
- role = SystemRole.find("worker_role")
- master_conf = CFA::MinionMasterConf.new
- master = role["controller_node"]
- begin
- master_conf.load
- rescue Errno::ENOENT
- log.info("The minion master.conf file does not exist, it will be
created")
- end
- log.info("The controller node for this worker role is: #{master}")
- # FIXME: the cobblersettings lense does not support dashes in the url
- # without single quotes, we need to use a custom lense for salt conf.
- # As Salt can use also 'url' just use in case of dashed.
- master_conf.master = master.include?("-") ? "'#{master}'" : master
- master_conf.save
- end
- end
- end
-end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-installation-3.2.31/src/lib/installation/update_repository.rb
new/yast2-installation-3.2.34/src/lib/installation/update_repository.rb
--- old/yast2-installation-3.2.31/src/lib/installation/update_repository.rb
2017-03-20 15:24:58.173124529 +0100
+++ new/yast2-installation-3.2.34/src/lib/installation/update_repository.rb
2017-03-28 23:05:44.357840292 +0200
@@ -16,6 +16,9 @@
require "pathname"
require "fileutils"
+require "packages/package_downloader"
+require "packages/package_extractor"
+
Yast.import "Pkg"
Yast.import "Progress"
Yast.import "URL"
@@ -177,7 +180,9 @@
update_progress(100 * index / packages.size)
files << fetch_package(package, path)
end
- rescue PackageNotFound, CouldNotExtractPackage, CouldNotSquashPackage => e
+ rescue Packages::PackageDownloader::FetchError,
Packages::PackageExtractor::ExtractionFailed,
+ CouldNotSquashPackage => e
+
log.error("Could not fetch update: #{e.inspect}. Rolling back.")
remove_update_files
raise CouldNotFetchUpdate
@@ -287,36 +292,18 @@
tempfile = Tempfile.new(package["name"])
tempfile.close
Dir.mktmpdir do |workdir|
- log.info("Trying to get #{package["name"]} from repo #{repo_id}")
- if !Yast::Pkg.ProvidePackage(repo_id, package["name"],
tempfile.path.to_s)
- log.error("Package #{package} could not be retrieved.")
- raise PackageNotFound
- end
- extract(tempfile, workdir)
+ downloader = Packages::PackageDownloader.new(repo_id, package["name"])
+ downloader.download(tempfile.path.to_s)
+
+ extractor = Packages::PackageExtractor.new(tempfile.path.to_s)
+ extractor.extract(workdir)
+
build_squashfs(workdir, next_name(dir, length: 3))
end
ensure
tempfile.unlink
end
- # Command to extract an RPM which is part of an update
- EXTRACT_CMD = "rpm2cpio %<source>s | cpio --quiet --sparse -dimu
--no-absolute-filenames".freeze
-
- # Extract a RPM contents to a given directory
- #
- # @param package_file [File] RPM package (local file name)
- # @param dir [Pathname] Directory to extract the RPM contents
- #
- # @raise CouldNotExtractPackage
- def extract(package_file, dir)
- Dir.chdir(dir) do
- cmd = format(EXTRACT_CMD, source: package_file.path)
- out = Yast::SCR.Execute(Yast::Path.new(".target.bash_output"), cmd)
- log.info("Extracting package #{package_file.inspect}: #{out}")
- raise CouldNotExtractPackage unless out["exit"].zero?
- end
- end
-
# Command to build an squashfs filesystem containing all updates
SQUASH_CMD = "mksquashfs %<dir>s %<file>s -noappend -no-progress".freeze
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-installation-3.2.31/src/lib/installation/widgets/system_role.rb
new/yast2-installation-3.2.34/src/lib/installation/widgets/system_role.rb
--- old/yast2-installation-3.2.31/src/lib/installation/widgets/system_role.rb
2017-03-20 15:24:58.173124529 +0100
+++ new/yast2-installation-3.2.34/src/lib/installation/widgets/system_role.rb
2017-03-28 23:05:44.357840292 +0200
@@ -177,6 +177,10 @@
Yast::DefaultDesktop.ForceReinit
end
end
+
+ def vspacing
+ 1
+ end
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-installation-3.2.31/test/fixtures/minion.d/master.conf_existent
new/yast2-installation-3.2.34/test/fixtures/minion.d/master.conf_existent
--- old/yast2-installation-3.2.31/test/fixtures/minion.d/master.conf_existent
2017-03-20 15:24:58.189124529 +0100
+++ new/yast2-installation-3.2.34/test/fixtures/minion.d/master.conf_existent
1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-master: previous_controller
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-installation-3.2.31/test/fixtures/minion.d/master.conf_expected
new/yast2-installation-3.2.34/test/fixtures/minion.d/master.conf_expected
--- old/yast2-installation-3.2.31/test/fixtures/minion.d/master.conf_expected
2017-03-20 15:24:58.189124529 +0100
+++ new/yast2-installation-3.2.34/test/fixtures/minion.d/master.conf_expected
1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-master: salt_controller
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-installation-3.2.31/test/lib/system_role_handlers_runner_test.rb
new/yast2-installation-3.2.34/test/lib/system_role_handlers_runner_test.rb
--- old/yast2-installation-3.2.31/test/lib/system_role_handlers_runner_test.rb
1970-01-01 01:00:00.000000000 +0100
+++ new/yast2-installation-3.2.34/test/lib/system_role_handlers_runner_test.rb
2017-03-28 23:05:44.373840292 +0200
@@ -0,0 +1,46 @@
+#!/usr/bin/env rspec
+
+require_relative "../test_helper"
+require "installation/system_role_handlers_runner"
+
+describe Installation::SystemRoleHandlersRunner do
+ subject(:runner) { Installation::SystemRoleHandlersRunner.new }
+
+ describe "#finish" do
+ let(:handler_class) { double("HandlerClass") }
+ let(:handler) { double("HandlerInstance") }
+
+ before do
+ stub_const("Y2SystemRoleHandlers::TestRoleFinish", handler_class)
+ allow(handler_class).to receive(:new).and_return(handler)
+ allow(runner).to
receive(:require).with("y2system_role_handlers/test_role_finish")
+ end
+
+ it "runs the handler's 'run' method" do
+ expect(handler).to receive(:run)
+ runner.finish("test_role")
+ end
+
+ context "when handler file is not found" do
+ before do
+ allow(runner).to receive(:require).and_call_original
+ end
+
+ it "logs the error" do
+ expect(runner.log).to receive(:info).with(/not found/)
+ runner.finish("unknown_role")
+ end
+ end
+
+ context "when handler class is not defined" do
+ before do
+ allow(runner).to
receive(:require).with("y2system_role_handlers/undefined_role_finish")
+ end
+
+ it "logs the error" do
+ expect(runner.log).to receive(:info).with(/not defined/)
+ runner.finish("undefined_role")
+ end
+ end
+ end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-installation-3.2.31/test/system_role_handlers_test.rb
new/yast2-installation-3.2.34/test/system_role_handlers_test.rb
--- old/yast2-installation-3.2.31/test/system_role_handlers_test.rb
2017-03-20 15:24:58.193124529 +0100
+++ new/yast2-installation-3.2.34/test/system_role_handlers_test.rb
1970-01-01 01:00:00.000000000 +0100
@@ -1,45 +0,0 @@
-#! /usr/bin/env rspec
-
-require_relative "./test_helper"
-require "installation/system_role"
-require "installation/system_roles/handlers"
-
-describe Installation::SystemRoleHandlers::WorkerRoleFinish do
- let(:role) { instance_double("::Installation::SystemRole") }
- let(:conf) do
- instance_double("::Installation::CFA::MinionMasterConf", load: true, save:
true)
- end
-
- before do
- allow(::Installation::SystemRole).to receive("find")
- .with("worker_role").and_return(role)
- allow(::Installation::CFA::MinionMasterConf).to
receive(:new).and_return(conf)
- end
-
- describe ".run" do
- context "if the worker role controller node location contains dashes" do
- it "surrounds the url with single quotes before save" do
- expect(role).to
receive(:[]).with("controller_node").and_return("controller-url")
- expect(conf).to receive(:master=).with("'controller-url'")
- described_class.run
- end
-
- end
-
- context "if the worker role controller node location does not contain
dashes" do
- it "saves the url as defined" do
- expect(role).to
receive(:[]).with("controller_node").and_return("controller")
- expect(conf).to receive(:master=).with("controller")
- described_class.run
- end
- end
-
- it "saves the controller node location into the minion master.conf file" do
- expect(role).to
receive(:[]).with("controller_node").and_return("controller")
- expect(conf).to receive(:master=).with("controller")
- expect(conf).to receive(:save)
-
- described_class.run
- end
- end
-end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/yast2-installation-3.2.31/test/update_repository_test.rb
new/yast2-installation-3.2.34/test/update_repository_test.rb
--- old/yast2-installation-3.2.31/test/update_repository_test.rb
2017-03-20 15:24:58.193124529 +0100
+++ new/yast2-installation-3.2.34/test/update_repository_test.rb
2017-03-28 23:05:44.377840292 +0200
@@ -110,25 +110,25 @@
let(:libzypp_package_path) { "/var/adm/tmp/pkg1-3.1.x86_64.rpm" }
let(:package_path) { "/var/adm/tmp/pkg1-3.1.x86_64.rpm" }
let(:tempfile) { double("tempfile", close: true, path: package_path,
unlink: true) }
+ let(:downloader) { double("Packages::PackageDownloader", download: nil) }
+ let(:extractor) { double("Packages::PackageExtractor", extract: nil) }
before do
allow(repo).to receive(:add_repo).and_return(repo_id)
allow(repo).to receive(:packages).and_return([package])
allow(Dir).to receive(:mktmpdir).and_yield(tmpdir.to_s)
+ allow(Packages::PackageDownloader).to receive(:new).with(repo_id,
package["name"]).and_return(downloader)
+ allow(Packages::PackageExtractor).to
receive(:new).with(tempfile.path.to_s).and_return(extractor)
+ allow(Tempfile).to receive(:new).and_return(tempfile)
end
it "builds one squashed filesystem by package" do
- allow(Tempfile).to receive(:new).and_return(tempfile)
-
# Download
- expect(Yast::Pkg).to receive(:ProvidePackage)
- .with(repo_id, package["name"], tempfile.path.to_s)
- .and_return(true)
+ expect(downloader).to receive(:download).with(tempfile.path.to_s)
# Extract
- expect(Yast::SCR).to receive(:Execute)
- .with(Yast::Path.new(".target.bash_output"),
/rpm2cpio.*#{package_path}/)
- .and_return("exit" => 0, "stdout" => "", "stderr" => "")
+ expect(extractor).to receive(:extract).with(tmpdir.to_s)
+
# Squash
expect(Yast::SCR).to receive(:Execute)
.with(Yast::Path.new(".target.bash_output"), /mksquashfs.+#{tmpdir}
.+\/yast_000/)
@@ -139,7 +139,7 @@
context "when a package can't be retrieved" do
before do
- allow(Yast::Pkg).to receive(:ProvidePackage).and_return(nil)
+ expect(downloader).to
receive(:download).and_raise(Packages::PackageDownloader::FetchError)
end
it "clear downloaded files and raises a CouldNotFetchUpdate error" do
@@ -151,10 +151,7 @@
context "when a package can't be extracted" do
it "clear downloaded files and raises a CouldNotFetchUpdate error" do
- allow(Yast::Pkg).to
receive(:ProvidePackage).and_return(libzypp_package_path)
- allow(Yast::SCR).to receive(:Execute)
- .with(Yast::Path.new(".target.bash_output"), /rpm2cpio/)
- .and_return("exit" => 1, "stdout" => "", "stderr" => "")
+ expect(extractor).to
receive(:extract).and_raise(Packages::PackageExtractor::ExtractionFailed)
expect(repo).to receive(:remove_update_files)
expect { repo.fetch(download_path) }
@@ -164,8 +161,6 @@
context "when a package can't be squashed" do
it "clear downloaded files and raises a CouldNotFetchUpdate error" do
- allow(Yast::Pkg).to
receive(:ProvidePackage).and_return(libzypp_package_path)
- allow(Yast::SCR).to receive(:Execute).and_return("exit" => 0)
allow(Yast::SCR).to receive(:Execute)
.with(Yast::Path.new(".target.bash_output"), /mksquash/)
.and_return("exit" => 1, "stdout" => "", "stderr" => "")