[zypp-commit] r8821 - in /trunk/zypper/src: zypper-misc.cc zypper-misc.h zypper-repos.cc zypper-repos.h zypper.cc
Author: jkupec Date: Tue Feb 19 17:55:01 2008 New Revision: 8821 URL: http://svn.opensuse.org/viewcvs/zypp?rev=8821&view=rev Log: - zypper-misc:cond_init_target -> zypper-repos:init_target Modified: trunk/zypper/src/zypper-misc.cc trunk/zypper/src/zypper-misc.h trunk/zypper/src/zypper-repos.cc trunk/zypper/src/zypper-repos.h trunk/zypper/src/zypper.cc Modified: trunk/zypper/src/zypper-misc.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-misc.cc?rev=8821&r1=8820&r2=8821&view=diff ============================================================================== --- trunk/zypper/src/zypper-misc.cc (original) +++ trunk/zypper/src/zypper-misc.cc Tue Feb 19 17:55:01 2008 @@ -39,34 +39,6 @@ extern ZYpp::Ptr God; extern RuntimeData gData; - -void cond_init_target (Zypper & zypper) { - static bool done = false; - //! \todo do this so that it works in zypper shell - if (!done) { - cout_v << _("Initializing Target") << endl; - - try - { - God->initializeTarget(zypper.globalOpts().root_dir); - } - catch (const Exception & e) - { - report_problem(e, - _("Target initialization failed:"), - geteuid() != 0 ? - _("Running 'zypper refresh' as root might resolve the problem."):"" - ); - - zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP); - throw ExitRequestException( - "Target initialization failed: " + e.msg()); - } - - done = true; - } -} - // converts a user-supplied kind to a zypp kind object // returns an empty one if not recognized ResObject::Kind string_to_kind (const string &skind) Modified: trunk/zypper/src/zypper-misc.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-misc.h?rev=8821&r1=8820&r2=8821&view=diff ============================================================================== --- trunk/zypper/src/zypper-misc.h (original) +++ trunk/zypper/src/zypper-misc.h Tue Feb 19 17:55:01 2008 @@ -16,11 +16,6 @@ #include "zypper-tabulator.h" -/** - * Initialize rpm database on target, if not already initialized. - */ -void cond_init_target(Zypper & zypper); - /// Parse a capability string. On error print a message and return noCap zypp::Capability safe_parse_cap (const Zypper & zypper, const zypp::ResObject::Kind &kind, Modified: trunk/zypper/src/zypper-repos.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-repos.cc?rev=8821&r1=8820&r2=8821&view=diff ============================================================================== --- trunk/zypper/src/zypper-repos.cc (original) +++ trunk/zypper/src/zypper-repos.cc Tue Feb 19 17:55:01 2008 @@ -22,7 +22,6 @@ #include "zypper-callbacks.h" #include "zypper-utils.h" #include "zypper-repos.h" -#include "zypper-misc.h" using namespace std; using namespace boost; @@ -327,7 +326,7 @@ MIL << "Going to initialize repositories." << endl; // load gpg keys - cond_init_target(zypper); + init_target(zypper); RepoManager manager(zypper.globalOpts().rm_options); // get repositories specified with --repo or --catalog @@ -472,6 +471,35 @@ // ---------------------------------------------------------------------------- +void init_target (Zypper & zypper) { + static bool done = false; + //! \todo do this so that it works in zypper shell + if (!done) { + cout_v << _("Initializing Target") << endl; + + try + { + God->initializeTarget(zypper.globalOpts().root_dir); + } + catch (const Exception & e) + { + report_problem(e, + _("Target initialization failed:"), + geteuid() != 0 ? + _("Running 'zypper refresh' as root might resolve the problem."):"" + ); + + zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP); + throw ExitRequestException( + "Target initialization failed: " + e.msg()); + } + + done = true; + } +} + +// ---------------------------------------------------------------------------- + static void print_rug_sources_list(const std::listzypp::RepoInfo &repos) { Table tbl; @@ -642,7 +670,7 @@ void refresh_repos(Zypper & zypper) { // need gpg keys when downloading (#304672) - cond_init_target(zypper); + init_target(zypper); RepoManager manager(zypper.globalOpts().rm_options); list<RepoInfo> repos; Modified: trunk/zypper/src/zypper-repos.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-repos.h?rev=8821&r1=8820&r2=8821&view=diff ============================================================================== --- trunk/zypper/src/zypper-repos.h (original) +++ trunk/zypper/src/zypper-repos.h Tue Feb 19 17:55:01 2008 @@ -8,6 +8,11 @@ #include "zypper.h" /** + * Initialize rpm database on target, if not already initialized. + */ +void init_target(Zypper & zypper); + +/** * Reads known enabled repositories and stores them in gData. * This command also refreshes repos with auto-refresh enabled. * Modified: trunk/zypper/src/zypper.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper.cc?rev=8821&r1=8820&r2=8821&view=diff ============================================================================== --- trunk/zypper/src/zypper.cc (original) +++ trunk/zypper/src/zypper.cc Tue Feb 19 17:55:01 2008 @@ -1518,7 +1518,7 @@ warn_if_zmd(); // load gpg keys - cond_init_target(*this); + init_target(*this); add_repo_by_url( *this, url, _arguments[1]/*alias*/, type, enabled, refresh); @@ -1649,7 +1649,7 @@ return; } -// cond_init_target(*this); +// init_target(*this); warn_if_zmd (); try { // also stores it @@ -1887,7 +1887,7 @@ } // prepare target - cond_init_target(*this); + init_target(*this); // load metadata cond_load_resolvables(*this); @@ -1949,7 +1949,7 @@ if (exitCode() != ZYPPER_EXIT_OK) return; - cond_init_target(*this); + init_target(*this); // load only repo resolvables, we don't need the installed ones load_repo_resolvables(*this); @@ -1974,7 +1974,7 @@ if (exitCode() != ZYPPER_EXIT_OK) return; - cond_init_target(*this); + init_target(*this); // load only repo resolvables, we don't need the installed ones load_repo_resolvables(*this); build_deps_install(_arguments); @@ -2034,7 +2034,7 @@ if (exitCode() != ZYPPER_EXIT_OK) return; - cond_init_target(*this); + init_target(*this); // now load resolvables: cond_load_resolvables(*this); @@ -2085,7 +2085,7 @@ return; } - cond_init_target(*this); + init_target(*this); init_repos(*this); if (exitCode() != ZYPPER_EXIT_OK) @@ -2127,7 +2127,7 @@ return; } - cond_init_target(*this); + init_target(*this); init_repos(*this); if (exitCode() != ZYPPER_EXIT_OK) return; @@ -2169,7 +2169,7 @@ out().warning( _("Running as 'rug', can't do 'best-effort' approach to update.")); } - cond_init_target(*this); + init_target(*this); init_repos(*this); if (exitCode() != ZYPPER_EXIT_OK) return; @@ -2187,7 +2187,7 @@ else if (command() == ZypperCommand::XML_LIST_UPDATES_PATCHES) { if (runningHelp()) { out().info(_command_help, Out::QUIET); return; } - cond_init_target(*this); + init_target(*this); init_repos(*this); if (exitCode() != ZYPPER_EXIT_OK) return; @@ -2253,7 +2253,7 @@ out().warning( _("Running as 'rug', can't do 'best-effort' approach to update.")); } - cond_init_target(*this); + init_target(*this); init_repos(*this); if (exitCode() != ZYPPER_EXIT_OK) return; @@ -2308,7 +2308,7 @@ if (copts.count("auto-agree-with-licenses")) _cmdopts.license_auto_agree = true; - cond_init_target(*this); + init_target(*this); init_repos(*this); if (exitCode() != ZYPPER_EXIT_OK) return; @@ -2379,7 +2379,7 @@ } } - cond_init_target(*this); + init_target(*this); init_repos(*this); if (exitCode() != ZYPPER_EXIT_OK) return; -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org
participants (1)
-
jkupec@svn.opensuse.org