Author: jkupec
Date: Tue Jun 19 18:53:46 2007
New Revision: 5798
URL: http://svn.opensuse.org/viewcvs/zypp?rev=5798&view=rev
Log:
Removed old source manager completely from all commands.
Modified:
trunk/zypper/src/zypp-checkpatches.cc
trunk/zypper/src/zypper-command.h
trunk/zypper/src/zypper-info.cc
trunk/zypper/src/zypper-info.h
trunk/zypper/src/zypper-misc.cc
trunk/zypper/src/zypper-misc.h
trunk/zypper/src/zypper-sources.cc
trunk/zypper/src/zypper-sources.h
trunk/zypper/src/zypper-updates.cc
trunk/zypper/src/zypper.cc
trunk/zypper/src/zypper.h
Modified: trunk/zypper/src/zypp-checkpatches.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypp-checkpatches.cc?rev=5798&r1=5797&r2=5798&view=diff
==============================================================================
--- trunk/zypper/src/zypp-checkpatches.cc (original)
+++ trunk/zypper/src/zypp-checkpatches.cc Tue Jun 19 18:53:46 2007
@@ -16,6 +16,7 @@
#include
#include
+#include
#include "checkpatches-keyring-callbacks.h"
#include "zypper.h"
@@ -84,11 +85,6 @@
}
-#ifdef LIBZYPP_1xx
-typedef zypp::SourceManager::SourceInfo SourceInfo;
-#else
-using zypp::source::SourceInfo;
-#endif
int exit_with_error( const std::string &error_str )
{
@@ -133,78 +129,52 @@
return exit_with_error(excpt_r.msg());
}
- SourceManager_Ptr manager;
- manager = SourceManager::sourceManager();
-
+ RepoManager manager;
+
KeyRingCallbacks keyring_callbacks;
DigestCallbacks digest_callbacks;
-#ifdef LIBZYPP_1xx
- // dont add rpms
- God->initTarget("/", true);
-#else
God->initializeTarget("/");
-#endif
std::string token;
stringstream token_stream;
-#ifdef LIBZYPP_1xx
- token_stream << "[" << "target" << "| " << Date::now() << "]"; // too bad
-#else
token_stream << "[" << "target" << "| " << God->target()->timestamp() << "]";
-#endif
- std::list<SourceInfo> new_sources = manager->knownSourceInfos("/");
- MIL << "Found " << new_sources.size() << " sources." << endl;
+ std::list<RepoInfo> new_sources = manager.knownRepositories();
+ MIL << "Found " << new_sources.size() << " repos." << endl;
- for ( std::list<SourceInfo>::iterator it = new_sources.begin(); it != new_sources.end(); ++it)
+ for (std::list<RepoInfo>::iterator it = new_sources.begin(); it != new_sources.end(); ++it)
{
-#ifdef LIBZYPP_1xx
- Url url = it->url;
-#else
- Url url = it->url();
-#endif
+ Url url = *(it->baseUrlsBegin());
std::string scheme( url.getScheme());
if ( (scheme == "cd" || scheme == "dvd") )
{
- MIL << "Skipping CD/DVD source: url:[" << it->url().asString() << "] product_dir:[" << it->path() << "] alias:[" << it->alias() << "] cache_dir:[" << it->cacheDir() << "] auto_refresh:[ " << it->autorefresh() << "]" << endl;
+ MIL << "Skipping CD/DVD source: url:[" << (it->baseUrlsBegin())->asString() << "] alias:[" << it->alias() << "] auto_refresh:[ " << it->autorefresh() << "]" << endl;
continue;
}
-
+
if ( ! it->enabled() )
{
- MIL << "Skipping disabled source: url:[" << url.asString() << "] product_dir:[" << it->path() << "] alias:[" << it->alias() << "] cache_dir:[" << it->cacheDir() << "] auto_refresh:[ " << it->autorefresh() << "]" << endl;
+ MIL << "Skipping disabled source: url:[" << url.asString() << "] alias:[" << it->alias() << "] auto_refresh:[ " << it->autorefresh() << "]" << endl;
continue;
}
// Note: Url(it->url).asString() to hide password in logs
- MIL << "Creating source: url:[" << url.asString() << "] product_dir:[" << it->path() << "] alias:[" << it->alias() << "] cache_dir:[" << it->cacheDir() << "] auto_refresh:[ " << it->autorefresh() << "]" << endl;
-
+ MIL << "Creating source: url:[" << url.asString() << "] alias:[" << it->alias() << "] auto_refresh:[ " << it->autorefresh() << "]" << endl;
+
try
{
- Source_Ref src = SourceFactory().createFrom(it->type(), url, it->path(), it->alias(), it->cacheDir(), false, it->autorefresh());
- src.refresh();
- token_stream << "[" << src.alias() << "| " << src.url() << src.timestamp() << "]";
-
- MIL << "Source: " << src.alias() << " from " << src.timestamp() << std::endl;
-
- // skip sources without patches sources for now
- bool has_patches = true;
-#ifndef LIBZYPP_1xx
- has_patches = src.hasResolvablesOfKind( ResTraitszypp::Patch::kind );
-#endif
- if ( has_patches )
- {
- MIL << "Including source " << src.url() << std::endl;
- gData.sources.push_back(src);
- }
- else
- {
- MIL << "Excluding source " << src.url() << " ( no patches ) "<< std::endl;
- }
+ manager.refreshMetadata(*it);
+ manager.buildCache(*it);
+
+ token_stream << "[" << it->alias() << "| " << *(it->baseUrlsBegin()) << "]"; // src.timestamp() << "]";
+
+ MIL << "Source: " << it->alias() << std::endl; //" from " << src.timestamp() << std::endl;
+
+ gData.repos.push_back(*it);
}
catch (const Exception &excpt_r )
{
@@ -213,7 +183,7 @@
gData.errors.push_back(str::form(_("Couldn't restore source.\nDetail: %s"), error.c_str()));
}
}
-
+
string previous_token;
if ( PathInfo(TOKEN_FILE).isExist() )
previous_token = read_old_token();
@@ -252,16 +222,17 @@
MIL << "System has changed, recalculation of updates needed" << endl;
}
- for ( std::list::const_iterator it = gData.sources.begin(); it != gData.sources.end(); ++it )
+ for ( std::list<RepoInfo>::const_iterator it = gData.repos.begin(); it != gData.repos.end(); ++it )
{
- God->addResolvables(it->resolvables());
+ Repository repository = manager.createFromCache(*it);
+ God->addResolvables(repository.resolvables());
}
-
- if ( gData.sources.size() == 0 )
+
+ if ( gData.repos.size() == 0 )
{
gData.errors.push_back( str::form( _( "There are no update sources defined. Please add one or more update sources in order to be notified of updates.") ) );
}
-
+
God->addResolvables( God->target()->resolvables(), true);
God->resolver()->establishPool();
Modified: trunk/zypper/src/zypper-command.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-command.h?rev=5798&r1=5797&r2=5798&view=diff
==============================================================================
--- trunk/zypper/src/zypper-command.h (original)
+++ trunk/zypper/src/zypper-command.h Tue Jun 19 18:53:46 2007
@@ -10,45 +10,54 @@
*/
struct ZypperCommand
{
- static const ZypperCommand NONE;
static const ZypperCommand ADD_REPO;
static const ZypperCommand REMOVE_REPO;
static const ZypperCommand LIST_REPOS;
static const ZypperCommand REFRESH;
- static const ZypperCommand SEARCH;
+
static const ZypperCommand INSTALL;
static const ZypperCommand REMOVE;
static const ZypperCommand UPDATE;
+ static const ZypperCommand SEARCH;
static const ZypperCommand INFO;
+ static const ZypperCommand LIST_UPDATES;
static const ZypperCommand HELP;
static const ZypperCommand SHELL;
static const ZypperCommand SHELL_QUIT;
static const ZypperCommand MOO;
-
- // rug commands
+
+ /** Special void command value meaning <b>not set</b> */
+ static const ZypperCommand NONE;
+
+ /** name rug commands */
+ //!@{
static const ZypperCommand RUG_PATCH_INFO;
+ //!@}
enum Command
{
- NONE_e,
ADD_REPO_e,
REMOVE_REPO_e,
LIST_REPOS_e,
REFRESH_e,
- SEARCH_e,
+
INSTALL_e,
REMOVE_e,
UPDATE_e,
+ SEARCH_e,
INFO_e,
+ LIST_UPDATES_e,
HELP_e,
SHELL_e,
SHELL_QUIT_e,
MOO_e,
+ NONE_e,
+
RUG_PATCH_INFO_e
};
Modified: trunk/zypper/src/zypper-info.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-info.cc?rev=5798&r1=5797&r2=5798&view=diff
==============================================================================
--- trunk/zypper/src/zypper-info.cc (original)
+++ trunk/zypper/src/zypper-info.cc Tue Jun 19 18:53:46 2007
@@ -18,10 +18,10 @@
/**
*
*/
-void printInfo(const string & command, const vector<string> & arguments) {
+void printInfo(const ZypperCommand & command, const vector<string> & arguments) {
Resolvable::Kind kind;
- if (command == "info" || command == "if") kind = ResTraits<Package>::kind;
- else if (command == "patch-info") kind = ResTraits<Patch>::kind;
+ if (command == ZypperCommand::INFO) kind = ResTraits<Package>::kind;
+ else if (command == ZypperCommand::RUG_PATCH_INFO) kind = ResTraits<Patch>::kind;
ResPool pool = God->pool();
@@ -51,9 +51,9 @@
// print info
cout << endl << _("Information for ") << kind.asString() << " " << *nameit << ":\n\n";
- if (command == "info" || command == "if")
+ if (command == ZypperCommand::INFO)
printPkgInfo(installer.item,installed);
- else if (command == "patch-info")
+ else if (command == ZypperCommand::RUG_PATCH_INFO)
printPatchInfo(installer.item,installed);
}
}
Modified: trunk/zypper/src/zypper-info.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-info.h?rev=5798&r1=5797&r2=5798&view=diff
==============================================================================
--- trunk/zypper/src/zypper-info.h (original)
+++ trunk/zypper/src/zypper-info.h Tue Jun 19 18:53:46 2007
@@ -6,7 +6,9 @@
#include "zypp/PoolItem.h"
-void printInfo(const std::string & command, const std::vectorstd::string & arguments);
+#include "zypper-command.h"
+
+void printInfo(const ZypperCommand & command, const std::vectorstd::string & arguments);
void printPkgInfo(const zypp::PoolItem & pool_item, const zypp::PoolItem & ins_pool_item);
void printPatchInfo(const zypp::PoolItem & pool_item, const zypp::PoolItem & ins_pool_item);
#endif /*ZYPPERINFO_H_*/
Modified: trunk/zypper/src/zypper-misc.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-misc.cc?rev=5798&r1=5797&r2=5798&view=diff
==============================================================================
--- trunk/zypper/src/zypper-misc.cc (original)
+++ trunk/zypper/src/zypper-misc.cc Tue Jun 19 18:53:46 2007
@@ -359,7 +359,7 @@
return retv;
}
-
+/*
std::string calculate_token()
{
SourceManager_Ptr manager;
@@ -382,11 +382,7 @@
MIL << "Source: " << src.alias() << " from " << src.timestamp() << std::endl;
}
-#ifdef LIBZYPP_1xx
- token_stream << "[" << "target" << "| " << Date::now() << "]"; // too bad
-#else
token_stream << "[" << "target" << "| " << God->target()->timestamp() << "]";
-#endif
//static std::string digest(const std::string& name, std::istream& is
token = Digest::digest("sha1", token_stream);
@@ -398,7 +394,8 @@
return token;
}
-
+*/
+/*
void cond_load_resolvables ()
{
// load repository resolvables
@@ -409,7 +406,7 @@
load_target();
}
}
-
+*/
void load_target()
{
cerr << _("Parsing RPM database...") << endl;
@@ -417,7 +414,7 @@
cerr_v << " " << tgt_resolvables.size() << _(" resolvables.") << endl;
God->addResolvables(tgt_resolvables, true /*installed*/);
}
-
+/*
void load_sources()
{
for ( std::list::iterator it = gData.sources.begin(); it != gData.sources.end(); ++it )
@@ -431,7 +428,7 @@
God->addResolvables(src_resolvables);
}
}
-
+*/
/** read repository resolvables */
void load_repo_resolvables()
Modified: trunk/zypper/src/zypper-misc.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-misc.h?rev=5798&r1=5797&r2=5798&view=diff
==============================================================================
--- trunk/zypper/src/zypper-misc.h (original)
+++ trunk/zypper/src/zypper-misc.h Tue Jun 19 18:53:46 2007
@@ -26,9 +26,9 @@
int show_summary();
std::string calculate_token();
//! load all resolvables that the user wants
-void cond_load_resolvables ();
+//void cond_load_resolvables ();
void load_target();
-void load_sources();
+//void load_sources();
void load_repo_resolvables();
void establish ();
bool resolve();
Modified: trunk/zypper/src/zypper-sources.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-sources.cc?rev=5798&r1=5797&r2=5798&view=diff
==============================================================================
--- trunk/zypper/src/zypper-sources.cc (original)
+++ trunk/zypper/src/zypper-sources.cc Tue Jun 19 18:53:46 2007
@@ -6,7 +6,6 @@
#include <fstream>
#include
#include
-#include
#include
#include
@@ -347,13 +346,14 @@
//! remove a source, identified in any way: alias, url, id
// may throw:
+/*
void remove_source( const std::string& anystring )
{
cerr_vv << "Constructing SourceManager" << endl;
SourceManager_Ptr manager = SourceManager::sourceManager();
cerr_vv << "Restoring SourceManager" << endl;
try {
- manager->restore (gSettings.root_dir, true /*use_cache*/);
+ manager->restore (gSettings.root_dir, true /*use_cache*//*);
}
catch (const Exception & ex) {
// so what if sources cannot be restored
@@ -416,16 +416,17 @@
}
cerr_vv << "Storing source data" << endl;
- manager->store( gSettings.root_dir, true /*metadata_cache*/ );
+ manager->store( gSettings.root_dir, true /*metadata_cache*//* );
}
-
+*/
+/*
//! rename a source, identified in any way: alias, url, id
void rename_source( const std::string& anystring, const std::string& newalias )
{
cerr_vv << "Constructing SourceManager" << endl;
SourceManager_Ptr manager = SourceManager::sourceManager();
cerr_vv << "Restoring SourceManager" << endl;
- manager->restore (gSettings.root_dir, true /*use_cache*/);
+ manager->restore (gSettings.root_dir, true /*use_cache*//*);
Source_Ref src;
@@ -483,9 +484,9 @@
}
cerr_vv << "Storing source data" << endl;
- manager->store( gSettings.root_dir, true /*metadata_cache*/ );
+ manager->store( gSettings.root_dir, true /*metadata_cache*//* );
}
-
+*/
// ----------------------------------------------------------------------------
// #217028
@@ -502,7 +503,7 @@
// ----------------------------------------------------------------------------
// OLD code
-
+/*
void cond_init_system_sources ()
{
static bool done = false;
@@ -520,8 +521,9 @@
}
done = true;
}
-
+*/
// OLD
+/*
void init_system_sources()
{
SourceManager_Ptr manager;
@@ -547,8 +549,9 @@
gData.sources.push_back(src);
}
}
-
+*/
// OLD
+/*
void include_source_by_url( const Url &url )
{
try
@@ -567,7 +570,7 @@
}
}
-
+*/
// Local Variables:
// c-basic-offset: 2
Modified: trunk/zypper/src/zypper-sources.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-sources.h?rev=5798&r1=5797&r2=5798&view=diff
==============================================================================
--- trunk/zypper/src/zypper-sources.h (original)
+++ trunk/zypper/src/zypper-sources.h Tue Jun 19 18:53:46 2007
@@ -1,6 +1,8 @@
#ifndef ZMART_SOURCES_H
#define ZMART_SOURCES_H
+#include
+
#include "zypp/Url.h"
/**
@@ -46,7 +48,7 @@
* ZYPPER_EXIT_OK otherwise
*/
int add_repo_from_file(const std::string & repo_file_url,
- tribool enabled = true, tribool autorefresh = true);
+ boost::tribool enabled = true, boost::tribool autorefresh = true);
/**
* If ZMD process found, notify user that ZMD is running and that changes
@@ -57,7 +59,7 @@
//! calls init_system_sources if not disabled by user (or non-root)
-void cond_init_system_sources(); // OLD
+//void cond_init_system_sources(); // OLD
void init_system_sources(); // OLD
void remove_source( const std::string& anystring ); // OLD
Modified: trunk/zypper/src/zypper-updates.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-updates.cc?rev=5798&r1=5797&r2=5798&view=diff
==============================================================================
--- trunk/zypper/src/zypper-updates.cc (original)
+++ trunk/zypper/src/zypper-updates.cc Tue Jun 19 18:53:46 2007
@@ -12,7 +12,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
@@ -86,9 +86,9 @@
out << " </errors>" << std::endl;
out << " <update-sources>" << std::endl;
- for ( std::list::const_iterator it = gData.sources.begin(); it != gData.sources.end(); ++it )
+ for ( std::list<RepoInfo>::const_iterator it = gData.repos.begin(); it != gData.repos.end(); ++it )
{
- out << "