Skip to content

Commit

Permalink
Improved self-update to use some packages as an add-on (bsc#1101016) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Sep 18, 2018
1 parent f1d0b84 commit ff5cd97
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 18 deletions.
11 changes: 9 additions & 2 deletions doc/SELF_UPDATE.md
Expand Up @@ -31,9 +31,14 @@ These are the basic steps performed by YaST in order to perform the update:
containing the updates.
2. If updates are available, they will be downloaded. Otherwise, the process
will be silently skipped.
3. The updates will be applied to the installation system.
3. The updates will be applied to the installation system, the meta-packages
which are needed by the installer are copied to the inst-sys instead of
applying.
4. YaST will be restarted to reload the modified files and the installation
will be resumed.
5. The selected meta-packages copied to the inst-sys are added as an add-on
installation repository to allow updating the `skelcd-*` or `*-release`
packages via the self-update repository.

### Language Selection

Expand Down Expand Up @@ -67,7 +72,9 @@ for more details.
YaST will use RPM packages stored in a rpm-md repository, although they are
handled in a different way:

* All RPMs in the repository are considered (no "patch" metadata).
* All RPMs in the repository are considered (no "patch" metadata), only some
meta-packages are skipped (e.g. the packages providing `system-installation()`
or `product()`, it does not make sense to apply them to the inst-sys).
* RPMs are not installed in the usual way: they're uncompressed and no scripts
are executed.
* No dependency checks are performed. RPMs are added in alphabetical order.
Expand Down
8 changes: 8 additions & 0 deletions package/yast2-installation.changes
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Thu Sep 13 16:37:43 UTC 2018 - lslezak@suse.cz

- Copy the selected packages from the self-update repository to an
additional add-on repository, allow updating the installation
workflow from the self-update repository (bsc#1101016)
- 4.1.15

-------------------------------------------------------------------
Tue Sep 11 15:29:22 CEST 2018 - aschnell@suse.com

Expand Down
10 changes: 5 additions & 5 deletions package/yast2-installation.spec
Expand Up @@ -16,7 +16,7 @@
#

Name: yast2-installation
Version: 4.1.14
Version: 4.1.15
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down Expand Up @@ -46,8 +46,8 @@ BuildRequires: rubygem(yast-rake)
BuildRequires: yast2 >= 4.1.3
Requires: yast2 >= 4.1.3

# Yast::Packages.check_remote_installation_packages
BuildRequires: yast2-packager >= 4.0.9
# Y2Packager::SelfUpdateAddonRepo
BuildRequires: yast2-packager >= 4.1.5

# Y2Storage::Inhibitors including systemd masking
BuildRequires: yast2-storage-ng >= 4.0.194
Expand All @@ -63,8 +63,8 @@ Requires: yast2-pkg-bindings >= 3.1.33
# Mouse-related scripts moved to yast2-mouse
Conflicts: yast2-mouse < 2.18.0

# Yast::AddOnProduct.selected_installation_products
Requires: yast2-packager >= 4.0.56
# Y2Packager::SelfUpdateAddonRepo
Requires: yast2-packager >= 4.1.5

# use in startup scripts
Requires: initviocons
Expand Down
16 changes: 16 additions & 0 deletions src/lib/installation/clients/inst_update_installer.rb
Expand Up @@ -15,6 +15,7 @@

require "installation/updates_manager"
require "installation/update_repositories_finder"
require "y2packager/self_update_addon_repo"
require "uri"
require "yaml"

Expand Down Expand Up @@ -112,6 +113,10 @@ def update_installer
updated = update_repositories.map { |u| add_repository(u) }.any?

if updated
# copy the addon packages before applying the updates to inst-sys,
# #apply_all removes the repositories!
Yast::Progress.NextStage
copy_addon_packages
log.info("Applying installer updates")
Yast::Progress.NextStage
updates_manager.apply_all
Expand Down Expand Up @@ -387,6 +392,7 @@ def initialize_progress
# TRANSLATORS: progress label
_("Add Update Repository"),
_("Download the Packages"),
_("Copy the Addon Packages"),
_("Apply the Packages"),
_("Restart")
]
Expand Down Expand Up @@ -508,5 +514,15 @@ def process_location
log.info("Processing profile location...")
ProfileLocation.Process
end

#
# Copy the addon packages from the self-update repositories to the inst-sys
#
def copy_addon_packages
log.info("Copying optional addon packages from the self update repositories...")
updates_manager.repositories.each do |u|
::Y2Packager::SelfUpdateAddonRepo.copy_packages(u.repo_id)
end
end
end
end
19 changes: 12 additions & 7 deletions src/lib/installation/update_repository.rb
Expand Up @@ -18,6 +18,7 @@

require "packages/package_downloader"
require "packages/package_extractor"
require "y2packager/self_update_addon_filter"

Yast.import "Pkg"
Yast.import "Progress"
Expand Down Expand Up @@ -136,10 +137,11 @@ def repo_id
add_repo
end

# Retrieves the list of packages to install
# Retrieves the list of packages to unpack to the inst-sys
#
# Only packages in the update repository are considered. Packages are
# sorted by name (alphabetical order).
# Only packages in the update repository are considered, meta-packages
# which should be used in an add-on and not applied to the inst-sys are ignored.
# The packages are sorted by name (alphabetical order).
#
# @return [Array<Hash>] List of packages to install
#
Expand All @@ -149,7 +151,11 @@ def packages
add_repo
candidates = Yast::Pkg.ResolvableProperties("", :package, "")
@packages = candidates.select { |p| p["source"] == repo_id }.sort_by! { |a| a["name"] }
log.info "Considering #{@packages.size} packages: #{@packages}"
log.info "Found #{@packages.size} packages: #{@packages}"
# remove packages which are used as addons, these should not be applied to the inst-sys
addon_pkgs = Y2Packager::SelfUpdateAddonFilter.packages(repo_id)
@packages.reject! { |p| addon_pkgs.include?(p["name"]) }
log.info "Using #{@packages.size} packages: #{@packages}"
@packages
end

Expand Down Expand Up @@ -245,10 +251,9 @@ def cleanup
# Determine whether the repository is empty or not
#
# @return [Boolean] true if the repository is empty; false otherwise.
#
# @see #packages
def empty?
packages.empty?
candidates = Yast::Pkg.ResolvableProperties("", :package, "")
candidates.none? { |p| p["source"] == repo_id }
end

# Returns whether is a user defined repository
Expand Down
20 changes: 16 additions & 4 deletions test/inst_update_installer_test.rb
Expand Up @@ -14,7 +14,7 @@

let(:manager) do
double("update_manager", all_signed?: all_signed?, apply_all: true,
repositories?: has_repos)
repositories?: has_repos, repositories: repos)
end
let(:url) { "http://update.opensuse.org/\$arch/update.dud" }
let(:real_url) { "http://update.opensuse.org/#{arch}/update.dud" }
Expand All @@ -26,6 +26,8 @@
let(:all_signed?) { true }
let(:network_running) { true }
let(:has_repos) { true }
let(:repo) { double("repo", repo_id: 42) }
let(:repos) { [repo] }
let(:restarting) { false }
let(:profile) { {} }
let(:ay_profile) { double("Yast::Profile", current: profile) }
Expand All @@ -43,6 +45,7 @@
allow(subject).to receive(:require).with("registration/url_helpers").and_raise(LoadError)
stub_const("Registration::Storage::InstallationOptions", FakeInstallationOptions)
stub_const("Registration::Storage::Config", FakeRegConfig)
allow(Y2Packager::SelfUpdateAddonRepo).to receive(:copy_packages)

# skip the libzypp initialization globally, enable in the specific tests
allow(subject).to receive(:initialize_packager).and_return(true)
Expand Down Expand Up @@ -111,14 +114,22 @@

context "and update works" do
before do
allow(subject).to receive(:update_installer).and_return(true)
allow(subject).to receive(:self_update_enabled?).and_return(true)
allow(subject).to receive(:add_repository).and_return(true)
allow(manager).to receive(:apply_all)
allow(::FileUtils).to receive(:touch)
allow(Y2Packager::SelfUpdateAddonRepo).to receive(:copy_packages)
end

it "creates update file and returns :restart_yast" do
expect(::FileUtils).to receive(:touch).once
allow(subject).to receive(:self_update_enabled?).and_return(true)
expect(subject.main).to eq(:restart_yast)
end

it "copies the add-on packages from the self-update repository" do
expect(Y2Packager::SelfUpdateAddonRepo).to receive(:copy_packages)
.with(repo.repo_id)
subject.main
end
end

context "and update fails" do
Expand Down Expand Up @@ -154,6 +165,7 @@

context "when repository is empty" do
let(:has_repos) { false }
let(:repos) { [] }

it "does not restart YaST" do
expect(manager).to receive(:add_repository)
Expand Down

0 comments on commit ff5cd97

Please sign in to comment.