aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-03-30 20:41:05 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-04-06 15:14:17 +0100
commitee75d7db208af06c84811353a118078a2656f794 (patch)
tree902210ddd9f31d5dec40a241577c7b2eabfdb8b8
parent5fc5af5290ed5387fe8fdf9cf72889abc92f29f1 (diff)
downloadpaludis-ee75d7db208af06c84811353a118078a2656f794.tar.gz
paludis-ee75d7db208af06c84811353a118078a2656f794.tar.xz
Refactor InstallTask a bit
-rw-r--r--paludis/handled_information-fwd.hh4
-rw-r--r--paludis/handled_information.hh31
-rw-r--r--paludis/install_task.cc111
-rw-r--r--paludis/install_task.hh7
4 files changed, 135 insertions, 18 deletions
diff --git a/paludis/handled_information-fwd.hh b/paludis/handled_information-fwd.hh
index 42251d0..2942b9a 100644
--- a/paludis/handled_information-fwd.hh
+++ b/paludis/handled_information-fwd.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -29,6 +29,8 @@
namespace paludis
{
class DepListEntryHandled;
+ class DepListEntryHandledFetchSuccess;
+ class DepListEntryHandledFetchFailed;
class DepListEntryHandledSuccess;
class DepListEntryHandledSkippedUnsatisfied;
class DepListEntryHandledSkippedDependent;
diff --git a/paludis/handled_information.hh b/paludis/handled_information.hh
index e2fca7b..dc05c6e 100644
--- a/paludis/handled_information.hh
+++ b/paludis/handled_information.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -51,6 +51,8 @@ namespace paludis
class PALUDIS_VISIBLE DepListEntryHandled :
public virtual DeclareAbstractAcceptMethods<DepListEntryHandled, MakeTypeList<
DepListEntryHandledSuccess,
+ DepListEntryHandledFetchSuccess,
+ DepListEntryHandledFetchFailed,
DepListEntryHandledSkippedUnsatisfied,
DepListEntryHandledSkippedDependent,
DepListEntryHandledFailed,
@@ -101,6 +103,20 @@ namespace paludis
};
/**
+ * Represents a DepListEntry that has been fetched successfully, but has
+ * not yet started its install.
+ *
+ * \ingroup g_dep_list
+ * \since 0.38
+ * \nosubgrouping
+ */
+ class PALUDIS_VISIBLE DepListEntryHandledFetchSuccess :
+ public DepListEntryHandled,
+ public ImplementAcceptMethods<DepListEntryHandled, DepListEntryHandledFetchSuccess>
+ {
+ };
+
+ /**
* Represents a DepListEntry that was skipped because of unsatisfied
* dependencies.
*
@@ -170,6 +186,19 @@ namespace paludis
public ImplementAcceptMethods<DepListEntryHandled, DepListEntryHandledFailed>
{
};
+
+ /**
+ * Represents a DepListEntry that failed its fetch.
+ *
+ * \ingroup g_dep_list
+ * \since 0.38
+ * \nosubgrouping
+ */
+ class PALUDIS_VISIBLE DepListEntryHandledFetchFailed :
+ public DepListEntryHandled,
+ public ImplementAcceptMethods<DepListEntryHandled, DepListEntryHandledFetchFailed>
+ {
+ };
}
#endif
diff --git a/paludis/install_task.cc b/paludis/install_task.cc
index adb91bb..ff6a0a0 100644
--- a/paludis/install_task.cc
+++ b/paludis/install_task.cc
@@ -230,6 +230,16 @@ namespace
throw InternalError(PALUDIS_HERE, "S takes no extra value");
return make_shared_ptr(new DepListEntryHandledSuccess);
+ case 'E':
+ if (s.length() != 1)
+ throw InternalError(PALUDIS_HERE, "E takes no extra value");
+ return make_shared_ptr(new DepListEntryHandledFetchFailed);
+
+ case 'T':
+ if (s.length() != 1)
+ throw InternalError(PALUDIS_HERE, "T takes no extra value");
+ return make_shared_ptr(new DepListEntryHandledFetchSuccess);
+
case 'U':
return make_shared_ptr(new DepListEntryHandledSkippedUnsatisfied(
parse_user_package_dep_spec(s.substr(1), env, UserPackageDepSpecOptions())));
@@ -265,7 +275,7 @@ void
InstallTask::set_targets_from_serialisation(const std::string & format,
const std::tr1::shared_ptr<const Sequence<std::string> > & ss)
{
- if (format != "0.25")
+ if (format != "0.25" && format != "0.37")
throw InternalError(PALUDIS_HERE, "Serialisation format '" + format + "' not supported by this version of Paludis");
for (Sequence<std::string>::ConstIterator s(ss->begin()), s_end(ss->end()) ;
@@ -324,7 +334,7 @@ InstallTask::set_targets_from_serialisation(const std::string & format,
std::string
InstallTask::serialised_format() const
{
- return "0.25";
+ return "0.37";
}
namespace
@@ -349,6 +359,16 @@ namespace
result = "S";
}
+ void visit(const DepListEntryHandledFetchFailed &)
+ {
+ result = "E";
+ }
+
+ void visit(const DepListEntryHandledFetchSuccess &)
+ {
+ result = "T";
+ }
+
void visit(const DepListEntryHandledFailed &)
{
if (undo_failures)
@@ -618,12 +638,25 @@ namespace
task.on_display_failure_summary_failure(*entry);
}
+ void visit(const DepListEntryHandledFetchFailed &)
+ {
+ ++failures;
+ ++total;
+ task.on_display_failure_summary_failure(*entry);
+ }
+
void visit(const DepListEntryUnhandled &)
{
++unreached;
++total;
}
+ void visit(const DepListEntryHandledFetchSuccess &)
+ {
+ ++unreached;
+ ++total;
+ }
+
void visit(const DepListEntryNoHandlingRequired &)
{
}
@@ -833,6 +866,7 @@ InstallTask::_one(const DepList::Iterator dep, const int x, const int y, const i
if (output_manager_holder->output_manager_if_constructed())
output_manager_holder->output_manager_if_constructed()->succeeded();
output_manager_holder.reset();
+ dep->handled().reset(new DepListEntryHandledFetchSuccess);
}
if (! _imp->fetch_only)
@@ -943,10 +977,8 @@ InstallTask::_one(const DepList::Iterator dep, const int x, const int y, const i
}
void
-InstallTask::_main_actions()
+InstallTask::_main_actions_pre_hooks()
{
- using namespace std::tr1::placeholders;
-
/* we're about to fetch / install the entire list */
if (_imp->fetch_only)
{
@@ -970,18 +1002,13 @@ InstallTask::_main_actions()
throw InstallActionError("Install aborted by hook");
on_install_all_pre();
}
+}
- /* fetch / install our entire list */
- int x(0), y(0), s(0), f(0);
+void
+InstallTask::_main_actions_all(const int y, const DepList::Iterator dep_last_package)
+{
+ int x(0), s(0), f(0);
bool is_first(true), is_last(false);
- DepList::Iterator dep_last_package(_imp->dep_list.end());
- for (DepList::Iterator dep(_imp->dep_list.begin()), dep_end(_imp->dep_list.end()) ;
- dep != dep_end ; ++dep)
- if (dep->kind() == dlk_package)
- {
- dep_last_package = dep;
- ++y;
- }
for (DepList::Iterator dep(_imp->dep_list.begin()), dep_end(_imp->dep_list.end()) ;
dep != dep_end ; ++dep)
@@ -1053,7 +1080,7 @@ InstallTask::_main_actions()
}
catch (const FetchActionError & e)
{
- dep->handled().reset(new DepListEntryHandledFailed);
+ dep->handled().reset(new DepListEntryHandledFetchFailed);
if (output_manager_holder && output_manager_holder->output_manager_if_constructed())
on_fetch_action_error(output_manager_holder->output_manager_if_constructed(), e);
else
@@ -1063,6 +1090,28 @@ InstallTask::_main_actions()
is_first = false;
}
+}
+
+
+void
+InstallTask::_main_actions()
+{
+ using namespace std::tr1::placeholders;
+
+ _main_actions_pre_hooks();
+
+ /* fetch / install our entire list */
+ int y(0);
+ DepList::Iterator dep_last_package(_imp->dep_list.end());
+ for (DepList::Iterator dep(_imp->dep_list.begin()), dep_end(_imp->dep_list.end()) ;
+ dep != dep_end ; ++dep)
+ if (dep->kind() == dlk_package)
+ {
+ dep_last_package = dep;
+ ++y;
+ }
+
+ _main_actions_all(y, dep_last_package);
/* go no further if we had failures */
if (had_action_failures())
@@ -1071,6 +1120,13 @@ InstallTask::_main_actions()
return;
}
+
+ _do_world_updates();
+}
+
+void
+InstallTask::_do_world_updates()
+{
/* update world */
if (! _imp->fetch_only)
{
@@ -1129,7 +1185,11 @@ InstallTask::_main_actions()
else
on_preserve_world();
}
+}
+void
+InstallTask::_main_actions_post_hooks()
+{
/* we've fetched / installed the entire list */
if (_imp->fetch_only)
{
@@ -1552,6 +1612,15 @@ namespace
void visit(const DepListEntryUnhandled &)
{
}
+
+ void visit(const DepListEntryHandledFetchFailed &)
+ {
+ failure = true;
+ }
+
+ void visit(const DepListEntryHandledFetchSuccess &)
+ {
+ }
};
struct CheckIndependentVisitor
@@ -1777,6 +1846,16 @@ namespace
{
result = false;
}
+
+ void visit(const DepListEntryHandledFetchFailed &)
+ {
+ result = false;
+ }
+
+ void visit(const DepListEntryHandledFetchSuccess &)
+ {
+ result = false;
+ }
};
}
diff --git a/paludis/install_task.hh b/paludis/install_task.hh
index f3a4f37..48c4577 100644
--- a/paludis/install_task.hh
+++ b/paludis/install_task.hh
@@ -59,10 +59,17 @@ namespace paludis
{
private:
void _execute();
+
void _build_dep_list();
void _display_task_list();
bool _pretend();
+
void _main_actions();
+ void _main_actions_pre_hooks();
+ void _main_actions_post_hooks();
+ void _do_world_updates();
+ void _main_actions_all(const int y, const DepList::Iterator dep_last_package);
+
void _one(const DepList::Iterator, const int, const int, const int, const int, const bool is_first, const bool is_last,
std::tr1::shared_ptr<OutputManagerFromEnvironment> &);
void _clean(const DepList::Iterator, const std::tr1::shared_ptr<const PackageID> & id,