Author: lslezak
Date: Wed Jul 4 15:35:52 2007
New Revision: 39170
URL: http://svn.opensuse.org/viewcvs/yast?rev=39170&view=rev
Log:
- first step to the new RepoManager API - too much commented code,
but it can be at least compiled...
Modified:
branches/REFACTORING-10_3/pkg-bindings/src/Callbacks.cc
branches/REFACTORING-10_3/pkg-bindings/src/Package.cc
branches/REFACTORING-10_3/pkg-bindings/src/PkgModuleFunctions.h
branches/REFACTORING-10_3/pkg-bindings/src/Resolvable.cc
branches/REFACTORING-10_3/pkg-bindings/src/Selection.cc
branches/REFACTORING-10_3/pkg-bindings/src/Source.cc
branches/REFACTORING-10_3/pkg-bindings/src/Target.cc
Modified: branches/REFACTORING-10_3/pkg-bindings/src/Callbacks.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/REFACTORING-10_3/pkg-bindings/src/Callbacks.cc?rev=39170&r1=39169&r2=39170&view=diff
==============================================================================
--- branches/REFACTORING-10_3/pkg-bindings/src/Callbacks.cc (original)
+++ branches/REFACTORING-10_3/pkg-bindings/src/Callbacks.cc Wed Jul 4 15:35:52 2007
@@ -35,7 +35,6 @@
#include
#include
#include
-#include
// FIXME: do this nicer, source create use this to avoid user feedback
// on probing of source type
@@ -43,7 +42,8 @@
ZyppRecipients::MediaChangeSensitivity _silent_probing = ZyppRecipients::MEDIA_CHANGE_FULL;
// remember redirected URLs
-std::map > redirect_map;
+// FIXME huh?
+std::map > redirect_map;
///////////////////////////////////////////////////////////////////
namespace ZyppRecipients {
@@ -453,8 +453,10 @@
size = pkg->archivesize();
- int source_id = pkg->source().numericId();
- int media_nr = pkg->sourceMediaNr();
+// FIXME NID
+ int source_id = 0;//pkg->source().numericId();
+// FIXME
+ int media_nr = 0;//pkg->sourceMediaNr();
if( source_id != last_source_id || media_nr != last_source_media )
{
@@ -924,7 +926,7 @@
{
MediaChangeReceive( RecipientCtl & construct_r ) : Recipient( construct_r ) {}
- virtual Action requestMedia(zypp::Source_Ref source, unsigned mediumNr, zypp::media::MediaChangeReport::Error error, const std::string &description)
+ virtual Action requestMedia(zypp::Repository source, unsigned mediumNr, zypp::media::MediaChangeReport::Error error, const std::string &description)
{
if ( _silent_probing == MEDIA_CHANGE_DISABLE )
return zypp::media::MediaChangeReport::ABORT;
@@ -940,7 +942,7 @@
callback.addStr( description );
// search URL in the redirection map
- std::map >::const_iterator source_it = redirect_map.find(source.numericId());
+ std::map >::const_iterator source_it = redirect_map.find(source.numericId());
bool found = false;
std::string report_url;
@@ -955,7 +957,7 @@
found = true;
// report the redirected URL
report_url = (*media_it).second;
- y2milestone("Using redirected URL %s, original URL: %s", report_url.c_str(), source.url().asString().c_str());
+ y2milestone("Using redirected URL %s, original URL: %s", report_url.c_str(), source.info().baseUrlsBegin()->asString().c_str());
}
}
@@ -963,15 +965,14 @@
{
// the source has not been redirected
// use URL of the source
- report_url = source.url().asString();
+ report_url = source.info().baseUrlsBegin()->asString();
}
-
// current URL
callback.addStr( report_url );
// current product name (use the alias, see #214886)
- callback.addStr( source.alias() );
+ callback.addStr( source.info().alias() );
// current medium, -1 means enable [Ignore]
callback.addInt( 0 );
@@ -1009,7 +1010,8 @@
// try/catch to catch invalid URLs
try {
zypp::Url ret_url (ret);
- source.redirect( mediumNr, ret_url );
+#warning FIXME: redirection is missing!
+ //source.redirect( mediumNr, ret_url );
// remember the redirection
std::map source_redir = redirect_map[source.numericId()];
@@ -1032,6 +1034,8 @@
}
};
+#warning FIXME SourceCreateReport has been removed
+/*
struct SourceCreateReceive : public Recipient, public zypp::callback::ReceiveReportzypp::source::SourceCreateReport
{
SourceCreateReceive( RecipientCtl & construct_r ) : Recipient( construct_r ) {}
@@ -1147,12 +1151,13 @@
}
}
};
+*/
-
+# warning FIXME: ProbeSourceReport has been removeed
///////////////////////////////////////////////////////////////////
// ProbeSourceReport
///////////////////////////////////////////////////////////////////
- struct ProbeSourceReceive : public Recipient, public zypp::callback::ReceiveReportzypp::source::ProbeSourceReport
+/* struct ProbeSourceReceive : public Recipient, public zypp::callback::ReceiveReportzypp::source::ProbeSourceReport
{
ProbeSourceReceive( RecipientCtl & construct_r ) : Recipient( construct_r ) {}
@@ -1247,6 +1252,7 @@
}
return zypp::source::ProbeSourceReport::progress(url, value);
+ return true;
}
virtual zypp::source::ProbeSourceReport::Action problem( const zypp::Url &url, zypp::source::ProbeSourceReport::Error error, const std::string &description )
@@ -1274,7 +1280,10 @@
return zypp::source::ProbeSourceReport::problem(url, error, description);
}
};
+ */
+# warning FIXME: SourceReport has been removed
+/*
struct SourceReport : public Recipient, public zypp::callback::ReceiveReportzypp::source::SourceReport
{
virtual void reportbegin()
@@ -1399,6 +1408,7 @@
}
}
};
+ */
struct ResolvableReport : public Recipient, public zypp::callback::ReceiveReportzypp::target::MessageResolvableReport
@@ -1650,9 +1660,12 @@
ZyppRecipients::MessageReceive _messageReceive;
// source manager callback
+#warning FIXME: source callbacks are missing
+/*
ZyppRecipients::SourceCreateReceive _sourceCreateReceive;
ZyppRecipients::SourceReport _sourceReport;
ZyppRecipients::ProbeSourceReceive _probeSourceReceive;
+*/
// resolvable report
ZyppRecipients::ResolvableReport _resolvableReport;
@@ -1683,9 +1696,10 @@
, _downloadProgressReceive( *this )
, _scriptExecReceive( *this )
, _messageReceive( *this )
- , _sourceCreateReceive( *this )
- , _sourceReport( *this )
- , _probeSourceReceive( *this )
+#warning FIXME: source callbacks are missing
+// , _sourceCreateReceive( *this )
+// , _sourceReport( *this )
+// , _probeSourceReceive( *this )
, _resolvableReport( *this )
, _digestReceive( *this )
, _keyRingReceive( *this )
@@ -1703,9 +1717,10 @@
_downloadProgressReceive.connect();
_scriptExecReceive.connect();
_messageReceive.connect();
- _sourceCreateReceive.connect();
- _sourceReport.connect();
- _probeSourceReceive.connect();
+#warning FIXME: source callbacks are missing
+// _sourceCreateReceive.connect();
+// _sourceReport.connect();
+// _probeSourceReceive.connect();
_resolvableReport.connect();
_digestReceive.connect();
_keyRingReceive.connect();
@@ -1726,9 +1741,10 @@
_downloadProgressReceive.disconnect();
_scriptExecReceive.disconnect();
_messageReceive.disconnect();
- _sourceCreateReceive.disconnect();
- _sourceReport.disconnect();
- _probeSourceReceive.disconnect();
+#warning FIXME: source callbacks are missing
+// _sourceCreateReceive.disconnect();
+// _sourceReport.disconnect();
+// _probeSourceReceive.disconnect();
_resolvableReport.disconnect();
_digestReceive.disconnect();
_keyRingReceive.disconnect();
Modified: branches/REFACTORING-10_3/pkg-bindings/src/Package.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/REFACTORING-10_3/pkg-bindings/src/Package.cc?rev=39170&r1=39169&r2=39170&view=diff
==============================================================================
--- branches/REFACTORING-10_3/pkg-bindings/src/Package.cc (original)
+++ branches/REFACTORING-10_3/pkg-bindings/src/Package.cc Wed Jul 4 15:35:52 2007
@@ -42,7 +42,6 @@
#include
#include
#include
-#include
#include
#include
#include
@@ -193,17 +192,22 @@
{
# warning No installation order
- std::listzypp::SourceManager::SourceId source_ids = zypp::SourceManager::sourceManager()->enabledSources();
+#warning PkgMediaNames is NOT implemented!!!
+// FIXME
+/*
+// std::listzypp::SourceManager::SourceId source_ids = zypp::SourceManager::sourceManager()->enabledSources();
YCPList res;
// initialize
+// FIXME: for all enabled sources...
for( std::listzypp::SourceManager::SourceId::const_iterator sit = source_ids.begin();
sit != source_ids.end(); ++sit)
{
unsigned id = *sit;
- zypp::Source_Ref src = zypp::SourceManager::sourceManager()->findSource( id );
+//FIXME
+// zypp::Source_Ref src = zypp::SourceManager::sourceManager()->findSource( id );
try
{
@@ -248,6 +252,9 @@
y2milestone( "Pkg::PkgMediaNames result: %s", res->toString().c_str());
return res;
+*/
+
+ return YCPList();
}
@@ -265,10 +272,12 @@
* @usage Pkg::PkgMediaSizes () -> [ [src1_media_1_size, src1_media_2_size, ...], ..]
*/
YCPValue
-PkgModuleFunctions::PkgMediaSizes ()
+PkgModuleFunctions::PkgMediaSizesOrCount (bool sizes)
{
# warning No installation order
+/*
+FIXME
// all enabled sources
std::listzypp::SourceManager::SourceId source_ids = zypp::SourceManager::sourceManager()->enabledSources();
@@ -297,7 +306,7 @@
{
zypp::Package::constPtr pkg = boost::dynamic_pointer_cast<const zypp::Package>(it->resolvable());
- if( it->status().isToBeInstalled())
+ if( pkg && it->status().isToBeInstalled())
{
unsigned int medium = pkg->sourceMediaNr();
if (medium == 0)
@@ -307,7 +316,7 @@
if (medium > 0)
{
- zypp::ByteCount size = pkg->size();
+ zypp::ByteCount size = sizes? pkg->size() : 1; //count only
result[ source_map[pkg->source()] ]
[medium - 1] += size ; // media are numbered from 1
}
@@ -319,7 +328,7 @@
for(std::mapzypp::ByteCount >::const_iterator it =
result.begin(); it != result.end() ; ++it)
{
- std::vectorzypp::ByteCount values = it->second;
+ const std::vectorzypp::ByteCount &values = it->second;
YCPList source;
for( unsigned i = 0 ; i < values.size() ; i++ )
@@ -330,11 +339,32 @@
res->add( source );
}
- y2milestone( "Pkg::PkgMediaSize result: %s", res->toString().c_str());
+ y2milestone( "Pkg::%s result: %s", sizes?"PkgMediaSizes": "PkgMediaCount", res->toString().c_str());
return res;
+*/
+
+ return YCPList();
}
+// ------------------------
+/**
+ * @builtin PkgMediaSizes
+ * @short Return size of packages to be installed
+ * @description
+ * return cumulated sizes (in bytes !) to be installed from different sources and media
+ *
+ * Returns the install size, not the archivesize !!
+ *
+ * @return list
+ * @usage Pkg::PkgMediaSizes () -> [ [src1_media_1_size, src1_media_2_size, ...], ..]
+ */
+YCPValue
+PkgModuleFunctions::PkgMediaSizes()
+{
+#warning PkgMediaSizes is NOT implemented!!!
+ return PkgMediaSizesOrCount (true);
+}
// ------------------------
/**
@@ -349,73 +379,8 @@
YCPValue
PkgModuleFunctions::PkgMediaCount()
{
-# warning No installation order
-
- // all enabled sources
- std::listzypp::SourceManager::SourceId source_ids = zypp::SourceManager::sourceManager()->enabledSources();
-
- // map SourceId -> [ number_of_media, total_size ]
- std::mapzypp::ByteCount > result;
-
- // map zypp::Source -> SourceID
- std::map source_map;
-
-
- // initialize
- for( std::listzypp::SourceManager::SourceId::const_iterator sit = source_ids.begin();
- sit != source_ids.end(); ++sit)
- {
- zypp::SourceManager::SourceId id = *sit;
-
- zypp::Source_Ref src = zypp::SourceManager::sourceManager()->findSource( id );
- unsigned media = src.numberOfMedia();
-
- result[id] = std::vectorzypp::ByteCount(media,0);
-
- source_map[ src ] = id;
- }
-
- for( zypp::ResPool::byKind_iterator it = zypp_ptr()->pool().byKindBeginzypp::Package()
- ; it != zypp_ptr()->pool().byKindEndzypp::Package()
- ; ++it )
- {
- zypp::Package::constPtr pkg = boost::dynamic_pointer_cast<const zypp::Package>(it->resolvable());
-
- if( pkg && it->status().isToBeInstalled())
- {
- unsigned int medium = pkg->sourceMediaNr();
- if (medium == 0)
- {
- medium = 1;
- }
-
- if (medium > 0)
- {
- result[ source_map[pkg->source()] ]
- [medium - 1]++ ; // media are numbered from 1
- }
- }
- }
-
- YCPList res;
-
- for(std::mapzypp::ByteCount >::const_iterator it =
- result.begin(); it != result.end() ; ++it)
- {
- const std::vectorzypp::ByteCount &values = it->second;
- YCPList source;
-
- for( unsigned i = 0 ; i < values.size() ; i++ )
- {
- source->add( YCPInteger( values[i] ) );
- }
-
- res->add( source );
- }
-
- y2milestone( "Pkg::PkgMediaCount result: %s", res->toString().c_str());
-
- return res;
+#warning PkgMediaCount is NOT implemented!!!
+ return PkgMediaSizesOrCount (false);
}
// ------------------------
@@ -1006,10 +971,11 @@
}
data->add( YCPString("arch"), YCPString( pkg->arch().asString() ) );
- data->add( YCPString("medianr"), YCPInteger( pkg->sourceMediaNr() ) );
+ data->add( YCPString("medianr"), YCPInteger( pkg->mediaNr() ) );
- y2debug("srcId: %ld", pkg->source().numericId() );
- data->add( YCPString("srcid"), YCPInteger( pkg->source().numericId() ) );
+ zypp::Repository::NumericId sid = pkg->repository().numericId();
+ y2debug("srcId: %ld", sid );
+ data->add( YCPString("srcid"), YCPInteger( sid ) );
std::string status("available");
if (item.status().isInstalled())
@@ -2238,7 +2204,9 @@
}
try {
- zypp::SourceManager::sourceManager()->releaseAllSources();
+
+#warning FIXME release all sources in PkgCommit
+// zypp::SourceManager::sourceManager()->releaseAllSources();
}
catch (const zypp::Exception& excpt)
{
Modified: branches/REFACTORING-10_3/pkg-bindings/src/PkgModuleFunctions.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/REFACTORING-10_3/pkg-bindings/src/PkgModuleFunctions.h?rev=39170&r1=39169&r2=39170&view=diff
==============================================================================
--- branches/REFACTORING-10_3/pkg-bindings/src/PkgModuleFunctions.h (original)
+++ branches/REFACTORING-10_3/pkg-bindings/src/PkgModuleFunctions.h Wed Jul 4 15:35:52 2007
@@ -43,7 +43,8 @@
#include
#include
#include
-#include
+#include
+#include
#include "PkgError.h"
@@ -94,6 +95,9 @@
private: // source related
+
+ // all known installation sources
+ std::listzypp::Repository repos;
bool DoProvideNameKind( const std::string & name, zypp::Resolvable::Kind kind, zypp::Arch architecture,
const std::string& version, const bool onlyNeeded = false);
@@ -103,6 +107,7 @@
bool DoAllKind(zypp::Resolvable::Kind kind, bool provide);
YCPValue GetPkgLocation(const YCPString& p, bool full_path);
YCPValue PkgProp( zypp::PoolItem_Ref item );
+ YCPValue PkgMediaSizesOrCount (bool sizes);
void SetCurrentDU();
@@ -136,10 +141,12 @@
/**
* Logging helper:
- * call zypp::SourceManager::sourceManager()->findSource
- * and in case of exception, log error and setLastError AND RETHROW
+ * search for a repository and in case of exception, log error
+ * and setLastError AND RETHROW
*/
- zypp::Source_Ref logFindSource (zypp::SourceManager::SourceId id);
+ zypp::Repository logFindRepository(zypp::Repository::NumericId id);
+ zypp::Repository::NumericId createManagedSource(const zypp::Url & url_r,
+ const zypp::Pathname & path_r, const bool base_source, const std::string& type);
public:
// general
Modified: branches/REFACTORING-10_3/pkg-bindings/src/Resolvable.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/REFACTORING-10_3/pkg-bindings/src/Resolvable.cc?rev=39170&r1=39169&r2=39170&view=diff
==============================================================================
--- branches/REFACTORING-10_3/pkg-bindings/src/Resolvable.cc (original)
+++ branches/REFACTORING-10_3/pkg-bindings/src/Resolvable.cc Wed Jul 4 15:35:52 2007
@@ -405,8 +405,8 @@
info->add(YCPString("locked"), YCPBoolean(it->status().isLocked()));
// source
- zypp::Source_Ref res_src = (*it)->source();
- info->add(YCPString("source"), YCPInteger(res_src.numericId()));
+ zypp::Repository repo = (*it)->repository();
+ info->add(YCPString("source"), YCPInteger(repo.numericId()));
// product specific info
if( req_kind == "product" ) {
Modified: branches/REFACTORING-10_3/pkg-bindings/src/Selection.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/REFACTORING-10_3/pkg-bindings/src/Selection.cc?rev=39170&r1=39169&r2=39170&view=diff
==============================================================================
--- branches/REFACTORING-10_3/pkg-bindings/src/Selection.cc (original)
+++ branches/REFACTORING-10_3/pkg-bindings/src/Selection.cc Wed Jul 4 15:35:52 2007
@@ -41,7 +41,6 @@
#include
#include
#include
-#include
using std::string;
@@ -100,9 +99,9 @@
else if (status == "available")
{
// ignore installed selections
- zypp::Source_Ref src = (*it)->source();
+ zypp::Repository src = (*it)->repository();
- if (src != zypp::Source_Ref::noSource)
+ if (src != zypp::Repository::noRepository)
selection = it->resolvable()->name();
}
else if (status == "selected")
@@ -201,9 +200,9 @@
else if (status == "available")
{
// ignore installed patterns
- zypp::Source_Ref src = (*it)->source();
+ zypp::Repository src = (*it)->repository();
- if (src != zypp::Source_Ref::noSource)
+ if (src != zypp::Repository::noRepository)
pattern = it->resolvable()->name();
}
else if (status == "selected")
@@ -307,7 +306,7 @@
data->add (YCPString ("script"), YCPString (pattern->script().asString()));
data->add (YCPString ("version"), YCPString((*it)->edition().asString()));
data->add (YCPString ("arch"), YCPString((*it)->arch().asString()));
- data->add (YCPString ("srcid"), YCPInteger((*it)->source().numericId()));
+ data->add (YCPString ("srcid"), YCPInteger((*it)->repository().numericId()));
}
else
{
Modified: branches/REFACTORING-10_3/pkg-bindings/src/Source.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/REFACTORING-10_3/pkg-bindings/src/Source.cc?rev=39170&r1=39169&r2=39170&view=diff
==============================================================================
--- branches/REFACTORING-10_3/pkg-bindings/src/Source.cc (original)
+++ branches/REFACTORING-10_3/pkg-bindings/src/Source.cc Wed Jul 4 15:35:52 2007
@@ -34,14 +34,17 @@
#include
#include
-#include
-#include
-#include
#include
#include
#include
#include
+#include
+#include
+#include
+#include
+#include
+
#include // snprintf
@@ -110,28 +113,37 @@
ycp_handler->evaluateCall();
}
}
+
/**
* Logging helper:
* call zypp::SourceManager::sourceManager()->findSource
* and in case of exception, log error and setLastError AND RETHROW
*/
-zypp::Source_Ref PkgModuleFunctions::logFindSource (zypp::SourceManager::SourceId id)
+zypp::Repository PkgModuleFunctions::logFindRepository(zypp::Repository::NumericId id)
{
- zypp::Source_Ref src;
-
try
{
- src = zypp::SourceManager::sourceManager()->findSource(id);
+ for (std::listzypp::Repository::iterator it = repos.begin();
+ it != repos.end(); ++it)
+ {
+ if (it->numericId() == id)
+ {
+ return *it;
+ }
+ }
}
catch (const zypp::Exception& excpt)
{
- y2error("Cannot find source %ld: %s",id, excpt.msg().c_str() );
+ y2error("Cannot find source %ld: %s", id, excpt.msg().c_str() );
_last_error.setLastError(excpt.asUserString());
throw;
}
- return src;
+
+ // not found, return empty Repository
+ return zypp::Repository();
}
+
/****************************************************************************************
* @builtin SourceSetRamCache
* @short Obsoleted function, do not use
@@ -161,8 +173,11 @@
PkgModuleFunctions::SourceRestore()
{
// evaluate the callbacks only when the source manager hasn't been initialized
- bool enable_callbacks = zypp::SourceManager::sourceManager()->Source_begin()
- == zypp::SourceManager::sourceManager()->Source_end();
+// FIXME
+// bool enable_callbacks = zypp::SourceManager::sourceManager()->Source_begin()
+// == zypp::SourceManager::sourceManager()->Source_end();
+
+ bool enable_callbacks = repos.size() == 0;
if (enable_callbacks)
{
@@ -172,28 +187,30 @@
bool success = true;
- try {
- // we always use the configured caches
- if( !zypp::SourceManager::sourceManager()->restore(_target_root, true) )
+ try
+ {
+ zypp::RepoManager repomanager;
+ zypp::RepoInfoList repolist = repomanager.knownRepositories();
+
+ repos.erase(repos.begin(), repos.end());
+
+ for (std::listzypp::RepoInfo::iterator it = repolist.begin();
+ it != repolist.end(); ++it)
{
- y2error( "Unable to restore all sources" );
+ zypp::RepoInfo repo(*it);
- success = false;
+ // build cache if needed
+ if (!repomanager.isCached(repo))
+ {
+ y2milestone("Caching source '%s'...", repo.alias().c_str());
+ repomanager.buildCache(repo);
+ }
+
+ // create Repository and remember it
+ zypp::Repository repository = repomanager.createFromCache(repo);
+ repos.push_back(repository);
}
}
- catch (const zypp::FailedSourcesRestoreException& excpt)
- {
- // FIXME: assuming the sources are already initialized
- y2error ("Error in SourceRestore: %s", excpt.asString().c_str());
- _last_error.setLastError(excpt.asUserString());
- _broken_sources = excpt.aliases();
- success = false;
- }
- catch (const zypp::SourcesAlreadyRestoredException& excpt)
- {
- y2milestone ("At least one source already registered, SourceManager already started.");
- success = true;
- }
catch (const zypp::Exception& excpt)
{
// FIXME: assuming the sources are already initialized
@@ -221,15 +238,8 @@
**/
YCPValue PkgModuleFunctions::SourceGetBrokenSources()
{
- YCPList ret;
-
- for( std::setstd::string::const_iterator it = _broken_sources.begin() ;
- it != _broken_sources.end() ; ++it )
- {
- ret->add(YCPString(*it));
- }
-
- return ret;
+ y2warning("Pkg::SourceGetBrokenSources() is obsoleted, it's not needed anymore.");
+ return YCPList();
}
/****************************************************************************************
@@ -243,80 +253,61 @@
YCPValue
PkgModuleFunctions::SourceLoad()
{
+ bool callbacks_evaluated = false;
bool success = true;
- std::listzypp::SourceManager::SourceId ids;
-
- // get all enabled sources
- try
- {
- ids = zypp::SourceManager::sourceManager()->enabledSources();
- }
- catch (const zypp::Exception& excpt)
+ for (std::listzypp::Repository::iterator it = repos.begin();
+ it != repos.end(); ++it)
{
- y2error ("Error in SourceLoad: %s", excpt.asString().c_str());
- _last_error.setLastError(excpt.asUserString());
- success = false;
- }
+ zypp::RepoInfo repo(it->info());
- bool callbacks_evaluated = false;
-
- // load resolvables the enabled sources
- for( std::listzypp::SourceManager::SourceId::iterator it = ids.begin(); it != ids.end(); ++it)
- {
- try
+ // skip disabled sources
+ if (! repo.enabled())
+ {
+ continue;
+ }
+
+ // autorefresh the source
+ if (repo.autorefresh())
+ {
+ y2milestone("Autorefreshing source: %s", repo.alias().c_str());
+ zypp::RepoManager repomanager;
+ repomanager.refreshMetadata(repo);
+ }
+
+ try
{
- zypp::Source_Ref src = logFindSource(*it);
- try
+ if (!callbacks_evaluated)
{
- if( src.enabled() )
- {
- if (!src.resStoreInitialized ())
- {
- if (!callbacks_evaluated)
- {
- CallSourceReportInit();
- CallSourceReportStart(_("Parsing files..."));
- callbacks_evaluated = true;
- }
-
- zypp_ptr()->addResolvables (src.resolvables());
- }
- }
- else
- {
- // remove the resolvables if they have been added
- if (src.resStoreInitialized ())
- {
- if (!callbacks_evaluated)
- {
- CallSourceReportInit();
- CallSourceReportStart(_("Parsing files..."));
- callbacks_evaluated = true;
- }
-
- zypp_ptr()->removeResolvables(src.resolvables());
- }
- }
-
+ CallSourceReportInit();
+ CallSourceReportStart(_("Parsing files..."));
+ callbacks_evaluated = true;
}
- catch (const zypp::Exception& excpt)
- {
- std::string url = src.url().asString();
- y2error ("Error for %s: %s", url.c_str(), excpt.asString().c_str());
- _last_error.setLastError(url + ": " + excpt.asUserString());
- success = false;
-
- // disable the source
- y2error("Disabling source %s", url.c_str());
- src.disable();
- // remember the broken source for SourceCleanupBroken
- _broken_sources.insert(src.alias());
- }
+
+ // load resolvables
+ zypp::ResStore store = it->resolvables();
+ zypp_ptr()->addResolvables(store);
+
+ y2milestone("Found %d resolvables", store.size());
+ }
+ catch(const zypp::repo::RepoNotCachedException &excpt )
+ {
+ std::string alias = repo.alias();
+ y2error ("Resolvables from '%s' havn't been loaded: %s", alias.c_str(), excpt.asString().c_str());
+ _last_error.setLastError("'" + alias + "': " + excpt.asUserString());
+ success = false;
+
+ // FIXME ??
+ /*
+ // disable the source
+ y2error("Disabling source %s", url.c_str());
+ src.disable();
+ */
}
catch (const zypp::Exception& excpt)
{
+ y2internal("Caught unknown error");
success = false;
}
}
@@ -418,25 +409,8 @@
YCPValue
PkgModuleFunctions::SourceCleanupBroken ()
{
- bool success = true;
-
- zypp::storage::PersistentStorage store;
- store.init( _target_root );
-
- for( std::setstd::string::const_iterator it = _broken_sources.begin() ;
- it != _broken_sources.end() ; ++it )
- {
- try {
- store.deleteSource( *it );
- } catch( const zypp::Exception& excpt )
- {
- success = false;
- }
- }
-
- _broken_sources.clear();
-
- return YCPBoolean(success);
+ y2warning("Pkg::SourceCleanupBroken() is obsoleted, it's not needed anymore.");
+ return YCPBoolean(true);
}
/****************************************************************************************
@@ -452,15 +426,17 @@
YCPValue
PkgModuleFunctions::SourceGetCurrent (const YCPBoolean& enabled)
{
- std::listzypp::SourceManager::SourceId ids = (enabled->value()) ?
- zypp::SourceManager::sourceManager()->enabledSources()
- : zypp::SourceManager::sourceManager()->allSources();
-
YCPList res;
- for( std::listzypp::SourceManager::SourceId::const_iterator it = ids.begin(); it != ids.end() ; ++it )
+ for( std::listzypp::Repository::const_iterator it = repos.begin(); it != repos.end() ; ++it )
{
- res->add( YCPInteger( *it ) );
+ // ignore disabled sources if requested
+ if (enabled->value() && !it->info().enabled())
+ {
+ continue;
+ }
+
+ res->add( YCPInteger( it->numericId() ) );
}
return res;
@@ -475,7 +451,8 @@
YCPValue
PkgModuleFunctions::SourceReleaseAll ()
{
- try
+#warning FIXME: SourceReleaseAll is empty!
+/* try
{
y2milestone( "Relesing all sources") ;
zypp::SourceManager::sourceManager()->releaseAllSources ();
@@ -488,6 +465,7 @@
}
y2milestone( "All sources released");
+*/
return YCPBoolean(true);
}
@@ -501,7 +479,8 @@
YCPValue
PkgModuleFunctions::SourceSaveAll ()
{
- try
+#warning FIXME SourceSaveAll is empty!
+/* try
{
y2milestone( "Storing the source setup in %s", _target_root.asString().c_str()) ;
zypp::SourceManager::sourceManager()->store( _target_root, true );
@@ -514,7 +493,7 @@
}
y2milestone( "All sources saved");
-
+*/
return YCPBoolean(true);
}
@@ -530,7 +509,8 @@
YCPValue
PkgModuleFunctions::SourceFinishAll ()
{
- try
+#warning FIXME: SourceFinishAll is empty!
+/* try
{
// look if there are any enabled sources
std::listzypp::SourceManager::SourceId enabled_sources = zypp::SourceManager::sourceManager()->enabledSources();
@@ -551,7 +531,7 @@
}
y2milestone( "All sources finished");
-
+*/
return YCPBoolean(true);
}
@@ -584,11 +564,12 @@
PkgModuleFunctions::SourceGeneralData (const YCPInteger& id)
{
YCPMap data;
- zypp::Source_Ref src;
+
+ zypp::RepoInfo src;
try
{
- src = logFindSource(id->value());
+ src = logFindRepository(id->value()).info();
}
catch (const zypp::Exception& excpt)
{
@@ -597,10 +578,21 @@
data->add( YCPString("enabled"), YCPBoolean(src.enabled()));
data->add( YCPString("autorefresh"), YCPBoolean(src.autorefresh()));
- data->add( YCPString("type"), YCPString(src.type()));
- data->add( YCPString("product_dir"), YCPString(src.path().asString()));
- data->add( YCPString("url"), YCPString(src.url().asString()));
+ data->add( YCPString("type"), YCPString(src.type().asString()));
+#warning FIXME: "product_dir" is missing
+// data->add( YCPString("product_dir"), YCPString(src.path().asString()));
+ data->add( YCPString("url"), YCPString(src.baseUrlsBegin()->asString()));
data->add( YCPString("alias"), YCPString(src.alias()));
+
+ YCPList base_urls;
+ for( zypp::RepoInfo::urls_const_iterator it = src.baseUrlsBegin(); it != src.baseUrlsEnd(); ++it)
+ {
+ base_urls->add(YCPString(it->asString()));
+ }
+ data->add( YCPString("base_urls"), base_urls);
+
+ data->add( YCPString("mirror_list"), YCPString(src.mirrorListUrl().asString()));
+
return data;
}
@@ -614,11 +606,11 @@
YCPValue
PkgModuleFunctions::SourceURL (const YCPInteger& id)
{
- zypp::Source_Ref src;
+ zypp::RepoInfo src;
try
{
- src = logFindSource(id->value());
+ src = logFindRepository(id->value()).info();
}
catch (const zypp::Exception& excpt)
{
@@ -626,7 +618,7 @@
}
// #186842
- return YCPString(src.url().asCompleteString());
+ return YCPString(src.baseUrlsBegin()->asCompleteString());
}
/****************************************************************************************
@@ -650,23 +642,24 @@
PkgModuleFunctions::SourceMediaData (const YCPInteger& id)
{
YCPMap data;
- zypp::Source_Ref src;
+ zypp::RepoInfo src;
try
{
- src = logFindSource(id->value());
+ src = logFindRepository(id->value()).info();
}
catch (const zypp::Exception& excpt)
{
return YCPVoid ();
}
-
- data->add( YCPString("media_count"), YCPInteger(src.numberOfMedia()));
+#warning FIXME SourceMediaData is NOT implemented!!!
+/* data->add( YCPString("media_count"), YCPInteger(src.numberOfMedia()));
data->add( YCPString("media_id"), YCPString(src.unique_id()));
data->add( YCPString("media_vendor"), YCPString(src.vendor()));
#warning SourceMediaData returns URL without password
data->add( YCPString("url"), YCPString(src.url().asString()));
+*/
return data;
}
@@ -696,8 +689,6 @@
try
{
- zypp::Source_Ref src = logFindSource(src_id->value());
-
// find a product for the given source
zypp::ResPool::byKind_iterator it = zypp_ptr()->pool().byKindBegin(zypp::ResTraitszypp::Product::kind);
@@ -705,7 +696,7 @@
{
zypp::Product::constPtr product = boost::dynamic_pointer_cast<const zypp::Product>( it->resolvable() );
- if( product->source() == src )
+ if( product->repository().numericId() == src_id->value() )
{
ret->add( YCPString("label"), YCPString( product->summary() ) );
ret->add( YCPString("vendor"), YCPString( product->vendor() ) );
@@ -751,6 +742,31 @@
return YCPMap();
}
+/*
+void SourceProvideFileEx(const zypp::RepoInfo &rep, const std::string &file,
+ const std::string &cachedir, const std::string &targetdir, bool optional = true)
+{
+ try {
+ zypp::OnMediaLocation oml;
+ oml.medianr(mid->value());
+ oml.filename(f->value());
+
+ zypp::MediaSetAccess maccess(*src.baseUrlsBegin());
+
+ zypp::Fetcher fetcher;
+ fetcher.enqueue(oml);
+ fetcher.addCachePath(cachedir);
+ fetcher.start(targetdir, maccess);
+ fetcher.reset();
+ }
+ catch (const zypp::Exception& excpt)
+ {
+ _last_error.setLastError(excpt.asUserString());
+ y2milestone ("File not found: %s", f->value_cstr());
+ }
+}
+*/
+
/****************************************************************************************
* @builtin SourceProvideFile
*
@@ -770,11 +786,12 @@
CallSourceReportInit();
CallSourceReportStart(_("Downloading file..."));
- zypp::Source_Ref src;
+#warning TODO: use SourceProvideFileEx()
+ zypp::RepoInfo src;
bool found = true;
try {
- src = logFindSource(id->value());
+ src = logFindRepository(id->value()).info();
}
catch (const zypp::Exception& excpt)
{
@@ -786,7 +803,17 @@
if (found)
{
try {
- path = src.provideFile(f->value(), mid->asInteger()->value());
+ zypp::OnMediaLocation oml;
+ oml.medianr(mid->value());
+ oml.filename(f->value());
+
+ zypp::MediaSetAccess maccess(*src.baseUrlsBegin());
+
+ zypp::Fetcher fetcher;
+ fetcher.enqueue(oml);
+ fetcher.addCachePath("/tmp/cache");
+ fetcher.start("/download-dir", maccess);
+ fetcher.reset();
}
catch (const zypp::Exception& excpt)
{
@@ -827,6 +854,7 @@
YCPValue
PkgModuleFunctions::SourceProvideOptionalFile (const YCPInteger& id, const YCPInteger& mid, const YCPString& f)
{
+#warning TODO: use SourceProvideFileEx()
CallSourceReportInit();
CallSourceReportStart(_("Downloading files..."));
@@ -840,19 +868,20 @@
// disable media change callback
_silent_probing = ZyppRecipients::MEDIA_CHANGE_OPTIONALFILE;
- zypp::Source_Ref src;
bool found = true;
+ zypp::filesystem::Pathname path;
+#warning FIXME SourceProvideOptionalFile is NOT implemented!!!
+/*
+ zypp::Source_Ref src;
try {
- src = logFindSource(id->value());
+ src = logFindRepository(id->value());
}
catch (const zypp::Exception& excpt)
{
found = false;
}
- zypp::filesystem::Pathname path;
-
if (found)
{
try {
@@ -865,7 +894,7 @@
}
}
-
+ */
// set the original probing value
_silent_probing = _silent_probing_old;
@@ -898,19 +927,21 @@
YCPValue
PkgModuleFunctions::SourceProvideDir (const YCPInteger& id, const YCPInteger& mid, const YCPString& d)
{
+#warning FIXME SourceProvideDir is NOT implemented!!!
+ /*
zypp::Source_Ref src;
try
{
- src = logFindSource(id->value());
+ src = logFindRepository(id->value());
}
catch (const zypp::Exception& excpt)
{
return YCPVoid ();
}
-
+*/
zypp::filesystem::Pathname path;
-
+/*
try
{
path = src.provideDirTree(d->value(), mid->asInteger()->value());
@@ -921,7 +952,7 @@
y2milestone ("Directory not found: %s", d->value_cstr());
return YCPVoid();
}
-
+*/
return YCPString(path.asString());
}
@@ -938,9 +969,9 @@
YCPValue
PkgModuleFunctions::SourceChangeUrl (const YCPInteger& id, const YCPString& u)
{
- zypp::Source_Ref src;
+ zypp::RepoInfo src;
try {
- src = logFindSource(id->value());
+ src = logFindRepository(id->value()).info();
}
catch (const zypp::Exception& excpt)
{
@@ -948,11 +979,19 @@
}
try {
- zypp::Pathname pth = src.path();
+#warning FIXME: SourceChangeUrl is NOT implemented
+// we cannot simply change the base URL we have to create a new RepoInfo...
+// src.setBaseUrl();
+
+// zypp::RepoManager repomanager;
+// repomanager.modifyRepository(src.alias(), src);
+
+/* zypp::Pathname pth = src.path();
zypp::Url url = zypp::Url(u->value ());
zypp::media::MediaManager media_mgr;
zypp::media::MediaAccessId media_id = media_mgr.open(url);
src.changeMedia(media_id, pth);
+ */
}
catch (const zypp::Exception & excpt)
{
@@ -1073,27 +1112,89 @@
* \return the SourceId
* \throws Exception if Source creation fails
*/
-zypp::SourceManager::SourceId
-createManagedSource( const zypp::Url & url_r,
+zypp::Repository::NumericId
+PkgModuleFunctions::createManagedSource( const zypp::Url & url_r,
const zypp::Pathname & path_r,
const bool base_source,
const std::string& type )
{
- y2milestone ("Original URL: %s", url_r.asString().c_str());
+ // parse URL
+ y2milestone ("Original URL: %s", url_r.asString().c_str());
- // #158850#c17, if the URL contains an alias, we use that
- zypp::Url new_url;
- string alias = removeAlias (url_r, new_url);
-
- y2milestone("Alias from URL: '%s'", alias.c_str());
-
- zypp::Source_Ref newsrc =
- (type.empty()) ?
- // autoprobe source type
- zypp::SourceFactory().createFrom(new_url, path_r, alias, zypp::filesystem::Pathname(), base_source) :
- // use required source type, autorefresh = true
- zypp::SourceFactory().createFrom(type, new_url, path_r, alias, zypp::filesystem::Pathname(), base_source, true);
-
+ // #158850#c17, if the URL contains an alias, we use that
+ zypp::Url url;
+
+ std::string alias = removeAlias(url_r, url);
+ y2milestone("Alias from URL: '%s'", alias.c_str());
+
+
+ // repository type
+ zypp::repo::RepoType repotype;
+ zypp::RepoManager repomanager;
+
+ if (!type.empty())
+ {
+ try
+ {
+ repotype.parse(type);
+ }
+ catch (zypp::repo::RepoUnknownTypeException &e)
+ {
+ y2warning("Unknown source type '%s'", type.c_str());
+ }
+ }
+
+ // the type is not specified or is wrong, autoprobe the type
+ if (repotype == zypp::repo::RepoType::NONE)
+ {
+ y2milestone("Probing source type: '%s'", url.asString().c_str());
+
+ // autoprobe type of the repository
+ repotype = repomanager.probe(url);
+ }
+
+ y2milestone("Using source type: %s", repotype.asString().c_str());
+
+
+ // create source definition object
+ zypp::RepoInfo repo;
+
+ repo.setAlias(alias.empty() ? timestamp() : alias);
+ repo.setType(repotype);
+ repo.addBaseUrl(url);
+ repo.setEnabled(true);
+ repo.setAutorefresh(true);
+
+ y2milestone("Adding source '%s' (%s)", repo.alias().c_str(), url.asString().c_str());
+
+/* try
+ {*/
+
+ repomanager.addRepository(repo);
+
+/* }
+ catch (const zypp::MediaException &e)
+ {
+ y2error("Cannot read source data");
+ }
+ catch (const ParseException &e)
+ {
+ y2error("Cannot parse source data");
+ }
+ catch (const RepoAlreadyExistsException &e)
+ {
+ y2error("Source '%s' already exists", repo.alias().c_str());
+ }
+*/
+
+ y2milestone("Added source '%s': '%s', enabled: %s, autorefresh: %s",
+ repo.alias().c_str(),
+ repo.baseUrlsBegin()->asString().c_str(),
+ repo.enabled() ? "true" : "false",
+ repo.autorefresh() ? "true" : "false"
+ );
+
+/*
// if the source has empty alias use a time stamp
if (newsrc.alias().empty())
{
@@ -1112,12 +1213,14 @@
alias += timestamp ();
newsrc.setAlias( alias );
- y2milestone("Using time stamp '%s' as the alias", alias.c_str());
+ y2milestone("Using string '%s' as the alias", alias.c_str());
}
zypp::SourceManager::SourceId id = zypp::SourceManager::sourceManager()->addSource( newsrc );
y2milestone("Added source %lu: %s %s (alias %s)", id, new_url.asString().c_str(), path_r.asString().c_str(), alias.c_str() );
- return id;
+*/
+
+ return 0; //TODO FIXME
}
/****************************************************************************************
@@ -1161,6 +1264,8 @@
YCPValue
PkgModuleFunctions::SourceScan (const YCPString& media, const YCPString& pd)
{
+#warning FIXME: libzypp doesn provide zypp::SourceFactory
+/*
zypp::SourceFactory factory;
@@ -1177,9 +1282,9 @@
}
zypp::Pathname pn(pd->value ());
-
+*/
YCPList ids;
- unsigned int id;
+/* unsigned int id;
if ( pd->value().empty() ) {
// scan all sources
@@ -1237,6 +1342,7 @@
}
y2milestone("Found sources: %s", ids->toString().c_str() );
+*/
return ids;
}
@@ -1293,6 +1399,9 @@
{
y2debug("Creating source...");
+#warning SourceCreateEx is NOT implemented!!
+
+/* FIXME
zypp::SourceFactory factory;
zypp::Pathname pn(pd->value ());
@@ -1392,6 +1501,8 @@
PkgFreshen();
return YCPInteger(ret);
+ */
+ return YCPInteger(0LL);
}
@@ -1407,46 +1518,59 @@
YCPValue
PkgModuleFunctions::SourceSetEnabled (const YCPInteger& id, const YCPBoolean& e)
{
- zypp::Source_Ref src;
- bool enabled = e->value();
+ zypp::RepoInfo src;
+ bool enable = e->value();
- try {
- src = logFindSource(id->value());
+ try
+ {
+ src = logFindRepository(id->value()).info();
}
catch (const zypp::Exception& excpt)
{
return YCPBoolean(false);
}
+ // no change required
+ if ((enable && src.enabled())
+ || (!enable && !src.enabled()))
+ return YCPBoolean(true);
+
+ bool success = true;
+
try
{
- if (enabled)
- {
- src.enable();
- if (!src.resStoreInitialized ())
- {
- zypp_ptr()->addResolvables (src.resolvables());
- }
- }
+ src.setEnabled(enable);
+
+ zypp::RepoManager repomanager;
+ // this is offline change
+ repomanager.modifyRepository(src.alias(), src);
+
+ // update Repository
+ zypp::Repository r;
+
+ r = logFindRepository(id->value());
+
+ // add/remove resolvables
+ if (enable)
+ zypp_ptr()->addResolvables(r.resolvables());
else
- {
- src.disable();
- // remove the resolvables if they have been added
- if (src.resStoreInitialized ())
- {
- zypp_ptr()->removeResolvables(src.resolvables());
- }
- }
+ zypp_ptr()->removeResolvables(r.resolvables());
+
+
+ // FIXME: needed?
+ // update 'repos' ?
+
PkgFreshen();
}
catch (const zypp::Exception& excpt)
{
- std::string url = src.url().asString();
- y2error ("Error for %s: %s", url.c_str(), excpt.asString().c_str());
- _last_error.setLastError(url + ": " + excpt.asUserString());
+ std::string alias = src.alias();
+ y2error ("Error for '%s': %s", alias.c_str(), excpt.asString().c_str());
+ _last_error.setLastError(alias + ": " + excpt.asUserString());
+ success = false;
}
- return YCPBoolean(src.enabled() == enabled);
+ return YCPBoolean(success);
}
/****************************************************************************************
@@ -1462,19 +1586,22 @@
YCPValue
PkgModuleFunctions::SourceSetAutorefresh (const YCPInteger& id, const YCPBoolean& e)
{
- zypp::Source_Ref src;
+ zypp::RepoInfo src;
- try
- {
- src = logFindSource(id->value());
+ try {
+ src = logFindRepository(id->value()).info();
}
catch (const zypp::Exception& excpt)
{
- return YCPVoid();
+ return YCPBoolean(false);
}
src.setAutorefresh(e->value());
+ zypp::RepoManager repomanager;
+ // this is offline change
+ repomanager.modifyRepository(src.alias(), src);
+
return YCPBoolean( true );
}
@@ -1504,22 +1631,27 @@
YCPValue
PkgModuleFunctions::SourceRefreshNow (const YCPInteger& id)
{
- zypp::Source_Ref src;
+ zypp::RepoInfo src;
try {
- src = logFindSource(id->value());
+ src = logFindRepository(id->value()).info();
}
catch (const zypp::Exception& excpt)
{
return YCPBoolean(false);
}
- try {
- src.refresh();
- } catch ( const zypp::Exception & expt ) {
- y2error ("Error while refreshin the source: %s", expt.asString().c_str());
+ try
+ {
+ zypp::RepoManager repomanager;
+ repomanager.refreshMetadata(src);
+ }
+ catch ( const zypp::Exception & expt )
+ {
+ y2error ("Error while refreshing the source: %s", expt.asString().c_str());
return YCPBoolean(false);
}
+
return YCPBoolean( true );
}
@@ -1537,31 +1669,46 @@
YCPValue
PkgModuleFunctions::SourceDelete (const YCPInteger& id)
{
- zypp::SourceManager::SourceId src_id = id->value();
+ zypp::RepoInfo src;
+
try
{
- zypp::Source_Ref src = zypp::SourceManager::sourceManager()->
- findSource(src_id);
- // If the source cache is corrupt for any reason, inst_source
- // would first try to access the resolvables only now,
- // preventing the deletion of the broken source. But we do
- // not need to remove resolvables that never got to the pool
- // in the first place. #174840.
- if (src.resStoreInitialized ())
- {
- zypp_ptr()->removeResolvables(src.resolvables());
- }
-
- zypp::SourceManager::sourceManager()->removeSource(src_id);
+ src = logFindRepository(id->value()).info();
}
catch (const zypp::Exception& excpt)
{
- y2error("Pkg::SourceDelete: Cannot remove source %lld", id->value());
- _last_error.setLastError(excpt.asUserString());
return YCPBoolean(false);
}
- return YCPBoolean(true);
+ bool success = true;
+
+ try
+ {
+ // update Repository
+ zypp::Repository r;
+
+ r = logFindRepository(id->value());
+
+ // remove resolvables
+ zypp_ptr()->removeResolvables(r.resolvables());
+
+ // update 'repos'
+ repos.remove(r);
+
+ zypp::RepoManager repomanager;
+ repomanager.removeRepository(src);
+
+ PkgFreshen();
+ }
+ catch (const zypp::Exception& excpt)
+ {
+ std::string alias = src.alias();
+ y2error ("Error for '%s': %s", alias.c_str(), excpt.asString().c_str());
+ _last_error.setLastError(alias + ": " + excpt.asUserString());
+ success = false;
+ }
+
+ return YCPBoolean(success);
}
/****************************************************************************************
@@ -1583,24 +1730,13 @@
PkgModuleFunctions::SourceEditGet ()
{
YCPList ret;
- std::listzypp::SourceManager::SourceId ids = zypp::SourceManager::sourceManager()->allSources();
- for( std::listzypp::SourceManager::SourceId::iterator it = ids.begin(); it != ids.end(); ++it)
+ for( std::listzypp::Repository::const_iterator it = repos.begin(); it != repos.end(); ++it)
{
YCPMap src_map;
- zypp::Source_Ref src;
-
- try
- {
- src = zypp::SourceManager::sourceManager()->findSource(*it);
- }
- catch (const zypp::Exception& excpt)
- {
- // this should never happen
- y2internal("Source ID %lu not found: %s", *it, excpt.msg().c_str());
- }
+ zypp::RepoInfo src(it->info());
- src_map->add(YCPString("SrcId"), YCPInteger(*it));
+ src_map->add(YCPString("SrcId"), YCPInteger(it->numericId()));
src_map->add(YCPString("enabled"), YCPBoolean(src.enabled()));
src_map->add(YCPString("autorefresh"), YCPBoolean(src.autorefresh()));
src_map->add(YCPString("alias"), YCPString(src.alias()));
@@ -1647,11 +1783,13 @@
error = true;
continue;
}
- int id = descr->value( YCPString("SrcId") )->asInteger()->value();
- zypp::Source_Ref src;
- try {
- src = zypp::SourceManager::sourceManager()->findSource(id);
+ zypp::Repository::NumericId id = descr->value( YCPString("SrcId") )->asInteger()->value();
+
+ zypp::RepoInfo src;
+ try
+ {
+ src = logFindRepository(id).info();
}
catch (const zypp::Exception& excpt)
{
@@ -1661,6 +1799,8 @@
continue;
}
+ std::string old_alias = src.alias();
+
// now, we have the source
if( ! descr->value( YCPString("enabled")).isNull() && descr->value(YCPString("enabled"))->isBoolean ())
{
@@ -1668,26 +1808,29 @@
if (src.enabled() != enable)
{
- ycpwarning("Pkg::SourceEditSet() does not refresh the pool (src: %lu, state: %s)", src.numericId(), enable ? "disabled -> enabled" : "enabled -> disabled");
+ ycpwarning("Pkg::SourceEditSet() does not refresh the pool (src: %lu, state: %s)", id, enable ? "disabled -> enabled" : "enabled -> disabled");
}
- if( enable )
- src.enable();
- else
- src.disable();
+ src.setEnabled(enable);
}
if( !descr->value(YCPString("autorefresh")).isNull() && descr->value(YCPString("autorefresh"))->isBoolean ())
{
- src.setAutorefresh( descr->value(YCPString("autorefresh"))->asBoolean ()->value() );
+ src.setAutorefresh( descr->value(YCPString("autorefresh"))->asBoolean()->value() );
}
if( !descr->value(YCPString("alias")).isNull() && descr->value(YCPString("alias"))->isString())
{
// rename the source
- zypp::SourceManager::sourceManager()->renameSource(src.numericId(), descr->value(YCPString("alias"))->asString()->value() );
+ src.setAlias(descr->value(YCPString("alias"))->asString()->value());
}
+ zypp::RepoManager repomanager;
+
+ repomanager.modifyRepository(old_alias, src);
+
+#warning FIXME create a new Repository
+
#warning SourceEditSet ordering not implemented yet
}
@@ -1713,10 +1856,12 @@
YCPValue
PkgModuleFunctions::SourceRaisePriority (const YCPInteger& id)
{
- zypp::Source_Ref src;
+#warning SourceRaisePriority is not implemented
+ y2warning("SourceRaisePriority is NOT implemented");
+/* zypp::Source_Ref src;
try {
- src = logFindSource(id->value());
+ src = logFindRepository(id->value());
}
catch (const zypp::Exception& excpt)
{
@@ -1725,8 +1870,10 @@
// raise priority by one
src.setPriority(src.priority() + 1);
+*/
return YCPBoolean( true );
+
}
/****************************************************************************************
@@ -1741,10 +1888,13 @@
YCPValue
PkgModuleFunctions::SourceLowerPriority (const YCPInteger& id)
{
+#warning SourceLowerPriority is not implemented
+ y2warning("SourceLowerPriority is NOT implemented");
+/*
zypp::Source_Ref src;
try {
- src = logFindSource(id->value());
+ src = logFindRepository(id->value());
}
catch (const zypp::Exception& excpt)
{
@@ -1753,7 +1903,7 @@
// lower priority by one
src.setPriority(src.priority() - 1);
-
+*/
return YCPBoolean( true );
}
@@ -1781,6 +1931,9 @@
YCPValue
PkgModuleFunctions::SourceMoveDownloadArea (const YCPString & path)
{
+#warning SourceMoveDownloadArea is NOT implemented
+// TODO FIXME
+ /*
try
{
y2milestone( "Moving download area of all sources to %s", path->value().c_str()) ;
@@ -1794,7 +1947,7 @@
}
y2milestone( "Download areas moved");
-
+*/
return YCPBoolean(true);
}
Modified: branches/REFACTORING-10_3/pkg-bindings/src/Target.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/REFACTORING-10_3/pkg-bindings/src/Target.cc?rev=39170&r1=39169&r2=39170&view=diff
==============================================================================
--- branches/REFACTORING-10_3/pkg-bindings/src/Target.cc (original)
+++ branches/REFACTORING-10_3/pkg-bindings/src/Target.cc Wed Jul 4 15:35:52 2007
@@ -38,7 +38,6 @@
#include
#include
-#include
#include
#include
@@ -146,6 +145,9 @@
{
try
{
+#warning TargetDisableSources is NOT implemented
+// FIXME: should it also remove from pool?
+/*
zypp::SourceManager::disableSourcesAt( _target_root );
// disable source refresh - workaround for #220056
@@ -161,6 +163,7 @@
it->setAutorefresh(false);
store.storeSource( *it );
}
+*/
}
catch (zypp::Exception & excpt)
{
@@ -168,7 +171,6 @@
ycperror("TargetDisableSources has failed: %s", excpt.msg().c_str() );
return YCPBoolean(false);
}
-
return YCPBoolean(true);
}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org