aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-05 14:31:12 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-02-05 15:33:37 +0000
commit96ab40db24ed0c814d2c19aa5b5ab5164d549eeb (patch)
treeeccea4e6dec01ad7960918c5adf6dca09727c94f
parent6931070f404f5e381de2db9ff9dd1ade33a07631 (diff)
downloadpaludis-96ab40db24ed0c814d2c19aa5b5ab5164d549eeb.tar.gz
paludis-96ab40db24ed0c814d2c19aa5b5ab5164d549eeb.tar.xz
UninstallJob
-rw-r--r--paludis/resolver/job-fwd.hh1
-rw-r--r--paludis/resolver/job.cc96
-rw-r--r--paludis/resolver/job.hh34
-rw-r--r--paludis/resolver/jobs.cc15
-rw-r--r--paludis/resolver/orderer.cc4
-rw-r--r--paludis/resolver/resolver_test.cc5
-rw-r--r--src/clients/cave/cmd_display_resolution.cc20
-rw-r--r--src/clients/cave/cmd_execute_resolution.cc51
8 files changed, 225 insertions, 1 deletions
diff --git a/paludis/resolver/job-fwd.hh b/paludis/resolver/job-fwd.hh
index e9ea4da..5322bd5 100644
--- a/paludis/resolver/job-fwd.hh
+++ b/paludis/resolver/job-fwd.hh
@@ -27,6 +27,7 @@ namespace paludis
struct Job;
struct SimpleInstallJob;
+ struct UninstallJob;
struct FetchJob;
struct UsableJob;
struct UsableGroupJob;
diff --git a/paludis/resolver/job.cc b/paludis/resolver/job.cc
index d76c12f..ef34e4c 100644
--- a/paludis/resolver/job.cc
+++ b/paludis/resolver/job.cc
@@ -101,6 +101,24 @@ namespace paludis
};
template <>
+ struct Implementation<UninstallJob>
+ {
+ const std::tr1::shared_ptr<const Resolution> resolution;
+ const std::tr1::shared_ptr<const RemoveDecision> decision;
+ const std::tr1::shared_ptr<ArrowSequence> arrows;
+ const std::tr1::shared_ptr<JobIDSequence> used_existing_packages_when_ordering;
+
+ Implementation(const std::tr1::shared_ptr<const Resolution> & r,
+ const std::tr1::shared_ptr<const RemoveDecision> & d) :
+ resolution(r),
+ decision(d),
+ arrows(new ArrowSequence),
+ used_existing_packages_when_ordering(new JobIDSequence)
+ {
+ }
+ };
+
+ template <>
struct Implementation<ErrorJob>
{
const std::tr1::shared_ptr<const Resolution> resolution;
@@ -181,6 +199,16 @@ Job::deserialise(Deserialisation & d)
do_arrows(result, v);
do_existing(result, v);
}
+ else if (d.class_name() == "UninstallJob")
+ {
+ Deserialisator v(d, "UninstallJob");
+ result.reset(new UninstallJob(
+ v.member<std::tr1::shared_ptr<Resolution> >("resolution"),
+ v.member<std::tr1::shared_ptr<RemoveDecision> >("remove_decision")
+ ));
+ do_arrows(result, v);
+ do_existing(result, v);
+ }
else if (d.class_name() == "FetchJob")
{
Deserialisator v(d, "FetchJob");
@@ -463,6 +491,72 @@ SimpleInstallJob::serialise(Serialiser & s) const
;
}
+UninstallJob::UninstallJob(const std::tr1::shared_ptr<const Resolution> & r,
+ const std::tr1::shared_ptr<const RemoveDecision> & d) :
+ PrivateImplementationPattern<UninstallJob>(new Implementation<UninstallJob>(r, d))
+{
+}
+
+UninstallJob::~UninstallJob()
+{
+}
+
+const std::tr1::shared_ptr<const Resolution>
+UninstallJob::resolution() const
+{
+ return _imp->resolution;
+}
+
+const std::tr1::shared_ptr<const RemoveDecision>
+UninstallJob::remove_decision() const
+{
+ return _imp->decision;
+}
+
+const std::tr1::shared_ptr<const ArrowSequence>
+UninstallJob::arrows() const
+{
+ return _imp->arrows;
+}
+
+const std::tr1::shared_ptr<ArrowSequence>
+UninstallJob::arrows()
+{
+ return _imp->arrows;
+}
+
+const std::tr1::shared_ptr<const JobIDSequence>
+UninstallJob::used_existing_packages_when_ordering() const
+{
+ return _imp->used_existing_packages_when_ordering;
+}
+
+const std::tr1::shared_ptr<JobIDSequence>
+UninstallJob::used_existing_packages_when_ordering()
+{
+ return _imp->used_existing_packages_when_ordering;
+}
+
+const JobID
+UninstallJob::id() const
+{
+ return make_named_values<JobID>(
+ value_for<n::string_id>("install:" + stringify(resolution()->resolvent()))
+ );
+}
+
+void
+UninstallJob::serialise(Serialiser & s) const
+{
+ s.object("UninstallJob")
+ .member(SerialiserFlags<serialise::might_be_null, serialise::container>(), "arrows", arrows())
+ .member(SerialiserFlags<serialise::might_be_null>(), "remove_decision", remove_decision())
+ .member(SerialiserFlags<serialise::might_be_null>(), "resolution", resolution())
+ .member(SerialiserFlags<serialise::container, serialise::might_be_null>(),
+ "used_existing_packages_when_ordering", used_existing_packages_when_ordering())
+ ;
+}
+
ErrorJob::ErrorJob(const std::tr1::shared_ptr<const Resolution> & r, const std::tr1::shared_ptr<const UnableToMakeDecision> & d) :
PrivateImplementationPattern<ErrorJob>(new Implementation<ErrorJob>(r, d))
{
@@ -527,9 +621,11 @@ ErrorJob::unable_to_make_decision() const
{
return _imp->decision;
}
+
template class PrivateImplementationPattern<resolver::UsableJob>;
template class PrivateImplementationPattern<resolver::UsableGroupJob>;
template class PrivateImplementationPattern<resolver::FetchJob>;
template class PrivateImplementationPattern<resolver::SimpleInstallJob>;
template class PrivateImplementationPattern<resolver::ErrorJob>;
+template class PrivateImplementationPattern<resolver::UninstallJob>;
diff --git a/paludis/resolver/job.hh b/paludis/resolver/job.hh
index 8598932..32455c5 100644
--- a/paludis/resolver/job.hh
+++ b/paludis/resolver/job.hh
@@ -39,7 +39,7 @@ namespace paludis
{
class PALUDIS_VISIBLE Job :
public virtual DeclareAbstractAcceptMethods<Job, MakeTypeList<
- UsableJob, UsableGroupJob, SimpleInstallJob, FetchJob, ErrorJob>::Type>
+ UsableJob, UsableGroupJob, SimpleInstallJob, UninstallJob, FetchJob, ErrorJob>::Type>
{
public:
virtual ~Job() = 0;
@@ -183,6 +183,37 @@ namespace paludis
virtual void serialise(Serialiser &) const;
};
+ class PALUDIS_VISIBLE UninstallJob :
+ public Job,
+ public ImplementAcceptMethods<Job, UninstallJob>,
+ private PrivateImplementationPattern<UninstallJob>
+ {
+ public:
+ UninstallJob(
+ const std::tr1::shared_ptr<const Resolution> &,
+ const std::tr1::shared_ptr<const RemoveDecision> &);
+ ~UninstallJob();
+
+ virtual const JobID id() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const std::tr1::shared_ptr<const ArrowSequence> arrows()
+ const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const std::tr1::shared_ptr<ArrowSequence> arrows()
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const std::tr1::shared_ptr<const JobIDSequence> used_existing_packages_when_ordering()
+ const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const std::tr1::shared_ptr<JobIDSequence> used_existing_packages_when_ordering()
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ const std::tr1::shared_ptr<const Resolution> resolution() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const std::tr1::shared_ptr<const RemoveDecision> remove_decision() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual void serialise(Serialiser &) const;
+ };
+
class PALUDIS_VISIBLE ErrorJob :
public Job,
public ImplementAcceptMethods<Job, ErrorJob>,
@@ -220,6 +251,7 @@ namespace paludis
extern template class PrivateImplementationPattern<resolver::UsableGroupJob>;
extern template class PrivateImplementationPattern<resolver::FetchJob>;
extern template class PrivateImplementationPattern<resolver::SimpleInstallJob>;
+ extern template class PrivateImplementationPattern<resolver::UninstallJob>;
extern template class PrivateImplementationPattern<resolver::ErrorJob>;
#endif
}
diff --git a/paludis/resolver/jobs.cc b/paludis/resolver/jobs.cc
index 965466e..3ada174 100644
--- a/paludis/resolver/jobs.cc
+++ b/paludis/resolver/jobs.cc
@@ -76,6 +76,11 @@ namespace
jobs_list_by_resolvent_index.insert(std::make_pair(j.resolution()->resolvent(), i));
}
+ void visit(const UninstallJob & j)
+ {
+ jobs_list_by_resolvent_index.insert(std::make_pair(j.resolution()->resolvent(), i));
+ }
+
void visit(const UsableGroupJob &)
{
}
@@ -120,6 +125,11 @@ namespace
return true;
}
+ bool visit(const UninstallJob &) const
+ {
+ return true;
+ }
+
bool visit(const UsableJob &) const
{
return false;
@@ -143,6 +153,11 @@ namespace
return false;
}
+ bool visit(const UninstallJob &) const
+ {
+ return true;
+ }
+
bool visit(const ErrorJob &) const
{
return true;
diff --git a/paludis/resolver/orderer.cc b/paludis/resolver/orderer.cc
index 56fce24..1992f1d 100644
--- a/paludis/resolver/orderer.cc
+++ b/paludis/resolver/orderer.cc
@@ -453,6 +453,10 @@ namespace
add_dep_arrows(true, c.resolution());
}
+ void visit(const UninstallJob &)
+ {
+ }
+
void visit(const UsableGroupJob &)
{
}
diff --git a/paludis/resolver/resolver_test.cc b/paludis/resolver/resolver_test.cc
index 9811166..52b40a9 100644
--- a/paludis/resolver/resolver_test.cc
+++ b/paludis/resolver/resolver_test.cc
@@ -549,6 +549,11 @@ namespace
{
return j.resolution();
}
+
+ std::tr1::shared_ptr<const Resolution> visit(const UninstallJob & j) const
+ {
+ return j.resolution();
+ }
};
template <>
diff --git a/src/clients/cave/cmd_display_resolution.cc b/src/clients/cave/cmd_display_resolution.cc
index 6c78cf8..5608162 100644
--- a/src/clients/cave/cmd_display_resolution.cc
+++ b/src/clients/cave/cmd_display_resolution.cc
@@ -621,6 +621,15 @@ namespace
display_one_installish(env, cmdline, *job.changes_to_make_decision(), job.resolution());
}
+ void display_one_uninstall(
+ const std::tr1::shared_ptr<Environment> &,
+ const DisplayResolutionCommandLine &,
+ const UninstallJob & job)
+ {
+ cout << "< " << c::bold_green() << job.resolution()->resolvent() << c::normal() << endl;
+ display_reasons(job.resolution());
+ }
+
void display_special_job_decision(
const std::tr1::shared_ptr<Environment> &,
const DisplayResolutionCommandLine &,
@@ -711,6 +720,12 @@ namespace
return true;
}
+ bool visit(const UninstallJob & job)
+ {
+ display_one_uninstall(env, cmdline, job);
+ return true;
+ }
+
bool visit(const UsableJob & job, const bool indent = false)
{
if (! all)
@@ -756,6 +771,11 @@ namespace
return "install " + stringify(*j.changes_to_make_decision()->origin_id());
}
+ const std::string visit(const UninstallJob & j) const
+ {
+ return "uninstall " + stringify(j.resolution()->resolvent());
+ }
+
const std::string visit(const UsableJob & j) const
{
return "usable " + stringify(j.resolution()->resolvent());
diff --git a/src/clients/cave/cmd_execute_resolution.cc b/src/clients/cave/cmd_execute_resolution.cc
index 99b1028..b7b0c2c 100644
--- a/src/clients/cave/cmd_execute_resolution.cc
+++ b/src/clients/cave/cmd_execute_resolution.cc
@@ -361,6 +361,14 @@ namespace
++y_installs;
}
+ void visit(const UninstallJob &)
+ {
+ /* we'll count uninstalls as installs for now. this might be
+ * confusing, or it might make most sense. if you're reading this,
+ * chances are you think it's the wrong thing to do. */
+ ++y_installs;
+ }
+
void visit(const FetchJob &)
{
++y_fetches;
@@ -445,6 +453,18 @@ namespace
}
}
+ bool visit(const UninstallJob &)
+ {
+ std::tr1::shared_ptr<OutputManager> uninstall_output_manager_goes_here;
+
+ ++counts.x_installs;
+
+ /* don't support uninstalls yet */
+ std::tr1::shared_ptr<JobFailedState> failed_state(new JobFailedState(state->job()));
+ state = failed_state;
+ return false;
+ }
+
bool visit(const FetchJob & job)
{
std::tr1::shared_ptr<OutputManager> output_manager_goes_here;
@@ -535,6 +555,18 @@ namespace
state.reset(new JobSkippedState(state->job()));
}
+ void visit(const UninstallJob & job)
+ {
+ ++counts.x_installs;
+
+ cout << endl;
+ cout << c::bold_blue() << counts.x_installs << " of " << counts.y_installs << ": Skipping uninstall of "
+ << job.resolution()->resolvent() << c::normal() << endl;
+ cout << endl;
+
+ state.reset(new JobSkippedState(state->job()));
+ }
+
void visit(const FetchJob &)
{
++counts.x_fetches;
@@ -680,6 +712,11 @@ namespace
common();
}
+ void visit(const UninstallJob &) const
+ {
+ common();
+ }
+
void visit(const UsableJob &) const
{
common();
@@ -852,6 +889,11 @@ namespace
output_manager_goes_here);
}
+ bool visit(const UninstallJob &) const
+ {
+ return true;
+ }
+
bool visit(const ErrorJob &) const
{
return true;
@@ -975,6 +1017,15 @@ namespace
}
}
+ void visit(const UninstallJob & job) const
+ {
+ if (want_to_flush || something_failed)
+ {
+ summary();
+ cout << colour << state << c::normal() << "uninstall " << job.resolution()->resolvent() << endl;
+ }
+ }
+
void visit(const FetchJob & job) const
{
if (want_to_flush || this_failed)