#include <zypp/target/store/xml_escape_parser.hpp>
#include "zypper.h"
+#include "zypper-getopt.h"
#include "zypper-misc.h"
#include "zypper-callbacks.h"
// ----------------------------------------------------------------------------
-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
{
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
}
// 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() ),
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
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;
// ----------------------------------------------------------------------------
-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;
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) {
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) {
// ----------------------------------------------------------------------------
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
// ----------------------------------------------------------------------------
-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
ZYpp::Ptr God = NULL;
RuntimeData gData;
Settings gSettings;
+parsed_opts gopts; // global options
+parsed_opts copts; // command options
ostream no_stream(NULL);
KeyRingCallbacks keyring_callbacks;
DigestCallbacks digest_callbacks;
+
static struct option global_options[] = {
{"help", no_argument, 0, 'h'},
{"verbose", no_argument, 0, 'v'},
"\tpatch-info\t\tShow full information for patches\n"
"");
-// global options
-parsed_opts gopts;
bool ghelp = false;
/*
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"
}
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
{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"
" 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
" 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[] = {
}
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}
};
"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'},
"\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) {
{"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}
};
"-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}
};
"\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}
};
"\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}
};
"\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}
};
"\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[] = {
}
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}
};
"\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;
return ZYPPER_EXIT_ERR_INVALID_ARGS;
}
- modify_repo(arguments[0], copts);
+ modify_repo(arguments[0]);
}
// --------------------------( refresh )------------------------------------
return ZYPPER_EXIT_ERR_INVALID_ARGS;
}
- init_repos();
+ int initret = init_repos();
+ if (initret != ZYPPER_EXIT_OK)
+ return initret;
//! \todo support temporary additional repos
/*
options.resolveConflicts();
+ int initret = init_repos();
+ if (initret != ZYPPER_EXIT_OK)
+ return initret;
+ cond_init_target(); // calls ZYpp::initializeTarget("/");
+
Table t;
t.style(Ascii);
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;
}
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?
}
cond_init_target ();
- init_repos ();
+ int initret = init_repos();
+ if (initret != ZYPPER_EXIT_OK)
+ return initret;
cond_load_resolvables();
establish ();
show_patches ();
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) {
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;
}
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 ();
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) {
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"))
}
cond_init_target ();
- init_repos ();
+ int initret = init_repos();
+ if (initret != ZYPPER_EXIT_OK)
+ return initret;
cond_load_resolvables ();
establish ();