From 39cc81fb1bf296c5641228df8f5ebb0c58278ddf Mon Sep 17 00:00:00 2001 From: Jan Kupec Date: Thu, 7 Jun 2007 12:07:50 +0000 Subject: [PATCH] - backup - zypper install/remove modified to load repo resolvables from db cache (init_repos() and load_repo_resolvables() added - just a quick hack, will clean up the code later) - not working ATM --- src/zmart-misc.cc | 45 +++++++++++++++++++++++++++++++++++++++++++-- src/zmart-misc.h | 1 + src/zmart-sources.cc | 42 ++++++++++++++++++++++++++++++++++++++++++ src/zmart-sources.h | 5 +++-- src/zmart.h | 4 ++++ src/zypper.cc | 36 ++++++++++++++++++++---------------- 6 files changed, 113 insertions(+), 20 deletions(-) diff --git a/src/zmart-misc.cc b/src/zmart-misc.cc index 7796e8e..bb175b0 100644 --- a/src/zmart-misc.cc +++ b/src/zmart-misc.cc @@ -8,6 +8,10 @@ #include #include +#include +#include +#include + using namespace zypp::detail; using namespace std; @@ -401,9 +405,10 @@ std::string calculate_token() void cond_load_resolvables () { - // something changed + // load repository resolvables load_sources(); - + + // load target resolvables if ( ! gSettings.disable_system_resolvables ) { load_target(); } @@ -431,6 +436,42 @@ void load_sources() } } + +/** read repository resolvables */ +void load_repo_resolvables() +{ + RepoManager manager; + + for (std::list::iterator it = gData.repos.begin(); + it != gData.repos.end(); ++it) + { + RepoInfo repo(*it); + + if (! it->enabled()) + continue; // #217297 + + Repository repository; + + try { + repository = manager.createFromCache(repo); + } + catch ( const repo::RepoNotCachedException &e ) + { + ZYPP_CAUGHT(e); + cout_v << "Repository " << repo.alias() << " not cached. Caching..." << endl; + manager.buildCache(repo); + repository = manager.createFromCache(repo); + } + + ResStore store = repository.resolvables(); + //! \todo use format + cout_vv << "(" << store.size() << " resolvables found)" << endl; + + God->addResolvables(store); + } + +} + void establish () { cerr_v << _("Establishing status of aggregates") << endl; diff --git a/src/zmart-misc.h b/src/zmart-misc.h index 73640df..641071c 100644 --- a/src/zmart-misc.h +++ b/src/zmart-misc.h @@ -29,6 +29,7 @@ std::string calculate_token(); void cond_load_resolvables (); void load_target(); void load_sources(); +void load_repo_resolvables(); void establish (); bool resolve(); void dump_pool (); diff --git a/src/zmart-sources.cc b/src/zmart-sources.cc index 06f6a1c..390cfe8 100644 --- a/src/zmart-sources.cc +++ b/src/zmart-sources.cc @@ -10,6 +10,9 @@ #include #include +#include +#include + using namespace zypp::detail; @@ -38,7 +41,22 @@ void cond_init_system_sources () } done = true; } +/* +void cond_init_system_sources () +{ + static bool done = false; + //! \todo this has to be done so that it works in zypper shell + if (done) + return; + if ( ! gSettings.disable_system_sources ) { + init_system_sources(); + } + + done = true; +} +*/ +// OLD void init_system_sources() { SourceManager_Ptr manager; @@ -65,6 +83,30 @@ void init_system_sources() } } +/** reads known repositories and stores them into gData, does refresh */ +void init_repos() +{ + RepoManager manager; + gData.repos = manager.knownRepositories(); + + for (std::list::iterator it = gData.repos.begin(); + it != gData.repos.end(); ++it) + { + RepoInfo repo(*it); + +// bool do_refresh = repo.autorefresh(); //! \todo honor command line options/commands + bool do_refresh = false; + + if (do_refresh) + { + //! \todo progress reporting + cout << "Refreshing " << repo.alias() << endl; + manager.refreshMetadata(repo); + } + } +} + + void include_source_by_url( const Url &url ) { try diff --git a/src/zmart-sources.h b/src/zmart-sources.h index 7f65f4b..7234656 100644 --- a/src/zmart-sources.h +++ b/src/zmart-sources.h @@ -13,8 +13,9 @@ #include "zypp/Url.h" //! calls init_system_sources if not disabled by user (or non-root) -void cond_init_system_sources(); -void init_system_sources(); +void cond_init_system_sources(); // OLD +void init_system_sources(); // OLD +void init_repos(); void include_source_by_url( const zypp::Url &url ); bool parse_repo_file (const std::string& file, std::string& url, std::string& alias); void add_source_by_url( const zypp::Url &url, const std::string &alias, diff --git a/src/zmart.h b/src/zmart.h index 211318c..cf26949 100644 --- a/src/zmart.h +++ b/src/zmart.h @@ -23,6 +23,8 @@ #include #include +#include + #define ZYPP_CHECKPATCHES_LOG "/var/log/zypper.log" #undef ZYPP_BASE_LOGGER_LOGGROUP #define ZYPP_BASE_LOGGER_LOGGROUP "zypper" @@ -84,7 +86,9 @@ struct RuntimeData {} std::list errors; + // deprecated std::list sources; + std::list repos; int patches_count; int security_patches_count; std::vector packages_to_install; diff --git a/src/zypper.cc b/src/zypper.cc index 00eab5f..454a08e 100644 --- a/src/zypper.cc +++ b/src/zypper.cc @@ -693,13 +693,11 @@ int one_command(const string& command, int argc, char **argv) // --------------------------( remove/install )----------------------------- else if (command == "install" || command == "in" || - command == "remove" || command == "rm") { + command == "remove" || command == "rm") { if (command == "install" || command == "in") { if (ghelp || arguments.size() < 1) { - cerr << "install [options] name...\n" - << specific_help - ; + cerr << "install [options] name...\n" << specific_help; return !ghelp; } @@ -717,6 +715,7 @@ int one_command(const string& command, int argc, char **argv) gData.packages_to_uninstall = arguments; } + // read resolvable type string skind = copts.count("type")? copts["type"].front() : "package"; kind = string_to_kind (skind); if (kind == ResObject::Kind ()) { @@ -724,27 +723,32 @@ int one_command(const string& command, int argc, char **argv) return ZYPPER_EXIT_ERR_INVALID_ARGS; } - cond_init_system_sources (); + init_repos(); + //! \todo support temporary additional sources + /* for ( std::list::const_iterator it = gSettings.additional_sources.begin(); it != gSettings.additional_sources.end(); ++it ) - { - include_source_by_url( *it ); - } - - if ( gData.sources.empty() ) - { - cerr << _("Warning: No sources. Operating only with the installed resolvables. Nothing can be installed.") << endl; - } + { + include_source_by_url( *it ); + } + */ + + if ( gData.repos.empty() ) + { + cerr << _("Warning: No sources. Operating only with the installed resolvables. Nothing can be installed.") << endl; + } cond_init_target (); - cond_load_resolvables (); + cout_v << "loading repo resolvables... "; + load_repo_resolvables(); + cout_v << "DONE" << endl; for ( vector::const_iterator it = arguments.begin(); it != arguments.end(); ++it ) { if (command == "install" || command == "in") { - mark_for_install(kind, *it); + mark_for_install(kind, *it); } else { - mark_for_uninstall(kind, *it); + mark_for_uninstall(kind, *it); } } -- 2.7.4