ref: refs/heads/master commit 9d8903e9f8a99c5b19a76c2b02f47b74e855575a Author: Ján Kupec <jkupec@suse.cz> Date: Fri Nov 20 15:11:44 2009 +0100 --download option added to in, up, dup, ve, and patch. --- src/Zypper.cc | 18 ++++++++++++++++++ src/solve-commit.cc | 7 ++----- src/utils/misc.cc | 28 ++++++++++++++++++++++++++++ src/utils/misc.h | 3 +++ 4 files changed, 51 insertions(+), 5 deletions(-) diff --git a/src/Zypper.cc b/src/Zypper.cc index ea0292b..9777849 100644 --- a/src/Zypper.cc +++ b/src/Zypper.cc @@ -917,6 +917,7 @@ void Zypper::processCommandOptions() {"no-recommends", no_argument, 0, 0 }, {"recommends", no_argument, 0, 0 }, {"download-only", no_argument, 0, 'd'}, + {"download", required_argument, 0, 0 }, // rug compatibility - will mark all packages for installation (like 'in *') {"entire-catalog", required_argument, 0, 0 }, {"help", no_argument, 0, 'h'}, @@ -1036,6 +1037,7 @@ void Zypper::processCommandOptions() // rug uses -N shorthand {"dry-run", no_argument, 0, 'N'}, {"download-only", no_argument, 0, 'd'}, + {"download", required_argument, 0, 0}, {"repo", required_argument, 0, 'r'}, {"no-recommends", no_argument, 0, 0}, {"help", no_argument, 0, 'h'}, @@ -1066,6 +1068,7 @@ void Zypper::processCommandOptions() static struct option options[] = { {"dry-run", no_argument, 0, 'D'}, {"download-only", no_argument, 0, 'd'}, + {"download", required_argument, 0, 0}, {"repo", required_argument, 0, 'r'}, {"debug-solver", no_argument, 0, 0}, {"help", no_argument, 0, 'h'}, @@ -1540,6 +1543,7 @@ void Zypper::processCommandOptions() // rug uses -N shorthand {"dry-run", no_argument, 0, 'N'}, {"download-only", no_argument, 0, 'd'}, + {"download", required_argument, 0, 0 }, // rug-compatibility - dummy for now //! \todo category can now be implemented in 'patch' using PoolQuery {"category", no_argument, 0, 'g'}, @@ -1593,6 +1597,7 @@ void Zypper::processCommandOptions() {"recommends", no_argument, 0, 0 }, {"dry-run", no_argument, 0, 'D'}, {"download-only", no_argument, 0, 'd'}, + {"download", required_argument, 0, 0 }, {"bz", required_argument, 0, 'b'}, {"bugzilla", required_argument, 0, 'b'}, {"cve", required_argument, 0, 0 }, @@ -1669,6 +1674,7 @@ void Zypper::processCommandOptions() // rug uses -N shorthand {"dry-run", no_argument, 0, 'N'}, {"download-only", no_argument, 0, 'd'}, + {"download", required_argument, 0, 0 }, {"help", no_argument, 0, 'h'}, {0, 0, 0, 0} }; @@ -3143,6 +3149,9 @@ void Zypper::doCommand() bool install_not_remove = command() == ZypperCommand::INSTALL; + // parse the download options to check for errors + get_download_option(*this); + initRepoManager(); // check for rpm files among the arguments @@ -3324,6 +3333,9 @@ void Zypper::doCommand() if (copts.count("no-confirm")) _gopts.non_interactive = true; + // parse the download options to check for errors + get_download_option(*this); + initRepoManager(); init_repos(*this); @@ -3780,6 +3792,9 @@ void Zypper::doCommand() Out::HIGH); } + // parse the download options to check for errors + get_download_option(*this); + init_target(*this); initRepoManager(); @@ -3828,6 +3843,9 @@ void Zypper::doCommand() return; } + // parse the download options to check for errors + get_download_option(*this); + initRepoManager(); if (!copts.count("repo") && !copts.count("from") diff --git a/src/solve-commit.cc b/src/solve-commit.cc index 37a79c9..fd9fab9 100755 --- a/src/solve-commit.cc +++ b/src/solve-commit.cc @@ -398,11 +398,8 @@ ZYppCommitPolicy get_commit_policy(Zypper & zypper) if (zypper.cOpts().count("dry-run")) policy.dryRun(true); - if (zypper.cOpts().count("download-only")) - policy.downloadMode(DownloadOnly); - //! \todo make this configurable - //else - // policy.downloadMode(DownloadInAdvance); + if (zypper.cOpts().count("download-only") || zypper.cOpts().count("download")) + policy.downloadMode(get_download_option(zypper)); policy.syncPoolAfterCommit(policy.dryRun() ? false : zypper.runningShell()); diff --git a/src/utils/misc.cc b/src/utils/misc.cc index d0f278c..e40b742 100644 --- a/src/utils/misc.cc +++ b/src/utils/misc.cc @@ -478,3 +478,31 @@ void list_processes_using_deleted_files(Zypper & zypper) "man zypper")); } } + +DownloadMode get_download_option(Zypper & zypper) +{ + if (!zypper.cOpts().count("download") && + !zypper.cOpts().count("download-only")) + return DownloadDefault; //! \todo FIXME return ZConfig value + + string download; + parsed_opts::const_iterator it = zypper.cOpts().find("download"); + if (it != zypper.cOpts().end()) + download = it->second.front(); + if (zypper.cOpts().count("download-only") || download == "only") + return DownloadOnly; + else if (download == "in-advance") + return DownloadInAdvance; + else if (download == "in-heaps") + return DownloadInHeaps; + else if (download == "as-needed") + return DownloadAsNeeded; + else + { + zypper.out().error(str::form(_("Unknown download mode '%s'."), download.c_str())); + zypper.out().info(str::form(_("Available download modes: %s"), + "only, in-advance, in-heaps, as-needed")); + zypper.setExitCode(ZYPPER_EXIT_ERR_INVALID_ARGS); + throw ExitRequestException("Unknown download mode"); + } +} diff --git a/src/utils/misc.h b/src/utils/misc.h index 4291b8c..eaf8860 100644 --- a/src/utils/misc.h +++ b/src/utils/misc.h @@ -18,6 +18,7 @@ #include "zypp/Capability.h" #include "zypp/ResKind.h" #include "zypp/RepoInfo.h" +#include "zypp/ZYppCommitPolicy.h" class Zypper; @@ -129,4 +130,6 @@ std::string asXML(const zypp::Pattern & p, bool is_installed); */ void list_processes_using_deleted_files(Zypper & zypper); +zypp::DownloadMode get_download_option(Zypper & zypper); + #endif /*ZYPPER_UTILS_H*/ -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org