1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/zypp_detail/ZYppImpl.cc
13 //#include "zypp/base/Logger.h"
15 #include "zypp/zypp_detail/ZYppImpl.h"
19 ///////////////////////////////////////////////////////////////////
21 { /////////////////////////////////////////////////////////////////
22 ///////////////////////////////////////////////////////////////////
24 { /////////////////////////////////////////////////////////////////
26 inline Locale defaultTextLocale()
29 char * envlist[] = { "LC_ALL", "LC_CTYPE", "LANG", NULL };
30 for ( char ** envvar = envlist; *envvar; ++envvar )
32 char * envlang = getenv( *envvar );
35 std::string envstr( envlang );
36 if ( envstr != "POSIX" && envstr != "C" )
38 Locale lang( envlang );
39 if ( lang != Locale::noCode )
50 ///////////////////////////////////////////////////////////////////
52 // METHOD NAME : ZYppImpl::ZYppImpl
53 // METHOD TYPE : Constructor
56 : _textLocale( defaultTextLocale() )
58 , _sourceFeed( _pool )
59 , _resolver( new Resolver(_pool.accessor()) )
61 MIL << "defaultTextLocale: '" << _textLocale << "'" << endl;
64 ///////////////////////////////////////////////////////////////////
66 // METHOD NAME : ZYppImpl::~ZYppImpl
67 // METHOD TYPE : Destructor
73 void ZYppImpl::addResolvables (const ResStore& store, bool installed)
75 _pool.insert(store.begin(), store.end(), installed);
78 void ZYppImpl::removeResolvables (const ResStore& store)
80 for (ResStore::iterator it = store.begin(); it != store.end(); it++)
86 Target_Ptr ZYppImpl::target() const
89 ZYPP_THROW(Exception("Target not initialized."));
93 void ZYppImpl::initTarget(const Pathname & root, bool commit_only)
96 _target = Target_Ptr();
97 _target = new Target(root);
100 _target->enableStorage(root);
101 addResolvables (_target->resolvables(), true);
105 void ZYppImpl::finishTarget()
107 #warning not removing target resolvables for now
109 // removeResolvables (_target->resolvables());
113 /** \todo Remove workflow from target, lot's of it could be done here,
114 * and target used for transact. */
115 ZYpp::CommitResult ZYppImpl::commit( int medianr_r )
117 MIL << "Attempt to commit (medianr " << medianr_r << ")" << endl;
119 ZYPP_THROW( Exception("Target not initialized.") );
121 ZYpp::CommitResult res;
122 // must redirect to Target::Impl. This kind of commit should not be
123 // in the Target interface.
124 res._result = _target->commit( pool(), medianr_r,
125 res._errors, res._remaining, res._srcremaining );
127 MIL << "Commit (medianr " << medianr_r << ") returned: "
129 << " (errors " << res._errors.size()
130 << ", remaining " << res._remaining.size()
131 << ", srcremaining " << res._srcremaining.size()
136 /******************************************************************
138 ** FUNCTION NAME : operator<<
139 ** FUNCTION TYPE : std::ostream &
141 std::ostream & operator<<( std::ostream & str, const ZYppImpl & obj )
143 return str << "ZYppImpl";
146 /////////////////////////////////////////////////////////////////
147 } // namespace zypp_detail
148 ///////////////////////////////////////////////////////////////////
149 /////////////////////////////////////////////////////////////////
151 ///////////////////////////////////////////////////////////////////