Author: lslezak
Date: Wed Mar 5 15:56:02 2008
New Revision: 45220
URL: http://svn.opensuse.org/viewcvs/yast?rev=45220&view=rev
Log:
- added Pkg::CallbackStartRefresh() and Pkg::CallbackDoneRefresh()
callbacks, added Pkg::SkipRefresh() call to abort and skip
running source refresh (FATE #30962, bnc #231745)
Modified:
trunk/pkg-bindings/package/yast2-pkg-bindings.changes
trunk/pkg-bindings/src/Callbacks_Register.cc
trunk/pkg-bindings/src/PkgFunctions.h
trunk/pkg-bindings/src/Source_Load.cc
trunk/pkg-bindings/src/Source_Resolvables.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=45220&r1=45219&r2=45220&view=diff
==============================================================================
--- trunk/pkg-bindings/package/yast2-pkg-bindings.changes (original)
+++ trunk/pkg-bindings/package/yast2-pkg-bindings.changes Wed Mar 5 15:56:02 2008
@@ -1,4 +1,11 @@
-------------------------------------------------------------------
+Wed Mar 5 12:22:37 CET 2008 - lslezak@suse.cz
+
+- added Pkg::CallbackStartRefresh() and Pkg::CallbackDoneRefresh()
+ callbacks, added Pkg::SkipRefresh() call to abort and skip
+ running source refresh (FATE #30962, bnc #231745)
+
+-------------------------------------------------------------------
Wed Feb 27 09:04:14 CET 2008 - lslezak@suse.cz
- update - 'keep_intalled_patches' and 'delete_unmaintained' options
Modified: trunk/pkg-bindings/src/Callbacks_Register.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Callbacks_Register.cc?rev=45220&r1=45219&r2=45220&view=diff
==============================================================================
--- trunk/pkg-bindings/src/Callbacks_Register.cc (original)
+++ trunk/pkg-bindings/src/Callbacks_Register.cc Wed Mar 5 15:56:02 2008
@@ -715,4 +715,29 @@
return SET_YCP_CB( CB_ProcessProgress, func);
}
+
+/**
+ * @builtin CallbackStartRefresh
+ * @short Register a callback function
+ * @param string func Name of the callback handler function. Required callback prototype is <code>void()</code>.
+ * The callback function is evaluated when repository refresh is started
+ * @return void
+ */
+YCPValue PkgFunctions::CallbackStartRefresh( const YCPString& func )
+{
+ return SET_YCP_CB( CB_StartSourceRefresh, func);
+}
+
+/**
+ * @builtin CallbackDoneRefresh
+ * @short Register a callback function
+ * @param string func Name of the callback handler function. Required callback prototype is <code>void()</code>.
+ * The callback function is evaluated when repository refresh is finished
+ * @return void
+ */
+YCPValue PkgFunctions::CallbackDoneRefresh( const YCPString& func )
+{
+ return SET_YCP_CB( CB_DoneSourceRefresh, func);
+}
+
#undef SET_YCP_CB
Modified: trunk/pkg-bindings/src/PkgFunctions.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/PkgFunctions.h?rev=45220&r1=45219&r2=45220&view=diff
==============================================================================
--- trunk/pkg-bindings/src/PkgFunctions.h (original)
+++ trunk/pkg-bindings/src/PkgFunctions.h Wed Mar 5 15:56:02 2008
@@ -95,6 +95,9 @@
// table for converting libzypp source type to Yast type (for backward compatibility)
std::map type_conversion_table;
+
+ // flag for skipping autorefresh
+ volatile bool autorefresh_skipped;
// conversion methods for type string between Yast and libzypp (for backward compatibility)
std::string zypp2yastType(const std::string &type);
@@ -134,6 +137,8 @@
const zypp::ProgressData::ReceiverFnc & progressrcv = zypp::ProgressData::ReceiverFnc());
zypp::repo::RepoType ProbeWithCallbacks(const zypp::Url &url);
void ScanProductsWithCallBacks(const zypp::Url &url);
+ void CallRefreshStarted();
+ void CallRefreshDone();
YCPValue SourceLoadImpl(PkgProgress &progress);
YCPValue SourceStartManagerImpl(const YCPBoolean& enable, PkgProgress &progress);
@@ -305,6 +310,11 @@
/* TYPEINFO: void(string) */
YCPValue CallbackProgressReportEnd(const YCPString& func);
+ /* TYPEINFO: void(string) */
+ YCPValue CallbackStartRefresh( const YCPString& func );
+ /* TYPEINFO: void(string) */
+ YCPValue CallbackDoneRefresh( const YCPString& func );
+
// Script (patch installation) callbacks
/* TYPEINFO: void(string) */
YCPValue CallbackScriptStart( const YCPString& args );
@@ -478,6 +488,8 @@
YCPValue RepositoryScan(const YCPString& url);
/* TYPEINFO: integer(map)*/
YCPValue RepositoryAdd(const YCPMap ¶ms);
+ /* TYPEINFO: void()*/
+ YCPValue SkipRefresh();
// target related
/* TYPEINFO: boolean(string,boolean)*/
Modified: trunk/pkg-bindings/src/Source_Load.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Source_Load.cc?rev=45220&r1=45219&r2=45220&view=diff
==============================================================================
--- trunk/pkg-bindings/src/Source_Load.cc (original)
+++ trunk/pkg-bindings/src/Source_Load.cc Wed Mar 5 15:56:02 2008
@@ -125,6 +125,37 @@
return ret;
}
+void PkgFunctions::CallRefreshStarted()
+{
+ // get the YCP callback handler for destroy event
+ Y2Function* ycp_handler = _callbackHandler._ycpCallbacks.createCallback(CallbackHandler::YCPCallbacks::CB_StartSourceRefresh);
+
+ // is the callback registered?
+ if (ycp_handler != NULL)
+ {
+ // evaluate the callback function
+ ycp_handler->evaluateCall();
+ }
+}
+
+void PkgFunctions::CallRefreshDone()
+{
+ // get the YCP callback handler for destroy event
+ Y2Function* ycp_handler = _callbackHandler._ycpCallbacks.createCallback(CallbackHandler::YCPCallbacks::CB_DoneSourceRefresh);
+
+ // is the callback registered?
+ if (ycp_handler != NULL)
+ {
+ // evaluate the callback function
+ ycp_handler->evaluateCall();
+ }
+}
+
+YCPValue PkgFunctions::SkipRefresh()
+{
+ autorefresh_skipped = true;
+ return YCPVoid();
+}
/****************************************************************************************
* @builtin SourceLoad
@@ -140,16 +171,22 @@
bool success = true;
int repos_to_load = 0;
+ int repos_to_refresh = 0;
for (RepoCont::iterator it = repos.begin();
it != repos.end(); ++it)
{
if ((*it)->repoInfo().enabled() && !(*it)->isDeleted())
{
repos_to_load++;
+
+ if ((*it)->repoInfo().autorefresh())
+ {
+ repos_to_refresh++;
+ }
}
}
- y2debug("repos_to_load: %d", repos_to_load);
+ y2debug("repos_to_load: %d, repos_to_refresh: %d", repos_to_load, repos_to_refresh);
// set max. value (3 steps per repository - refresh, rebuild, load)
zypp::ProgressData prog_total(repos_to_load * 3 * 100);
@@ -158,46 +195,71 @@
zypp::RepoManager repomanager = CreateRepoManager();
- // refresh metadata
- for (RepoCont::iterator it = repos.begin();
- it != repos.end(); ++it)
+ autorefresh_skipped = false;
+ CallRefreshStarted();
+
+ if (repos_to_refresh > 0)
{
- // load resolvables only from enabled repos which are not deleted
- if ((*it)->repoInfo().enabled() && !(*it)->isDeleted())
+ // refresh metadata
+ for (RepoCont::iterator it = repos.begin();
+ it != repos.end(); ++it)
{
- // sub tasks
- zypp::CombinedProgressData refresh_subprogress(prog_total, 100);
- zypp::ProgressData prog(100);
- prog.sendTo(refresh_subprogress);
- y2debug("Progress status: %lld", prog_total.val());
-
- if (AnyResolvableFrom((*it)->repoInfo().alias()))
- {
- y2milestone("Resolvables from '%s' are already present, not loading", (*it)->repoInfo().alias().c_str());
- }
- else
+ // load resolvables only from enabled repos which are not deleted
+ if ((*it)->repoInfo().enabled() && !(*it)->isDeleted())
{
- // autorefresh the source
- if ((*it)->repoInfo().autorefresh())
+ // sub tasks
+ zypp::CombinedProgressData refresh_subprogress(prog_total, 100);
+ zypp::ProgressData prog(100);
+ prog.sendTo(refresh_subprogress);
+ y2debug("Progress status: %lld", prog_total.val());
+
+ if (AnyResolvableFrom((*it)->repoInfo().alias()))
{
- try
- {
- y2milestone("Autorefreshing source: %s", (*it)->repoInfo().alias().c_str());
- // refresh the repository
- RefreshWithCallbacks((*it)->repoInfo(), prog.receiver());
- }
- // NOTE: subtask progresses are reported as done in the descructor
- // no need to handle them in the exception code
- catch (const zypp::Exception& excpt)
+ y2milestone("Resolvables from '%s' are already present, not loading", (*it)->repoInfo().alias().c_str());
+ }
+ else
+ {
+ zypp::RepoStatus raw_metadata_status = repomanager.metadataStatus((*it)->repoInfo());
+
+ // autorefresh the source
+ if ((*it)->repoInfo().autorefresh() || raw_metadata_status.empty())
{
- y2error ("Error in SourceLoad: %s", excpt.asString().c_str());
- _last_error.setLastError(ExceptionAsString(excpt));
- success = false;
+ try
+ {
+ y2milestone("Autorefreshing source: %s", (*it)->repoInfo().alias().c_str());
+ // refresh the repository
+ RefreshWithCallbacks((*it)->repoInfo(), prog.receiver());
+ }
+ // NOTE: subtask progresses are reported as done in the destructor
+ // no need to handle them in the exception code
+ catch (const zypp::Exception& excpt)
+ {
+ if (autorefresh_skipped)
+ {
+ y2internal("autorefresh_skipped, ignoring the exception");
+ }
+ else
+ {
+ y2error ("Error in SourceLoad: %s", excpt.asString().c_str());
+ _last_error.setLastError(ExceptionAsString(excpt));
+ success = false;
+ }
+ }
+
+ if (autorefresh_skipped)
+ {
+ y2internal("Skipping autorefresh for the rest of repositories");
+ break;
+ }
+ else
+ {
+ y2internal("Continuing with autorefresh");
+ }
}
}
+ prog.toMax();
+ y2debug("Progress status: %lld", prog_total.val());
}
- prog.toMax();
- y2debug("Progress status: %lld", prog_total.val());
}
}
@@ -218,13 +280,25 @@
y2debug("Progress status: %lld", prog_total.val());
if (AnyResolvableFrom((*it)->repoInfo().alias()))
{
- y2milestone("Resolvables from '%s' are already present, not loading", (*it)->repoInfo().alias().c_str());
+ y2milestone("Resolvables from '%s' are already present, not rebuilding the cache", (*it)->repoInfo().alias().c_str());
}
else
{
// autorefresh the source
if ((*it)->repoInfo().autorefresh())
{
+ if (autorefresh_skipped)
+ {
+ zypp::RepoStatus raw_metadata_status = repomanager.metadataStatus((*it)->repoInfo());
+
+ // autorefresh the source
+ if (raw_metadata_status.empty() )
+ {
+ y2internal("Missinga metadata, not rebuilding the cache");
+ continue;
+ }
+ }
+
try
{
// rebuild cache (the default policy is "if needed")
@@ -237,9 +311,26 @@
// no need to handle them in the exception code
catch (const zypp::Exception& excpt)
{
- y2error ("Error in SourceLoad: %s", excpt.asString().c_str());
- _last_error.setLastError(ExceptionAsString(excpt));
- success = false;
+ if (autorefresh_skipped)
+ {
+ y2internal("autorefresh_skipped, ignoring the exception");
+ }
+ else
+ {
+ y2error ("Error in SourceLoad: %s", excpt.asString().c_str());
+ _last_error.setLastError(ExceptionAsString(excpt));
+ success = false;
+ }
+ }
+
+ if (autorefresh_skipped)
+ {
+ y2internal("Skipping autorefresh for the rest of repositories");
+ break;
+ }
+ else
+ {
+ y2internal("Continuing with autorefresh");
}
}
}
@@ -248,6 +339,8 @@
}
}
+ CallRefreshDone();
+
progress.NextStage();
for (RepoCont::iterator it = repos.begin();
@@ -277,6 +370,7 @@
// report 100%
prog_total.toMax();
+ autorefresh_skipped = false;
return YCPBoolean(success);
}
Modified: trunk/pkg-bindings/src/Source_Resolvables.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/pkg-bindings/src/Source_Resolvables.cc?rev=45220&r1=45219&r2=45220&view=diff
==============================================================================
--- trunk/pkg-bindings/src/Source_Resolvables.cc (original)
+++ trunk/pkg-bindings/src/Source_Resolvables.cc Wed Mar 5 15:56:02 2008
@@ -85,13 +85,18 @@
zypp::RepoManager repomanager = CreateRepoManager();
// build cache if needed
- if (!repomanager.isCached(repoinfo))
+ if (!repomanager.isCached(repoinfo) && !autorefresh_skipped)
{
zypp::RepoStatus raw_metadata_status = repomanager.metadataStatus(repoinfo);
if (raw_metadata_status.empty())
{
y2milestone("Missing metadata for source '%s', downloading...", repoinfo.alias().c_str());
+
+ CallRefreshStarted();
+
RefreshWithCallbacks(repoinfo);
+
+ CallRefreshDone();
}
y2milestone("Caching source '%s'...", repoinfo.alias().c_str());
@@ -103,10 +108,17 @@
}
catch(const zypp::repo::RepoNotCachedException &excpt )
{
- std::string alias = repoinfo.alias();
- y2error ("Resolvables from '%s' havn't been loaded: %s", alias.c_str(), excpt.asString().c_str());
- _last_error.setLastError("'" + alias + "': " + ExceptionAsString(excpt));
- success = false;
+ if (!autorefresh_skipped)
+ {
+ std::string alias = repoinfo.alias();
+ y2error ("Resolvables from '%s' havn't been loaded: %s", alias.c_str(), excpt.asString().c_str());
+ _last_error.setLastError("'" + alias + "': " + ExceptionAsString(excpt));
+ success = false;
+ }
+ else
+ {
+ y2internal("Autorefresh disabled, the cache is missing -> cannot load resolvables");
+ }
// FIXME ??
/*
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org