Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package yast2-installation for openSUSE:Factory checked in at 2021-03-28 11:53:57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-installation (Old) and /work/SRC/openSUSE:Factory/.yast2-installation.new.2401 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-installation" Sun Mar 28 11:53:57 2021 rev:464 rq:879817 version:4.3.35 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-installation/yast2-installation.changes 2021-03-08 15:17:50.609964450 +0100 +++ /work/SRC/openSUSE:Factory/.yast2-installation.new.2401/yast2-installation.changes 2021-03-28 11:54:08.568106043 +0200 @@ -1,0 +2,34 @@ +Wed Mar 17 16:53:42 UTC 2021 - Ladislav Slez??k <lsle...@suse.cz> + +- Expert console: use "dash" if available instead of "bash" shell + to avoid job control error messages (bsc#1183648) +- 4.3.35 + +------------------------------------------------------------------- +Thu Mar 11 15:13:16 UTC 2021 - Ladislav Slez??k <lsle...@suse.cz> + +- Remove the libzypp cache symlink (related to bsc#1182928) +- Improved "memsample" script handling + - Do not start it again if it is already running + (might happen if YaST is started again after crash) + - Stop it when YaST finishes +- 4.3.34 + +------------------------------------------------------------------- +Wed Mar 10 17:25:29 UTC 2021 - Knut Anderssen <kanders...@suse.com> + +- Do not trigger any kernel event with udevadm from the + kernel_finish client (bsc#1180535) +- 4.3.33 + +------------------------------------------------------------------- +Wed Mar 10 10:06:00 UTC 2021 - Imobach Gonzalez Sosa <igonzalezs...@suse.com> + +- Reduce self-update mechanism memory consumption (bsc#1182928): + - Make sure to download the package only once. + - Use a single squash file system for each update repository. + - Ignore unchanged files and directories like /usr/share/man, + /usr/share/info, etc. +- 4.3.32 + +------------------------------------------------------------------- Old: ---- yast2-installation-4.3.31.tar.bz2 New: ---- yast2-installation-4.3.35.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-installation.spec ++++++ --- /var/tmp/diff_new_pack.TGCBAt/_old 2021-03-28 11:54:10.124107422 +0200 +++ /var/tmp/diff_new_pack.TGCBAt/_new 2021-03-28 11:54:10.128107425 +0200 @@ -17,7 +17,7 @@ Name: yast2-installation -Version: 4.3.31 +Version: 4.3.35 Release: 0 Summary: YaST2 - Installation Parts License: GPL-2.0-only ++++++ yast2-installation-4.3.31.tar.bz2 -> yast2-installation-4.3.35.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-installation-4.3.31/doc/SELF_UPDATE.md new/yast2-installation-4.3.35/doc/SELF_UPDATE.md --- old/yast2-installation-4.3.31/doc/SELF_UPDATE.md 2021-03-05 14:33:52.000000000 +0100 +++ new/yast2-installation-4.3.35/doc/SELF_UPDATE.md 2021-03-18 08:17:18.000000000 +0100 @@ -97,11 +97,13 @@ https://www.suse.com/products/subscription-management-tool)) as this is the only format which it supports for data mirroring. -The files from the packages override the files from the original inst-sys. -That means the update packages might not need to contain all files, -it is enough to include only the changed files which are different than -in the original inst-sys. The unchanged files can be omitted to save memory -and the download bandwidth. +The files from the packages override the files from the original inst-sys. YaST +automatically ignores those files that have not changed, removing them to save +some memory. Additionally, `/usr/share/doc`, `/usr/share/info`, `/usr/share/man` +and `var/adm/fillup-templates` are excluded too. + +In order to reduce the download bandwidth, the update packages might include +only the changed files. ## Where to Find the Updates diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-installation-4.3.31/package/yast2-installation.changes new/yast2-installation-4.3.35/package/yast2-installation.changes --- old/yast2-installation-4.3.31/package/yast2-installation.changes 2021-03-05 14:33:52.000000000 +0100 +++ new/yast2-installation-4.3.35/package/yast2-installation.changes 2021-03-18 08:17:18.000000000 +0100 @@ -1,4 +1,38 @@ ------------------------------------------------------------------- +Wed Mar 17 16:53:42 UTC 2021 - Ladislav Slez??k <lsle...@suse.cz> + +- Expert console: use "dash" if available instead of "bash" shell + to avoid job control error messages (bsc#1183648) +- 4.3.35 + +------------------------------------------------------------------- +Thu Mar 11 15:13:16 UTC 2021 - Ladislav Slez??k <lsle...@suse.cz> + +- Remove the libzypp cache symlink (related to bsc#1182928) +- Improved "memsample" script handling + - Do not start it again if it is already running + (might happen if YaST is started again after crash) + - Stop it when YaST finishes +- 4.3.34 + +------------------------------------------------------------------- +Wed Mar 10 17:25:29 UTC 2021 - Knut Anderssen <kanders...@suse.com> + +- Do not trigger any kernel event with udevadm from the + kernel_finish client (bsc#1180535) +- 4.3.33 + +------------------------------------------------------------------- +Wed Mar 10 10:06:00 UTC 2021 - Imobach Gonzalez Sosa <igonzalezs...@suse.com> + +- Reduce self-update mechanism memory consumption (bsc#1182928): + - Make sure to download the package only once. + - Use a single squash file system for each update repository. + - Ignore unchanged files and directories like /usr/share/man, + /usr/share/info, etc. +- 4.3.32 + +------------------------------------------------------------------- Thu Mar 4 13:49:52 UTC 2021 - Ladislav Slez??k <lsle...@suse.cz> - Added special installer configuration dialog diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-installation-4.3.31/package/yast2-installation.spec new/yast2-installation-4.3.35/package/yast2-installation.spec --- old/yast2-installation-4.3.31/package/yast2-installation.spec 2021-03-05 14:33:52.000000000 +0100 +++ new/yast2-installation-4.3.35/package/yast2-installation.spec 2021-03-18 08:17:18.000000000 +0100 @@ -16,7 +16,7 @@ # Name: yast2-installation -Version: 4.3.31 +Version: 4.3.35 Release: 0 Group: System/YaST License: GPL-2.0-only diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-installation-4.3.31/src/lib/installation/clients/kernel_finish.rb new/yast2-installation-4.3.35/src/lib/installation/clients/kernel_finish.rb --- old/yast2-installation-4.3.31/src/lib/installation/clients/kernel_finish.rb 2021-03-05 14:33:52.000000000 +0100 +++ new/yast2-installation-4.3.35/src/lib/installation/clients/kernel_finish.rb 2021-03-18 08:17:18.000000000 +0100 @@ -30,6 +30,7 @@ # # $Id$ # + module Yast class KernelFinishClient < Client def main @@ -77,16 +78,6 @@ # Write list of modules to load after system gets up Kernel.SaveModulesToLoad - - # BNC #427705, formerly added as BNC #163073 - # after the chroot into the installed system has been performed. - # This will recreate all missing links. - # bnc#774301 - without --action=change at least when installing - # over lcs device on s390 emulated eth device get lost - SCR.Execute( - path(".target.bash"), - "/usr/bin/udevadm trigger --action=change; /usr/bin/udevadm settle --timeout=60" - ) else Builtins.y2error("unknown function: %1", @func) @ret = nil diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-installation-4.3.31/src/lib/installation/console/plugins/shell_command.rb new/yast2-installation-4.3.35/src/lib/installation/console/plugins/shell_command.rb --- old/yast2-installation-4.3.31/src/lib/installation/console/plugins/shell_command.rb 2021-03-05 14:33:52.000000000 +0100 +++ new/yast2-installation-4.3.35/src/lib/installation/console/plugins/shell_command.rb 2021-03-18 08:17:18.000000000 +0100 @@ -16,13 +16,23 @@ # define the "shell" command in the expert console class Commands def shell - system("/bin/bash") + # dash is a simple shell and needs less memory, also it does not complain + # about missing job control terminal + if File.exist?("/bin/dash") + system("/bin/dash") + # use full featured bash + elsif File.exist?("/bin/bash") + system("/bin/bash") + # fallback + else + system("/bin/sh") + end end private def shell_description - "Starts a shell session (/bin/bash), use the \"exit\" command\n" \ + "Starts a shell session, use the \"exit\" command\n" \ "or press Ctrl+D to return back to the YaST console" end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-installation-4.3.31/src/lib/installation/update_repository.rb new/yast2-installation-4.3.35/src/lib/installation/update_repository.rb --- old/yast2-installation-4.3.31/src/lib/installation/update_repository.rb 2021-03-05 14:33:52.000000000 +0100 +++ new/yast2-installation-4.3.35/src/lib/installation/update_repository.rb 2021-03-18 08:17:18.000000000 +0100 @@ -62,8 +62,8 @@ # @return [URI] URI of the repository attr_reader :uri - # @return [Array<Pathname>] local paths of updates fetched from the repo - attr_reader :update_files + # @return [Array<Pathname>] squash filesystem path + attr_reader :updates_file # @return [Symbol] Repository origin. @see ORIGINS attr_reader :origin # @return [Integer] Repository ID @@ -122,7 +122,7 @@ textdomain "installation" @uri = uri - @update_files = [] + @updates_file = nil @packages = nil raise UnknownOrigin unless ORIGINS.include?(origin) @origin = origin @@ -142,17 +142,26 @@ # Retrieves the list of packages to unpack to the inst-sys # - # 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). + # 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). Additionally, only the latest version is considered. # # @return [Array<Y2Packager::Resolvable>] List of packages to install # # @see Y2Packager::Resolvable def packages return @packages unless @packages.nil? + add_repo - @packages = Y2Packager::Resolvable.find(kind: :package, source: repo_id).sort_by!(&:name) + all_packages = Y2Packager::Resolvable.find(kind: :package, source: repo_id) + pkg_names = all_packages.map(&:name).uniq + + # find the highest version of each package + @packages = pkg_names.map do |name| + all_packages.select { |p| p.name == name }.max do |a, b| + Yast::Pkg.CompareVersions(a.version, b.version) + end + end log.info "Found #{@packages.size} packages: #{@packages.map(&:name)}" # remove packages which are used as addons, these should not be applied to the inst-sys addon_pkgs = Y2Packager::SelfUpdateAddonFilter.packages(repo_id) @@ -161,11 +170,9 @@ @packages end - # Fetch updates + # Fetch updates and save them in a squasfs filesystem # - # Updates will be stored in the given directory. They'll be named - # sequentially using three digits and the prefix 'yast'. For example: - # yast_000, yast_001 and so on. + # Updates will be stored in the given directory. # # If a known error occurs, it will be converted to a CouldNotFetchUpdate # exception. @@ -176,38 +183,26 @@ # @param path [Pathname] Directory to store the updates # @return [Pathname] Paths to the updates # - # @see #fetch_package + # @see #fetch_and_extract_package # @see #paths - # @see #update_files # # @raise CouldNotFetchUpdate def fetch(path = Pathname("/download")) init_progress - packages.each_with_object(update_files).with_index do |(package, files), index| - update_progress(100 * index / packages.size) - files << fetch_package(package, path) + Dir.mktmpdir do |workdir| + packages.each_with_index do |package, index| + update_progress(100 * index / packages.size) + fetch_and_extract_package(package, workdir) + end + @updates_file = build_squashfs(workdir, next_name(path, length: 3)) end rescue Packages::PackageDownloader::FetchError, Packages::PackageExtractor::ExtractionFailed, CouldNotSquashPackage => e - log.error("Could not fetch update: #{e.inspect}. Rolling back.") - remove_update_files raise CouldNotFetchUpdate end - # Remove fetched packages - # - # Remove fetched packages from the filesystem. This method won't work - # if the update is already applied. - def remove_update_files - log.info("Removing update files: #{update_files}") - update_files.each do |path| - FileUtils.rm_f(path) - end - update_files.clear - end - # Apply updates to inst-sys # # It happens in two phases (for each update/package): @@ -215,15 +210,6 @@ # * Mount the squashfs filesystem # * Add files/directories to inst-sys using the /sbin/adddir script # - # @note The current implementation creates one squashfs image per package - # and mounting a squashfs image consumes one loop device (/dev/loop*). - # Inst-sys has by default 64 loop devices, but some of them already used, - # in an extreme case we might run out of loop devices. - # - # On the other hand downloading and unpacking all packages at once might - # require a lot of memory, the installer could crash on a system with - # small memory. - # # @param mount_path [Pathname] Directory to mount the update # # @raise UpdatesNotFetched @@ -231,14 +217,12 @@ # @see #mount_squashfs # @see #adddir def apply(mount_path = Pathname("/mounts")) - raise UpdatesNotFetched if update_files.nil? - update_files.each do |path| - mountpoint = next_name(mount_path, length: 4) - mount_squashfs(path, mountpoint) - adddir(mountpoint) - update_instsys_parts(path, mountpoint) - end + raise UpdatesNotFetched if updates_file.nil? + mountpoint = next_name(mount_path, length: 4) + mount_squashfs(updates_file, mountpoint) + adddir(mountpoint) + update_instsys_parts(updates_file, mountpoint) write_package_index end @@ -286,27 +270,27 @@ private - # Fetch and build a squashfs filesytem for a given package + # Fetch and extract a package to a given directory # # @param package [Y2Packager::Resolvable] Package to retrieve - # @param dir [Pathname] Path to store the squashed filesystems - # @return [Pathname] Path where the file is stored + # @param dir [Pathname] Directory to extract the package contents to # # @see #packages # @see #apply # # @raise PackageNotFound - def fetch_package(package, dir) + def fetch_and_extract_package(package, dir) tempfile = Tempfile.new(package.name) tempfile.close - Dir.mktmpdir do |workdir| - downloader = Packages::PackageDownloader.new(repo_id, package.name) - downloader.download(tempfile.path.to_s) + downloader = Packages::PackageDownloader.new(repo_id, package.name) + downloader.download(tempfile.path.to_s) + Dir.mktmpdir do |tmpdir| + workdir = Pathname.new(tmpdir) extractor = Packages::PackageExtractor.new(tempfile.path.to_s) extractor.extract(workdir) - - build_squashfs(workdir, next_name(dir, length: 3)) + clean_unneeded_files(workdir) + FileUtils.cp_r(workdir.children, dir) unless workdir.empty? end ensure tempfile.unlink @@ -377,6 +361,44 @@ end end + # Directories that are ignored in the instsys + IGNORED_DIRS = [ + "usr/share/doc", + "usr/share/info", + "usr/share/man", + "var/adm/fillup-templates" + ].freeze + + # Clean-up unnecessary files + # + # Clean-up those files that are not needed as part of the update because: + # + # * they are under a path which is not relevant at installation time (doc, man, etc.) + # * they are identical to the original files (no real changes) + # + # @param dir [String,Pathname] Directory to clean-up + def clean_unneeded_files(dir) + top = Pathname.new(dir) + + ignored_dirs = IGNORED_DIRS.map { |d| top.join(d) }.select(&:directory?) + ignored_dirs.each { |d| FileUtils.rm_r(d) } + + top.find do |path| + next if !path.file? || path.symlink? + + instsys_path = Pathname.new("/").join(path.relative_path_from(top)) + next unless instsys_path.exist? + + path.unlink if FileUtils.identical?(path, instsys_path) + end + + top.find.to_a[1..-1].reverse.each do |path| + next if !path.directory? || path.symlink? + + path.unlink if path.empty? + end + end + # Command to mount squashfs filesystem MOUNT_CMD = "mount %<source>s %<target>s".freeze diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-installation-4.3.31/startup/First-Stage/F08-logging new/yast2-installation-4.3.35/startup/First-Stage/F08-logging --- old/yast2-installation-4.3.31/startup/First-Stage/F08-logging 2021-03-05 14:33:52.000000000 +0100 +++ new/yast2-installation-4.3.35/startup/First-Stage/F08-logging 2021-03-18 08:17:18.000000000 +0100 @@ -62,6 +62,10 @@ if [ "$MEMSAMPLE" = 0 ]; then log "\tdisabled" else - memsample --sleep="${MEMSAMPLE-5}" --archive=/var/log/YaST2/memsample.zcat & - log "\tPID: $!" + if pgrep -f memsample; then + log "\talready running" + else + memsample --sleep="${MEMSAMPLE-5}" --archive=/var/log/YaST2/memsample.zcat & + log "\tPID: $!" + fi fi diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-installation-4.3.31/startup/First-Stage/F09-start new/yast2-installation-4.3.35/startup/First-Stage/F09-start --- old/yast2-installation-4.3.31/startup/First-Stage/F09-start 2021-03-05 14:33:52.000000000 +0100 +++ new/yast2-installation-4.3.35/startup/First-Stage/F09-start 2021-03-18 08:17:18.000000000 +0100 @@ -17,10 +17,17 @@ # Using /dev/null - If there is nothing to do, let it fail silently SUSEConnect --cleanup > /dev/null 2>&1 -# delete the repositories accidentally saved into inst-sys +# delete the repositories saved into inst-sys # they make troubles when restarting YaST rm -fv /etc/zypp/repos.d/*.repo +# during installation we move the libzypp cache to the target system (/mnt) +# and replace it with a symlink, when YaST is restarted the symlink becomes +# invalid and needs to be removed +if [ -L /var/cache/zypp ]; then + rm -fv /var/cache/zypp +fi + #============================================= # 9.1) check for driver update mode #--------------------------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-installation-4.3.31/startup/First-Stage/F10-cleanup new/yast2-installation-4.3.35/startup/First-Stage/F10-cleanup --- old/yast2-installation-4.3.31/startup/First-Stage/F10-cleanup 2021-03-05 14:33:52.000000000 +0100 +++ new/yast2-installation-4.3.35/startup/First-Stage/F10-cleanup 2021-03-18 08:17:18.000000000 +0100 @@ -14,6 +14,9 @@ umount /y2update fi +# stop memory sampling +pkill -f memsample + #============================================= # 10.4) write exit code for evaluation #--------------------------------------------- Binary files old/yast2-installation-4.3.31/test/fixtures/self-update-content.tar.xz and new/yast2-installation-4.3.35/test/fixtures/self-update-content.tar.xz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-installation-4.3.31/test/update_repository_test.rb new/yast2-installation-4.3.35/test/update_repository_test.rb --- old/yast2-installation-4.3.31/test/update_repository_test.rb 2021-03-05 14:33:52.000000000 +0100 +++ new/yast2-installation-4.3.35/test/update_repository_test.rb 2021-03-18 08:17:18.000000000 +0100 @@ -18,7 +18,6 @@ let(:repo_id) { 1 } let(:download_path) { TEMP_DIR.join("download") } let(:updates_path) { TEMP_DIR.join("mounts") } - let(:tmpdir) { TEMP_DIR.join("tmp") } let(:probed) { "RPMMD" } let(:packages) { [] } @@ -37,20 +36,44 @@ after { FileUtils.rm_rf(TEMP_DIR) } let(:package) do - Y2Packager::Resolvable.new("name" => "pkg1", "path" => "./x86_64/pkg1-3.1.x86_64.rpm", "source" => repo_id) + Y2Packager::Resolvable.new( + "name" => "pkg1", + "version" => "3.2", + "path" => "./x86_64/pkg1-3.2.x86_64.rpm", + "source" => repo_id + ) + end + + let(:same_package) do + Y2Packager::Resolvable.new( + "name" => "pkg1", + "version" => "3.1", + "path" => "./x86_64/pkg1-3.1.x86_64.rpm", + "source" => repo_id + ) end let(:other_package) do - Y2Packager::Resolvable.new("name" => "pkg0", "path" => "./x86_64/pkg0-3.1.x86_64.rpm", "source" => repo_id) + Y2Packager::Resolvable.new( + "name" => "pkg0", + "version" => "3.1", + "path" => "./x86_64/pkg0-3.1.x86_64.rpm", + "source" => repo_id + ) end let(:from_other_repo) do - Y2Packager::Resolvable.new("name" => "pkg2", "path" => "./x86_64/pkg2-3.1.x86_64.rpm", "source" => repo_id + 1) + Y2Packager::Resolvable.new( + "name" => "pkg2", + "version" => "3.1", + "path" => "./x86_64/pkg2-3.1.x86_64.rpm", + "source" => repo_id + 1 + ) end before do allow(Y2Packager::Resolvable).to receive(:find).with(kind: :package, source: repo_id) - .and_return([other_package, package]) + .and_return([other_package, package, same_package]) allow(Y2Packager::Resolvable).to receive(:find).with(kind: :package, source: repo_id + 1) .and_return([from_other_repo]) end @@ -101,7 +124,7 @@ describe "#fetch" do around do |example| - FileUtils.mkdir_p([download_path, updates_path, tmpdir]) + FileUtils.mkdir_p([download_path, updates_path]) example.run FileUtils.rm_rf(TEMP_DIR) end @@ -115,79 +138,81 @@ let(:tempfile) { double("tempfile", close: true, path: package_path, unlink: true) } let(:downloader) { double("Packages::PackageDownloader", download: nil) } let(:extractor) { double("Packages::PackageExtractor", extract: nil) } + let(:self_update_archive) { fixtures_dir("self-update-content.tar.xz") } before do allow(repo).to receive(:add_repo).and_return(repo_id) allow(repo).to receive(:packages).and_return([package]) - allow(Dir).to receive(:mktmpdir).and_yield(tmpdir.to_s) - allow(Packages::PackageDownloader).to receive(:new).with(repo_id, package.name).and_return(downloader) - allow(Packages::PackageExtractor).to receive(:new).with(tempfile.path.to_s).and_return(extractor) + allow(Packages::PackageDownloader).to receive(:new).with(repo_id, package.name) + .and_return(downloader) + allow(Packages::PackageExtractor).to receive(:new).with(tempfile.path.to_s) + .and_return(extractor) + allow(extractor).to receive(:extract) do |dir| + FileUtils.mkdir_p(dir) + system("/usr/bin/tar xf #{self_update_archive} -C #{dir}") + end allow(Tempfile).to receive(:new).and_return(tempfile) end - it "builds one squashed filesystem by package" do + it "builds a squashed filesystem containing all updates" do # Download expect(downloader).to receive(:download).with(tempfile.path.to_s) - # Extract - expect(extractor).to receive(:extract).with(tmpdir.to_s) - # Squash - expect(Yast::SCR).to receive(:Execute) - .with(Yast::Path.new(".target.bash_output"), /mksquashfs.+#{tmpdir} .+\/yast_000/) - .and_return("exit" => 0, "stdout" => "", "stderr" => "") + expect(Yast::SCR).to receive(:Execute) do |*args| + yast_path, command = args + expect(yast_path).to eq(Yast::Path.new(".target.bash_output")) + dir = command[/mksquashfs ([^ ]+) .+\/yast_000/, 1] + tmpdir = Pathname.new(dir) + squashed = tmpdir.glob("**/*") + expect(squashed).to_not include(tmpdir.join("usr", "share", "doc")) + expect(squashed).to_not include(tmpdir.join("usr", "share", "info")) + expect(squashed).to_not include(tmpdir.join("usr", "share", "man")) + expect(squashed).to_not include(tmpdir.join("usr", "share", "YaST2", "schema")) + expect(squashed).to include( + tmpdir.join("usr", "share", "YaST2", "lib", "installation", "sample.rb") + ) + end.and_return("exit" => 0, "stdout" => "") repo.fetch(download_path) end context "when a package can't be retrieved" do before do - expect(downloader).to receive(:download).and_raise(Packages::PackageDownloader::FetchError) + allow(downloader).to receive(:download) + .and_raise(Packages::PackageDownloader::FetchError) end - it "clear downloaded files and raises a CouldNotFetchUpdate error" do - expect(repo).to receive(:remove_update_files) + it "raises a CouldNotFetchUpdate error" do expect { repo.fetch(download_path) } .to raise_error(Installation::UpdateRepository::CouldNotFetchUpdate) end end context "when a package can't be extracted" do - it "clear downloaded files and raises a CouldNotFetchUpdate error" do - expect(extractor).to receive(:extract).and_raise(Packages::PackageExtractor::ExtractionFailed) + it "raises a CouldNotFetchUpdate error" do + expect(extractor).to receive(:extract) + .and_raise(Packages::PackageExtractor::ExtractionFailed) - expect(repo).to receive(:remove_update_files) expect { repo.fetch(download_path) } .to raise_error(Installation::UpdateRepository::CouldNotFetchUpdate) end end context "when a package can't be squashed" do - it "clear downloaded files and raises a CouldNotFetchUpdate error" do + it "raises a CouldNotFetchUpdate error" do allow(Yast::SCR).to receive(:Execute) .with(Yast::Path.new(".target.bash_output"), /mksquash/) .and_return("exit" => 1, "stdout" => "", "stderr" => "") - expect(repo).to receive(:remove_update_files) expect { repo.fetch(download_path) } .to raise_error(Installation::UpdateRepository::CouldNotFetchUpdate) end end end - describe "#remove_update_files" do - let(:update_file) { Pathname.new("yast_001") } - - it "removes downloaded files and clear update_files" do - allow(repo).to receive(:update_files).and_return([update_file]) - expect(FileUtils).to receive(:rm_f).with(update_file) - expect(repo.update_files).to receive(:clear) - repo.remove_update_files - end - end - describe "#apply" do - let(:update_path) { Pathname("/download/yast_000") } + let(:updates_file) { Pathname("/download/yast_000") } let(:mount_point) { updates_path.join("yast_0000") } let(:file) { double("file") } let(:package) do @@ -195,7 +220,7 @@ end before do - allow(repo).to receive(:update_files).and_return([update_path]) + allow(repo).to receive(:updates_file).and_return(updates_file) allow(Installation::UpdateRepository::INSTSYS_PARTS_PATH).to receive(:open).and_yield(file) allow(FileUtils).to receive(:mkdir_p).with(mount_point) allow(repo).to receive(:packages).and_return([package]) @@ -206,14 +231,13 @@ it "mounts and adds files/dir" do # mount expect(Yast::SCR).to receive(:Execute) - .with(Yast::Path.new(".target.bash_output"), /mount.+#{update_path}.+#{mount_point}/) + .with(Yast::Path.new(".target.bash_output"), /mount.+#{updates_file}.+#{mount_point}/) .and_return("exit" => 0) # adddir expect(Yast::SCR).to receive(:Execute) .with(Yast::Path.new(".target.bash_output"), /adddir #{mount_point} \//) .and_return("exit" => 0) - expect(file).to receive(:puts) repo.apply(updates_path) end