aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-19 12:04:14 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-19 12:04:14 +0000
commit39e7682513d8c24e4f415864dcd2c0ef017199ce (patch)
tree6fe8162d77160372f83dd310c80dd8f053e6a718
parent605084e3a31f384b828d2641a9eb3f62eaa172a8 (diff)
downloadpaludis-39e7682513d8c24e4f415864dcd2c0ef017199ce.tar.gz
paludis-39e7682513d8c24e4f415864dcd2c0ef017199ce.tar.xz
display-resolution internally
-rw-r--r--src/clients/cave/cmd_display_resolution.cc20
-rw-r--r--src/clients/cave/cmd_display_resolution.hh9
-rw-r--r--src/clients/cave/resolve_common.cc52
3 files changed, 57 insertions, 24 deletions
diff --git a/src/clients/cave/cmd_display_resolution.cc b/src/clients/cave/cmd_display_resolution.cc
index 53b224c..e25c83a 100644
--- a/src/clients/cave/cmd_display_resolution.cc
+++ b/src/clients/cave/cmd_display_resolution.cc
@@ -942,7 +942,8 @@ DisplayResolutionCommand::important() const
int
DisplayResolutionCommand::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
)
{
DisplayResolutionCommandLine cmdline;
@@ -954,13 +955,14 @@ DisplayResolutionCommand::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>());
@@ -977,6 +979,14 @@ DisplayResolutionCommand::run(
return 0;
}
+int
+DisplayResolutionCommand::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>
DisplayResolutionCommand::make_doc_cmdline()
{
diff --git a/src/clients/cave/cmd_display_resolution.hh b/src/clients/cave/cmd_display_resolution.hh
index 4d6c3be..6f01f7f 100644
--- a/src/clients/cave/cmd_display_resolution.hh
+++ b/src/clients/cave/cmd_display_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_DISPLAY_RESOLUTION_HH 1
#include "command.hh"
+#include <paludis/resolver/resolver_lists-fwd.hh>
namespace paludis
{
@@ -37,6 +38,12 @@ 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 a6fded9..4cf4c66 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -20,6 +20,7 @@
#include "resolve_common.hh"
#include "cmd_resolve_display_callback.hh"
#include "cmd_resolve_dump.hh"
+#include "cmd_display_resolution.hh"
#include "exceptions.hh"
#include "command_command_line.hh"
#include "match_qpns.hh"
@@ -1026,8 +1027,8 @@ namespace
}
int display_resolution(
- const std::tr1::shared_ptr<Environment> &,
- const ResolverLists & resolution_lists,
+ const std::tr1::shared_ptr<Environment> & env,
+ const std::tr1::shared_ptr<const ResolverLists> & resolution_lists,
const ResolveCommandLineResolutionOptions &,
const ResolveCommandLineDisplayOptions & display_options,
const ResolveCommandLineProgramOptions & program_options,
@@ -1039,11 +1040,9 @@ namespace
StringListStream ser_stream;
Thread ser_thread(std::tr1::bind(&ser_thread_func,
std::tr1::ref(ser_stream),
- std::tr1::cref(resolution_lists)));
+ std::tr1::cref(*resolution_lists)));
- std::string command(program_options.a_display_resolution_program.argument());
- if (command.empty())
- command = "$CAVE display-resolution";
+ std::tr1::shared_ptr<Sequence<std::string> > args(new Sequence<std::string>);
for (args::ArgsSection::GroupsConstIterator g(display_options.begin()), g_end(display_options.end()) ;
g != g_end ; ++g)
@@ -1051,24 +1050,41 @@ namespace
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());
+ }
}
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 (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 + "'";
+ if (program_options.a_display_resolution_program.specified())
+ {
+ std::string command(program_options.a_display_resolution_program.argument());
- paludis::Command cmd(command);
- cmd
- .with_input_stream(&ser_stream, -1, "PALUDIS_SERIALISED_RESOLUTION_FD");
+ 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);
+ }
+
+ for (Sequence<std::string>::ConstIterator a(args->begin()), a_end(args->end()) ;
+ a != a_end ; ++a)
+ command = command + " " + args::escape(*a);
- return run_command(cmd);
+ paludis::Command cmd(command);
+ cmd
+ .with_input_stream(&ser_stream, -1, "PALUDIS_SERIALISED_RESOLUTION_FD");
+
+ return run_command(cmd);
+ }
+ else
+ return DisplayResolutionCommand().run(env, args, resolution_lists);
}
void perform_resolution(
@@ -1360,7 +1376,7 @@ paludis::cave::resolve_common(
dump_if_requested(env, resolver, resolution_options);
- retcode |= display_resolution(env, *resolver->lists(), resolution_options,
+ retcode |= display_resolution(env, resolver->lists(), resolution_options,
display_options, program_options, keys_if_import, targets);
if (! resolver->lists()->taken_error_job_ids()->empty())