ref: refs/heads/ma-misc
commit 00ebdfb6fbd938f8f7dbb5ff9ac416e1eff600ea
Author: Michael Andres
Date: Wed Sep 23 19:42:03 2009 +0200
Add zypp.conf option update.messages.notify: Command to be invoked to send update messages.
---
zypp.conf | 37 +++++++++++++++++++++++
zypp/ZConfig.cc | 87 ++++++++++++++++++++++++++++++++++++------------------
zypp/ZConfig.h | 10 ++++++
3 files changed, 105 insertions(+), 29 deletions(-)
diff --git a/zypp.conf b/zypp.conf
index 32c1b44..f70b00f 100644
--- a/zypp.conf
+++ b/zypp.conf
@@ -340,6 +340,43 @@
# update.scriptsdir = /var/adm/update-scripts
##
+## Command to be invoked to send update messages.
+##
+## Packages may leave an update message file in {update.messagesdir}.
+## At the end of each commit, zypp collects those messages and may send
+## a notification to the user.
+##
+## zypp will prepare the update messages according to the selected
+## content format and pipe the content to the command.
+##
+## Format:
+## single - For each update message invoke the command and send
+## the message.
+## none - For each update message invoke the command but don't
+## use a pipe to send any data. You probably want to pass
+## the message file on the commandline using %P (see
+## Substitutions).
+## digest - Single invocation of the command, sending the path
+## names of all update message. One per line.
+## bulk - Single invocation of the command, sending the
+## concatenated content of all update messages, separated
+## by Ctrl-L.
+##
+## Substitutions:
+## %p - package identification (name-version-release.arch)
+## %P - full path to the update message file
+##
+## Valid values: The value is specified as "format | command".
+## An empty value will turn off any notification.
+##
+## Examples: single | mail -s 'Update message from %p' root
+## none | my-send-script -f %P
+##
+## Default value: single | /usr/lib/zypp/notify-message -p %p
+##
+# update.messages.notify = single | /usr/lib/zypp/notify-message -p %p
+
+##
## Options for package installation: excludedocs
##
## Don't install any files which are marked as documentation.
diff --git a/zypp/ZConfig.cc b/zypp/ZConfig.cc
index 69cab62..86dec13 100644
--- a/zypp/ZConfig.cc
+++ b/zypp/ZConfig.cc
@@ -135,35 +135,45 @@ namespace zypp
} // namespace zypp
///////////////////////////////////////////////////////////////////
- /** Mutable option with initial value. */
- template
+ /** Mutable option. */
+ template<class _Tp>
struct Option
{
typedef _Tp value_type;
- /** Default ctor sets _Initial. */
- Option()
- : _val( _Initial )
+ /** No default ctor, explicit initialisation! */
+ Option( const value_type & initial_r )
+ : _val( initial_r )
{}
/** Get the value. */
- value_type get() const
+ const value_type & get() const
{ return _val; }
+ operator const value_type &() const
+ { return _val; }
+
/** Set a new value. */
void set( const value_type & newval_r )
{ _val = newval_r; }
+ value_type & ref()
+ { return _val; }
+
private:
value_type _val;
};
/** Mutable option with initial value also remembering a config value. */
- template
- struct DefaultOption : public Option<_Tp,_Initial>
+ template<class _Tp>
+ struct DefaultOption : public Option<_Tp>
{
- typedef _Tp value_type;
- typedef Option<_Tp,_Initial> option_type;
+ typedef _Tp value_type;
+ typedef Option<_Tp> option_type;
+
+ DefaultOption( const value_type & initial_r )
+ : Option<_Tp>( initial_r ), _default( initial_r )
+ {}
/** Reset value to the current default. */
void restoreToDefault()
@@ -174,7 +184,7 @@ namespace zypp
{ setDefault( newval_r ); restoreToDefault(); }
/** Get the current default value. */
- value_type getDefault() const
+ const value_type & getDefault() const
{ return _default.get(); }
/** Set a new default value. */
@@ -201,15 +211,21 @@ namespace zypp
: _parsedZyppConf ( override_r )
, cfg_arch ( defaultSystemArchitecture() )
, cfg_textLocale ( defaultTextLocale() )
+ , updateMessagesNotify ( "single | /usr/lib/zypp/notify-message -p %p" )
, repo_add_probe ( false )
, repo_refresh_delay ( 10 )
, download_use_deltarpm ( true )
, download_use_deltarpm_always ( false )
- , download_max_concurrent_connections(2)
- , download_min_download_speed(0)
- , download_max_download_speed(0)
- , download_max_silent_tries(5)
- , apply_locks_file ( true )
+ , download_media_prefer_download( true )
+ , download_max_concurrent_connections( 2 )
+ , download_min_download_speed ( 0 )
+ , download_max_download_speed ( 0 )
+ , download_max_silent_tries ( 5 )
+ , commit_downloadMode ( DownloadDefault )
+ , solver_onlyRequires ( false )
+ , solver_allowVendorChange ( false )
+ , solver_upgradeTestcasesToKeep ( 2 )
+ , apply_locks_file ( true )
{
MIL << "libzypp: " << VERSION << " built " << __DATE__ << " " << __TIME__ << endl;
@@ -330,11 +346,11 @@ namespace zypp
}
else if ( entry == "solver.onlyRequires" )
{
- solver_onlyRequires.set( str::strToBool( value, solver_onlyRequires.get() ) );
+ solver_onlyRequires.set( str::strToBool( value, solver_onlyRequires ) );
}
else if ( entry == "solver.allowVendorChange" )
{
- solver_allowVendorChange.set( str::strToBool( value, solver_allowVendorChange.get() ) );
+ solver_allowVendorChange.set( str::strToBool( value, solver_allowVendorChange ) );
}
else if ( entry == "solver.upgradeTestcasesToKeep" )
{
@@ -373,6 +389,10 @@ namespace zypp
{
update_messages_path = Pathname(value);
}
+ else if ( entry == "update.messages.notify" )
+ {
+ updateMessagesNotify.set( value );
+ }
else if ( entry == "rpm.install.excludedocs" )
{
rpmInstallFlags.setFlag( target::rpm::RPMINST_EXCLUDEDOCS,
@@ -437,24 +457,25 @@ namespace zypp
Pathname update_data_path;
Pathname update_scripts_path;
Pathname update_messages_path;
+ DefaultOptionstd::string updateMessagesNotify;
bool repo_add_probe;
unsigned repo_refresh_delay;
bool download_use_deltarpm;
bool download_use_deltarpm_always;
- DefaultOption download_media_prefer_download;
+ DefaultOption<bool> download_media_prefer_download;
int download_max_concurrent_connections;
int download_min_download_speed;
int download_max_download_speed;
int download_max_silent_tries;
- Option commit_downloadMode;
+ Option<DownloadMode> commit_downloadMode;
- Option solver_onlyRequires;
- Option solver_allowVendorChange;
- Option solver_upgradeTestcasesToKeep;
+ Option<bool> solver_onlyRequires;
+ Option<bool> solver_allowVendorChange;
+ Option<unsigned> solver_upgradeTestcasesToKeep;
Pathname solver_checkSystemFile;
std::set<IdString> multiversion;
@@ -638,7 +659,7 @@ namespace zypp
{ return download_use_deltarpm() && _pimpl->download_use_deltarpm_always; }
bool ZConfig::download_media_prefer_download() const
- { return _pimpl->download_media_prefer_download.get(); }
+ { return _pimpl->download_media_prefer_download; }
void ZConfig::set_download_media_prefer_download( bool yesno_r )
{ _pimpl->download_media_prefer_download.set( yesno_r ); }
@@ -659,20 +680,20 @@ namespace zypp
{ return _pimpl->download_max_silent_tries; }
DownloadMode ZConfig::commit_downloadMode() const
- { return _pimpl->commit_downloadMode.get(); }
+ { return _pimpl->commit_downloadMode; }
bool ZConfig::solver_onlyRequires() const
- { return _pimpl->solver_onlyRequires.get(); }
+ { return _pimpl->solver_onlyRequires; }
bool ZConfig::solver_allowVendorChange() const
- { return _pimpl->solver_allowVendorChange.get(); }
+ { return _pimpl->solver_allowVendorChange; }
Pathname ZConfig::solver_checkSystemFile() const
{ return ( _pimpl->solver_checkSystemFile.empty()
? (configPath()/"systemCheck") : _pimpl->solver_checkSystemFile ); }
unsigned ZConfig::solver_upgradeTestcasesToKeep() const
- { return _pimpl->solver_upgradeTestcasesToKeep.get(); }
+ { return _pimpl->solver_upgradeTestcasesToKeep; }
std::set<IdString> ZConfig::multiversion() const
{ return _pimpl->multiversion; }
@@ -698,13 +719,21 @@ namespace zypp
? Pathname(update_dataPath()/"update-messages") : _pimpl->update_messages_path );
}
-
Pathname ZConfig::update_scriptsPath() const
{
return ( _pimpl->update_scripts_path.empty()
? Pathname(update_dataPath()/"update-scripts") : _pimpl->update_scripts_path );
}
+ std::string ZConfig::updateMessagesNotify() const
+ { return _pimpl->updateMessagesNotify; }
+
+ void ZConfig::setUpdateMessagesNotify( const std::string & val_r )
+ { _pimpl->updateMessagesNotify.set( val_r ); }
+
+ void ZConfig::resetUpdateMessagesNotify()
+ { _pimpl->updateMessagesNotify.restoreToDefault(); }
+
///////////////////////////////////////////////////////////////////
target::rpm::RpmInstFlags ZConfig::rpmInstallFlags() const
diff --git a/zypp/ZConfig.h b/zypp/ZConfig.h
index cec14a0..3c24a33 100644
--- a/zypp/ZConfig.h
+++ b/zypp/ZConfig.h
@@ -282,6 +282,16 @@ namespace zypp
*/
Pathname update_messagesPath() const;
+ /** \name Command to be invoked to send update messages. */
+ //@{
+ /** Command definition for sending update messages.*/
+ std::string updateMessagesNotify() const;
+ /** Set a new command definition (see update.messages.notify in zypp.conf). */
+ void setUpdateMessagesNotify( const std::string & val_r );
+ /** Reset to the zypp.conf default. */
+ void resetUpdateMessagesNotify();
+ //@}
+
/** \name Options for package installation */
//@{
/** The default \ref target::rpm::RpmInstFlags for \ref ZYppCommitPolicy.
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org