Author: mlandres
Date: Tue Oct 30 17:35:26 2007
New Revision: 7709
URL: http://svn.opensuse.org/viewcvs/zypp?rev=7709&view=rev
Log:
backport 10.3 ZConfig (zypp.conf) support,
stripped down to support configuration of patch/delta rpm usage
Added:
branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/ZConfig.cc
branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/ZConfig.h
Modified:
branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/Makefile.am
branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/source/PackageProvider.cc
Modified: branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/Makefile.am
URL: http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/Makefile.am?rev=7709&r1=7708&r2=7709&view=diff
==============================================================================
--- branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/Makefile.am (original)
+++ branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/Makefile.am Tue Oct 30 17:35:26 2007
@@ -85,6 +85,7 @@
VendorAttr.h \
UpgradeStatistics.h \
TranslatedText.h \
+ ZConfig.h \
ZYpp.h \
ZYppCommit.h \
ZYppCommitPolicy.h \
@@ -165,6 +166,7 @@
DiskUsageCounter.cc \
VendorAttr.cc \
UpgradeStatistics.cc \
+ ZConfig.cc \
ZYpp.cc \
ZYppCommitPolicy.cc \
ZYppCommitResult.cc \
Added: branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/ZConfig.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/ZConfig.cc?rev=7709&view=auto
==============================================================================
--- branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/ZConfig.cc (added)
+++ branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/ZConfig.cc Tue Oct 30 17:35:26 2007
@@ -0,0 +1,136 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/ZConfig.cc
+ *
+*/
+#include <iostream>
+#include "zypp/base/Logger.h"
+#include "zypp/base/InputStream.h"
+#include "zypp/base/String.h"
+
+#include "zypp/ZConfig.h"
+#include "zypp/ZYppFactory.h"
+#include "zypp/PathInfo.h"
+#include "zypp/parser/IniDict.h"
+
+using namespace std;
+using namespace zypp::filesystem;
+using namespace zypp::parser;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : ZConfig::Impl
+ //
+ /** ZConfig implementation.
+ * \todo Enrich section and entry definition by some comment
+ * (including the default setting and provide some method to
+ * write this into a sample zypp.conf.
+ */
+ class ZConfig::Impl
+ {
+ public:
+ Impl()
+ : download_use_patchrpm( true )
+ , download_use_deltarpm( true )
+ {
+ MIL << "ZConfig singleton created." << endl;
+
+ // ZYPP_CONF might override /etc/zypp/zypp.conf
+ const char *env_confpath = getenv( "ZYPP_CONF" );
+ PathInfo confpath( env_confpath ? env_confpath : "/etc/zypp/zypp.conf" );
+
+ if ( ! ( confpath.isFile() && confpath.isR() ) )
+ {
+ MIL << "Unable to read " << confpath << ": using defaults instead." << endl;
+ return;
+ }
+
+ MIL << "Reading " << confpath << endl;
+ parser::IniDict dict;
+ dict.read( confpath.path() );
+
+ for ( IniDict::section_const_iterator sit = dict.sectionsBegin();
+ sit != dict.sectionsEnd();
+ ++sit )
+ {
+ string section(*sit);
+ //MIL << section << endl;
+ for ( IniDict::entry_const_iterator it = dict.entriesBegin(*sit);
+ it != dict.entriesEnd(*sit);
+ ++it )
+ {
+ string entry(it->first);
+ string value(it->second);
+ //DBG << (*it).first << "=" << (*it).second << endl;
+ if ( section == "main" )
+ {
+ if( entry == "download.use_patchrpm" )
+ {
+ download_use_patchrpm = str::strToBool( value, download_use_patchrpm );
+ }
+ else if ( entry == "download.use_deltarpm" )
+ {
+ download_use_deltarpm = str::strToBool( value, download_use_deltarpm );
+ }
+ }
+ }
+ }
+ }
+
+ ~Impl()
+ {}
+
+ public:
+ bool download_use_patchrpm;
+ bool download_use_deltarpm;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : ZConfig::instance
+ // METHOD TYPE : ZConfig &
+ //
+ ZConfig & ZConfig::instance()
+ {
+ static ZConfig _instance; // The singleton
+ return _instance;
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : ZConfig::ZConfig
+ // METHOD TYPE : Ctor
+ //
+ ZConfig::ZConfig()
+ : _pimpl( new Impl )
+ {}
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : ZConfig::~ZConfig
+ // METHOD TYPE : Dtor
+ //
+ ZConfig::~ZConfig( )
+ {}
+
+ bool ZConfig::download_use_patchrpm() const
+ { return _pimpl->download_use_patchrpm; }
+
+ bool ZConfig::download_use_deltarpm() const
+ { return _pimpl->download_use_deltarpm; }
+
+
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
Added: branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/ZConfig.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/ZConfig.h?rev=7709&view=auto
==============================================================================
--- branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/ZConfig.h (added)
+++ branches/SuSE-SLE-10-SP2-Branch/libzypp/zypp/ZConfig.h Tue Oct 30 17:35:26 2007
@@ -0,0 +1,70 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/ZConfig.h
+ *
+*/
+#ifndef ZYPP_ZCONFIG_H
+#define ZYPP_ZCONFIG_H
+
+#include <iosfwd>
+
+#include "zypp/base/NonCopyable.h"
+#include "zypp/base/PtrTypes.h"
+
+#include "zypp/Arch.h"
+#include "zypp/Locale.h"
+#include "zypp/Pathname.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : ZConfig
+ //
+ /** Interim helper class to collect global options and settings.
+ * It reads /etc/zypp/zypp.conf, the filename can be overridden by
+ * setting the ZYPP_CONF environment variable to a different file.
+ *
+ * \ingroup Singleton
+ */
+ class ZConfig : private base::NonCopyable
+ {
+ public:
+ /** Singleton ctor */
+ static ZConfig & instance();
+
+ public:
+ /** Whether to consider using a patchrpm when downloading a package.
+ * Config option <tt>download.use_patchrpm (true)</tt>
+ */
+ bool download_use_patchrpm() const;
+
+ /** Whether to consider using a deltarpm when downloading a package.
+ * Config option <tt>download.use_deltarpm (true)</tt>
+ */
+ bool download_use_deltarpm() const;
+
+ public:
+ class Impl;
+ /** Dtor */
+ ~ZConfig();
+ private:
+ /** Default ctor. */
+ ZConfig();
+ /** Pointer to implementation */
+ RW_pointer