ref: refs/heads/master
commit ceb5b4767315bdf41cd94081e79c0c9b5a2ac656
Author: Michael Andres
Date: Tue Oct 6 16:27:29 2009 +0200
Return update messages via ZYppCommitResult. (fate #301175)
---
zypp/ZYppCommitResult.cc | 40 ++++++++++++++++++++++
zypp/ZYppCommitResult.h | 82 +++++++++++++++++++++++++++++++++------------
zypp/target/TargetImpl.cc | 35 +++++++++++--------
3 files changed, 120 insertions(+), 37 deletions(-)
diff --git a/zypp/ZYppCommitResult.cc b/zypp/ZYppCommitResult.cc
index eaf186c..ed9b62e 100644
--- a/zypp/ZYppCommitResult.cc
+++ b/zypp/ZYppCommitResult.cc
@@ -18,12 +18,52 @@
namespace zypp
{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : ZYppCommitResult::Impl
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ class ZYppCommitResult::Impl
+ {
+ public:
+ Impl()
+ {}
+
+ public:
+ UpdateNotifications _updateMessages;
+
+ private:
+ friend Impl * rwcowClone<Impl>( const Impl * rhs );
+ /** clone for RWCOW_pointer */
+ Impl * clone() const { return new Impl( *this ); }
+ };
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : ZYppCommitResult
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ ZYppCommitResult::ZYppCommitResult()
+ : _result(0), _pimpl( new Impl )
+ {}
+
+ const UpdateNotifications & ZYppCommitResult::updateMessages() const
+ { return _pimpl->_updateMessages; }
+
+ UpdateNotifications & ZYppCommitResult::setUpdateMessages()
+ { return _pimpl->_updateMessages; }
+
+ ///////////////////////////////////////////////////////////////////
+
std::ostream & operator<<( std::ostream & str, const ZYppCommitResult & obj )
{
str << "CommitResult " << obj._result
<< " (errors " << obj._errors.size()
<< ", remaining " << obj._remaining.size()
<< ", srcremaining " << obj._srcremaining.size()
+ << ", updateMessages " << obj.updateMessages().size()
<< ")";
return str;
}
diff --git a/zypp/ZYppCommitResult.h b/zypp/ZYppCommitResult.h
index bf28652..ae65611 100644
--- a/zypp/ZYppCommitResult.h
+++ b/zypp/ZYppCommitResult.h
@@ -21,39 +21,77 @@
namespace zypp
{ /////////////////////////////////////////////////////////////////
+ /** Pair of \ref sat::Solvable and \ref Pathname. */
+ class UpdateNotificationFile
+ {
+ public:
+ UpdateNotificationFile( sat::Solvable solvable_r, const Pathname & file_r )
+ : _solvable( solvable_r ), _file( file_r )
+ {}
+ public:
+ sat::Solvable solvable() const { return _solvable; }
+ const Pathname & file() const { return _file; }
+ private:
+ sat::Solvable _solvable;
+ Pathname _file;
+ };
+
+ typedef std::list<UpdateNotificationFile> UpdateNotifications;
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : ZYppCommitResult
//
/** Result returned from ZYpp::commit.
+ *
* \see \ref ZYpp::commit
* \todo document fields.
- */
- struct ZYppCommitResult
+ */
+ class ZYppCommitResult
{
- ZYppCommitResult()
- : _result(0)
- {}
+ public:
+ ZYppCommitResult();
+
+ public:
+ /** List of update messages installed during this commit.
+ * \Note Pathnames are relative to the targets root directory.
+ */
+ const UpdateNotifications & updateMessages() const;
- typedef std::list<PoolItem> PoolItemList;
+ /** Change list of update messages installed during this commit.
+ * \Note Pathnames are relative to the targets root directory.
+ */
+ UpdateNotifications & setUpdateMessages();
- /**
- * number of committed resolvables
- **/
- int _result;
+ public:
+ /** \name Oldstlye interface to be removed asap.
+ */
+ //@{
+ typedef std::list<PoolItem> PoolItemList;
+ /**
+ * number of committed resolvables
+ **/
+ int _result;
+ /**
+ * list of resolvables with error
+ **/
+ PoolItemList _errors;
+ /**
+ * list of resolvables remaining (due to wrong media)
+ **/
+ PoolItemList _remaining;
+ /**
+ * list of kind:source resolvables remaining (due to wrong media)
+ **/
+ PoolItemList _srcremaining;
+ //@}
- /**
- * list of resolvables with error
- **/
- PoolItemList _errors;
- /**
- * list of resolvables remaining (due to wrong media)
- **/
- PoolItemList _remaining;
- /**
- * list of kind:source resolvables remaining (due to wrong media)
- **/
- PoolItemList _srcremaining;
+ public:
+ /** Implementation */
+ class Impl;
+ private:
+ /** Pointer to data. */
+ RWCOW_pointer<Impl> _pimpl;
};
///////////////////////////////////////////////////////////////////
diff --git a/zypp/target/TargetImpl.cc b/zypp/target/TargetImpl.cc
index 8245fa0..f1f4b73 100644
--- a/zypp/target/TargetImpl.cc
+++ b/zypp/target/TargetImpl.cc
@@ -200,6 +200,8 @@ namespace zypp
/** Look for update scripts named 'name-version-release-*' and
* execute them. Return \c false if \c ABORT was requested.
+ *
+ * \see http://en.opensuse.org/Software_Management/Code11/Scripts_and_Messages
*/
bool RunUpdateScripts( const Pathname & root_r,
const Pathname & scriptsPath_r,
@@ -270,7 +272,7 @@ namespace zypp
void sendNotification( const Pathname & root_r,
const Pathname & messagesPath_r,
- const std::listsat::Solvable,Pathname > & notifications_r )
+ const UpdateNotifications & notifications_r )
{
if ( notifications_r.empty() )
return;
@@ -321,7 +323,7 @@ namespace zypp
for_( it, notifications_r.begin(), notifications_r.end() )
{
if ( format == SINGLE )
- command.front() = "<"+Pathname::assertprefix( root_r, it->second ).asString();
+ command.front() = "<"+Pathname::assertprefix( root_r, it->file() ).asString();
ExternalProgram prog( command, ExternalProgram::Stderr_To_Stdout, false, -1, true, root_r );
if ( true ) // Wait for feedback
{
@@ -347,11 +349,11 @@ namespace zypp
{
if ( format == DIGEST )
{
- out << it->second << endl;
+ out << it->file() << endl;
}
else if ( format == BULK )
{
- copyTo( out << '\f', Pathname::assertprefix( root_r, it->second ) );
+ copyTo( out << '\f', Pathname::assertprefix( root_r, it->file() ) );
}
}
@@ -383,10 +385,13 @@ namespace zypp
/** Look for update messages named 'name-version-release-*' and
* send notification according to \ref ZConfig::updateMessagesNotify.
+ *
+ * \see http://en.opensuse.org/Software_Management/Code11/Scripts_and_Messages
*/
void RunUpdateMessages( const Pathname & root_r,
const Pathname & messagesPath_r,
- const std::vectorsat::Solvable & checkPackages_r )
+ const std::vectorsat::Solvable & checkPackages_r,
+ ZYppCommitResult & result_r )
{
if ( checkPackages_r.empty() )
return; // no installed packages to check
@@ -394,16 +399,14 @@ namespace zypp
MIL << "Looking for new update messages in (" << root_r << ")" << messagesPath_r << endl;
Pathname messagesDir( Pathname::assertprefix( root_r, messagesPath_r ) );
if ( ! PathInfo( messagesDir ).isDir() )
- return; // no script dir
+ return; // no messages dir
std::liststd::string messages;
filesystem::readdir( messages, messagesDir, /*dots*/false );
if ( messages.empty() )
return; // no messages in message dir
- // Now collect all matching messages in notifications and send them.
- std::listsat::Solvable,Pathname > notifications;
-
+ // Now collect all matching messages in result and send them
HistoryLog historylog;
for_( it, checkPackages_r.begin(), checkPackages_r.end() )
{
@@ -419,11 +422,11 @@ namespace zypp
MIL << "Found update message " << *sit << endl;
Pathname localPath( messagesPath_r/(*sit) ); // without root prefix
+ result_r.setUpdateMessages().push_back( UpdateNotificationFile( *it, localPath ) );
historylog.comment( str::Str() << _("New update message") << " " << localPath, /*timestamp*/true );
- notifications.push_back( std::make_pair( *it, localPath ) );
}
}
- sendNotification( root_r, messagesPath_r, notifications );
+ sendNotification( root_r, messagesPath_r, result_r.updateMessages() );
}
/////////////////////////////////////////////////////////////////
@@ -431,9 +434,10 @@ namespace zypp
///////////////////////////////////////////////////////////////////
void XRunUpdateMessages( const Pathname & root_r,
- const Pathname & messagesPath_r,
- const std::vectorsat::Solvable & checkPackages_r )
- { RunUpdateMessages( root_r, messagesPath_r, checkPackages_r ); }
+ const Pathname & messagesPath_r,
+ const std::vectorsat::Solvable & checkPackages_r,
+ ZYppCommitResult & result_r )
+ { RunUpdateMessages( root_r, messagesPath_r, checkPackages_r, result_r ); }
/** Helper for PackageProvider queries during commit. */
struct QueryInstalledEditionHelper
@@ -1357,7 +1361,8 @@ namespace zypp
if ( ! successfullyInstalledPackages.empty() )
{
RunUpdateMessages( _root, ZConfig::instance().update_messagesPath(),
- successfullyInstalledPackages );
+ successfullyInstalledPackages,
+ result_r );
if ( ! RunUpdateScripts( _root, ZConfig::instance().update_scriptsPath(),
successfullyInstalledPackages, abort ) )
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org