ref: refs/heads/master
commit d7e827d83b39b163b860e20a9a7ce9068b05d3f0
Author: Michael Andres
Date: Wed Feb 11 13:04:26 2009 +0100
Add ZyppAC::repoManager() and make ZyppAC zero-sized again.
---
src/SUSE_zypp.cc | 55 ++++++++++++++++++++++++++---------------------------
src/SUSE_zypp.h | 10 ++------
2 files changed, 30 insertions(+), 35 deletions(-)
diff --git a/src/SUSE_zypp.cc b/src/SUSE_zypp.cc
index a3d71cc..6c0020d 100644
--- a/src/SUSE_zypp.cc
+++ b/src/SUSE_zypp.cc
@@ -1,11 +1,15 @@
#include <iostream>
+#include
#include "zypp/base/LogControl.h"
#include "zypp/base/LogTools.h"
#include "SUSE_zypp.h"
+#undef ZYPP_BASE_LOGGER_LOGGROUP
+#define ZYPP_BASE_LOGGER_LOGGROUP "zyppAC"
+
using namespace zypp;
using std::endl;
@@ -13,37 +17,13 @@ namespace cmpizypp
{
namespace
{
-
- int _initonce()
+ void zyppACInit()
{
- // use `export ZYPP_LOGFILE=/tmp/CMPIZYPP.log` to redirect the zypp log.
- // zypp::base::LogControl::instance().logToStdErr();
- return 0;
- }
- int initonce = _initonce();
-
-
- bool zyppACInitialized = false;
-
-
- } // namespace
-
-
- ZyppAC::ZyppAC()
- {
- zyppACInit();
- }
-
- ZyppAC::~ZyppAC()
- {
- }
-
- void ZyppAC::zyppACInit()
- {
+ static bool zyppACInitialized = false;
if ( zyppACInitialized )
return;
- sysRoot = Pathname( getenv("CMPIZYPP_ROOT") ? getenv("CMPIZYPP_ROOT") : "/" );
+ Pathname sysRoot( ZyppAC::getSysRoot() );
KeyRing::setDefaultAccept( KeyRing::ACCEPT_UNKNOWNKEY|KeyRing::TRUST_KEY_TEMPORARILY );
@@ -99,10 +79,29 @@ namespace cmpizypp
ResPool pool( ResPool::instance() );
sat::Pool satpool( sat::Pool::instance() );
- dumpRange( USR, satpool.reposBegin(), satpool.reposEnd() );
+
+ dumpRange( USR << "Repos: ", satpool.reposBegin(), satpool.reposEnd() ) << endl;
USR << "pool: " << pool << endl;
zyppACInitialized = true;
+ }
+ } // namespace
+
+ zypp::Pathname ZyppAC::getSysRoot()
+ {
+ static zypp::Pathname _sysRoot( getenv("CMPIZYPP_ROOT") ? getenv("CMPIZYPP_ROOT") : "/" );
+ return _sysRoot;
+ }
+
+ ZyppAC::ZyppAC()
+ {
+ //INT << "+++Lock " << this << endl;
+ zyppACInit();
+ }
+
+ ZyppAC::~ZyppAC()
+ {
+ //MIL << "---Lock " << this << endl;
}
std::string ZyppAC::exceptionString( const Exception & err_r, const std::string & prefix_r )
diff --git a/src/SUSE_zypp.h b/src/SUSE_zypp.h
index 442737e..a065ee9 100644
--- a/src/SUSE_zypp.h
+++ b/src/SUSE_zypp.h
@@ -17,21 +17,17 @@ namespace cmpizypp
/** Access to libzypp components. */
class ZyppAC
{
- private:
- zypp::Pathname sysRoot;
-
- void zyppACInit();
-
public:
ZyppAC();
~ZyppAC();
- zypp::Pathname getSysRoot() const { return sysRoot; }
+ static zypp::Pathname getSysRoot();
+
zypp::Target & target() const { return *zypp::getZYpp()->getTarget(); }
+ zypp::RepoManager repoManager() const { return zypp::RepoManager( getSysRoot() ); }
zypp::ResPool pool() const { return zypp::ResPool::instance(); }
zypp::ResPoolProxy poolProxy() const { return pool().proxy(); }
zypp::sat::Pool satpool() const { return zypp::sat::Pool::instance(); }
- zypp::RepoManager repoManager() const { return zypp::RepoManager( sysRoot ); }
static std::string exceptionString( const zypp::Exception & err_r, const std::string & prefix = std::string() );
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org