Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion service/lib/agama/software/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
7 changes: 7 additions & 0 deletions service/package/rubygem-agama-yast.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Feb 5 14:32:29 UTC 2025 - Ladislav Slezák <lslezak@suse.com>

- 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 <jreidinger@suse.com>

Expand Down
38 changes: 38 additions & 0 deletions service/test/agama/software/manager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down