diff --git a/service/lib/agama/software/manager.rb b/service/lib/agama/software/manager.rb index 6794e77d45..ddb08989fd 100644 --- a/service/lib/agama/software/manager.rb +++ b/service/lib/agama/software/manager.rb @@ -506,7 +506,7 @@ def pattern_exist?(pattern_name) # the Live system package manager) # @see https://github.com/yast/yast-pkg-bindings/blob/3d314480b70070299f90da4c6e87a5574e9c890c/src/Source_Installation.cc#L213-L267 def copy_zypp_to_target - # copy the zypp "raw" cache + # copy the zypp "raw" cache cache = File.join(TARGET_DIR, "/var/cache/zypp/raw") if Dir.exist?(cache) target_cache = File.join(Yast::Installation.destdir, "/var/cache/zypp") diff --git a/service/test/agama/software/manager_test.rb b/service/test/agama/software/manager_test.rb index ca6d0b4a93..ad2770c4ec 100644 --- a/service/test/agama/software/manager_test.rb +++ b/service/test/agama/software/manager_test.rb @@ -372,40 +372,54 @@ it "copies the libzypp cache and credentials to the target system" do allow(Dir).to receive(:exist?).and_call_original + allow(Dir).to receive(:entries).and_call_original # copying the raw cache - expect(Dir).to receive(:exist?).with("/run/agama/zypp/var/cache/zypp/raw").and_return(true) - expect(FileUtils).to receive(:mkdir_p).with("/mnt/var/cache/zypp") - expect(FileUtils).to receive(:cp_r).with("/run/agama/zypp/var/cache/zypp/raw", - "/mnt/var/cache/zypp") + expect(Dir).to receive(:exist?).with( + File.join(target_dir, "/var/cache/zypp/raw") + ).and_return(true) + expect(FileUtils).to receive(:mkdir_p).with( + File.join(Yast::Installation.destdir, "/var/cache/zypp") + ) + expect(FileUtils).to receive(:cp_r).with( + File.join(target_dir, "/var/cache/zypp/raw"), + File.join(Yast::Installation.destdir, "/var/cache/zypp") + ) # copy the solv cache repo_alias = "https-download.opensuse.org-94cc89aa" - expect(Dir).to receive(:entries).with("/run/agama/zypp/var/cache/zypp/solv") + expect(Dir).to receive(:entries) + .with(File.join(target_dir, "/var/cache/zypp/solv")) .and_return([".", "..", "@System", repo_alias]) expect(FileUtils).to receive(:cp_r).with( - File.join("/run/agama/zypp/var/cache/zypp/solv/", repo_alias), - "/mnt/var/cache/zypp/solv" + File.join(target_dir, "/var/cache/zypp/solv/", repo_alias), + File.join(Yast::Installation.destdir, "/var/cache/zypp/solv") ) # ensure the @System cache is not copied expect(FileUtils).to_not receive(:cp_r).with( - "/run/agama/zypp/var/cache/zypp/solv/@System", - "/mnt/var/cache/zypp/solv" + File.join(target_dir, "/var/cache/zypp/solv/@System"), + File.join(Yast::Installation.destdir, "/var/cache/zypp/solv") ) # copying the credentials.d directory - expect(Dir).to receive(:exist?).with("/run/agama/zypp/etc/zypp/credentials.d") + expect(Dir).to receive(:exist?) + .with(File.join(target_dir, "/etc/zypp/credentials.d")) .and_return(true) - expect(FileUtils).to receive(:mkdir_p).with("/mnt/etc/zypp") - expect(FileUtils).to receive(:cp_r).with("/run/agama/zypp/etc/zypp/credentials.d", - "/mnt/etc/zypp") + expect(FileUtils).to receive(:mkdir_p) + .with(File.join(Yast::Installation.destdir, "/etc/zypp")) + expect(FileUtils).to receive(:cp_r).with( + File.join(target_dir, "/etc/zypp/credentials.d"), + File.join(Yast::Installation.destdir, "/etc/zypp") + ) # copying the global credentials file - expect(File).to receive(:exist?).with("/run/agama/zypp/etc/zypp/credentials.cat") + expect(File).to receive(:exist?) + .with(File.join(target_dir, "/etc/zypp/credentials.cat")) .and_return(true) - expect(FileUtils).to receive(:mkdir_p).with("/mnt/etc/zypp") - expect(FileUtils).to receive(:copy).with("/run/agama/zypp/etc/zypp/credentials.cat", - "/mnt/etc/zypp") + expect(FileUtils).to receive(:copy).with( + File.join(target_dir, "/etc/zypp/credentials.cat"), + File.join(Yast::Installation.destdir, "/etc/zypp") + ) subject.finish end