- Moved DefaultAcceptBits enum to class KeyRing (formerly KeyRingReort).
authorMichael Andres <ma@suse.de>
Fri, 19 Sep 2008 11:25:51 +0000 (11:25 +0000)
committerMichael Andres <ma@suse.de>
Fri, 19 Sep 2008 11:25:51 +0000 (11:25 +0000)
- Fix Deltarpm_test. Running the test polluted the source tree.

VERSION.cmake
devel/devel.ma/NewPool.cc
devel/devel.ma/Tools.h
package/libzypp.changes
tests/zypp/Deltarpm_test.cc
zypp/KeyRing.cc
zypp/KeyRing.h

index 74e81a6..13e2a9d 100644 (file)
@@ -59,8 +59,8 @@
 #   changes file. See './mkChangelog -h' for help.
 #
 SET(LIBZYPP_MAJOR "5")
-SET(LIBZYPP_COMPATMINOR "11")
-SET(LIBZYPP_MINOR "11")
+SET(LIBZYPP_COMPATMINOR "12")
+SET(LIBZYPP_MINOR "12")
 SET(LIBZYPP_PATCH "0")
 #
 # LAST RELEASED: 5.11.0 (11)
index 4dbc473..34e5c42 100644 (file)
@@ -444,6 +444,14 @@ try {
   INT << "===[START]==========================================" << endl;
   ZConfig::instance();
 
+  Edition a("4.21.3-2");
+  DBG << a << endl;
+  DBG << (a == a) << endl;
+  DBG << (a.match(a)) << endl;
+  ///////////////////////////////////////////////////////////////////
+  INT << "===[END]============================================" << endl << endl;
+  zypp::base::LogControl::instance().logNothing();
+  return 0;
 
 
 #if 0
@@ -485,7 +493,6 @@ try {
   }
 
   repoManager.loadFromCache( nrepo );
-#endif
 
 
   ///////////////////////////////////////////////////////////////////
@@ -515,6 +522,24 @@ try {
   if ( 1 )
   {
     RepoManager repoManager( makeRepoManager( sysRoot ) );
+    ServiceInfoList services = repoManager.knownServices();
+
+    for ( ServiceInfoList::iterator it = services.begin(); it != services.end(); ++it )
+    {
+      ServiceInfo & nservice( *it );
+      SEC << nservice << endl;
+
+      if ( ! nservice.enabled() )
+        continue;
+
+      repoManager.refreshService( nservice );
+
+    }
+  }
+
+  if ( 1 )
+  {
+    RepoManager repoManager( makeRepoManager( sysRoot ) );
     RepoInfoList repos = repoManager.knownRepositories();
 
     // launch repos
@@ -581,6 +606,7 @@ try {
     UpgradeStatistics u;
     getZYpp()->resolver()->doUpgrade( u );
   }
+
   ///////////////////////////////////////////////////////////////////
   ///////////////////////////////////////////////////////////////////
 
@@ -598,6 +624,45 @@ try {
     }
   }
 
+
+  //////////////////////////////////////////////////////////////////
+  INT << "===[END]============================================" << endl << endl;
+  zypp::base::LogControl::instance().logNothing();
+  return 0;
+  for_( it, pool.byKindBegin<Product>(), pool.byKindEnd<Product>() )
+  {
+    MIL << *it << endl;
+    DBG << (*it)->provides() << endl;
+  }
+
+  sat::WhatProvides prv( Capability("product()") );
+  SEC << prv << endl;
+  for_( it, prv.begin(), prv.end() )
+  {
+
+    MIL << *it << endl;
+    MIL << it->provides() << endl;
+  }
+
+  Capability cap;
+
+  cap = Capability( "sles-release" );
+  prv = sat::WhatProvides( cap );
+  MIL << cap << ": " << prv << endl;
+
+  cap = Capability( "sles-release == 11" );
+  prv = sat::WhatProvides( cap );
+  MIL << cap << ": " << prv << endl;
+
+
+//   PoolItem pi ( getPi<Package>("sles-release", Edition("11.0") ) );
+
+  //////////////////////////////////////////////////////////////////
+  INT << "===[END]============================================" << endl << endl;
+  zypp::base::LogControl::instance().logNothing();
+  return 0;
+
+
   //SEC << zypp::getZYpp()->diskUsage() << endl;
 
   //vdumpPoolStats( USR << "Pool:"<< endl, pool.begin(), pool.end() ) << endl;
index c3aecd8..a1154bc 100644 (file)
@@ -158,7 +158,7 @@ PoolItem getPi( const std::string & name_r, const Edition & ed_r, const Arch & a
   for_(it, pool.byNameBegin(name_r), pool.byNameEnd(name_r) )
   {
     if ( !ret && isKind<_Res>( (*it).resolvable() )
-         && ( ed_r == Edition() || ed_r == (*it)->edition() )
+         && ( ed_r == Edition() || ed_r.match((*it)->edition()) == 0 )
          && ( arch_r == Arch()  || arch_r == (*it)->arch()  ) )
     {
       ret = (*it);
index 20c2a07..fb60938 100644 (file)
@@ -1,4 +1,10 @@
 -------------------------------------------------------------------
+Fri Sep 19 13:17:38 CEST 2008 - ma@suse.de
+
+- Moved DefaultAcceptBits enum to class KeyRing (formerly KeyRingReort).
+- revision 11102
+
+-------------------------------------------------------------------
 Thu Sep 18 16:11:23 CEST 2008 - ma@suse.de
 
 - Use service alias as namespace for it's repositories aliases.
index 7dd0f58..5a927d6 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "zypp/base/Logger.h"
 #include "zypp/base/Exception.h"
+#include "zypp/TmpPath.h"
 #include "zypp/PathInfo.h"
 #include "zypp/RepoManager.h"
 #include "zypp/sat/Pool.h"
@@ -26,21 +27,14 @@ using namespace zypp::filesystem;
 
 BOOST_AUTO_TEST_CASE(delta)
 {
-  KeyRingTestReceiver rec;
-  rec.answerAcceptUnknownKey(true);
-//  rec.answerImportKey(true);
-  Pathname rootdir(TEST_DIR );
-  RepoManagerOptions opts(rootdir);
-  opts.repoRawCachePath = rootdir;
-  opts.repoSolvCachePath = rootdir;
-  opts.knownReposPath = rootdir;
-  opts.knownServicesPath = rootdir;
+  KeyRing::setDefaultAccept( KeyRing::ACCEPT_UNKNOWNKEY | KeyRing::ACCEPT_UNSIGNED_FILE );
 
-  RepoManager rm(opts);
+  TmpDir rootdir;
+  RepoManager rm( RepoManagerOptions::makeTestSetup( rootdir ) );
 
   RepoInfo updates;
   updates.setAlias("updates");
-  updates.addBaseUrl(Url(string("dir:") + rootdir.absolutename().asString() ));
+  updates.addBaseUrl( Pathname(TEST_DIR).asUrl() );
 
   try
   {
@@ -61,7 +55,7 @@ BOOST_AUTO_TEST_CASE(delta)
     BOOST_CHECK(it->name() == "libzypp");
     BOOST_CHECK(it->edition() == Edition("4.21.3-2"));
     BOOST_CHECK(it->arch() == "i386");
-    BOOST_CHECK(it->baseversion().edition().match(Edition("4.21.3-1")) 
+    BOOST_CHECK(it->baseversion().edition().match(Edition("4.21.3-1"))
       ||it->baseversion().edition().match(Edition("4.21.2-3")));
 
     cout << it->name() << " - " << it->edition() << " - " <<  it->arch()
@@ -69,10 +63,9 @@ BOOST_AUTO_TEST_CASE(delta)
 
     cout << (it->edition() == "4.21.3-2") << endl;              // fine
     cout << (it->edition() == Edition("4.21.3-2")) << endl;     // fine
-    cout << (it->edition().match(Edition("4.21.3-2"))) << endl; //! \todo FIXME says no 
-    cout << (it->edition().match("4.21.3-2")) << endl;          //! \todo FIXME says no
+    cout << (it->edition().match(Edition("4.21.3-2")) == 0) << endl; // !match returns -1,0,1
+    cout << (it->edition().match("4.21.3-2") == 0) << endl;          // !match returns -1,0,1
   }
 
   //! \todo FIXME Edition("0:4.21.3-2") != Edition("4.21.3-2") (not even does Edition("0:4.21.3-2").match(Edition("4.21.3-2"))
-  rm.cleanCache(updates);
 }
index 75f52d1..811a61d 100644 (file)
@@ -55,34 +55,34 @@ namespace zypp
 
   namespace
   {
-    KeyRingReport::DefaultAccept _keyRingDefaultAccept( KeyRingReport::ACCEPT_NOTHING );
+    KeyRing::DefaultAccept _keyRingDefaultAccept( KeyRing::ACCEPT_NOTHING );
   }
 
-  KeyRingReport::DefaultAccept KeyRingReport::defaultAccept()
+  KeyRing::DefaultAccept KeyRing::defaultAccept()
   { return _keyRingDefaultAccept; }
 
-  void KeyRingReport::setDefaultAccept( DefaultAccept value_r )
+  void KeyRing::setDefaultAccept( DefaultAccept value_r )
   {
-    MIL << "Set new default accept: " << value_r << endl;
+    MIL << "Set new KeyRing::DefaultAccept: " << value_r << endl;
     _keyRingDefaultAccept = value_r;
   }
 
   ///////////////////////////////////////////////////////////////////
 
   bool KeyRingReport::askUserToAcceptUnsignedFile( const string &file )
-  { return _keyRingDefaultAccept.testFlag( ACCEPT_UNSIGNED_FILE ); }
+  { return _keyRingDefaultAccept.testFlag( KeyRing::ACCEPT_UNSIGNED_FILE ); }
 
   bool KeyRingReport::askUserToAcceptUnknownKey( const string &file, const string &id )
-  { return _keyRingDefaultAccept.testFlag( ACCEPT_UNKNOWNKEY ); }
+  { return _keyRingDefaultAccept.testFlag( KeyRing::ACCEPT_UNKNOWNKEY ); }
 
   bool KeyRingReport::askUserToTrustKey( const PublicKey &key )
-  { return _keyRingDefaultAccept.testFlag( TRUST_KEY ); }
+  { return _keyRingDefaultAccept.testFlag( KeyRing::TRUST_KEY ); }
 
   bool KeyRingReport::askUserToImportKey( const PublicKey &key)
-  { return _keyRingDefaultAccept.testFlag( IMPORT_KEY ); }
+  { return _keyRingDefaultAccept.testFlag( KeyRing::IMPORT_KEY ); }
 
   bool KeyRingReport::askUserToAcceptVerificationFailed( const string &file, const PublicKey &key )
-  { return _keyRingDefaultAccept.testFlag( ACCEPT_VERIFICATION_FAILED ); }
+  { return _keyRingDefaultAccept.testFlag( KeyRing::ACCEPT_VERIFICATION_FAILED ); }
 
   ///////////////////////////////////////////////////////////////////
   //
@@ -91,25 +91,14 @@ namespace zypp
   /** KeyRing implementation. */
   struct KeyRing::Impl
   {
-    Impl(const Pathname &baseTmpDir)
-    : _trusted_tmp_dir(baseTmpDir, "zypp-trusted-kr")
-   ,  _general_tmp_dir(baseTmpDir, "zypp-general-kr")
-   , _base_dir( baseTmpDir )
-
+    Impl( const Pathname & baseTmpDir )
+    : _trusted_tmp_dir( baseTmpDir, "zypp-trusted-kr" )
+    , _general_tmp_dir( baseTmpDir, "zypp-general-kr" )
+    , _base_dir( baseTmpDir )
     {
+      MIL << "Current KeyRing::DefaultAccept: " << _keyRingDefaultAccept << endl;
     }
 
-    /*
-    Impl( const Pathname &general_kr, const Pathname &trusted_kr )
-    {
-      filesystem::assert_dir(general_kr);
-      filesystem::assert_dir(trusted_kr);
-
-      generalKeyRing() = general_kr;
-      trustedKeyRing() = trusted_kr;
-    }
-    */
-
     void importKey( const PublicKey &key, bool trusted = false);
     void deleteKey( const string &id, bool trusted );
 
index 64e4b51..ea9b3bf 100644 (file)
@@ -33,7 +33,12 @@ namespace zypp
 
   /** Callbacks from signature verification workflow.
    *
-   * Per default all methods answer \c false.
+   * Per default all methods answer \c false. This may be canged
+   * by calling \ref KeyRing::setDefaultAccept.
+   * \code
+   *  KeyRing::setDefaultAccept( KeyRing::ACCEPT_UNSIGNED_FILE | KeyRing::ACCEPT_VERIFICATION_FAILED );
+   * \endcode
+   * \see \ref KeyRing
   */
   struct KeyRingReport : public callback::ReportBase
   {
@@ -78,29 +83,7 @@ namespace zypp
      */
     virtual bool askUserToAcceptVerificationFailed( const std::string &filedesc, const PublicKey &key );
 
-    public:
-      /** \name Query/change the default values.
-       * Per default all methods answer \c false.
-       */
-      //@{
-      enum DefaultAcceptBits
-      {
-        ACCEPT_NOTHING             = 0x0000,
-        ACCEPT_UNSIGNED_FILE       = 0x0001,
-        ACCEPT_UNKNOWNKEY          = 0x0002,
-        TRUST_KEY                  = 0x0004,
-        IMPORT_KEY                 = 0x0008,
-        ACCEPT_VERIFICATION_FAILED = 0x0010,
-      };
-      ZYPP_DECLARE_FLAGS(DefaultAccept,DefaultAcceptBits);
-
-      /** Get the active accept bits. */
-      static DefaultAccept defaultAccept();
-      /** Set the active accept bits. */
-      static void setDefaultAccept( DefaultAccept value_r );
-     //@}
   };
-  ZYPP_DECLARE_OPERATORS_FOR_FLAGS(KeyRingReport::DefaultAccept);
 
   struct KeyRingSignals : public callback::ReportBase
   {
@@ -133,12 +116,43 @@ namespace zypp
   //
   //   CLASS NAME : KeyRing
   //
-  /** Class that represent a text and multiple translations.
+  /** Gpg key handling.
+   *
   */
-  class KeyRing  : public base::ReferenceCounted, private base::NonCopyable
+  class KeyRing : public base::ReferenceCounted, private base::NonCopyable
   {
     friend std::ostream & operator<<( std::ostream & str, const KeyRing & obj );
 
+    public:
+      /** \name Default answers in verification workflow.
+       * Per default all answers are \c false.
+       */
+      //@{
+      /** \ref DefaultAccept flags (\see \ref base::Flags) are used to
+       *  define the default callback answers during signature verification.
+       * \code
+       *  KeyRingReport::setDefaultAccept( KeyRing::ACCEPT_UNSIGNED_FILE | ACCEPT_VERIFICATION_FAILED );
+       * \endcode
+       * \see \ref KeyRingReport.
+       */
+      enum DefaultAcceptBits
+      {
+        ACCEPT_NOTHING             = 0x0000,
+        ACCEPT_UNSIGNED_FILE       = 0x0001,
+        ACCEPT_UNKNOWNKEY          = 0x0002,
+        TRUST_KEY                  = 0x0004,
+        IMPORT_KEY                 = 0x0008,
+        ACCEPT_VERIFICATION_FAILED = 0x0010,
+      };
+      ZYPP_DECLARE_FLAGS( DefaultAccept, DefaultAcceptBits );
+
+      /** Get the active accept bits. */
+      static DefaultAccept defaultAccept();
+
+      /** Set the active accept bits. */
+      static void setDefaultAccept( DefaultAccept value_r );
+     //@}
+
   public:
     /** Implementation  */
     class Impl;
@@ -257,6 +271,9 @@ namespace zypp
     return str;
   }
 
+  /** \relates KeyRing::DefaultAccept  */
+  ZYPP_DECLARE_OPERATORS_FOR_FLAGS( KeyRing::DefaultAccept );
+
   ///////////////////////////////////////////////////////////////////
 
   namespace target