- --repo added to install, remove, search, update, list-updates, info,
authorJan Kupec <jkupec@suse.cz>
Tue, 31 Jul 2007 17:17:48 +0000 (17:17 +0000)
committerJan Kupec <jkupec@suse.cz>
Tue, 31 Jul 2007 17:17:48 +0000 (17:17 +0000)
  patch-check, show-patches, xml-updates  (FATE #302158, #302160)

src/zypper-getopt.h
src/zypper-misc.cc
src/zypper-misc.h
src/zypper-search.cc
src/zypper-sources.cc
src/zypper-sources.h
src/zypper.cc

index 859bcf8..f97f0c5 100644 (file)
@@ -73,6 +73,8 @@ private:
   char ** _argv;
 };
 
+extern parsed_opts gopts; // global options
+extern parsed_opts copts; // command options
 
 #endif /*ZYPPER_GETOPT_H_*/
 // Local Variables:
index a2324fa..ca4d2cb 100644 (file)
@@ -16,6 +16,7 @@
 #include <zypp/target/store/xml_escape_parser.hpp>
 
 #include "zypper.h"
+#include "zypper-getopt.h"
 #include "zypper-misc.h"
 #include "zypper-callbacks.h"
 
@@ -693,7 +694,7 @@ void xml_list_patches ()
 
 // ----------------------------------------------------------------------------
 
-void list_patch_updates( const string &repo_alias, bool best_effort )
+void list_patch_updates(bool best_effort)
 {
   Table tbl;
   Table pm_tbl;        // only those that affect packagemanager: they have priority
@@ -760,21 +761,13 @@ class LookForArchUpdate : public zypp::resfilter::PoolItemFilterFunctor
 {
 public:
   PoolItem_Ref best;
-  string _repo_alias;
-
-  LookForArchUpdate( const string &repo_alias = "" )
-  {
-    _repo_alias = repo_alias;
-  }
 
   bool operator()( PoolItem_Ref provider )
     {
       if (!provider.status().isLocked()        // is not locked (taboo)
          && (!best                     // first match
              // or a better edition than candidate
-             || best->edition().compare( provider->edition() ) < 0)
-         && (_repo_alias.empty()
-             || provider->repository().info().alias() == _repo_alias) )
+             || best->edition().compare( provider->edition() ) < 0))
       {
        best = provider;        // store 
       }
@@ -790,9 +783,9 @@ public:
 // but that allows changing the arch (#222140).
 static
 PoolItem_Ref
-findArchUpdateItem( const ResPool & pool, PoolItem_Ref item, const string &repo_alias )
+findArchUpdateItem( const ResPool & pool, PoolItem_Ref item )
 {
-  LookForArchUpdate info( repo_alias );
+  LookForArchUpdate info;
 
   invokeOnEach( pool.byNameBegin( item->name() ),
                pool.byNameEnd( item->name() ),
@@ -815,7 +808,7 @@ findArchUpdateItem( const ResPool & pool, PoolItem_Ref item, const string &repo_
 typedef set<PoolItem_Ref> Candidates;
 
 static void
-find_updates( const ResObject::Kind &kind, const string &repo_alias, Candidates &candidates )
+find_updates( const ResObject::Kind &kind, Candidates &candidates )
 {
   const zypp::ResPool& pool = God->pool();
   ResPool::byKind_iterator
@@ -827,7 +820,7 @@ find_updates( const ResObject::Kind &kind, const string &repo_alias, Candidates
     if (it->status().isUninstalled())
       continue;
     // (actually similar to ProvideProcess?)
-    PoolItem_Ref candidate = findArchUpdateItem( pool, *it, repo_alias );
+    PoolItem_Ref candidate = findArchUpdateItem( pool, *it );
     if (!candidate.resolvable())
       continue;
 
@@ -839,17 +832,17 @@ find_updates( const ResObject::Kind &kind, const string &repo_alias, Candidates
 
 // ----------------------------------------------------------------------------
 
-void list_updates( const ResObject::Kind &kind, const string &repo_alias, bool best_effort )
+void list_updates( const ResObject::Kind &kind, bool best_effort )
 {
   bool k_is_patch = kind == ResTraits<Patch>::kind;
   if (k_is_patch)
-    list_patch_updates( repo_alias, best_effort );
+    list_patch_updates( best_effort );
   else {
     Table tbl;
 
     // show repo only if not best effort or --from-repo set
-    //   on best_effort, the solver will determine the repo if we don't limit it to a specific one
-    bool hide_repo = best_effort && repo_alias.empty();
+    // on best_effort, the solver will determine the repo if we don't limit it to a specific one
+    bool hide_repo = best_effort || copts.count("repo");
 
     // header
     TableHeader th;
@@ -872,7 +865,7 @@ void list_updates( const ResObject::Kind &kind, const string &repo_alias, bool b
     unsigned int cols = th.cols();
 
     Candidates candidates;
-    find_updates( kind, repo_alias, candidates );
+    find_updates( kind, candidates );
 
     Candidates::iterator cb = candidates.begin (), ce = candidates.end (), ci;
     for (ci = cb; ci != ce; ++ci) {
@@ -972,8 +965,7 @@ bool require_item_update (const PoolItem& pi) {
 void xml_list_updates()
 {
   Candidates candidates;
-  string repo_alias;
-  find_updates (ResTraits<Package>::kind, repo_alias, candidates);
+  find_updates (ResTraits<Package>::kind, candidates);
 
   Candidates::iterator cb = candidates.begin (), ce = candidates.end (), ci;
   for (ci = cb; ci != ce; ++ci) {
@@ -1002,7 +994,7 @@ void xml_list_updates()
 // ----------------------------------------------------------------------------
 
 static
-void mark_patch_updates( const std::string &repo_alias, bool skip_interactive )
+void mark_patch_updates( bool skip_interactive )
 {
   if (true) {
     // search twice: if there are none with affects_pkg_manager, retry on all
@@ -1040,16 +1032,16 @@ void mark_patch_updates( const std::string &repo_alias, bool skip_interactive )
 
 // ----------------------------------------------------------------------------
 
-void mark_updates( const ResObject::Kind &kind, const std::string &repo_alias, bool skip_interactive, bool best_effort )
+void mark_updates( const ResObject::Kind &kind, bool skip_interactive, bool best_effort )
 {
   bool k_is_patch = kind == ResTraits<Patch>::kind;
 
   if (k_is_patch) {
-    mark_patch_updates( repo_alias, skip_interactive );
+    mark_patch_updates(skip_interactive);
   }
   else {
     Candidates candidates;
-    find_updates (kind, repo_alias, candidates);
+    find_updates (kind, candidates);
     if (best_effort)
       invokeOnEach (candidates.begin(), candidates.end(), require_item_update);
     else
index 68987cf..0c783d9 100644 (file)
@@ -75,9 +75,22 @@ void patch_check();
  * if repo_alias != "", restrict updates to this repository.
  * if best_effort == true, any version greater than the installed one will do.
  * Prints the table of updates to stdout.
+ * 
+ * \param kind  resolvable type
+ * \param best_effort
+ */
+void list_updates( const zypp::ResObject::Kind &kind, bool best_effort );
+
+/**
+ * \param kind  resolvable type
+ * \param skip_interactive whether to skip updates that need user interaction
+ * \param best_effort
+ */
+void mark_updates( const zypp::ResObject::Kind &kind, bool skip_interactive, bool best_effort );
+
+/**
+ * 
  */
-void list_updates( const zypp::ResObject::Kind &kind, const std::string &repo_alias, bool best_effort );
-void mark_updates( const zypp::ResObject::Kind &kind, const std::string &repo_alias, bool skip_interactive, bool best_effort );
 void usage(int argc, char **argv);
 
 /**
index 1fe9f87..56fedb4 100644 (file)
@@ -37,9 +37,6 @@ ZyppSearch::ZyppSearch (
     ) :
     _zypp(zypp), _options(options), _qstrings(qstrings) {
 
-  cond_init_target();         // calls ZYpp::initializeTarget("/");
-  init_repos();
-
   // no repos warning
   if (gData.repos.empty()) {
     cerr << _("No repositories configured. Please, add at least one"
index 1e5c228..519e1fc 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <fstream>
 #include <boost/format.hpp>
+#include <boost/logic/tribool.hpp>
 #include <boost/lexical_cast.hpp>
 
 #include <zypp/target/store/PersistentStorage.h>
@@ -28,16 +29,39 @@ extern RuntimeData gData;
 extern Settings gSettings;
 
 
-static void do_init_repos()
+static int do_init_repos()
 {
   RepoManager manager;
-  gData.repos = manager.knownRepositories();
+
+  string specific_repo = copts.count( "repo" ) ? copts["repo"].front() : "";
+  if (!specific_repo.empty())
+  {
+    MIL << "--repo set to '" << specific_repo
+        << "'. Going to operate on this repo only." << endl;
+    try { gData.repos.push_back(manager.getRepositoryInfo(specific_repo)); }
+    catch (const repo::RepoNotFoundException & ex)
+    {
+      cerr << format(_("Repository '%s' not found.")) % specific_repo << endl;
+      ERR << specific_repo << " not found";
+      return ZYPPER_EXIT_ERR_INVALID_ARGS;
+    }
+    catch (const Exception & ex)
+    {
+      cerr << format(_("Error reading repository description file for '%s'."))
+          % specific_repo << endl;
+      cerr_v << _("Reason: ") << ex.asUserString() << endl;
+      ZYPP_CAUGHT(ex);
+      return ZYPPER_EXIT_ERR_ZYPP;
+    }
+  }
+  else
+    gData.repos = manager.knownRepositories();
 
   for (std::list<RepoInfo>::iterator it = gData.repos.begin();
        it !=  gData.repos.end(); ++it)
   {
     RepoInfo repo(*it);
-    MIL << "initializing " << repo.alias() << endl; 
+    MIL << "initializing " << repo.alias() << endl;
 
     //! \todo honor command line options/commands
     bool do_refresh = repo.enabled() && repo.autorefresh(); 
@@ -67,20 +91,22 @@ static void do_init_repos()
       }
     }
   }
+
+  return ZYPPER_EXIT_OK;
 }
 
 // ----------------------------------------------------------------------------
 
-void init_repos()
+int init_repos()
 {
   static bool done = false;
   //! \todo this has to be done so that it works in zypper shell 
   if (done)
-    return;
+    return ZYPPER_EXIT_OK;
 
   if ( !gSettings.disable_system_sources )
   {
-    do_init_repos();
+    return do_init_repos();
   }
 
   done = true;
@@ -343,7 +369,7 @@ int add_repo_by_url( const zypp::Url & url, const string & alias,
   repo.addBaseUrl(url);
   repo.setEnabled(enabled);
   repo.setAutorefresh(refresh);
-  
+
   return add_repo(repo);
 }
 
@@ -351,7 +377,7 @@ int add_repo_by_url( const zypp::Url & url, const string & alias,
 
 //! \todo handle zypp exceptions
 int add_repo_from_file(const std::string & repo_file_url,
-                       const tribool enabled, const tribool autorefresh)
+                       bool enabled, bool autorefresh)
 {
   //! \todo handle local .repo files, validate the URL
   Url url(repo_file_url);
@@ -363,14 +389,8 @@ int add_repo_from_file(const std::string & repo_file_url,
   {
     RepoInfo repo = *it;
 
-    // by default set enabled and autorefresh to true
-    repo.setEnabled(true);
-    repo.setAutorefresh(true);
-
-    if (!indeterminate(enabled))
-      repo.setEnabled(enabled);
-    if (!indeterminate(autorefresh))
-      repo.setAutorefresh(autorefresh);
+    repo.setEnabled(enabled);
+    repo.setAutorefresh(autorefresh);
 
     add_repo(repo);
   }
@@ -496,7 +516,7 @@ void rename_repo(const std::string & alias, const std::string & newalias)
 
 // ----------------------------------------------------------------------------
 
-void modify_repo(const string & alias, const parsed_opts & copts)
+void modify_repo(const string & alias)
 {
   // tell whether currenlty processed options are contradicting each other
   bool contradiction = false;
@@ -553,7 +573,7 @@ void modify_repo(const string & alias, const parsed_opts & copts)
 
     manager.modifyRepository(alias, repo);
 
-    cout_n << format(_("Repository %s has been sucessfully modified.")) % alias << endl;
+    cout << format(_("Repository %s has been sucessfully modified.")) % alias << endl;
     MIL << format("Repository %s modified:") % alias << repo << endl;
   }
   catch (const RepoNotFoundException & ex)
index 613a117..7907ee0 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef ZMART_SOURCES_H
 #define ZMART_SOURCES_H
 
-#include <boost/logic/tribool.hpp>
-
 #include "zypp/Url.h"
 
 #include "zypper-getopt.h"
@@ -10,8 +8,11 @@
 /**
  * Reads known enabled repositories and stores them in gData.
  * This command also refreshes repos with auto-refresh enabled.
+ * 
+ * \return ZYPPER_EXIT_ERR_INVALID_ARGS if --repo does not specify a valid repository,
+ *         ZYPPER_EXIT_ERR_ZYPP on error, ZYPPER_EXIT_OK otherwise.
  */
-void init_repos();
+int init_repos();
 
 /**
  * List defined repositories.
@@ -30,8 +31,8 @@ void refresh_repos();
  * \param url Valid URL of the repository.
  * \param alias
  * \param type
- * \param enabled
- * \param autorefresh
+ * \param enabled     Whether the repo should be enabled   
+ * \param autorefresh Whether the repo should have autorefresh turned on
  * \return ZYPPER_EXIT_ERR_ZYPP on unexpected zypp exception,
  *         ZYPPER_EXIT_OK otherwise
  */
@@ -41,16 +42,18 @@ int add_repo_by_url( const zypp::Url & url,
                       bool enabled = true, bool autorefresh = true );
 
 /**
- * Add repository specified in given repo file on \a repo_file_url.
+ * Add repository specified in given repo file on \a repo_file_url. All repos
+ * will be added enabled and with autorefresh turned on. The enabled and
+ * autorefresh values provided in the files will be ignored.
  * 
  * \param repo_file_url Valid URL of the repo file.
- * \param enabled       If determined, overrides repo file's enabled setting.
- * \param autorefresh   If determined, overrides repo file's autorefresh setting.
+ * \param enabled     Whether the repo should be enabled   
+ * \param autorefresh Whether the repo should have autorefresh turned on
  * \return ZYPPER_EXIT_ERR_ZYPP on unexpected zypp exception,
  *         ZYPPER_EXIT_OK otherwise
  */
 int add_repo_from_file(const std::string & repo_file_url,
-                        boost::tribool enabled = true, boost::tribool autorefresh = true);
+                        bool enabled = true, bool autorefresh = true);
 
 /**
  * If ZMD process found, notify user that ZMD is running and that changes
@@ -76,9 +79,8 @@ void rename_repo(const std::string & alias, const std::string & newalias);
  * Modify repository properties.
  * 
  * \param alias repository alias
- * \param copts pre-parsed command line options
  */
-void modify_repo(const std::string & alias, const parsed_opts & copts);
+void modify_repo(const std::string & alias);
 
 #endif
 // Local Variables:
index b57e450..de56bf8 100644 (file)
@@ -46,6 +46,8 @@ using namespace boost;
 ZYpp::Ptr God = NULL;
 RuntimeData gData;
 Settings gSettings;
+parsed_opts gopts; // global options
+parsed_opts copts; // command options
 
 ostream no_stream(NULL);
 
@@ -55,6 +57,7 @@ MediaCallbacks media_callbacks;
 KeyRingCallbacks keyring_callbacks;
 DigestCallbacks digest_callbacks;
 
+
 static struct option global_options[] = {
   {"help",            no_argument,       0, 'h'},
   {"verbose",         no_argument,       0, 'v'},
@@ -109,8 +112,6 @@ string help_commands = _(
   "\tpatch-info\t\tShow full information for patches\n"
   "");
 
-// global options
-parsed_opts gopts;
 bool ghelp = false;
 
 /*
@@ -247,7 +248,7 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
   string help_global_source_options = _(
       "  Repository options:\n"
       "\t--disable-repositories, -D\t\tDo not read data from defined repositories.\n"
-      "\t--repo <URI|.repo>\t\tRead additional repository\n"
+      "\t--plus-repo <URI|.repo>\t\tRead additional repository\n" //! \todo additional repo
       );
 //! \todo preserve for rug comp.  "\t--disable-system-sources, -D\t\tDo not read the system sources\n"
 //! \todo preserve for rug comp.  "\t--source, -S\t\tRead additional source\n"
@@ -262,7 +263,9 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
   }
   else if (command == ZypperCommand::INSTALL) {
     static struct option install_options[] = {
-      {"catalog",                  required_argument, 0, 'c'},
+      {"repo",                      required_argument, 0, 'r'},
+      // rug compatibility option, we have --repo
+      {"catalog",                   required_argument, 0, 'c'},
       {"type",                     required_argument, 0, 't'},
       {"name",                     no_argument,       0, 'n'},
       // rug compatibility, we have global --non-interactive
@@ -275,6 +278,9 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
       {0, 0, 0, 0}
     };
     specific_options = install_options;
+    // TranslatorExplanation don't translate the resolvable types
+    // (package, patch, pattern, product) or at least leave also their
+    // originals, since they are expected untranslated on the command line
     specific_help = _(
       "install [options] <capability> ...\n"
       "\n"
@@ -282,16 +288,19 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
       "            NAME[ OP <VERSION>], where OP is one of <, <=, =, >=, >.\n"
       "\n"
       "  Command options:\n"
-      "\t--catalog,-c\t\t\tOnly from this catalog (under development)\n"
-      "\t--type,-t <resolvable_type>\tType of resolvable (package, patch, pattern, product) (default: package)\n"
-      "\t--name,-n\t\t\tSelect resolvables by plain name, not by capability\n"
-      "\t--auto-agree-with-licenses,-l\tAutomatically say 'yes' to third party license confirmation prompt.\n"
-      "\t\t\t\t\tSee man zypper for more details.\n"
-      "\t--debug-solver\t\t\tCreate solver test case for debugging\n"  
+      "-r, --repo <alias>              Install resolvables only from repository specified by alias.\n"
+      "-t, --type <type>               Type of resolvable (package, patch, pattern, product) (default: package)\n"
+      "-n, --name                      Select resolvables by plain name, not by capability\n"
+      "-l, --auto-agree-with-licenses  Automatically say 'yes' to third party license confirmation prompt.\n"
+      "                                See 'man zypper' for more details.\n"
+      "    --debug-solver              Create solver test case for debugging\n"
     );
   }
   else if (command == ZypperCommand::REMOVE) {
     static struct option remove_options[] = {
+      {"repo",       required_argument, 0, 'r'},
+      // rug compatibility option, we have --repo
+      {"catalog",    required_argument, 0, 'c'},
       {"type",       required_argument, 0, 't'},
       {"name",      no_argument,       0, 'n'},
       // rug compatibility, we have global --non-interactive
@@ -308,10 +317,11 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
       "            NAME[ OP <VERSION>], where OP is one of <, <=, =, >=, >.\n"
       "\n"
       "  Command options:\n"
-      "\t--type,-t <resolvable_type>\tType of resolvable (package, patch, pattern, product) (default: package)\n"
-      "\t--name,-n\t\t\tSelect resolvables by plain name, not by capability\n"
-      "\t--debug-solver\t\t\tCreate solver test case for debugging\n"  
-      );
+      "-r, --repo <alias> Operate only with resolvables from repository specified by alias.\n"
+      "-t, --type <type>  Type of resolvable (package, patch, pattern, product) (default: package)\n"
+      "-n, --name         Select resolvables by plain name, not by capability\n"
+      "    --debug-solver Create solver test case for debugging\n"  
+    );
   }
   else if (command == ZypperCommand::ADD_REPO) {
     static struct option service_add_options[] = {
@@ -419,9 +429,11 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
   }
   else if (command == ZypperCommand::LIST_UPDATES) {
     static struct option list_updates_options[] = {
-      {"type",         required_argument, 0, 't'},
-      { "from-repo",    required_argument, 0, 0 },
-      { "best-effort",  no_argument, 0, 0 },
+      {"repo",        required_argument, 0, 'r'},
+      // rug compatibility option, we have --repo
+      {"catalog",     required_argument, 0, 'c'},
+      {"type",        required_argument, 0, 't'},
+      {"best-effort", no_argument, 0, 0 },
       {"help", no_argument, 0, 'h'},
       {0, 0, 0, 0}
     };
@@ -432,17 +444,19 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
       "List all available updates\n"
       "\n"
       "  Command options:\n"
-      "\t--type,-t <resolvable_type>\tType of resolvable (package, patch, pattern, product) (default: patch)\n"
-      "\t--from-repo <repository_alias>\tRestrict updates to named repository (default: get updates from all repositories)\n"
-      "\t--best-effort\tDo a 'best effort' approach to update, updates to a lower than latest-and-greatest version are also acceptable\n"
+      "-t, --type <type>   Type of resolvable (package, patch, pattern, product) (default: patch)\n"
+      "-r, --repo <alias>  Work only with updates from repository specified by alias.\n"
+      "    --best-effort   Do a 'best effort' approach to update, updates to a lower than latest-and-greatest version are also acceptable.\n"
       );
   }
   else if (command == ZypperCommand::UPDATE) {
     static struct option update_options[] = {
+      {"repo",                      required_argument, 0, 'r'},
+      // rug compatibility option, we have --repo
+      {"catalog",                   required_argument, 0, 'c'},
       {"type",                     required_argument, 0, 't'},
       {"skip-interactive",          no_argument,       0, 0},
       {"auto-agree-with-licenses",  no_argument,       0, 'l'},
-      {"from-repo",                 required_argument, 0, 0},
       {"best-effort",               no_argument,       0, 0},
       {"debug-solver",              no_argument,       0, 0},
       {"help", no_argument, 0, 'h'},
@@ -454,13 +468,13 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
       "\n"
       "  Command options:\n"
       "\n"
-      "\t--type,-t <resolvable_type>\tType of resolvable (package, patch, pattern, product) (default: patch)\n"
-      "\t--skip-interactive\t\tSkip interactive updates\n"
-      "\t--auto-agree-with-licenses,-l\tAutomatically say 'yes' to third party license confirmation prompt.\n"
-      "\t\t\t\t\tSee man zypper for more details.\n"
-      "\t--from-repo <repository_alias>\tRestrict updates to named repository (default: get updates from all repositories)\n"
-      "\t--best-effort\t\t\tDo a 'best effort' approach to update, updates to a lower than latest-and-greatest version are also acceptable\n"
-      "\t--debug-solver\t\t\tCreate solver test case for debugging\n"  
+      "-t, --type <type>               Type of resolvable (package, patch, pattern, product) (default: patch)\n"
+      "-r, --repo <alias>              Work only with updates from repository specified by alias.\n"
+      "    --skip-interactive          Skip interactive updates\n"
+      "-l, --auto-agree-with-licenses  Automatically say 'yes' to third party license confirmation prompt.\n"
+      "                                See man zypper for more details.\n"
+      "    --best-effort               Do a 'best effort' approach to update, updates to a lower than latest-and-greatest version are also acceptable\n"
+      "    --debug-solver              Create solver test case for debugging\n"  
     );
   }
   else if (command == ZypperCommand::SEARCH) {
@@ -476,7 +490,12 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
       {"case-sensitive", no_argument, 0, 'c'},
       {"type",    required_argument, 0, 't'},
       {"sort-by-name", no_argument, 0, 0},
+      // rug compatibility option, we have --sort-by-repo
       {"sort-by-catalog", no_argument, 0, 0},
+      {"sort-by-repo", no_argument, 0, 0},
+      // rug compatibility option, we have --repo
+      {"catalog", required_argument, 0, 'c'}, //! \todo fix conflicting 'c' short option
+      {"repo", required_argument, 0, 'r'},
       {"help", no_argument, 0, 'h'},
       {0, 0, 0, 0}
     };
@@ -497,14 +516,18 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
       "-i, --installed-only       Show only packages that are already installed.\n"
       "-u, --uninstalled-only     Show only packages that are not currently installed.\n"
       "-t, --type                 Search only for packages of the specified type.\n"
+      "-r, --repo <alias>         Search only in repository specified by alias.\n"
       "    --sort-by-name         Sort packages by name (default).\n"
-      "    --sort-by-catalog      Sort packages by catalog (source).\n"
+      "    --sort-by-repo         Sort packages by repository.\n"
       "\n"
       "* and ? wildcards can also be used within search strings.\n"
       );
   }
   else if (command == ZypperCommand::PATCH_CHECK) {
     static struct option patch_check_options[] = {
+      {"repo", required_argument, 0, 'r'},
+      // rug compatibility option, we have --repo
+      {"catalog", required_argument, 0, 'c'},
       {"help", no_argument, 0, 'h'},
       {0, 0, 0, 0}
     };
@@ -514,11 +537,16 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
       "\n"
       "Check for available patches\n"
       "\n"
-      "This command has no additional options.\n"
-      );
+      "  Command options:\n"
+      "\n"
+      "-r, --repo <alias>  Check for patches only in repository specified by alias.\n"
+    );
   }
   else if (command == ZypperCommand::SHOW_PATCHES) {
     static struct option patches_options[] = {
+      {"repo", required_argument, 0, 'r'},
+      // rug compatibility option, we have --repo
+      {"catalog", required_argument, 0, 'c'},
       {"help", no_argument, 0, 'h'},
       {0, 0, 0, 0}
     };
@@ -528,11 +556,16 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
       "\n"
       "List all available patches\n"
       "\n"
-      "This command has no additional options.\n"
-      );
+      "  Command options:\n"
+      "\n"
+      "-r, --repo <alias>  Check for patches only in repository specified by alias.\n"
+    );
   }
   else if (command == ZypperCommand::INFO) {
     static struct option info_options[] = {
+      {"repo", required_argument, 0, 'r'},
+      // rug compatibility option, we have --repo
+      {"catalog", required_argument, 0, 'c'},
       {"help", no_argument, 0, 'h'},
       {0, 0, 0, 0}
     };
@@ -542,11 +575,15 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
       "\n"
       "'info' -- Show full information for packages\n"
       "\n"
-      "This command has no additional options.\n"
-      );
+      "  Command options:\n"
+      "\n"
+      "-r, --repo <alias>  Work only with the repository specified by alias.\n"
+    );
   }
+  // rug compatibility command, we have zypper info [-t <res_type>]
   else if (command == ZypperCommand::RUG_PATCH_INFO) {
     static struct option patch_info_options[] = {
+      {"catalog", required_argument, 0, 'c'},
       {"help", no_argument, 0, 'h'},
       {0, 0, 0, 0}
     };
@@ -556,8 +593,8 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
       "\n"
       "'patch-info' -- Show detailed information for patches\n"
       "\n"
-      "This command has no additional options.\n"
-      );
+      "This is a rug compatibility alias for 'zypper info -t patch'\n"
+    );
   }
   else if (command == ZypperCommand::MOO) {
     static struct option moo_options[] = {
@@ -575,6 +612,7 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
   }
   else if (command == ZypperCommand::XML_LIST_UPDATES_PATCHES) {
     static struct option xml_updates_options[] = {
+      {"repo", required_argument, 0, 'r'},
       {"help", no_argument, 0, 'h'},
       {0, 0, 0, 0}
     };
@@ -584,11 +622,13 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
       "\n"
       "'xml-updates' - Show updates and patches in xml format\n"
       "\n"
-      "This command has no additional options.\n"
+      "  Command options:\n"
+      "-r, --repo <alias>  Work only with updates from repository specified by alias.\n"
     );
   }
 
-  parsed_opts copts = parse_options (argc, argv, specific_options);
+  // parse command options
+  copts = parse_options (argc, argv, specific_options);
   if (copts.count("_unknown"))
     return ZYPPER_EXIT_ERR_SYNTAX;
 
@@ -891,7 +931,7 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
       return ZYPPER_EXIT_ERR_INVALID_ARGS;
     }
 
-    modify_repo(arguments[0], copts);
+    modify_repo(arguments[0]);
   }
 
   // --------------------------( refresh )------------------------------------
@@ -961,7 +1001,9 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
       return ZYPPER_EXIT_ERR_INVALID_ARGS;
     }
 
-    init_repos();
+    int initret = init_repos();
+    if (initret != ZYPPER_EXIT_OK)
+      return initret;
 
     //! \todo support temporary additional repos
     /*
@@ -1047,6 +1089,11 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
 
     options.resolveConflicts();
 
+    int initret = init_repos();
+    if (initret != ZYPPER_EXIT_OK)
+      return initret;
+    cond_init_target();         // calls ZYpp::initializeTarget("/");
+
     Table t;
     t.style(Ascii);
 
@@ -1054,8 +1101,9 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
     search.doSearch(FillTable(t, search.installedCache()));
 
     if (t.empty())
-      cout_n << _("No resolvables found.") << endl;
+      cout << _("No resolvables found.") << endl;
     else {
+      cout << endl;
       if (copts.count("sort-by-catalog")) t.sort(1);
       else t.sort(3); // sort by name
       cout << t;
@@ -1074,7 +1122,11 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
     }
 
     cond_init_target ();
-    init_repos ();
+
+    int initret = init_repos();
+    if (initret != ZYPPER_EXIT_OK)
+      return initret;
+
     // TODO additional_sources
     // TODO warn_no_sources
     // TODO calc token?
@@ -1101,7 +1153,9 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
     }
 
     cond_init_target ();
-    init_repos ();
+    int initret = init_repos();
+    if (initret != ZYPPER_EXIT_OK)
+      return initret;
     cond_load_resolvables();
     establish ();
     show_patches ();
@@ -1125,7 +1179,6 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
        return ZYPPER_EXIT_ERR_INVALID_ARGS;
     }
 
-    string srepo = copts.count( "from-repo" ) ? copts["from-repo"].front() : "";
     bool best_effort = copts.count( "best-effort" ); 
 
     if (gSettings.is_rug_compatible && best_effort) {
@@ -1135,11 +1188,13 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
        cerr << _("Running as 'rug', can't do 'best-effort' approach to update.") << endl;
     }
     cond_init_target ();
-    init_repos ();
+    int initret = init_repos();
+    if (initret != ZYPPER_EXIT_OK)
+      return initret;
     cond_load_resolvables();
     establish ();
 
-    list_updates( kind, srepo, best_effort );
+    list_updates( kind, best_effort );
 
     return ZYPPER_EXIT_OK;
   }
@@ -1152,7 +1207,9 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
     if (ghelp) { cout << specific_help << endl; return !ghelp; }
 
     cond_init_target ();
-    init_repos ();
+    int initret = init_repos();
+    if (initret != ZYPPER_EXIT_OK)
+      return initret;
     cond_load_resolvables();
     establish ();
 
@@ -1195,7 +1252,6 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
        return ZYPPER_EXIT_ERR_INVALID_ARGS;
     }
 
-    string srepo = copts.count( "from-repo" ) ? copts["from-repo"].front() : "";
     bool best_effort = copts.count( "best-effort" ); 
 
     if (gSettings.is_rug_compatible && best_effort) {
@@ -1205,12 +1261,14 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
        cerr << _("Running as 'rug', can't do 'best-effort' approach to update.") << endl;
     }
     cond_init_target ();
-    init_repos ();
+    int initret = init_repos();
+    if (initret != ZYPPER_EXIT_OK)
+      return initret;
     cond_load_resolvables ();
     establish ();
 
     bool skip_interactive = copts.count("skip-interactive") || gSettings.non_interactive;
-    mark_updates( kind, srepo, skip_interactive, best_effort );
+    mark_updates( kind, skip_interactive, best_effort );
 
 
     if (copts.count("debug-solver"))
@@ -1240,7 +1298,9 @@ int one_command(const ZypperCommand & command, int argc, char **argv)
     }
 
     cond_init_target ();
-    init_repos ();
+    int initret = init_repos();
+    if (initret != ZYPPER_EXIT_OK)
+      return initret;
     cond_load_resolvables ();
     establish ();