diff --git a/service/lib/agama/software/manager.rb b/service/lib/agama/software/manager.rb index ba3881b7fc..1414ecc0d8 100644 --- a/service/lib/agama/software/manager.rb +++ b/service/lib/agama/software/manager.rb @@ -201,10 +201,16 @@ def install # Writes the repositories information to the installed system def finish + # remove the dir:///run/initramfs/live/install repository and similar + remove_local_repos Yast::Pkg.SourceSaveAll Yast::Pkg.TargetFinish # copy the libzypp caches to the target - copy_zypp_to_target + if Agama::Software::Repository.all.empty? + logger.info("No repository defined, not copying the libzypp caches") + else + copy_zypp_to_target + end registration.finish end @@ -700,6 +706,11 @@ def update_repositories(new_product) Yast::Pkg.SourceSaveAll end end + + # remove all local repositories + def remove_local_repos + Agama::Software::Repository.all.select(&:local?).each(&:delete!) + end end end end diff --git a/service/package/rubygem-agama-yast.changes b/service/package/rubygem-agama-yast.changes index 234b7cb787..3d542f157b 100644 --- a/service/package/rubygem-agama-yast.changes +++ b/service/package/rubygem-agama-yast.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Wed Feb 5 14:32:29 UTC 2025 - Ladislav Slezák + +- Disable the local media in the installed system, esp. the + offline repository with URL dir:///run/initramfs/live/install + (bsc#1236813) + ------------------------------------------------------------------- Wed Jan 29 16:28:32 UTC 2025 - Josef Reidinger diff --git a/service/test/agama/software/manager_test.rb b/service/test/agama/software/manager_test.rb index e5583c017c..f3551e9429 100644 --- a/service/test/agama/software/manager_test.rb +++ b/service/test/agama/software/manager_test.rb @@ -89,6 +89,7 @@ allow(Yast::Pkg).to receive(:TargetFinish) allow(Yast::Pkg).to receive(:TargetLoad) allow(Yast::Pkg).to receive(:SourceSaveAll) + allow(Yast::Pkg).to receive(:SourceDelete) allow(Yast::Pkg).to receive(:ImportGPGKey) # allow glob to work for other calls allow(Dir).to receive(:glob).and_call_original @@ -383,6 +384,15 @@ end it "copies the libzypp cache and credentials to the target system" do + allow(Agama::Software::Repository).to receive(:all).and_return( + [ + Agama::Software::Repository.new( + repo_id: 42, repo_alias: "alias", name: "name", + url: "http://example.com", enabled: true, autorefresh: false + ) + ] + ) + allow(Dir).to receive(:exist?).and_call_original allow(Dir).to receive(:entries).and_call_original @@ -435,6 +445,34 @@ subject.finish end + + context "only a local repository is used" do + let(:repo_id) { 42 } + before do + expect(Agama::Software::Repository).to receive(:all).and_return( + [ + Agama::Software::Repository.new( + repo_id: repo_id, repo_alias: "alias", name: "name", + url: "dir:///run/initramfs/live/install", enabled: true, autorefresh: false + ) + ], + # for the second and further calls return empty list, the repo has been removed + [] + ) + end + + it "removes the local repository" do + expect(Yast::Pkg).to receive(:SourceDelete).with(repo_id) + + subject.finish + end + + it "does not copy the libzypp cache" do + expect(subject).to_not receive(:copy_zypp_to_target) + + subject.finish + end + end end describe "#package_installed?" do