aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-02-14 18:13:34 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-02-14 18:13:34 +0000
commit3a6bcd7033c526aca5d2e6d94b5cf688c11013e6 (patch)
tree489727c42f4cda0479e36703aa67fb24821e2333
parent1159e9fd770b98a8aa2cd2e505ef7fc8f899390c (diff)
downloadpaludis-3a6bcd7033c526aca5d2e6d94b5cf688c11013e6.tar.gz
paludis-3a6bcd7033c526aca5d2e6d94b5cf688c11013e6.tar.xz
Don't stop searching after a broken package
-rw-r--r--src/clients/cave/cmd_find_candidates.cc70
-rw-r--r--src/clients/cave/cmd_find_candidates.hh6
-rw-r--r--src/clients/cave/cmd_search.cc6
3 files changed, 49 insertions, 33 deletions
diff --git a/src/clients/cave/cmd_find_candidates.cc b/src/clients/cave/cmd_find_candidates.cc
index e0346a1..e5e0057 100644
--- a/src/clients/cave/cmd_find_candidates.cc
+++ b/src/clients/cave/cmd_find_candidates.cc
@@ -141,17 +141,15 @@ FindCandidatesCommand::run(
if (cmdline.begin_parameters() != cmdline.end_parameters())
throw args::DoHelp("find-candidates takes no parameters");
- run_hosted(env, cmdline.search_options, cmdline.match_options, cmdline.index_options,
+ return run_hosted(env, cmdline.search_options, cmdline.match_options, cmdline.index_options,
cmdline.a_name_description_substring_hint.argument(), &print_spec, &no_step);
-
- return EXIT_SUCCESS;
}
typedef std::set<RepositoryName> RepositoryNames;
typedef std::set<CategoryNamePart> CategoryNames;
typedef std::set<QualifiedPackageName> QualifiedPackageNames;
-void
+int
FindCandidatesCommand::run_hosted(
const std::shared_ptr<Environment> & env,
const SearchCommandLineCandidateOptions & search_options,
@@ -161,6 +159,8 @@ FindCandidatesCommand::run_hosted(
const std::function<void (const PackageDepSpec &)> & yield,
const std::function<void (const std::string &)> & step)
{
+ int retcode(0);
+
if (index_options.a_index.specified())
{
step("Searching index");
@@ -247,39 +247,51 @@ FindCandidatesCommand::run_hosted(
for (QualifiedPackageNames::const_iterator q(package_names.begin()), q_end(package_names.end()) ;
q != q_end ; ++q)
{
- if (search_options.a_all_versions.specified())
+ try
{
- if (search_options.a_visible.specified())
+ if (search_options.a_all_versions.specified())
{
- const auto ids((*env)[selection::AllVersionsUnsorted(generator::Package(*q) | filter::NotMasked())]);
- check_candidates(yield, step, ids);
+ if (search_options.a_visible.specified())
+ {
+ const auto ids((*env)[selection::AllVersionsUnsorted(generator::Package(*q) | filter::NotMasked())]);
+ check_candidates(yield, step, ids);
+ }
+ else
+ {
+ const auto ids((*env)[selection::AllVersionsUnsorted(generator::Package(*q))]);
+ check_candidates(yield, step, ids);
+ }
}
else
{
- const auto ids((*env)[selection::AllVersionsUnsorted(generator::Package(*q))]);
+ std::shared_ptr<const PackageIDSequence> ids;
+
+ ids = ((*env)[selection::BestVersionOnly(generator::Package(*q) | filter::SupportsAction<InstallAction>() | filter::NotMasked())]);
+
+ if (search_options.a_visible.specified())
+ {
+ if (ids->empty())
+ ids = ((*env)[selection::BestVersionOnly(generator::Package(*q) | filter::NotMasked())]);
+ }
+ else
+ {
+ if (ids->empty())
+ ids = ((*env)[selection::BestVersionOnly(generator::Package(*q) | filter::SupportsAction<InstallAction>())]);
+ if (ids->empty())
+ ids = ((*env)[selection::BestVersionOnly(generator::Package(*q))]);
+ }
+
check_candidates(yield, step, ids);
}
}
- else
+ catch (const InternalError &)
{
- std::shared_ptr<const PackageIDSequence> ids;
-
- ids = ((*env)[selection::BestVersionOnly(generator::Package(*q) | filter::SupportsAction<InstallAction>() | filter::NotMasked())]);
-
- if (search_options.a_visible.specified())
- {
- if (ids->empty())
- ids = ((*env)[selection::BestVersionOnly(generator::Package(*q) | filter::NotMasked())]);
- }
- else
- {
- if (ids->empty())
- ids = ((*env)[selection::BestVersionOnly(generator::Package(*q) | filter::SupportsAction<InstallAction>())]);
- if (ids->empty())
- ids = ((*env)[selection::BestVersionOnly(generator::Package(*q))]);
- }
-
- check_candidates(yield, step, ids);
+ throw;
+ }
+ catch (const Exception & e)
+ {
+ std::cerr << "When processing '" << *q << "' got exception '" << e.message() << "' (" << e.what() << ")" << std::endl;
+ retcode |= 1;
}
}
}
@@ -320,6 +332,8 @@ FindCandidatesCommand::run_hosted(
check_candidates(yield, step, ids);
}
}
+
+ return retcode;
}
std::shared_ptr<args::ArgsHandler>
diff --git a/src/clients/cave/cmd_find_candidates.hh b/src/clients/cave/cmd_find_candidates.hh
index 5929c70..382c6be 100644
--- a/src/clients/cave/cmd_find_candidates.hh
+++ b/src/clients/cave/cmd_find_candidates.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2010 Ciaran McCreesh
+ * Copyright (c) 2010, 2011 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -39,14 +39,14 @@ namespace paludis
const std::shared_ptr<const Sequence<std::string > > & args
);
- void run_hosted(
+ int run_hosted(
const std::shared_ptr<Environment> &,
const SearchCommandLineCandidateOptions &,
const SearchCommandLineMatchOptions &,
const SearchCommandLineIndexOptions &,
const std::string &,
const std::function<void (const PackageDepSpec &)> &,
- const std::function<void (const std::string &)> &);
+ const std::function<void (const std::string &)> &) PALUDIS_ATTRIBUTE((warn_unused_result));
std::shared_ptr<args::ArgsHandler> make_doc_cmdline();
};
diff --git a/src/clients/cave/cmd_search.cc b/src/clients/cave/cmd_search.cc
index de06f76..dd8476d 100644
--- a/src/clients/cave/cmd_search.cc
+++ b/src/clients/cave/cmd_search.cc
@@ -278,6 +278,8 @@ SearchCommand::run(
if (cmdline.begin_parameters() == cmdline.end_parameters())
throw args::DoHelp("search requires at least one parameter");
+ int retcode(0);
+
const std::shared_ptr<Sequence<std::string> > show_args(std::make_shared<Sequence<std::string>>());
std::string name_description_substring_hint;
@@ -311,7 +313,7 @@ SearchCommand::run(
MatchCommand match_command;
std::shared_ptr<Set<QualifiedPackageName> > matches(std::make_shared<Set<QualifiedPackageName>>());
- find_candidates_command.run_hosted(env, cmdline.search_options, cmdline.match_options,
+ retcode |= find_candidates_command.run_hosted(env, cmdline.search_options, cmdline.match_options,
cmdline.index_options, name_description_substring_hint, std::bind(
&found_candidate, env, std::ref(match_command), std::cref(cmdline.match_options),
std::placeholders::_1, patterns, std::function<void (const PackageDepSpec &)>(std::bind(
@@ -346,7 +348,7 @@ SearchCommand::run(
show_args->push_back("--description-keys");
ShowCommand show_command;
- return show_command.run(env, show_args);
+ return show_command.run(env, show_args) | retcode;
}
std::shared_ptr<args::ArgsHandler>