[yast-commit] r62714 - in /trunk/packager: agents/Makefile.am agents/etc_zypp_conf.scr package/yast2-packager.changes src/modules/PackageSlideShow.ycp
Author: lslezak
Date: Tue Nov 2 14:03:08 2010
New Revision: 62714
URL: http://svn.opensuse.org/viewcvs/yast?rev=62714&view=rev
Log:
- correctly display download progress in DownloadInAdvance
libzypp mode (bnc#616708)
Added:
trunk/packager/agents/etc_zypp_conf.scr
Modified:
trunk/packager/agents/Makefile.am
trunk/packager/package/yast2-packager.changes
trunk/packager/src/modules/PackageSlideShow.ycp
Modified: trunk/packager/agents/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/packager/agents/Makefile.am?rev=62714&r1=62713&r2=62714&view=diff
==============================================================================
--- trunk/packager/agents/Makefile.am (original)
+++ trunk/packager/agents/Makefile.am Tue Nov 2 14:03:08 2010
@@ -6,6 +6,7 @@
ag_zypp_repos
scrconf_DATA = \
+ etc_zypp_conf.scr \
zypp_repos.scr
EXTRA_DIST = $(agent_SCRIPTS) $(scrconf_DATA)
Added: trunk/packager/agents/etc_zypp_conf.scr
URL: http://svn.opensuse.org/viewcvs/yast/trunk/packager/agents/etc_zypp_conf.scr?rev=62714&view=auto
==============================================================================
--- trunk/packager/agents/etc_zypp_conf.scr (added)
+++ trunk/packager/agents/etc_zypp_conf.scr Tue Nov 2 14:03:08 2010
@@ -0,0 +1,65 @@
+/**
+ * File:
+ * etc_zypp_conf.scr
+ * Summary:
+ * SCR Agent for reading/writing /etc/zypp/zypp.conf file
+ * using the ini-agent
+ * Access:
+ * read/write
+ * Authors:
+ * Ladislav Slezak total_sizes_per_cd_per_src = []; // total sizes per inst-src: [ [42, 43, 44], [12, 13, 14] ]
global list
remaining_sizes_per_cd_per_src = []; // remaining sizes
@@ -28,6 +29,9 @@
global string media_type = _("Medium %1");
global integer total_size_installed = 0;
global integer total_size_to_install = 0;
+ global integer total_count_to_download = 0;
+ global integer total_count_downloaded = 0;
+ global integer downloading_pct = 0;
global integer min_time_per_cd = 10; // const - minimum time displayed per CD if there is something to install
global integer max_time_per_cd = 7200; // const - seconds to cut off predicted time (it's bogus anyway)
global integer size_column = 1; // const - column number for remaining size per CD
@@ -47,6 +51,8 @@
string provide_name = ""; // currently downlaoded package name
string provide_size = ""; // currently downlaoded package size
+ boolean download_in_advance_mode = false;
+
// package summary
// package counters
@@ -405,6 +411,50 @@
y2milestone( "SubtractPackageSize( %1 ) -> %2", pkg_size, remaining_sizes_per_cd_per_src);
}
+ integer packages_to_download(list
src_mapping)
+ {
+ y2milestone("Packages to download input: %1", src_mapping);
+
+ integer ret = 0;
+
+ integer i = 0;
+ foreach(list<integer> media_mapping, src_mapping,
+ {
+ if (size(media_mapping) > 0)
+ {
+ // check if the repository is remote
+ string repo_url = Pkg::SourceGeneralData(i)["url"]:"";
+ string repo_schema = tolower(URL::Parse(repo_url)["scheme"]:"");
+
+ if (contains(["http", "https", "ftp", "sftp"], repo_schema))
+ {
+ integer total = 0;
+ foreach(integer count, media_mapping,
+ {
+ total = total + count;
+ }
+ );
+
+ y2milestone("Downloading %1 packages from remote repository %2", total, i);
+ ret = ret + total;
+ }
+ }
+
+ i = i + 1;
+ }
+ );
+
+ y2milestone("Total number of packages to download: %1", ret);
+
+ return ret;
+ }
+
+ integer packages_to_install(list
src_mapping)
+ {
+ integer ret = ListSum(flatten(src_mapping));
+ y2milestone("Total number of packages to install: %1", ret);
+ return ret;
+ }
/**
* Initialize internal pacakge data, such as remaining package sizes and
@@ -454,6 +504,11 @@
remaining_sizes_per_cd_per_src = (list
) eval (total_sizes_per_cd_per_src);
remaining_pkg_count_per_cd_per_src = (list
) eval (total_pkg_count_per_cd_per_src);
total_cd_count = size( flatten( total_sizes_per_cd_per_src ) );
+ total_count_to_download = packages_to_download(total_pkg_count_per_cd_per_src);
+ total_count_downloaded = 0;
+ integer total_count_to_install = packages_to_install(total_pkg_count_per_cd_per_src);
+ downloading_pct = 100 * total_count_to_download / (total_count_to_install + total_count_to_download);
+ download_in_advance_mode= (string)SCR::Read(.etc.zypp_conf.value.main."commit.downloadMode") == "DownloadInAdvance";
init_pkg_data_complete = true;
// reset the history log
@@ -783,6 +838,27 @@
}
}
+ // update the overall progress value (download + installation)
+ void UpdateTotalProgressValue()
+ {
+ integer total_progress = 0;
+
+ if (total_count_to_download == 0)
+ {
+ // no package to download, just use the install size
+ total_progress = (TotalInstalledSize() * 100 / total_size_to_install);
+ }
+ else
+ {
+ // compute the total progress (use both download and installation size)
+ total_progress = (total_count_downloaded * downloading_pct / total_count_to_download) +
+ (TotalInstalledSize() * (100 - downloading_pct) / total_size_to_install);
+ }
+
+ y2internal("Total package installation progress: %1%%", total_progress);
+ SlideShow::StageProgress( total_progress, nil );
+ }
+
/**
* Update progress widgets
**/
@@ -796,7 +872,8 @@
total_size_to_install_kB = 1;
}
- SlideShow::StageProgress( ( TotalInstalledSize() >> 10 ) * 100 / total_size_to_install_kB, nil /*, SlideShow::GetProgressLabel()*/ );
+ // update the overall progress value (download + installation)
+ UpdateTotalProgressValue();
UpdateCurrentCdProgress(silent_check);
@@ -943,6 +1020,21 @@
if (error == 0)
{
total_downloaded = total_downloaded + current_provide_size;
+
+ total_count_downloaded = total_count_downloaded + 1;
+ y2milestone("Downloaded %1/%2 packages (%3%%)", total_count_downloaded, total_count_to_download, total_count_downloaded * 100 / total_count_to_download);
+
+ // move the progress also for downloaded files
+ UpdateTotalProgressValue();
+
+ if (download_in_advance_mode)
+ {
+ // display download progress in DownloadInAdvance mode
+ // translations: progress message (part1)
+ SlideShow::SetGlobalProgressLabel( _("Downloading Packages...") +
+ // progress message (part2)
+ sformat(_(" (Downloaded %1 of %2 packages)"), total_count_downloaded, total_count_to_download));
+ }
}
}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
lslezak@svn2.opensuse.org