X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=zypp%2Ftarget%2FTargetImpl.h;h=66589007be9995a3ec2a73ee28207a6695c2cdc3;hb=362a3fe325c0e1d66cb6b560cf99dd2147a8aa8d;hp=edb035105b6547465e14355e220a00e2b2d3f404;hpb=400087bdb94968b67a5d74455531e9d374d03bad;p=platform%2Fupstream%2Flibzypp.git diff --git a/zypp/target/TargetImpl.h b/zypp/target/TargetImpl.h index edb0351..6658900 100644 --- a/zypp/target/TargetImpl.h +++ b/zypp/target/TargetImpl.h @@ -13,18 +13,23 @@ #define ZYPP_TARGET_TARGETIMPL_H #include +#include #include "zypp/base/ReferenceCounted.h" #include "zypp/base/NonCopyable.h" #include "zypp/base/PtrTypes.h" -#include "zypp/ResStore.h" +#include "zypp/PoolItem.h" +#include "zypp/ZYppCommit.h" #include "zypp/Pathname.h" #include "zypp/media/MediaAccess.h" #include "zypp/Target.h" #include "zypp/target/rpm/RpmDb.h" -#include "zypp/target/store/PersistentStorage.h" -#include "zypp/solver/detail/Types.h" +#include "zypp/target/TargetException.h" +#include "zypp/target/RequestedLocalesFile.h" +#include "zypp/target/SolvIdentFile.h" +#include "zypp/target/HardLocksFile.h" +#include "zypp/ManagedFile.h" /////////////////////////////////////////////////////////////////// namespace zypp @@ -34,6 +39,7 @@ namespace zypp { ///////////////////////////////////////////////////////////////// DEFINE_PTR_TYPE(TargetImpl); + class CommitPackageCache; /////////////////////////////////////////////////////////////////// // @@ -48,78 +54,181 @@ namespace zypp { friend std::ostream & operator<<( std::ostream & str, const TargetImpl & obj ); - private: - /** Sort according to prereqs and media numbers */ - void getResolvablesToInsDel ( const ResPool pool_r, - PoolItemList & dellist_r, - PoolItemList & instlist_r, - PoolItemList & srclist_r ); + public: + /** list of pool items */ + typedef std::list PoolItemList; + /** set of pool items */ + typedef std::set PoolItemSet; public: /** Ctor. */ - TargetImpl(const Pathname & root_r = "/"); + TargetImpl(const Pathname & root_r = "/", bool doRebuild_r = false ); /** Dtor. */ virtual ~TargetImpl(); - /** Null implementation */ - static TargetImpl_Ptr nullimpl(); + /** + * generates the unique anonymous id which is called + * when creating the target + */ + void createAnonymousId() const; + + /** + * generates a cache of the last product flavor + */ + void createLastDistributionFlavorCache() const; + + /** \name Solv file handling. + * If target solv file is outdated, but (non-root-)user has + * no permission to create it at the default location, we + * use a temporary one. + */ + //@{ + private: + /** The systems default solv file location. */ + Pathname defaultSolvfilesPath() const; + + /** The solv file location actually in use (default or temp). */ + Pathname solvfilesPath() const + { return solvfilesPathIsTemp() ? _tmpSolvfilesPath : defaultSolvfilesPath(); } + + /** Whether we're using a temp. solvfile. */ + bool solvfilesPathIsTemp() const + { return ! _tmpSolvfilesPath.empty(); } + + Pathname _tmpSolvfilesPath; + + public: + void load( bool force = true ); + + void unload(); + + void reload(); + + void clearCache(); + + bool buildCache(); + //@} public: - /** All resolvables in the target. */ - const ResStore & resolvables(); + /** The root set for this target */ + Pathname root() const + { return _root; } + + /** The directory to store things. */ + Pathname home() const + { return home( _root ); } + + static Pathname home( const Pathname & root_r ) + { return root_r / "/var/lib/zypp"; } - /** Commit changes in the pool - media = 0 means any/all medias - media > 0 means limit commits to this media */ - void commit( ResPool pool_r, unsigned int medianr, PoolItemList & errors_r, PoolItemList & remaining_r, PoolItemList & srcremaining_r ); + /** Commit changes in the pool */ + ZYppCommitResult commit( ResPool pool_r, const ZYppCommitPolicy & policy_r ); - /** enables the storage target */ - bool isStorageEnabled() const; - void enableStorage(const Pathname &root_r); + /** Install a source package on the Target. */ + void installSrcPackage( const SrcPackage_constPtr & srcPackage_r ); - /** Commit ordered changes - return uncommitted ones (due to error) */ - PoolItemList commit( const PoolItemList & items_r ); + /** Provides a source package on the Target. */ + ManagedFile provideSrcPackage( const SrcPackage_constPtr & srcPackage_r ); /** Overload to realize stream output. */ virtual std::ostream & dumpOn( std::ostream & str ) const - { return str << "TargetImpl"; } + { + return str << "TargetImpl"; + } /** The RPM database */ rpm::RpmDb & rpm(); /** If the package is installed and provides the file - Needed to evaluate split provides during Resolver::Upgrade() */ + Needed to evaluate split provides during Resolver::Upgrade() */ bool providesFile (const std::string & path_str, const std::string & name_str) const; - /** Return the resolvable which provides path_str (rpm -qf) - return NULL if no resolvable provides this file */ - ResObject::constPtr whoOwnsFile (const std::string & path_str) const; + /** Return name of package owning \a path_str + * or empty string if no installed package owns \a path_str. */ + std::string whoOwnsFile (const std::string & path_str) const + { return _rpm.whoOwnsFile (path_str); } + + /** return the last modification date of the target */ + Date timestamp() const; + + /** \copydoc Target::baseProduct() */ + Product::constPtr baseProduct() const; + + /** \copydoc Target::requestedLocales() */ + LocaleSet requestedLocales() const + { return _requestedLocalesFile.locales(); } + /** \overload */ + static LocaleSet requestedLocales( const Pathname & root_r ); + + /** \copydoc Target::updateAutoInstalled */ + void updateAutoInstalled(); + + /** \copydoc Target::targetDistribution() */ + std::string targetDistribution() const; + /** \overload */ + static std::string targetDistribution( const Pathname & root_r ); + + /** \copydoc Target::targetDistributionRelease()*/ + std::string targetDistributionRelease() const; + /** \overload */ + static std::string targetDistributionRelease( const Pathname & root_r ); + + /** \copydoc Target::targetDistributionFlavor()*/ + std::string targetDistributionFlavor() const; + /** \overload */ + static std::string targetDistributionFlavor( const Pathname & root_r ); + + /** \copydoc Target::distributionLabel()*/ + Target::DistributionLabel distributionLabel() const; + /** \overload */ + static Target::DistributionLabel distributionLabel( const Pathname & root_r ); + + /** \copydoc Target::distributionVersion()*/ + std::string distributionVersion() const; + /** \overload */ + static std::string distributionVersion( const Pathname & root_r ); + + /** \copydoc Target::distributionFlavor() */ + std::string distributionFlavor() const; + /** \overload */ + static std::string distributionFlavor( const Pathname & root_r ); + + /** \copydoc Target::anonymousUniqueId() */ + std::string anonymousUniqueId() const; + /** \overload */ + static std::string anonymousUniqueId( const Pathname & root_r ); + private: + /** Commit ordered changes (internal helper) */ + void commit( const ZYppCommitPolicy & policy_r, + CommitPackageCache & packageCache_r, + ZYppCommitResult & result_r ); + + /** Commit helper checking for file conflicts after download. */ + void commitFindFileConflicts( const ZYppCommitPolicy & policy_r, ZYppCommitResult & result_r ); protected: - /** All resolvables provided by the target. */ - ResStore _store; /** Path to the target */ Pathname _root; /** RPM database */ rpm::RpmDb _rpm; -#ifndef STORAGE_DISABLED - zypp::storage::PersistentStorage _storage; -#endif - private: - /** Null implementation */ - static TargetImpl_Ptr _nullimpl; - - /** wrapper with callback around getPlainRpm */ - Pathname getRpmFile(Package::constPtr package); + /** Requested Locales database */ + RequestedLocalesFile _requestedLocalesFile; + /** user/auto installed database */ + SolvIdentFile _autoInstalledFile; + /** Hard-Locks database */ + HardLocksFile _hardLocksFile; + /** Cache distributionVersion */ + mutable std::string _distributionVersion; }; /////////////////////////////////////////////////////////////////// /** \relates TargetImpl Stream output */ inline std::ostream & operator<<( std::ostream & str, const TargetImpl & obj ) - { return obj.dumpOn( str ); } + { + return obj.dumpOn( str ); + } ///////////////////////////////////////////////////////////////// } // namespace target