From: Michael Andres Date: Fri, 31 Mar 2006 14:05:00 +0000 (+0000) Subject: - ZYppReadOnly access (workaround). X-Git-Tag: BASE-SuSE-SLE-10-SP2-Branch~1258 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=700953498488410fe8b2605ddb08274b3942aa0d;p=platform%2Fupstream%2Flibzypp.git - ZYppReadOnly access (workaround). --- diff --git a/zypp/ZYpp.cc b/zypp/ZYpp.cc index adf4ca9..67484fa 100644 --- a/zypp/ZYpp.cc +++ b/zypp/ZYpp.cc @@ -68,13 +68,10 @@ namespace zypp Resolver_Ptr ZYpp::resolver() const { return _pimpl->resolver(); } - + KeyRing* ZYpp::keyRing() const { return _pimpl->keyRing(); } - void ZYpp::reset() - { _pimpl->reset(); } - /////////////////////////////////////////////////////////////////// // // Forward to Impl: diff --git a/zypp/ZYpp.h b/zypp/ZYpp.h index 5af32c3..8bb3af5 100644 --- a/zypp/ZYpp.h +++ b/zypp/ZYpp.h @@ -37,7 +37,7 @@ namespace zypp class ResStore; class Locale; class KeyRing; - + /////////////////////////////////////////////////////////////////// // // CLASS NAME : ZYpp @@ -74,15 +74,8 @@ namespace zypp void setPartitions(const DiskUsageCounter::MountPointSet &mp); - public: - /** - * Tries to reset the ZYpp instance. It discards the current - * status without too much house keeping. Might be dangerous to use. - * - * \throws Exception - */ - void reset(); - + /** NOOP */ + ZYPP_DEPRECATED void reset() {} public: /** * \throws Exception diff --git a/zypp/ZYppFactory.cc b/zypp/ZYppFactory.cc index 72d7fe8..fdde363 100644 --- a/zypp/ZYppFactory.cc +++ b/zypp/ZYppFactory.cc @@ -23,6 +23,7 @@ #include "zypp/ZYppFactory.h" #include "zypp/zypp_detail/ZYppImpl.h" +#include "zypp/zypp_detail/ZYppReadOnlyHack.h" #define ZYPP_LOCK_FILE "/var/run/zypp.pid" @@ -34,6 +35,22 @@ namespace zypp { ///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// + namespace zypp_readonly_hack + { ///////////////////////////////////////////////////////////////// + + static bool active = false; + + void IWantIt() + { + active = true; + MIL << "ZYPP_READONLY promised." << endl; + } + + ///////////////////////////////////////////////////////////////// + } // namespace zypp_readonly_hack + /////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////// // // CLASS NAME : ZYppGlobalLock // @@ -43,10 +60,10 @@ namespace zypp { public: - ZYppGlobalLock() : _zypp_lockfile(0), _clean_lock(false) - { - - } + ZYppGlobalLock() + : _clean_lock(false) + , _zypp_lockfile(0) + {} ~ZYppGlobalLock() { @@ -73,7 +90,7 @@ namespace zypp } bool _clean_lock; - + private: FILE *_zypp_lockfile; @@ -291,6 +308,14 @@ namespace zypp if ( ! _instance ) { + /*--------------------------------------------------*/ + if ( zypp_readonly_hack::active ) + { + _instance = new ZYpp( ZYpp::Impl_Ptr(new ZYpp::Impl) ); + MIL << "ZYPP_READONLY active." << endl; + return _instance; + } + /*--------------------------------------------------*/ if ( globalLock.zyppLocked() ) { ZYPP_THROW( ZYppFactoryException(N_("Cannot aquire zypp lock.")) ); diff --git a/zypp/zypp_detail/Makefile.am b/zypp/zypp_detail/Makefile.am index b916ff1..f6338ff 100644 --- a/zypp/zypp_detail/Makefile.am +++ b/zypp/zypp_detail/Makefile.am @@ -10,7 +10,8 @@ INCLUDES = -DZYPP_BASE_LOGGER_LOGGROUP=\"zypp_detail\" baseincludedir = $(pkgincludedir)/zypp_detail baseinclude_HEADERS = \ - ZYppImpl.h + ZYppImpl.h \ + ZYppReadOnlyHack.h noinst_LTLIBRARIES = lib@PACKAGE@_zypp_detail.la diff --git a/zypp/zypp_detail/ZYppImpl.cc b/zypp/zypp_detail/ZYppImpl.cc index 734c6cb..5fcc032 100644 --- a/zypp/zypp_detail/ZYppImpl.cc +++ b/zypp/zypp_detail/ZYppImpl.cc @@ -70,10 +70,10 @@ namespace zypp , _disk_usage() { MIL << "defaultTextLocale: '" << _textLocale << "'" << endl; - + MIL << "initializing keyring..." << std::endl; _keyring = new KeyRing(homePath() + Pathname("/keyring/all"), homePath() + Pathname("/keyring/trusted")); - + struct utsname buf; if (uname (&buf) < 0) { ERR << "Can't determine system architecture" << endl; @@ -133,18 +133,6 @@ namespace zypp delete _keyring; } - void ZYppImpl::reset() - { - MIL << "Resetting ZYpp instance" << endl; - // TODO: check the memory is released - _textLocale = defaultTextLocale(); - _pool = ResPoolManager(); - _sourceFeed = SourceFeed_Ref(_pool); - _resolver = new Resolver(_pool.accessor()); - _disk_usage = DiskUsageCounter(); - _target = 0; - } - //------------------------------------------------------------------------ // add/remove resolvables diff --git a/zypp/zypp_detail/ZYppImpl.h b/zypp/zypp_detail/ZYppImpl.h index 69fe88f..c10743a 100644 --- a/zypp/zypp_detail/ZYppImpl.h +++ b/zypp/zypp_detail/ZYppImpl.h @@ -63,7 +63,7 @@ namespace zypp KeyRing* keyRing() const { return _keyring; } - + Resolver_Ptr resolver() const { return _resolver; } @@ -92,11 +92,6 @@ namespace zypp /** Commit changes and transactions. */ ZYpp::CommitResult commit( int medianr_r, bool dry_run = false ); - /** Reset the instance, discard changes - * \throws Exception - */ - void reset(); - public: /** \todo Signal locale change. */ void setTextLocale( const Locale & textLocale_r ) @@ -146,7 +141,7 @@ namespace zypp Target_Ptr _target; /** */ Resolver_Ptr _resolver; - + KeyRing *_keyring; /** */ Arch _architecture; diff --git a/zypp/zypp_detail/ZYppReadOnlyHack.h b/zypp/zypp_detail/ZYppReadOnlyHack.h new file mode 100644 index 0000000..24b1dd7 --- /dev/null +++ b/zypp/zypp_detail/ZYppReadOnlyHack.h @@ -0,0 +1,35 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/zypp_detail/ZYppReadOnlyHack.h + * +*/ + +#ifndef ZYPP_ZYPP_DETAIL_ZYPPREADONLYHACK_H +#define ZYPP_ZYPP_DETAIL_ZYPPREADONLYHACK_H +#warning ZYPP_ZYPP_DETAIL_ZYPPREADONLYHACK_H + +#include "zypp/base/Deprecated.h" + +/////////////////////////////////////////////////////////////////// +namespace zypp +{ ///////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////// + namespace zypp_readonly_hack + { ///////////////////////////////////////////////////////////////// + + void IWantIt() ZYPP_DEPRECATED; + + ///////////////////////////////////////////////////////////////// + } // namespace zypp_readonly_hack + /////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////// +} // namespace zypp +/////////////////////////////////////////////////////////////////// + +#endif // ZYPP_ZYPP_DETAIL_ZYPPREADONLYHACK_H