[yast-commit] r64900 - in /branches/SuSE-Code-11-SP1-Branch/pkg-bindings: ./ package/yast2-pkg-bindings.changes src/Package.cc src/PkgFunctions.cc src/PkgFunctions.h

Author: lslezak Date: Tue Jul 19 20:39:23 2011 New Revision: 64900 URL: http://svn.opensuse.org/viewcvs/yast?rev=64900&view=rev Log: backport from SP2 branch: - implemented download in advance mode support for yast2-wagon (fate#308951) Modified: branches/SuSE-Code-11-SP1-Branch/pkg-bindings/ (props changed) branches/SuSE-Code-11-SP1-Branch/pkg-bindings/package/yast2-pkg-bindings.changes branches/SuSE-Code-11-SP1-Branch/pkg-bindings/src/Package.cc branches/SuSE-Code-11-SP1-Branch/pkg-bindings/src/PkgFunctions.cc branches/SuSE-Code-11-SP1-Branch/pkg-bindings/src/PkgFunctions.h Modified: branches/SuSE-Code-11-SP1-Branch/pkg-bindings/package/yast2-pkg-bindings.changes URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/pkg-bi... ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/pkg-bindings/package/yast2-pkg-bindings.changes (original) +++ branches/SuSE-Code-11-SP1-Branch/pkg-bindings/package/yast2-pkg-bindings.changes Tue Jul 19 20:39:23 2011 @@ -1,5 +1,7 @@ ------------------------------------------------------------------- +- added Pkg::CommitPolicy() +- support for download in advance mode in yast2-wagon (fate#308951) - added Pkg::Commit() function which accepts commit options map (with download_mode, dry_run... options) (FATE#308951) - added Pkg::ZConfig() function returning current libzypp config Modified: branches/SuSE-Code-11-SP1-Branch/pkg-bindings/src/Package.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/pkg-bi... ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/pkg-bindings/src/Package.cc (original) +++ branches/SuSE-Code-11-SP1-Branch/pkg-bindings/src/Package.cc Tue Jul 19 20:39:23 2011 @@ -2015,7 +2015,7 @@ return YCPVoid(); } -YCPValue PkgFunctions::CommitHelper(const zypp::ZYppCommitPolicy &policy) +YCPValue PkgFunctions::CommitHelper(const zypp::ZYppCommitPolicy *policy) { zypp::ZYpp::CommitResult result; @@ -2029,7 +2029,7 @@ last_reported_repo = -1; last_reported_mediumnr = 1; - result = zypp_ptr()->commit(policy); + result = zypp_ptr()->commit(*policy); } catch (const zypp::target::TargetAbortedException & excpt) { @@ -2093,6 +2093,48 @@ return ret; } +YCPValue PkgFunctions::CommitPolicy() +{ + YCPMap ret; + + if (commit_policy == NULL) + { + return ret; + } + + zypp::DownloadMode d_mode = commit_policy->downloadMode(); + std::string mode; + + switch (d_mode) + { + case zypp::DownloadDefault: + mode = "default"; + break; + case zypp::DownloadOnly: + mode = "download_only"; + break; + case zypp::DownloadInAdvance: + mode = "download_in_advance"; + break; + case zypp::DownloadInHeaps: + mode = "download_in_heaps"; + break; + case zypp::DownloadAsNeeded: + mode = "download_as_needed"; + break; + default : + y2error("Unknown download mode"); + } + + if (!mode.empty()) + { + ret->add(YCPString("download_mode"), YCPSymbol(mode)); + } + + + return ret; +} + /** @builtin PkgCommit @@ -2118,10 +2160,15 @@ return YCPError ("Bad args to Pkg::PkgCommit"); } - zypp::ZYppCommitPolicy policy; - policy.restrictToMedia( medianr ); + commit_policy = new zypp::ZYppCommitPolicy; + commit_policy->restrictToMedia(medianr); + + YCPValue ret = CommitHelper(commit_policy); - return CommitHelper(policy); + delete commit_policy; + commit_policy = NULL; + + return ret; } /** @@ -2143,7 +2190,7 @@ /* TYPEINFO: list<any>(integer)*/ YCPValue PkgFunctions::Commit (const YCPMap& config) { - zypp::ZYppCommitPolicy policy; + commit_policy = new zypp::ZYppCommitPolicy; if (!config.isNull()) { @@ -2158,28 +2205,32 @@ if (mode == "default") { - policy.downloadMode(zypp::DownloadDefault); + commit_policy->downloadMode(zypp::DownloadDefault); } else if (mode == "download_only") { - policy.downloadMode(zypp::DownloadOnly); + commit_policy->downloadMode(zypp::DownloadOnly); } else if (mode == "download_in_advance") { - policy.downloadMode(zypp::DownloadInAdvance); + commit_policy->downloadMode(zypp::DownloadInAdvance); } else if (mode == "download_in_heaps") { - policy.downloadMode(zypp::DownloadInHeaps); + commit_policy->downloadMode(zypp::DownloadInHeaps); } else if (mode == "download_as_needed") { - policy.downloadMode(zypp::DownloadAsNeeded); + commit_policy->downloadMode(zypp::DownloadAsNeeded); } else { y2error("Invalid download mode: %s", mode.c_str()); _last_error.setLastError(std::string("Invalid download mode: ") + mode); + + delete commit_policy; + commit_policy = NULL; + return YCPVoid(); } @@ -2189,6 +2240,10 @@ { y2error("Invalid download mode: symbol is required, got: %s", config->value(key)->asString()->value().c_str()); _last_error.setLastError(std::string("Invalid download mode: ") + config->value(key)->asString()->value()); + + delete commit_policy; + commit_policy = NULL; + return YCPVoid(); } } @@ -2200,7 +2255,7 @@ if (config->value(key)->isInteger()) { unsigned medium_nr = config->value(key)->asInteger()->value(); - policy.restrictToMedia(medium_nr); + commit_policy->restrictToMedia(medium_nr); y2milestone("Restricting commit only to medium number: %u", medium_nr); } @@ -2208,6 +2263,10 @@ { y2error("Invalid medium number: integer is required, got: %s", config->value(key)->asString()->value().c_str()); _last_error.setLastError(std::string("Invalid medium number: ") + config->value(key)->asString()->value()); + + delete commit_policy; + commit_policy = NULL; + return YCPVoid(); } } @@ -2219,7 +2278,7 @@ if (config->value(key)->isBoolean()) { bool dry_run = config->value(key)->asBoolean()->value(); - policy.dryRun(dry_run); + commit_policy->dryRun(dry_run); y2milestone("Dry run commit: %s", config->value(key)->asString()->value().c_str()); } @@ -2227,6 +2286,10 @@ { y2error("Dry run option: boolean is required, got: %s", config->value(key)->asString()->value().c_str()); _last_error.setLastError(std::string("Invalid dry run option: ") + config->value(key)->asString()->value()); + + delete commit_policy; + commit_policy = NULL; + return YCPVoid(); } } @@ -2238,7 +2301,7 @@ if (config->value(key)->isBoolean()) { bool exclude_docs = config->value(key)->asBoolean()->value(); - policy.rpmExcludeDocs(exclude_docs); + commit_policy->rpmExcludeDocs(exclude_docs); y2milestone("Excluding documentation: %s", config->value(key)->asString()->value().c_str()); } @@ -2246,6 +2309,10 @@ { y2error("Exclude documentation option: boolean is required, got: %s", config->value(key)->asString()->value().c_str()); _last_error.setLastError(std::string("Invalid exclude documentation option: ") + config->value(key)->asString()->value()); + + delete commit_policy; + commit_policy = NULL; + return YCPVoid(); } } @@ -2257,7 +2324,7 @@ if (config->value(key)->isBoolean()) { bool no_signature = config->value(key)->asBoolean()->value(); - policy.rpmNoSignature(no_signature); + commit_policy->rpmNoSignature(no_signature); y2milestone("Don't check RPM signature: %s", config->value(key)->asString()->value().c_str()); } @@ -2265,12 +2332,21 @@ { y2error("No signature option: boolean is required, got: %s", config->value(key)->asString()->value().c_str()); _last_error.setLastError(std::string("Invalid no signature option: ") + config->value(key)->asString()->value()); + + delete commit_policy; + commit_policy = NULL; + return YCPVoid(); } } } - return CommitHelper(policy); + YCPValue ret = CommitHelper(commit_policy); + + delete commit_policy; + commit_policy = NULL; + + return ret; } /** Modified: branches/SuSE-Code-11-SP1-Branch/pkg-bindings/src/PkgFunctions.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/pkg-bi... ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/pkg-bindings/src/PkgFunctions.cc (original) +++ branches/SuSE-Code-11-SP1-Branch/pkg-bindings/src/PkgFunctions.cc Tue Jul 19 20:39:23 2011 @@ -61,6 +61,7 @@ _target_root( "/" ) , _target_loaded(false) , zypp_pointer(NULL) + , commit_policy(NULL) ,_callbackHandler( *new CallbackHandler(*this) ) , base_product(NULL) { Modified: branches/SuSE-Code-11-SP1-Branch/pkg-bindings/src/PkgFunctions.h URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/pkg-bi... ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/pkg-bindings/src/PkgFunctions.h (original) +++ branches/SuSE-Code-11-SP1-Branch/pkg-bindings/src/PkgFunctions.h Tue Jul 19 20:39:23 2011 @@ -49,6 +49,7 @@ #include <zypp/RepoManager.h> #include <zypp/ProgressData.h> #include <zypp/TmpPath.h> +#include <zypp/ZYppCommitPolicy.h> #include <YRepo.h> #include <i18n.h> @@ -195,6 +196,9 @@ YCPMap Resolvable2YCPMap(const zypp::PoolItem &item, const std::string &req_kind, bool dependencies); + // CommitPolicy used for commit + zypp::ZYppCommitPolicy *commit_policy; + private: /** @@ -705,11 +709,13 @@ YCPBoolean PkgSolveCheckTargetOnly (); /* TYPEINFO: integer()*/ YCPValue PkgSolveErrors (); - YCPValue CommitHelper(const zypp::ZYppCommitPolicy &policy); + YCPValue CommitHelper(const zypp::ZYppCommitPolicy *policy); /* TYPEINFO: list<any>(integer)*/ YCPValue PkgCommit (const YCPInteger& medianr); /* TYPEINFO: list<any>(map<string,any>)*/ YCPValue Commit (const YCPMap& config); + /* TYPEINFO: map<string,any>*/ + YCPValue CommitPolicy(); /* TYPEINFO: boolean(map<string,any>)*/ YCPValue AddLock(const YCPMap &lock); -- 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