aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-19 12:46:59 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-19 13:00:34 +0000
commit7e1c6abfa30aab20915696e4a9f44b23d5d97c28 (patch)
tree458ceb5849d49edad3abce7219de2c8942bcf5d7
parent39e7682513d8c24e4f415864dcd2c0ef017199ce (diff)
downloadpaludis-7e1c6abfa30aab20915696e4a9f44b23d5d97c28.tar.gz
paludis-7e1c6abfa30aab20915696e4a9f44b23d5d97c28.tar.xz
execute-resolution for pretends internally
-rw-r--r--src/clients/cave/cmd_execute_resolution.cc20
-rw-r--r--src/clients/cave/cmd_execute_resolution.hh8
-rw-r--r--src/clients/cave/resolve_common.cc99
3 files changed, 78 insertions, 49 deletions
diff --git a/src/clients/cave/cmd_execute_resolution.cc b/src/clients/cave/cmd_execute_resolution.cc
index d1359ba..3a00340 100644
--- a/src/clients/cave/cmd_execute_resolution.cc
+++ b/src/clients/cave/cmd_execute_resolution.cc
@@ -1332,7 +1332,8 @@ ExecuteResolutionCommand::important() const
int
ExecuteResolutionCommand::run(
const std::tr1::shared_ptr<Environment> & env,
- const std::tr1::shared_ptr<const Sequence<std::string > > & args
+ const std::tr1::shared_ptr<const Sequence<std::string > > & args,
+ const std::tr1::shared_ptr<const ResolverLists> & maybe_lists
)
{
ExecuteResolutionCommandLine cmdline;
@@ -1344,13 +1345,14 @@ ExecuteResolutionCommand::run(
return EXIT_SUCCESS;
}
- if (getenv_with_default("PALUDIS_SERIALISED_RESOLUTION_FD", "").empty())
- throw args::DoHelp("PALUDIS_SERIALISED_RESOLUTION_FD must be provided");
-
cmdline.import_options.apply(env);
- std::tr1::shared_ptr<ResolverLists> lists;
+ std::tr1::shared_ptr<const ResolverLists> lists(maybe_lists);
+ if (! lists)
{
+ if (getenv_with_default("PALUDIS_SERIALISED_RESOLUTION_FD", "").empty())
+ throw args::DoHelp("PALUDIS_SERIALISED_RESOLUTION_FD must be provided");
+
int fd(destringify<int>(getenv_with_default("PALUDIS_SERIALISED_RESOLUTION_FD", "")));
SafeIFStream deser_stream(fd);
const std::string deser_str((std::istreambuf_iterator<char>(deser_stream)), std::istreambuf_iterator<char>());
@@ -1362,6 +1364,14 @@ ExecuteResolutionCommand::run(
return execute_resolution(env, *lists, cmdline);
}
+int
+ExecuteResolutionCommand::run(
+ const std::tr1::shared_ptr<Environment> & env,
+ const std::tr1::shared_ptr<const Sequence<std::string > > & args)
+{
+ return run(env, args, make_null_shared_ptr());
+}
+
std::tr1::shared_ptr<args::ArgsHandler>
ExecuteResolutionCommand::make_doc_cmdline()
{
diff --git a/src/clients/cave/cmd_execute_resolution.hh b/src/clients/cave/cmd_execute_resolution.hh
index da7ca1c..51f04cf 100644
--- a/src/clients/cave/cmd_execute_resolution.hh
+++ b/src/clients/cave/cmd_execute_resolution.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 2010 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
@@ -21,6 +21,7 @@
#define PALUDIS_GUARD_SRC_CLIENTS_CAVE_CMD_EXECUTE_RESOLUTION_HH 1
#include "command.hh"
+#include <paludis/resolver/resolver_lists-fwd.hh>
namespace paludis
{
@@ -37,6 +38,11 @@ namespace paludis
const std::tr1::shared_ptr<const Sequence<std::string > > & args
);
+ int run(
+ const std::tr1::shared_ptr<Environment> &,
+ const std::tr1::shared_ptr<const Sequence<std::string > > & args,
+ const std::tr1::shared_ptr<const resolver::ResolverLists> & maybe_lists);
+
std::tr1::shared_ptr<args::ArgsHandler> make_doc_cmdline();
};
}
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 4cf4c66..42fb39a 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -21,6 +21,7 @@
#include "cmd_resolve_display_callback.hh"
#include "cmd_resolve_dump.hh"
#include "cmd_display_resolution.hh"
+#include "cmd_execute_resolution.hh"
#include "exceptions.hh"
#include "command_command_line.hh"
#include "match_qpns.hh"
@@ -1087,19 +1088,9 @@ namespace
return DisplayResolutionCommand().run(env, args, resolution_lists);
}
- void perform_resolution(
- const std::tr1::shared_ptr<Environment> &,
- const ResolverLists & resolution_lists,
- const ResolveCommandLineResolutionOptions & resolution_options,
- const ResolveCommandLineExecutionOptions & execution_options,
- const ResolveCommandLineProgramOptions & program_options,
- const std::tr1::shared_ptr<const Map<std::string, std::string> > & keys_if_import,
- const std::tr1::shared_ptr<const Sequence<std::string> > & targets,
- const bool is_set) PALUDIS_ATTRIBUTE((noreturn));
-
- void perform_resolution(
- const std::tr1::shared_ptr<Environment> &,
- const ResolverLists & resolution_lists,
+ int perform_resolution(
+ const std::tr1::shared_ptr<Environment> & env,
+ const std::tr1::shared_ptr<const ResolverLists> & resolution_lists,
const ResolveCommandLineResolutionOptions & resolution_options,
const ResolveCommandLineExecutionOptions & execution_options,
const ResolveCommandLineProgramOptions & program_options,
@@ -1109,58 +1100,80 @@ namespace
{
Context context("When performing chosen resolution:");
- StringListStream ser_stream;
- Serialiser ser(ser_stream);
- resolution_lists.serialise(ser);
-
- /* backgrounding this barfs with become_command. working out why could
- * be a fun exercise for someone with way too much time on their hands.
- * */
- ser_thread_func(ser_stream, resolution_lists);
+ std::tr1::shared_ptr<Sequence<std::string> > args(new Sequence<std::string>);
- std::string command(program_options.a_execute_resolution_program.argument());
- if (command.empty())
- command = "$CAVE execute-resolution";
+ if (is_set)
+ args->push_back("--set");
- for (args::ArgsSection::GroupsConstIterator g(execution_options.begin()), g_end(execution_options.end()) ;
+ for (args::ArgsSection::GroupsConstIterator g(program_options.begin()), g_end(program_options.end()) ;
g != g_end ; ++g)
{
for (args::ArgsGroup::ConstIterator o(g->begin()), o_end(g->end()) ;
o != o_end ; ++o)
if ((*o)->specified())
- command = command + " " + (*o)->forwardable_string();
+ {
+ const std::tr1::shared_ptr<const Sequence<std::string> > f((*o)->forwardable_args());
+ std::copy(f->begin(), f->end(), args->back_inserter());
+ }
}
- if (is_set)
- command.append(" --set");
-
- for (args::ArgsSection::GroupsConstIterator g(program_options.begin()), g_end(program_options.end()) ;
+ for (args::ArgsSection::GroupsConstIterator g(execution_options.begin()), g_end(execution_options.end()) ;
g != g_end ; ++g)
{
for (args::ArgsGroup::ConstIterator o(g->begin()), o_end(g->end()) ;
o != o_end ; ++o)
if ((*o)->specified())
- command = command + " " + (*o)->forwardable_string();
+ {
+ const std::tr1::shared_ptr<const Sequence<std::string> > f((*o)->forwardable_args());
+ std::copy(f->begin(), f->end(), args->back_inserter());
+ }
}
if (! resolution_options.a_execute.specified())
- command = command + " --pretend";
+ args->push_back("--pretend");
for (Sequence<std::string>::ConstIterator p(targets->begin()), p_end(targets->end()) ;
p != p_end ; ++p)
- command = command + " " + args::escape(*p);
+ args->push_back(*p);
+
+ if (program_options.a_execute_resolution_program.specified() || resolution_options.a_execute.specified())
+ {
+ StringListStream ser_stream;
+ Serialiser ser(ser_stream);
+ resolution_lists->serialise(ser);
+
+ /* backgrounding this barfs with become_command. working out why could
+ * be a fun exercise for someone with way too much time on their hands.
+ * */
+ ser_thread_func(ser_stream, *resolution_lists);
+
+ std::string command;
+ if (program_options.a_execute_resolution_program.specified())
+ command = program_options.a_execute_resolution_program.argument();
+ else
+ command = "$CAVE execute-resolution";
+
+ if (keys_if_import)
+ for (Map<std::string, std::string>::ConstIterator k(keys_if_import->begin()),
+ k_end(keys_if_import->end()) ;
+ k != k_end ; ++k)
+ {
+ args->push_back("--unpackaged-repository-params");
+ args->push_back(k->first + "=" + k->second);
+ }
- if (keys_if_import)
- for (Map<std::string, std::string>::ConstIterator k(keys_if_import->begin()),
- k_end(keys_if_import->end()) ;
- k != k_end ; ++k)
- command = command + " --unpackaged-repository-params '" + k->first + "=" + k->second + "'";
+ for (Sequence<std::string>::ConstIterator a(args->begin()), a_end(args->end()) ;
+ a != a_end ; ++a)
+ command = command + " " + args::escape(*a);
- paludis::Command cmd(command);
- cmd
- .with_input_stream(&ser_stream, -1, "PALUDIS_SERIALISED_RESOLUTION_FD");
+ paludis::Command cmd(command);
+ cmd
+ .with_input_stream(&ser_stream, -1, "PALUDIS_SERIALISED_RESOLUTION_FD");
- become_command(cmd);
+ become_command(cmd);
+ }
+ else
+ return ExecuteResolutionCommand().run(env, args, resolution_lists);
}
struct ChosenIDVisitor
@@ -1383,7 +1396,7 @@ paludis::cave::resolve_common(
retcode |= 1;
if (0 == retcode)
- perform_resolution(env, *resolver->lists(), resolution_options,
+ return perform_resolution(env, resolver->lists(), resolution_options,
execution_options, program_options, keys_if_import, targets, is_set);
}
catch (...)