aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2007-10-05 21:49:33 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2007-10-05 21:49:33 +0000
commit819359e4dd7a2ce7df86a6a2b85154cbd2697e61 (patch)
treef3db04c4f06c4005e9102c2d8b4b5a14a2326792
parent5cbbc59d6c90e3ff9e69ccd28a6470a111c44205 (diff)
downloadpaludis-819359e4dd7a2ce7df86a6a2b85154cbd2697e61.tar.gz
paludis-819359e4dd7a2ce7df86a6a2b85154cbd2697e61.tar.xz
Move a bunch of command line and resume command handling code out of src/clients/paludis/. Fixes: ticket:368
-rw-r--r--paludis/args/Makefile.am33
-rw-r--r--paludis/args/dep_list_args_group.cc318
-rw-r--r--paludis/args/dep_list_args_group.hh82
-rw-r--r--paludis/args/install_args_group.cc221
-rw-r--r--paludis/args/install_args_group.hh105
-rw-r--r--src/clients/contrarius/install.cc60
-rw-r--r--src/clients/paludis/command_line.cc130
-rw-r--r--src/clients/paludis/command_line.hh80
-rw-r--r--src/clients/paludis/install.cc426
-rw-r--r--src/clients/paludis/paludis.cc54
-rw-r--r--src/clients/paludis/uninstall.cc14
-rw-r--r--src/output/console_install_task.cc118
-rw-r--r--src/output/console_install_task.hh7
13 files changed, 934 insertions, 714 deletions
diff --git a/paludis/args/Makefile.am b/paludis/args/Makefile.am
index 0e940be..c24b15f 100644
--- a/paludis/args/Makefile.am
+++ b/paludis/args/Makefile.am
@@ -8,19 +8,21 @@ TESTS = \
paludis_args_includedir = $(includedir)/paludis-$(PALUDIS_PC_SLOT)/paludis/args/
paludis_args_include_HEADERS = \
- args.hh \
- args_error.hh \
- args_group.hh \
- args_handler.hh \
- args_option.hh \
- bad_argument.hh \
- args_visitor.hh \
- args_dumper.hh \
- man.hh \
- checks_arg.hh \
- debug_build_arg.hh \
- deps_option_arg.hh \
- log_level_arg.hh \
+ args.hh \
+ args_error.hh \
+ args_group.hh \
+ args_handler.hh \
+ args_option.hh \
+ bad_argument.hh \
+ args_visitor.hh \
+ args_dumper.hh \
+ man.hh \
+ checks_arg.hh \
+ debug_build_arg.hh \
+ deps_option_arg.hh \
+ log_level_arg.hh \
+ dep_list_args_group.hh \
+ install_args_group.hh \
do_help.hh
libpaludisargs_la_SOURCES = \
@@ -35,7 +37,9 @@ libpaludisargs_la_SOURCES = \
checks_arg.cc \
debug_build_arg.cc \
deps_option_arg.cc \
- log_level_arg.cc
+ log_level_arg.cc \
+ dep_list_args_group.cc \
+ install_args_group.cc
libpaludisman_a_SOURCES = \
man.cc
@@ -43,6 +47,7 @@ libpaludisman_a_SOURCES = \
libpaludisargs_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0
libpaludisargs_la_LIBADD = \
+ $(top_builddir)/paludis/libpaludis.la
$(top_builddir)/paludis/util/libpaludisutil.la
TESTS_ENVIRONMENT = env PALUDIS_OPTIONS="" \
diff --git a/paludis/args/dep_list_args_group.cc b/paludis/args/dep_list_args_group.cc
new file mode 100644
index 0000000..2139660
--- /dev/null
+++ b/paludis/args/dep_list_args_group.cc
@@ -0,0 +1,318 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2007 David Leverton <levertond@googlemail.com>
+ *
+ * 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 "dep_list_args_group.hh"
+
+#include <paludis/util/log.hh>
+#include <paludis/util/sequence.hh>
+
+#include <paludis/args/do_help.hh>
+#include <paludis/environment-fwd.hh>
+#include <paludis/override_functions.hh>
+
+using namespace paludis;
+using namespace paludis::args;
+
+namespace
+{
+ DepListDepsOption
+ enum_arg_to_dep_list_deps_option(const args::EnumArg & arg)
+ {
+ if (arg.argument() == "pre")
+ return dl_deps_pre;
+ else if (arg.argument() == "pre-or-post")
+ return dl_deps_pre_or_post;
+ else if (arg.argument() == "post")
+ return dl_deps_post;
+ else if (arg.argument() == "try-post")
+ return dl_deps_try_post;
+ else if (arg.argument() == "discard")
+ return dl_deps_discard;
+ else
+ throw args::DoHelp("bad value for --" + arg.long_name());
+ }
+}
+
+DepListArgsGroup::DepListArgsGroup(ArgsHandler * h) :
+ ArgsGroup(h, "DepList behaviour",
+ "Modify dependency list generation behaviour. Use with caution."),
+
+ dl_reinstall(this, "dl-reinstall", '\0', "When to reinstall packages",
+ args::EnumArg::EnumArgOptions
+ ("never", "Never")
+ ("always", "Always")
+ ("if-use-changed", "If USE flags have changed"),
+ "never"),
+ dl_reinstall_scm(this, "dl-reinstall-scm", '\0', "When to reinstall scm packages",
+ args::EnumArg::EnumArgOptions
+ ("never", "Never")
+ ("always", "Always")
+ ("daily", "If they are over a day old")
+ ("weekly", "If they are over a week old"),
+ "never"),
+ dl_reinstall_targets(this, "dl-reinstall-targets", '\0', "Whether to reinstall targets",
+ args::EnumArg::EnumArgOptions
+ ("auto", "If the target is a set, never, otherwise always")
+ ("never", "Never")
+ ("always", "Always"),
+ "auto"),
+
+ dl_upgrade(this, "dl-upgrade", '\0', "When to upgrade packages",
+ args::EnumArg::EnumArgOptions
+ ("always", "Always")
+ ("as-needed", "As needed"),
+ "always"),
+ dl_new_slots(this, "dl-new-slots", '\0', "When to pull in new slots (works with --dl-upgrade)",
+ args::EnumArg::EnumArgOptions
+ ("always", "Always")
+ ("as-needed", "As needed"),
+ "always"),
+ dl_downgrade(this, "dl-downgrade", '\0', "When to downgrade packages",
+ args::EnumArg::EnumArgOptions
+ ("as-needed", "As needed")
+ ("warning", "As needed, but warn when doing so")
+ ("error", "Downgrades should be treated as errors"),
+ "as-needed"),
+
+ dl_deps_default(this, "dl-deps-default", '\0',
+ "Override default behaviour for all dependency classes",
+ static_cast<DepListDepsOption>(-1)),
+
+ dl_installed_deps_pre(this, "dl-installed-deps-pre", '\0',
+ "How to handle pre dependencies for installed packages",
+ dl_deps_discard),
+ dl_installed_deps_runtime(this, "dl-installed-deps-runtime", '\0',
+ "How to handle runtime dependencies for installed packages",
+ dl_deps_try_post),
+ dl_installed_deps_post(this, "dl-installed-deps-post", '\0',
+ "How to handle post dependencies for installed packages",
+ dl_deps_try_post),
+
+ dl_uninstalled_deps_pre(this, "dl-uninstalled-deps-pre", '\0',
+ "How to handle pre dependencies for uninstalled packages",
+ dl_deps_pre),
+ dl_uninstalled_deps_runtime(this, "dl-uninstalled-deps-runtime", '\0',
+ "How to handle runtime dependencies for uninstalled packages",
+ dl_deps_pre_or_post),
+ dl_uninstalled_deps_post(this, "dl-uninstalled-deps-post", '\0',
+ "How to handle post dependencies for uninstalled packages",
+ dl_deps_post),
+ dl_uninstalled_deps_suggested(this, "dl-uninstalled-deps-suggested", '\0',
+ "How to handle suggested dependencies for uninstalled packages (only with --dl-suggested install)",
+ dl_deps_post),
+
+ dl_suggested(this, "dl-suggested", '\0', "How to handle suggested dependencies",
+ args::EnumArg::EnumArgOptions
+ ("show", "Display, but do not install")
+ ("install", "Install")
+ ("discard", "Discard"),
+ "show"),
+ dl_circular(this, "dl-circular", '\0', "How to handle circular dependencies",
+ args::EnumArg::EnumArgOptions
+ ("error", "Raise an error")
+ ("discard", "Discard"),
+ "error"),
+ dl_blocks(this, "dl-blocks", '\0', "How to handle blocks",
+ args::EnumArg::EnumArgOptions
+ ("accumulate", "Accumulate and show in the dependency list")
+ ("error", "Error straight away")
+ ("discard", "Discard (dangerous)"),
+ "error"),
+ dl_override_masks(this, "dl-override-masks", '\0',
+ "Zero or more mask kinds that can be overridden as necessary",
+ args::StringSetArg::StringSetArgOptions
+ ("tilde-keyword", "Keyword masks where accepting ~ would work")
+ ("unkeyworded", "Keyword masks where a package is unkeyworded")
+ ("repository", "Repository masks")
+ ("profile", "Deprecated synonym for repository")
+ ("license", "License masks")),
+
+ dl_fall_back(this, "dl-fall-back", '\0', "When to fall back to installed packages",
+ args::EnumArg::EnumArgOptions
+ ("as-needed-except-targets", "Where necessary, but not for target packages")
+ ("as-needed", "Where necessary, including for target packages")
+ ("never", "Never"),
+ "as-needed-except-targets")
+{
+}
+
+DepListArgsGroup::~DepListArgsGroup()
+{
+}
+
+void
+DepListArgsGroup::populate_dep_list_options(const Environment * env, DepListOptions & options) const
+{
+ if (dl_reinstall.argument() == "never")
+ options.reinstall = dl_reinstall_never;
+ else if (dl_reinstall.argument() == "always")
+ options.reinstall = dl_reinstall_always;
+ else if (dl_reinstall.argument() == "if-use-changed")
+ options.reinstall = dl_reinstall_if_use_changed;
+ else
+ throw args::DoHelp("bad value for --dl-reinstall");
+
+ if (dl_reinstall_scm.argument() == "never")
+ options.reinstall_scm = dl_reinstall_scm_never;
+ else if (dl_reinstall_scm.argument() == "always")
+ options.reinstall_scm = dl_reinstall_scm_always;
+ else if (dl_reinstall_scm.argument() == "daily")
+ options.reinstall_scm = dl_reinstall_scm_daily;
+ else if (dl_reinstall_scm.argument() == "weekly")
+ options.reinstall_scm = dl_reinstall_scm_weekly;
+ else
+ throw args::DoHelp("bad value for --dl-reinstall-scm");
+
+ if (dl_upgrade.argument() == "as-needed")
+ options.upgrade = dl_upgrade_as_needed;
+ else if (dl_upgrade.argument() == "always")
+ options.upgrade = dl_upgrade_always;
+ else
+ throw args::DoHelp("bad value for --dl-upgrade");
+
+ if (dl_new_slots.argument() == "as-needed")
+ options.new_slots = dl_new_slots_as_needed;
+ else if (dl_new_slots.argument() == "always")
+ options.new_slots = dl_new_slots_always;
+ else
+ throw args::DoHelp("bad value for --dl-new-slots");
+
+ if (dl_downgrade.argument() == "as-needed")
+ options.downgrade = dl_downgrade_as_needed;
+ else if (dl_downgrade.argument() == "warning")
+ options.downgrade = dl_downgrade_warning;
+ else if (dl_downgrade.argument() == "error")
+ options.downgrade = dl_downgrade_error;
+ else
+ throw args::DoHelp("bad value for --dl-downgrade");
+
+ if (dl_circular.argument() == "discard")
+ options.circular = dl_circular_discard;
+ else if (dl_circular.argument() == "error")
+ options.circular = dl_circular_error;
+ else
+ throw args::DoHelp("bad value for --dl-circular");
+
+ if (dl_suggested.argument() == "show")
+ options.suggested = dl_suggested_show;
+ else if (dl_suggested.argument() == "discard")
+ options.suggested = dl_suggested_discard;
+ else if (dl_suggested.argument() == "install")
+ options.suggested = dl_suggested_install;
+ else
+ throw args::DoHelp("bad value for --dl-suggested");
+
+ if (dl_blocks.argument() == "discard")
+ options.blocks = dl_blocks_discard;
+ else if (dl_blocks.argument() == "error")
+ options.blocks = dl_blocks_error;
+ else if (dl_blocks.argument() == "accumulate")
+ options.blocks = dl_blocks_accumulate;
+ else
+ throw args::DoHelp("bad value for --dl-blocks");
+
+ if (dl_override_masks.specified())
+ {
+ for (args::StringSetArg::ConstIterator a(dl_override_masks.begin_args()),
+ a_end(dl_override_masks.end_args()) ; a != a_end ; ++a)
+ {
+ if (! options.override_masks)
+ options.override_masks.reset(new DepListOverrideMasksFunctions);
+
+ using namespace tr1::placeholders;
+
+ if (*a == "tilde-keyword")
+ options.override_masks->push_back(tr1::bind(&override_tilde_keywords, env, _1, _2));
+ else if (*a == "unkeyworded")
+ options.override_masks->push_back(tr1::bind(&override_unkeyworded, env, _1, _2));
+ else if (*a == "repository")
+ options.override_masks->push_back(tr1::bind(&override_repository_masks, _2));
+ else if (*a == "license")
+ options.override_masks->push_back(tr1::bind(&override_license, _2));
+ else if (*a == "profile")
+ {
+ Log::get_instance()->message(ll_warning, lc_no_context, "--dl-override-masks profile is deprecated, use --dl-override-masks repository");
+ options.override_masks->push_back(tr1::bind(&override_repository_masks, _2));
+ }
+ else
+ throw args::DoHelp("bad value for --dl-override-masks");
+ }
+ }
+
+ if (dl_fall_back.argument() == "as-needed-except-targets")
+ options.fall_back = dl_fall_back_as_needed_except_targets;
+ else if (dl_fall_back.argument() == "as-needed")
+ options.fall_back = dl_fall_back_as_needed;
+ else if (dl_fall_back.argument() == "never")
+ options.fall_back = dl_fall_back_never;
+ else
+ throw args::DoHelp("bad value for --dl-fall-back");
+
+ if (dl_deps_default.specified())
+ {
+ DepListDepsOption x(dl_deps_default.option());
+ options.installed_deps_pre = x;
+ options.installed_deps_post = x;
+ options.installed_deps_runtime = x;
+ options.uninstalled_deps_pre = x;
+ options.uninstalled_deps_post = x;
+ options.uninstalled_deps_runtime = x;
+ options.uninstalled_deps_suggested = x;
+ }
+
+ options.installed_deps_pre = enum_arg_to_dep_list_deps_option(dl_installed_deps_pre);
+ options.installed_deps_runtime = enum_arg_to_dep_list_deps_option(dl_installed_deps_runtime);
+ options.installed_deps_post = enum_arg_to_dep_list_deps_option(dl_installed_deps_post);
+
+ options.uninstalled_deps_pre = enum_arg_to_dep_list_deps_option(dl_uninstalled_deps_pre);
+ options.uninstalled_deps_runtime = enum_arg_to_dep_list_deps_option(dl_uninstalled_deps_runtime);
+ options.uninstalled_deps_post = enum_arg_to_dep_list_deps_option(dl_uninstalled_deps_post);
+ options.uninstalled_deps_suggested = enum_arg_to_dep_list_deps_option(dl_uninstalled_deps_suggested);
+}
+
+void
+DepListArgsGroup::populate_install_task(const Environment *, InstallTask & task) const
+{
+ if (dl_reinstall_targets.specified())
+ {
+ if (dl_reinstall_targets.argument() == "auto")
+ {
+ }
+ else if (dl_reinstall_targets.argument() == "always")
+ task.override_target_type(dl_target_package);
+ else if (dl_reinstall_targets.argument() == "never")
+ task.override_target_type(dl_target_set);
+ else
+ throw args::DoHelp("bad value for --dl-reinstall-targets");
+ }
+}
+
+std::string
+DepListArgsGroup::paludis_command_fragment() const
+{
+ return "";
+}
+
+std::string
+DepListArgsGroup::resume_command_fragment(const InstallTask &) const
+{
+ return " --" + dl_deps_default.long_name() + " discard";
+}
+
diff --git a/paludis/args/dep_list_args_group.hh b/paludis/args/dep_list_args_group.hh
new file mode 100644
index 0000000..7346615
--- /dev/null
+++ b/paludis/args/dep_list_args_group.hh
@@ -0,0 +1,82 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2007 David Leverton <levertond@googlemail.com>
+ *
+ * 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_COMMON_ARGS_DEP_LIST_ARGS_HH
+#define PALUDIS_GUARD_SRC_COMMON_ARGS_DEP_LIST_ARGS_HH 1
+
+#include <paludis/args/args.hh>
+#include <paludis/args/deps_option_arg.hh>
+#include <paludis/dep_list.hh>
+#include <paludis/install_task.hh>
+
+namespace paludis
+{
+ namespace args
+ {
+ class PALUDIS_VISIBLE DepListArgsGroup : public ArgsGroup
+ {
+ public:
+ /// Constructor.
+ DepListArgsGroup(ArgsHandler *);
+
+ /// Destructor
+ ~DepListArgsGroup();
+
+ /// \name DepList behaviour arguments
+ /// {
+
+ paludis::args::EnumArg dl_reinstall;
+ paludis::args::EnumArg dl_reinstall_scm;
+ paludis::args::EnumArg dl_reinstall_targets;
+ paludis::args::EnumArg dl_upgrade;
+ paludis::args::EnumArg dl_new_slots;
+ paludis::args::EnumArg dl_downgrade;
+
+ paludis::args::DepsOptionArg dl_deps_default;
+
+ paludis::args::DepsOptionArg dl_installed_deps_pre;
+ paludis::args::DepsOptionArg dl_installed_deps_runtime;
+ paludis::args::DepsOptionArg dl_installed_deps_post;
+
+ paludis::args::DepsOptionArg dl_uninstalled_deps_pre;
+ paludis::args::DepsOptionArg dl_uninstalled_deps_runtime;
+ paludis::args::DepsOptionArg dl_uninstalled_deps_post;
+ paludis::args::DepsOptionArg dl_uninstalled_deps_suggested;
+
+ paludis::args::EnumArg dl_suggested;
+ paludis::args::EnumArg dl_circular;
+ paludis::args::EnumArg dl_blocks;
+ paludis::args::StringSetArg dl_override_masks;
+
+ paludis::args::EnumArg dl_fall_back;
+
+ /// }
+
+ void populate_dep_list_options(const paludis::Environment *, DepListOptions &) const;
+ void populate_install_task(const paludis::Environment *, InstallTask &) const;
+
+ std::string paludis_command_fragment() const;
+ std::string resume_command_fragment(const InstallTask &) const;
+ };
+ }
+}
+
+#endif
+
diff --git a/paludis/args/install_args_group.cc b/paludis/args/install_args_group.cc
new file mode 100644
index 0000000..e935e12
--- /dev/null
+++ b/paludis/args/install_args_group.cc
@@ -0,0 +1,221 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2007 David Leverton <levertond@googlemail.com>
+ *
+ * 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 "install_args_group.hh"
+
+#include <paludis/environment-fwd.hh>
+#include <paludis/args/do_help.hh>
+
+using namespace paludis;
+using namespace paludis::args;
+
+InstallArgsGroup::InstallArgsGroup(ArgsHandler * h, const std::string & our_name,
+ const std::string & our_description) :
+ ArgsGroup(h, our_name, our_description),
+
+ a_pretend(this, "pretend", 'p', "Pretend only"),
+ a_destinations(this, "destinations", 'd', "Use specified destinations instead of defaults"),
+ a_preserve_world(this, "preserve-world", '1', "Don't modify the world file"),
+ a_add_to_world_spec(this, "add-to-world-spec", '\0',
+ "Use this spec, rather than all targets, for updating world (for resume commands)"),
+ a_no_config_protection(this, "no-config-protection", '\0', "Disable config file protection (dangerous)"),
+ a_debug_build(this, "debug-build", '\0'),
+ a_checks(this, "checks", '\0'),
+ a_fetch(this, "fetch", 'f', "Only fetch sources; don't install anything"),
+ a_no_safe_resume(this, "no-safe-resume", '\0', "Do not allow interrupted downloads to be resumed"),
+ a_show_reasons(this, "show-reasons", '\0', "Show why packages are being (un)installed",
+ args::EnumArg::EnumArgOptions
+ ("none", "Don't show any information")
+ ("summary", "Show a summary")
+ ("full", "Show full output (can be very verbose)"),
+ "none"),
+ a_show_use_descriptions(this, "show-use-descriptions", '\0', "Show descriptions of USE flags",
+ args::EnumArg::EnumArgOptions
+ ("none", "Don't show any descriptions")
+ ("new", "Show for new use flags")
+ ("changed", "Show for new and changed flags")
+ ("all", "Show for all flags"),
+ "none"),
+ a_continue_on_faillure(this, "continue-on-failure", '\0', "Whether to continue after a fetch or install error",
+ args::EnumArg::EnumArgOptions
+ ("if-fetch-only", "If fetching only")
+ ("never", "Never")
+ ("if-satisfied", "If remaining packages' dependencies are satisfied")
+ ("always", "Always (UNSAFE)"),
+ "if-fetch-only")
+{
+}
+
+InstallArgsGroup::~InstallArgsGroup()
+{
+}
+
+void
+InstallArgsGroup::populate_dep_list_options(const Environment *, DepListOptions & options) const
+{
+ options.dependency_tags = a_show_reasons.argument() == "summary" || a_show_reasons.argument() == "full";
+}
+
+tr1::shared_ptr<const DestinationsSet>
+InstallArgsGroup::destinations(Environment * env) const
+{
+ if (a_destinations.specified())
+ {
+ Context local_context("When building destinations collection:");
+
+ tr1::shared_ptr<DestinationsSet> d(new DestinationsSet);
+ for (args::StringSetArg::ConstIterator i(a_destinations.begin_args()),
+ i_end(a_destinations.end_args()) ;
+ i != i_end ; ++i)
+ {
+ tr1::shared_ptr<Repository> repo(env->package_database()->fetch_repository(
+ RepositoryName(*i)));
+ if (repo->destination_interface)
+ d->insert(repo);
+ else
+ throw args::DoHelp("--destinations argument '" + *i + "' does not provide a destinations interface");
+ }
+
+ return d;
+ }
+ else
+ return env->default_destinations();
+}
+
+void
+InstallArgsGroup::populate_install_task(const Environment *, InstallTask & task) const
+{
+ task.set_no_config_protect(a_no_config_protection.specified());
+ task.set_fetch_only(a_fetch.specified());
+ task.set_pretend(a_pretend.specified());
+ task.set_preserve_world(a_preserve_world.specified());
+ task.set_safe_resume(! a_no_safe_resume.specified());
+
+ if (a_add_to_world_spec.specified())
+ task.set_add_to_world_spec(a_add_to_world_spec.argument());
+
+ task.set_debug_mode(a_debug_build.option());
+ task.set_checks_mode(a_checks.option());
+
+ if (a_continue_on_faillure.argument() == "if-fetch-only")
+ task.set_continue_on_failure(itcof_if_fetch_only);
+ else if (a_continue_on_faillure.argument() == "never")
+ task.set_continue_on_failure(itcof_never);
+ else if (a_continue_on_faillure.argument() == "if-satisfied")
+ task.set_continue_on_failure(itcof_if_satisfied);
+ else if (a_continue_on_faillure.argument() == "always")
+ task.set_continue_on_failure(itcof_always);
+ else
+ throw args::DoHelp("bad value for --continue-on-failure");
+}
+
+bool
+InstallArgsGroup::want_full_install_reasons() const
+{
+ return "full" == a_show_reasons.argument();
+}
+
+bool
+InstallArgsGroup::want_tags_summary() const
+{
+ return a_pretend.specified();
+}
+
+bool
+InstallArgsGroup::want_install_reasons() const
+{
+ if (! a_pretend.specified())
+ return false;
+
+ return "full" == a_show_reasons.argument() || "summary" == a_show_reasons.argument();
+}
+
+bool
+InstallArgsGroup::want_unchanged_use_flags() const
+{
+ return "none" != a_show_use_descriptions.argument() &&
+ "new" != a_show_use_descriptions.argument() &&
+ "changed" != a_show_use_descriptions.argument();
+}
+
+bool
+InstallArgsGroup::want_changed_use_flags() const
+{
+ return "none" != a_show_use_descriptions.argument() && "new" != a_show_use_descriptions.argument();
+}
+
+bool
+InstallArgsGroup::want_new_use_flags() const
+{
+ return "none" != a_show_use_descriptions.argument();
+}
+
+bool
+InstallArgsGroup::want_use_summary() const
+{
+ return "none" != a_show_use_descriptions.argument();
+}
+
+std::string
+InstallArgsGroup::paludis_command_fragment() const
+{
+ std::string paludis_command;
+
+ if (a_no_config_protection.specified())
+ paludis_command.append(" --" + a_no_config_protection.long_name());
+
+ if (a_preserve_world.specified())
+ paludis_command.append(" --" + a_preserve_world.long_name());
+
+ if (a_debug_build.specified())
+ paludis_command.append(" --" + a_debug_build.long_name() + " " + a_debug_build.argument());
+
+ if (a_no_safe_resume.specified())
+ paludis_command.append(" --" + a_no_safe_resume.long_name());
+
+ return paludis_command;
+}
+
+std::string
+InstallArgsGroup::resume_command_fragment(const InstallTask & task) const
+{
+ std::string resume_command;
+
+ if (a_add_to_world_spec.specified())
+ resume_command = resume_command + " --" + a_add_to_world_spec.long_name()
+ + " '" + a_add_to_world_spec.argument() + "'";
+ else if (! a_preserve_world.specified())
+ {
+ if (task.had_set_targets())
+ resume_command = resume_command + " --" + a_add_to_world_spec.long_name()
+ + " '( )'";
+ else
+ resume_command = resume_command + " --" + a_add_to_world_spec.long_name()
+ + " '( " + join(task.begin_targets(), task.end_targets(), " ") + " )'";
+ }
+
+ if (a_destinations.specified())
+ for (args::StringSetArg::ConstIterator i(a_destinations.begin_args()),
+ i_end(a_destinations.end_args()) ; i != i_end ; ++i)
+ resume_command = resume_command + " --" + a_destinations.long_name() + " '" + *i + "'";
+
+ return resume_command;
+}
+
diff --git a/paludis/args/install_args_group.hh b/paludis/args/install_args_group.hh
new file mode 100644
index 0000000..bdf7d43
--- /dev/null
+++ b/paludis/args/install_args_group.hh
@@ -0,0 +1,105 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2007 David Leverton <levertond@googlemail.com>
+ *
+ * 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_COMMON_ARGS_INSTALL_ARGS_HH
+#define PALUDIS_GUARD_SRC_COMMON_ARGS_INSTALL_ARGS_HH 1
+
+#include <paludis/util/set.hh>
+
+#include <paludis/args/args.hh>
+#include <paludis/args/checks_arg.hh>
+#include <paludis/args/debug_build_arg.hh>
+#include <paludis/dep_list-fwd.hh>
+#include <paludis/install_task.hh>
+
+namespace paludis
+{
+ namespace args
+ {
+ class PALUDIS_VISIBLE InstallArgsGroup : public ArgsGroup
+ {
+ public:
+ /// Constructor.
+ InstallArgsGroup(ArgsHandler *, const std::string &, const std::string &);
+
+ /// Destructor
+ ~InstallArgsGroup();
+
+ /// \name (Un)Install arguments
+ /// {
+
+ /// --pretend
+ paludis::args::SwitchArg a_pretend;
+
+ /// --destinations
+ paludis::args::StringSetArg a_destinations;
+
+ /// --preserve-world
+ paludis::args::SwitchArg a_preserve_world;
+
+ /// --add-to-world-spec
+ paludis::args::StringArg a_add_to_world_spec;
+
+ /// --no-config-protection
+ paludis::args::SwitchArg a_no_config_protection;
+
+ /// --debug-build
+ paludis::args::DebugBuildArg a_debug_build;
+
+ /// --checks
+ paludis::args::ChecksArg a_checks;
+
+ /// --fetch
+ paludis::args::SwitchArg a_fetch;
+
+ /// --no-safe-resume
+ paludis::args::SwitchArg a_no_safe_resume;
+
+ /// --show-reasons
+ paludis::args::EnumArg a_show_reasons;
+
+ /// --show-use-descriptions
+ paludis::args::EnumArg a_show_use_descriptions;
+
+ /// --continue-on-failure
+ paludis::args::EnumArg a_continue_on_faillure;
+
+ /// }
+
+ void populate_dep_list_options(const Environment *, DepListOptions &) const;
+ tr1::shared_ptr<const DestinationsSet> destinations(Environment *) const;
+ void populate_install_task(const Environment *, InstallTask &) const;
+
+ bool want_full_install_reasons() const;
+ bool want_install_reasons() const;
+ bool want_tags_summary() const;
+
+ bool want_use_summary() const;
+ bool want_unchanged_use_flags() const;
+ bool want_changed_use_flags() const;
+ bool want_new_use_flags() const;
+
+ std::string paludis_command_fragment() const;
+ std::string resume_command_fragment(const InstallTask &) const;
+ };
+ }
+}
+
+#endif
diff --git a/src/clients/contrarius/install.cc b/src/clients/contrarius/install.cc
index 89a8448..34c1cc2 100644
--- a/src/clients/contrarius/install.cc
+++ b/src/clients/contrarius/install.cc
@@ -19,24 +19,14 @@
*/
#include "install.hh"
-#include <src/output/colour.hh>
#include <src/output/console_install_task.hh>
#include <iostream>
-#include <limits>
-#include <set>
#include <paludis/install_task.hh>
-#include <paludis/util/fd_output_stream.hh>
#include <paludis/util/log.hh>
-#include <paludis/util/tokeniser.hh>
#include <paludis/util/sequence.hh>
#include <paludis/environment.hh>
-#include <paludis/dep_list_exceptions.hh>
-#include <paludis/query.hh>
-#include <paludis/metadata_key.hh>
-#include <paludis/mask.hh>
-#include <paludis/action.hh>
#include <paludis/package_id.hh>
/** \file
@@ -96,40 +86,13 @@ namespace
return false;
}
+ virtual std::string make_resume_command(const PackageIDSequence & p) const
+ {
+ return "";
+ }
+
virtual void show_resume_command() const
{
- if (CommandLine::get_instance()->a_fetch.specified() ||
- CommandLine::get_instance()->a_pretend.specified())
- return;
-
- const tr1::shared_ptr<const PackageIDSequence> p(packages_not_yet_installed_successfully());
- if (! p->empty())
- {
- std::string resume_command = environment()->paludis_command() + " "
- "--dl-installed-deps-pre discard "
- "--dl-installed-deps-runtime discard "
- "--dl-installed-deps-post discard "
- "--dl-uninstalled-deps-pre discard "
- "--dl-uninstalled-deps-runtime discard "
- "--dl-uninstalled-deps-post discard "
- "--install --preserve-world";
- for (PackageIDSequence::ConstIterator i(p->begin()), i_end(p->end()) ; i != i_end ; ++i)
- resume_command = resume_command + " '=" + stringify(**i) + "'";
-
- if (CommandLine::get_instance()->a_resume_command_template.specified())
- {
- std::string file_name(CommandLine::get_instance()->a_resume_command_template.argument());
- char* resume_template = strdup(file_name.c_str());
- FDOutputStream resume_command_file(mkstemp(resume_template));
- cerr << endl;
- cerr << "Resume command saved to file: " << resume_template;
- cerr << endl;
- resume_command_file << resume_command << endl;
- std::free(resume_template);
- }
- else
- cerr << "Resume command: " << resume_command << endl;
- }
}
};
}
@@ -137,8 +100,6 @@ namespace
int
do_install(tr1::shared_ptr<Environment> env, std::string spec_str)
{
- int return_code(0);
-
Context context("When performing install action from command line:");
DepListOptions options;
@@ -176,15 +137,6 @@ do_install(tr1::shared_ptr<Environment> env, std::string spec_str)
cout << endl;
- if (task.dep_list().has_errors())
- return_code |= 1;
-
- if (task.had_resolution_failures())
- return_code |= 3;
-
- if (task.had_action_failures())
- return_code |= 7;
-
- return return_code;
+ return task.exit_status();
}
diff --git a/src/clients/paludis/command_line.cc b/src/clients/paludis/command_line.cc
index f821ac5..212a735 100644
--- a/src/clients/paludis/command_line.cc
+++ b/src/clients/paludis/command_line.cc
@@ -80,36 +80,6 @@ CommandLine::CommandLine() :
install_args(this, "Install, Uninstall options",
"Options which are relevant for --install, --uninstall or --uninstall-unused."),
- a_pretend(&install_args, "pretend", 'p', "Pretend only"),
- a_destinations(&install_args, "destinations", 'd', "Use specified destinations instead of defaults"),
- a_preserve_world(&install_args, "preserve-world", '1', "Don't modify the world file"),
- a_add_to_world_spec(&install_args, "add-to-world-spec", '\0',
- "Use this spec, rather than all targets, for updating world (for resume commands)"),
- a_no_config_protection(&install_args, "no-config-protection", '\0', "Disable config file protection (dangerous)"),
- a_debug_build(&install_args, "debug-build", '\0'),
- a_checks(&install_args, "checks", '\0'),
- a_fetch(&install_args, "fetch", 'f', "Only fetch sources; don't install anything"),
- a_no_safe_resume(&install_args, "no-safe-resume", '\0', "Do not allow interrupted downloads to be resumed"),
- a_show_reasons(&install_args, "show-reasons", '\0', "Show why packages are being (un)installed",
- args::EnumArg::EnumArgOptions
- ("none", "Don't show any information")
- ("summary", "Show a summary")
- ("full", "Show full output (can be very verbose)"),
- "none"),
- a_show_use_descriptions(&install_args, "show-use-descriptions", '\0', "Show descriptions of USE flags",
- args::EnumArg::EnumArgOptions
- ("none", "Don't show any descriptions")
- ("new", "Show for new use flags")
- ("changed", "Show for new and changed flags")
- ("all", "Show for all flags"),
- "none"),
- a_continue_on_faillure(&install_args, "continue-on-failure", '\0', "Whether to continue after a fetch or install error",
- args::EnumArg::EnumArgOptions
- ("if-fetch-only", "If fetching only")
- ("never", "Never")
- ("if-satisfied", "If remaining packages' dependencies are satisfied")
- ("always", "Always (UNSAFE)"),
- "if-fetch-only"),
uninstall_args(this, "Uninstall options",
"Options which are relevant for --uninstall."),
@@ -122,105 +92,7 @@ CommandLine::CommandLine() :
a_permit_unsafe_uninstalls(&uninstall_args, "permit-unsafe-uninstalls", '\0',
"Allow depended-upon packages to uninstalled"),
- dl_args(this, "DepList behaviour",
- "Modify dependency list generation behaviour. Use with caution."),
-
- dl_reinstall(&dl_args, "dl-reinstall", '\0', "When to reinstall packages",
- args::EnumArg::EnumArgOptions
- ("never", "Never")
- ("always", "Always")
- ("if-use-changed", "If USE flags have changed"),
- "never"),
- dl_reinstall_scm(&dl_args, "dl-reinstall-scm", '\0', "When to reinstall scm packages",
- args::EnumArg::EnumArgOptions
- ("never", "Never")
- ("always", "Always")
- ("daily", "If they are over a day old")
- ("weekly", "If they are over a week old"),
- "never"),
- dl_reinstall_targets(&dl_args, "dl-reinstall-targets", '\0', "Whether to reinstall targets",
- args::EnumArg::EnumArgOptions
- ("auto", "If the target is a set, never, otherwise always")
- ("never", "Never")
- ("always", "Always"),
- "auto"),
-
- dl_upgrade(&dl_args, "dl-upgrade", '\0', "When to upgrade packages",
- args::EnumArg::EnumArgOptions
- ("always", "Always")
- ("as-needed", "As needed"),
- "always"),
- dl_new_slots(&dl_args, "dl-new-slots", '\0', "When to pull in new slots (works with --dl-upgrade)",
- args::EnumArg::EnumArgOptions
- ("always", "Always")
- ("as-needed", "As needed"),
- "always"),
- dl_downgrade(&dl_args, "dl-downgrade", '\0', "When to downgrade packages",
- args::EnumArg::EnumArgOptions
- ("as-needed", "As needed")
- ("warning", "As needed, but warn when doing so")
- ("error", "Downgrades should be treated as errors"),
- "as-needed"),
-
- dl_deps_default(&dl_args, "dl-deps-default", '\0',
- "Override default behaviour for all dependency classes",
- static_cast<DepListDepsOption>(-1)),
-
- dl_installed_deps_pre(&dl_args, "dl-installed-deps-pre", '\0',
- "How to handle pre dependencies for installed packages",
- dl_deps_discard),
- dl_installed_deps_runtime(&dl_args, "dl-installed-deps-runtime", '\0',
- "How to handle runtime dependencies for installed packages",
- dl_deps_try_post),
- dl_installed_deps_post(&dl_args, "dl-installed-deps-post", '\0',
- "How to handle post dependencies for installed packages",
- dl_deps_try_post),
-
- dl_uninstalled_deps_pre(&dl_args, "dl-uninstalled-deps-pre", '\0',
- "How to handle pre dependencies for uninstalled packages",
- dl_deps_pre),
- dl_uninstalled_deps_runtime(&dl_args, "dl-uninstalled-deps-runtime", '\0',
- "How to handle runtime dependencies for uninstalled packages",
- dl_deps_pre_or_post),
- dl_uninstalled_deps_post(&dl_args, "dl-uninstalled-deps-post", '\0',
- "How to handle post dependencies for uninstalled packages",
- dl_deps_post),
- dl_uninstalled_deps_suggested(&dl_args, "dl-uninstalled-deps-suggested", '\0',
- "How to handle suggested dependencies for uninstalled packages (only with --dl-suggested install)",
- dl_deps_post),
-
- dl_suggested(&dl_args, "dl-suggested", '\0', "How to handle suggested dependencies",
- args::EnumArg::EnumArgOptions
- ("show", "Display, but do not install")
- ("install", "Install")
- ("discard", "Discard"),
- "show"),
- dl_circular(&dl_args, "dl-circular", '\0', "How to handle circular dependencies",
- args::EnumArg::EnumArgOptions
- ("error", "Raise an error")
- ("discard", "Discard"),
- "error"),
- dl_blocks(&dl_args, "dl-blocks", '\0', "How to handle blocks",
- args::EnumArg::EnumArgOptions
- ("accumulate", "Accumulate and show in the dependency list")
- ("error", "Error straight away")
- ("discard", "Discard (dangerous)"),
- "error"),
- dl_override_masks(&dl_args, "dl-override-masks", '\0',
- "Zero or more mask kinds that can be overridden as necessary",
- args::StringSetArg::StringSetArgOptions
- ("tilde-keyword", "Keyword masks where accepting ~ would work")
- ("unkeyworded", "Keyword masks where a package is unkeyworded")
- ("repository", "Repository masks")
- ("profile", "Deprecated synonym for repository")
- ("license", "License masks")),
-
- dl_fall_back(&dl_args, "dl-fall-back", '\0', "When to fall back to installed packages",
- args::EnumArg::EnumArgOptions
- ("as-needed-except-targets", "Where necessary, but not for target packages")
- ("as-needed", "Where necessary, including for target packages")
- ("never", "Never"),
- "as-needed-except-targets"),
+ dl_args(this),
list_args(this, "List options",
"Options relevant for one or more of the --list actions."),
diff --git a/src/clients/paludis/command_line.hh b/src/clients/paludis/command_line.hh
index 9c64326..55bf679 100644
--- a/src/clients/paludis/command_line.hh
+++ b/src/clients/paludis/command_line.hh
@@ -22,10 +22,9 @@
#include <paludis/args/args.hh>
#include <paludis/util/instantiation_policy.hh>
-#include <paludis/args/debug_build_arg.hh>
-#include <paludis/args/checks_arg.hh>
+#include <paludis/args/dep_list_args_group.hh>
+#include <paludis/args/install_args_group.hh>
#include <paludis/args/log_level_arg.hh>
-#include <paludis/args/deps_option_arg.hh>
/** \file
* Declarations for the CommandLine class.
@@ -184,48 +183,7 @@ class CommandLine :
/// }
/// \name (Un)Install arguments
- /// {
-
- /// Install arguments.
- paludis::args::ArgsGroup install_args;
-
- /// --pretend
- paludis::args::SwitchArg a_pretend;
-
- /// --destinations
- paludis::args::StringSetArg a_destinations;
-
- /// --preserve-world
- paludis::args::SwitchArg a_preserve_world;
-
- /// --add-to-world-spec
- paludis::args::StringArg a_add_to_world_spec;
-
- /// --no-config-protection
- paludis::args::SwitchArg a_no_config_protection;
-
- /// --debug-build
- paludis::args::DebugBuildArg a_debug_build;
-
- /// --checks
- paludis::args::ChecksArg a_checks;
-
- /// --fetch
- paludis::args::SwitchArg a_fetch;
-
- /// --no-safe-resume
- paludis::args::SwitchArg a_no_safe_resume;
-
- /// --show-reasons
- paludis::args::EnumArg a_show_reasons;
-
- /// --show-use-descriptions
- paludis::args::EnumArg a_show_use_descriptions;
-
- /// --continue-on-failure
- paludis::args::EnumArg a_continue_on_faillure;
-
- /// }
+ paludis::args::InstallArgsGroup install_args;
/// \name Uninstall arguments
///\{
@@ -246,38 +204,8 @@ class CommandLine :
///\}
- /// \name DepList behaviour arguments
- /// {
-
/// DepList behaviour arguments.
- paludis::args::ArgsGroup dl_args;
-
- paludis::args::EnumArg dl_reinstall;
- paludis::args::EnumArg dl_reinstall_scm;
- paludis::args::EnumArg dl_reinstall_targets;
- paludis::args::EnumArg dl_upgrade;
- paludis::args::EnumArg dl_new_slots;
- paludis::args::EnumArg dl_downgrade;
-
- paludis::args::DepsOptionArg dl_deps_default;
-
- paludis::args::DepsOptionArg dl_installed_deps_pre;
- paludis::args::DepsOptionArg dl_installed_deps_runtime;
- paludis::args::DepsOptionArg dl_installed_deps_post;
-
- paludis::args::DepsOptionArg dl_uninstalled_deps_pre;
- paludis::args::DepsOptionArg dl_uninstalled_deps_runtime;
- paludis::args::DepsOptionArg dl_uninstalled_deps_post;
- paludis::args::DepsOptionArg dl_uninstalled_deps_suggested;
-
- paludis::args::EnumArg dl_suggested;
- paludis::args::EnumArg dl_circular;
- paludis::args::EnumArg dl_blocks;
- paludis::args::StringSetArg dl_override_masks;
-
- paludis::args::EnumArg dl_fall_back;
-
- /// }
+ paludis::args::DepListArgsGroup dl_args;
/// \name List arguments
/// {
diff --git a/src/clients/paludis/install.cc b/src/clients/paludis/install.cc
index dbc239f..2707d44 100644
--- a/src/clients/paludis/install.cc
+++ b/src/clients/paludis/install.cc
@@ -17,35 +17,21 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <src/output/colour.hh>
#include "install.hh"
#include <src/output/console_install_task.hh>
#include <paludis/args/do_help.hh>
#include <iostream>
-#include <limits>
-#include <set>
#include <cstdlib>
#include <cstring>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-
#include <paludis/install_task.hh>
#include <paludis/tasks_exceptions.hh>
-#include <paludis/util/fd_output_stream.hh>
#include <paludis/util/log.hh>
#include <paludis/util/tokeniser.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/set.hh>
-#include <paludis/util/system.hh>
-
-#include <paludis/dep_list_exceptions.hh>
-#include <paludis/override_functions.hh>
#include <paludis/hook.hh>
#include <paludis/query.hh>
@@ -69,39 +55,6 @@ using std::endl;
namespace
{
- std::string make_resume_command(const Environment * const env, const InstallTask & task, const PackageIDSequence & s)
- {
- std::string resume_command = env->paludis_command()
- + " --" + CommandLine::get_instance()->dl_deps_default.long_name() + " discard --"
- + CommandLine::get_instance()->a_install.long_name();
-
- for (PackageIDSequence::ConstIterator i(s.begin()), i_end(s.end()) ;
- i != i_end ; ++i)
- resume_command = resume_command + " '=" + stringify(**i) + "'";
-
- if (CommandLine::get_instance()->a_add_to_world_spec.specified())
- resume_command = resume_command + " --" + CommandLine::get_instance()->a_add_to_world_spec.long_name()
- + " '" + CommandLine::get_instance()->a_add_to_world_spec.argument() + "'";
- else if (! CommandLine::get_instance()->a_preserve_world.specified())
- {
- if (task.had_set_targets())
- resume_command = resume_command + " --" + CommandLine::get_instance()->a_add_to_world_spec.long_name()
- + " '( )'";
- else
- resume_command = resume_command + " --" + CommandLine::get_instance()->a_add_to_world_spec.long_name()
- + " '( " + join(task.begin_targets(), task.end_targets(), " ") + " )'";
- }
-
- if (CommandLine::get_instance()->a_destinations.specified())
- for (args::StringSetArg::ConstIterator i(CommandLine::get_instance()->a_destinations.begin_args()),
- i_end(CommandLine::get_instance()->a_destinations.end_args()) ;
- i != i_end ; ++i)
- resume_command = resume_command + " --" + CommandLine::get_instance()->a_destinations.long_name()
- + " '" + *i + "'";
-
- return resume_command;
- }
-
class OurInstallTask :
public ConsoleInstallTask
{
@@ -118,397 +71,77 @@ namespace
virtual bool want_full_install_reasons() const
{
- return "full" == CommandLine::get_instance()->a_show_reasons.argument();
+ return CommandLine::get_instance()->install_args.want_full_install_reasons();
}
virtual bool want_tags_summary() const
{
- return CommandLine::get_instance()->a_pretend.specified();
+ return CommandLine::get_instance()->install_args.want_tags_summary();
}
virtual bool want_install_reasons() const
{
- if (! CommandLine::get_instance()->a_pretend.specified())
- return false;
-
- return "full" == CommandLine::get_instance()->a_show_reasons.argument() ||
- "summary" == CommandLine::get_instance()->a_show_reasons.argument();
+ return CommandLine::get_instance()->install_args.want_install_reasons();
}
virtual bool want_unchanged_use_flags() const
{
- return "none" != CommandLine::get_instance()->a_show_use_descriptions.argument() &&
- "new" != CommandLine::get_instance()->a_show_use_descriptions.argument() &&
- "changed" != CommandLine::get_instance()->a_show_use_descriptions.argument();
+ return CommandLine::get_instance()->install_args.want_unchanged_use_flags();
}
virtual bool want_changed_use_flags() const
{
- return "none" != CommandLine::get_instance()->a_show_use_descriptions.argument() &&
- "new" != CommandLine::get_instance()->a_show_use_descriptions.argument();
+ return CommandLine::get_instance()->install_args.want_changed_use_flags();
}
virtual bool want_new_use_flags() const
{
- return "none" != CommandLine::get_instance()->a_show_use_descriptions.argument();
+ return CommandLine::get_instance()->install_args.want_new_use_flags();
}
virtual bool want_use_summary() const
{
- return "none" != CommandLine::get_instance()->a_show_use_descriptions.argument();
+ return CommandLine::get_instance()->install_args.want_use_summary();
}
- virtual void on_installed_paludis()
+ virtual std::string make_resume_command(const PackageIDSequence & s) const
{
- std::string r(stringify(_env->root()));
- std::string exec_mode(getenv_with_default("PALUDIS_EXEC_PALUDIS", ""));
-
- if ("always" != exec_mode)
- {
- if ("never" == exec_mode)
- return;
- else if (! (r.empty() || r == "/"))
- return;
- }
+ std::string resume_command = environment()->paludis_command()
+ + " --" + CommandLine::get_instance()->a_install.long_name();
- std::string resume_command(make_resume_command(_env.get(), *this, *packages_not_yet_installed_successfully()));
+ resume_command = resume_command + CommandLine::get_instance()->install_args.resume_command_fragment(*this);
+ resume_command = resume_command + CommandLine::get_instance()->dl_args.resume_command_fragment(*this);
- output_heading("Paludis has just upgraded Paludis");
- output_starred_item("Using '" + resume_command + "' to start a new Paludis instance...");
- output_endl();
-
- execl("/bin/sh", "sh", "-c", resume_command.c_str(), static_cast<const char *>(0));
- }
+ for (PackageIDSequence::ConstIterator i(s.begin()), i_end(s.end()) ;
+ i != i_end ; ++i)
+ resume_command = resume_command + " '=" + stringify(**i) + "'";
- virtual HookResult perform_hook(const Hook & hook) const
- {
- return ConsoleInstallTask::perform_hook(hook("RESUME_COMMAND", make_resume_command(
- _env.get(), *this, *packages_not_yet_installed_successfully())));
+ return resume_command;
}
void show_resume_command() const
{
- if (CommandLine::get_instance()->a_fetch.specified() ||
- CommandLine::get_instance()->a_pretend.specified())
+ if (CommandLine::get_instance()->install_args.a_fetch.specified() ||
+ CommandLine::get_instance()->install_args.a_pretend.specified())
return;
- const tr1::shared_ptr<const PackageIDSequence> p(packages_not_yet_installed_successfully());
- if (! p->empty())
- {
- std::string resume_command(make_resume_command(environment(), *this, *p));
-
- if (CommandLine::get_instance()->a_resume_command_template.specified())
- {
- std::string file_name(CommandLine::get_instance()->a_resume_command_template.argument());
- int fd;
- if (std::string::npos == file_name.find("XXXXXX"))
- fd = open(file_name.c_str(), O_WRONLY | O_CREAT | O_TRUNC);
- else
- {
- char * resume_template = strdup(file_name.c_str());
- fd = mkstemp(resume_template);
- file_name = resume_template;
- std::free(resume_template);
- }
-
- if (-1 != fd)
- {
- ::fchmod(fd, 0644);
- FDOutputStream resume_command_file(fd);
- resume_command_file << resume_command << endl;
-
- if (resume_command_file)
- {
- cerr << endl;
- cerr << "Resume command saved to file: " << file_name;
- cerr << endl;
- }
- else
- {
- cerr << "Resume command NOT saved to file: " << file_name << " due to error "
- << strerror(errno) << endl;
- cerr << "Resume command: " << file_name << endl;
- }
- }
- else
- {
- cerr << "Resume command NOT saved to file: " << file_name << " due to error "
- << strerror(errno) << endl;
- cerr << "Resume command: " << file_name << endl;
- }
- }
- else
- {
- cerr << endl;
- cerr << "Resume command: " << resume_command << endl;
- }
- }
+ ConsoleInstallTask::show_resume_command(CommandLine::get_instance()->a_resume_command_template.argument());
}
};
-
- DepListDepsOption
- enum_arg_to_dep_list_deps_option(const args::EnumArg & arg)
- {
- if (arg.argument() == "pre")
- return dl_deps_pre;
- else if (arg.argument() == "pre-or-post")
- return dl_deps_pre_or_post;
- else if (arg.argument() == "post")
- return dl_deps_post;
- else if (arg.argument() == "try-post")
- return dl_deps_try_post;
- else if (arg.argument() == "discard")
- return dl_deps_discard;
- else
- throw args::DoHelp("bad value for --" + arg.long_name());
- }
}
int
do_install(tr1::shared_ptr<Environment> env)
{
- int return_code(0);
-
Context context("When performing install action from command line:");
DepListOptions options;
+ CommandLine::get_instance()->dl_args.populate_dep_list_options(env.get(), options);
+ CommandLine::get_instance()->install_args.populate_dep_list_options(env.get(), options);
- if (CommandLine::get_instance()->dl_reinstall.specified())
- {
- if (CommandLine::get_instance()->dl_reinstall.argument() == "never")
- options.reinstall = dl_reinstall_never;
- else if (CommandLine::get_instance()->dl_reinstall.argument() == "always")
- options.reinstall = dl_reinstall_always;
- else if (CommandLine::get_instance()->dl_reinstall.argument() == "if-use-changed")
- options.reinstall = dl_reinstall_if_use_changed;
- else
- throw args::DoHelp("bad value for --dl-reinstall");
- }
-
- if (CommandLine::get_instance()->dl_reinstall_scm.specified())
- {
- if (CommandLine::get_instance()->dl_reinstall_scm.argument() == "never")
- options.reinstall_scm = dl_reinstall_scm_never;
- else if (CommandLine::get_instance()->dl_reinstall_scm.argument() == "always")
- options.reinstall_scm = dl_reinstall_scm_always;
- else if (CommandLine::get_instance()->dl_reinstall_scm.argument() == "daily")
- options.reinstall_scm = dl_reinstall_scm_daily;
- else if (CommandLine::get_instance()->dl_reinstall_scm.argument() == "weekly")
- options.reinstall_scm = dl_reinstall_scm_weekly;
- else
- throw args::DoHelp("bad value for --dl-reinstall-scm");
- }
-
- if (CommandLine::get_instance()->dl_upgrade.specified())
- {
- if (CommandLine::get_instance()->dl_upgrade.argument() == "as-needed")
- options.upgrade = dl_upgrade_as_needed;
- else if (CommandLine::get_instance()->dl_upgrade.argument() == "always")
- options.upgrade = dl_upgrade_always;
- else
- throw args::DoHelp("bad value for --dl-upgrade");
- }
-
- if (CommandLine::get_instance()->dl_new_slots.specified())
- {
- if (CommandLine::get_instance()->dl_new_slots.argument() == "as-needed")
- options.new_slots = dl_new_slots_as_needed;
- else if (CommandLine::get_instance()->dl_new_slots.argument() == "always")
- options.new_slots = dl_new_slots_always;
- else
- throw args::DoHelp("bad value for --dl-new-slots");
- }
-
- if (CommandLine::get_instance()->dl_downgrade.specified())
- {
- if (CommandLine::get_instance()->dl_downgrade.argument() == "as-needed")
- options.downgrade = dl_downgrade_as_needed;
- else if (CommandLine::get_instance()->dl_downgrade.argument() == "warning")
- options.downgrade = dl_downgrade_warning;
- else if (CommandLine::get_instance()->dl_downgrade.argument() == "error")
- options.downgrade = dl_downgrade_error;
- else
- throw args::DoHelp("bad value for --dl-downgrade");
- }
-
- if (CommandLine::get_instance()->dl_circular.specified())
- {
- if (CommandLine::get_instance()->dl_circular.argument() == "discard")
- options.circular = dl_circular_discard;
- else if (CommandLine::get_instance()->dl_circular.argument() == "error")
- options.circular = dl_circular_error;
- else
- throw args::DoHelp("bad value for --dl-circular");
- }
-
- if (CommandLine::get_instance()->dl_suggested.specified())
- {
- if (CommandLine::get_instance()->dl_suggested.argument() == "show")
- options.suggested = dl_suggested_show;
- else if (CommandLine::get_instance()->dl_suggested.argument() == "discard")
- options.suggested = dl_suggested_discard;
- else if (CommandLine::get_instance()->dl_suggested.argument() == "install")
- options.suggested = dl_suggested_install;
- else
- throw args::DoHelp("bad value for --dl-suggested");
- }
-
- if (CommandLine::get_instance()->dl_blocks.specified())
- {
- if (CommandLine::get_instance()->dl_blocks.argument() == "discard")
- options.blocks = dl_blocks_discard;
- else if (CommandLine::get_instance()->dl_blocks.argument() == "error")
- options.blocks = dl_blocks_error;
- else if (CommandLine::get_instance()->dl_blocks.argument() == "accumulate")
- options.blocks = dl_blocks_accumulate;
- else
- throw args::DoHelp("bad value for --dl-blocks");
- }
-
- if (CommandLine::get_instance()->dl_override_masks.specified())
- {
- for (args::StringSetArg::ConstIterator a(CommandLine::get_instance()->dl_override_masks.begin_args()),
- a_end(CommandLine::get_instance()->dl_override_masks.end_args()) ; a != a_end ; ++a)
- {
- if (! options.override_masks)
- options.override_masks.reset(new DepListOverrideMasksFunctions);
-
- using namespace tr1::placeholders;
-
- if (*a == "tilde-keyword")
- options.override_masks->push_back(tr1::bind(&override_tilde_keywords, env.get(), _1, _2));
- else if (*a == "unkeyworded")
- options.override_masks->push_back(tr1::bind(&override_unkeyworded, env.get(), _1, _2));
- else if (*a == "repository")
- options.override_masks->push_back(tr1::bind(&override_repository_masks, _2));
- else if (*a == "license")
- options.override_masks->push_back(tr1::bind(&override_license, _2));
- else if (*a == "profile")
- {
- Log::get_instance()->message(ll_warning, lc_no_context, "--dl-override-masks profile is deprecated, use --dl-override-masks repository");
- options.override_masks->push_back(tr1::bind(&override_repository_masks, _2));
- }
- else
- throw args::DoHelp("bad value for --dl-override-masks");
- }
- }
-
- if (CommandLine::get_instance()->dl_fall_back.specified())
- {
- if (CommandLine::get_instance()->dl_fall_back.argument() == "as-needed-except-targets")
- options.fall_back = dl_fall_back_as_needed_except_targets;
- else if (CommandLine::get_instance()->dl_fall_back.argument() == "as-needed")
- options.fall_back = dl_fall_back_as_needed;
- else if (CommandLine::get_instance()->dl_fall_back.argument() == "never")
- options.fall_back = dl_fall_back_never;
- else
- throw args::DoHelp("bad value for --dl-fall-back");
- }
-
- if (CommandLine::get_instance()->dl_deps_default.specified())
- {
- DepListDepsOption x(CommandLine::get_instance()->dl_deps_default.option());
- options.installed_deps_pre = x;
- options.installed_deps_post = x;
- options.installed_deps_runtime = x;
- options.uninstalled_deps_pre = x;
- options.uninstalled_deps_post = x;
- options.uninstalled_deps_runtime = x;
- options.uninstalled_deps_suggested = x;
- }
-
- if (CommandLine::get_instance()->dl_installed_deps_pre.specified())
- options.installed_deps_pre = enum_arg_to_dep_list_deps_option(
- CommandLine::get_instance()->dl_installed_deps_pre);
- if (CommandLine::get_instance()->dl_installed_deps_runtime.specified())
- options.installed_deps_runtime = enum_arg_to_dep_list_deps_option(
- CommandLine::get_instance()->dl_installed_deps_runtime);
- if (CommandLine::get_instance()->dl_installed_deps_post.specified())
- options.installed_deps_post = enum_arg_to_dep_list_deps_option(
- CommandLine::get_instance()->dl_installed_deps_post);
-
- if (CommandLine::get_instance()->dl_uninstalled_deps_pre.specified())
- options.uninstalled_deps_pre = enum_arg_to_dep_list_deps_option(
- CommandLine::get_instance()->dl_uninstalled_deps_pre);
- if (CommandLine::get_instance()->dl_uninstalled_deps_runtime.specified())
- options.uninstalled_deps_runtime = enum_arg_to_dep_list_deps_option(
- CommandLine::get_instance()->dl_uninstalled_deps_runtime);
- if (CommandLine::get_instance()->dl_uninstalled_deps_post.specified())
- options.uninstalled_deps_post = enum_arg_to_dep_list_deps_option(
- CommandLine::get_instance()->dl_uninstalled_deps_post);
- if (CommandLine::get_instance()->dl_uninstalled_deps_suggested.specified())
- options.uninstalled_deps_suggested = enum_arg_to_dep_list_deps_option(
- CommandLine::get_instance()->dl_uninstalled_deps_suggested);
-
- if ((CommandLine::get_instance()->a_show_reasons.argument() == "summary") ||
- (CommandLine::get_instance()->a_show_reasons.argument() == "full"))
- options.dependency_tags = true;
-
- tr1::shared_ptr<const DestinationsSet> destinations;
- if (CommandLine::get_instance()->a_destinations.specified())
- {
- Context local_context("When building destinations collection:");
-
- tr1::shared_ptr<DestinationsSet> d(new DestinationsSet);
- for (args::StringSetArg::ConstIterator i(CommandLine::get_instance()->a_destinations.begin_args()),
- i_end(CommandLine::get_instance()->a_destinations.end_args()) ;
- i != i_end ; ++i)
- {
- tr1::shared_ptr<Repository> repo(env->package_database()->fetch_repository(
- RepositoryName(*i)));
- if (repo->destination_interface)
- d->insert(repo);
- else
- throw args::DoHelp("--destinations argument '" + *i + "' does not provide a destinations interface");
- }
-
- destinations = d;
- }
- else
- destinations = env->default_destinations();
-
- OurInstallTask task(env, options, destinations);
- task.set_no_config_protect(CommandLine::get_instance()->a_no_config_protection.specified());
- task.set_fetch_only(CommandLine::get_instance()->a_fetch.specified());
- task.set_pretend(CommandLine::get_instance()->a_pretend.specified());
- task.set_preserve_world(CommandLine::get_instance()->a_preserve_world.specified());
- task.set_safe_resume(! CommandLine::get_instance()->a_no_safe_resume.specified());
-
- if (CommandLine::get_instance()->dl_reinstall_targets.specified())
- {
- if (CommandLine::get_instance()->dl_reinstall_targets.argument() == "auto")
- {
- }
- else if (CommandLine::get_instance()->dl_reinstall_targets.argument() == "always")
- task.override_target_type(dl_target_package);
- else if (CommandLine::get_instance()->dl_reinstall_targets.argument() == "never")
- task.override_target_type(dl_target_set);
- else
- throw args::DoHelp("bad value for --dl-reinstall-targets");
- }
-
- if (CommandLine::get_instance()->a_add_to_world_spec.specified())
- task.set_add_to_world_spec(CommandLine::get_instance()->a_add_to_world_spec.argument());
-
- if (CommandLine::get_instance()->a_debug_build.specified())
- task.set_debug_mode(CommandLine::get_instance()->a_debug_build.option());
-
- if (CommandLine::get_instance()->a_checks.specified())
- task.set_checks_mode(CommandLine::get_instance()->a_checks.option());
-
- if (CommandLine::get_instance()->a_continue_on_faillure.specified())
- {
- if (CommandLine::get_instance()->a_continue_on_faillure.argument() == "if-fetch-only")
- task.set_continue_on_failure(itcof_if_fetch_only);
- else if (CommandLine::get_instance()->a_continue_on_faillure.argument() == "never")
- task.set_continue_on_failure(itcof_never);
- else if (CommandLine::get_instance()->a_continue_on_faillure.argument() == "if-satisfied")
- task.set_continue_on_failure(itcof_if_satisfied);
- else if (CommandLine::get_instance()->a_continue_on_faillure.argument() == "always")
- task.set_continue_on_failure(itcof_always);
- else
- throw args::DoHelp("bad value for --continue-on-failure");
- }
+ OurInstallTask task(env, options, CommandLine::get_instance()->install_args.destinations(env.get()));
+ CommandLine::get_instance()->install_args.populate_install_task(env.get(), task);
+ CommandLine::get_instance()->dl_args.populate_install_task(env.get(), task);
cout << "Building target list... " << std::flush;
for (CommandLine::ParametersConstIterator q(CommandLine::get_instance()->begin_parameters()),
@@ -520,15 +153,6 @@ do_install(tr1::shared_ptr<Environment> env)
cout << endl;
- if (task.dep_list().has_errors())
- return_code |= 1;
-
- if (task.had_resolution_failures())
- return_code |= 3;
-
- if (task.had_action_failures())
- return_code |= 7;
-
- return return_code;
+ return task.exit_status();
}
diff --git a/src/clients/paludis/paludis.cc b/src/clients/paludis/paludis.cc
index b0e717c..3658dfb 100644
--- a/src/clients/paludis/paludis.cc
+++ b/src/clients/paludis/paludis.cc
@@ -104,48 +104,48 @@ main(int argc, char *argv[])
if (CommandLine::get_instance()->a_dl_no_unnecessary_upgrades.specified())
{
Log::get_instance()->message(ll_warning, lc_no_context, "--dl-no-unnecessary-upgrades / -U is deprecated");
- CommandLine::get_instance()->dl_upgrade.set_argument("as-needed");
- CommandLine::get_instance()->dl_upgrade.set_specified(true);
+ CommandLine::get_instance()->dl_args.dl_upgrade.set_argument("as-needed");
+ CommandLine::get_instance()->dl_args.dl_upgrade.set_specified(true);
}
if (CommandLine::get_instance()->a_dl_drop_all.specified())
{
Log::get_instance()->message(ll_warning, lc_no_context, "--dl-drop-all / -0 is deprecated");
- CommandLine::get_instance()->dl_installed_deps_pre.set_argument("discard");
- CommandLine::get_instance()->dl_installed_deps_pre.set_specified(true);
- CommandLine::get_instance()->dl_installed_deps_post.set_argument("discard");
- CommandLine::get_instance()->dl_installed_deps_post.set_specified(true);
- CommandLine::get_instance()->dl_installed_deps_runtime.set_argument("discard");
- CommandLine::get_instance()->dl_installed_deps_runtime.set_specified(true);
- CommandLine::get_instance()->dl_uninstalled_deps_pre.set_argument("discard");
- CommandLine::get_instance()->dl_uninstalled_deps_pre.set_specified(true);
- CommandLine::get_instance()->dl_uninstalled_deps_post.set_argument("discard");
- CommandLine::get_instance()->dl_uninstalled_deps_post.set_specified(true);
- CommandLine::get_instance()->dl_uninstalled_deps_runtime.set_argument("discard");
- CommandLine::get_instance()->dl_uninstalled_deps_runtime.set_specified(true);
+ CommandLine::get_instance()->dl_args.dl_installed_deps_pre.set_argument("discard");
+ CommandLine::get_instance()->dl_args.dl_installed_deps_pre.set_specified(true);
+ CommandLine::get_instance()->dl_args.dl_installed_deps_post.set_argument("discard");
+ CommandLine::get_instance()->dl_args.dl_installed_deps_post.set_specified(true);
+ CommandLine::get_instance()->dl_args.dl_installed_deps_runtime.set_argument("discard");
+ CommandLine::get_instance()->dl_args.dl_installed_deps_runtime.set_specified(true);
+ CommandLine::get_instance()->dl_args.dl_uninstalled_deps_pre.set_argument("discard");
+ CommandLine::get_instance()->dl_args.dl_uninstalled_deps_pre.set_specified(true);
+ CommandLine::get_instance()->dl_args.dl_uninstalled_deps_post.set_argument("discard");
+ CommandLine::get_instance()->dl_args.dl_uninstalled_deps_post.set_specified(true);
+ CommandLine::get_instance()->dl_args.dl_uninstalled_deps_runtime.set_argument("discard");
+ CommandLine::get_instance()->dl_args.dl_uninstalled_deps_runtime.set_specified(true);
}
if (CommandLine::get_instance()->a_dl_ignore_installed.specified())
{
Log::get_instance()->message(ll_warning, lc_no_context, "--dl-ignore-installed / -e is deprecated");
- CommandLine::get_instance()->dl_reinstall.set_argument("always");
- CommandLine::get_instance()->dl_reinstall.set_specified(true);
+ CommandLine::get_instance()->dl_args.dl_reinstall.set_argument("always");
+ CommandLine::get_instance()->dl_args.dl_reinstall.set_specified(true);
}
if (CommandLine::get_instance()->a_show_install_reasons.specified())
{
Log::get_instance()->message(ll_warning, lc_no_context, "--show-install-reasons is deprecated, use --show-reasons");
- CommandLine::get_instance()->a_show_reasons.set_argument(
+ CommandLine::get_instance()->install_args.a_show_reasons.set_argument(
CommandLine::get_instance()->a_show_install_reasons.argument());
- CommandLine::get_instance()->a_show_reasons.set_specified(true);
+ CommandLine::get_instance()->install_args.a_show_reasons.set_specified(true);
}
if (CommandLine::get_instance()->a_add_to_world_atom.specified())
{
Log::get_instance()->message(ll_warning, lc_no_context, "--add-to-world-atom is deprecated, use --add-to-world-spec");
- CommandLine::get_instance()->a_add_to_world_spec.set_argument(
+ CommandLine::get_instance()->install_args.a_add_to_world_spec.set_argument(
CommandLine::get_instance()->a_add_to_world_atom.argument());
- CommandLine::get_instance()->a_add_to_world_spec.set_specified(true);
+ CommandLine::get_instance()->install_args.a_add_to_world_spec.set_specified(true);
}
if (CommandLine::get_instance()->a_safe_resume.specified())
@@ -276,18 +276,8 @@ main(int argc, char *argv[])
if (CommandLine::get_instance()->a_no_color.specified())
paludis_command.append(" --" + CommandLine::get_instance()->a_no_color.long_name());
- if (CommandLine::get_instance()->a_no_config_protection.specified())
- paludis_command.append(" --" + CommandLine::get_instance()->a_no_config_protection.long_name());
-
- if (CommandLine::get_instance()->a_preserve_world.specified())
- paludis_command.append(" --" + CommandLine::get_instance()->a_preserve_world.long_name());
-
- if (CommandLine::get_instance()->a_debug_build.specified())
- paludis_command.append(" --" + CommandLine::get_instance()->a_debug_build.long_name() + " "
- + CommandLine::get_instance()->a_debug_build.argument());
-
- if (CommandLine::get_instance()->a_no_safe_resume.specified())
- paludis_command.append(" --" + CommandLine::get_instance()->a_no_safe_resume.long_name());
+ paludis_command.append(CommandLine::get_instance()->install_args.paludis_command_fragment());
+ paludis_command.append(CommandLine::get_instance()->dl_args.paludis_command_fragment());
tr1::shared_ptr<Environment> env(EnvironmentMaker::get_instance()->make_from_spec(env_spec));
env->set_paludis_command(paludis_command);
diff --git a/src/clients/paludis/uninstall.cc b/src/clients/paludis/uninstall.cc
index 6130312..6fa524f 100644
--- a/src/clients/paludis/uninstall.cc
+++ b/src/clients/paludis/uninstall.cc
@@ -92,7 +92,7 @@ namespace
virtual void on_display_unmerge_list_entry(const UninstallListEntry & d)
{
if (d.kind == ulk_virtual)
- if (CommandLine::get_instance()->a_show_reasons.argument() != "full")
+ if (CommandLine::get_instance()->install_args.a_show_reasons.argument() != "full")
return;
switch (d.kind)
@@ -115,13 +115,13 @@ namespace
break;
}
- if ((CommandLine::get_instance()->a_show_reasons.argument() == "summary") ||
- (CommandLine::get_instance()->a_show_reasons.argument() == "full") ||
+ if ((CommandLine::get_instance()->install_args.a_show_reasons.argument() == "summary") ||
+ (CommandLine::get_instance()->install_args.a_show_reasons.argument() == "full") ||
ulk_required == d.kind)
{
std::string deps;
unsigned count(0), max_count;
- if (CommandLine::get_instance()->a_show_reasons.argument() == "summary")
+ if (CommandLine::get_instance()->install_args.a_show_reasons.argument() == "summary")
max_count = 3;
else
max_count = std::numeric_limits<long>::max();
@@ -222,9 +222,9 @@ namespace
OurUninstallTask task(env);
- task.set_pretend(CommandLine::get_instance()->a_pretend.specified());
- task.set_no_config_protect(CommandLine::get_instance()->a_no_config_protection.specified());
- task.set_preserve_world(CommandLine::get_instance()->a_preserve_world.specified());
+ task.set_pretend(CommandLine::get_instance()->install_args.a_pretend.specified());
+ task.set_no_config_protect(CommandLine::get_instance()->install_args.a_no_config_protection.specified());
+ task.set_preserve_world(CommandLine::get_instance()->install_args.a_preserve_world.specified());
task.set_with_unused_dependencies(CommandLine::get_instance()->a_with_unused_dependencies.specified());
task.set_with_dependencies(CommandLine::get_instance()->a_with_dependencies.specified());
task.set_check_safety(! CommandLine::get_instance()->a_permit_unsafe_uninstalls.specified());
diff --git a/src/output/console_install_task.cc b/src/output/console_install_task.cc
index ff6c604..a9d54c5 100644
--- a/src/output/console_install_task.cc
+++ b/src/output/console_install_task.cc
@@ -32,6 +32,8 @@
#include <paludis/util/iterator.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/tr1_functional.hh>
+#include <paludis/util/fd_output_stream.hh>
+#include <paludis/util/system.hh>
#include <paludis/query.hh>
#include <paludis/action.hh>
#include <paludis/repository.hh>
@@ -39,6 +41,7 @@
#include <paludis/package_id.hh>
#include <paludis/metadata_key.hh>
#include <paludis/mask.hh>
+#include <paludis/hook.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
@@ -52,6 +55,10 @@
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
using namespace paludis;
using std::cout;
@@ -145,6 +152,19 @@ ConsoleInstallTask::execute()
}
}
+int
+ConsoleInstallTask::exit_status() const
+{
+ int return_code(0);
+ if (dep_list().has_errors())
+ return_code |= 1;
+ if (had_resolution_failures())
+ return_code |= 3;
+ if (had_action_failures())
+ return_code |= 7;
+ return return_code;
+}
+
void
ConsoleInstallTask::on_build_deplist_pre()
{
@@ -1466,3 +1486,101 @@ ConsoleInstallTask::make_x_of_y(const int x, const int y, const int s, const int
return result;
}
+void
+ConsoleInstallTask::show_resume_command() const
+{
+ show_resume_command("");
+}
+
+void
+ConsoleInstallTask::show_resume_command(const std::string & resume_command_template) const
+{
+ const tr1::shared_ptr<const PackageIDSequence> p(packages_not_yet_installed_successfully());
+ if (! p->empty())
+ {
+ std::string resume_command(make_resume_command(*p));
+ if (resume_command.empty())
+ return;
+
+ if (! resume_command_template.empty())
+ {
+ std::string file_name(resume_command_template);
+ int fd;
+ if (std::string::npos == file_name.find("XXXXXX"))
+ fd = open(file_name.c_str(), O_WRONLY | O_CREAT | O_TRUNC);
+ else
+ {
+ char * resume_template = strdup(file_name.c_str());
+ fd = mkstemp(resume_template);
+ file_name = resume_template;
+ std::free(resume_template);
+ }
+
+ if (-1 != fd)
+ {
+ ::fchmod(fd, 0644);
+ FDOutputStream resume_command_file(fd);
+ resume_command_file << resume_command << endl;
+
+ if (resume_command_file)
+ {
+ cerr << endl;
+ cerr << "Resume command saved to file: " << file_name;
+ cerr << endl;
+ }
+ else
+ {
+ cerr << "Resume command NOT saved to file: " << file_name << " due to error "
+ << strerror(errno) << endl;
+ cerr << "Resume command: " << file_name << endl;
+ }
+ }
+ else
+ {
+ cerr << "Resume command NOT saved to file: " << file_name << " due to error "
+ << strerror(errno) << endl;
+ cerr << "Resume command: " << resume_command << endl;
+ }
+ }
+ else
+ {
+ cerr << endl;
+ cerr << "Resume command: " << resume_command << endl;
+ }
+ }
+}
+
+void
+ConsoleInstallTask::on_installed_paludis()
+{
+ std::string r(stringify(environment()->root()));
+ std::string exec_mode(getenv_with_default("PALUDIS_EXEC_PALUDIS", ""));
+
+ if ("always" != exec_mode)
+ {
+ if ("never" == exec_mode)
+ return;
+ else if (! (r.empty() || r == "/"))
+ return;
+ }
+
+ std::string resume_command(make_resume_command(*packages_not_yet_installed_successfully()));
+ if (resume_command.empty())
+ return;
+
+ output_heading("Paludis has just upgraded Paludis");
+ output_starred_item("Using '" + resume_command + "' to start a new Paludis instance...");
+ output_endl();
+
+ execl("/bin/sh", "sh", "-c", resume_command.c_str(), static_cast<const char *>(0));
+}
+
+HookResult
+ConsoleInstallTask::perform_hook(const Hook & hook) const
+{
+ std::string resume_command(make_resume_command(*packages_not_yet_installed_successfully()));
+ if (resume_command.empty())
+ return InstallTask::perform_hook(hook);
+ return InstallTask::perform_hook(hook("RESUME_COMMAND", resume_command));
+}
+
diff --git a/src/output/console_install_task.hh b/src/output/console_install_task.hh
index e4e5b45..2677870 100644
--- a/src/output/console_install_task.hh
+++ b/src/output/console_install_task.hh
@@ -127,6 +127,7 @@ namespace paludis
public:
virtual void execute();
+ int exit_status() const;
virtual std::string make_x_of_y(const int x, const int y, const int s, const int f);
@@ -238,7 +239,11 @@ namespace paludis
Set<UseDescription, UseDescriptionComparator>::ConstIterator);
virtual void display_use_summary_end();
- virtual void show_resume_command() const = 0;
+ virtual void show_resume_command() const;
+ void show_resume_command(const std::string &) const;
+ virtual std::string make_resume_command(const PackageIDSequence &) const = 0;
+ virtual void on_installed_paludis();
+ virtual HookResult perform_hook(const Hook &) const;
///\}