1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/target/TargetImpl.h
12 #ifndef ZYPP_TARGET_TARGETIMPL_H
13 #define ZYPP_TARGET_TARGETIMPL_H
19 #include "zypp/base/ReferenceCounted.h"
20 #include "zypp/base/NonCopyable.h"
21 #include "zypp/base/DefaultFalseBool.h"
22 #include "zypp/base/PtrTypes.h"
23 #include "zypp/PoolItem.h"
24 #include "zypp/ZYppCommit.h"
26 #include "zypp/Pathname.h"
27 #include "zypp/media/MediaAccess.h"
28 #include "zypp/Target.h"
29 #include "zypp/target/rpm/RpmDb.h"
30 #include "zypp/target/TargetException.h"
31 #include "zypp/target/RequestedLocalesFile.h"
32 #include "zypp/target/SoftLocksFile.h"
33 #include "zypp/target/HardLocksFile.h"
35 ///////////////////////////////////////////////////////////////////
37 { /////////////////////////////////////////////////////////////////
38 ///////////////////////////////////////////////////////////////////
40 { /////////////////////////////////////////////////////////////////
42 DEFINE_PTR_TYPE(TargetImpl);
44 ///////////////////////////////////////////////////////////////////
46 // CLASS NAME : TargetImpl
48 /** Base class for concrete Target implementations.
50 * Constructed by \ref TargetFactory. Public access via \ref Target
53 class TargetImpl : public base::ReferenceCounted, private base::NonCopyable
55 friend std::ostream & operator<<( std::ostream & str, const TargetImpl & obj );
58 /** list of pool items */
59 typedef std::list<PoolItem> PoolItemList;
61 /** set of pool items */
62 typedef std::set<PoolItem> PoolItemSet;
66 TargetImpl(const Pathname & root_r = "/", bool doRebuild_r = false );
68 virtual ~TargetImpl();
70 /** Null implementation */
71 static TargetImpl_Ptr nullimpl();
83 /** The root set for this target */
87 /** The directory to store things. */
89 { return _root / "/var/lib/zypp"; }
91 /** Commit changes in the pool */
92 ZYppCommitResult commit( ResPool pool_r, const ZYppCommitPolicy & policy_r );
94 ZYPP_DEPRECATED int commit( ResPool pool_r, unsigned int medianr,
95 PoolItemList & errors_r,
96 PoolItemList & remaining_r,
97 PoolItemList & srcremaining_r,
98 bool dry_run = false )
100 ZYppCommitPolicy policy;
101 policy.restrictToMedia( medianr ).dryRun( dry_run );
102 ZYppCommitResult res = commit( pool_r, policy );
103 errors_r.swap( res._errors );
104 remaining_r.swap( res._remaining );
105 srcremaining_r.swap( res._srcremaining );
109 /** Commit ordered changes
110 * @param pool_r only needed for #160792
111 * @return uncommitted ones (due to error)
113 PoolItemList commit( const PoolItemList & items_r, const ZYppCommitPolicy & policy_r, const ResPool & pool_r );
115 /** Install a source package on the Target. */
116 void installSrcPackage( const SrcPackage_constPtr & srcPackage_r );
118 /** Overload to realize stream output. */
119 virtual std::ostream & dumpOn( std::ostream & str ) const
121 return str << "TargetImpl";
124 /** The RPM database */
127 /** If the package is installed and provides the file
128 Needed to evaluate split provides during Resolver::Upgrade() */
129 bool providesFile (const std::string & path_str, const std::string & name_str) const;
131 /** Return name of package owning \a path_str
132 * or empty string if no installed package owns \a path_str. */
133 std::string whoOwnsFile (const std::string & path_str) const
134 { return _rpm.whoOwnsFile (path_str); }
136 /** Set the log file for target */
137 bool setInstallationLogfile(const Pathname & path_r);
139 /** return the last modification date of the target */
140 Date timestamp() const;
142 /** The targets distribution release string.
144 * openSUSE 10.3 (i586)
147 std::string release() const;
150 /** Path to the target */
154 /** Requested Locales database */
155 RequestedLocalesFile _requestedLocalesFile;
156 /** Soft-locks database */
157 SoftLocksFile _softLocksFile;
158 /** Hard-Locks database */
159 HardLocksFile _hardLocksFile;
161 /** Null implementation */
162 static TargetImpl_Ptr _nullimpl;
164 ///////////////////////////////////////////////////////////////////
166 /** \relates TargetImpl Stream output */
167 inline std::ostream & operator<<( std::ostream & str, const TargetImpl & obj )
169 return obj.dumpOn( str );
172 /////////////////////////////////////////////////////////////////
173 } // namespace target
174 ///////////////////////////////////////////////////////////////////
175 /////////////////////////////////////////////////////////////////
177 ///////////////////////////////////////////////////////////////////
178 #endif // ZYPP_TARGET_TARGETIMPL_H