Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package yast2-packager for openSUSE:Factory checked in at 2022-04-08 00:27:32 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-packager (Old) and /work/SRC/openSUSE:Factory/.yast2-packager.new.1900 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-packager" Fri Apr 8 00:27:32 2022 rev:424 rq:967481 version:4.5.1 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-packager/yast2-packager.changes 2022-03-18 16:41:48.849167492 +0100 +++ /work/SRC/openSUSE:Factory/.yast2-packager.new.1900/yast2-packager.changes 2022-04-08 00:28:04.138086434 +0200 @@ -1,0 +2,19 @@ +Thu Apr 7 11:28:48 UTC 2022 - Stefan Hundhammer <shundham...@suse.com> + +- Show package downloads in the global progress bar during package + installation (bsc#1195608) + PR: https://github.com/yast/yast-packager/pull/612 +- 4.5.1 + +------------------------------------------------------------------- +Wed Apr 06 13:24:58 UTC 2022 - Ladislav Slez??k <lsle...@suse.cz> + +- Bump version to 4.5.0 (#bsc1198109) + +------------------------------------------------------------------- +Thu Mar 31 15:52:11 UTC 2022 - Ladislav Slez??k <lsle...@suse.cz> + +- Fixed regression in repository alias name for add-ons (bsc#1193214) +- 4.4.27 + +------------------------------------------------------------------- Old: ---- yast2-packager-4.4.26.tar.bz2 New: ---- yast2-packager-4.5.1.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-packager.spec ++++++ --- /var/tmp/diff_new_pack.GckSAT/_old 2022-04-08 00:28:04.950077320 +0200 +++ /var/tmp/diff_new_pack.GckSAT/_new 2022-04-08 00:28:04.962077185 +0200 @@ -17,7 +17,7 @@ Name: yast2-packager -Version: 4.4.26 +Version: 4.5.1 Release: 0 Summary: YaST2 - Package Library License: GPL-2.0-or-later ++++++ yast2-packager-4.4.26.tar.bz2 -> yast2-packager-4.5.1.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-packager-4.4.26/package/yast2-packager.changes new/yast2-packager-4.5.1/package/yast2-packager.changes --- old/yast2-packager-4.4.26/package/yast2-packager.changes 2022-03-17 09:58:58.000000000 +0100 +++ new/yast2-packager-4.5.1/package/yast2-packager.changes 2022-04-07 13:42:53.000000000 +0200 @@ -1,4 +1,23 @@ ------------------------------------------------------------------- +Thu Apr 7 11:28:48 UTC 2022 - Stefan Hundhammer <shundham...@suse.com> + +- Show package downloads in the global progress bar during package + installation (bsc#1195608) + PR: https://github.com/yast/yast-packager/pull/612 +- 4.5.1 + +------------------------------------------------------------------- +Wed Apr 06 13:24:58 UTC 2022 - Ladislav Slez??k <lsle...@suse.cz> + +- Bump version to 4.5.0 (#bsc1198109) + +------------------------------------------------------------------- +Thu Mar 31 15:52:11 UTC 2022 - Ladislav Slez??k <lsle...@suse.cz> + +- Fixed regression in repository alias name for add-ons (bsc#1193214) +- 4.4.27 + +------------------------------------------------------------------- Thu Mar 17 08:01:35 UTC 2022 - Ladislav Slez??k <lsle...@suse.cz> - Read the products from libzypp in installed system, fixes crash diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-packager-4.4.26/package/yast2-packager.spec new/yast2-packager-4.5.1/package/yast2-packager.spec --- old/yast2-packager-4.4.26/package/yast2-packager.spec 2022-03-17 09:58:58.000000000 +0100 +++ new/yast2-packager-4.5.1/package/yast2-packager.spec 2022-04-07 13:42:53.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-packager -Version: 4.4.26 +Version: 4.5.1 Release: 0 Summary: YaST2 - Package Library License: GPL-2.0-or-later diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-packager-4.4.26/src/include/packager/repositories_include.rb new/yast2-packager-4.5.1/src/include/packager/repositories_include.rb --- old/yast2-packager-4.4.26/src/include/packager/repositories_include.rb 2022-03-17 09:58:58.000000000 +0100 +++ new/yast2-packager-4.5.1/src/include/packager/repositories_include.rb 2022-04-07 13:42:53.000000000 +0200 @@ -148,7 +148,7 @@ alias_name = if force_alias != "" force_alias - elsif product.media_name && !product.media_name.empty? + elsif product.media_name && !product.media_name.empty? && product.media_name != "/" propose_alias(product.media_name) elsif product.name && !product.name.empty? propose_alias(product.name) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-packager-4.4.26/src/modules/PackageSlideShow.rb new/yast2-packager-4.5.1/src/modules/PackageSlideShow.rb --- old/yast2-packager-4.4.26/src/modules/PackageSlideShow.rb 2022-03-17 09:58:58.000000000 +0100 +++ new/yast2-packager-4.5.1/src/modules/PackageSlideShow.rb 2022-04-07 13:42:53.000000000 +0200 @@ -16,66 +16,62 @@ Yast.import "SlideShow" Yast.import "String" Yast.import "Mode" + Yast.import "Packages" - @inst_src_names = [] # a list of strings identifying each repository - @total_size_installed = 0 - @total_size_to_install = 0 + init_member_vars + end + def init_member_vars @init_pkg_data_complete = false - # package summary - # package counters - @installed_packages = 0 - @updated_packages = 0 - @removed_packages = 0 - - @total_downloaded = 0 - @total_installed = 0 @total_pkgs_to_install = 0 + @total_size_to_install = 0 # directly accessed in one click installer :-( + @total_installed_size = 0 + @expected_total_download_size = 0 + @finished_total_download_size = 0 + + @active_downloads = 0 # Number of pkg downloads currently going on + @detected_parallel_download = false + + # Those @current_download_pkg_... variables keep track of the most recent + # current download. Avoid using them if parallel downloads are in effect. + + @current_download_pkg_size = 0 # RPM size, not installed size + @current_download_pkg_percent = 0 + @current_download_pkg_name = "" + + # Lists of package names that were installed / updated / removed + # (after that operation is finished) + + @installed_pkg_list = [] + @updated_pkg_list = [] + @removed_pkg_list = [] - # package list (only used in installed system) - @installed_packages_list = [] - @updated_packages_list = [] - @removed_packages_list = [] - + # This is a kludge to pass information from one callback that gets the + # needed information (the pkg name) to another that doesn't. @updating = false + nil end def ResetPackageSummary - @installed_packages = 0 - @updated_packages = 0 - @removed_packages = 0 - @total_downloaded = 0 - @total_installed = 0 - - @installed_packages_list = [] - @updated_packages_list = [] - @removed_packages_list = [] - - # temporary values - @updating = false - + init_member_vars nil end def GetPackageSummary { - "installed" => @installed_packages, - "updated" => @updated_packages, - "removed" => @removed_packages, - "installed_list" => @installed_packages_list, - "updated_list" => @updated_packages_list, - "removed_list" => @removed_packages_list, - "downloaded_bytes" => @total_downloaded, - "installed_bytes" => @total_installed + "installed" => @installed_pkg_list.size, + "updated" => @updated_pkg_list.size, + "removed" => @removed_pkg_list.size, + "installed_list" => @installed_pkg_list, + "updated_list" => @updated_pkg_list, + "removed_list" => @removed_pkg_list, + "downloaded_bytes" => @finished_total_download_size, + "installed_bytes" => @total_installed_size } end - # *************************************************************************** - # ************** Formatting functions and helpers ************************** - # *************************************************************************** - - # Sum up all list items. It flattens list and also skip all negative values. + # Sum up all list items. It flattens the list and also skips all negative values. # # @param sizes [Array<Fixnum|Array>] Sizes to sum # @return [Fixnum] Sizes sum @@ -83,16 +79,22 @@ sizes.flatten.select(&:positive?).reduce(0, :+) end + # The total size in bytes to install. + def TotalSizeToInstall + @total_size_to_install + end + + # The current size in bytes that is already installed. def TotalInstalledSize - @total_size_installed + @total_installed_size end # Format number of remaining bytes to be installed as string. # @param [Fixnum] remaining bytes remaining, -1 for 'done' - # @return [String] human readable remaining time or byte / kB/ MB size + # @return [String] human readable remaining time or byte / kB/ MB size # def FormatRemainingSize(remaining) - if Ops.less_than(remaining, 0) + if remaining < 0 # Nothing more to install from this CD (very concise - little space!!) return _("Done.") end @@ -103,10 +105,10 @@ # Format number of remaining packages to be installed as string. # @param [Fixnum] remaining bytes remaining, -1 for 'done' - # @return [String] human readable remaining time or byte / kB/ MB size + # @return [String] human readable remaining time or byte / kB/ MB size # def FormatRemainingCount(remaining) - if Ops.less_than(remaining, 0) + if remaining < 0 # Nothing more to install from this CD (very concise - little space!!) return _("Done.") end @@ -125,60 +127,90 @@ return if @init_pkg_data_complete && !force ResetPackageSummary() - # Reinititalize some globals (in case this is a second run) - @total_size_installed = 0 - @updated_packages = 0 - @installed_packages = 0 total_sizes_per_cd_per_src = Pkg.PkgMediaSizes total_pkg_count_per_cd_per_src = Pkg.PkgMediaCount @total_size_to_install = ListSum(total_sizes_per_cd_per_src) - log.info "total_size_to_install: #{@total_size_to_install}" @total_pkgs_to_install = ListSum(total_pkg_count_per_cd_per_src) + @expected_total_download_size = Packages.CountSizeToBeDownloaded @init_pkg_data_complete = true - end - - # Recalculate remaining times per CD based on package sizes remaining - # and data rate so far. Recalculation is only done each 'recalc_interval' - # seconds unless 'force_recalc' is set to 'true'. - # - # @param [Boolean] _force_recalc force recalculation even if timeout not reached yet - # @return true if recalculated, false if not - # - # @see SlideShow.next_recalc_time - # @see Yast2::SystemTime.uptime - def RecalcRemainingTimes(_force_recalc) - true - end - # Switch unit to seconds if necessary and recalc everything accordingly. - # @return true if just switched from sizes to seconds, false otherwise - # - def SwitchToSecondsIfNecessary - false + log.info "Total size to install: #{String.FormatSize(@total_size_to_install)}" + log.info "Expected download size: #{String.FormatSize(@expected_total_download_size)}" + log.info "Parallel download (initial): #{parallel_download?}" + nil end - # *************************************************************************** - # ***************** Callbacks and progress bars **************************** - # *************************************************************************** - - # Update progress widgets for the current CD: Label and ProgressBar. - # Use global statistics variables for that. - # @param [Boolean] silent_check don't complain in log file + # Check if package are downloaded in parallel to being installed. + def parallel_download? + # Did the callbacks here clearly detect parallel operation? + return true if @detected_parallel_download + + # Use heuristics based on installation modes + # + # 15.4: Not in the installed system, only during system installation + # (and upgrade / autoinstallation (?)). + !Mode.normal + end + + # Update the overall progress value of the progress bar. + # + # If libzypp is downloading and installing in parallel, keep this simple + # and only use the installed package size for the total vs. the current + # progress, disregarding the download size since the downloads are not + # causing additional delays. + # + # Otherwise, take the download into account so the progress bar doesn't + # appear to be stuck at zero while libzypp downloads a whole lot of + # packages and waits for that to finish before starting installing any of + # them. + # + # In that case, use the download size plus the installed (unpacked) package + # size for the total vs. the current progress. + # + # Caveat 1: Of course the time to download a package cannot really be + # compared to the time it takes to install it after it is downloaded; it + # depends on the network (Internet or LAN) speed. It may be slower, or it + # may even be faster than installing the package. + # + # This progress reporting is not meant to be an accurate prediction of the + # remaining time; that would only be wild guessing anyway since network + # operations with wildly unpredictable time behavior are involved. + # + # Caveat 2: Only real downloads are considered, not getting packages that + # are directly available from a local repo (installation media or local + # directories) since that causes no noticeable delay, so it's irrelevant + # for progress reporting. # - def UpdateCurrentCdProgress(silent_check); end - - # update the overall progress value (download + installation) def UpdateTotalProgressValue - total_progress = if @total_size_to_install.zero? - 100 # nothing to install. Should not happen + total_size = @total_size_to_install + total_size += @expected_total_download_size unless parallel_download? + + if total_size.zero? # Prevent division by zero + total_progress = 100 # Nothing to install. Should not happen. else - TotalInstalledSize() * 100 / @total_size_to_install + current = TotalInstalledSize() + current += CurrentDownloadSize() unless parallel_download? + log.debug "Current: #{String.FormatSize(current)} of #{String.FormatSize(total_size)}" + total_progress = 100.0 * current / total_size end - log.debug "Total package installation progress: #{total_progress}%" - SlideShow.StageProgress(total_progress, nil) + log.debug "Total progress: #{total_progress.round(2)}%" + SlideShow.StageProgress(total_progress.round, nil) + end + + # Calculate the size of the current downloads from finished downloads and + # the percentage of the current download. + # + # A partial download of the current package is relevant if there are only + # very few packages to download, or if the current one is very large in + # comparison to the total expected download; which is a common scenario in + # the installed system (e.g. kernel updates). + # + def CurrentDownloadSize + current_pkg = @current_download_pkg_size * @current_download_pkg_percent / 100 + @finished_total_download_size + current_pkg end # Update progress widgets @@ -188,150 +220,206 @@ UpdateTotalProgressValue() end - # Progress display update - # This is called via the packager's progress callbacks. + # @deprecated Misleading method name. For API backwards compatibility. # - # @param [Fixnum] pkg_percent package percentage + def DisplayGlobalProgress + log.warn "DEPRECATED. Use UpdateTotalProgressText() instead." + UpdateTotalProgressText() + end + + # Update the total progress text (not the value!). # - def UpdateCurrentPackageProgress(pkg_percent); end + def UpdateTotalProgressText + if @active_downloads > 0 && !parallel_download? + UpdateDownloadProgressText() + else + UpdateInstallationProgressText() + end + end + + # Update the total progress text for downloading. + # This should only be used if parallel download + installation is not in effect. + # + def UpdateDownloadProgressText + SlideShow.SetGlobalProgressLabel( + _("Downloading...") + + Builtins.sformat( + # TRANSLATORS: This is about a remaining download size. + # %1 is the remaining size with a unit (kiB, MiB, GiB etc.), + # %2 the total download size, also with a unit. + _(" (Remaining: %1 of %2)"), + String.FormatSize(@expected_total_download_size - CurrentDownloadSize()), + String.FormatSize(@expected_total_download_size) + ) + ) - # update the download rate - def UpdateCurrentPackageRateProgress(_pkg_percent, _bps_avg, _bps_current) nil end - def DisplayGlobalProgress - rem_string = FormatRemainingSize(@total_size_to_install - @total_size_installed) - - rem_string += ", " unless rem_string.empty? + # Update the total progress text for installing / updating / removing + # packages; or, for parallel download + installation, also for downloading. + # + def UpdateInstallationProgressText + installed_pkg = @installed_pkg_list.size + updated_pkg = @updated_pkg_list.size + remaining_string = FormatRemainingSize(@total_size_to_install - @total_installed_size) + remaining_string += ", " unless remaining_string.empty? SlideShow.SetGlobalProgressLabel( - Ops.add( - SlideShow.CurrentStageDescription, - Builtins.sformat( - _(" (Remaining: %1%2 packages)"), - rem_string, - @total_pkgs_to_install - @installed_packages - @updated_packages - ) + SlideShow.CurrentStageDescription + + Builtins.sformat( + _(" (Remaining: %1%2 packages)"), + remaining_string, + @total_pkgs_to_install - installed_pkg - updated_pkg ) ) nil end - # Callback when file is downloaded ( but not yet installed ) - # @param error[Integer] error code - def DoneProvide(error, _reason, _name) - return if error.nonzero? - - # move the progress also for downloaded files + # Notification when download of a package starts + def DownloadStart(pkg_name, download_size) + @active_downloads += 1 + log.info "Starting download of #{pkg_name} (#{String.FormatSize(download_size)})" + log.info "active downloads: #{@active_downloads}" if @active_downloads > 1 + @current_download_pkg_name = pkg_name + @current_download_pkg_size = download_size + @current_download_pkg_percent = 0 + return if parallel_download? + + # Update the progress text since it may change from "Installing..." to + # "Downloading...". + UpdateTotalProgressText() UpdateTotalProgressValue() nil end - # Update progress widgets for all CDs. - # Uses global statistics variables. - # Redraw whole table, time consuming, but called only when all times recalculated. - # - def UpdateAllCdProgress(_silent_check) + # Update the download progress for the current package + def DownloadProgress(pkg_percent) + log.debug "#{@current_download_pkg_name}: #{pkg_percent}%" + @current_download_pkg_percent = pkg_percent + return if parallel_download? + + UpdateTotalProgressValue() nil end - # Return a CD's progress bar ID - # @param [Fixnum] src_no number of the repository (from 0 on) - # @param [Fixnum] cd_no number of the CD within that repository (from 0 on) - # - def CdProgressId(src_no, cd_no) - Builtins.sformat("Src %1 CD %2", src_no, cd_no) + # Notification when download of a package is finished + def DownloadEnd(pkg_name) + log.info "Downloading #{pkg_name} finished" + return if parallel_download? + + CurrentDownloadFinished() + UpdateTotalProgressValue() + nil end - # package start display update - # - this is called at the end of a new package - # - # @param [String] pkg_name package name - # @param [String] pkg_size package size in bytes - # @param [Boolean] deleting Flag: deleting (true) or installing (false) package + # Notification about a download error # - def SlideDisplayDone(pkg_name, pkg_size, deleting) - if deleting - @removed_packages += 1 - - @removed_packages_list << pkg_name if Mode.normal - else - @total_size_installed += pkg_size - - UpdateTotalProgress(false) - - # Update global progress bar - DisplayGlobalProgress() + # @param [Integer] error Numeric error code + # @param [String] reason + # @param [String] pkg_name + def DownloadError(error, reason, pkg_name) + log.error "Download error #{error} for #{pkg_name}: #{reason}" + return if parallel_download? - if @updating - @updated_packages = Ops.add(@updated_packages, 1) + CurrentDownloadFinished() + UpdateTotalProgressValue() + nil + end - if Mode.normal - @updated_packages_list = Builtins.add( - @updated_packages_list, - pkg_name - ) - end - else - @installed_packages = Ops.add(@installed_packages, 1) + # Finalize the sums for the current download + def CurrentDownloadFinished + @active_downloads -= 1 if @active_downloads > 0 + @finished_total_download_size += @current_download_pkg_size + @current_download_pkg_size = 0 + @current_download_pkg_percent = 0 + @current_download_pkg_name = "" + end + + # Notification that a package starts being installed, updated or removed. + # Not to be confused with DownloadStart. + # + # @param [String] pkg_name package name + # @param [String] _pkg_location full path to a package + # @param [String] _pkg_summary package summary (short description) + # @param [Integer] _pkg_size installed package size in bytes + # @param [Boolean] deleting Flag: deleting (true) or installing (false) package? + # + def PkgInstallStart(pkg_name, _pkg_location, _pkg_summary, _pkg_size, deleting) + if @active_downloads > 0 && !@detected_parallel_download + @detected_parallel_download = true + log.info "Detected parallel download and installation" + end - if Mode.normal - @installed_packages_list = Builtins.add( - @installed_packages_list, - pkg_name - ) - end - end + @updating = Pkg.PkgInstalled(pkg_name) unless deleting + UpdateTotalProgressText() - @total_installed = Ops.add(@total_installed, pkg_size) - end + # Don't update the progress value since it cannot have changed right now: + # Only fully installed packages are taken into account, and this one has + # just begun. nil end - # package start display update - # - this is called at the beginning of a new package + # Progress notification while a package is finished being installed, updated or removed. # - # @param [String] pkg_name package name - # @param [String] _pkg_location full path to a package - # @param [String] _pkg_summary package summary (short description) - # @param [Integer] _pkg_size package size in bytes - # @param [Boolean] deleting Flag: deleting (true) or installing (false) package? + # @param [Integer] _pkg_percent percent of progress of this package # - def SlideDisplayStart(pkg_name, _pkg_location, _pkg_summary, _pkg_size, deleting) - @updating = Pkg.PkgInstalled(pkg_name) if !deleting - # Update global progress bar - DisplayGlobalProgress() - + def PkgInstallProgress(_pkg_percent) + # For future use and to mirror the callbacks one call level above + # (SlideShowCallbacks). + # + # Right now, not doing anything here since we only take the fully + # installed packages into account for progress reporting. nil end - def SlideGenericProvideStart(pkg_name, size, pattern, remote); end + # Notification that a package is finished being installed, updated or removed. + # + # @param [String] pkg_name package name + # @param [String] pkg_size package size in bytes + # @param [Boolean] deleting Flag: deleting (true) or installing (false) package + # + def PkgInstallDone(pkg_name, pkg_size, deleting) + if deleting + @removed_pkg_list << pkg_name if Mode.normal + log.info "Uninstalled package #{pkg_name}" + else # installing or updating + @total_installed_size += pkg_size - def SlideDeltaApplyStart(_pkg_name) - nil - end + UpdateTotalProgressValue() + UpdateTotalProgressText() + + if @updating + @updated_pkg_list << pkg_name if Mode.normal + log.info "Updated package #{pkg_name}" + else + @installed_pkg_list << pkg_name if Mode.normal + log.info "Installed package #{pkg_name}" + end + end - # Package providal start - def SlideProvideStart(_pkg_name, _size, _remote) nil end - publish variable: :total_size_to_install, type: "integer" # Used in installation client + # rubocop:disable Layout/LineLength + # + publish variable: :total_size_to_install, type: "integer" # Deprecated; used in one click installer + publish function: :TotalSizeToInstall, type: "integer ()" # Better substitute for the above publish function: :GetPackageSummary, type: "map <string, any> ()" publish function: :InitPkgData, type: "void (boolean)" - publish function: :UpdateCurrentPackageProgress, type: "void (integer)" - publish function: :UpdateCurrentPackageRateProgress, type: "void (integer, integer, integer)" - publish function: :DisplayGlobalProgress, type: "void ()" - publish function: :DoneProvide, type: "void (integer, string, string)" - publish function: :UpdateAllCdProgress, type: "void (boolean)" - publish function: :SlideDisplayDone, type: "void (string, integer, boolean)" - publish function: :SlideDisplayStart, type: "void (string, string, string, integer, boolean)" - publish function: :SlideGenericProvideStart, type: "void (string, integer, string, boolean)" - publish function: :SlideDeltaApplyStart, type: "void (string)" - publish function: :SlideProvideStart, type: "void (string, integer, boolean)" + publish function: :DisplayGlobalProgress, type: "void ()" # Deprecated + publish function: :UpdateTotalProgressText, type: "void ()" # Better substitute for the above + publish function: :DownloadStart, type: "void (string, integer)" + publish function: :DownloadProgress, type: "void (integer)" + publish function: :DownloadEnd, type: "void (string)" + publish function: :DownloadError, type: "void (integer, string, string)" + publish function: :PkgInstallStart, type: "void (string, string, string, integer, boolean)" + publish function: :PkgInstallProgress, type: "void (integer)" + publish function: :PkgInstallDone, type: "void (string, integer, boolean)" + # + # rubocop:enable Layout/LineLength end PackageSlideShow = PackageSlideShowClass.new diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-packager-4.4.26/src/modules/SlideShowCallbacks.rb new/yast2-packager-4.5.1/src/modules/SlideShowCallbacks.rb --- old/yast2-packager-4.4.26/src/modules/SlideShowCallbacks.rb 2022-03-17 09:58:58.000000000 +0100 +++ new/yast2-packager-4.5.1/src/modules/SlideShowCallbacks.rb 2022-04-07 13:42:53.000000000 +0200 @@ -25,7 +25,7 @@ Yast.import "Directory" Yast.import "URL" - @_remote_provide = false + @remote_provide = false @pkg_inprogress = "" @@ -69,40 +69,55 @@ nil end - # at start of file providal + # Start of file providal. + # + # This can be a download (if the package is provided by a remote + # repository) or simply accessing a local repo, e.g. on the currently + # mounted installation media. + # def StartProvide(name, archivesize, remote) @pkg_inprogress = name - @_remote_provide = remote - - PackageSlideShow.SlideProvideStart(name, archivesize, remote) + @remote_provide = remote + PackageSlideShow.DownloadStart(name, archivesize) if @remote_provide nil end - # during file providal + # Update progress during file providal. + # + # This is meant to update a progress bar for the download percent. + # def ProgressProvide(percent) - PackageSlideShow.UpdateCurrentPackageProgress(percent) if @_remote_provide + PackageSlideShow.DownloadProgress(percent) if @remote_provide HandleInput() !SlideShow.GetUserAbort end - def ProgressDownload(percent, bps_avg, bps_current) - PackageSlideShow.UpdateCurrentPackageRateProgress( - percent, - bps_avg, - bps_current - ) - + # Update during package download: Percent, average and current bytes per second. + # + # Notice that there is also ProgressProvide for only the percentage value; + # this callback is meant to update a display of the current data rate and + # possibly predictions about the remaining time based on the data rate. + # + def ProgressDownload(_percent, _bps_avg, _bps_current) HandleInput() !SlideShow.GetUserAbort end - # during file providal + # End of file providal; used both for success (error == 0) and error (error + # != 0). + # + # If this was a download from a remote repo, this means that the download + # is now finished. + # def DoneProvide(error, reason, name) - if @_remote_provide - PackageSlideShow.UpdateCurrentPackageProgress(100) - PackageSlideShow.DoneProvide(error, reason, name) - @_remote_provide = false + if @remote_provide + if error.zero? + PackageSlideShow.DownloadEnd(name) + else + PackageSlideShow.DownloadError(error, reason, name) + end + @remote_provide = false end return "C" if SlideShow.GetUserAbort return PackageCallbacks.DoneProvide(error, reason, name) if error.nonzero? @@ -110,6 +125,8 @@ "" end + # A pre- or post-install/uninstall script is started. + # def ScriptStart(patch_name, patch_version, patch_arch, script_path) patch_full_name = PackageCallbacks.FormatPatchName( patch_name, @@ -122,8 +139,11 @@ script_path ) + # FIXME: maybe use a DelayedProgressPopup here? + # reset the progressbar if UI.WidgetExists(:progressCurrentPackage) + # FIXME: This widget does not exist anymore. UI.ChangeWidget(:progressCurrentPackage, :Label, patch_full_name) UI.ChangeWidget(:progressCurrentPackage, :Value, 0) end @@ -136,8 +156,15 @@ nil end + # Progress during a pre- or post-install/uninstall script. + # + # Since there is no way to find out how far the execution of this script + # has progressed, this is only a "ping" notification, not reporting + # percents. + # def ScriptProgress(ping, output) Builtins.y2milestone("ScriptProgress: ping:%1, output: %2", ping, output) + # FIXME: maybe use a DelayedProgressPopup here? if !output.nil? && output != "" # remove the trailing new line character @@ -159,11 +186,15 @@ ![:abort, :close].include?(input) end + # Error reporting during execution of a pre- or post-install/uninstall script. + # def ScriptProblem(description) # display Abort/Retry/Ignore popup PackageCallbacks.ScriptProblem(description) end + # A pre- or post-install/uninstall script has finished. + # def ScriptFinish Builtins.y2milestone("ScriptFinish") @@ -260,7 +291,7 @@ # and pass the "deleting" flag as appropriate. # def DisplayStartInstall(pkg_name, pkg_location, pkg_description, pkg_size, deleting) - PackageSlideShow.SlideDisplayStart( + PackageSlideShow.PkgInstallStart( pkg_name, pkg_location, pkg_description, @@ -383,7 +414,7 @@ nil end - # at start of package install + # Notification that a package starts being installed, updated or removed. def StartPackage(name, location, summary, install_size, is_delete) PackageCallbacks._package_name = name PackageCallbacks._package_size = install_size @@ -394,9 +425,9 @@ nil end - # ProgressPackage percent - # + # Progress while a package is being installed, updated or removed. def ProgressPackage(pkg_percent) + PackageSlideShow.PkgInstallProgress(pkg_percent) HandleInput() Builtins.y2milestone("Aborted at %1%%", pkg_percent) if SlideShow.GetUserAbort @@ -404,7 +435,8 @@ !SlideShow.GetUserAbort end - # at end of install + # Notification that a package is finished being installed, updated or removed. + # # just to override the PackageCallbacks default (which does a 'CloseDialog' :-}) def DonePackage(error, reason) return "I" if SlideShow.GetUserAbort @@ -420,7 +452,7 @@ if Builtins.size(ret).zero? || Builtins.tolower(Builtins.substring(ret, 0, 1)) != "r" - PackageSlideShow.SlideDisplayDone( + PackageSlideShow.PkgInstallDone( PackageCallbacks._package_name, PackageCallbacks._package_size, PackageCallbacks._deleting_package @@ -430,21 +462,12 @@ end # at start of file providal - def StartDeltaProvide(name, archivesize) - PackageSlideShow.SlideGenericProvideStart( - name, # remote - archivesize, - _("Downloading delta RPM %1 (download size %2)"), - true - ) - + def StartDeltaProvide(_name, _archivesize) nil end # at start of file providal - def StartDeltaApply(name) - PackageSlideShow.SlideDeltaApplyStart(name) - + def StartDeltaApply(_name) nil end @@ -484,7 +507,7 @@ PackageCallbacks.SourceChange(source, media) # inform PackageCallbacks about the change # display remaining packages - PackageSlideShow.DisplayGlobalProgress + PackageSlideShow.UpdateTotalProgressText nil end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-packager-4.4.26/test/package_slide_show_test.rb new/yast2-packager-4.5.1/test/package_slide_show_test.rb --- old/yast2-packager-4.4.26/test/package_slide_show_test.rb 2022-03-17 09:58:58.000000000 +0100 +++ new/yast2-packager-4.5.1/test/package_slide_show_test.rb 2022-04-07 13:42:53.000000000 +0200 @@ -17,19 +17,19 @@ end end - describe ".SlideDisplayDone" do - context "when deleting package" do + describe ".PkgInstallDone" do + context "when deleting a package" do it "increases removed counter in summary" do package_slide_show.main # to reset counter - expect { package_slide_show.SlideDisplayDone("test", 1, true) }.to( + expect { package_slide_show.PkgInstallDone("test", 1, true) }.to( change { package_slide_show.GetPackageSummary["removed"] }.from(0).to(1) ) end - it "adds name to removed_list in summary in normal mode" do + it "adds the name to the removed_list in the summary in normal mode" do allow(Yast::Mode).to receive(:normal).and_return(true) package_slide_show.main # to reset counter - expect { package_slide_show.SlideDisplayDone("test", 1, true) }.to( + expect { package_slide_show.PkgInstallDone("test", 1, true) }.to( change { package_slide_show.GetPackageSummary["removed_list"] } .from([]) .to(["test"]) @@ -37,21 +37,20 @@ end end - context "when installing package" do - # TODO: lot of internal variables changes in size and time estimation that is hard to test + context "when installing a package" do # TODO: updating is also hard to test as it is set at start of package install # TODO: updating non trivial amount of table it "increases installed counter in summary" do package_slide_show.main # to reset counter - expect { package_slide_show.SlideDisplayDone("test", 1, false) }.to( + expect { package_slide_show.PkgInstallDone("test", 1, false) }.to( change { package_slide_show.GetPackageSummary["installed"] }.from(0).to(1) ) end - it "adds name to installed_list in summary in normal mode" do + it "adds the name to the installed_list in the summary in normal mode" do allow(Yast::Mode).to receive(:normal).and_return(true) package_slide_show.main # to reset counter - expect { package_slide_show.SlideDisplayDone("test", 1, false) }.to( + expect { package_slide_show.PkgInstallDone("test", 1, false) }.to( change { package_slide_show.GetPackageSummary["installed_list"] } .from([]) .to(["test"]) @@ -60,7 +59,7 @@ it "adds its size to installed_bytes in summary" do package_slide_show.main # to reset counter - expect { package_slide_show.SlideDisplayDone("test", 502, false) }.to( + expect { package_slide_show.PkgInstallDone("test", 502, false) }.to( change { package_slide_show.GetPackageSummary["installed_bytes"] }.from(0).to(502) ) end @@ -68,13 +67,13 @@ it "sets global progress label in slide show" do expect(Yast::SlideShow).to receive(:SetGlobalProgressLabel) - package_slide_show.SlideDisplayDone("test", 502, false) + package_slide_show.PkgInstallDone("test", 502, false) end it "updates stage progress" do expect(Yast::SlideShow).to receive(:StageProgress) - package_slide_show.SlideDisplayDone("test", 502, false) + package_slide_show.PkgInstallDone("test", 502, false) end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-packager-4.4.26/test/slide_show_callabacks_test.rb new/yast2-packager-4.5.1/test/slide_show_callabacks_test.rb --- old/yast2-packager-4.4.26/test/slide_show_callabacks_test.rb 2022-03-17 09:58:58.000000000 +0100 +++ new/yast2-packager-4.5.1/test/slide_show_callabacks_test.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,97 +0,0 @@ -#!/usr/bin/env rspec - -require_relative "test_helper" - -Yast.import "SlideShowCallbacks" - -describe Yast::SlideShowCallbacksClass do - subject { Yast::SlideShowCallbacksClass.new } - - describe "#DisplayStartInstall" do - let(:pkg_name) { "libyui-ncurses-pkg-devel" } - let(:pkg_location) { "pkg_location" } - let(:pkg_description) { "pkg_description" } - let(:pkg_size) { 138510 } - let(:deleting) { false } - - before do - allow(Yast::PackageSlideShow).to receive(:SlideDisplayStart) - allow(subject).to receive(:HandleInput) - allow(Yast::Installation).to receive(:destdir).and_return("/") - allow(File).to receive(:exist?).and_return(true) - allow(Yast::SlideShow).to receive(:SetUserAbort) - - subject.instance_variable_set(:@ask_again, true) - subject.instance_variable_set(:@pkg_inprogress, pkg_name) - end - - RSpec.shared_examples "free space check" do - it "does not display the space warning when free space is >8EiB" do - # sizes > 8EiB are returned as negative numbers (data overflow) - expect(Yast::Pkg).to receive(:TargetAvailable).and_return(-42) - expect(subject).to_not receive(:YesNoAgainWarning) - - subject.DisplayStartInstall(pkg_name, pkg_location, pkg_description, pkg_size, deleting) - end - - it "does not display the space warning when free space is enough" do - # 1MiB free space - expect(Yast::Pkg).to receive(:TargetAvailable).and_return(1 << 20) - expect(subject).to_not receive(:YesNoAgainWarning) - - subject.DisplayStartInstall(pkg_name, pkg_location, pkg_description, pkg_size, deleting) - end - - it "displays the space warning when free space is not enough" do - # 64KiB free space - expect(Yast::Pkg).to receive(:TargetAvailable).and_return(1 << 16) - expect(subject).to receive(:YesNoAgainWarning) - - subject.DisplayStartInstall(pkg_name, pkg_location, pkg_description, pkg_size, deleting) - end - end - - context "package data usage is available" do - before do - expect(Yast::Pkg).to receive(:PkgDU).with(pkg_name).and_return( - # required space 230KiB - "/" => [6854656, 4483116, 4483346, 0] - ) - end - - include_examples "free space check" - end - - context "package data usage is not available" do - before do - expect(Yast::Pkg).to receive(:PkgDU).with(pkg_name).and_return(nil) - end - - include_examples "free space check" - end - end - - describe "ScriptProgress" do - let(:input) { nil } - - before do - allow(Yast::UI).to receive(:PollInput).and_return(input) - end - - context "user does not click anything" do - let(:input) { nil } - - it "returns true" do - expect(subject.ScriptProgress(0, nil)).to eq true - end - end - - context "user click on abort" do - let(:input) { :abort } - - it "returns false" do - expect(subject.ScriptProgress(0, nil)).to eq false - end - end - end -end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-packager-4.4.26/test/slide_show_callbacks_test.rb new/yast2-packager-4.5.1/test/slide_show_callbacks_test.rb --- old/yast2-packager-4.4.26/test/slide_show_callbacks_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-packager-4.5.1/test/slide_show_callbacks_test.rb 2022-04-07 13:42:53.000000000 +0200 @@ -0,0 +1,97 @@ +#!/usr/bin/env rspec + +require_relative "test_helper" + +Yast.import "SlideShowCallbacks" + +describe Yast::SlideShowCallbacksClass do + subject { Yast::SlideShowCallbacksClass.new } + + describe "#DisplayStartInstall" do + let(:pkg_name) { "libyui-ncurses-pkg-devel" } + let(:pkg_location) { "pkg_location" } + let(:pkg_description) { "pkg_description" } + let(:pkg_size) { 138510 } + let(:deleting) { false } + + before do + allow(Yast::PackageSlideShow).to receive(:PkgInstallStart) + allow(subject).to receive(:HandleInput) + allow(Yast::Installation).to receive(:destdir).and_return("/") + allow(File).to receive(:exist?).and_return(true) + allow(Yast::SlideShow).to receive(:SetUserAbort) + + subject.instance_variable_set(:@ask_again, true) + subject.instance_variable_set(:@pkg_inprogress, pkg_name) + end + + RSpec.shared_examples "free space check" do + it "does not display the space warning when free space is >8EiB" do + # sizes > 8EiB are returned as negative numbers (data overflow) + expect(Yast::Pkg).to receive(:TargetAvailable).and_return(-42) + expect(subject).to_not receive(:YesNoAgainWarning) + + subject.DisplayStartInstall(pkg_name, pkg_location, pkg_description, pkg_size, deleting) + end + + it "does not display the space warning when free space is enough" do + # 1MiB free space + expect(Yast::Pkg).to receive(:TargetAvailable).and_return(1 << 20) + expect(subject).to_not receive(:YesNoAgainWarning) + + subject.DisplayStartInstall(pkg_name, pkg_location, pkg_description, pkg_size, deleting) + end + + it "displays the space warning when free space is not enough" do + # 64KiB free space + expect(Yast::Pkg).to receive(:TargetAvailable).and_return(1 << 16) + expect(subject).to receive(:YesNoAgainWarning) + + subject.DisplayStartInstall(pkg_name, pkg_location, pkg_description, pkg_size, deleting) + end + end + + context "package data usage is available" do + before do + expect(Yast::Pkg).to receive(:PkgDU).with(pkg_name).and_return( + # required space 230KiB + "/" => [6854656, 4483116, 4483346, 0] + ) + end + + include_examples "free space check" + end + + context "package data usage is not available" do + before do + expect(Yast::Pkg).to receive(:PkgDU).with(pkg_name).and_return(nil) + end + + include_examples "free space check" + end + end + + describe "ScriptProgress" do + let(:input) { nil } + + before do + allow(Yast::UI).to receive(:PollInput).and_return(input) + end + + context "user does not click anything" do + let(:input) { nil } + + it "returns true" do + expect(subject.ScriptProgress(0, nil)).to eq true + end + end + + context "user click on abort" do + let(:input) { :abort } + + it "returns false" do + expect(subject.ScriptProgress(0, nil)).to eq false + end + end + end +end