aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-05-13 22:23:08 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-05-14 17:59:12 +0100
commit089e8a39998302745e3c92748fa1c36a95cf602a (patch)
tree1e76037d8c178d60bc9e217123ed5920d4db6060
parent2fec84edf07c6863d66730460f67409b5f831de0 (diff)
downloadpaludis-089e8a39998302745e3c92748fa1c36a95cf602a.tar.gz
paludis-089e8a39998302745e3c92748fa1c36a95cf602a.tar.xz
Merge repo IDs, but don't do anything
-rw-r--r--paludis/repositories/repository/repository_repository.cc34
-rw-r--r--paludis/repositories/repository/repository_repository.hh12
-rw-r--r--paludis/repositories/unavailable/unavailable_repository_id.cc83
-rw-r--r--paludis/repositories/unavailable/unavailable_repository_id.hh6
4 files changed, 130 insertions, 5 deletions
diff --git a/paludis/repositories/repository/repository_repository.cc b/paludis/repositories/repository/repository_repository.cc
index eb99dce..f6e8d74 100644
--- a/paludis/repositories/repository/repository_repository.cc
+++ b/paludis/repositories/repository/repository_repository.cc
@@ -29,6 +29,7 @@
#include <paludis/action.hh>
#include <paludis/syncer.hh>
#include <paludis/hook.hh>
+#include <paludis/package_id.hh>
#include <list>
using namespace paludis;
@@ -85,7 +86,7 @@ RepositoryRepository::RepositoryRepository(const RepositoryRepositoryParams & p)
p.environment(),
p.name(),
make_named_values<RepositoryCapabilities>(
- value_for<n::destination_interface>(static_cast<RepositoryDestinationInterface *>(0)),
+ value_for<n::destination_interface>(static_cast<RepositoryDestinationInterface *>(this)),
value_for<n::environment_variable_interface>(static_cast<RepositoryEnvironmentVariableInterface *>(0)),
value_for<n::make_virtuals_interface>(static_cast<RepositoryMakeVirtualsInterface *>(0)),
value_for<n::manifest_interface>(static_cast<RepositoryManifestInterface *>(0)),
@@ -329,5 +330,36 @@ RepositoryRepository::sync_host_key() const
return make_null_shared_ptr();
}
+bool
+RepositoryRepository::is_suitable_destination_for(const PackageID & e) const
+{
+ std::string f(e.repository()->format_key() ? e.repository()->format_key()->value() : "");
+ return f == "unavailable";
+}
+
+bool
+RepositoryRepository::is_default_destination() const
+{
+ return false;
+}
+
+bool
+RepositoryRepository::want_pre_post_phases() const
+{
+ return true;
+}
+
+void
+RepositoryRepository::merge(const MergeParams & m)
+{
+ using namespace std::tr1::placeholders;
+
+ Context context("When merging '" + stringify(*m.package_id()) + "' at '" + stringify(m.image_dir())
+ + "' to RepositoryRepository repository '" + stringify(name()) + "':");
+
+ if (! is_suitable_destination_for(*m.package_id()))
+ throw ActionFailedError("Not a suitable destination for '" + stringify(*m.package_id()) + "'");
+}
+
template class PrivateImplementationPattern<repository_repository::RepositoryRepository>;
diff --git a/paludis/repositories/repository/repository_repository.hh b/paludis/repositories/repository/repository_repository.hh
index c7f893a..ff9bd2e 100644
--- a/paludis/repositories/repository/repository_repository.hh
+++ b/paludis/repositories/repository/repository_repository.hh
@@ -57,6 +57,7 @@ namespace paludis
class PALUDIS_VISIBLE RepositoryRepository :
private PrivateImplementationPattern<RepositoryRepository>,
public Repository,
+ public RepositoryDestinationInterface,
public std::tr1::enable_shared_from_this<RepositoryRepository>
{
private:
@@ -97,6 +98,17 @@ namespace paludis
virtual bool sync(const std::tr1::shared_ptr<OutputManager> &) const;
+ virtual bool is_suitable_destination_for(const PackageID &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool is_default_destination() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool want_pre_post_phases() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual void merge(const MergeParams &);
+
///\name RepositoryFactory functions
///\{
diff --git a/paludis/repositories/unavailable/unavailable_repository_id.cc b/paludis/repositories/unavailable/unavailable_repository_id.cc
index 03508f6..ab2f8bf 100644
--- a/paludis/repositories/unavailable/unavailable_repository_id.cc
+++ b/paludis/repositories/unavailable/unavailable_repository_id.cc
@@ -26,6 +26,7 @@
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/hashes.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/make_named_values.hh>
#include <paludis/name.hh>
#include <paludis/version_spec.hh>
#include <paludis/metadata_key.hh>
@@ -156,10 +157,88 @@ UnavailableRepositoryID::supports_action(const SupportsActionTestBase & a) const
return simple_visitor_cast<const SupportsActionTest<InstallAction> >(a);
}
+namespace
+{
+ void used_this_for_config_protect(std::string & s, const std::string & v)
+ {
+ s = v;
+ }
+
+ std::tr1::shared_ptr<OutputManager> this_output_manager(
+ const std::tr1::shared_ptr<OutputManager> & o, const Action &)
+ {
+ return o;
+ }
+
+ bool ignore_nothing(const FSEntry &)
+ {
+ return false;
+ }
+}
+
void
-UnavailableRepositoryID::perform_action(Action & a) const
+UnavailableRepositoryID::perform_action(Action & action) const
{
- throw ActionFailedError("Unsupported action: " + a.simple_name());
+ Timestamp build_start_time(Timestamp::now());
+
+ const InstallAction * const install_action(simple_visitor_cast<const InstallAction>(action));
+ if (! install_action)
+ throw ActionFailedError("Unsupported action: " + action.simple_name());
+
+ if (! (*install_action->options.destination()).destination_interface())
+ throw ActionFailedError("Can't install '" + stringify(*this)
+ + "' to destination '" + stringify(install_action->options.destination()->name())
+ + "' because destination does not provide destination_interface");
+
+ std::tr1::shared_ptr<OutputManager> output_manager(install_action->options.make_output_manager()(*install_action));
+ std::string used_config_protect;
+
+ switch (install_action->options.want_phase()("merge"))
+ {
+ case wp_yes:
+ {
+ (*install_action->options.destination()).destination_interface()->merge(
+ make_named_values<MergeParams>(
+ value_for<n::build_start_time>(build_start_time),
+ value_for<n::environment_file>(FSEntry("/dev/null")),
+ value_for<n::image_dir>(FSEntry("/dev/null")),
+ value_for<n::merged_entries>(make_shared_ptr(new FSEntrySet)),
+ value_for<n::options>(MergerOptions()),
+ value_for<n::output_manager>(output_manager),
+ value_for<n::package_id>(shared_from_this()),
+ value_for<n::perform_uninstall>(install_action->options.perform_uninstall()),
+ value_for<n::used_this_for_config_protect>(std::tr1::bind(
+ &used_this_for_config_protect, std::tr1::ref(used_config_protect), std::tr1::placeholders::_1))
+ ));
+ }
+ break;
+
+ case wp_skip:
+ break;
+
+ case wp_abort:
+ throw ActionAbortedError("Told to abort install");
+
+ case last_wp:
+ throw InternalError(PALUDIS_HERE, "bad WantPhase");
+ }
+
+ for (PackageIDSequence::ConstIterator i(install_action->options.replacing()->begin()),
+ i_end(install_action->options.replacing()->end()) ;
+ i != i_end ; ++i)
+ {
+ Context local_context("When cleaning '" + stringify(**i) + "':");
+
+ UninstallActionOptions uo(make_named_values<UninstallActionOptions>(
+ value_for<n::config_protect>(used_config_protect),
+ value_for<n::if_for_install_id>(shared_from_this()),
+ value_for<n::ignore_for_unmerge>(&ignore_nothing),
+ value_for<n::is_overwrite>(false),
+ value_for<n::make_output_manager>(std::tr1::bind(
+ &this_output_manager, output_manager, std::tr1::placeholders::_1))
+ ));
+ install_action->options.perform_uninstall()(*i, uo);
+ }
}
std::tr1::shared_ptr<const Set<std::string> >
diff --git a/paludis/repositories/unavailable/unavailable_repository_id.hh b/paludis/repositories/unavailable/unavailable_repository_id.hh
index a9b4ab4..b5e97d2 100644
--- a/paludis/repositories/unavailable/unavailable_repository_id.hh
+++ b/paludis/repositories/unavailable/unavailable_repository_id.hh
@@ -24,6 +24,7 @@
#include <paludis/package_id.hh>
#include <paludis/repositories/unavailable/unavailable_repository_file-fwd.hh>
#include <paludis/repositories/unavailable/unavailable_repository-fwd.hh>
+#include <tr1/memory>
namespace paludis
{
@@ -55,7 +56,8 @@ namespace paludis
class PALUDIS_VISIBLE UnavailableRepositoryID :
public PackageID,
- private PrivateImplementationPattern<UnavailableRepositoryID>
+ private PrivateImplementationPattern<UnavailableRepositoryID>,
+ public std::tr1::enable_shared_from_this<UnavailableRepositoryID>
{
private:
PrivateImplementationPattern<UnavailableRepositoryID>::ImpPtr & _imp;
@@ -106,7 +108,7 @@ namespace paludis
bool supports_action(const SupportsActionTestBase &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- void perform_action(Action &) const PALUDIS_ATTRIBUTE((noreturn));
+ void perform_action(Action &) const;
std::tr1::shared_ptr<const Set<std::string> > breaks_portage() const
PALUDIS_ATTRIBUTE((warn_unused_result));