aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-09-03 19:47:10 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-09-04 23:50:43 +0100
commit1a300a6eec57dca2807f98071d2c5b1023eaf71a (patch)
treea5856aebba5ba3eb7fd61f79f449df39beaf5ee4
parentd85b70b6293b004fc315e2fa6d9c78c0961be89f (diff)
downloadpaludis-1a300a6eec57dca2807f98071d2c5b1023eaf71a.tar.gz
paludis-1a300a6eec57dca2807f98071d2c5b1023eaf71a.tar.xz
start
-rw-r--r--src/clients/cave/Makefile.am1
-rw-r--r--src/clients/cave/cmd_execute_resolution.cc148
-rw-r--r--src/clients/cave/cmd_execute_resolution.hh45
-rw-r--r--src/clients/cave/command_factory.cc2
4 files changed, 196 insertions, 0 deletions
diff --git a/src/clients/cave/Makefile.am b/src/clients/cave/Makefile.am
index 55458b5..84b1d37 100644
--- a/src/clients/cave/Makefile.am
+++ b/src/clients/cave/Makefile.am
@@ -79,6 +79,7 @@ libcave_a_SOURCES = \
command_command_line.cc command_command_line.hh \
command_factory.cc command_factory.hh \
cmd_display_resolution.cc cmd_display_resolution.hh \
+ cmd_execute_resolution.cc cmd_execute_resolution.hh \
cmd_help.cc cmd_help.hh \
cmd_perform.cc cmd_perform.hh \
cmd_print_categories.cc cmd_print_categories.hh \
diff --git a/src/clients/cave/cmd_execute_resolution.cc b/src/clients/cave/cmd_execute_resolution.cc
new file mode 100644
index 0000000..0f19684
--- /dev/null
+++ b/src/clients/cave/cmd_execute_resolution.cc
@@ -0,0 +1,148 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "cmd_execute_resolution.hh"
+#include "cmd_resolve_cmdline.hh"
+#include "exceptions.hh"
+#include "command_command_line.hh"
+#include "formats.hh"
+#include "colour_formatter.hh"
+#include <paludis/args/do_help.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/safe_ifstream.hh>
+#include <paludis/util/system.hh>
+#include <paludis/util/destringify.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/join.hh>
+#include <paludis/util/iterator_funcs.hh>
+#include <paludis/util/options.hh>
+#include <paludis/resolver/resolutions.hh>
+#include <paludis/resolver/serialise.hh>
+#include <paludis/resolver/reason.hh>
+#include <paludis/resolver/sanitised_dependencies.hh>
+#include <paludis/resolver/resolution.hh>
+#include <paludis/resolver/decision.hh>
+#include <paludis/resolver/destinations.hh>
+#include <paludis/resolver/constraint.hh>
+#include <paludis/resolver/resolver.hh>
+#include <paludis/resolver/qpn_s.hh>
+#include <paludis/package_id.hh>
+#include <paludis/version_spec.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/choice.hh>
+#include <paludis/user_dep_spec.hh>
+#include <paludis/match_package.hh>
+
+#include <set>
+#include <iterator>
+#include <iostream>
+#include <cstdlib>
+
+using namespace paludis;
+using namespace cave;
+using namespace paludis::resolver;
+
+using std::cout;
+using std::endl;
+
+namespace
+{
+ struct ExecuteResolutionCommandLine :
+ CaveCommandCommandLine
+ {
+ ResolveCommandLineExecutionOptions display_options;
+ ResolveCommandLineProgramOptions program_options;
+
+ ExecuteResolutionCommandLine() :
+ display_options(this),
+ program_options(this)
+ {
+ add_environment_variable("PALUDIS_SERIALISED_RESOLUTION_FD",
+ "The file descriptor on which the serialised resolution can be found.");
+ }
+
+ virtual std::string app_name() const
+ {
+ return "cave execute-resolution";
+ }
+
+ virtual std::string app_synopsis() const
+ {
+ return "Executes a dependency resolution created using 'cave execute'.";
+ }
+
+ virtual std::string app_description() const
+ {
+ return "Execute a dependency resolution created using 'cave resolve'. Mostly for "
+ "internal use; most users will not use this command directly.";
+ }
+ };
+
+ void execute_resolution(
+ const std::tr1::shared_ptr<Environment> &,
+ const ResolutionLists &,
+ const ExecuteResolutionCommandLine &)
+ {
+ Context context("When executing chosen resolution:");
+ }
+}
+
+bool
+ExecuteResolutionCommand::important() const
+{
+ return false;
+}
+
+int
+ExecuteResolutionCommand::run(
+ const std::tr1::shared_ptr<Environment> & env,
+ const std::tr1::shared_ptr<const Sequence<std::string > > & args
+ )
+{
+ ExecuteResolutionCommandLine cmdline;
+ cmdline.run(args, "CAVE", "CAVE_EXECUTE_RESOLUTION_OPTIONS", "CAVE_EXECUTE_RESOLUTION_CMDLINE");
+
+ if (cmdline.a_help.specified())
+ {
+ cout << cmdline;
+ return EXIT_SUCCESS;
+ }
+
+ 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>());
+ Deserialiser deserialiser(env.get(), deser_str);
+ Deserialisation deserialisation("ResolutionLists", deserialiser);
+ ResolutionLists lists(ResolutionLists::deserialise(deserialisation));
+
+ execute_resolution(env, lists, cmdline);
+
+ return 0;
+}
+
+std::tr1::shared_ptr<args::ArgsHandler>
+ExecuteResolutionCommand::make_doc_cmdline()
+{
+ return make_shared_ptr(new ExecuteResolutionCommandLine);
+}
+
+
diff --git a/src/clients/cave/cmd_execute_resolution.hh b/src/clients/cave/cmd_execute_resolution.hh
new file mode 100644
index 0000000..da7ca1c
--- /dev/null
+++ b/src/clients/cave/cmd_execute_resolution.hh
@@ -0,0 +1,45 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_SRC_CLIENTS_CAVE_CMD_EXECUTE_RESOLUTION_HH
+#define PALUDIS_GUARD_SRC_CLIENTS_CAVE_CMD_EXECUTE_RESOLUTION_HH 1
+
+#include "command.hh"
+
+namespace paludis
+{
+ namespace cave
+ {
+ class PALUDIS_VISIBLE ExecuteResolutionCommand :
+ public Command
+ {
+ public:
+ bool important() const;
+
+ int run(
+ const std::tr1::shared_ptr<Environment> &,
+ const std::tr1::shared_ptr<const Sequence<std::string > > & args
+ );
+
+ std::tr1::shared_ptr<args::ArgsHandler> make_doc_cmdline();
+ };
+ }
+}
+
+#endif
diff --git a/src/clients/cave/command_factory.cc b/src/clients/cave/command_factory.cc
index 843cc2c..26b6518 100644
--- a/src/clients/cave/command_factory.cc
+++ b/src/clients/cave/command_factory.cc
@@ -27,6 +27,7 @@
#include <map>
#include "cmd_display_resolution.hh"
+#include "cmd_execute_resolution.hh"
#include "cmd_help.hh"
#include "cmd_perform.hh"
#include "cmd_print_categories.hh"
@@ -74,6 +75,7 @@ CommandFactory::CommandFactory() :
PrivateImplementationPattern<CommandFactory>(new Implementation<CommandFactory>)
{
_imp->handlers.insert(std::make_pair("display-resolution", make_command<DisplayResolutionCommand>));
+ _imp->handlers.insert(std::make_pair("execute-resolution", make_command<ExecuteResolutionCommand>));
_imp->handlers.insert(std::make_pair("help", make_command<HelpCommand>));
_imp->handlers.insert(std::make_pair("perform", make_command<PerformCommand>));
_imp->handlers.insert(std::make_pair("print-categories", make_command<PrintCategoriesCommand>));