From 98d07237edf367e5ba36f00fffd049d73c62d89d Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Tue, 31 Jul 2007 19:58:43 +0000 Subject: [PATCH] - Added package attributes Package::sourcePkgName and Package::sourcePkgEdition. Name and edition of the source rpm this package was built from. - Added ZYpp::installSrcPackage to install a single source package. --- VERSION.cmake | 2 +- devel/devel.ma/Parse.cc | 28 ++++++---------------------- zypp/Package.cc | 8 +++++++- zypp/Package.h | 18 ++++++++++++++---- zypp/ZYpp.cc | 7 +++++-- zypp/ZYpp.h | 18 ++++++++++++------ zypp/detail/PackageImplIf.cc | 12 +++++++++--- zypp/detail/PackageImplIf.h | 23 ++++++++++++++++++----- zypp/detail/SrcPackageImplIf.cc | 17 ++++++++++------- zypp/detail/SrcPackageImplIf.h | 16 +++++++++++++--- zypp/repo/cached/PackageImpl.cc | 10 ++++++++++ zypp/repo/cached/PackageImpl.h | 13 ++++++------- zypp/target/TargetImpl.cc | 10 ++++++++++ zypp/target/TargetImpl.h | 9 ++++++--- zypp/zypp_detail/ZYppImpl.cc | 6 ++++++ zypp/zypp_detail/ZYppImpl.h | 12 ++++++++---- 16 files changed, 141 insertions(+), 68 deletions(-) diff --git a/VERSION.cmake b/VERSION.cmake index 0677993..407adac 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -47,4 +47,4 @@ SET(LIBZYPP_MAJOR "3") SET(LIBZYPP_MINOR "13") SET(LIBZYPP_COMPATMINOR "13") -SET(LIBZYPP_PATCH "3") +SET(LIBZYPP_PATCH "4") diff --git a/devel/devel.ma/Parse.cc b/devel/devel.ma/Parse.cc index 4e216cd..e48d098 100644 --- a/devel/devel.ma/Parse.cc +++ b/devel/devel.ma/Parse.cc @@ -48,8 +48,11 @@ struct Xprint { bool operator()( const PoolItem & obj_r ) { - MIL << obj_r << " " << obj_r->summary() << endl; - MIL << obj_r << " " << obj_r->description() << endl; + Package::constPtr p( asKind(obj_r) ); + if ( p ) + { + MIL << p << " \t" << p->sourcePkgName() << '-' << p->sourcePkgEdition() << endl; + } return true; } @@ -264,25 +267,6 @@ int main( int argc, char * argv[] ) //zypp::base::LogControl::instance().logfile( "log.restrict" ); INT << "===[START]==========================================" << endl; - Capability c( CapFactory().parse( ResTraits::kind, - "modalias(kernel-bigsmp:pci:kfghkskd***k)" ) ); - - capability::ModaliasCap::constPtr mc( capability::asKind(c) ); - - DBG << c << endl; - DBG << c.index() << endl; - - MIL << mc << endl; - MIL << mc->name() << endl; - MIL << mc->pkgname() << endl; - - - - /////////////////////////////////////////////////////////////////// - INT << "===[END]============================================" << endl << endl; - zypp::base::LogControl::instance().logNothing(); - return 0; - RepoManager repoManager( makeRepoManager( "/Local/ROOT" ) ); RepoInfoList repos = repoManager.knownRepositories(); SEC << repos << endl; @@ -346,7 +330,7 @@ int main( int argc, char * argv[] ) SEC << pool.knownRepositoriesSize() << endl; std::for_each( pool.knownRepositoriesBegin(), pool.knownRepositoriesEnd(), Print() ); - std::for_each( pool.byNameBegin("glibc"), pool.byNameEnd("glibc"), Xprint() ); + std::for_each( pool.begin(), pool.end(), Xprint() ); /////////////////////////////////////////////////////////////////// INT << "===[END]============================================" << endl << endl; diff --git a/zypp/Package.cc b/zypp/Package.cc index 0e63228..8188f3a 100644 --- a/zypp/Package.cc +++ b/zypp/Package.cc @@ -111,7 +111,13 @@ namespace zypp OnMediaLocation Package::location() const { return pimpl().location(); } - + + std::string Package::sourcePkgName() const + { return pimpl().sourcePkgName(); } + + Edition Package::sourcePkgEdition() const + { return pimpl().sourcePkgEdition(); } + ///////////////////////////////////////////////////////////////// } // namespace zypp /////////////////////////////////////////////////////////////////// diff --git a/zypp/Package.h b/zypp/Package.h index 11e9b74..04019b2 100644 --- a/zypp/Package.h +++ b/zypp/Package.h @@ -40,7 +40,7 @@ namespace zypp typedef std::set Keywords; public: - + /** Get the package change log */ Changelog changelog() const; /** */ @@ -77,19 +77,29 @@ namespace zypp /** Disk usage per directory */ DiskUsage diskusage() const; - + + /** Name of the source rpm this package was built from. + * Empty if unknown. + */ + std::string sourcePkgName() const; + + /** Edition of the source rpm this package was built from. + * Empty if unknown. + */ + Edition sourcePkgEdition() const; + /** * Checksum the source says this package should have * \deprecated Use location().checksum() */ ZYPP_DEPRECATED CheckSum checksum() const { return location().checksum(); } - + /** * \short Location of the resolvable in the repository */ OnMediaLocation location() const; - + protected: Package( const NVRAD & nvrad_r ); /** Dtor */ diff --git a/zypp/ZYpp.cc b/zypp/ZYpp.cc index 46716ee..b3b9eb0 100644 --- a/zypp/ZYpp.cc +++ b/zypp/ZYpp.cc @@ -98,7 +98,7 @@ namespace zypp void ZYpp::initTarget(const Pathname & root, bool commit_only ) { _pimpl->initTarget(root, commit_only); } - + void ZYpp::initializeTarget(const Pathname & root) { _pimpl->initializeTarget(root); } @@ -108,6 +108,9 @@ namespace zypp ZYppCommitResult ZYpp::commit( const ZYppCommitPolicy & policy_r ) { return _pimpl->commit( policy_r ); } + void ZYpp::installSrcPackage( const ResTraits::constPtrType & srcPackage_r ) + { _pimpl->installSrcPackage( srcPackage_r ); } + /////////////////////////////////////////////////////////////////// void ZYpp::setTextLocale( const Locale & textLocale_r ) @@ -139,7 +142,7 @@ namespace zypp Pathname ZYpp::tmpPath() const { return _pimpl->tmpPath(); } - + void ZYpp::setHomePath( const Pathname & path ) { _pimpl->setHomePath(path); } diff --git a/zypp/ZYpp.h b/zypp/ZYpp.h index c46e5a1..2e68fc1 100644 --- a/zypp/ZYpp.h +++ b/zypp/ZYpp.h @@ -20,6 +20,7 @@ #include "zypp/base/Deprecated.h" #include "zypp/ZYppCommit.h" +#include "zypp/ResTraits.h" #include "zypp/Target.h" #include "zypp/Resolver.h" @@ -59,7 +60,7 @@ namespace zypp public: - /** + /** * Access to the main resolvable pool * \ref zypp::ResPool */ @@ -78,7 +79,7 @@ namespace zypp DiskUsageCounter::MountPointSet diskUsage(); void setPartitions(const DiskUsageCounter::MountPointSet &mp); - + DiskUsageCounter::MountPointSet getPartitions() const; public: @@ -97,8 +98,8 @@ namespace zypp * \throws Exception * if commit_only == true, just init the target, dont populate store or pool */ - ZYPP_DEPRECATED void initTarget(const Pathname & root, bool commit_only = false); - + ZYPP_DEPRECATED void initTarget(const Pathname & root, bool commit_only = false); + /** * \throws Exception */ @@ -115,6 +116,11 @@ namespace zypp */ ZYppCommitResult commit( const ZYppCommitPolicy & policy_r ); + /** Install a source package on the Target. + * \throws Exception + */ + void installSrcPackage( const ResTraits::constPtrType & srcPackage_r ); + public: /** */ Resolver_Ptr resolver() const; @@ -154,10 +160,10 @@ namespace zypp public: /** Get the path where zypp related plugins store persistent data and caches */ Pathname homePath() const; - + /** Get the path where zypp related plugins store temp data */ Pathname tmpPath() const; - + /** set the home, if you need to change it */ void setHomePath( const Pathname & path ); diff --git a/zypp/detail/PackageImplIf.cc b/zypp/detail/PackageImplIf.cc index 48b4a6a..04dd940 100644 --- a/zypp/detail/PackageImplIf.cc +++ b/zypp/detail/PackageImplIf.cc @@ -21,6 +21,9 @@ namespace zypp namespace detail { ///////////////////////////////////////////////////////////////// + ByteCount PackageImplIf::downloadSize() const + { return location().downloadSize(); } + unsigned PackageImplIf::mediaNr() const { return location().medianr(); } @@ -71,9 +74,6 @@ namespace zypp ByteCount PackageImplIf::sourcesize() const { return ByteCount(); } - ByteCount PackageImplIf::downloadSize() const - { return location().downloadSize(); } - OnMediaLocation PackageImplIf::location() const { return OnMediaLocation(); } @@ -92,6 +92,12 @@ namespace zypp std::list PackageImplIf::patchRpms() const { return std::list(); } + std::string PackageImplIf::sourcePkgName() const + { return std::string(); } + + Edition PackageImplIf::sourcePkgEdition() const + { return Edition(); } + ///////////////////////////////////////////////////////////////// } // namespace detail /////////////////////////////////////////////////////////////////// diff --git a/zypp/detail/PackageImplIf.h b/zypp/detail/PackageImplIf.h index 920ab16..13ad3a3 100644 --- a/zypp/detail/PackageImplIf.h +++ b/zypp/detail/PackageImplIf.h @@ -49,13 +49,18 @@ namespace zypp typedef packagedelta::PatchRpm PatchRpm; typedef std::set Keywords; - public: - /** Overloaded ResObjectImpl attribute. + public: + /** Overloaded ResObjectImpl attribute. * \return The \ref location media number. */ virtual unsigned mediaNr() const; - public: + /** Overloaded ResObjectImpl attribute. + * \return The \ref location downloadSize. + */ + virtual ByteCount downloadSize() const; + + public: /** \name Rpm Package Attributes. */ //@{ @@ -99,10 +104,18 @@ namespace zypp /** */ virtual std::list patchRpms() const PURE_VIRTUAL; - virtual ByteCount downloadSize() const PURE_VIRTUAL; - virtual OnMediaLocation location() const PURE_VIRTUAL; + /** Name of the source rpm this package was built from. + * Empty if unknown. + */ + virtual std::string sourcePkgName() const PURE_VIRTUAL; + + /** Edition of the source rpm this package was built from. + * Empty if unknown. + */ + virtual Edition sourcePkgEdition() const PURE_VIRTUAL; + //@} }; diff --git a/zypp/detail/SrcPackageImplIf.cc b/zypp/detail/SrcPackageImplIf.cc index 9752914..881eae3 100644 --- a/zypp/detail/SrcPackageImplIf.cc +++ b/zypp/detail/SrcPackageImplIf.cc @@ -21,19 +21,22 @@ namespace zypp namespace detail { ///////////////////////////////////////////////////////////////// + ByteCount SrcPackageImplIf::downloadSize() const + { return location().downloadSize(); } + + unsigned SrcPackageImplIf::mediaNr() const + { return location().medianr(); } + ///////////////////////////////////////////////////////////////// // Default implementation of SrcPackageImplIf attributes, // as far as resonable. ///////////////////////////////////////////////////////////////// - OnMediaLocation SrcPackageImplIf::location() const - { return OnMediaLocation(); } - - ByteCount SrcPackageImplIf::downloadSize() const - { return location().downloadSize(); } + OnMediaLocation SrcPackageImplIf::location() const + { return OnMediaLocation(); } - DiskUsage SrcPackageImplIf::diskusage() const - { return DiskUsage(); } + DiskUsage SrcPackageImplIf::diskusage() const + { return DiskUsage(); } ///////////////////////////////////////////////////////////////// } // namespace detail diff --git a/zypp/detail/SrcPackageImplIf.h b/zypp/detail/SrcPackageImplIf.h index 1b5cec6..399506c 100644 --- a/zypp/detail/SrcPackageImplIf.h +++ b/zypp/detail/SrcPackageImplIf.h @@ -40,12 +40,22 @@ namespace zypp typedef SrcPackage ResType; public: - virtual OnMediaLocation location() const PURE_VIRTUAL; + /** Overloaded ResObjectImpl attribute. + * \return The \ref location media number. + */ + virtual unsigned mediaNr() const; + + /** Overloaded ResObjectImpl attribute. + * \return The \ref location downloadSize. + */ + virtual ByteCount downloadSize() const; + + public: /** */ - virtual ByteCount downloadSize() const PURE_VIRTUAL; + virtual OnMediaLocation location() const PURE_VIRTUAL; /** */ virtual DiskUsage diskusage() const PURE_VIRTUAL; - + }; /////////////////////////////////////////////////////////////////// diff --git a/zypp/repo/cached/PackageImpl.cc b/zypp/repo/cached/PackageImpl.cc index 0efe802..f19fe45 100644 --- a/zypp/repo/cached/PackageImpl.cc +++ b/zypp/repo/cached/PackageImpl.cc @@ -193,6 +193,16 @@ std::list PackageImpl::filenames() const return std::list(); } +std::string PackageImpl::sourcePkgName() const +{ + return _repository->resolvableQuery().queryStringAttribute( _id, cache::attrPackageSourcePkgName() ); +} + +Edition PackageImpl::sourcePkgEdition() const +{ + return _repository->resolvableQuery().queryStringAttribute( _id, cache::attrPackageSourcePkgEdition() ); +} + ///////////////////////////////////////////////////////////////// } } } // namespace zypp::repo::cached /////////////////////////////////////////////////////////////////// diff --git a/zypp/repo/cached/PackageImpl.h b/zypp/repo/cached/PackageImpl.h index cef0030..e51614f 100644 --- a/zypp/repo/cached/PackageImpl.h +++ b/zypp/repo/cached/PackageImpl.h @@ -30,7 +30,7 @@ namespace cached public: PackageImpl( const data::RecordId &id, repo::cached::RepoImpl::Ptr repository_r ); - + virtual TranslatedText summary() const; virtual TranslatedText description() const; virtual TranslatedText insnotify() const; @@ -41,7 +41,7 @@ namespace cached virtual bool installOnly() const; virtual Date buildtime() const; virtual Date installtime() const; - + // PACKAGE virtual std::string buildhost() const; virtual std::string distribution() const; @@ -61,12 +61,11 @@ namespace cached virtual std::list authors() const; virtual std::list filenames() const; virtual OnMediaLocation location() const; - - /*virtual std::list deltaRpms() const; - virtual std::list patchRpms() const; - */ + virtual std::string sourcePkgName() const; + virtual Edition sourcePkgEdition() const; + virtual Repository repository() const; - + private: repo::cached::RepoImpl::Ptr _repository; diff --git a/zypp/target/TargetImpl.cc b/zypp/target/TargetImpl.cc index 06a70ca..d6f7c38 100644 --- a/zypp/target/TargetImpl.cc +++ b/zypp/target/TargetImpl.cc @@ -25,6 +25,7 @@ #include "zypp/Resolvable.h" #include "zypp/ResObject.h" #include "zypp/Package.h" +#include "zypp/SrcPackage.h" #include "zypp/Pattern.h" #include "zypp/Selection.h" #include "zypp/Script.h" @@ -793,6 +794,15 @@ namespace zypp } } + void TargetImpl::installSrcPackage( const SrcPackage::constPtr & srcPackage_r ) + { + ZYPP_THROW( Exception("srcPackage install not yet implemented") ); +#warning IMPLEMENT IT + // Provide srcPackage_r on the local disk and install it using + // _rpm.installPackage( localfile ); + } + + ///////////////////////////////////////////////////////////////// } // namespace target /////////////////////////////////////////////////////////////////// diff --git a/zypp/target/TargetImpl.h b/zypp/target/TargetImpl.h index 23e1948..296791e 100644 --- a/zypp/target/TargetImpl.h +++ b/zypp/target/TargetImpl.h @@ -113,6 +113,9 @@ namespace zypp */ PoolItemList commit( const PoolItemList & items_r, const ZYppCommitPolicy & policy_r, const ResPool & pool_r ); + /** Install a source package on the Target. */ + void installSrcPackage( const ResTraits::constPtrType & srcPackage_r ); + /** Overload to realize stream output. */ virtual std::ostream & dumpOn( std::ostream & str ) const { @@ -135,12 +138,12 @@ namespace zypp /** return the last modification date of the target */ Date timestamp() const; - - /** + + /** * reload the target in future calls if * needed. * note the loading can actually be delayed, but - * the next call to resolvables must reflect the + * the next call to resolvables must reflect the * status of the system. */ void reset(); diff --git a/zypp/zypp_detail/ZYppImpl.cc b/zypp/zypp_detail/ZYppImpl.cc index ad8af98..84b5b05 100644 --- a/zypp/zypp_detail/ZYppImpl.cc +++ b/zypp/zypp_detail/ZYppImpl.cc @@ -273,6 +273,12 @@ namespace zypp return res; } + void ZYppImpl::installSrcPackage( const ResTraits::constPtrType & srcPackage_r ) + { + if (! _target) + ZYPP_THROW( Exception("Target not initialized.") ); + _target->_pimpl->installSrcPackage( srcPackage_r ); + } //------------------------------------------------------------------------ // locales diff --git a/zypp/zypp_detail/ZYppImpl.h b/zypp/zypp_detail/ZYppImpl.h index 1f3af21..0467457 100644 --- a/zypp/zypp_detail/ZYppImpl.h +++ b/zypp/zypp_detail/ZYppImpl.h @@ -21,6 +21,7 @@ #include "zypp/Locale.h" #include "zypp/KeyRing.h" #include "zypp/ZYppCommit.h" +#include "zypp/ResTraits.h" #include "zypp/DiskUsageCounter.h" using namespace zypp::filesystem; @@ -82,13 +83,13 @@ namespace zypp * true, just init the target, dont populate store or pool */ void initializeTarget(const Pathname & root); - + /** * \throws Exception * if commit_only == true, just init the target, dont populate store or pool */ ZYPP_DEPRECATED void initTarget(const Pathname & root, bool commit_only); - + /** * \throws Exception */ @@ -97,6 +98,9 @@ namespace zypp /** Commit changes and transactions. */ ZYppCommitResult commit( const ZYppCommitPolicy & policy_r ); + /** Install a source package on the Target. */ + void installSrcPackage( const ResTraits::constPtrType & srcPackage_r ); + public: /** \todo Signal locale change. */ void setTextLocale( const Locale & textLocale_r ) @@ -130,10 +134,10 @@ namespace zypp /** Get the path where zypp related plugins store persistent data and caches */ Pathname homePath() const; - + /** Get the path where zypp related plugins store tmp data */ Pathname tmpPath() const; - + /** set the home, if you need to change it */ void setHomePath( const Pathname & path ); -- 2.7.4