- Remove obsolete zypp-query-pool binary. zypper provides all
authorMichael Andres <ma@suse.de>
Thu, 25 Sep 2008 11:17:17 +0000 (11:17 +0000)
committerMichael Andres <ma@suse.de>
Thu, 25 Sep 2008 11:17:17 +0000 (11:17 +0000)
  the information one needs.

package/libzypp.changes
tools/CMakeLists.txt
tools/registration/CMakeLists.txt [deleted file]
tools/registration/keyring-callbacks.h [deleted file]
tools/registration/zypp-query-pool.cc [deleted file]
zypp/RepoManager.cc
zypp/Url.h

index 88a00a7..4db1412 100644 (file)
@@ -1,4 +1,11 @@
 -------------------------------------------------------------------
+Thu Sep 25 13:11:43 CEST 2008 - ma@suse.de
+
+- Remove obsolete zypp-query-pool binary. zypper provides all
+  the information one needs.
+- revision 11160
+
+-------------------------------------------------------------------
 Wed Sep 24 19:11:19 CEST 2008 - jkupec@suse.cz
 
 - HistoryLog added and used to log package installs/removes and
index eca98b4..128c027 100644 (file)
@@ -1,3 +1,2 @@
-ADD_SUBDIRECTORY( registration ) 
 ADD_SUBDIRECTORY( package-manager )
 #ADD_SUBDIRECTORY( migrate-sources )
diff --git a/tools/registration/CMakeLists.txt b/tools/registration/CMakeLists.txt
deleted file mode 100644 (file)
index b587114..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-SET( querypool_SRC
-zypp-query-pool.cc
-)
-
-ADD_EXECUTABLE( zypp-query-pool ${querypool_SRC} )
-TARGET_LINK_LIBRARIES( zypp-query-pool zypp )
-TARGET_LINK_LIBRARIES( zypp-query-pool xml2 )
-TARGET_LINK_LIBRARIES( zypp-query-pool ${SATSOLVER_LIBRARY} )
-
-INSTALL(TARGETS zypp-query-pool RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/zypp )
diff --git a/tools/registration/keyring-callbacks.h b/tools/registration/keyring-callbacks.h
deleted file mode 100644 (file)
index 30cdb26..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-
-#ifndef ZYPP_QUERYPOOL_KEYRINGCALLBACKS_H
-#define ZYPP_QUERYPOOL_KEYRINGCALLBACKS_H
-
-#include <stdlib.h>
-#include <iostream>
-
-#include <zypp/base/Logger.h>
-#include <zypp/base/Sysconfig.h>
-#include <zypp/ZYppCallbacks.h>
-#include <zypp/Pathname.h>
-#include <zypp/KeyRing.h>
-#include <zypp/Digest.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{
-///////////////////////////////////////////////////////////////////
-
-
-///////////////////////////////////////////////////////////////////
-// KeyRingReceive
-///////////////////////////////////////////////////////////////////
-struct KeyRingReceive : public zypp::callback::ReceiveReport<zypp::KeyRingReport>
-{
-  KeyRingReceive()
-  {}
-
-  virtual bool askUserToAcceptUnsignedFile( const std::string &file, const zypp::KeyContext &keycontext )
-  {
-    return true;
-  }
-  virtual bool askUserToAcceptUnknownKey( const std::string &file, const std::string &id, const zypp::KeyContext &keycontext )
-  {
-    return true;
-  }
-
-  virtual bool askUserAcceptKey( const PublicKey &key, const zypp::KeyContext &keycontext )
-  {
-    DBG << "By default zypp-query-pool does not import keys for now." << std::endl;
-    return zypp::KeyRingReport::KEY_TRUST_TEMPORARILY;
-  }
-
-  virtual bool askUserToAcceptVerificationFailed( const std::string &file,  const PublicKey &key, const zypp::KeyContext &keycontext )
-  {
-    return true;
-  }
-};
-
-
-struct DigestReceive : public zypp::callback::ReceiveReport<zypp::DigestReport>
-{
-  DigestReceive()
-  {}
-
-  virtual bool askUserToAcceptNoDigest( const zypp::Pathname &file )
-  {
-    return true;
-  }
-  virtual bool askUserToAccepUnknownDigest( const Pathname &file, const std::string &name )
-  {
-    return true;
-  }
-  virtual bool askUserToAcceptWrongDigest( const Pathname &file, const std::string &requested, const std::string &found )
-  {
-    // this smells like false
-    return true;
-  }
-};
-
-///////////////////////////////////////////////////////////////////
-}
-; // namespace zypp
-///////////////////////////////////////////////////////////////////
-
-class KeyRingCallbacks
-{
-
-private:
-  zypp::KeyRingReceive _keyRingReport;
-
-public:
-  KeyRingCallbacks()
-  {
-    _keyRingReport.connect();
-  }
-
-  ~KeyRingCallbacks()
-  {
-    _keyRingReport.disconnect();
-  }
-
-};
-
-class DigestCallbacks
-{
-
-private:
-  zypp::DigestReceive _digestReport;
-
-public:
-  DigestCallbacks()
-  {
-    _digestReport.connect();
-  }
-
-  ~DigestCallbacks()
-  {
-    _digestReport.disconnect();
-  }
-
-};
-
-
-#endif // ZMD_BACKEND_KEYRINGCALLBACKS_H
diff --git a/tools/registration/zypp-query-pool.cc b/tools/registration/zypp-query-pool.cc
deleted file mode 100644 (file)
index f62c674..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-#include <iostream>
-
-#include <zypp/ZYpp.h>
-#include <zypp/zypp_detail/ZYppReadOnlyHack.h>
-#include <zypp/parser/ProductConfReader.h>
-#include <zypp/ZYppFactory.h>
-#include <zypp/RepoManager.h>
-#include <zypp/base/Logger.h>
-#include <zypp/base/Exception.h>
-#include <zypp/base/Algorithm.h>
-#include <zypp/Product.h>
-#include <zypp/ResFilters.h>
-#include <zypp/PoolItem.h>
-
-#undef ZYPP_BASE_LOGGER_LOGGROUP
-#define ZYPP_BASE_LOGGER_LOGGROUP "zypp-query-pool"
-
-#include "keyring-callbacks.h"
-
-using namespace std;
-using namespace zypp;
-using namespace zypp::resfilter;
-
-struct ByPresent : public PoolItemFilterFunctor
-{
-    bool operator()( const PoolItem & p ) const
-    {
-       if ( traits::isPseudoInstalled( p->kind() ) )
-           return p.status().isSatisfied();
-       else
-           return p.status().isInstalled();
-    }
-};
-
-
-//-----------------------------------------------------------------------------
-
-class PrintItem : public resfilter::PoolItemFilterFunctor
-{
-public:
-  string _repository;
-
-  PrintItem( const string & repository )
-      : _repository( repository )
-  { }
-
-  bool operator()( PoolItem item )
-  {
-    if (_repository.empty()
-        || _repository == item->repository().info().alias())
-    {
-
-       if ( traits::isPseudoInstalled( item->kind() ) )
-           cout << (item.status().isSatisfied() ? "i" : " ");
-       else
-           cout << (item.status().isInstalled() ? "i" : " ");
-
-      cout << "|" << item->kind();
-      cout << "|" << item->name();
-      cout << "|" << item->edition().version();
-      if (!item->edition().release().empty())
-        cout << "-" << item->edition().release();
-      cout << "|" << item->arch();
-      cout << endl;
-    }
-    return true;
-  }
-};
-
-
-bool printAdditionalProducts( const zypp::parser::ProductConfData & d )
-{
-  cout << str::form( "i|product|%s|%s|%s|%s|%s\n",
-                        d.name().c_str(),
-                        d.edition().c_str(),
-                        d.arch().c_str(),
-                        d.distName().c_str(),
-                        d.distEdition().c_str() );
-  return true;
-}
-
-
-static void
-query_pool( ZYpp::Ptr Z,
-           string filter,
-           const string & repository,
-           bool installed_only )
-{
-  Resolvable::Kind kind;
-
-#define FILTER_ALL "all"
-  if ( filter.empty() ) filter = FILTER_ALL;
-
-  if (filter == "packages") kind = ResKind::package;
-  else if (filter == "patches") kind = ResKind::patch;
-  else if (filter == "patterns") kind = ResKind::pattern;
-  else if (filter == "products") kind = ResKind::product;
-  else if (filter != FILTER_ALL)
-  {
-    std::cerr << "usage: zypp-query-pool [--registrable|-r] [packages|patches|patterns|products] [<alias>]" << endl;
-    exit( 1 );
-  }
-
-  MIL << "query_pool kind '" << kind << "', repository '" << repository << "'" << endl;
-
-  try
-  {
-      MIL << "Load enabled repositories..." << endl;
-      RepoManager  repoManager;
-      RepoInfoList repos = repoManager.knownRepositories();
-      for ( RepoInfoList::iterator it = repos.begin(); it != repos.end(); ++it )
-      {
-         RepoInfo & repo( *it );
-
-         if ( ! repo.enabled() )
-             continue;
-
-         MIL << "Loading " << repo << endl;
-         if ( ! repoManager.isCached( repo ) )
-         {
-             MIL << "Must build cache..." << repo << endl;
-             repoManager.buildCache( repo );
-         }
-         repoManager.loadFromCache( repo );
-      }
-      MIL << "Loaded enabled repositories." << endl;
-  }
-  catch (Exception & excpt_r)
-  {
-      ZYPP_CAUGHT( excpt_r );
-      ERR << "Couldn't restore sources" << endl;
-      exit( 1 );
-  }
-
-// add resolvables from the system
-  MIL << "Loading target..." << endl;
-  Z->target()->load();
-
-  MIL << "Loaded target." << endl;
-
-  MIL << "Pool has " << Z->pool().size() << " entries" << endl;
-
-// solve to get the status satisfied available
-  getZYpp()->resolver()->setOnlyRequires( true );
-  getZYpp()->resolver()->resolvePool();
-
-  if ( filter == FILTER_ALL)
-  {
-      PrintItem printitem( repository );
-      if (installed_only)
-         zypp::invokeOnEach( Z->pool().begin(), Z->pool().end(),                               // all kinds
-                             ByPresent(),
-                             zypp::functor::functorRef<bool,PoolItem> (printitem) );
-      else
-         zypp::invokeOnEach( Z->pool().begin(), Z->pool().end(),                               // all kinds
-                             zypp::functor::functorRef<bool,PoolItem> (printitem) );
-
-  }
-  else
-  {
-    PrintItem printitem( repository );
-    if (installed_only)
-       zypp::invokeOnEach( Z->pool().byKindBegin( kind ), Z->pool().byKindEnd( kind ), // filter kind
-                           ByPresent(),
-                           zypp::functor::functorRef<bool,PoolItem> (printitem) );
-    else
-       zypp::invokeOnEach( Z->pool().byKindBegin( kind ), Z->pool().byKindEnd( kind ), // filter kind
-                           zypp::functor::functorRef<bool,PoolItem> (printitem) );
-  }
-
-  if ( installed_only
-       && repository.empty()
-       && ( filter == FILTER_ALL || filter == "products" ) )
-  {
-    // write out additional products from /etc/zypp/products.d
-    // if -r is active and no repo filter is defined.
-    zypp::parser::ProductConfReader::scanDir( &printAdditionalProducts,
-                                              ZConfig::instance().productsPath() );
-  }
-
-  return;
-}
-
-//-----------------------------------------------------------------------------
-
-int
-main (int argc, char **argv)
-{
-  MIL << "-------------------------------------" << endl;
-  string filter;
-  string repository;
-  bool only_installed = false;
-  int offset = 1;
-
-  if ( (argc>1) && ( (string(argv[offset]) == "--registrable")
-                    || ( string(argv[offset]) == "-r" ) ) )
-  {
-      only_installed = true;
-      ++offset; --argc;
-  }
-
-  if ( argc > 1 )
-  {
-      filter = argv[offset];
-      --argc; ++offset;
-
-      if ( argc > 1 )
-      {
-         repository = argv[offset];
-         ++offset; --argc;
-      }
-  }
-
-  MIL << "START zypp-query-pool " << filter << " " << repository << endl;
-
-  zypp::zypp_readonly_hack::IWantIt();
-  ZYpp::Ptr Z = zypp::getZYpp();
-
-  KeyRingCallbacks keyring_callbacks;
-  DigestCallbacks digest_callbacks;
-
-  Z->initializeTarget( "/" );
-
-  query_pool( Z, filter, repository, only_installed );
-
-  MIL << "END zypp-query-pool, result 0" << endl;
-
-  return 0;
-}
index b8522f4..e493074 100644 (file)
@@ -1226,8 +1226,11 @@ namespace zypp
     // check for credentials in Urls
     bool havePasswords = false;
     for_( urlit, tosave.baseUrlsBegin(), tosave.baseUrlsEnd() )
-      if ( !urlit->getUsername().empty() && !urlit->getPassword().empty() )
-      { havePasswords = true; break; }
+      if ( urlit->hasCredentialsInAuthority() )
+      {
+        havePasswords = true;
+        break;
+      }
     // save the credentials
     if ( havePasswords )
     {
@@ -1235,11 +1238,11 @@ namespace zypp
           media::CredManagerOptions(_pimpl->options.rootDir) );
 
       for_(urlit, tosave.baseUrlsBegin(), tosave.baseUrlsEnd())
-        if (!urlit->getPassword().empty() && !urlit->getUsername().empty())
+        if (urlit->hasCredentialsInAuthority())
           //! \todo use a method calling UI callbacks to ask where to save creds?
           cm.saveInUser(media::AuthData(*urlit));
     }
-    
+
     HistoryLog().addRepository(tosave);
 
     progress.toMax();
@@ -1530,7 +1533,7 @@ namespace zypp
     _pimpl->services.insert( toSave );
 
     // check for credentials in Url (username:password, not ?credentials param)
-    if ( !toSave.url().getUsername().empty() && !toSave.url().getPassword().empty() )
+    if ( toSave.url().hasCredentialsInAuthority() )
     {
       media::CredentialManager cm(
           media::CredManagerOptions(_pimpl->options.rootDir) );
@@ -1662,20 +1665,8 @@ namespace zypp
         url = service.url();
       else
       {
-        // service repo can contain only one URL now, so no need to iterate
+        // service repo can contain only one URL now, so no need to iterate.
         url = *it->baseUrlsBegin();
-
-        url::ViewOption vopt;
-        vopt = vopt
-          - url::ViewOption::WITH_USERNAME
-          - url::ViewOption::WITH_PASSWORD
-          - url::ViewOption::WITH_QUERY_STR;
-
-        // use the same username as the service in case the URL starts with
-        // the service url
-        if (url.asString(vopt).find(service.url().asString(vopt)) == 0
-            && !service.url().getUsername().empty())
-          url.setUsername(service.url().getUsername());
       }
 
       // libzypp currently has problem with separate url + path handling
index 48c99b5..d3f0cec 100644 (file)
@@ -342,10 +342,10 @@ namespace zypp
     getPassword(EEncoding eflag = zypp::url::E_DECODED) const;
 
     /**
-     * Returns \c true if username or password are encoded in the authority component.
+     * Returns \c true if username \b and password are encoded in the authority component.
      */
     bool hasCredentialsInAuthority() const
-    { return ! ( getUsername().empty() && getPassword().empty() ); }
+    { return ! ( getUsername().empty() || getPassword().empty() ); }
 
     /**
      * Returns the hostname or IP from the URL authority.