- Added package attributes Package::sourcePkgName and
authorMichael Andres <ma@suse.de>
Tue, 31 Jul 2007 19:58:43 +0000 (19:58 +0000)
committerMichael Andres <ma@suse.de>
Tue, 31 Jul 2007 19:58:43 +0000 (19:58 +0000)
  Package::sourcePkgEdition. Name and edition of the source
  rpm this package was built from.
- Added ZYpp::installSrcPackage to install a single source package.

16 files changed:
VERSION.cmake
devel/devel.ma/Parse.cc
zypp/Package.cc
zypp/Package.h
zypp/ZYpp.cc
zypp/ZYpp.h
zypp/detail/PackageImplIf.cc
zypp/detail/PackageImplIf.h
zypp/detail/SrcPackageImplIf.cc
zypp/detail/SrcPackageImplIf.h
zypp/repo/cached/PackageImpl.cc
zypp/repo/cached/PackageImpl.h
zypp/target/TargetImpl.cc
zypp/target/TargetImpl.h
zypp/zypp_detail/ZYppImpl.cc
zypp/zypp_detail/ZYppImpl.h

index 0677993..407adac 100644 (file)
@@ -47,4 +47,4 @@
 SET(LIBZYPP_MAJOR "3")
 SET(LIBZYPP_MINOR "13")
 SET(LIBZYPP_COMPATMINOR "13")
-SET(LIBZYPP_PATCH "3")
+SET(LIBZYPP_PATCH "4")
index 4e216cd..e48d098 100644 (file)
@@ -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<Package>(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<Package>::kind,
-                                    "modalias(kernel-bigsmp:pci:kfghkskd***k)" ) );
-
-  capability::ModaliasCap::constPtr mc( capability::asKind<capability::ModaliasCap>(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;
index 0e63228..8188f3a 100644 (file)
@@ -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
 ///////////////////////////////////////////////////////////////////
index 11e9b74..04019b2 100644 (file)
@@ -40,7 +40,7 @@ namespace zypp
     typedef std::set<PackageKeyword> 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 */
index 46716ee..b3b9eb0 100644 (file)
@@ -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<SrcPackage>::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); }
 
index c46e5a1..2e68fc1 100644 (file)
@@ -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<SrcPackage>::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 );
 
index 48b4a6a..04dd940 100644 (file)
@@ -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::PatchRpm> PackageImplIf::patchRpms() const
       { return std::list<PatchRpm>(); }
 
+      std::string PackageImplIf::sourcePkgName() const
+      { return std::string(); }
+
+      Edition PackageImplIf::sourcePkgEdition() const
+      { return Edition(); }
+
     /////////////////////////////////////////////////////////////////
   } // namespace detail
   ///////////////////////////////////////////////////////////////////
index 920ab16..13ad3a3 100644 (file)
@@ -49,13 +49,18 @@ namespace zypp
       typedef packagedelta::PatchRpm    PatchRpm;
       typedef std::set<PackageKeyword>  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<PatchRpm> 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;
+
       //@}
 
     };
index 9752914..881eae3 100644 (file)
@@ -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
index 1b5cec6..399506c 100644 (file)
@@ -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;
-      
+
     };
     ///////////////////////////////////////////////////////////////////
 
index 0efe802..f19fe45 100644 (file)
@@ -193,6 +193,16 @@ std::list<std::string> PackageImpl::filenames() const
   return std::list<std::string>();
 }
 
+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
 ///////////////////////////////////////////////////////////////////
index cef0030..e51614f 100644 (file)
@@ -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<std::string> authors() const;
     virtual std::list<std::string> filenames() const;
     virtual OnMediaLocation location() const;
-    
-    /*virtual std::list<DeltaRpm> deltaRpms() const;
-    virtual std::list<PatchRpm> patchRpms() const;
-    */
+    virtual std::string sourcePkgName() const;
+    virtual Edition sourcePkgEdition() const;
+
     virtual Repository repository() const;
-    
+
 
   private:
     repo::cached::RepoImpl::Ptr _repository;
index 06a70ca..d6f7c38 100644 (file)
@@ -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
   ///////////////////////////////////////////////////////////////////
index 23e1948..296791e 100644 (file)
@@ -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<SrcPackage>::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();
index ad8af98..84b5b05 100644 (file)
@@ -273,6 +273,12 @@ namespace zypp
       return res;
     }
 
+    void ZYppImpl::installSrcPackage( const ResTraits<SrcPackage>::constPtrType & srcPackage_r )
+    {
+      if (! _target)
+        ZYPP_THROW( Exception("Target not initialized.") );
+      _target->_pimpl->installSrcPackage( srcPackage_r );
+    }
 
     //------------------------------------------------------------------------
     // locales
index 1f3af21..0467457 100644 (file)
@@ -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<SrcPackage>::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 );