Author: lslezak
Date: Wed Dec 12 13:09:01 2007
New Revision: 43016
URL: http://svn.opensuse.org/viewcvs/yast?rev=43016&view=rev
Log:
- merged Pkg::SourceCreate() and Pkg::SourceScan() code
Modified:
trunk/pkg-bindings/package/yast2-pkg-bindings.changes
trunk/pkg-bindings/src/PkgModuleFunctions.h
trunk/pkg-bindings/src/Source_Create.cc
Modified: trunk/pkg-bindings/package/yast2-pkg-bindings.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/package/yast2-pkg-bindings.changes?rev=43016&r1=43015&r2=43016&view=diff
==============================================================================
--- trunk/pkg-bindings/package/yast2-pkg-bindings.changes (original)
+++ trunk/pkg-bindings/package/yast2-pkg-bindings.changes Wed Dec 12 13:09:01 2007
@@ -8,6 +8,7 @@
- PkgProgress - don't evaluate the callbacks when the progress
is not enabled (started)
- added total progress to Pkg::SourceCreate()
+- merged Pkg::SourceCreate() and Pkg::SourceScan() code
-------------------------------------------------------------------
Fri Dec 7 12:58:09 CET 2007 - lslezak@suse.cz
Modified: trunk/pkg-bindings/src/PkgModuleFunctions.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/PkgModuleFunctions.h?rev=43016&r1=43015&r2=43016&view=diff
==============================================================================
--- trunk/pkg-bindings/src/PkgModuleFunctions.h (original)
+++ trunk/pkg-bindings/src/PkgModuleFunctions.h Wed Dec 12 13:09:01 2007
@@ -428,7 +428,7 @@
YCPValue SourceCreateBase (const YCPString&, const YCPString&);
/* TYPEINFO: integer(string,string,string)*/
YCPValue SourceCreateType (const YCPString& media, const YCPString& pd, const YCPString& type);
- YCPValue SourceCreateEx (const YCPString&, const YCPString&, bool, const YCPString& source_type);
+ YCPValue SourceCreateEx (const YCPString&, const YCPString&, bool, const YCPString& source_type, bool scan_only = false);
/* TYPEINFO: list<integer>(boolean)*/
YCPValue SourceStartCache (const YCPBoolean&);
/* TYPEINFO: boolean()*/
Modified: trunk/pkg-bindings/src/Source_Create.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Source_Create.cc?rev=43016&r1=43015&r2=43016&view=diff
==============================================================================
--- trunk/pkg-bindings/src/Source_Create.cc (original)
+++ trunk/pkg-bindings/src/Source_Create.cc Wed Dec 12 13:09:01 2007
@@ -560,7 +560,7 @@
}
YCPValue
-PkgModuleFunctions::SourceCreateEx (const YCPString& media, const YCPString& pd, bool base, const YCPString& source_type)
+PkgModuleFunctions::SourceCreateEx (const YCPString& media, const YCPString& pd, bool base, const YCPString& source_type, bool scan_only)
{
y2debug("Creating source...");
@@ -578,10 +578,6 @@
return YCPInteger (-1LL);
}
-
- YCPList ids;
- std::vectorzypp::RepoInfo::size_type ret = -1LL;
-
const std::string type = source_type->value();
const bool scan = pd->value().empty();
@@ -602,7 +598,11 @@
stages.push_back(_("Download Descriptions"));
stages.push_back(_("Rebuild Cache"));
- stages.push_back(_("Load Data"));
+
+ if (!scan_only)
+ {
+ stages.push_back(_("Load Data"));
+ }
pkgprogress.Start(_("Adding the Repository..."), stages, _("TODO: help"));
@@ -610,6 +610,9 @@
prg.sendTo(pkgprogress.Receiver());
prg.toMin();
+ // remember the new ids for loading the resolvables
+ std::listzypp::RepoInfo::size_type> new_repos;
+
if (scan) {
// scan all sources
zypp::MediaProductSet products;
@@ -636,9 +639,6 @@
prg.set(5);
pkgprogress.NextStage();
- // remember the new ids for loading the resolvables
- std::listzypp::RepoInfo::size_type> new_repos;
-
// register the repositories
for( zypp::MediaProductSet::const_iterator it = products.begin();
it != products.end() ; ++it )
@@ -661,31 +661,30 @@
}
}
- // load resolvables
- for(std::listzypp::RepoInfo::size_type>::const_iterator it = new_repos.begin();
- it != new_repos.end() ; ++it )
+ if (!scan_only)
{
- zypp::CombinedProgressData subprogrcv2(prg, 10/products.size());
-
- try
+ // load resolvables
+ for(std::listzypp::RepoInfo::size_type>::const_iterator it = new_repos.begin();
+ it != new_repos.end() ; ++it )
{
- YRepo_Ptr repo = logFindRepository(*it);
+ zypp::CombinedProgressData subprogrcv2(prg, 10/products.size());
- // no detailed progress needed, refresh has been done in createManagedSource()
- LoadResolvablesFrom(repo->repoInfo(), subprogrcv2);
- }
- catch ( const zypp::Exception& excpt)
- {
- y2error("SourceCreate for '%s' product '%s' has failed"
- , url.asString().c_str(), pn.asString().c_str());
- _last_error.setLastError(ExceptionAsString(excpt));
- return YCPInteger(-1LL);
+ try
+ {
+ YRepo_Ptr repo = logFindRepository(*it);
+
+ // no detailed progress needed, refresh has been done in createManagedSource()
+ LoadResolvablesFrom(repo->repoInfo(), subprogrcv2);
+ }
+ catch ( const zypp::Exception& excpt)
+ {
+ y2error("SourceCreate for '%s' product '%s' has failed"
+ , url.asString().c_str(), pn.asString().c_str());
+ _last_error.setLastError(ExceptionAsString(excpt));
+ return YCPInteger(-1LL);
+ }
}
}
-
- // return ID of the _first_ repository
- ret = *new_repos.begin();
-
} else {
y2debug("Creating source...");
@@ -694,14 +693,18 @@
try
{
- ret = createManagedSource(url, pn, base, type, "", pkgprogress, subprogrcv_create);
- pkgprogress.NextStage();
+ std::vectorzypp::RepoInfo::size_type new_id = createManagedSource(url, pn, base, type, "", pkgprogress, subprogrcv_create);
+ new_repos.push_back(new_id);
- YRepo_Ptr repo = logFindRepository(ret);
- repo->repoInfo().setEnabled(true);
+ if (!scan_only)
+ {
+ pkgprogress.NextStage();
+
+ YRepo_Ptr repo = logFindRepository(new_id);
- // load the resolvables
- LoadResolvablesFrom(repo->repoInfo(), subprogrcv_load);
+ // load the resolvables
+ LoadResolvablesFrom(repo->repoInfo(), subprogrcv_load);
+ }
}
catch ( const zypp::Exception& excpt)
{
@@ -713,9 +716,24 @@
prg.toMax();
- PkgFreshen();
+ if (!scan_only)
+ {
+ PkgFreshen();
+ return YCPInteger(*new_repos.begin());
+ }
+ else
+ {
+ YCPList ids;
- return YCPInteger(ret);
+ // load resolvables
+ for(std::listzypp::RepoInfo::size_type>::const_iterator it = new_repos.begin();
+ it != new_repos.end() ; ++it )
+ {
+ ids->add(YCPInteger(*it));
+ }
+
+ return ids;
+ }
}
/****************************************************************************************
@@ -797,87 +815,8 @@
YCPValue
PkgModuleFunctions::SourceScan (const YCPString& media, const YCPString& pd)
{
- zypp::Url url;
-
- try {
- url = zypp::Url(media->value ());
- }
- catch(const zypp::Exception & expt )
- {
- y2error ("Invalid URL: %s", expt.asString().c_str());
- _last_error.setLastError(ExceptionAsString(expt));
- return YCPList();
- }
-
- zypp::Pathname pn(pd->value ());
-
- YCPList ids;
- std::vectorzypp::RepoInfo::size_type id;
-
- // TODO add total progress
- PkgProgress pkgprogress(_callbackHandler);
-
- if ( pd->value().empty() ) {
-
- // scan all sources
- zypp::MediaProductSet products;
-
- try
- {
- y2milestone("Scanning products in %s ...", url.asString().c_str());
- ScanProductsWithCallBacks(url);
- products = available_products;
- }
- catch ( const zypp::Exception& excpt)
- {
- y2error("Scanning products for '%s' has failed"
- , url.asString().c_str());
- _last_error.setLastError(ExceptionAsString(excpt));
- return ids;
- }
-
- if( products.empty() )
- {
- // no products found, use the base URL instead
- zypp::MediaProductEntry entry;
- products.insert(entry);
- }
-
- for( zypp::MediaProductSet::const_iterator it = products.begin();
- it != products.end() ; ++it )
- {
- try
- {
- y2milestone("Using product %s in directory %s", it->_name.c_str(), it->_dir.c_str());
- id = createManagedSource(url, it->_dir, false, "", it->_name, pkgprogress);
- ids->add( YCPInteger(id) );
- }
- catch ( const zypp::Exception& excpt)
- {
- y2error("SourceScan for '%s' product '%s' has failed"
- , url.asString().c_str(), pn.asString().c_str());
- _last_error.setLastError(ExceptionAsString(excpt));
- }
- }
- } else {
- y2debug("Creating source...");
-
- try
- {
- id = createManagedSource(url, pn, false, "", "", pkgprogress);
- ids->add( YCPInteger(id) );
- }
- catch ( const zypp::Exception& excpt)
- {
- y2error("SourceScan for '%s' product '%s' has failed"
- , url.asString().c_str(), pn.asString().c_str());
- _last_error.setLastError(ExceptionAsString(excpt));
- }
- }
-
- y2milestone("Found sources: %s", ids->toString().c_str() );
-
- return ids;
+ // not base product, autoprobe source type, scanning only
+ return SourceCreateEx(media, pd, false, YCPString(""), true);
}
/****************************************************************************************
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org