From 76abd3e0b8479d339d15e394abdab45b07acd342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ladislav=20Slez=C3=A1k?= Date: Fri, 27 Oct 2023 16:17:25 +0200 Subject: [PATCH] Refresh repositories with changed URL and reload them again ...to activate the changes (related to bsc#1215884) - 4.5.18 --- package/yast2-installation.changes | 6 ++++++ package/yast2-installation.spec | 2 +- src/lib/installation/clients/inst_upgrade_urls.rb | 4 ++++ src/lib/installation/upgrade_repo_manager.rb | 9 +++++++++ test/lib/clients/inst_upgrade_urls_test.rb | 2 ++ test/lib/upgrade_repo_manager_test.rb | 4 ++++ 6 files changed, 26 insertions(+), 1 deletion(-) diff --git a/package/yast2-installation.changes b/package/yast2-installation.changes index 658e7c27c..3e43e7d98 100644 --- a/package/yast2-installation.changes +++ b/package/yast2-installation.changes @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Fri Oct 27 14:13:14 UTC 2023 - Ladislav Slezák + +- Refresh repositories with changed URL and reload them again + to activate the changes (related to bsc#1215884) +- 4.5.18 + ------------------------------------------------------------------- Thu Jun 15 15:01:13 UTC 2023 - Stefan Hundhammer diff --git a/package/yast2-installation.spec b/package/yast2-installation.spec index d92e95c53..9b59eb92e 100644 --- a/package/yast2-installation.spec +++ b/package/yast2-installation.spec @@ -16,7 +16,7 @@ # Name: yast2-installation -Version: 4.5.17 +Version: 4.5.18 Release: 0 Summary: YaST2 - Installation Parts License: GPL-2.0-only diff --git a/src/lib/installation/clients/inst_upgrade_urls.rb b/src/lib/installation/clients/inst_upgrade_urls.rb index 5dd2a9552..14dbe12cf 100644 --- a/src/lib/installation/clients/inst_upgrade_urls.rb +++ b/src/lib/installation/clients/inst_upgrade_urls.rb @@ -19,6 +19,7 @@ require "yast" require "installation/upgrade_repo_manager" +require "y2packager/medium_type" require "y2packager/repository" Yast.import "GetInstArgs" @@ -297,6 +298,9 @@ def save_pkg_mgr # do not save the changes in the test mode Pkg.SourceSaveAll unless test? + # reload repositories only when using the openSUSE Leap media + Pkg.SourceLoad if Y2Packager::MediumType.standard? + # clear the old repositories Y2Packager::OriginalRepositorySetup.instance.repositories.clear end diff --git a/src/lib/installation/upgrade_repo_manager.rb b/src/lib/installation/upgrade_repo_manager.rb index aa7bf8c1c..6496bd7da 100644 --- a/src/lib/installation/upgrade_repo_manager.rb +++ b/src/lib/installation/upgrade_repo_manager.rb @@ -125,6 +125,12 @@ def activate_changes update_urls process_repos remove_services + + # reload the package manager to activate the changes + Yast::Pkg.SourceSaveAll + Yast::Pkg.SourceFinishAll + Yast::Pkg.SourceRestore + Yast::Pkg.SourceLoad end private @@ -167,6 +173,9 @@ def process_repos def update_urls new_urls.each do |repo, url| repo.url = url + + # if the repository will be enabled refresh the content + Yast::Pkg.SourceForceRefreshNow(repo.repo_id) if status_map[repo] == :enabled end end diff --git a/test/lib/clients/inst_upgrade_urls_test.rb b/test/lib/clients/inst_upgrade_urls_test.rb index 39e7ac765..32f505662 100755 --- a/test/lib/clients/inst_upgrade_urls_test.rb +++ b/test/lib/clients/inst_upgrade_urls_test.rb @@ -36,6 +36,8 @@ allow(Yast::UI).to receive(:QueryWidget) allow(Yast::UI).to receive(:ChangeWidget) allow(Yast::Pkg).to receive(:SourceSaveAll) + allow(Y2Packager::MediumType).to receive(:standard?).and_return(true) + allow(Yast::Pkg).to receive(:SourceLoad) end describe "#main" do diff --git a/test/lib/upgrade_repo_manager_test.rb b/test/lib/upgrade_repo_manager_test.rb index aa423242b..c47329caa 100755 --- a/test/lib/upgrade_repo_manager_test.rb +++ b/test/lib/upgrade_repo_manager_test.rb @@ -97,6 +97,10 @@ def self.is_registered? allow(repo1).to receive(:disable!) allow(repo1).to receive(:delete!) allow(Yast::Pkg).to receive(:ServiceDelete) + allow(Yast::Pkg).to receive(:SourceSaveAll) + allow(Yast::Pkg).to receive(:SourceFinishAll) + allow(Yast::Pkg).to receive(:SourceRestore) + allow(Yast::Pkg).to receive(:SourceLoad) end it "removes the selected repositories" do