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);
99 addResolvables (_target->resolvables(), true);
102 void ZYppImpl::finishTarget()
104 #warning not removing target resolvables for now
106 // removeResolvables (_target->resolvables());
110 /** \todo Remove workflow from target, lot's of it could be done here,
111 * and target used for transact. */
112 ZYpp::CommitResult ZYppImpl::commit( int medianr_r )
114 MIL << "Attempt to commit (medianr " << medianr_r << ")" << endl;
116 ZYPP_THROW( Exception("Target not initialized.") );
118 ZYpp::CommitResult res;
119 // must redirect to Target::Impl. This kind of commit should not be
120 // in the Target interface.
121 res._result = _target->commit( pool(), medianr_r,
122 res._errors, res._remaining, res._srcremaining );
124 MIL << "Commit (medianr " << medianr_r << ") returned: "
126 << " (errors " << res._errors.size()
127 << ", remaining " << res._remaining.size()
128 << ", srcremaining " << res._srcremaining.size()
133 /******************************************************************
135 ** FUNCTION NAME : operator<<
136 ** FUNCTION TYPE : std::ostream &
138 std::ostream & operator<<( std::ostream & str, const ZYppImpl & obj )
140 return str << "ZYppImpl";
143 /////////////////////////////////////////////////////////////////
144 } // namespace zypp_detail
145 ///////////////////////////////////////////////////////////////////
146 /////////////////////////////////////////////////////////////////
148 ///////////////////////////////////////////////////////////////////