From 71127eca7154b068e9024aafe1747b4948e9ae58 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A1n=20Kupec?= Date: Mon, 25 Oct 2010 12:01:28 +0200 Subject: [PATCH] Tell about download-only switched on (bnc #648606) --- src/Summary.cc | 35 ++++++++++++++++++++++------------- src/Summary.h | 3 +++ src/solve-commit.cc | 3 +++ src/utils/misc.cc | 7 +++++-- src/utils/misc.h | 2 +- 5 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/Summary.cc b/src/Summary.cc index 95754f4..2fa8241 100644 --- a/src/Summary.cc +++ b/src/Summary.cc @@ -44,7 +44,11 @@ bool Summary::ResPairNameCompare::operator()( // -------------------------------------------------------------------------- Summary::Summary(const zypp::ResPool & pool, const ViewOptions options) - : _viewop(options), _show_repo_alias(false), _wrap_width(80), _force_no_color(false) + : _viewop(options) + , _show_repo_alias(false) + , _wrap_width(80) + , _force_no_color(false) + , _download_only(false) { readPool(pool); } @@ -959,20 +963,25 @@ void Summary::writeDownloadAndInstalledSizeSummary(ostream & out) if (_todownload > 0) s << format(_("Overall download size: %s.")) % _todownload << " "; - // installed size change info - if (_inst_size_change > 0) - // TrasnlatorExplanation %s will be substituted by a byte count e.g. 212 K - s << format(_("After the operation, additional %s will be used.")) - % _inst_size_change.asString(0,1,1); - else if (_inst_size_change == 0) - s << _("No additional space will be used or freed after the operation."); + if (_download_only) + s << _("Download only."); else { - // get the absolute size - ByteCount abs; - abs = (-_inst_size_change); - // TrasnlatorExplanation %s will be substituted by a byte count e.g. 212 K - s << format(_("After the operation, %s will be freed.")) % abs.asString(0,1,1); + // installed size change info + if (_inst_size_change > 0) + // TrasnlatorExplanation %s will be substituted by a byte count e.g. 212 K + s << format(_("After the operation, additional %s will be used.")) + % _inst_size_change.asString(0,1,1); + else if (_inst_size_change == 0) + s << _("No additional space will be used or freed after the operation."); + else + { + // get the absolute size + ByteCount abs; + abs = (-_inst_size_change); + // TrasnlatorExplanation %s will be substituted by a byte count e.g. 212 K + s << format(_("After the operation, %s will be freed.")) % abs.asString(0,1,1); + } } mbs_write_wrapped(out, s.str(), 0, _wrap_width); diff --git a/src/Summary.h b/src/Summary.h index 8e55f61..35ff4de 100644 --- a/src/Summary.h +++ b/src/Summary.h @@ -69,6 +69,8 @@ public: { _show_repo_alias = value; } void setForceNoColor(bool value = true) { _force_no_color = value; } + void setDownloadOnly(bool value = true) + { _download_only = value; } void writeNewlyInstalled(std::ostream & out); void writeRemoved(std::ostream & out); @@ -118,6 +120,7 @@ private: bool _show_repo_alias; mutable unsigned _wrap_width; bool _force_no_color; + bool _download_only; bool _need_reboot; bool _need_restart; diff --git a/src/solve-commit.cc b/src/solve-commit.cc index 5a8553d..9dfd66d 100755 --- a/src/solve-commit.cc +++ b/src/solve-commit.cc @@ -581,6 +581,9 @@ void solve_and_commit (Zypper & zypper) summary.setShowRepoAlias(zypper.config().show_alias); + if (get_download_option(zypper, true) == DownloadOnly) + summary.setDownloadOnly(true); + // show the summary if (zypper.out().type() == Out::TYPE_XML) summary.dumpAsXmlTo(cout); diff --git a/src/utils/misc.cc b/src/utils/misc.cc index 90c957b..2d94d52 100644 --- a/src/utils/misc.cc +++ b/src/utils/misc.cc @@ -516,7 +516,7 @@ void list_processes_using_deleted_files(Zypper & zypper) // ---------------------------------------------------------------------------- -DownloadMode get_download_option(Zypper & zypper) +DownloadMode get_download_option(Zypper & zypper, bool quiet) { DownloadMode mode; DownloadMode zconfig = ZConfig::instance().commit_downloadMode(); @@ -557,7 +557,7 @@ DownloadMode get_download_option(Zypper & zypper) } // warn about the override, both were specified - if (!download.empty() && + if (!quiet && !download.empty() && (zypper.cOpts().count("download-only") || zypper.cOpts().count("download-in-advance") || zypper.cOpts().count("download-in-heaps") || @@ -567,6 +567,9 @@ DownloadMode get_download_option(Zypper & zypper) str::form(_("Option '%s' overrides '%s'."), "--download", "--download-*")); } + if (quiet) + return mode; + MIL << "Download mode: "; if (mode == DownloadInAdvance) MIL << "in-advance"; else if (mode == DownloadInHeaps) MIL << "in-heaps"; diff --git a/src/utils/misc.h b/src/utils/misc.h index fce9d27..f2274c8 100644 --- a/src/utils/misc.h +++ b/src/utils/misc.h @@ -141,7 +141,7 @@ void list_processes_using_deleted_files(Zypper & zypper); * Check whether one of --download-* or --download options was given and return * the specified mode. */ -zypp::DownloadMode get_download_option(Zypper & zypper); +zypp::DownloadMode get_download_option(Zypper & zypper, bool quiet = false); /** Check whether packagekit is running using a DBus call */ bool packagekit_running(); -- 2.7.4