aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-07-30 14:21:18 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-07-30 14:21:18 +0100
commit84fdbf9be567f94bbed02ad285904c95fd6888b2 (patch)
tree3640e3dc9a2da75ade2aa03cebae00aea47b4686
parent644e2a37971f0b93249162379b173346181104ea (diff)
downloadpaludis-84fdbf9be567f94bbed02ad285904c95fd6888b2.tar.gz
paludis-84fdbf9be567f94bbed02ad285904c95fd6888b2.tar.xz
cave execute-resolution --fetch defaults to -J0
Fixes: ticket:945
-rw-r--r--src/clients/cave/cmd_execute_resolution.cc58
-rw-r--r--src/clients/cave/cmd_resolve_cmdline.cc4
2 files changed, 41 insertions, 21 deletions
diff --git a/src/clients/cave/cmd_execute_resolution.cc b/src/clients/cave/cmd_execute_resolution.cc
index 531f519..1501ba5 100644
--- a/src/clients/cave/cmd_execute_resolution.cc
+++ b/src/clients/cave/cmd_execute_resolution.cc
@@ -281,6 +281,7 @@ namespace
bool do_fetch(
const std::shared_ptr<Environment> & env,
const ExecuteResolutionCommandLine & cmdline,
+ const int n_fetch_jobs,
const PackageDepSpec & id_spec,
const int x, const int y, bool normal_only,
Mutex & job_mutex,
@@ -296,7 +297,7 @@ namespace
command = "$CAVE perform";
command.append(" fetch --hooks --if-supported --managed-output ");
- if (cmdline.execution_options.a_fetch_jobs.argument() != 0)
+ if (0 != n_fetch_jobs)
command.append("--output-exclusivity with-others --no-terminal-titles ");
command.append(stringify(id->uniquely_identifying_spec()));
command.append(" --x-of-y '" + stringify(x) + " of " + stringify(y) + "'");
@@ -354,6 +355,7 @@ namespace
bool do_install(
const std::shared_ptr<Environment> & env,
const ExecuteResolutionCommandLine & cmdline,
+ const int n_fetch_jobs,
const PackageDepSpec & id_spec,
const RepositoryName & destination_repository_name,
const std::shared_ptr<const Sequence<PackageDepSpec> > & replacing_specs,
@@ -372,7 +374,7 @@ namespace
command = "$CAVE perform";
command.append(" install --hooks --managed-output ");
- if (cmdline.execution_options.a_fetch_jobs.argument() != 0)
+ if (0 != n_fetch_jobs)
command.append("--output-exclusivity with-others ");
command.append(stringify(id->uniquely_identifying_spec()));
command.append(" --destination " + stringify(destination_repository_name));
@@ -433,6 +435,7 @@ namespace
bool do_uninstall(
const std::shared_ptr<Environment> & env,
const ExecuteResolutionCommandLine & cmdline,
+ const int n_fetch_jobs,
const PackageDepSpec & id_spec,
const int x, const int y,
Mutex & job_mutex,
@@ -448,7 +451,7 @@ namespace
command = "$CAVE perform";
command.append(" uninstall --hooks --managed-output ");
- if (cmdline.execution_options.a_fetch_jobs.argument() != 0)
+ if (0 != n_fetch_jobs)
command.append("--output-exclusivity with-others ");
command.append(stringify(id->uniquely_identifying_spec()));
@@ -689,6 +692,7 @@ namespace
{
const std::shared_ptr<Environment> env;
const ExecuteResolutionCommandLine & cmdline;
+ const int n_fetch_jobs;
ExecuteCounts & counts;
Mutex & job_mutex;
const ExecuteOneVisitorPart part;
@@ -697,12 +701,14 @@ namespace
ExecuteOneVisitor(
const std::shared_ptr<Environment> & e,
const ExecuteResolutionCommandLine & c,
+ const int n,
ExecuteCounts & k,
Mutex & m,
ExecuteOneVisitorPart p,
int r) :
env(e),
cmdline(c),
+ n_fetch_jobs(n),
counts(k),
job_mutex(m),
part(p),
@@ -752,7 +758,7 @@ namespace
install_item.set_state(active_state);
}
- if (! do_fetch(env, cmdline, install_item.origin_id_spec(), counts.x_installs, counts.y_installs, false,
+ if (! do_fetch(env, cmdline, n_fetch_jobs, install_item.origin_id_spec(), counts.x_installs, counts.y_installs, false,
job_mutex, *active_state))
{
Lock lock(job_mutex);
@@ -760,7 +766,7 @@ namespace
return 1;
}
- if (! do_install(env, cmdline, install_item.origin_id_spec(), install_item.destination_repository_name(),
+ if (! do_install(env, cmdline, n_fetch_jobs, install_item.origin_id_spec(), install_item.destination_repository_name(),
install_item.replacing_specs(), destination_string,
counts.x_installs, counts.y_installs, job_mutex, *active_state))
{
@@ -814,7 +820,7 @@ namespace
for (Sequence<PackageDepSpec>::ConstIterator i(uninstall_item.ids_to_remove_specs()->begin()),
i_end(uninstall_item.ids_to_remove_specs()->end()) ;
i != i_end ; ++i)
- if (! do_uninstall(env, cmdline, *i, counts.x_installs, counts.y_installs, job_mutex, *active_state))
+ if (! do_uninstall(env, cmdline, n_fetch_jobs, *i, counts.x_installs, counts.y_installs, job_mutex, *active_state))
{
Lock lock(job_mutex);
uninstall_item.set_state(active_state->failed());
@@ -856,7 +862,7 @@ namespace
fetch_item.set_state(active_state);
}
- if (! do_fetch(env, cmdline, fetch_item.origin_id_spec(), counts.x_fetches, counts.y_fetches, true,
+ if (! do_fetch(env, cmdline, n_fetch_jobs, fetch_item.origin_id_spec(), counts.x_fetches, counts.y_fetches, true,
job_mutex, *active_state))
{
Lock lock(job_mutex);
@@ -1099,6 +1105,7 @@ namespace
{
const std::shared_ptr<Environment> env;
const ExecuteResolutionCommandLine & cmdline;
+ const int n_fetch_jobs;
const std::shared_ptr<ExecuteJob> job;
const std::shared_ptr<const JobLists> lists;
JobRequirementIf require_if;
@@ -1117,6 +1124,7 @@ namespace
ExecuteJobExecutive(
const std::shared_ptr<Environment> & e,
const ExecuteResolutionCommandLine & c,
+ const int n,
const std::shared_ptr<ExecuteJob> & j,
const std::shared_ptr<const JobLists> & l,
JobRequirementIf r,
@@ -1126,6 +1134,7 @@ namespace
std::string & h) :
env(e),
cmdline(c),
+ n_fetch_jobs(n),
job(j),
lists(l),
require_if(r),
@@ -1143,7 +1152,7 @@ namespace
std::string queue_name() const
{
- if (cmdline.execution_options.a_fetch_jobs.argument() != 0)
+ if (0 != n_fetch_jobs)
return simple_visitor_cast<const FetchJob>(*job) ? "fetch" : "execute";
else
return "execute";
@@ -1231,7 +1240,7 @@ namespace
if (want)
{
- ExecuteOneVisitor execute(env, cmdline, counts, job_mutex, x1_pre, local_retcode);
+ ExecuteOneVisitor execute(env, cmdline, n_fetch_jobs, counts, job_mutex, x1_pre, local_retcode);
int job_retcode(job->accept_returning<int>(execute));
local_retcode |= job_retcode;
}
@@ -1241,7 +1250,7 @@ namespace
{
if (want)
{
- ExecuteOneVisitor execute(env, cmdline, counts, job_mutex, x1_main, local_retcode);
+ ExecuteOneVisitor execute(env, cmdline, n_fetch_jobs, counts, job_mutex, x1_main, local_retcode);
int job_retcode(job->accept_returning<int>(execute));
local_retcode |= job_retcode;
}
@@ -1254,7 +1263,7 @@ namespace
void display_active()
{
- if (cmdline.execution_options.a_fetch_jobs.argument() == 0)
+ if (n_fetch_jobs == 0)
return;
Lock lock(job_mutex);
@@ -1308,7 +1317,7 @@ namespace
{
if (want)
{
- ExecuteOneVisitor execute(env, cmdline, counts, job_mutex, x1_post, local_retcode);
+ ExecuteOneVisitor execute(env, cmdline, n_fetch_jobs, counts, job_mutex, x1_post, local_retcode);
local_retcode |= job->accept_returning<int>(execute);
Lock lock(job_mutex);
@@ -1333,7 +1342,8 @@ namespace
int execute_executions(
const std::shared_ptr<Environment> & env,
const std::shared_ptr<JobLists> & lists,
- const ExecuteResolutionCommandLine & cmdline)
+ const ExecuteResolutionCommandLine & cmdline,
+ const int n_fetch_jobs)
{
int retcode(0);
Mutex retcode_mutex;
@@ -1369,7 +1379,7 @@ namespace
for (JobList<ExecuteJob>::ConstIterator c(lists->execute_job_list()->begin()),
c_end(lists->execute_job_list()->end()) ;
c != c_end ; ++c)
- executor.add(std::make_shared<ExecuteJobExecutive>(env, cmdline, *c, lists, require_if, retcode_mutex,
+ executor.add(std::make_shared<ExecuteJobExecutive>(env, cmdline, n_fetch_jobs, *c, lists, require_if, retcode_mutex,
retcode, counts, old_heading));
executor.execute();
@@ -1385,7 +1395,8 @@ namespace
int execute_resolution_main(
const std::shared_ptr<Environment> & env,
const std::shared_ptr<JobLists> & lists,
- const ExecuteResolutionCommandLine & cmdline)
+ const ExecuteResolutionCommandLine & cmdline,
+ const int n_fetch_jobs)
{
for (JobList<ExecuteJob>::ConstIterator c(lists->execute_job_list()->begin()),
c_end(lists->execute_job_list()->end()) ;
@@ -1399,7 +1410,7 @@ namespace
if (0 != retcode || cmdline.a_pretend.specified())
return retcode;
- retcode |= execute_executions(env, lists, cmdline);
+ retcode |= execute_executions(env, lists, cmdline, n_fetch_jobs);
if (0 != retcode)
return retcode;
@@ -1596,7 +1607,8 @@ namespace
int execute_resolution(
const std::shared_ptr<Environment> & env,
const std::shared_ptr<JobLists> & lists,
- const ExecuteResolutionCommandLine & cmdline)
+ const ExecuteResolutionCommandLine & cmdline,
+ const int n_fetch_jobs)
{
Context context("When executing chosen resolution:");
@@ -1608,7 +1620,7 @@ namespace
try
{
- retcode = execute_resolution_main(env, lists, cmdline);
+ retcode = execute_resolution_main(env, lists, cmdline, n_fetch_jobs);
}
catch (...)
{
@@ -1682,7 +1694,15 @@ ExecuteResolutionCommand::run(
close(fd);
}
- return execute_resolution(env, lists, cmdline);
+ int n_fetch_jobs;
+ if (cmdline.execution_options.a_fetch_jobs.specified())
+ n_fetch_jobs = cmdline.execution_options.a_fetch_jobs.argument();
+ else if (cmdline.execution_options.a_fetch.specified())
+ n_fetch_jobs = 0;
+ else
+ n_fetch_jobs = 1;
+
+ return execute_resolution(env, lists, cmdline, n_fetch_jobs);
}
int
diff --git a/src/clients/cave/cmd_resolve_cmdline.cc b/src/clients/cave/cmd_resolve_cmdline.cc
index 5307962..c1438c2 100644
--- a/src/clients/cave/cmd_resolve_cmdline.cc
+++ b/src/clients/cave/cmd_resolve_cmdline.cc
@@ -315,7 +315,7 @@ ResolveCommandLineExecutionOptions::ResolveCommandLineExecutionOptions(args::Arg
"--continue-on-failure if any of the packages to be merged have fetch dependencies.", true),
a_fetch_jobs(&g_jobs_options, "fetch-jobs", 'J', "The number of parallel fetch jobs to launch. If set to 0, fetches "
"will be carried out sequentially with other jobs. Values higher than 1 are currently treated "
- "as being 1. Defaults to 1."),
+ "as being 1. Defaults to 1, or if --fetch is specified, 0."),
g_phase_options(this, "Phase Options", "Options controlling which phases to execute. No sanity checking "
"is done, allowing you to shoot as many feet off as you desire. Phase names do not have the "
@@ -331,7 +331,7 @@ ResolveCommandLineExecutionOptions::ResolveCommandLineExecutionOptions(args::Arg
("last", "Only the last package on the list"),
"all")
{
- a_fetch_jobs.set_argument(1);
+ a_fetch_jobs.set_argument(-1);
}
ResolveCommandLineProgramOptions::ResolveCommandLineProgramOptions(args::ArgsHandler * const h) :