aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-09-04 22:02:27 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-09-04 22:02:27 +0000
commitcbd0cba9208c2712506d35b74974ba61bbe78d1d (patch)
tree86de91c1980cc55d3c952b05c4e3e9196cd9a68b
parentf36205276cc7e0319385647bc50d4a03748ed82a (diff)
downloadpaludis-cbd0cba9208c2712506d35b74974ba61bbe78d1d.tar.gz
paludis-cbd0cba9208c2712506d35b74974ba61bbe78d1d.tar.xz
Move common task code. Clean up headers a bit.
-rw-r--r--paludis/dep_list/dep_list.cc1
-rw-r--r--paludis/dep_list/show_suggest_visitor.cc1
-rw-r--r--paludis/files.m44
-rw-r--r--paludis/package_database-fwd.hh41
-rw-r--r--paludis/package_database.cc30
-rw-r--r--paludis/package_database.hh29
-rw-r--r--paludis/query-fwd.hh62
-rw-r--r--paludis/query.cc1
-rw-r--r--paludis/query.hh30
-rw-r--r--paludis/repositories/e/e_repository_sets.cc1
-rw-r--r--paludis/tasks/find_unused_packages_task.cc1
-rw-r--r--paludis/tasks/install_task.cc87
-rw-r--r--paludis/tasks/install_task.hh43
-rw-r--r--paludis/tasks/report_task.cc1
-rw-r--r--python/query.cc1
-rw-r--r--ruby/package_database.cc57
-rw-r--r--ruby/package_database_TEST.rb22
-rw-r--r--src/clients/accerso/accerso.cc1
-rw-r--r--src/clients/adjutrix/downgrade_check.cc1
-rw-r--r--src/clients/adjutrix/find_insecure_packages.cc1
-rw-r--r--src/clients/adjutrix/find_reverse_deps.cc1
-rw-r--r--src/clients/adjutrix/keywords_graph.cc1
-rw-r--r--src/clients/contrarius/install.cc237
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/packages_list_model.cc1
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/version_info_model.cc1
-rw-r--r--src/clients/inquisitio/do_search.cc1
-rw-r--r--src/clients/instruo/instruo.cc1
-rw-r--r--src/clients/paludis/install.cc322
-rw-r--r--src/output/console_install_task.cc174
-rw-r--r--src/output/console_install_task.hh13
30 files changed, 572 insertions, 595 deletions
diff --git a/paludis/dep_list/dep_list.cc b/paludis/dep_list/dep_list.cc
index 74f5864..62fb54e 100644
--- a/paludis/dep_list/dep_list.cc
+++ b/paludis/dep_list/dep_list.cc
@@ -31,6 +31,7 @@
#include <paludis/match_package.hh>
#include <paludis/metadata_key.hh>
#include <paludis/query.hh>
+#include <paludis/package_id.hh>
#include <paludis/version_requirements.hh>
#include <paludis/util/iterator.hh>
diff --git a/paludis/dep_list/show_suggest_visitor.cc b/paludis/dep_list/show_suggest_visitor.cc
index 0bb57e4..f86c398 100644
--- a/paludis/dep_list/show_suggest_visitor.cc
+++ b/paludis/dep_list/show_suggest_visitor.cc
@@ -21,6 +21,7 @@
#include <paludis/dep_list/dep_list.hh>
#include <paludis/dep_list/condition_tracker.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/package_id.hh>
#include <paludis/query.hh>
#include <paludis/package_database.hh>
#include <paludis/util/log.hh>
diff --git a/paludis/files.m4 b/paludis/files.m4
index 01cee1b..da5cc12 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -27,11 +27,11 @@ add(`mask', `hh', `cc', `fwd', `sr')
add(`match_package', `hh', `cc')
add(`metadata_key', `hh', `cc', `se', `fwd')
add(`name', `hh', `cc', `fwd', `test', `sr', `se')
-add(`package_database', `hh', `cc', `test', `se')
+add(`package_database', `hh', `cc', `fwd', `test', `se')
add(`package_id', `hh', `cc', `fwd', `se')
add(`paludis', `hh')
add(`qa', `hh', `cc', `fwd', `se', `sr')
-add(`query', `hh', `cc')
+add(`query', `hh', `cc', `fwd')
add(`repository', `hh', `fwd', `cc', `sr')
add(`repository_info', `hh', `fwd', `cc')
add(`repository_name_cache', `hh', `cc', `test', `testscript')
diff --git a/paludis/package_database-fwd.hh b/paludis/package_database-fwd.hh
new file mode 100644
index 0000000..d0745b3
--- /dev/null
+++ b/paludis/package_database-fwd.hh
@@ -0,0 +1,41 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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_PALUDIS_PACKAGE_DATABASE_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_PACKAGE_DATABASE_FWD_HH 1
+
+#include <iosfwd>
+#include <paludis/util/attributes.hh>
+
+namespace paludis
+{
+ class PackageDatabaseError;
+ class PackageDatabaseLookupError;
+ class AmbiguousPackageNameError;
+ class DuplicateRepositoryError;
+ class NoSuchPackageError;
+ class NonUniqueQueryResultError;
+ class NoSuchRepositoryError;
+
+#include <paludis/package_database-se.hh>
+
+ class PackageDatabase;
+}
+
+#endif
diff --git a/paludis/package_database.cc b/paludis/package_database.cc
index 5e74fe4..27ef9c8 100644
--- a/paludis/package_database.cc
+++ b/paludis/package_database.cc
@@ -20,6 +20,7 @@
#include <paludis/dep_spec.hh>
#include <paludis/match_package.hh>
#include <paludis/package_database.hh>
+#include <paludis/package_id.hh>
#include <paludis/util/iterator.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/stringify.hh>
@@ -498,32 +499,3 @@ PackageDatabase::end_repositories() const
return RepositoryIterator(_imp->repositories.end());
}
-std::ostream &
-paludis::operator<< (std::ostream & o, const InstallState & s)
-{
- do
- {
- switch (s)
- {
- case is_installed_only:
- o << "installed_only";
- continue;
-
- case is_installable_only:
- o << "installable_only";
- continue;
-
- case is_any:
- o << "any";
- continue;
-
- case last_is:
- ;
- }
-
- throw InternalError(PALUDIS_HERE, "Bad InstallState");
- } while (false);
-
- return o;
-}
-
diff --git a/paludis/package_database.hh b/paludis/package_database.hh
index d7243fd..913f5fe 100644
--- a/paludis/package_database.hh
+++ b/paludis/package_database.hh
@@ -20,9 +20,11 @@
#ifndef PALUDIS_GUARD_PALUDIS_PACKAGE_DATABASE_HH
#define PALUDIS_GUARD_PALUDIS_PACKAGE_DATABASE_HH 1
+#include <paludis/package_database-fwd.hh>
#include <paludis/dep_spec.hh>
#include <paludis/name.hh>
#include <paludis/repository.hh>
+#include <paludis/query-fwd.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/iterator.hh>
#include <paludis/util/instantiation_policy.hh>
@@ -43,10 +45,6 @@
namespace paludis
{
- class PackageDepSpec;
- class Query;
- class Environment;
-
/**
* A PackageDatabaseError is an error that occurs when performing some
* operation upon a PackageDatabase.
@@ -230,21 +228,6 @@ namespace paludis
};
/**
- * Do we want installed, installable or either when querying?
- *
- * \ingroup grppackagedatabase
- */
- enum InstallState
- {
- is_installed_only, ///< Installed only
- is_installable_only, ///< Installable only
- is_any, ///< Either
- last_is
- } PALUDIS_ATTRIBUTE((deprecated));
-
-#include <paludis/package_database-se.hh>
-
- /**
* A PackageDatabase can be queried for Package instances.
*
* \ingroup grppackagedatabase
@@ -335,14 +318,6 @@ namespace paludis
///\}
};
-
- /**
- * Write an InstallState to a stream.
- *
- * \ingroup grppackagedatabase
- */
- std::ostream &
- operator<< (std::ostream &, const InstallState &) PALUDIS_VISIBLE;
}
#endif
diff --git a/paludis/query-fwd.hh b/paludis/query-fwd.hh
new file mode 100644
index 0000000..552bcb7
--- /dev/null
+++ b/paludis/query-fwd.hh
@@ -0,0 +1,62 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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_PALUDIS_QUERY_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_QUERY_FWD_HH 1
+
+#include <iosfwd>
+#include <paludis/util/attributes.hh>
+
+namespace paludis
+{
+ class QueryDelegate;
+ class Query;
+
+ namespace query
+ {
+ class Matches;
+ class Package;
+ class Repository;
+ class Category;
+ class NotMasked;
+ template <typename A_> class SupportsAction;
+ class InstalledAtRoot;
+ class All;
+ }
+
+ /**
+ * Create a Query that returns packages for which both Query parameters
+ * hold.
+ *
+ * \see Query
+ * \see PackageDatabase::query
+ * \ingroup grpquery
+ */
+ Query operator& (const Query &, const Query &) PALUDIS_VISIBLE;
+
+ /**
+ * Output a human-readable description of a Query.
+ *
+ * \see Query
+ * \ingroup grpquery
+ */
+ std::ostream & operator<< (std::ostream &, const Query &) PALUDIS_VISIBLE;
+}
+
+#endif
diff --git a/paludis/query.cc b/paludis/query.cc
index afba7f8..1b8757e 100644
--- a/paludis/query.cc
+++ b/paludis/query.cc
@@ -28,6 +28,7 @@
#include <paludis/environment.hh>
#include <paludis/match_package.hh>
#include <paludis/action.hh>
+#include <paludis/package_id.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
#include <algorithm>
diff --git a/paludis/query.hh b/paludis/query.hh
index 9e6bc97..d795532 100644
--- a/paludis/query.hh
+++ b/paludis/query.hh
@@ -20,8 +20,12 @@
#ifndef PALUDIS_GUARD_PALUDIS_QUERY_HH
#define PALUDIS_GUARD_PALUDIS_QUERY_HH 1
-#include <paludis/name.hh>
-#include <paludis/package_id.hh>
+#include <paludis/name-fwd.hh>
+#include <paludis/query-fwd.hh>
+#include <paludis/package_id-fwd.hh>
+#include <paludis/environment-fwd.hh>
+#include <paludis/dep_spec-fwd.hh>
+#include <paludis/util/fs_entry-fwd.hh>
#include <iosfwd>
/** \file
@@ -32,10 +36,6 @@
namespace paludis
{
- class Environment;
- class PackageDepSpec;
- class FSEntry;
-
/**
* A QueryDelegate subclass is used by Query to provide the information
* needed by PackageDatabase::query.
@@ -330,24 +330,6 @@ namespace paludis
///}
};
}
-
- /**
- * Create a Query that returns packages for which both Query parameters
- * hold.
- *
- * \see Query
- * \see PackageDatabase::query
- * \ingroup grpquery
- */
- Query operator& (const Query &, const Query &) PALUDIS_VISIBLE;
-
- /**
- * Output a human-readable description of a Query.
- *
- * \see Query
- * \ingroup grpquery
- */
- std::ostream & operator<< (std::ostream &, const Query &) PALUDIS_VISIBLE;
}
#endif
diff --git a/paludis/repositories/e/e_repository_sets.cc b/paludis/repositories/e/e_repository_sets.cc
index 9fa4d79..f256bdb 100644
--- a/paludis/repositories/e/e_repository_sets.cc
+++ b/paludis/repositories/e/e_repository_sets.cc
@@ -28,6 +28,7 @@
#include <paludis/query.hh>
#include <paludis/set_file.hh>
#include <paludis/dep_tag.hh>
+#include <paludis/package_id.hh>
#include <paludis/version_operator.hh>
#include <paludis/version_requirements.hh>
#include <paludis/util/dir_iterator.hh>
diff --git a/paludis/tasks/find_unused_packages_task.cc b/paludis/tasks/find_unused_packages_task.cc
index 3f66d12..1612c76 100644
--- a/paludis/tasks/find_unused_packages_task.cc
+++ b/paludis/tasks/find_unused_packages_task.cc
@@ -24,6 +24,7 @@
#include <paludis/query.hh>
#include <paludis/package_database.hh>
#include <paludis/metadata_key.hh>
+#include <paludis/package_id.hh>
#include <paludis/util/tokeniser.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/set.hh>
diff --git a/paludis/tasks/install_task.cc b/paludis/tasks/install_task.cc
index 31d69be..a7124b7 100644
--- a/paludis/tasks/install_task.cc
+++ b/paludis/tasks/install_task.cc
@@ -27,6 +27,7 @@
#include <paludis/hook.hh>
#include <paludis/repository.hh>
#include <paludis/package_database.hh>
+#include <paludis/package_id.hh>
#include <paludis/tasks/exceptions.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/tokeniser.hh>
@@ -63,6 +64,9 @@ namespace paludis
bool had_package_targets;
bool override_target_type;
+ bool had_action_failures;
+ bool had_resolution_failures;
+
Implementation<InstallTask>(Environment * const e, const DepListOptions & o,
tr1::shared_ptr<const DestinationsSet> d) :
env(e),
@@ -88,7 +92,9 @@ namespace paludis
preserve_world(false),
had_set_targets(false),
had_package_targets(false),
- override_target_type(false)
+ override_target_type(false),
+ had_action_failures(false),
+ had_resolution_failures(false)
{
}
};
@@ -112,6 +118,8 @@ InstallTask::clear()
_imp->had_package_targets = false;
_imp->dep_list.clear();
_imp->raw_targets.clear();
+ _imp->had_action_failures = false;
+ _imp->had_package_targets = false;
}
void
@@ -128,10 +136,16 @@ InstallTask::add_target(const std::string & target)
if ((target != "insecurity") && ((s = ((_imp->env->set(SetName(target)))))))
{
if (_imp->had_set_targets)
+ {
+ _imp->had_resolution_failures = true;
throw MultipleSetTargetsSpecified();
+ }
if (_imp->had_package_targets)
+ {
+ _imp->had_resolution_failures = true;
throw HadBothPackageAndSetTargets();
+ }
_imp->had_set_targets = true;
if (! _imp->override_target_type)
@@ -149,7 +163,10 @@ InstallTask::add_target(const std::string & target)
Log::get_instance()->message(ll_debug, lc_context) << "target '" << target << "' is a package";
if (_imp->had_set_targets)
+ {
+ _imp->had_resolution_failures = true;
throw HadBothPackageAndSetTargets();
+ }
_imp->had_package_targets = true;
if (! _imp->override_target_type)
@@ -179,7 +196,7 @@ InstallTask::add_target(const std::string & target)
}
void
-InstallTask::execute()
+InstallTask::_execute()
{
Context context("When executing install task:");
@@ -516,6 +533,60 @@ InstallTask::execute()
}
}
+void
+InstallTask::execute()
+{
+ try
+ {
+ _execute();
+ }
+ catch (const AmbiguousPackageNameError & e)
+ {
+ _imp->had_resolution_failures = true;
+ on_ambiguous_package_name_error(e);
+ }
+ catch (const InstallActionError & e)
+ {
+ _imp->had_action_failures = true;
+ on_install_action_error(e);
+ }
+ catch (const FetchActionError & e)
+ {
+ _imp->had_action_failures = true;
+ on_fetch_action_error(e);
+ }
+ catch (const NoSuchPackageError & e)
+ {
+ _imp->had_resolution_failures = true;
+ on_no_such_package_error(e);
+ }
+ catch (const AllMaskedError & e)
+ {
+ _imp->had_resolution_failures = true;
+ on_all_masked_error(e);
+ }
+ catch (const UseRequirementsNotMetError & e)
+ {
+ _imp->had_resolution_failures = true;
+ on_use_requirements_not_met_error(e);
+ }
+ catch (const DepListError & e)
+ {
+ _imp->had_resolution_failures = true;
+ on_dep_list_error(e);
+ }
+ catch (const HadBothPackageAndSetTargets & e)
+ {
+ _imp->had_resolution_failures = true;
+ on_had_both_package_and_set_targets_error(e);
+ }
+ catch (const MultipleSetTargetsSpecified & e)
+ {
+ _imp->had_resolution_failures = true;
+ on_multiple_set_targets_specified(e);
+ }
+}
+
const DepList &
InstallTask::dep_list() const
{
@@ -705,3 +776,15 @@ InstallTask::world_update_packages(tr1::shared_ptr<const SetSpecTree::ConstItem>
}
}
+bool
+InstallTask::had_action_failures() const
+{
+ return _imp->had_action_failures;
+}
+
+bool
+InstallTask::had_resolution_failures() const
+{
+ return _imp->had_resolution_failures;
+}
+
diff --git a/paludis/tasks/install_task.hh b/paludis/tasks/install_task.hh
index c94823b..73e74a7 100644
--- a/paludis/tasks/install_task.hh
+++ b/paludis/tasks/install_task.hh
@@ -23,8 +23,11 @@
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/dep_list/dep_list.hh>
+#include <paludis/dep_list/exceptions.hh>
+#include <paludis/tasks/exceptions.hh>
#include <paludis/repository-fwd.hh>
#include <paludis/action-fwd.hh>
+#include <paludis/package_database-fwd.hh>
#include <libwrapiter/libwrapiter_forward_iterator-fwd.hh>
namespace paludis
@@ -41,6 +44,9 @@ namespace paludis
PrivateImplementationPattern<InstallTask>,
InstantiationPolicy<InstallTask, instantiation_method::NonCopyableTag>
{
+ private:
+ void _execute();
+
protected:
///\name Basic operations
///\{
@@ -77,13 +83,13 @@ namespace paludis
void add_target(const std::string &);
void clear();
- bool had_set_targets() const;
- bool had_package_targets() const;
+ bool had_set_targets() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ bool had_package_targets() const PALUDIS_ATTRIBUTE((warn_unused_result));
void override_target_type(const DepListTargetType);
typedef libwrapiter::ForwardIterator<InstallTask, const std::string> TargetsIterator;
- TargetsIterator begin_targets() const;
- TargetsIterator end_targets() const;
+ TargetsIterator begin_targets() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ TargetsIterator end_targets() const PALUDIS_ATTRIBUTE((warn_unused_result));
///\}
@@ -135,6 +141,17 @@ namespace paludis
virtual void on_installed_paludis();
+ virtual void on_ambiguous_package_name_error(const AmbiguousPackageNameError &) = 0;
+ virtual void on_no_such_package_error(const NoSuchPackageError &) = 0;
+ virtual void on_all_masked_error(const AllMaskedError &) = 0;
+ virtual void on_use_requirements_not_met_error(const UseRequirementsNotMetError &) = 0;
+ virtual void on_dep_list_error(const DepListError &) = 0;
+ virtual void on_had_both_package_and_set_targets_error(const HadBothPackageAndSetTargets &) = 0;
+ virtual void on_multiple_set_targets_specified(const MultipleSetTargetsSpecified &) = 0;
+
+ virtual void on_install_action_error(const InstallActionError &) = 0;
+ virtual void on_fetch_action_error(const FetchActionError &) = 0;
+
///\}
///\name Logic
@@ -153,28 +170,38 @@ namespace paludis
/**
* Fetch our deplist.
*/
- const DepList & dep_list() const;
+ const DepList & dep_list() const PALUDIS_ATTRIBUTE((warn_unused_result));
/**
* Fetch our current deplist entry.
*/
- DepList::Iterator current_dep_list_entry() const;
+ DepList::Iterator current_dep_list_entry() const PALUDIS_ATTRIBUTE((warn_unused_result));
/**
* Fetch our environment.
*/
- Environment * environment();
+ Environment * environment() PALUDIS_ATTRIBUTE((warn_unused_result));
/**
* Fetch our environment.
*/
- const Environment * environment() const;
+ const Environment * environment() const PALUDIS_ATTRIBUTE((warn_unused_result));
/**
* Perform a hook. By default, delegates to environment.
*/
virtual HookResult perform_hook(const Hook &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ /**
+ * Have we had any resolution failures?
+ */
+ virtual bool had_resolution_failures() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ /**
+ * Have we had any action failures?
+ */
+ virtual bool had_action_failures() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
}
diff --git a/paludis/tasks/report_task.cc b/paludis/tasks/report_task.cc
index d2f7a97..3d0e877 100644
--- a/paludis/tasks/report_task.cc
+++ b/paludis/tasks/report_task.cc
@@ -24,6 +24,7 @@
#include <paludis/query.hh>
#include <paludis/metadata_key.hh>
#include <paludis/dep_tag.hh>
+#include <paludis/package_id.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/set.hh>
diff --git a/python/query.cc b/python/query.cc
index c3bafba..d6d1d51 100644
--- a/python/query.cc
+++ b/python/query.cc
@@ -22,6 +22,7 @@
#include <paludis/query.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/action.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/environment.hh>
diff --git a/ruby/package_database.cc b/ruby/package_database.cc
index 2910e0f..82f65be 100644
--- a/ruby/package_database.cc
+++ b/ruby/package_database.cc
@@ -33,7 +33,6 @@ using namespace paludis::ruby;
namespace
{
static VALUE c_package_database;
- static VALUE c_package_database_install_state;
static VALUE c_package_database_query_order;
/*
@@ -94,7 +93,7 @@ namespace
tr1::shared_ptr<const PackageIDSequence> items;
try
{
- if (2 == argc && is_kind_of_query(argv[0]))
+ if (2 == argc)
{
Query q = value_to_query(argv[0]);
QueryOrder qo = static_cast<QueryOrder>(NUM2INT(argv[1]));
@@ -104,48 +103,8 @@ namespace
items = ((*self_ptr)->query(q, qo));
}
- else if (2 == argc || 3 == argc)
- {
- QueryOrder qo;
- Query q = query::Matches(*value_to_package_dep_spec(argv[0]));
- InstallState is = static_cast<InstallState>(NUM2INT(argv[1]));
-
- switch (is)
- {
- case is_installed_only:
- q = q & query::SupportsAction<InstalledAction>();
- break;
-
- case is_installable_only:
- q = q & query::SupportsAction<InstallAction>();
- break;
-
- case is_any:
- case last_is:
- ;
-
- }
- if (2 ==argc)
- {
- qo = qo_order_by_version;
- rb_warn("Calling query with (PackageDepSpec, InstallState) has been deprecated");
- }
- else
- {
- qo = static_cast<QueryOrder>(NUM2INT(argv[2]));
- rb_warn("Calling query with (PackageDepSpec, InstallState, QueryOrder) has been deprecated");
- }
-
- tr1::shared_ptr<PackageDatabase> * self_ptr;
- Data_Get_Struct(self, tr1::shared_ptr<PackageDatabase>, self_ptr);
-
- items = ((*self_ptr)->query(q, qo));
-
- }
else
- {
- rb_raise(rb_eArgError, "query expects two or three arguments, but got %d",argc);
- }
+ rb_raise(rb_eArgError, "query expects two arguments, but got %d",argc);
}
catch (const std::exception & e)
{
@@ -261,18 +220,6 @@ namespace
RUBY_FUNC_CAST(&package_database_more_important_than), 2);
/*
- * Document-module: Paludis::InstallState
- *
- * Do we want only installed packages, only installable packages, or any package when querying?
- */
- c_package_database_install_state = rb_define_module_under(paludis_module(), "InstallState");
- for (InstallState l(static_cast<InstallState>(0)), l_end(last_is) ; l != l_end ;
- l = static_cast<InstallState>(static_cast<int>(l) + 1))
- rb_define_const(c_package_database_install_state, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
-
- // cc_enum_special<paludis/package_database.hh, InstallState, c_package_database_install_state>
-
- /*
* Document-module: Paludis::QueryOrder
*
* How to order query results.
diff --git a/ruby/package_database_TEST.rb b/ruby/package_database_TEST.rb
index 053b5b5..1f70f05 100644
--- a/ruby/package_database_TEST.rb
+++ b/ruby/package_database_TEST.rb
@@ -90,15 +90,6 @@ module Paludis
db.query(1);
end
- #outputs a deprecation warning
- assert_nothing_raised do
- db.query(pda, InstallState::Any)
- end
-
- assert_nothing_raised do
- db.query(pda, InstallState::Any, QueryOrder::Whatever)
- end
-
assert_nothing_raised do
db.query(Query::Matches.new(pda), QueryOrder::Whatever)
end
@@ -109,7 +100,7 @@ module Paludis
end
def test_package_database_query
- a = db.query(pda, InstallState::InstallableOnly, QueryOrder::Whatever)
+ a = db.query(Query::Matches.new(pda), QueryOrder::Whatever)
assert_kind_of Array, a
assert_equal 1, a.length
pid = a.first
@@ -128,7 +119,7 @@ module Paludis
assert_equal '1.0', pid.version.to_s
assert_equal 'testrepo', pid.repository_name
- a = db.query(pda, InstallState::Any, QueryOrder::Whatever)
+ a = db.query(Query::Matches.new(pda), QueryOrder::Whatever)
assert_kind_of Array, a
assert_equal 1, a.length
pid = a.first
@@ -137,7 +128,7 @@ module Paludis
assert_equal '1.0', pid.version.to_s
assert_equal 'testrepo', pid.repository_name
- a = db.query(pda2, InstallState::InstallableOnly, QueryOrder::OrderByVersion)
+ a = db.query(Query::Matches.new(pda2) & Query::SupportsInstallAction.new, QueryOrder::OrderByVersion)
assert_kind_of Array, a
assert_equal 2, a.length
pid = a.shift
@@ -167,16 +158,17 @@ module Paludis
assert_equal pid.repository_name, pid2.repository_name
- a = db.query(PackageDepSpec.new('>=foo/bar-27',PackageDepSpecParseMode::Permissive), InstallState::InstallableOnly, QueryOrder::Whatever)
+ a = db.query(Query::Matches.new(PackageDepSpec.new('>=foo/bar-27',PackageDepSpecParseMode::Permissive)),
+ QueryOrder::Whatever)
assert a.empty?
- a = db.query(pda2, InstallState::InstalledOnly, QueryOrder::Whatever)
+ a = db.query(Query::Matches.new(pda2) & Query::SupportsInstalledAction.new, QueryOrder::Whatever)
assert a.empty?
end
def test_package_database_query_bad
assert_raise TypeError do
- db.query(123, InstallState::Any)
+ db.query(123, QueryOrder::Whatever)
end
assert_raise TypeError do
db.query(pda2, "Either")
diff --git a/src/clients/accerso/accerso.cc b/src/clients/accerso/accerso.cc
index 4d5660a..994d77e 100644
--- a/src/clients/accerso/accerso.cc
+++ b/src/clients/accerso/accerso.cc
@@ -22,6 +22,7 @@
#include "command_line.hh"
#include <paludis/about.hh>
#include <paludis/action.hh>
+#include <paludis/package_id.hh>
#include <paludis/util/join.hh>
#include <paludis/util/log.hh>
#include <paludis/util/fs_entry.hh>
diff --git a/src/clients/adjutrix/downgrade_check.cc b/src/clients/adjutrix/downgrade_check.cc
index a55f498..e5d9a36 100644
--- a/src/clients/adjutrix/downgrade_check.cc
+++ b/src/clients/adjutrix/downgrade_check.cc
@@ -24,6 +24,7 @@
#include <paludis/util/sr.hh>
#include <paludis/util/tokeniser.hh>
#include <paludis/util/sequence.hh>
+#include <paludis/package_id.hh>
#include <fstream>
#include <iostream>
#include <vector>
diff --git a/src/clients/adjutrix/find_insecure_packages.cc b/src/clients/adjutrix/find_insecure_packages.cc
index 23d1c1d..8a0d0dd 100644
--- a/src/clients/adjutrix/find_insecure_packages.cc
+++ b/src/clients/adjutrix/find_insecure_packages.cc
@@ -24,6 +24,7 @@
#include <paludis/query.hh>
#include <paludis/dep_spec.hh>
#include <paludis/dep_tag.hh>
+#include <paludis/package_id.hh>
#include <paludis/package_database.hh>
#include <paludis/util/visitor-impl.hh>
diff --git a/src/clients/adjutrix/find_reverse_deps.cc b/src/clients/adjutrix/find_reverse_deps.cc
index 80872c3..76ff391 100644
--- a/src/clients/adjutrix/find_reverse_deps.cc
+++ b/src/clients/adjutrix/find_reverse_deps.cc
@@ -28,6 +28,7 @@
#include <paludis/util/sequence.hh>
#include <paludis/query.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/package_id.hh>
#include <paludis/package_database.hh>
#include <paludis/metadata_key.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
diff --git a/src/clients/adjutrix/keywords_graph.cc b/src/clients/adjutrix/keywords_graph.cc
index 93a80ff..b894ec7 100644
--- a/src/clients/adjutrix/keywords_graph.cc
+++ b/src/clients/adjutrix/keywords_graph.cc
@@ -30,6 +30,7 @@
#include <paludis/repository.hh>
#include <paludis/package_database.hh>
#include <paludis/metadata_key.hh>
+#include <paludis/package_id.hh>
#include <set>
#include <map>
diff --git a/src/clients/contrarius/install.cc b/src/clients/contrarius/install.cc
index 84d896d..b3f50c6 100644
--- a/src/clients/contrarius/install.cc
+++ b/src/clients/contrarius/install.cc
@@ -41,6 +41,7 @@
#include <paludis/metadata_key.hh>
#include <paludis/mask.hh>
#include <paludis/action.hh>
+#include <paludis/package_id.hh>
/** \file
* Handle the --install action for the contrarius program.
@@ -98,49 +99,49 @@ namespace
{
return false;
}
- };
-
- void show_resume_command(tr1::shared_ptr<Environment> env, const InstallTask & task)
- {
- if (CommandLine::get_instance()->a_fetch.specified() ||
- CommandLine::get_instance()->a_pretend.specified())
- return;
- if (task.current_dep_list_entry() != task.dep_list().end())
- {
- std::string resume_command = env->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 (DepList::Iterator i(task.current_dep_list_entry()), i_end(task.dep_list().end()) ;
- i != i_end ; ++i)
- if (dlk_package == i->kind)
- resume_command = resume_command + " '=" + stringify(*i->package_id) + "'";
-
- if (CommandLine::get_instance()->a_resume_command_template.specified())
+ virtual void show_resume_command() const
{
- 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);
+ if (CommandLine::get_instance()->a_fetch.specified() ||
+ CommandLine::get_instance()->a_pretend.specified())
+ return;
+
+ if (current_dep_list_entry() != dep_list().end())
+ {
+ 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 (DepList::Iterator i(current_dep_list_entry()), i_end(dep_list().end()) ;
+ i != i_end ; ++i)
+ if (dlk_package == i->kind)
+ resume_command = resume_command + " '=" + stringify(*i->package_id) + "'";
+
+ 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;
+ }
}
- else
- cerr << "Resume command: " << resume_command << endl;
- }
- }
+ };
class InstallKilledCatcher
{
private:
- static const InstallTask * _task;
+ static const ConsoleInstallTask * _task;
static tr1::shared_ptr<Environment> _env;
@@ -149,7 +150,7 @@ namespace
sig_t _old;
public:
- InstallKilledCatcher(tr1::shared_ptr<Environment> env, const InstallTask & task) :
+ InstallKilledCatcher(tr1::shared_ptr<Environment> env, const ConsoleInstallTask & task) :
_old(signal(SIGINT, &InstallKilledCatcher::_signal_handler))
{
_task = &task;
@@ -163,7 +164,7 @@ namespace
}
};
- const InstallTask * InstallKilledCatcher::_task(0);
+ const ConsoleInstallTask * InstallKilledCatcher::_task(0);
tr1::shared_ptr<Environment> InstallKilledCatcher::_env;
void
@@ -195,7 +196,7 @@ namespace
;
cerr << endl;
if (_task)
- show_resume_command(_env, *_task);
+ _task->show_resume_command();
cerr << endl;
cerr << "Exiting with failure" << endl;
exit(EXIT_FAILURE);
@@ -239,162 +240,20 @@ do_install(tr1::shared_ptr<Environment> env, std::string spec_str)
throw DoHelp("bad value for --debug-build");
}
- try
- {
- task.add_target(spec_str);
-
- task.execute();
-
- cout << endl;
-
- if (task.dep_list().has_errors())
- return_code |= 1;
- }
- catch (const AmbiguousPackageNameError & e)
- {
- cout << endl;
- cerr << "Query error:" << endl;
- cerr << " * " << e.backtrace("\n * ");
- cerr << "Ambiguous package name '" << e.name() << "'. Did you mean:" << endl;
- for (AmbiguousPackageNameError::OptionsIterator o(e.begin_options()),
- o_end(e.end_options()) ; o != o_end ; ++o)
- cerr << " * " << colour(cl_package_name, *o) << endl;
- cerr << endl;
- return 1;
- }
- catch (const InstallActionError & e)
- {
- cout << endl;
- cerr << "Install error:" << endl;
- cerr << " * " << e.backtrace("\n * ");
- cerr << e.message() << endl;
- cerr << endl;
-
- return_code |= 1;
- }
- catch (const FetchActionError & e)
- {
- cout << endl;
- cerr << "Fetch error:" << endl;
- cerr << " * " << e.backtrace("\n * ");
- cerr << e.message() << endl;
- cerr << endl;
- if (e.failures())
- {
- for (Sequence<FetchActionFailure>::Iterator f(e.failures()->begin()), f_end(e.failures()->end()) ;
- f != f_end ; ++f)
- {
- cerr << " * File '" << f->target_file << "': ";
-
- bool need_comma(false);
- if (f->requires_manual_fetching)
- {
- cerr << "requires manual fetching";
- need_comma = true;
- }
-
- if (f->failed_automatic_fetching)
- {
- if (need_comma)
- cerr << ", ";
- cerr << "failed automatic fetching";
- need_comma = true;
- }
+ task.add_target(spec_str);
- if (! f->failed_integrity_checks.empty())
- {
- if (need_comma)
- cerr << "failed automatic fetching";
- cerr << "failed integrity checks: " << f->failed_integrity_checks;
- need_comma = true;
- }
+ task.execute();
- cerr << endl;
- }
- }
+ cout << endl;
+ if (task.dep_list().has_errors())
return_code |= 1;
- }
- catch (const NoSuchPackageError & e)
- {
- cout << endl;
- cerr << "Query error:" << endl;
- cerr << " * " << e.backtrace("\n * ");
- cerr << "No such package '" << e.name() << "'" << endl;
- return 1;
- }
- catch (const AllMaskedError & e)
- {
- try
- {
- tr1::shared_ptr<const PackageIDSequence> p(
- env->package_database()->query(
- query::Matches(e.query()) &
- query::SupportsAction<InstallAction>(),
- qo_order_by_version));
- if (p->empty())
- {
- cout << endl;
- cerr << "Query error:" << endl;
- cerr << " * " << e.backtrace("\n * ");
- cerr << "All versions of '" << e.query() << "' are masked" << endl;
- }
- else
- {
- cout << endl;
- cerr << "Query error:" << endl;
- cerr << " * " << e.backtrace("\n * ");
- cerr << "All versions of '" << e.query() << "' are masked. Candidates are:" << endl;
- for (PackageIDSequence::Iterator pp(p->begin()), pp_end(p->end()) ;
- pp != pp_end ; ++pp)
- {
- cerr << " * " << colour(cl_package_name, **pp) << ": Masked by ";
+ if (task.had_resolution_failures())
+ return_code |= 3;
- bool need_comma(false);
- for (PackageID::MasksIterator m((*pp)->begin_masks()), m_end((*pp)->end_masks()) ;
- m != m_end ; ++m)
- {
- if (need_comma)
- cerr << ", ";
- cerr << (*m)->description();
- need_comma = true;
- }
- cerr << endl;
- }
- }
- }
- catch (...)
- {
- throw e;
- }
-
- return 1;
- }
- catch (const UseRequirementsNotMetError & e)
- {
- cout << endl;
- cerr << "DepList USE requirements not met error:" << endl;
- cerr << " * " << e.backtrace("\n * ") << e.message() << endl;
- cerr << endl;
- cerr << "This error usually indicates that one of the packages you are trying to" << endl;
- cerr << "install requires that another package be built with particular USE flags" << endl;
- cerr << "enabled or disabled. You may be able to work around this restriction by" << endl;
- cerr << "adjusting your use.conf." << endl;
- cerr << endl;
-
- return_code |= 1;
- }
- catch (const DepListError & e)
- {
- cout << endl;
- cerr << "Dependency error:" << endl;
- cerr << " * " << e.backtrace("\n * ") << e.message() << " ("
- << e.what() << ")" << endl;
- cerr << endl;
-
- return_code |= 1;
- }
+ if (task.had_action_failures())
+ return_code |= 7;
return return_code;
}
diff --git a/src/clients/gtkpaludis/libgtkpaludis/packages_list_model.cc b/src/clients/gtkpaludis/libgtkpaludis/packages_list_model.cc
index cc38e27..22c6ebe 100644
--- a/src/clients/gtkpaludis/libgtkpaludis/packages_list_model.cc
+++ b/src/clients/gtkpaludis/libgtkpaludis/packages_list_model.cc
@@ -8,6 +8,7 @@
#include <paludis/environment.hh>
#include <paludis/package_database.hh>
#include <paludis/metadata_key.hh>
+#include <paludis/package_id.hh>
#include <paludis/util/iterator.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
diff --git a/src/clients/gtkpaludis/libgtkpaludis/version_info_model.cc b/src/clients/gtkpaludis/libgtkpaludis/version_info_model.cc
index 82c9297..fd83187 100644
--- a/src/clients/gtkpaludis/libgtkpaludis/version_info_model.cc
+++ b/src/clients/gtkpaludis/libgtkpaludis/version_info_model.cc
@@ -7,6 +7,7 @@
#include <paludis/util/iterator.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/set.hh>
+#include <paludis/package_id.hh>
#include <paludis/environment.hh>
#include <paludis/package_database.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
diff --git a/src/clients/inquisitio/do_search.cc b/src/clients/inquisitio/do_search.cc
index 75e5004..c702f79 100644
--- a/src/clients/inquisitio/do_search.cc
+++ b/src/clients/inquisitio/do_search.cc
@@ -26,6 +26,7 @@
#include <paludis/environment.hh>
#include <paludis/query.hh>
#include <paludis/package_database.hh>
+#include <paludis/package_id.hh>
#include <paludis/util/iterator.hh>
#include <paludis/util/set.hh>
#include <paludis/util/sequence.hh>
diff --git a/src/clients/instruo/instruo.cc b/src/clients/instruo/instruo.cc
index ac3d951..3f3014a 100644
--- a/src/clients/instruo/instruo.cc
+++ b/src/clients/instruo/instruo.cc
@@ -22,6 +22,7 @@
#include "command_line.hh"
#include <paludis/about.hh>
#include <paludis/action.hh>
+#include <paludis/package_id.hh>
#include <paludis/util/join.hh>
#include <paludis/util/log.hh>
#include <paludis/util/fs_entry.hh>
diff --git a/src/clients/paludis/install.cc b/src/clients/paludis/install.cc
index 48dd431..4ec1875 100644
--- a/src/clients/paludis/install.cc
+++ b/src/clients/paludis/install.cc
@@ -52,6 +52,7 @@
#include <paludis/hook.hh>
#include <paludis/query.hh>
+#include <paludis/package_id.hh>
#include <paludis/metadata_key.hh>
#include <paludis/mask.hh>
#include <paludis/action.hh>
@@ -71,7 +72,7 @@ using std::endl;
namespace
{
- std::string make_resume_command(tr1::shared_ptr<Environment> env, const InstallTask & task, bool skip_first)
+ std::string make_resume_command(const Environment * const env, const InstallTask & task, bool skip_first)
{
std::string resume_command = env->paludis_command()
+ " --" + CommandLine::get_instance()->dl_deps_default.long_name() + " discard --"
@@ -109,64 +110,6 @@ namespace
return resume_command;
}
- void show_resume_command(tr1::shared_ptr<Environment> env, const InstallTask & task)
- {
- if (CommandLine::get_instance()->a_fetch.specified() ||
- CommandLine::get_instance()->a_pretend.specified())
- return;
-
- if (task.current_dep_list_entry() != task.dep_list().end())
- {
- std::string resume_command(make_resume_command(env, task, false));
-
- 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;
- }
- }
- }
-
class OurInstallTask :
public ConsoleInstallTask
{
@@ -236,7 +179,7 @@ namespace
return;
}
- std::string resume_command(make_resume_command(_env, *this, true));
+ std::string resume_command(make_resume_command(_env.get(), *this, true));
output_heading("Paludis has just upgraded Paludis");
output_starred_item("Using '" + resume_command + "' to start a new Paludis instance...");
@@ -248,14 +191,72 @@ namespace
virtual HookResult perform_hook(const Hook & hook) const
{
return ConsoleInstallTask::perform_hook(hook("RESUME_COMMAND", make_resume_command(
- _env, *this, false)));
+ _env.get(), *this, false)));
+ }
+
+ void show_resume_command() const
+ {
+ if (CommandLine::get_instance()->a_fetch.specified() ||
+ CommandLine::get_instance()->a_pretend.specified())
+ return;
+
+ if (current_dep_list_entry() != dep_list().end())
+ {
+ std::string resume_command(make_resume_command(environment(), *this, false));
+
+ 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;
+ }
+ }
}
};
class InstallKilledCatcher
{
private:
- static const InstallTask * _task;
+ static const ConsoleInstallTask * _task;
static tr1::shared_ptr<Environment> _env;
@@ -264,7 +265,7 @@ namespace
sig_t _old;
public:
- InstallKilledCatcher(tr1::shared_ptr<Environment> env, const InstallTask & task) :
+ InstallKilledCatcher(tr1::shared_ptr<Environment> env, const ConsoleInstallTask & task) :
_old(signal(SIGINT, &InstallKilledCatcher::_signal_handler))
{
_task = &task;
@@ -278,7 +279,7 @@ namespace
}
};
- const InstallTask * InstallKilledCatcher::_task(0);
+ const ConsoleInstallTask * InstallKilledCatcher::_task(0);
tr1::shared_ptr<Environment> InstallKilledCatcher::_env;
void
@@ -310,7 +311,7 @@ namespace
;
cerr << endl;
if (_task)
- show_resume_command(_env, *_task);
+ _task->show_resume_command();
cerr << endl;
cerr << "Exiting with failure" << endl;
exit(EXIT_FAILURE);
@@ -569,191 +570,24 @@ do_install(tr1::shared_ptr<Environment> env)
InstallKilledCatcher install_killed_catcher(env, task);
- try
- {
- cout << "Building target list... " << std::flush;
- for (CommandLine::ParametersIterator q(CommandLine::get_instance()->begin_parameters()),
- q_end(CommandLine::get_instance()->end_parameters()) ; q != q_end ; ++q)
- task.add_target(*q);
- cout << endl;
-
- task.execute();
+ cout << "Building target list... " << std::flush;
+ for (CommandLine::ParametersIterator q(CommandLine::get_instance()->begin_parameters()),
+ q_end(CommandLine::get_instance()->end_parameters()) ; q != q_end ; ++q)
+ task.add_target(*q);
+ cout << endl;
- cout << endl;
+ task.execute();
- if (task.dep_list().has_errors())
- return_code |= 1;
- }
- catch (const AmbiguousPackageNameError & e)
- {
- cout << endl;
- cerr << "Query error:" << endl;
- cerr << " * " << e.backtrace("\n * ");
- cerr << "Ambiguous package name '" << e.name() << "'. Did you mean:" << endl;
- for (AmbiguousPackageNameError::OptionsIterator o(e.begin_options()),
- o_end(e.end_options()) ; o != o_end ; ++o)
- cerr << " * " << colour(cl_package_name, *o) << endl;
- cerr << endl;
- return 1;
- }
- catch (const InstallActionError & e)
- {
- cout << endl;
- cerr << "Install error:" << endl;
- cerr << " * " << e.backtrace("\n * ");
- cerr << e.message() << endl;
- cerr << endl;
- show_resume_command(env, task);
- cerr << endl;
+ cout << endl;
+ if (task.dep_list().has_errors())
return_code |= 1;
- }
- catch (const FetchActionError & e)
- {
- cout << endl;
- cerr << "Fetch error:" << endl;
- cerr << " * " << e.backtrace("\n * ");
- cerr << e.message() << endl;
- cerr << endl;
- if (e.failures())
- {
- for (Sequence<FetchActionFailure>::Iterator f(e.failures()->begin()), f_end(e.failures()->end()) ;
- f != f_end ; ++f)
- {
- cerr << " * File '" << f->target_file << "': ";
+ if (task.had_resolution_failures())
+ return_code |= 3;
- bool need_comma(false);
- if (f->requires_manual_fetching)
- {
- cerr << "requires manual fetching";
- need_comma = true;
- }
-
- if (f->failed_automatic_fetching)
- {
- if (need_comma)
- cerr << ", ";
- cerr << "failed automatic fetching";
- need_comma = true;
- }
-
- if (! f->failed_integrity_checks.empty())
- {
- if (need_comma)
- cerr << "failed automatic fetching";
- cerr << "failed integrity checks: " << f->failed_integrity_checks;
- need_comma = true;
- }
-
- cerr << endl;
- }
- }
-
- show_resume_command(env, task);
- cerr << endl;
-
- return_code |= 1;
- }
- catch (const NoSuchPackageError & e)
- {
- cout << endl;
- cerr << "Query error:" << endl;
- cerr << " * " << e.backtrace("\n * ");
- cerr << "No such package '" << e.name() << "'" << endl;
- return 1;
- }
- catch (const AllMaskedError & e)
- {
- try
- {
- tr1::shared_ptr<const PackageIDSequence> p(
- env->package_database()->query(
- query::Matches(e.query()) & query::SupportsAction<InstallAction>(), qo_order_by_version));
- if (p->empty())
- {
- cout << endl;
- cerr << "Query error:" << endl;
- cerr << " * " << e.backtrace("\n * ");
- cerr << "No versions of '" << e.query() << "' are available" << endl;
- }
- else
- {
- cout << endl;
- cerr << "Query error:" << endl;
- cerr << " * " << e.backtrace("\n * ");
- cerr << "All versions of '" << e.query() << "' are masked. Candidates are:" << endl;
- for (PackageIDSequence::Iterator pp(p->begin()), pp_end(p->end()) ;
- pp != pp_end ; ++pp)
- {
- cerr << " * " << colour(cl_package_name, **pp) << ": Masked by ";
-
- bool need_comma(false);
- for (PackageID::MasksIterator m((*pp)->begin_masks()), m_end((*pp)->end_masks()) ;
- m != m_end ; ++m)
- {
- if (need_comma)
- cerr << ", ";
- cerr << (*m)->description();
-
- need_comma = true;
- }
- cerr << endl;
- }
- }
- }
- catch (...)
- {
- Log::get_instance()->message(ll_warning, lc_context, "Couldn't work out a friendly error message for mask reasons");
- throw e;
- }
-
- return 1;
- }
- catch (const UseRequirementsNotMetError & e)
- {
- cout << endl;
- cerr << "DepList USE requirements not met error:" << endl;
- cerr << " * " << e.backtrace("\n * ") << e.message() << endl;
- cerr << endl;
- cerr << "This error usually indicates that one of the packages you are trying to" << endl;
- cerr << "install requires that another package be built with particular USE flags" << endl;
- cerr << "enabled or disabled. You may be able to work around this restriction by" << endl;
- cerr << "adjusting your use.conf." << endl;
- cerr << endl;
-
- return_code |= 1;
- }
- catch (const DepListError & e)
- {
- cout << endl;
- cerr << "Dependency error:" << endl;
- cerr << " * " << e.backtrace("\n * ") << e.message() << " ("
- << e.what() << ")" << endl;
- cerr << endl;
-
- return_code |= 1;
- }
- catch (const HadBothPackageAndSetTargets &)
- {
- cout << endl;
- cerr << "Error: both package sets and packages were specified." << endl;
- cerr << endl;
- cerr << "Package sets (like 'system' and 'world') cannot be installed at the same time" << endl;
- cerr << "as ordinary packages." << endl;
-
- return_code |= 1;
- }
- catch (const MultipleSetTargetsSpecified &)
- {
- cout << endl;
- cerr << "Error: multiple package sets were specified." << endl;
- cerr << endl;
- cerr << "Package sets (like 'system' and 'world') must be installed individually," << endl;
- cerr << "without any other sets or packages." << endl;
-
- return_code |= 1;
- }
+ if (task.had_action_failures())
+ return_code |= 7;
return return_code;
}
diff --git a/src/output/console_install_task.cc b/src/output/console_install_task.cc
index 15c4a29..228173b 100644
--- a/src/output/console_install_task.cc
+++ b/src/output/console_install_task.cc
@@ -32,6 +32,7 @@
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/tr1_functional.hh>
#include <paludis/query.hh>
+#include <paludis/action.hh>
#include <paludis/repository.hh>
#include <paludis/package_database.hh>
#include <paludis/package_id.hh>
@@ -48,6 +49,7 @@
#include <limits>
using namespace paludis;
+using std::endl;
#include <src/output/console_install_task-sr.cc>
@@ -1188,3 +1190,175 @@ ConsoleInstallTask::display_merge_list_entry_mask_reasons(const DepListEntry & e
output_endl();
}
+void
+ConsoleInstallTask::on_ambiguous_package_name_error(const AmbiguousPackageNameError & e)
+{
+ output_stream() << endl;
+ output_stream() << "Query error:" << endl;
+ output_stream() << " * " << e.backtrace("\n * ");
+ output_stream() << "Ambiguous package name '" << e.name() << "'. Did you mean:" << endl;
+ for (AmbiguousPackageNameError::OptionsIterator o(e.begin_options()),
+ o_end(e.end_options()) ; o != o_end ; ++o)
+ output_stream() << " * " << colour(cl_package_name, *o) << endl;
+ output_stream() << endl;
+}
+
+void
+ConsoleInstallTask::on_install_action_error(const InstallActionError & e)
+{
+ output_stream() << endl;
+ output_stream() << "Install error:" << endl;
+ output_stream() << " * " << e.backtrace("\n * ");
+ output_stream() << e.message() << endl;
+ output_stream() << endl;
+ show_resume_command();
+ output_stream() << endl;
+}
+
+void
+ConsoleInstallTask::on_fetch_action_error(const FetchActionError & e)
+{
+ output_stream() << endl;
+ output_stream() << "Fetch error:" << endl;
+ output_stream() << " * " << e.backtrace("\n * ");
+ output_stream() << e.message() << endl;
+ output_stream() << endl;
+
+ if (e.failures())
+ {
+ for (Sequence<FetchActionFailure>::Iterator f(e.failures()->begin()), f_end(e.failures()->end()) ;
+ f != f_end ; ++f)
+ {
+ output_stream() << " * File '" << f->target_file << "': ";
+
+ bool need_comma(false);
+ if (f->requires_manual_fetching)
+ {
+ output_stream() << "requires manual fetching";
+ need_comma = true;
+ }
+
+ if (f->failed_automatic_fetching)
+ {
+ if (need_comma)
+ output_stream() << ", ";
+ output_stream() << "failed automatic fetching";
+ need_comma = true;
+ }
+
+ if (! f->failed_integrity_checks.empty())
+ {
+ if (need_comma)
+ output_stream() << "failed automatic fetching";
+ output_stream() << "failed integrity checks: " << f->failed_integrity_checks;
+ need_comma = true;
+ }
+
+ output_stream() << endl;
+ }
+ }
+
+ show_resume_command();
+ output_stream() << endl;
+}
+
+void
+ConsoleInstallTask::on_no_such_package_error(const NoSuchPackageError & e)
+{
+ output_stream() << endl;
+ output_stream() << "Query error:" << endl;
+ output_stream() << " * " << e.backtrace("\n * ");
+ output_stream() << "No such package '" << e.name() << "'" << endl;
+}
+
+void
+ConsoleInstallTask::on_all_masked_error(const AllMaskedError & e)
+{
+ try
+ {
+ tr1::shared_ptr<const PackageIDSequence> p(
+ environment()->package_database()->query(
+ query::Matches(e.query()) & query::SupportsAction<InstallAction>(), qo_order_by_version));
+ if (p->empty())
+ {
+ output_stream() << endl;
+ output_stream() << "Query error:" << endl;
+ output_stream() << " * " << e.backtrace("\n * ");
+ output_stream() << "No versions of '" << e.query() << "' are available" << endl;
+ }
+ else
+ {
+ output_stream() << endl;
+ output_stream() << "Query error:" << endl;
+ output_stream() << " * " << e.backtrace("\n * ");
+ output_stream() << "All versions of '" << e.query() << "' are masked. Candidates are:" << endl;
+ for (PackageIDSequence::Iterator pp(p->begin()), pp_end(p->end()) ;
+ pp != pp_end ; ++pp)
+ {
+ output_stream() << " * " << colour(cl_package_name, **pp) << ": Masked by ";
+
+ bool need_comma(false);
+ for (PackageID::MasksIterator m((*pp)->begin_masks()), m_end((*pp)->end_masks()) ;
+ m != m_end ; ++m)
+ {
+ if (need_comma)
+ output_stream() << ", ";
+ output_stream() << (*m)->description();
+
+ need_comma = true;
+ }
+ output_stream() << endl;
+ }
+ }
+ }
+ catch (...)
+ {
+ Log::get_instance()->message(ll_warning, lc_context, "Couldn't work out a friendly error message for mask reasons");
+ throw e;
+ }
+}
+
+void
+ConsoleInstallTask::on_use_requirements_not_met_error(const UseRequirementsNotMetError & e)
+{
+ output_stream() << endl;
+ output_stream() << "DepList USE requirements not met error:" << endl;
+ output_stream() << " * " << e.backtrace("\n * ") << e.message() << endl;
+ output_stream() << endl;
+ output_stream() << "This error usually indicates that one of the packages you are trying to" << endl;
+ output_stream() << "install requires that another package be built with particular USE flags" << endl;
+ output_stream() << "enabled or disabled. You may be able to work around this restriction by" << endl;
+ output_stream() << "adjusting your use.conf." << endl;
+ output_stream() << endl;
+}
+
+void
+ConsoleInstallTask::on_dep_list_error(const DepListError & e)
+{
+ output_stream() << endl;
+ output_stream() << "Dependency error:" << endl;
+ output_stream() << " * " << e.backtrace("\n * ") << e.message() << " ("
+ << e.what() << ")" << endl;
+ output_stream() << endl;
+}
+
+void
+ConsoleInstallTask::on_had_both_package_and_set_targets_error(const HadBothPackageAndSetTargets &)
+{
+ output_stream() << endl;
+ output_stream() << "Error: both package sets and packages were specified." << endl;
+ output_stream() << endl;
+ output_stream() << "Package sets (like 'system' and 'world') cannot be installed at the same time" << endl;
+ output_stream() << "as ordinary packages." << endl;
+}
+
+void
+ConsoleInstallTask::on_multiple_set_targets_specified(const MultipleSetTargetsSpecified &)
+{
+ output_stream() << endl;
+ output_stream() << "Error: multiple package sets were specified." << endl;
+ output_stream() << endl;
+ output_stream() << "Package sets (like 'system' and 'world') must be installed individually," << endl;
+ output_stream() << "without any other sets or packages." << endl;
+}
+
diff --git a/src/output/console_install_task.hh b/src/output/console_install_task.hh
index f6d108e..80febb7 100644
--- a/src/output/console_install_task.hh
+++ b/src/output/console_install_task.hh
@@ -170,6 +170,17 @@ namespace paludis
virtual void on_update_world_post();
virtual void on_preserve_world();
+ virtual void on_ambiguous_package_name_error(const AmbiguousPackageNameError &);
+ virtual void on_no_such_package_error(const NoSuchPackageError &);
+ virtual void on_all_masked_error(const AllMaskedError &);
+ virtual void on_use_requirements_not_met_error(const UseRequirementsNotMetError &);
+ virtual void on_dep_list_error(const DepListError &);
+ virtual void on_had_both_package_and_set_targets_error(const HadBothPackageAndSetTargets &);
+ virtual void on_multiple_set_targets_specified(const MultipleSetTargetsSpecified &);
+
+ virtual void on_install_action_error(const InstallActionError &);
+ virtual void on_fetch_action_error(const FetchActionError &);
+
///\name More granular display routines
///\{
@@ -214,6 +225,8 @@ namespace paludis
Set<UseDescription, UseDescriptionComparator>::Iterator);
virtual void display_use_summary_end();
+ virtual void show_resume_command() const = 0;
+
///\}
///\name Data