ref: refs/heads/master
commit 680feb2ad8a02e6b5f69bef1c3dcf0d5a1892292
Author: Michael Andres
Date: Tue Mar 31 15:47:02 2009 +0200
Add zypp.conf(download.media_preference): Hint which media to prefer when installing packages (download vs. CD).
---
zypp.conf | 26 +++++++++++++++++++++++
zypp/ZConfig.cc | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
zypp/ZConfig.h | 17 +++++++++++++++
3 files changed, 102 insertions(+), 2 deletions(-)
diff --git a/zypp.conf b/zypp.conf
index 99f84af..93071ba 100644
--- a/zypp.conf
+++ b/zypp.conf
@@ -171,6 +171,32 @@
# download.use_deltarpm.always = false
##
+## Hint which media to prefer when installing packages (download vs. CD).
+##
+## Valid values: download, volatile
+## Default value: download
+##
+## Note that this just a hint. First of all the solver will choose the 'best'
+## package according to its repos proiority, version and architecture. But if
+## there is a choice, we will prefer packages from the desired media.
+##
+## Packages available loacaly are always prefered. The question is whether
+## you prefer packages being downloaded via FTP/HTTP/HTTPS (download), rather
+## than being prompted to insert a CD/DVD (volatile), in case they are available
+## on both media.
+##
+## Name | Priority | URI
+## openSUSE-11.1 99 dvd:///
+## openSUSE-11.1-Oss 99 http://download.opensuse.org/distribution/11.1/repo/oss
+##
+## In the above example 2 repositories with similar content are used. Rather
+## than raising the priority of one of them to 'prefer' a certain media, you
+## should use the same priority for both and set download.media_preference
+## instead.
+##
+## download.media_preference = download
+
+##
## Defining directory which contains vendor description files.
##
## One file in this directory reflects a group of equivalent vendors. e.G.:
diff --git a/zypp/ZConfig.cc b/zypp/ZConfig.cc
index 50b5551..be1c3d4 100644
--- a/zypp/ZConfig.cc
+++ b/zypp/ZConfig.cc
@@ -134,6 +134,49 @@ namespace zypp
} // namespace zypp
///////////////////////////////////////////////////////////////////
+ /** Mutable option with initial value. */
+ template
+ struct Option
+ {
+ typedef _Tp value_type;
+
+ Option()
+ : _val( _Initial )
+ {}
+
+ value_type get() const
+ { return _val; }
+
+ void set( const value_type & newval_r )
+ { _val = newval_r; }
+
+ private:
+ value_type _val;
+ };
+
+ /** Mutable option with initial value also remembering a config value. */
+ template
+ struct DefaultOption : public Option<_Tp,_Initial>
+ {
+ typedef _Tp value_type;
+ typedef Option<_Tp,_Initial> option_type;
+
+ void restoreDefault()
+ { this->set( _default.get() ); }
+
+ void restoreDefault( const value_type & newval_r )
+ { setDefault( newval_r ); restoreDefault(); }
+
+ value_type getDefault() const
+ { return _default.get(); }
+
+ void setDefault( const value_type & newval_r )
+ { _default.set( newval_r ); }
+
+ private:
+ option_type _default;
+ };
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : ZConfig::Impl
@@ -248,6 +291,10 @@ namespace zypp
{
download_use_deltarpm_always = str::strToBool( value, download_use_deltarpm_always );
}
+ else if ( entry == "download.media_preference" )
+ {
+ download_media_prefer_download.restoreDefault( str::compareCI( value, "volatile" ) != 0 );
+ }
else if ( entry == "download.max_concurrent_connections" )
{
str::strtonum(value, download_max_concurrent_connections);
@@ -380,6 +427,7 @@ namespace zypp
bool download_use_deltarpm;
bool download_use_deltarpm_always;
+ DefaultOption download_media_prefer_download;
int download_max_concurrent_connections;
int download_min_download_speed;
@@ -569,12 +617,21 @@ namespace zypp
bool ZConfig::download_use_deltarpm_always() const
{ return download_use_deltarpm() && _pimpl->download_use_deltarpm_always; }
+ bool ZConfig::download_media_prefer_download() const
+ { return _pimpl->download_media_prefer_download.get(); }
+
+ void ZConfig::set_download_media_prefer_download( bool yesno_r )
+ { _pimpl->download_media_prefer_download.set( yesno_r ); }
+
+ void ZConfig::set_default_download_media_prefer_download()
+ { _pimpl->download_media_prefer_download.restoreDefault(); }
+
long ZConfig::download_max_concurrent_connections() const
{ return _pimpl->download_max_concurrent_connections; }
-
+
long ZConfig::download_min_download_speed() const
{ return _pimpl->download_min_download_speed; }
-
+
long ZConfig::download_max_download_speed() const
{ return _pimpl->download_max_download_speed; }
diff --git a/zypp/ZConfig.h b/zypp/ZConfig.h
index 9b73393..42f602e 100644
--- a/zypp/ZConfig.h
+++ b/zypp/ZConfig.h
@@ -188,6 +188,23 @@ namespace zypp
bool download_use_deltarpm_always() const;
/**
+ * Hint which media to prefer when installing packages (download vs. CD).
+ * \see class \ref media::MediaPriority
+ */
+ bool download_media_prefer_download() const;
+ /** \overload */
+ bool download_media_prefer_volatile() const
+ { return ! download_media_prefer_download(); }
+ /**
+ * Set \ref download_media_prefer_download to a specific value.
+ */
+ void set_download_media_prefer_download( bool yesno_r );
+ /**
+ * Set \ref download_media_prefer_download to the configfiles default.
+ */
+ void set_default_download_media_prefer_download();
+
+ /**
* Directory for equivalent vendor definitions (configPath()/vendors.d)
* \ingroup g_ZC_CONFIGFILES
*/
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org