aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-02-15 14:41:49 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-02-15 14:41:49 +0000
commitc954a40d2348694ede9c281c6fc7f2e18aafe396 (patch)
tree8e31d9b6db0ee34ec9260bce0ecf206352ede523
parentfd7d95ea636342ca160830add2f81e00fab15f34 (diff)
parented5c1be29d5eed73ec272b47d1bad9eea5e44687 (diff)
downloadpaludis-c954a40d2348694ede9c281c6fc7f2e18aafe396.tar.gz
paludis-c954a40d2348694ede9c281c6fc7f2e18aafe396.tar.xz
Merge branch 'logging'
-rw-r--r--configure.ac1
-rw-r--r--doc/api/cplusplus/examples/example_action.cc15
-rw-r--r--hooks/Makefile.am.m42
-rw-r--r--paludis/Makefile.am.m42
-rw-r--r--paludis/action-fwd.hh3
-rw-r--r--paludis/action.cc61
-rw-r--r--paludis/action.hh136
-rw-r--r--paludis/create_output_manager_info-fwd.hh36
-rw-r--r--paludis/create_output_manager_info.cc118
-rw-r--r--paludis/create_output_manager_info.hh100
-rw-r--r--paludis/create_output_manager_info.se23
-rw-r--r--paludis/distributions/exherbo/paludis.conf2
-rw-r--r--paludis/distributions/gentoo/paludis.conf2
-rw-r--r--paludis/environment-fwd.hh6
-rw-r--r--paludis/environment.cc2
-rw-r--r--paludis/environment.hh23
-rw-r--r--paludis/environments/no_config/no_config_environment.cc7
-rw-r--r--paludis/environments/no_config/no_config_environment.hh3
-rw-r--r--paludis/environments/paludis/Makefile.am15
-rw-r--r--paludis/environments/paludis/action_to_string.cc77
-rw-r--r--paludis/environments/paludis/action_to_string.hh34
-rw-r--r--paludis/environments/paludis/bashable_conf.cc35
-rw-r--r--paludis/environments/paludis/bashable_conf.hh3
-rw-r--r--paludis/environments/paludis/default_output.conf15
-rw-r--r--paludis/environments/paludis/extra_distribution_data.cc4
-rw-r--r--paludis/environments/paludis/extra_distribution_data.hh6
-rw-r--r--paludis/environments/paludis/output_conf.cc269
-rw-r--r--paludis/environments/paludis/output_conf.hh64
-rw-r--r--paludis/environments/paludis/output_managers.cc196
-rw-r--r--paludis/environments/paludis/output_managers.hh75
-rw-r--r--paludis/environments/paludis/output_managers/Makefile.am41
-rw-r--r--paludis/environments/paludis/output_managers/keep_messages.part.conf10
-rw-r--r--paludis/environments/paludis/output_managers/keep_stdout_as_messages.part.conf10
-rw-r--r--paludis/environments/paludis/output_managers/logged.conf6
-rw-r--r--paludis/environments/paludis/output_managers/logged_only.part.conf11
-rw-r--r--paludis/environments/paludis/output_managers/quiet.conf6
-rw-r--r--paludis/environments/paludis/output_managers/show_messages.part.conf5
-rw-r--r--paludis/environments/paludis/output_managers/standard.conf4
-rw-r--r--paludis/environments/paludis/paludis_config.cc86
-rw-r--r--paludis/environments/paludis/paludis_config.hh6
-rw-r--r--paludis/environments/paludis/paludis_environment.cc15
-rw-r--r--paludis/environments/paludis/paludis_environment.hh7
-rw-r--r--paludis/environments/paludis/tests_output.conf1
-rw-r--r--paludis/environments/portage/portage_environment.cc7
-rw-r--r--paludis/environments/portage/portage_environment.hh3
-rw-r--r--paludis/environments/test/test_environment.cc7
-rw-r--r--paludis/environments/test/test_environment.hh2
-rw-r--r--paludis/file_output_manager-fwd.hh (renamed from paludis/util/output_deviator-fwd.hh)9
-rw-r--r--paludis/file_output_manager.cc206
-rw-r--r--paludis/file_output_manager.hh66
-rw-r--r--paludis/files.m48
-rw-r--r--paludis/install_task.cc124
-rw-r--r--paludis/install_task.hh22
-rw-r--r--paludis/messages_to_stdout_output_handler-fwd.hh28
-rw-r--r--paludis/messages_to_stdout_output_handler.cc171
-rw-r--r--paludis/messages_to_stdout_output_handler.hh71
-rw-r--r--paludis/ndbam_merger.cc12
-rw-r--r--paludis/ndbam_merger.hh5
-rw-r--r--paludis/ndbam_unmerger.cc4
-rw-r--r--paludis/ndbam_unmerger.hh5
-rw-r--r--paludis/output_manager-fwd.hh34
-rw-r--r--paludis/output_manager.cc32
-rw-r--r--paludis/output_manager.hh66
-rw-r--r--paludis/output_manager.se22
-rw-r--r--paludis/output_manager_factory-fwd.hh28
-rw-r--r--paludis/output_manager_factory.cc141
-rw-r--r--paludis/output_manager_factory.hh110
-rw-r--r--paludis/output_manager_from_environment-fwd.hh28
-rw-r--r--paludis/output_manager_from_environment.cc88
-rw-r--r--paludis/output_manager_from_environment.hh57
-rw-r--r--paludis/repositories/accounts/Makefile.am2
-rw-r--r--paludis/repositories/accounts/accounts_id.cc7
-rw-r--r--paludis/repositories/accounts/dummy_accounts_handler.cc7
-rw-r--r--paludis/repositories/accounts/passwd_accounts_handler.cc10
-rw-r--r--paludis/repositories/cran/Makefile.am2
-rw-r--r--paludis/repositories/cran/cran_repository.cc49
-rw-r--r--paludis/repositories/cran/cran_repository.hh4
-rw-r--r--paludis/repositories/e/Makefile.am2
-rw-r--r--paludis/repositories/e/check_fetched_files_visitor.cc39
-rw-r--r--paludis/repositories/e/check_fetched_files_visitor.hh6
-rw-r--r--paludis/repositories/e/e_installed_repository.cc14
-rw-r--r--paludis/repositories/e/e_installed_repository.hh16
-rw-r--r--paludis/repositories/e/e_installed_repository_id.cc12
-rw-r--r--paludis/repositories/e/e_repository.cc5
-rw-r--r--paludis/repositories/e/e_repository.hh4
-rw-r--r--paludis/repositories/e/e_repository_TEST.cc21
-rw-r--r--paludis/repositories/e/e_repository_TEST_ever.cc8
-rw-r--r--paludis/repositories/e/e_repository_TEST_exlibs.cc7
-rw-r--r--paludis/repositories/e/e_repository_entries.hh10
-rw-r--r--paludis/repositories/e/e_stripper.cc13
-rw-r--r--paludis/repositories/e/e_stripper.hh5
-rw-r--r--paludis/repositories/e/ebuild.cc27
-rw-r--r--paludis/repositories/e/ebuild.hh6
-rw-r--r--paludis/repositories/e/ebuild/0/Makefile.am2
-rw-r--r--paludis/repositories/e/ebuild/1/Makefile.am2
-rw-r--r--paludis/repositories/e/ebuild/2/Makefile.am2
-rw-r--r--paludis/repositories/e/ebuild/Makefile.am2
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/Makefile.am2
-rw-r--r--paludis/repositories/e/ebuild/kdebuild-1/Makefile.am2
-rw-r--r--paludis/repositories/e/ebuild/paludis-1/Makefile.am2
-rw-r--r--paludis/repositories/e/ebuild/pbin-1/Makefile.am2
-rw-r--r--paludis/repositories/e/ebuild_entries.cc76
-rw-r--r--paludis/repositories/e/ebuild_entries.hh11
-rw-r--r--paludis/repositories/e/ebuild_id.cc5
-rw-r--r--paludis/repositories/e/exndbam_repository.cc39
-rw-r--r--paludis/repositories/e/exndbam_repository.hh8
-rw-r--r--paludis/repositories/e/exndbam_repository_TEST.cc11
-rw-r--r--paludis/repositories/e/fetch_visitor.cc22
-rw-r--r--paludis/repositories/e/fetch_visitor.hh6
-rw-r--r--paludis/repositories/e/fetch_visitor_TEST.cc3
-rw-r--r--paludis/repositories/e/pipe_command_handler.cc38
-rw-r--r--paludis/repositories/e/pipe_command_handler.hh6
-rw-r--r--paludis/repositories/e/qa/Makefile.am2
-rw-r--r--paludis/repositories/e/qa/manifest.cc1
-rw-r--r--paludis/repositories/e/vdb_merger.cc12
-rw-r--r--paludis/repositories/e/vdb_merger.hh5
-rw-r--r--paludis/repositories/e/vdb_merger_TEST.cc3
-rw-r--r--paludis/repositories/e/vdb_repository.cc44
-rw-r--r--paludis/repositories/e/vdb_repository.hh8
-rw-r--r--paludis/repositories/e/vdb_repository_TEST.cc51
-rw-r--r--paludis/repositories/e/vdb_unmerger.cc4
-rw-r--r--paludis/repositories/e/vdb_unmerger.hh4
-rw-r--r--paludis/repositories/e/vdb_unmerger_TEST.cc3
-rw-r--r--paludis/repositories/fake/Makefile.am2
-rw-r--r--paludis/repositories/gems/Makefile.am2
-rw-r--r--paludis/repositories/unavailable/Makefile.am2
-rw-r--r--paludis/repositories/unavailable/unavailable_repository.cc7
-rw-r--r--paludis/repositories/unavailable/unavailable_repository.hh4
-rw-r--r--paludis/repositories/unpackaged/Makefile.am2
-rw-r--r--paludis/repositories/unpackaged/installed_id.cc10
-rw-r--r--paludis/repositories/unpackaged/installed_id.hh3
-rw-r--r--paludis/repositories/unpackaged/installed_repository.cc3
-rw-r--r--paludis/repositories/unpackaged/installed_repository_TEST.cc21
-rw-r--r--paludis/repositories/unpackaged/unpackaged_id.cc7
-rw-r--r--paludis/repositories/unpackaged/unpackaged_repository_TEST.cc8
-rw-r--r--paludis/repositories/unpackaged/unpackaged_stripper.cc13
-rw-r--r--paludis/repositories/unpackaged/unpackaged_stripper.hh5
-rw-r--r--paludis/repositories/unwritten/Makefile.am2
-rw-r--r--paludis/repositories/unwritten/unwritten_repository.cc7
-rw-r--r--paludis/repositories/unwritten/unwritten_repository.hh4
-rw-r--r--paludis/repositories/virtuals/Makefile.am2
-rw-r--r--paludis/repository.hh7
-rw-r--r--paludis/sohooks_TEST.cc1
-rw-r--r--paludis/standard_output_manager-fwd.hh28
-rw-r--r--paludis/standard_output_manager.cc73
-rw-r--r--paludis/standard_output_manager.hh56
-rw-r--r--paludis/syncer.cc16
-rw-r--r--paludis/syncer.hh13
-rw-r--r--paludis/tee_output_manager-fwd.hh34
-rw-r--r--paludis/tee_output_manager.cc122
-rw-r--r--paludis/tee_output_manager.hh63
-rw-r--r--paludis/uninstall_task.cc11
-rw-r--r--paludis/util/discard_output_stream.cc40
-rw-r--r--paludis/util/discard_output_stream.hh59
-rw-r--r--paludis/util/echo_functions.bash.in7
-rw-r--r--paludis/util/files.m42
-rw-r--r--paludis/util/map.cc3
-rw-r--r--paludis/util/output_deviator.cc144
-rw-r--r--paludis/util/output_deviator.hh71
-rw-r--r--paludis/util/tee_output_stream.cc59
-rw-r--r--paludis/util/tee_output_stream.hh54
-rw-r--r--python/Makefile.am2
-rw-r--r--python/action.cc87
-rwxr-xr-xpython/action_TEST.py6
-rw-r--r--python/environment.cc7
-rwxr-xr-xpython/package_id_TEST.py6
-rw-r--r--ruby/Makefile.am2
-rw-r--r--ruby/action.cc47
-rw-r--r--ruby/demos/Makefile.am2
-rw-r--r--src/clients/accerso/Makefile.am2
-rw-r--r--src/clients/accerso/accerso.cc18
-rw-r--r--src/clients/adjutrix/Makefile.am2
-rw-r--r--src/clients/appareo/Makefile.am2
-rw-r--r--src/clients/appareo/appareo.cc8
-rw-r--r--src/clients/cave/Makefile.am2
-rw-r--r--src/clients/cave/cmd_sync.cc83
-rw-r--r--src/clients/importare/Makefile.am2
-rw-r--r--src/clients/inquisitio/Makefile.am2
-rw-r--r--src/clients/instruo/Makefile.am2
-rw-r--r--src/clients/paludis/Makefile.am2
-rw-r--r--src/clients/paludis/do_config.cc14
-rw-r--r--src/clients/paludis/info.cc14
-rw-r--r--src/clients/reconcilio/Makefile.am2
-rw-r--r--src/output/console_install_task.cc68
-rw-r--r--src/output/console_install_task.hh14
185 files changed, 4231 insertions, 685 deletions
diff --git a/configure.ac b/configure.ac
index becd1fe..1634898 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1523,6 +1523,7 @@ AC_OUTPUT(
paludis/environments/Makefile
paludis/environments/no_config/Makefile
paludis/environments/paludis/Makefile
+ paludis/environments/paludis/output_managers/Makefile
paludis/environments/portage/Makefile
paludis/environments/test/Makefile
paludis/fetchers/Makefile
diff --git a/doc/api/cplusplus/examples/example_action.cc b/doc/api/cplusplus/examples/example_action.cc
index fc3f83d..45eacd8 100644
--- a/doc/api/cplusplus/examples/example_action.cc
+++ b/doc/api/cplusplus/examples/example_action.cc
@@ -23,6 +23,19 @@ using namespace examples;
using std::cout;
using std::endl;
+namespace
+{
+ /* Some actions need an OutputManager, but to avoid chicken / egg problems
+ * they take a function that creates an OutputManager as a parameter. Here
+ * we just use a StandardOutputManager, which sticks everything to stdout /
+ * stderr. More complex clients may use Environment::create_output_manager
+ * to use the user's preferences for logging etc. */
+ std::tr1::shared_ptr<OutputManager> make_standard_output_manager(const Action &)
+ {
+ return make_shared_ptr(new StandardOutputManager);
+ }
+}
+
int main(int argc, char * argv[])
{
int exit_status(0);
@@ -63,7 +76,7 @@ int main(int argc, char * argv[])
FetchAction fetch_action(make_named_values<FetchActionOptions>(
value_for<n::exclude_unmirrorable>(false),
value_for<n::fetch_unneeded>(false),
- value_for<n::maybe_output_deviant>(make_null_shared_ptr()),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::safe_resume>(true)
));
try
diff --git a/hooks/Makefile.am.m4 b/hooks/Makefile.am.m4
index e008f77..9512812 100644
--- a/hooks/Makefile.am.m4
+++ b/hooks/Makefile.am.m4
@@ -301,6 +301,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_SKIP_CONFIG="yes" \
PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \
PALUDIS_ENVIRONMENT_SO_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments`" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
TOP_SRCDIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_srcdir)`" \
TOP_BUILDDIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)`" \
bash $(top_srcdir)/hooks/run_test.bash
diff --git a/paludis/Makefile.am.m4 b/paludis/Makefile.am.m4
index 57ec966..a3100cd 100644
--- a/paludis/Makefile.am.m4
+++ b/paludis/Makefile.am.m4
@@ -200,6 +200,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_PC_SLOT=@PALUDIS_PC_SLOT@ \
PYTHONPATH="$(top_builddir)/python/" \
PALUDIS_PYTHON_DIR="$(top_srcdir)/python/" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
LD_LIBRARY_PATH="`echo $$LD_LIBRARY_PATH: | sed -e 's,^:,,'`` \
$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/.libs/ \
`:`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/util/.libs/ \
diff --git a/paludis/action-fwd.hh b/paludis/action-fwd.hh
index 2881e3d..127d785 100644
--- a/paludis/action-fwd.hh
+++ b/paludis/action-fwd.hh
@@ -56,6 +56,9 @@ namespace paludis
struct FetchActionOptions;
struct InstallActionOptions;
struct UninstallActionOptions;
+ struct InfoActionOptions;
+ struct ConfigActionOptions;
+ struct PretendActionOptions;
struct FetchActionFailure;
diff --git a/paludis/action.cc b/paludis/action.cc
index 7fa330c..92a8e3c 100644
--- a/paludis/action.cc
+++ b/paludis/action.cc
@@ -111,16 +111,19 @@ namespace paludis
struct Implementation<PretendAction>
{
bool failed;
+ const PretendActionOptions options;
- Implementation() :
- failed(false)
+ Implementation(const PretendActionOptions & o) :
+ failed(false),
+ options(o)
{
}
};
}
-PretendAction::PretendAction() :
- PrivateImplementationPattern<PretendAction>(new Implementation<PretendAction>)
+PretendAction::PretendAction(const PretendActionOptions & o) :
+ PrivateImplementationPattern<PretendAction>(new Implementation<PretendAction>(o)),
+ options(_imp->options)
{
}
@@ -164,6 +167,54 @@ PretendFetchAction::~PretendFetchAction()
{
}
+namespace paludis
+{
+ template <>
+ struct Implementation<InfoAction>
+ {
+ const InfoActionOptions options;
+
+ Implementation(const InfoActionOptions & o) :
+ options(o)
+ {
+ }
+ };
+}
+
+InfoAction::InfoAction(const InfoActionOptions & o) :
+ PrivateImplementationPattern<InfoAction>(new Implementation<InfoAction>(o)),
+ options(_imp->options)
+{
+}
+
+InfoAction::~InfoAction()
+{
+}
+
+namespace paludis
+{
+ template <>
+ struct Implementation<ConfigAction>
+ {
+ const ConfigActionOptions options;
+
+ Implementation(const ConfigActionOptions & o) :
+ options(o)
+ {
+ }
+ };
+}
+
+ConfigAction::ConfigAction(const ConfigActionOptions & o) :
+ PrivateImplementationPattern<ConfigAction>(new Implementation<ConfigAction>(o)),
+ options(_imp->options)
+{
+}
+
+ConfigAction::~ConfigAction()
+{
+}
+
SupportsActionTestBase::~SupportsActionTestBase()
{
}
@@ -283,6 +334,8 @@ template class PrivateImplementationPattern<InstallAction>;
template class PrivateImplementationPattern<PretendAction>;
template class PrivateImplementationPattern<PretendFetchAction>;
template class PrivateImplementationPattern<UninstallAction>;
+template class PrivateImplementationPattern<InfoAction>;
+template class PrivateImplementationPattern<ConfigAction>;
template class Sequence<FetchActionFailure>;
template class WrappedForwardIterator<Sequence<FetchActionFailure>::ConstIteratorTag, const FetchActionFailure>;
diff --git a/paludis/action.hh b/paludis/action.hh
index 4cbbd1c..fd1f436 100644
--- a/paludis/action.hh
+++ b/paludis/action.hh
@@ -30,7 +30,7 @@
#include <paludis/util/sequence-fwd.hh>
#include <paludis/util/named_value.hh>
#include <paludis/util/fs_entry-fwd.hh>
-#include <paludis/util/output_deviator-fwd.hh>
+#include <paludis/output_manager-fwd.hh>
#include <paludis/util/type_list.hh>
#include <tr1/functional>
@@ -54,7 +54,7 @@ namespace paludis
struct failed_automatic_fetching;
struct failed_integrity_checks;
struct fetch_unneeded;
- struct maybe_output_deviant;
+ struct make_output_manager;
struct requires_manual_fetching;
struct safe_resume;
struct target_file;
@@ -79,10 +79,13 @@ namespace paludis
NamedValue<n::fetch_unneeded, bool> fetch_unneeded;
/**
- * May be an empty pointer, for no deviation.
- * \since 0.32
+ * This is a function to avoid chicken / egg problems when using
+ * Environment::create_output_manager.
+ *
+ * \since 0.36
*/
- NamedValue<n::maybe_output_deviant, std::tr1::shared_ptr<OutputDeviant> > maybe_output_deviant;
+ NamedValue<n::make_output_manager, std::tr1::function<std::tr1::shared_ptr<OutputManager> (
+ const FetchAction &)> > make_output_manager;
NamedValue<n::safe_resume, bool> safe_resume;
};
@@ -97,6 +100,16 @@ namespace paludis
struct InstallActionOptions
{
NamedValue<n::destination, std::tr1::shared_ptr<Repository> > destination;
+
+ /**
+ * This is a function to avoid chicken / egg problems when using
+ * Environment::create_output_manager.
+ *
+ * \since 0.36
+ */
+ NamedValue<n::make_output_manager, std::tr1::function<std::tr1::shared_ptr<OutputManager> (
+ const InstallAction &)> > make_output_manager;
+
NamedValue<n::used_this_for_config_protect, std::tr1::function<void (const std::string &)> > used_this_for_config_protect;
NamedValue<n::want_phase, std::tr1::function<WantPhase (const std::string &)> > want_phase;
};
@@ -111,6 +124,15 @@ namespace paludis
struct UninstallActionOptions
{
NamedValue<n::config_protect, std::string> config_protect;
+
+ /**
+ * This is a function to avoid chicken / egg problems when using
+ * Environment::create_output_manager.
+ *
+ * \since 0.36
+ */
+ NamedValue<n::make_output_manager, std::tr1::function<std::tr1::shared_ptr<OutputManager> (
+ const UninstallAction &)> > make_output_manager;
};
/**
@@ -244,6 +266,25 @@ namespace paludis
};
/**
+ * Options for a PretendAction.
+ *
+ * \see PretendAction
+ * \ingroup g_actions
+ * \since 0.36
+ */
+ struct PretendActionOptions
+ {
+ /**
+ * This is a function to avoid chicken / egg problems when using
+ * Environment::create_output_manager.
+ *
+ * \since 0.36
+ */
+ NamedValue<n::make_output_manager, std::tr1::function<std::tr1::shared_ptr<OutputManager> (
+ const PretendAction &)> > make_output_manager;
+ };
+
+ /**
* A PretendAction is used by InstallTask to handle install-pretend-phase
* checks on a PackageID.
*
@@ -260,7 +301,10 @@ namespace paludis
///\name Basic operations
///\{
- PretendAction();
+ /**
+ * \since 0.36
+ */
+ PretendAction(const PretendActionOptions &);
~PretendAction();
///\}
@@ -270,6 +314,11 @@ namespace paludis
/// Mark the action as failed.
void set_failed();
+
+ /**
+ * \since 0.36
+ */
+ const PretendActionOptions & options;
};
/**
@@ -302,6 +351,25 @@ namespace paludis
};
/**
+ * Options for a ConfigAction.
+ *
+ * \see ConfigAction
+ * \ingroup g_actions
+ * \since 0.36
+ */
+ struct ConfigActionOptions
+ {
+ /**
+ * This is a function to avoid chicken / egg problems when using
+ * Environment::create_output_manager.
+ *
+ * \since 0.36
+ */
+ NamedValue<n::make_output_manager, std::tr1::function<std::tr1::shared_ptr<OutputManager> (
+ const ConfigAction &)> > make_output_manager;
+ };
+
+ /**
* A ConfigAction is used via PackageID::perform_action to execute
* post-install configuration (for example, via 'paludis --config')
* on a PackageID.
@@ -312,8 +380,44 @@ namespace paludis
*/
class PALUDIS_VISIBLE ConfigAction :
public Action,
+ private PrivateImplementationPattern<ConfigAction>,
public ImplementAcceptMethods<Action, ConfigAction>
{
+ public:
+ ///\name Basic operations
+ ///\{
+
+ /**
+ * \since 0.36
+ */
+ ConfigAction(const ConfigActionOptions &);
+ ~ConfigAction();
+
+ ///\}
+
+ /**
+ * \since 0.36
+ */
+ const ConfigActionOptions & options;
+ };
+
+ /**
+ * Options for an InfoAction.
+ *
+ * \see InfoAction
+ * \ingroup g_actions
+ * \since 0.36
+ */
+ struct InfoActionOptions
+ {
+ /**
+ * This is a function to avoid chicken / egg problems when using
+ * Environment::create_output_manager.
+ *
+ * \since 0.36
+ */
+ NamedValue<n::make_output_manager, std::tr1::function<std::tr1::shared_ptr<OutputManager> (
+ const InfoAction &)> > make_output_manager;
};
/**
@@ -331,8 +435,26 @@ namespace paludis
*/
class PALUDIS_VISIBLE InfoAction:
public Action,
+ private PrivateImplementationPattern<InfoAction>,
public ImplementAcceptMethods<Action, InfoAction>
{
+ public:
+ ///\name Basic operations
+ ///\{
+
+ /**
+ * \since 0.36
+ */
+ InfoAction(const InfoActionOptions &);
+
+ ~InfoAction();
+
+ ///\}
+
+ /**
+ * \since 0.36
+ */
+ const InfoActionOptions & options;
};
/**
@@ -535,6 +657,8 @@ namespace paludis
extern template class PrivateImplementationPattern<PretendAction>;
extern template class PrivateImplementationPattern<PretendFetchAction>;
extern template class PrivateImplementationPattern<UninstallAction>;
+ extern template class PrivateImplementationPattern<InfoAction>;
+ extern template class PrivateImplementationPattern<ConfigAction>;
#endif
}
diff --git a/paludis/create_output_manager_info-fwd.hh b/paludis/create_output_manager_info-fwd.hh
new file mode 100644
index 0000000..ca25778
--- /dev/null
+++ b/paludis/create_output_manager_info-fwd.hh
@@ -0,0 +1,36 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_CREATE_OUTPUT_MANAGER_INFO_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_CREATE_OUTPUT_MANAGER_INFO_FWD_HH 1
+
+#include <paludis/util/attributes.hh>
+#include <iosfwd>
+
+namespace paludis
+{
+ class CreateOutputManagerInfo;
+ class CreateOutputManagerForPackageIDActionInfo;
+ class CreateOutputManagerForRepositorySyncInfo;
+
+#include <paludis/create_output_manager_info-se.hh>
+
+}
+
+#endif
diff --git a/paludis/create_output_manager_info.cc b/paludis/create_output_manager_info.cc
new file mode 100644
index 0000000..7717085
--- /dev/null
+++ b/paludis/create_output_manager_info.cc
@@ -0,0 +1,118 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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 <paludis/create_output_manager_info.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/exception.hh>
+#include <ostream>
+
+using namespace paludis;
+
+#include <paludis/create_output_manager_info-se.cc>
+
+namespace paludis
+{
+ template <>
+ struct Implementation<CreateOutputManagerForPackageIDActionInfo>
+ {
+ const std::tr1::shared_ptr<const PackageID> id;
+ const Action & action;
+ const OutputExclusivity output_exclusivity;
+
+ Implementation(const std::tr1::shared_ptr<const PackageID> & i,
+ const Action & a, const OutputExclusivity e) :
+ id(i),
+ action(a),
+ output_exclusivity(e)
+ {
+ }
+ };
+
+ template <>
+ struct Implementation<CreateOutputManagerForRepositorySyncInfo>
+ {
+ const Repository & repo;
+ const OutputExclusivity output_exclusivity;
+
+ Implementation(const Repository & r, const OutputExclusivity e) :
+ repo(r),
+ output_exclusivity(e)
+ {
+ }
+ };
+}
+
+CreateOutputManagerForPackageIDActionInfo::CreateOutputManagerForPackageIDActionInfo(
+ const std::tr1::shared_ptr<const PackageID> & i,
+ const Action & a,
+ const OutputExclusivity e) :
+ PrivateImplementationPattern<CreateOutputManagerForPackageIDActionInfo>(
+ new Implementation<CreateOutputManagerForPackageIDActionInfo>(i, a, e))
+{
+}
+
+CreateOutputManagerForPackageIDActionInfo::~CreateOutputManagerForPackageIDActionInfo()
+{
+}
+
+const std::tr1::shared_ptr<const PackageID>
+CreateOutputManagerForPackageIDActionInfo::package_id() const
+{
+ return _imp->id;
+}
+
+const Action &
+CreateOutputManagerForPackageIDActionInfo::action() const
+{
+ return _imp->action;
+}
+
+const OutputExclusivity
+CreateOutputManagerForPackageIDActionInfo::output_exclusivity() const
+{
+ return _imp->output_exclusivity;
+}
+
+CreateOutputManagerForRepositorySyncInfo::CreateOutputManagerForRepositorySyncInfo(
+ const Repository & r, const OutputExclusivity e) :
+ PrivateImplementationPattern<CreateOutputManagerForRepositorySyncInfo>(
+ new Implementation<CreateOutputManagerForRepositorySyncInfo>(r, e))
+{
+}
+
+CreateOutputManagerForRepositorySyncInfo::~CreateOutputManagerForRepositorySyncInfo()
+{
+}
+
+const Repository &
+CreateOutputManagerForRepositorySyncInfo::repository() const
+{
+ return _imp->repo;
+}
+
+const OutputExclusivity
+CreateOutputManagerForRepositorySyncInfo::output_exclusivity() const
+{
+ return _imp->output_exclusivity;
+}
+
+template class PrivateImplementationPattern<CreateOutputManagerForRepositorySyncInfo>;
+template class PrivateImplementationPattern<CreateOutputManagerForPackageIDActionInfo>;
+
diff --git a/paludis/create_output_manager_info.hh b/paludis/create_output_manager_info.hh
new file mode 100644
index 0000000..4ce3f7d
--- /dev/null
+++ b/paludis/create_output_manager_info.hh
@@ -0,0 +1,100 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_CREATE_OUTPUT_MANAGER_INFO_HH
+#define PALUDIS_GUARD_PALUDIS_CREATE_OUTPUT_MANAGER_INFO_HH 1
+
+#include <paludis/create_output_manager_info-fwd.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/simple_visitor.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/util/type_list.hh>
+#include <paludis/action-fwd.hh>
+#include <paludis/package_id-fwd.hh>
+#include <paludis/repository-fwd.hh>
+
+namespace paludis
+{
+ /**
+ * Information for Environment::create_output_manager.
+ *
+ * \since 0.36
+ * \ingroup g_environment
+ * \see Environment::create_output_manager
+ */
+ class PALUDIS_VISIBLE CreateOutputManagerInfo :
+ public virtual DeclareAbstractAcceptMethods<CreateOutputManagerInfo, MakeTypeList<
+ CreateOutputManagerForPackageIDActionInfo,
+ CreateOutputManagerForRepositorySyncInfo
+ >::Type>
+ {
+ };
+
+ /**
+ * Information for Environment::create_output_manager, if we're performing a
+ * PackageID action.
+ *
+ * \since 0.36
+ * \ingroup g_environment
+ * \see Environment::create_output_manager
+ */
+ class PALUDIS_VISIBLE CreateOutputManagerForPackageIDActionInfo :
+ private PrivateImplementationPattern<CreateOutputManagerForPackageIDActionInfo>,
+ public CreateOutputManagerInfo,
+ public ImplementAcceptMethods<CreateOutputManagerInfo, CreateOutputManagerForPackageIDActionInfo>
+ {
+ public:
+ CreateOutputManagerForPackageIDActionInfo(
+ const std::tr1::shared_ptr<const PackageID> & id,
+ const Action & action,
+ const OutputExclusivity output_exclusivity);
+
+ ~CreateOutputManagerForPackageIDActionInfo();
+
+ const std::tr1::shared_ptr<const PackageID> package_id() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const Action & action() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const OutputExclusivity output_exclusivity() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ /**
+ * Information for Environment::create_output_manager, if we're performing a
+ * Repository sync.
+ *
+ * \since 0.36
+ * \ingroup g_environment
+ * \see Environment::create_output_manager
+ */
+ class PALUDIS_VISIBLE CreateOutputManagerForRepositorySyncInfo :
+ private PrivateImplementationPattern<CreateOutputManagerForRepositorySyncInfo>,
+ public CreateOutputManagerInfo,
+ public ImplementAcceptMethods<CreateOutputManagerInfo, CreateOutputManagerForRepositorySyncInfo>
+ {
+ public:
+ CreateOutputManagerForRepositorySyncInfo(
+ const Repository & repo,
+ const OutputExclusivity);
+
+ ~CreateOutputManagerForRepositorySyncInfo();
+
+ const Repository & repository() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ const OutputExclusivity output_exclusivity() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+}
+
+#endif
diff --git a/paludis/create_output_manager_info.se b/paludis/create_output_manager_info.se
new file mode 100644
index 0000000..7a51cde
--- /dev/null
+++ b/paludis/create_output_manager_info.se
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+# vim: set sw=4 sts=4 et ft=sh :
+
+make_enum_OutputExclusivity()
+{
+ prefix oe
+
+ key oe_background "Run in the background, produce no output"
+ key oe_with_others "Other things may be running at the same time"
+ key oe_exclusive "We are the only thing running"
+
+ want_destringify
+
+ doxygen_comment << "END"
+ /**
+ * Options telling most CreateOutputManagerInfo subclasses whether we
+ * will be run exclusively or with other tasks.
+ *
+ * \see CreateOutputManagerInfo
+ */
+END
+}
+
diff --git a/paludis/distributions/exherbo/paludis.conf b/paludis/distributions/exherbo/paludis.conf
index cd01858..be3b043 100644
--- a/paludis/distributions/exherbo/paludis.conf
+++ b/paludis/distributions/exherbo/paludis.conf
@@ -3,6 +3,8 @@ keywords_filename_part = platforms
licenses_filename_part = licences
mandatory_userpriv = true
mirrors_filename_part = mirrors
+output_filename_part = output
+output_managers_directory = output_managers
package_mask_filename_part = package_mask
package_unmask_filename_part = package_unmask
repositories_directory = repositories
diff --git a/paludis/distributions/gentoo/paludis.conf b/paludis/distributions/gentoo/paludis.conf
index 1c5b97e..0c270f4 100644
--- a/paludis/distributions/gentoo/paludis.conf
+++ b/paludis/distributions/gentoo/paludis.conf
@@ -3,6 +3,8 @@ keywords_filename_part = keywords
licenses_filename_part = licenses
mandatory_userpriv = false
mirrors_filename_part = mirrors
+output_filename_part = output
+output_managers_directory = output_managers
package_mask_filename_part = package_mask
package_unmask_filename_part = package_unmask
repositories_directory = repositories
diff --git a/paludis/environment-fwd.hh b/paludis/environment-fwd.hh
index c0a4284..2b98d06 100644
--- a/paludis/environment-fwd.hh
+++ b/paludis/environment-fwd.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 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
@@ -41,6 +41,10 @@ namespace paludis
typedef Sequence<std::string> MirrorsSequence;
class Environment;
+
+ struct CreateOutputManagerInfo;
+ struct CreateOutputManagerForPackageIDActionInfo;
+ struct CreateOutputManagerForRepositorySyncInfo;
}
#endif
diff --git a/paludis/environment.cc b/paludis/environment.cc
index aad5bf4..9046b47 100644
--- a/paludis/environment.cc
+++ b/paludis/environment.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 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
diff --git a/paludis/environment.hh b/paludis/environment.hh
index 467b1a8..48c431b 100644
--- a/paludis/environment.hh
+++ b/paludis/environment.hh
@@ -25,6 +25,9 @@
#include <paludis/util/options-fwd.hh>
#include <paludis/util/fs_entry-fwd.hh>
#include <paludis/util/tribool-fwd.hh>
+#include <paludis/util/simple_visitor.hh>
+#include <paludis/output_manager-fwd.hh>
+#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/name-fwd.hh>
#include <paludis/hook-fwd.hh>
#include <paludis/repository-fwd.hh>
@@ -36,6 +39,7 @@
#include <paludis/selection-fwd.hh>
#include <paludis/metadata_key_holder.hh>
#include <paludis/choice-fwd.hh>
+#include <paludis/create_output_manager_info-fwd.hh>
/** \file
* Declarations for the Environment class.
@@ -365,7 +369,26 @@ namespace paludis
virtual const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > config_location_key() const = 0;
///\}
+
+ ///\name Output management
+ ///\{
+
+ /**
+ * Create an output manager.
+ *
+ * \since 0.36
+ */
+ virtual const std::tr1::shared_ptr<OutputManager> create_output_manager(
+ const CreateOutputManagerInfo &) const = 0;
+
+ ///\}
};
+
+#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
+ extern template class PrivateImplementationPattern<CreateOutputManagerForRepositorySyncInfo>;
+ extern template class PrivateImplementationPattern<CreateOutputManagerForPackageIDActionInfo>;
+#endif
+
}
#endif
diff --git a/paludis/environments/no_config/no_config_environment.cc b/paludis/environments/no_config/no_config_environment.cc
index 48a5953..9c5af10 100644
--- a/paludis/environments/no_config/no_config_environment.cc
+++ b/paludis/environments/no_config/no_config_environment.cc
@@ -35,6 +35,7 @@
#include <paludis/util/graph-impl.hh>
#include <paludis/util/hashes.hh>
#include <paludis/util/member_iterator-impl.hh>
+#include <paludis/standard_output_manager.hh>
#include <paludis/distribution.hh>
#include <paludis/package_database.hh>
#include <paludis/hook.hh>
@@ -632,3 +633,9 @@ NoConfigEnvironment::known_choice_value_names(
return make_shared_ptr(new Set<UnprefixedChoiceName>);
}
+const std::tr1::shared_ptr<OutputManager>
+NoConfigEnvironment::create_output_manager(const CreateOutputManagerInfo &) const
+{
+ return make_shared_ptr(new StandardOutputManager);
+}
+
diff --git a/paludis/environments/no_config/no_config_environment.hh b/paludis/environments/no_config/no_config_environment.hh
index e41a613..08307c1 100644
--- a/paludis/environments/no_config/no_config_environment.hh
+++ b/paludis/environments/no_config/no_config_environment.hh
@@ -202,6 +202,9 @@ namespace paludis
virtual const std::tr1::shared_ptr<const MetadataValueKey<std::string> > format_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > config_location_key() const;
+
+ virtual const std::tr1::shared_ptr<OutputManager> create_output_manager(
+ const CreateOutputManagerInfo &) const;
};
}
diff --git a/paludis/environments/paludis/Makefile.am b/paludis/environments/paludis/Makefile.am
index bbebe20..5aa5cd9 100644
--- a/paludis/environments/paludis/Makefile.am
+++ b/paludis/environments/paludis/Makefile.am
@@ -1,3 +1,4 @@
+SUBDIRS = output_managers .
CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda *.loT *.epicfail
BUILT_SOURCES = $(DISTCLEANFILES)
MAINTAINERCLEANFILES = Makefile.in
@@ -6,15 +7,19 @@ DEFS= \
-DSYSCONFDIR=\"$(sysconfdir)\" \
-DLIBEXECDIR=\"$(libexecdir)\" \
-DDATADIR=\"$(datadir)\" \
- -DLIBDIR=\"$(libdir)\"
+ -DLIBDIR=\"$(libdir)\" \
+ -DSHAREDIR=\"$(sharedir)\"
libpaludispaludisenvironment_@PALUDIS_PC_SLOT@_la_SOURCES = \
+ action_to_string.cc action_to_string.hh \
bashable_conf.cc bashable_conf.hh \
keywords_conf.cc keywords_conf.hh \
licenses_conf.cc licenses_conf.hh \
package_mask_conf.cc package_mask_conf.hh \
use_conf.cc use_conf.hh \
mirrors_conf.cc mirrors_conf.hh \
+ output_conf.cc output_conf.hh \
+ output_managers.cc output_managers.hh \
world.cc world.hh \
paludis_config.cc paludis_config.hh \
paludis_environment.cc paludis_environment.hh \
@@ -23,6 +28,12 @@ libpaludispaludisenvironment_@PALUDIS_PC_SLOT@_la_SOURCES = \
libpaludispaludisenvironment_@PALUDIS_PC_SLOT@_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0
+shareenvpaludisdir = $(sharedir)/paludis/environments/paludis/
+
+dist_shareenvpaludis_DATA = \
+ default_output.conf \
+ tests_output.conf
+
if ! MONOLITHIC
libpaludispaludisenvironment_@PALUDIS_PC_SLOT@_la_LIBADD = \
@@ -81,6 +92,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \
PALUDIS_NO_CHOWN="yes" \
PALUDIS_TESTS_KEEP_STDERR="yes" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
LD_LIBRARY_PATH="`echo $$LD_LIBRARY_PATH: | sed -e 's,^:,,'`` \
$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories/e/`:` \
$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories/e/.libs/`" \
diff --git a/paludis/environments/paludis/action_to_string.cc b/paludis/environments/paludis/action_to_string.cc
new file mode 100644
index 0000000..2058c5d
--- /dev/null
+++ b/paludis/environments/paludis/action_to_string.cc
@@ -0,0 +1,77 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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 <paludis/environments/paludis/action_to_string.hh>
+#include <paludis/action.hh>
+
+using namespace paludis;
+
+namespace
+{
+ struct ActionToString
+ {
+ std::string visit(const InstallAction &) const
+ {
+ return "install";
+ }
+
+ std::string visit(const PretendFetchAction &) const
+ {
+ return "pretend-fetch";
+ }
+
+ std::string visit(const UninstallAction &) const
+ {
+ return "uninstall";
+ }
+
+ std::string visit(const FetchAction &) const
+ {
+ return "fetch";
+ }
+
+ std::string visit(const PretendAction &) const
+ {
+ return "pretend";
+ }
+
+ std::string visit(const InfoAction &) const
+ {
+ return "info";
+ }
+
+ std::string visit(const ConfigAction &) const
+ {
+ return "config";
+ }
+
+ std::string visit(const InstalledAction &) const
+ {
+ return "installed";
+ }
+ };
+}
+
+const std::string
+paludis::paludis_environment::action_to_string(const Action & a)
+{
+ ActionToString v;
+ return a.accept_returning<std::string>(v);
+}
+
diff --git a/paludis/environments/paludis/action_to_string.hh b/paludis/environments/paludis/action_to_string.hh
new file mode 100644
index 0000000..a2049ef
--- /dev/null
+++ b/paludis/environments/paludis/action_to_string.hh
@@ -0,0 +1,34 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_ENVIRONMENTS_PALUDIS_ACTION_TO_STRING_HH
+#define PALUDIS_GUARD_PALUDIS_ENVIRONMENTS_PALUDIS_ACTION_TO_STRING_HH 1
+
+#include <string>
+#include <paludis/action-fwd.hh>
+
+namespace paludis
+{
+ namespace paludis_environment
+ {
+ const std::string action_to_string(const Action & a);
+ }
+}
+
+#endif
diff --git a/paludis/environments/paludis/bashable_conf.cc b/paludis/environments/paludis/bashable_conf.cc
index 69bf774..f1f6547 100644
--- a/paludis/environments/paludis/bashable_conf.cc
+++ b/paludis/environments/paludis/bashable_conf.cc
@@ -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
@@ -59,3 +59,36 @@ paludis::paludis_environment::make_bashable_conf(const FSEntry & f)
return result;
}
+std::tr1::shared_ptr<KeyValueConfigFile>
+paludis::paludis_environment::make_bashable_kv_conf(const FSEntry & f)
+{
+ Context context("When making a key=value config file out of '" + stringify(f) + "':");
+
+ std::tr1::shared_ptr<KeyValueConfigFile> result;
+
+ if (is_file_with_extension(f, ".bash", IsFileWithOptions()))
+ {
+ std::stringstream s;
+ Command cmd(Command("bash '" + stringify(f) + "'")
+ .with_setenv("PALUDIS_LOG_LEVEL", stringify(Log::get_instance()->log_level()))
+ .with_setenv("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis"))
+ .with_stderr_prefix(f.basename() + "> ")
+ .with_captured_stdout_stream(&s));
+ int exit_status(run_command(cmd));
+ result.reset(new KeyValueConfigFile(s, KeyValueConfigFileOptions(), &KeyValueConfigFile::no_defaults,
+ &KeyValueConfigFile::no_transformation));
+
+ if (exit_status != 0)
+ {
+ Log::get_instance()->message("paludis_environment.bash_conf.failure", ll_warning, lc_context)
+ << "Script '" << f <<"' returned non-zero exit status '" << exit_status << "'";
+ result.reset();
+ }
+ }
+ else
+ result.reset(new KeyValueConfigFile(f, KeyValueConfigFileOptions(), &KeyValueConfigFile::no_defaults,
+ &KeyValueConfigFile::no_transformation));
+
+ return result;
+}
+
diff --git a/paludis/environments/paludis/bashable_conf.hh b/paludis/environments/paludis/bashable_conf.hh
index f3819a8..6a6ede1 100644
--- a/paludis/environments/paludis/bashable_conf.hh
+++ b/paludis/environments/paludis/bashable_conf.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,7 @@ namespace paludis
namespace paludis_environment
{
std::tr1::shared_ptr<LineConfigFile> make_bashable_conf(const FSEntry &);
+ std::tr1::shared_ptr<KeyValueConfigFile> make_bashable_kv_conf(const FSEntry &);
}
}
diff --git a/paludis/environments/paludis/default_output.conf b/paludis/environments/paludis/default_output.conf
new file mode 100644
index 0000000..21ab224
--- /dev/null
+++ b/paludis/environments/paludis/default_output.conf
@@ -0,0 +1,15 @@
+# By default, output to stdout, keep logs of messages and keep output logs on
+# failure:
+
+type = * : logged
+
+# But if we're being run in the background, display only messages to stdout, and
+# keep logs of messages and keep output logs on failure:
+
+type = * output_exclusivity = background : quiet
+
+# We don't want to log pretend actions though. They're often run as a normal
+# user, and keeping logs isn't useful.
+
+type = package action = pretend : standard
+
diff --git a/paludis/environments/paludis/extra_distribution_data.cc b/paludis/environments/paludis/extra_distribution_data.cc
index 68d1d07..0893c63 100644
--- a/paludis/environments/paludis/extra_distribution_data.cc
+++ b/paludis/environments/paludis/extra_distribution_data.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 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
@@ -44,6 +44,8 @@ namespace paludis
value_for<n::licenses_filename_part>(k->get("licenses_filename_part")),
value_for<n::mandatory_userpriv>(destringify<bool>(k->get("mandatory_userpriv"))),
value_for<n::mirrors_filename_part>(k->get("mirrors_filename_part")),
+ value_for<n::output_filename_part>(k->get("output_filename_part")),
+ value_for<n::output_managers_directory>(k->get("output_managers_directory")),
value_for<n::package_mask_filename_part>(k->get("package_mask_filename_part")),
value_for<n::package_unmask_filename_part>(k->get("package_unmask_filename_part")),
value_for<n::repositories_directory>(k->get("repositories_directory")),
diff --git a/paludis/environments/paludis/extra_distribution_data.hh b/paludis/environments/paludis/extra_distribution_data.hh
index 963fa6f..0496e5d 100644
--- a/paludis/environments/paludis/extra_distribution_data.hh
+++ b/paludis/environments/paludis/extra_distribution_data.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 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
@@ -33,6 +33,8 @@ namespace paludis
struct licenses_filename_part;
struct mandatory_userpriv;
struct mirrors_filename_part;
+ struct output_filename_part;
+ struct output_managers_directory;
struct package_mask_filename_part;
struct package_unmask_filename_part;
struct repositories_directory;
@@ -49,6 +51,8 @@ namespace paludis
NamedValue<n::licenses_filename_part, std::string> licenses_filename_part;
NamedValue<n::mandatory_userpriv, bool> mandatory_userpriv;
NamedValue<n::mirrors_filename_part, std::string> mirrors_filename_part;
+ NamedValue<n::output_filename_part, std::string> output_filename_part;
+ NamedValue<n::output_managers_directory, std::string> output_managers_directory;
NamedValue<n::package_mask_filename_part, std::string> package_mask_filename_part;
NamedValue<n::package_unmask_filename_part, std::string> package_unmask_filename_part;
NamedValue<n::repositories_directory, std::string> repositories_directory;
diff --git a/paludis/environments/paludis/output_conf.cc b/paludis/environments/paludis/output_conf.cc
new file mode 100644
index 0000000..feee537
--- /dev/null
+++ b/paludis/environments/paludis/output_conf.cc
@@ -0,0 +1,269 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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 <paludis/environments/paludis/output_conf.hh>
+#include <paludis/environments/paludis/bashable_conf.hh>
+#include <paludis/environments/paludis/paludis_config.hh>
+#include <paludis/environments/paludis/paludis_environment.hh>
+#include <paludis/environments/paludis/action_to_string.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/tokeniser.hh>
+#include <paludis/util/named_value.hh>
+#include <paludis/util/make_named_values.hh>
+#include <paludis/util/config_file.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/destringify.hh>
+#include <paludis/util/options.hh>
+#include <paludis/util/make_shared_copy.hh>
+#include <paludis/user_dep_spec.hh>
+#include <paludis/create_output_manager_info.hh>
+#include <paludis/package_id.hh>
+#include <paludis/match_package.hh>
+#include <paludis/action.hh>
+#include <list>
+#include <vector>
+
+using namespace paludis;
+using namespace paludis::paludis_environment;
+
+namespace paludis
+{
+ namespace n
+ {
+ struct action_requirement;
+ struct manager;
+ struct matches_requirement;
+ struct name_requirement;
+ struct output_exclusivity_requirement;
+ struct type_requirement;
+ }
+}
+
+namespace
+{
+ struct Rule
+ {
+ NamedValue<n::action_requirement, std::string> action_requirement;
+ NamedValue<n::manager, std::string> manager;
+ NamedValue<n::matches_requirement, std::tr1::shared_ptr<PackageDepSpec> > matches_requirement;
+ NamedValue<n::name_requirement, std::string> name_requirement;
+ NamedValue<n::output_exclusivity_requirement, OutputExclusivity> output_exclusivity_requirement;
+ NamedValue<n::type_requirement, std::string> type_requirement;
+ };
+
+ typedef std::list<Rule> RuleList;
+}
+
+namespace paludis
+{
+ template<>
+ struct Implementation<OutputConf>
+ {
+ const PaludisEnvironment * const env;
+ RuleList rules;
+
+ Implementation(const PaludisEnvironment * const e) :
+ env(e)
+ {
+ }
+ };
+}
+
+OutputConf::OutputConf(const PaludisEnvironment * const e) :
+ PrivateImplementationPattern<OutputConf>(new Implementation<OutputConf>(e))
+{
+}
+
+OutputConf::~OutputConf()
+{
+}
+
+namespace
+{
+ void set_rule(const Environment * const env, Rule & rule, const std::string & k, const std::string & v)
+ {
+ if (k == "type")
+ rule.type_requirement() = v;
+ else if (k == "name")
+ rule.name_requirement() = v;
+ else if (k == "output_exclusivity")
+ rule.output_exclusivity_requirement() = destringify<OutputExclusivity>(v);
+ else if (k == "matches")
+ rule.matches_requirement() = make_shared_copy(parse_user_package_dep_spec(
+ v, env, UserPackageDepSpecOptions() + updso_allow_wildcards + updso_no_disambiguation));
+ else if (k == "action")
+ rule.action_requirement() = v;
+ else
+ throw PaludisConfigError("Unknown rule '" + k + "'");
+ }
+
+ struct MatchRuleVisitor
+ {
+ const Environment * const env;
+ const Rule & rule;
+
+ MatchRuleVisitor(const Environment * const e, const Rule & r) :
+ env(e),
+ rule(r)
+ {
+ }
+
+ bool visit(const CreateOutputManagerForRepositorySyncInfo & i) const
+ {
+ if (rule.type_requirement() != "*" && rule.type_requirement() != "repository")
+ return false;
+
+ if (rule.name_requirement() != "*" && rule.name_requirement() != stringify(i.repository().name()))
+ return false;
+
+ if (rule.action_requirement() != "*" && rule.action_requirement() != "sync")
+ return false;
+
+ if (-1 != rule.output_exclusivity_requirement() &&
+ rule.output_exclusivity_requirement() != i.output_exclusivity())
+ return false;
+
+ if (rule.matches_requirement())
+ return false;
+
+ return true;
+ }
+
+ bool visit(const CreateOutputManagerForPackageIDActionInfo & i) const
+ {
+ if (rule.type_requirement() != "*" && rule.type_requirement() != "package")
+ return false;
+
+ if (rule.name_requirement() != "*" && rule.name_requirement() != stringify(i.package_id()->name()))
+ return false;
+
+ if (rule.action_requirement() != "*" && rule.action_requirement() != action_to_string(i.action()))
+ return false;
+
+ if (-1 != rule.output_exclusivity_requirement() &&
+ rule.output_exclusivity_requirement() != i.output_exclusivity())
+ return false;
+
+ if (rule.matches_requirement() && ! match_package(*env, *rule.matches_requirement(),
+ *i.package_id(), MatchPackageOptions()))
+ return false;
+
+ return true;
+ }
+ };
+
+ bool match_rule(const Environment * const e, const Rule & rule, const CreateOutputManagerInfo & i)
+ {
+ MatchRuleVisitor v(e, rule);
+ return i.accept_returning<bool>(v);
+ }
+}
+
+void
+OutputConf::add(const FSEntry & filename)
+{
+ Context context("When adding source '" + stringify(filename) + "' as an output file:");
+
+ std::tr1::shared_ptr<LineConfigFile> f(make_bashable_conf(filename));
+ if (! f)
+ return;
+
+ for (LineConfigFile::ConstIterator line(f->begin()), line_end(f->end()) ;
+ line != line_end ; ++line)
+ {
+ std::vector<std::string> tokens;
+ tokenise_whitespace_quoted(*line, std::back_inserter(tokens));
+
+ if (tokens.empty())
+ continue;
+
+ if ("source" == tokens.at(0))
+ {
+ if (tokens.size() != 2)
+ throw PaludisConfigError("Invalid source line '" + *line + "'");
+
+ add(FSEntry(tokens.at(1)));
+ continue;
+ }
+
+ Rule rule(make_named_values<Rule>(
+ value_for<n::action_requirement>("*"),
+ value_for<n::manager>("unset"),
+ value_for<n::matches_requirement>(make_null_shared_ptr()),
+ value_for<n::name_requirement>("*"),
+ value_for<n::output_exclusivity_requirement>(static_cast<OutputExclusivity>(-1)),
+ value_for<n::type_requirement>("*")
+ ));
+
+ std::vector<std::string>::const_iterator t(tokens.begin()), t_end(tokens.end());
+
+ for ( ; t != t_end ; ++t)
+ {
+ if (*t == ":")
+ break;
+
+ std::string::size_type p(t->find("="));
+ if (std::string::npos != p)
+ set_rule(_imp->env, rule, t->substr(0, p), t->substr(p + 1));
+ else
+ {
+ std::string r(*t);
+ if (++t == t_end)
+ throw PaludisConfigError("Expected '=' but found end of line for line '" + *line + "'");
+
+ if (*t != "=")
+ throw PaludisConfigError("Expected '=' but found '" + *t + "' for line '" + *line + "'");
+
+ if (++t == t_end)
+ throw PaludisConfigError("Expected value but found end of for line '" + *line + "'");
+
+ set_rule(_imp->env, rule, r, *t);
+ }
+ }
+
+ if (t == t_end)
+ throw PaludisConfigError("Found no ':' for line '" + *line + "'");
+
+ if (++t == t_end)
+ throw PaludisConfigError("Found no manager after ':' for line '" + *line + "'");
+
+ rule.manager() = *t;
+ _imp->rules.push_back(rule);
+
+ if (++t != t_end)
+ throw PaludisConfigError("Trailing text after manager on line '" + *line + "'");
+ }
+}
+
+const std::tr1::shared_ptr<OutputManager>
+OutputConf::create_output_manager(const CreateOutputManagerInfo & i) const
+{
+ Context context("When creating output manager:");
+
+ for (RuleList::const_reverse_iterator r(_imp->rules.rbegin()), r_end(_imp->rules.rend()) ;
+ r != r_end ; ++r)
+ if (match_rule(_imp->env, *r, i))
+ return _imp->env->create_named_output_manager(r->manager(), i);
+
+ throw PaludisConfigError("No matching output manager rule specified");
+}
+
+template class PrivateImplementationPattern<paludis_environment::OutputConf>;
+
diff --git a/paludis/environments/paludis/output_conf.hh b/paludis/environments/paludis/output_conf.hh
new file mode 100644
index 0000000..903b03c
--- /dev/null
+++ b/paludis/environments/paludis/output_conf.hh
@@ -0,0 +1,64 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_ENVIRONMENTS_PALUDIS_OUTPUT_CONF_HH
+#define PALUDIS_GUARD_PALUDIS_ENVIRONMENTS_PALUDIS_OUTPUT_CONF_HH 1
+
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/instantiation_policy.hh>
+#include <paludis/util/fs_entry-fwd.hh>
+#include <paludis/output_manager-fwd.hh>
+#include <paludis/create_output_manager_info-fwd.hh>
+#include <tr1/memory>
+
+namespace paludis
+{
+ class PaludisEnvironment;
+
+ namespace paludis_environment
+ {
+ class OutputConf :
+ private PrivateImplementationPattern<OutputConf>,
+ private InstantiationPolicy<OutputConf, instantiation_method::NonCopyableTag>
+ {
+ public:
+ ///\name Basic operations
+ ///\{
+
+ OutputConf(const PaludisEnvironment * const);
+ ~OutputConf();
+
+ ///\}
+
+ /**
+ * Add another file.
+ */
+ void add(const FSEntry &);
+
+ const std::tr1::shared_ptr<OutputManager> create_output_manager(
+ const CreateOutputManagerInfo &) const;
+ };
+ }
+
+#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
+ extern template class PrivateImplementationPattern<paludis_environment::OutputConf>;
+#endif
+}
+
+#endif
diff --git a/paludis/environments/paludis/output_managers.cc b/paludis/environments/paludis/output_managers.cc
new file mode 100644
index 0000000..b448da9
--- /dev/null
+++ b/paludis/environments/paludis/output_managers.cc
@@ -0,0 +1,196 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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 <paludis/environments/paludis/output_managers.hh>
+#include <paludis/environments/paludis/bashable_conf.hh>
+#include <paludis/environments/paludis/paludis_config.hh>
+#include <paludis/environments/paludis/paludis_environment.hh>
+#include <paludis/environments/paludis/action_to_string.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/config_file.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/map.hh>
+#include <paludis/util/strip.hh>
+#include <paludis/util/simple_parser.hh>
+#include <paludis/output_manager_factory.hh>
+#include <paludis/create_output_manager_info.hh>
+#include <paludis/package_id.hh>
+#include <paludis/metadata_key.hh>
+#include <algorithm>
+#include <tr1/unordered_map>
+#include <sys/types.h>
+#include <unistd.h>
+#include <time.h>
+
+using namespace paludis;
+using namespace paludis::paludis_environment;
+
+namespace
+{
+ typedef std::tr1::unordered_map<std::string, std::tr1::shared_ptr<const KeyValueConfigFile> > Store;
+
+ std::string from_kv(const std::tr1::shared_ptr<const KeyValueConfigFile> & m,
+ const std::string & k)
+ {
+ return m->get(k);
+ }
+}
+
+namespace paludis
+{
+ template<>
+ struct Implementation<OutputManagers>
+ {
+ Store store;
+ };
+}
+
+OutputManagers::OutputManagers(const PaludisEnvironment * const) :
+ PrivateImplementationPattern<OutputManagers>(new Implementation<OutputManagers>)
+{
+}
+
+OutputManagers::~OutputManagers()
+{
+}
+
+void
+OutputManagers::add(const FSEntry & filename)
+{
+ Context context("When adding source '" + stringify(filename) + "' as an output manager file:");
+
+ std::tr1::shared_ptr<KeyValueConfigFile> f(make_bashable_kv_conf(filename));
+ if (! f)
+ return;
+
+ std::string manager(filename.basename());
+ manager = strip_trailing_string(manager, ".conf");
+ manager = strip_trailing_string(manager, ".bash");
+
+ _imp->store[manager] = f;
+}
+
+const std::tr1::shared_ptr<OutputManager>
+OutputManagers::create_named_output_manager(const std::string & s, const CreateOutputManagerInfo & n) const
+{
+ Context context("When creating output manager named '" + s + "':");
+
+ Store::const_iterator i(_imp->store.find(s));
+ if (i == _imp->store.end())
+ throw PaludisConfigError("No output manager named '" + s + "' exists");
+
+ std::tr1::shared_ptr<Map<std::string, std::string> > vars(vars_from_create_output_manager_info(n));
+ return OutputManagerFactory::get_instance()->create(
+ std::tr1::bind(&from_kv, i->second, std::tr1::placeholders::_1),
+ std::tr1::bind(&OutputManagers::create_named_output_manager, this, std::tr1::placeholders::_1, std::tr1::cref(n)),
+ std::tr1::bind(replace_percent_vars, std::tr1::placeholders::_1, vars, std::tr1::placeholders::_2)
+ );
+}
+
+namespace
+{
+ std::string escape(const std::string & s)
+ {
+ std::string result(s);
+ std::replace(result.begin(), result.end(), ' ', '_');
+ std::replace(result.begin(), result.end(), '/', '_');
+ return result;
+ }
+
+ struct CreateVarsFromInfo
+ {
+ std::tr1::shared_ptr<Map<std::string, std::string> > m;
+
+ CreateVarsFromInfo(std::tr1::shared_ptr<Map<std::string, std::string> > & mm) :
+ m(mm)
+ {
+ }
+
+ void visit(const CreateOutputManagerForRepositorySyncInfo & i)
+ {
+ m->insert("type", "repository");
+ m->insert("action", "sync");
+ m->insert("name", stringify(i.repository().name()));
+ m->insert("pid", stringify(getpid()));
+ m->insert("time", stringify(time(0)));
+ }
+
+ void visit(const CreateOutputManagerForPackageIDActionInfo & i)
+ {
+ m->insert("type", "package");
+ m->insert("action", action_to_string(i.action()));
+ m->insert("name", stringify(i.package_id()->name()));
+ m->insert("id", escape(stringify(*i.package_id())));
+ if (i.package_id()->slot_key())
+ m->insert("slot", stringify(i.package_id()->slot_key()->value()));
+ m->insert("version", stringify(i.package_id()->version()));
+ m->insert("repository", stringify(i.package_id()->repository()->name()));
+ m->insert("category", stringify(i.package_id()->name().category()));
+ m->insert("package", stringify(i.package_id()->name().package()));
+ m->insert("pid", stringify(getpid()));
+ m->insert("time", stringify(time(0)));
+ }
+ };
+}
+
+const std::tr1::shared_ptr<Map<std::string, std::string> >
+OutputManagers::vars_from_create_output_manager_info(
+ const CreateOutputManagerInfo & i) const
+{
+ std::tr1::shared_ptr<Map<std::string, std::string> > result(new Map<std::string, std::string>);
+ CreateVarsFromInfo v(result);
+ i.accept(v);
+ return result;
+}
+
+const std::string
+paludis::paludis_environment::replace_percent_vars(
+ const std::string & s,
+ const std::tr1::shared_ptr<const Map<std::string, std::string> > & vars,
+ const std::tr1::shared_ptr<const Map<std::string, std::string> > & override_vars)
+{
+ std::string result, token;
+ SimpleParser parser(s);
+ while (! parser.eof())
+ {
+ if (parser.consume((+simple_parser::any_except("%")) >> token))
+ result.append(token);
+ else if (parser.consume(simple_parser::exact("%%")))
+ result.append("%");
+ else if (parser.consume(simple_parser::exact("%{") &
+ ((+simple_parser::any_except("} \t\r\n%")) >> token) &
+ simple_parser::exact("}")))
+ {
+ Map<std::string, std::string>::ConstIterator v(override_vars->find(token));
+ if (v == override_vars->end())
+ v = vars->find(token);
+ if (v == vars->end())
+ throw PaludisConfigError("No variable named '" + token + "' in var string '" + s + "'");
+
+ result.append(v->second);
+ }
+ else
+ throw PaludisConfigError("Invalid var string '" + s + "'");
+ }
+
+ return result;
+}
+
+template class PrivateImplementationPattern<paludis_environment::OutputManagers>;
+
diff --git a/paludis/environments/paludis/output_managers.hh b/paludis/environments/paludis/output_managers.hh
new file mode 100644
index 0000000..80ad723
--- /dev/null
+++ b/paludis/environments/paludis/output_managers.hh
@@ -0,0 +1,75 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_ENVIRONMENTS_PALUDIS_OUTPUT_MANAGERS_HH
+#define PALUDIS_GUARD_PALUDIS_ENVIRONMENTS_PALUDIS_OUTPUT_MANAGERS_HH 1
+
+#include <paludis/util/attributes.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/instantiation_policy.hh>
+#include <paludis/util/fs_entry-fwd.hh>
+#include <paludis/util/map-fwd.hh>
+#include <paludis/output_manager-fwd.hh>
+#include <paludis/create_output_manager_info-fwd.hh>
+#include <tr1/memory>
+
+namespace paludis
+{
+ class PaludisEnvironment;
+
+ namespace paludis_environment
+ {
+ const std::string replace_percent_vars(
+ const std::string &,
+ const std::tr1::shared_ptr<const Map<std::string, std::string> > & vars,
+ const std::tr1::shared_ptr<const Map<std::string, std::string> > & override_vars);
+
+ class OutputManagers :
+ private PrivateImplementationPattern<OutputManagers>,
+ private InstantiationPolicy<OutputManagers, instantiation_method::NonCopyableTag>
+ {
+ public:
+ ///\name Basic operations
+ ///\{
+
+ OutputManagers(const PaludisEnvironment * const);
+ ~OutputManagers();
+
+ ///\}
+
+ /**
+ * Add another file.
+ */
+ void add(const FSEntry &);
+
+ const std::tr1::shared_ptr<OutputManager> create_named_output_manager(
+ const std::string &,
+ const CreateOutputManagerInfo &) const;
+
+ const std::tr1::shared_ptr<Map<std::string, std::string> > vars_from_create_output_manager_info(
+ const CreateOutputManagerInfo &) const;
+ };
+ }
+
+#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
+ extern template class PrivateImplementationPattern<paludis_environment::OutputManagers>;
+#endif
+}
+
+#endif
diff --git a/paludis/environments/paludis/output_managers/Makefile.am b/paludis/environments/paludis/output_managers/Makefile.am
new file mode 100644
index 0000000..fd16890
--- /dev/null
+++ b/paludis/environments/paludis/output_managers/Makefile.am
@@ -0,0 +1,41 @@
+SUBDIRS = .
+CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda *.loT *.epicfail .keep
+BUILT_SOURCES =
+MAINTAINERCLEANFILES = Makefile.in
+AM_CXXFLAGS = -I$(top_srcdir) @PALUDIS_CXXFLAGS@ @PALUDIS_CXXFLAGS_VISIBILITY@
+DEFS= \
+ -DSYSCONFDIR=\"$(sysconfdir)\" \
+ -DLIBEXECDIR=\"$(libexecdir)\" \
+ -DDATADIR=\"$(datadir)\" \
+ -DLIBDIR=\"$(libdir)\"
+
+shareenvpaludisdir = $(sharedir)/paludis/environments/paludis/output_managers
+
+dist_shareenvpaludis_DATA = \
+ logged.conf \
+ quiet.conf \
+ standard.conf \
+ keep_messages.part.conf \
+ keep_stdout_as_messages.part.conf \
+ logged_only.part.conf \
+ show_messages.part.conf
+
+logdir = /var/log/paludis
+
+log_DATA = .keep
+
+.keep :
+ touch $@
+
+built-sources : $(BUILT_SOURCES)
+ for s in `echo $(SUBDIRS) | tr -d .` ; do $(MAKE) -C $$s built-sources || exit 1 ; done
+
+distcheck-deps-local : $(DISTCHECK_DEPS)
+
+distcheck-deps : distcheck-deps-subdirs
+
+distcheck-deps-subdirs :
+ for s in $(SUBDIRS) . ; do if test x$$s = x. ; then $(MAKE) distcheck-deps-local || exit 1 ; \
+ else $(MAKE) -C $$s distcheck-deps || exit 1 ; fi ; done
+
+
diff --git a/paludis/environments/paludis/output_managers/keep_messages.part.conf b/paludis/environments/paludis/output_managers/keep_messages.part.conf
new file mode 100644
index 0000000..5cc0f7b
--- /dev/null
+++ b/paludis/environments/paludis/output_managers/keep_messages.part.conf
@@ -0,0 +1,10 @@
+# Keep message logs, ignore stdout / stderr. Not directly usable.
+
+handler = messages_to_stdout
+child = keep_stdout_as_messages.part
+format_debug =
+format_info = --- %{message}
+format_warn = *** %{message}
+format_error = !!! %{message}
+format_log = +++ %{message}
+
diff --git a/paludis/environments/paludis/output_managers/keep_stdout_as_messages.part.conf b/paludis/environments/paludis/output_managers/keep_stdout_as_messages.part.conf
new file mode 100644
index 0000000..ebbb5ee
--- /dev/null
+++ b/paludis/environments/paludis/output_managers/keep_stdout_as_messages.part.conf
@@ -0,0 +1,10 @@
+# Keep message logs. For use by keep_messages.part; do not use directly.
+
+handler = file
+stdout = /var/log/paludis/%{time}-%{action}-%{id}.messages
+stderr = ${stdout}
+keep_on_success = true
+keep_on_empty = false
+summary_output_manager = standard
+summary_output_stdout_message = Messages log: ${stdout}
+
diff --git a/paludis/environments/paludis/output_managers/logged.conf b/paludis/environments/paludis/output_managers/logged.conf
new file mode 100644
index 0000000..1e40328
--- /dev/null
+++ b/paludis/environments/paludis/output_managers/logged.conf
@@ -0,0 +1,6 @@
+# Output to stdout / stderr, keep logs of messages and keep output logs on
+# failure.
+
+handler = tee
+children = standard logged_only.part keep_messages.part
+
diff --git a/paludis/environments/paludis/output_managers/logged_only.part.conf b/paludis/environments/paludis/output_managers/logged_only.part.conf
new file mode 100644
index 0000000..08ba32d
--- /dev/null
+++ b/paludis/environments/paludis/output_managers/logged_only.part.conf
@@ -0,0 +1,11 @@
+# Keep logs of output only, and discard on success. Used by logged and quiet;
+# not directly usable.
+#
+handler = file
+stdout = /var/log/paludis/%{time}-%{action}-%{id}.out
+stderr = ${stdout}
+keep_on_success = false
+keep_on_empty = true
+summary_output_manager = standard
+summary_output_stdout_message = Output log: ${stdout}
+
diff --git a/paludis/environments/paludis/output_managers/quiet.conf b/paludis/environments/paludis/output_managers/quiet.conf
new file mode 100644
index 0000000..a86ca5a
--- /dev/null
+++ b/paludis/environments/paludis/output_managers/quiet.conf
@@ -0,0 +1,6 @@
+# Messages only to stdout / stderr, keep logs of messages and keep output logs
+# on failure.
+
+handler = tee
+children = logged_only show_messages.part keep_messages.part
+
diff --git a/paludis/environments/paludis/output_managers/show_messages.part.conf b/paludis/environments/paludis/output_managers/show_messages.part.conf
new file mode 100644
index 0000000..39cfa2c
--- /dev/null
+++ b/paludis/environments/paludis/output_managers/show_messages.part.conf
@@ -0,0 +1,5 @@
+# Show messages only. Not usable on its own.
+
+handler = messages_to_stdout
+child = standard
+
diff --git a/paludis/environments/paludis/output_managers/standard.conf b/paludis/environments/paludis/output_managers/standard.conf
new file mode 100644
index 0000000..7b910c7
--- /dev/null
+++ b/paludis/environments/paludis/output_managers/standard.conf
@@ -0,0 +1,4 @@
+# This output manager sends stdout output to stdout and stderr output to
+# stderr. There is no special handling for messages.
+
+handler = standard
diff --git a/paludis/environments/paludis/paludis_config.cc b/paludis/environments/paludis/paludis_config.cc
index 157a1f4..1dc309e 100644
--- a/paludis/environments/paludis/paludis_config.cc
+++ b/paludis/environments/paludis/paludis_config.cc
@@ -24,6 +24,8 @@
#include <paludis/environments/paludis/mirrors_conf.hh>
#include <paludis/environments/paludis/licenses_conf.hh>
#include <paludis/environments/paludis/package_mask_conf.hh>
+#include <paludis/environments/paludis/output_conf.hh>
+#include <paludis/environments/paludis/output_managers.hh>
#include <paludis/environments/paludis/world.hh>
#include <paludis/environments/paludis/extra_distribution_data.hh>
@@ -180,6 +182,8 @@ namespace paludis
std::tr1::shared_ptr<PackageMaskConf> package_mask_conf;
std::tr1::shared_ptr<PackageMaskConf> package_unmask_conf;
std::tr1::shared_ptr<MirrorsConf> mirrors_conf;
+ std::tr1::shared_ptr<OutputConf> output_conf;
+ std::tr1::shared_ptr<OutputManagers> output_managers;
mutable std::tr1::shared_ptr<World> world;
mutable Mutex reduced_mutex;
@@ -210,6 +214,8 @@ namespace paludis
package_mask_conf(new PackageMaskConf(e)),
package_unmask_conf(new PackageMaskConf(e)),
mirrors_conf(new MirrorsConf(e)),
+ output_conf(new OutputConf(e)),
+ output_managers(new OutputManagers(e)),
has_environment_conf(false),
accept_all_breaks_portage(false),
reduced_username(getenv_with_default("PALUDIS_REDUCED_USERNAME", "paludisbuild")),
@@ -654,6 +660,74 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
}
}
+ /* output */
+ {
+ std::list<FSEntry> files;
+ files.push_back(getenv_with_default("PALUDIS_DEFAULT_OUTPUT_CONF",
+ SHAREDIR "/paludis/environments/paludis/default_output.conf"));
+ files.push_back(local_config_dir / (dist->output_filename_part() + ".conf"));
+ files.push_back(local_config_dir / (dist->output_filename_part() + ".bash"));
+ if ((local_config_dir / (dist->output_filename_part() + ".conf.d")).exists())
+ {
+ std::remove_copy_if(DirIterator(local_config_dir / (dist->output_filename_part() + ".conf.d")), DirIterator(), std::back_inserter(files),
+ std::tr1::bind(std::logical_not<bool>(), std::tr1::bind(&is_file_with_extension, _1, ".conf", IsFileWithOptions())));
+ std::remove_copy_if(DirIterator(local_config_dir / (dist->output_filename_part() + ".conf.d")), DirIterator(), std::back_inserter(files),
+ std::tr1::bind(std::logical_not<bool>(), std::tr1::bind(&is_file_with_extension, _1, ".bash", IsFileWithOptions())));
+ }
+
+ bool any(false);
+ for (std::list<FSEntry>::const_iterator file(files.begin()), file_end(files.end()) ;
+ file != file_end ; ++file)
+ {
+ Context local_context("When reading output file '" + stringify(*file) + "':");
+
+ if (! file->exists())
+ continue;
+
+ _imp->output_conf->add(*file);
+ any = true;
+ }
+
+ if (! any)
+ throw PaludisConfigError("No output confs found");
+ }
+
+ /* output managers */
+ {
+ std::list<FSEntry> dirs, files;
+ dirs.push_back(getenv_with_default("PALUDIS_OUTPUT_MANAGERS_DIR",
+ SHAREDIR "/paludis/environments/paludis/output_managers/"));
+ dirs.push_back(local_config_dir / dist->output_managers_directory());
+
+ for (std::list<FSEntry>::const_iterator dir(dirs.begin()), dir_end(dirs.end()) ;
+ dir != dir_end ; ++dir)
+ {
+ if (! dir->exists())
+ continue;
+
+ std::remove_copy_if(DirIterator(*dir), DirIterator(), std::back_inserter(files),
+ std::tr1::bind(std::logical_not<bool>(), std::tr1::bind(&is_file_with_extension, _1, ".conf", IsFileWithOptions())));
+ std::remove_copy_if(DirIterator(*dir), DirIterator(), std::back_inserter(files),
+ std::tr1::bind(std::logical_not<bool>(), std::tr1::bind(&is_file_with_extension, _1, ".bash", IsFileWithOptions())));
+ }
+
+ bool any(false);
+ for (std::list<FSEntry>::const_iterator file(files.begin()), file_end(files.end()) ;
+ file != file_end ; ++file)
+ {
+ Context local_context("When reading output manager file '" + stringify(*file) + "':");
+
+ if (! file->exists())
+ continue;
+
+ _imp->output_managers->add(*file);
+ any = true;
+ }
+
+ if (! any)
+ throw PaludisConfigError("No output managers found");
+ }
+
/* use */
{
std::list<FSEntry> files;
@@ -911,6 +985,12 @@ PaludisConfig::keywords_conf() const
return _imp->keywords_conf;
}
+std::tr1::shared_ptr<const OutputConf>
+PaludisConfig::output_conf() const
+{
+ return _imp->output_conf;
+}
+
std::tr1::shared_ptr<const UseConf>
PaludisConfig::use_conf() const
{
@@ -935,6 +1015,12 @@ PaludisConfig::package_unmask_conf() const
return _imp->package_unmask_conf;
}
+std::tr1::shared_ptr<const OutputManagers>
+PaludisConfig::output_managers() const
+{
+ return _imp->output_managers;
+}
+
std::tr1::shared_ptr<const MirrorsConf>
PaludisConfig::mirrors_conf() const
{
diff --git a/paludis/environments/paludis/paludis_config.hh b/paludis/environments/paludis/paludis_config.hh
index 9f64c3f..f3b1d94 100644
--- a/paludis/environments/paludis/paludis_config.hh
+++ b/paludis/environments/paludis/paludis_config.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 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
@@ -50,6 +50,8 @@ namespace paludis
struct LicensesConf;
struct PackageMaskConf;
struct MirrorsConf;
+ struct OutputConf;
+ struct OutputManagers;
struct World;
/**
@@ -119,6 +121,8 @@ namespace paludis
std::tr1::shared_ptr<const PackageMaskConf> package_unmask_conf() const;
std::tr1::shared_ptr<const MirrorsConf> mirrors_conf() const;
std::tr1::shared_ptr<const World> world() const;
+ std::tr1::shared_ptr<const OutputConf> output_conf() const;
+ std::tr1::shared_ptr<const OutputManagers> output_managers() const;
///\}
diff --git a/paludis/environments/paludis/paludis_environment.cc b/paludis/environments/paludis/paludis_environment.cc
index bf4d050..95fc295 100644
--- a/paludis/environments/paludis/paludis_environment.cc
+++ b/paludis/environments/paludis/paludis_environment.cc
@@ -24,6 +24,8 @@
#include <paludis/environments/paludis/package_mask_conf.hh>
#include <paludis/environments/paludis/licenses_conf.hh>
#include <paludis/environments/paludis/mirrors_conf.hh>
+#include <paludis/environments/paludis/output_conf.hh>
+#include <paludis/environments/paludis/output_managers.hh>
#include <paludis/environments/paludis/world.hh>
#include <paludis/util/config_file.hh>
@@ -55,6 +57,7 @@
#include <paludis/util/options.hh>
#include <paludis/util/tribool.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/standard_output_manager.hh>
#include <tr1/functional>
#include <functional>
@@ -550,3 +553,15 @@ PaludisEnvironment::known_choice_value_names(
return _imp->config->use_conf()->known_choice_value_names(id, choice);
}
+const std::tr1::shared_ptr<OutputManager>
+PaludisEnvironment::create_output_manager(const CreateOutputManagerInfo & i) const
+{
+ return _imp->config->output_conf()->create_output_manager(i);
+}
+
+const std::tr1::shared_ptr<OutputManager>
+PaludisEnvironment::create_named_output_manager(const std::string & s, const CreateOutputManagerInfo & i) const
+{
+ return _imp->config->output_managers()->create_named_output_manager(s, i);
+}
+
diff --git a/paludis/environments/paludis/paludis_environment.hh b/paludis/environments/paludis/paludis_environment.hh
index b8159c9..70b45e8 100644
--- a/paludis/environments/paludis/paludis_environment.hh
+++ b/paludis/environments/paludis/paludis_environment.hh
@@ -162,6 +162,13 @@ namespace paludis
const std::tr1::shared_ptr<const Choice> &
) const
PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const std::tr1::shared_ptr<OutputManager> create_output_manager(
+ const CreateOutputManagerInfo &) const;
+
+ const std::tr1::shared_ptr<OutputManager> create_named_output_manager(
+ const std::string &,
+ const CreateOutputManagerInfo &) const;
};
}
#endif
diff --git a/paludis/environments/paludis/tests_output.conf b/paludis/environments/paludis/tests_output.conf
new file mode 100644
index 0000000..8f4e280
--- /dev/null
+++ b/paludis/environments/paludis/tests_output.conf
@@ -0,0 +1 @@
+type = * : standard
diff --git a/paludis/environments/portage/portage_environment.cc b/paludis/environments/portage/portage_environment.cc
index bd77a6c..8248c1d 100644
--- a/paludis/environments/portage/portage_environment.cc
+++ b/paludis/environments/portage/portage_environment.cc
@@ -37,6 +37,7 @@
#include <paludis/util/config_file.hh>
#include <paludis/util/tribool.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/standard_output_manager.hh>
#include <paludis/util/safe_ofstream.hh>
#include <paludis/hooker.hh>
#include <paludis/hook.hh>
@@ -1009,3 +1010,9 @@ PortageEnvironment::set_names() const
return result;
}
+const std::tr1::shared_ptr<OutputManager>
+PortageEnvironment::create_output_manager(const CreateOutputManagerInfo &) const
+{
+ return make_shared_ptr(new StandardOutputManager);
+}
+
diff --git a/paludis/environments/portage/portage_environment.hh b/paludis/environments/portage/portage_environment.hh
index b5d1715..0e2a8d5 100644
--- a/paludis/environments/portage/portage_environment.hh
+++ b/paludis/environments/portage/portage_environment.hh
@@ -168,6 +168,9 @@ namespace paludis
virtual const std::tr1::shared_ptr<const MetadataValueKey<std::string> > format_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > config_location_key() const;
+
+ virtual const std::tr1::shared_ptr<OutputManager> create_output_manager(
+ const CreateOutputManagerInfo &) const;
};
}
diff --git a/paludis/environments/test/test_environment.cc b/paludis/environments/test/test_environment.cc
index 58a71b3..983a9dc 100644
--- a/paludis/environments/test/test_environment.cc
+++ b/paludis/environments/test/test_environment.cc
@@ -29,6 +29,7 @@
#include <paludis/util/destringify.hh>
#include <paludis/util/system.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/standard_output_manager.hh>
#include <paludis/package_database.hh>
#include <paludis/package_id.hh>
#include <paludis/hook.hh>
@@ -276,3 +277,9 @@ TestEnvironment::known_choice_value_names(
return make_shared_ptr(new Set<UnprefixedChoiceName>);
}
+const std::tr1::shared_ptr<OutputManager>
+TestEnvironment::create_output_manager(const CreateOutputManagerInfo &) const
+{
+ return make_shared_ptr(new StandardOutputManager);
+}
+
diff --git a/paludis/environments/test/test_environment.hh b/paludis/environments/test/test_environment.hh
index 5bad55b..6cf563e 100644
--- a/paludis/environments/test/test_environment.hh
+++ b/paludis/environments/test/test_environment.hh
@@ -137,6 +137,8 @@ namespace paludis
) const
PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::tr1::shared_ptr<OutputManager> create_output_manager(
+ const CreateOutputManagerInfo &) const;
};
}
diff --git a/paludis/util/output_deviator-fwd.hh b/paludis/file_output_manager-fwd.hh
index 3819c35..007ad64 100644
--- a/paludis/util/output_deviator-fwd.hh
+++ b/paludis/file_output_manager-fwd.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 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
@@ -17,13 +17,12 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef PALUDIS_GUARD_PALUDIS_UTIL_OUTPUT_DEVIATOR_FWD_HH
-#define PALUDIS_GUARD_PALUDIS_UTIL_OUTPUT_DEVIATOR_FWD_HH 1
+#ifndef PALUDIS_GUARD_PALUDIS_FILE_OUTPUT_MANAGER_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_FILE_OUTPUT_MANAGER_FWD_HH 1
namespace paludis
{
- class OutputDeviator;
- class OutputDeviant;
+ class FileOutputManager;
}
#endif
diff --git a/paludis/file_output_manager.cc b/paludis/file_output_manager.cc
new file mode 100644
index 0000000..ff797a5
--- /dev/null
+++ b/paludis/file_output_manager.cc
@@ -0,0 +1,206 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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 <paludis/file_output_manager.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/safe_ofstream.hh>
+#include <paludis/util/set.hh>
+#include <paludis/util/map.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/destringify.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/stringify.hh>
+
+using namespace paludis;
+
+namespace paludis
+{
+ template <>
+ struct Implementation<FileOutputManager>
+ {
+ FSEntry stdout_file;
+ FSEntry stderr_file;
+ std::tr1::shared_ptr<SafeOFStream> stdout_stream;
+ std::tr1::shared_ptr<SafeOFStream> stderr_stream;
+ const bool keep_on_success, keep_on_empty;
+ const std::tr1::shared_ptr<OutputManager> summary_output_manager;
+ const std::string summary_output_stdout_message;
+ const std::string summary_output_stderr_message;
+
+ bool succeeded, unlinked_stdout, unlinked_stderr;
+
+ Implementation(
+ const FSEntry & o,
+ const FSEntry & e,
+ const bool k,
+ const bool l,
+ const std::tr1::shared_ptr<OutputManager> & m,
+ const std::string & s,
+ const std::string & t
+ ) :
+ stdout_file(o),
+ stderr_file(e),
+ stdout_stream(new SafeOFStream(o)),
+ keep_on_success(k),
+ keep_on_empty(l),
+ summary_output_manager(m),
+ summary_output_stdout_message(s),
+ summary_output_stderr_message(t),
+ succeeded(false),
+ unlinked_stdout(false),
+ unlinked_stderr(false)
+ {
+ if (o == e)
+ stderr_stream = stdout_stream;
+ else
+ stderr_stream.reset(new SafeOFStream(e));
+ }
+ };
+}
+
+FileOutputManager::FileOutputManager(const FSEntry & o, const FSEntry & e, const bool k, const bool l,
+ const std::tr1::shared_ptr<OutputManager> & m, const std::string & s, const std::string & t) :
+ PrivateImplementationPattern<FileOutputManager>(new Implementation<FileOutputManager>(o, e, k, l, m, s, t))
+{
+}
+
+FileOutputManager::~FileOutputManager()
+{
+ if (! _imp->keep_on_empty)
+ {
+ *_imp->stdout_stream << std::flush;
+ *_imp->stderr_stream << std::flush;
+
+ FSEntry stdout_file_now(stringify(_imp->stdout_file)), stderr_file_now(stringify(_imp->stderr_file));
+ if (stdout_file_now.exists() && 0 == stdout_file_now.file_size())
+ {
+ _imp->stdout_file.unlink();
+ _imp->unlinked_stdout = true;
+ }
+
+ if (stdout_file_now != stderr_file_now)
+ {
+ if (stderr_file_now.exists() && 0 == stderr_file_now.file_size())
+ {
+ _imp->stderr_file.unlink();
+ _imp->unlinked_stderr = true;
+ }
+ }
+ }
+
+ if (_imp->summary_output_manager)
+ {
+ if ((! _imp->unlinked_stdout) && (! _imp->summary_output_stdout_message.empty()))
+ {
+ _imp->summary_output_manager->stdout_stream()
+ << _imp->summary_output_stdout_message
+ << std::endl;
+ }
+
+ if (_imp->stdout_file != _imp->stderr_file)
+ {
+ if ((! _imp->unlinked_stderr) && (! _imp->summary_output_stderr_message.empty()))
+ _imp->summary_output_manager->stdout_stream()
+ << _imp->summary_output_stderr_message
+ << std::endl;
+ }
+ }
+}
+
+std::ostream &
+FileOutputManager::stdout_stream()
+{
+ return *_imp->stdout_stream;
+}
+
+std::ostream &
+FileOutputManager::stderr_stream()
+{
+ return *_imp->stderr_stream;
+}
+
+void
+FileOutputManager::succeeded()
+{
+ _imp->succeeded = true;
+
+ if (! _imp->keep_on_success)
+ {
+ _imp->stdout_file.unlink();
+ _imp->stderr_file.unlink();
+ _imp->unlinked_stdout = true;
+ _imp->unlinked_stderr = true;
+ }
+}
+
+void
+FileOutputManager::message(const MessageType, const std::string &)
+{
+}
+
+const std::tr1::shared_ptr<const Set<std::string> >
+FileOutputManager::factory_managers()
+{
+ std::tr1::shared_ptr<Set<std::string> > result(new Set<std::string>);
+ result->insert("file");
+ return result;
+}
+
+const std::tr1::shared_ptr<OutputManager>
+FileOutputManager::factory_create(
+ const OutputManagerFactory::KeyFunction & key_func,
+ const OutputManagerFactory::CreateChildFunction & create_child_function,
+ const OutputManagerFactory::ReplaceVarsFunc & replace_vars_func)
+{
+ std::string stdout_s(key_func("stdout")), stderr_s(key_func("stderr")),
+ keep_on_success_s(key_func("keep_on_success")), keep_on_empty_s(key_func("keep_on_empty")),
+ summary_output_manager_s(key_func("summary_output_manager")),
+ summary_output_stdout_message_s(key_func("summary_output_stdout_message")),
+ summary_output_stderr_message_s(key_func("summary_output_stderr_message"));
+
+ if (stdout_s.empty())
+ throw ConfigurationError("Key 'stdout' not specified when creating a file output manager");
+ stdout_s = replace_vars_func(stdout_s, make_shared_ptr(new Map<std::string, std::string>));
+
+ if (stderr_s.empty())
+ throw ConfigurationError("Key 'stderr' not specified when creating a file output manager");
+ stderr_s = replace_vars_func(stderr_s, make_shared_ptr(new Map<std::string, std::string>));
+
+ if (keep_on_success_s.empty())
+ keep_on_success_s = "true";
+
+ if (keep_on_empty_s.empty())
+ keep_on_empty_s = "true";
+
+ std::tr1::shared_ptr<OutputManager> summary_output_manager;
+ if (! summary_output_manager_s.empty())
+ summary_output_manager = create_child_function(summary_output_manager_s);
+
+ summary_output_stdout_message_s = replace_vars_func(summary_output_stdout_message_s, make_shared_ptr(new Map<std::string, std::string>));
+ summary_output_stderr_message_s = replace_vars_func(summary_output_stderr_message_s, make_shared_ptr(new Map<std::string, std::string>));
+
+ return make_shared_ptr(new FileOutputManager(FSEntry(stdout_s), FSEntry(stderr_s),
+ destringify<bool>(keep_on_success_s), destringify<bool>(keep_on_empty_s),
+ summary_output_manager, summary_output_stdout_message_s,
+ summary_output_stderr_message_s));
+}
+
+template class PrivateImplementationPattern<FileOutputManager>;
+
diff --git a/paludis/file_output_manager.hh b/paludis/file_output_manager.hh
new file mode 100644
index 0000000..5009abe
--- /dev/null
+++ b/paludis/file_output_manager.hh
@@ -0,0 +1,66 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_FILE_OUTPUT_MANAGER_HH
+#define PALUDIS_GUARD_PALUDIS_FILE_OUTPUT_MANAGER_HH 1
+
+#include <paludis/file_output_manager-fwd.hh>
+#include <paludis/output_manager.hh>
+#include <paludis/output_manager_factory.hh>
+#include <paludis/util/set-fwd.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/fs_entry-fwd.hh>
+#include <tr1/memory>
+#include <tr1/functional>
+
+namespace paludis
+{
+ class PALUDIS_VISIBLE FileOutputManager :
+ private PrivateImplementationPattern<FileOutputManager>,
+ public OutputManager
+ {
+ public:
+ FileOutputManager(const FSEntry &, const FSEntry &, const bool keep_on_success,
+ const bool keep_on_empty, const std::tr1::shared_ptr<OutputManager> & summary_output_manager,
+ const std::string & summary_output_stdout_message,
+ const std::string & summary_output_stderr_message);
+ ~FileOutputManager();
+
+ virtual std::ostream & stdout_stream() PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual std::ostream & stderr_stream() PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual void succeeded();
+ virtual void message(const MessageType, const std::string &);
+
+ static const std::tr1::shared_ptr<const Set<std::string> > factory_managers()
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ static const std::tr1::shared_ptr<OutputManager> factory_create(
+ const OutputManagerFactory::KeyFunction &,
+ const OutputManagerFactory::CreateChildFunction &,
+ const OutputManagerFactory::ReplaceVarsFunc &)
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
+ extern template class PrivateImplementationPattern<FileOutputManager>;
+#endif
+}
+
+#endif
diff --git a/paludis/files.m4 b/paludis/files.m4
index 883d92d..a3492e8 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -13,6 +13,7 @@ add(`action', `hh', `cc', `fwd', `se')
add(`action_names', `hh', `cc', `fwd')
add(`choice', `hh', `cc', `fwd')
add(`contents', `hh', `cc', `fwd')
+add(`create_output_manager_info', `hh', `cc', `fwd', `se')
add(`dep_label', `hh', `cc', `fwd')
add(`dep_list', `hh', `cc', `fwd', `test', `fwd')
add(`dep_list_exceptions', `hh', `cc')
@@ -30,6 +31,7 @@ add(`elike_use_requirement', `hh', `cc', `fwd', `se', `test')
add(`environment', `hh', `fwd', `cc')
add(`environment_factory', `hh', `fwd', `cc')
add(`environment_implementation', `hh', `cc')
+add(`file_output_manager', `hh', `cc', `fwd')
add(`filter', `hh', `cc', `fwd', `test')
add(`filter_handler', `hh', `cc', `fwd')
add(`filtered_generator', `hh', `cc', `fwd', `test')
@@ -47,12 +49,16 @@ add(`mask', `hh', `cc', `fwd', `se')
add(`match_package', `hh', `cc', `se', `fwd')
add(`merger', `hh', `cc', `fwd', `se', `test', `testscript')
add(`merger_entry_type', `hh', `cc', `se')
+add(`messages_to_stdout_output_handler', `hh', `cc', `fwd')
add(`metadata_key', `hh', `cc', `se', `fwd')
add(`metadata_key_holder', `hh', `cc', `fwd')
add(`name', `hh', `cc', `fwd', `test')
add(`ndbam', `hh', `cc', `fwd')
add(`ndbam_merger', `hh', `cc')
add(`ndbam_unmerger', `hh', `cc')
+add(`output_manager', `hh', `fwd', `cc', `se')
+add(`output_manager_factory', `hh', `fwd', `cc')
+add(`output_manager_from_environment', `hh', `fwd', `cc')
add(`override_functions', `hh', `cc')
add(`package_database', `hh', `cc', `fwd', `test')
add(`package_dep_spec_properties', `hh', `cc', `fwd')
@@ -71,11 +77,13 @@ add(`set_file', `hh', `cc', `se', `test', `testscript')
add(`show_suggest_visitor', `hh', `cc')
add(`slot_requirement', `hh', `fwd', `cc')
add(`spec_tree', `hh', `fwd', `cc')
+add(`standard_output_manager', `hh', `cc', `fwd')
add(`stringify_formatter', `hh', `cc', `fwd', `impl', `test')
add(`stripper', `hh', `cc', `fwd', `test', `testscript')
add(`syncer', `hh', `cc')
add(`sync_task', `hh', `cc')
add(`tasks_exceptions', `hh', `cc')
+add(`tee_output_manager', `hh', `cc', `fwd')
add(`unchoices_key', `hh', `cc', `fwd')
add(`uninstall_list', `hh', `cc', `se', `test')
add(`uninstall_task', `hh', `cc')
diff --git a/paludis/install_task.cc b/paludis/install_task.cc
index c9d775b..bd48140 100644
--- a/paludis/install_task.cc
+++ b/paludis/install_task.cc
@@ -50,6 +50,10 @@
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/accept_visitor.hh>
#include <paludis/handled_information.hh>
+#include <paludis/create_output_manager_info.hh>
+#include <paludis/output_manager_from_environment.hh>
+#include <paludis/output_manager.hh>
+#include <paludis/standard_output_manager.hh>
#include <tr1/functional>
#include <sstream>
#include <functional>
@@ -66,23 +70,29 @@ template class WrappedForwardIterator<InstallTask::TargetsConstIteratorTag, cons
namespace
{
- WantPhase want_all_phases_function(InstallTask * const task, bool & done_any, const std::string & phase)
+ WantPhase want_all_phases_function(
+ InstallTask * const task,
+ OutputManagerFromEnvironment & output_manager_holder,
+ bool & done_any, const std::string & phase)
{
- task->on_phase_proceed_unconditionally(phase);
+ output_manager_holder.construct_standard_if_unconstructed();
+ task->on_phase_proceed_unconditionally(output_manager_holder.output_manager_if_constructed(), phase);
done_any = true;
return wp_yes;
}
WantPhase want_phase_function(
InstallTask * const task,
+ OutputManagerFromEnvironment & output_manager_holder,
const std::tr1::shared_ptr<const Set<std::string> > & abort_at_phases,
const std::tr1::shared_ptr<const Set<std::string> > & skip_phases,
const std::tr1::shared_ptr<const Set<std::string> > & skip_until_phases,
bool & done_any, const std::string & phase)
{
+ output_manager_holder.construct_standard_if_unconstructed();
if (abort_at_phases->end() != abort_at_phases->find(phase))
{
- task->on_phase_abort(phase);
+ task->on_phase_abort(output_manager_holder.output_manager_if_constructed(), phase);
return wp_abort;
}
@@ -90,7 +100,7 @@ namespace
if (! done_any)
if (skip_until_phases->end() == skip_until_phases->find(phase))
{
- task->on_phase_skip_until(phase);
+ task->on_phase_skip_until(output_manager_holder.output_manager_if_constructed(), phase);
return wp_skip;
}
@@ -99,11 +109,11 @@ namespace
if (skip_phases->end() != skip_phases->find(phase))
{
- task->on_phase_skip(phase);
+ task->on_phase_skip(output_manager_holder.output_manager_if_constructed(), phase);
return wp_skip;
}
- task->on_phase_proceed_conditionally(phase);
+ task->on_phase_proceed_conditionally(output_manager_holder.output_manager_if_constructed(), phase);
return wp_yes;
}
}
@@ -115,8 +125,6 @@ namespace paludis
{
Environment * const env;
DepList dep_list;
- FetchActionOptions fetch_options;
- InstallActionOptions install_options;
std::string config_protect;
@@ -128,6 +136,7 @@ namespace paludis
bool pretend;
bool fetch_only;
bool preserve_world;
+ bool safe_resume;
bool had_set_targets;
bool had_package_targets;
@@ -149,27 +158,13 @@ namespace paludis
std::tr1::shared_ptr<const DestinationsSet> d) :
env(e),
dep_list(e, o),
- fetch_options(
- make_named_values<FetchActionOptions>(
- value_for<n::exclude_unmirrorable>(false),
- value_for<n::fetch_unneeded>(false),
- value_for<n::maybe_output_deviant>(make_null_shared_ptr()),
- value_for<n::safe_resume>(false)
- )),
- install_options(
- make_named_values<InstallActionOptions>(
- value_for<n::destination>(std::tr1::shared_ptr<Repository>()),
- value_for<n::used_this_for_config_protect>(std::tr1::bind(
- &Implementation<InstallTask>::assign_config_protect,
- this, std::tr1::placeholders::_1)),
- value_for<n::want_phase>(std::tr1::function<WantPhase (const std::string &)>())
- )),
config_protect(""),
targets(new SetSpecTree(make_shared_ptr(new AllDepSpec))),
destinations(d),
pretend(false),
fetch_only(false),
preserve_world(false),
+ safe_resume(false),
had_set_targets(false),
had_package_targets(false),
override_target_type(false),
@@ -694,13 +689,22 @@ InstallTask::_pretend()
{
on_pretend_pre(*dep);
- PretendAction pretend_action;
+ OutputManagerFromEnvironment output_manager_holder(_imp->env, dep->package_id(), oe_exclusive);
+ PretendActionOptions options(make_named_values<PretendActionOptions>(
+ value_for<n::make_output_manager>(std::tr1::ref(output_manager_holder))
+ ));
+ PretendAction pretend_action(options);
dep->package_id()->perform_action(pretend_action);
if (pretend_action.failed())
{
pretend_failed = true;
dep->handled().reset(new DepListEntryHandledFailed);
}
+ else
+ {
+ if (output_manager_holder.output_manager_if_constructed())
+ output_manager_holder.output_manager_if_constructed()->succeeded();
+ }
on_pretend_post(*dep);
}
@@ -722,7 +726,8 @@ InstallTask::_pretend()
}
void
-InstallTask::_one(const DepList::Iterator dep, const int x, const int y, const int s, const int f, const bool is_first, const bool is_last)
+InstallTask::_one(const DepList::Iterator dep, const int x, const int y, const int s, const int f, const bool is_first, const bool is_last,
+ std::tr1::shared_ptr<OutputManagerFromEnvironment> & output_manager_holder)
{
std::string cpvr(stringify(*dep->package_id()));
@@ -762,14 +767,29 @@ InstallTask::_one(const DepList::Iterator dep, const int x, const int y, const i
SupportsActionTest<FetchAction> test_fetch;
if (dep->package_id()->supports_action(test_fetch))
{
- FetchAction fetch_action(_imp->fetch_options);
+ output_manager_holder.reset(new OutputManagerFromEnvironment(_imp->env, dep->package_id(), oe_exclusive));
+ FetchActionOptions fetch_options(make_fetch_action_options(*dep, *output_manager_holder));
+ FetchAction fetch_action(fetch_options);
dep->package_id()->perform_action(fetch_action);
+ if (output_manager_holder->output_manager_if_constructed())
+ output_manager_holder->output_manager_if_constructed()->succeeded();
+ output_manager_holder.reset();
}
if (! _imp->fetch_only)
{
+ output_manager_holder.reset(new OutputManagerFromEnvironment(_imp->env, dep->package_id(), oe_exclusive));
+
+ InstallActionOptions install_options(make_named_values<InstallActionOptions>(
+ value_for<n::destination>(dep->destination()),
+ value_for<n::make_output_manager>(std::tr1::ref(*output_manager_holder)),
+ value_for<n::used_this_for_config_protect>(std::tr1::bind(
+ &Implementation<InstallTask>::assign_config_protect,
+ _imp.get(), std::tr1::placeholders::_1)),
+ value_for<n::want_phase>(std::tr1::function<WantPhase (const std::string &)>())
+ ));
+
bool done_any(false);
- _imp->install_options.destination() = dep->destination();
bool apply_phases(false);
if (! _imp->abort_at_phases->empty() || ! _imp->skip_phases->empty() || ! _imp->skip_until_phases->empty())
@@ -782,15 +802,20 @@ InstallTask::_one(const DepList::Iterator dep, const int x, const int y, const i
apply_phases = true;
}
if (apply_phases)
- _imp->install_options.want_phase() = std::tr1::bind(&want_phase_function, this,
+ install_options.want_phase() = std::tr1::bind(&want_phase_function, this, std::tr1::ref(*output_manager_holder),
std::tr1::cref(_imp->abort_at_phases), std::tr1::cref(_imp->skip_phases), std::tr1::cref(_imp->skip_until_phases),
std::tr1::ref(done_any), std::tr1::placeholders::_1);
else
- _imp->install_options.want_phase() = std::tr1::bind(&want_all_phases_function, this,
+ install_options.want_phase() = std::tr1::bind(&want_all_phases_function, this, std::tr1::ref(*output_manager_holder),
std::tr1::ref(done_any), std::tr1::placeholders::_1);
- InstallAction install_action(_imp->install_options);
+ InstallAction install_action(install_options);
dep->package_id()->perform_action(install_action);
+
+ if (output_manager_holder->output_manager_if_constructed())
+ output_manager_holder->output_manager_if_constructed()->succeeded();
+
+ output_manager_holder.reset();
}
}
catch (const InstallActionError & e)
@@ -874,11 +899,16 @@ InstallTask::_one(const DepList::Iterator dep, const int x, const int y, const i
try
{
+ output_manager_holder.reset(new OutputManagerFromEnvironment(_imp->env, dep->package_id(), oe_exclusive));
UninstallAction uninstall_action(
make_named_values<UninstallActionOptions>(
- value_for<n::config_protect>(_imp->config_protect)
+ value_for<n::config_protect>(_imp->config_protect),
+ value_for<n::make_output_manager>(std::tr1::ref(*output_manager_holder))
));
(*c)->perform_action(uninstall_action);
+ if (output_manager_holder->output_manager_if_constructed())
+ output_manager_holder->output_manager_if_constructed()->succeeded();
+ output_manager_holder.reset();
}
catch (const UninstallActionError & e)
{
@@ -1015,20 +1045,27 @@ InstallTask::_main_actions()
}
}
+ std::tr1::shared_ptr<OutputManagerFromEnvironment> output_manager_holder;
try
{
- _one(dep, x, y, s, f, is_first, is_last);
+ _one(dep, x, y, s, f, is_first, is_last, output_manager_holder);
}
catch (const InstallActionError & e)
{
dep->handled().reset(new DepListEntryHandledFailed);
- on_install_action_error(e);
+ if (output_manager_holder && output_manager_holder->output_manager_if_constructed())
+ on_install_action_error(output_manager_holder->output_manager_if_constructed(), e);
+ else
+ on_install_action_error(make_shared_ptr(new StandardOutputManager), e);
++f;
}
catch (const FetchActionError & e)
{
dep->handled().reset(new DepListEntryHandledFailed);
- on_fetch_action_error(e);
+ if (output_manager_holder && output_manager_holder->output_manager_if_constructed())
+ on_fetch_action_error(output_manager_holder->output_manager_if_constructed(), e);
+ else
+ on_fetch_action_error(make_shared_ptr(new StandardOutputManager), e);
++f;
}
@@ -1266,7 +1303,7 @@ InstallTask::on_installed_paludis()
void
InstallTask::set_safe_resume(const bool value)
{
- _imp->fetch_options.safe_resume() = value;
+ _imp->safe_resume = value;
}
HookResult
@@ -1761,12 +1798,6 @@ InstallTask::already_done(const DepListEntry & e) const
return v.result;
}
-FetchActionOptions &
-InstallTask::fetch_action_options()
-{
- return _imp->fetch_options;
-}
-
void
InstallTask::set_skip_phases(const std::tr1::shared_ptr<const Set<std::string> > & s)
{
@@ -1803,3 +1834,14 @@ InstallTask::set_phase_options_apply_to_all(const bool b)
_imp->phase_options_apply_to_all = b;
}
+FetchActionOptions
+InstallTask::make_fetch_action_options(const DepListEntry &, OutputManagerFromEnvironment & o) const
+{
+ return make_named_values<FetchActionOptions>(
+ value_for<n::exclude_unmirrorable>(false),
+ value_for<n::fetch_unneeded>(false),
+ value_for<n::make_output_manager>(std::tr1::ref(o)),
+ value_for<n::safe_resume>(_imp->safe_resume)
+ );
+}
+
diff --git a/paludis/install_task.hh b/paludis/install_task.hh
index 51a1100..e733324 100644
--- a/paludis/install_task.hh
+++ b/paludis/install_task.hh
@@ -29,6 +29,7 @@
#include <paludis/repository-fwd.hh>
#include <paludis/action-fwd.hh>
#include <paludis/package_database-fwd.hh>
+#include <paludis/output_manager_from_environment-fwd.hh>
/** \file
* Declarations for InstallTask.
@@ -62,7 +63,8 @@ namespace paludis
void _display_task_list();
bool _pretend();
void _main_actions();
- void _one(const DepList::Iterator, const int, const int, const int, const int, const bool is_first, const bool is_last);
+ 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 _display_failure_summary();
void _add_target(const std::string &);
@@ -81,7 +83,9 @@ namespace paludis
///\}
bool already_done(const DepListEntry &) const PALUDIS_ATTRIBUTE((warn_unused_result));
- FetchActionOptions & fetch_action_options() PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ FetchActionOptions make_fetch_action_options(const DepListEntry &,
+ OutputManagerFromEnvironment & o) const PALUDIS_ATTRIBUTE((warn_unused_result));
public:
///\name Basic operations
@@ -204,14 +208,14 @@ namespace paludis
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;
+ virtual void on_install_action_error(const std::tr1::shared_ptr<OutputManager> &, const InstallActionError &) = 0;
+ virtual void on_fetch_action_error(const std::tr1::shared_ptr<OutputManager> &, const FetchActionError &) = 0;
- virtual void on_phase_skip(const std::string & phase) = 0;
- virtual void on_phase_abort(const std::string & phase) = 0;
- virtual void on_phase_skip_until(const std::string & phase) = 0;
- virtual void on_phase_proceed_conditionally(const std::string & phase) = 0;
- virtual void on_phase_proceed_unconditionally(const std::string & phase) = 0;
+ virtual void on_phase_skip(const std::tr1::shared_ptr<OutputManager> & output_manager, const std::string & phase) = 0;
+ virtual void on_phase_abort(const std::tr1::shared_ptr<OutputManager> & output_manager, const std::string & phase) = 0;
+ virtual void on_phase_skip_until(const std::tr1::shared_ptr<OutputManager> & output_manager, const std::string & phase) = 0;
+ virtual void on_phase_proceed_conditionally(const std::tr1::shared_ptr<OutputManager> & output_manager, const std::string & phase) = 0;
+ virtual void on_phase_proceed_unconditionally(const std::tr1::shared_ptr<OutputManager> & output_manager, const std::string & phase) = 0;
///\}
diff --git a/paludis/messages_to_stdout_output_handler-fwd.hh b/paludis/messages_to_stdout_output_handler-fwd.hh
new file mode 100644
index 0000000..9e2ec56
--- /dev/null
+++ b/paludis/messages_to_stdout_output_handler-fwd.hh
@@ -0,0 +1,28 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_MESSAGES_TO_STDOUT_OUTPUT_HANDLER_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_MESSAGES_TO_STDOUT_OUTPUT_HANDLER_FWD_HH 1
+
+namespace paludis
+{
+ struct MessagesToStdoutOutputManager;
+}
+
+#endif
diff --git a/paludis/messages_to_stdout_output_handler.cc b/paludis/messages_to_stdout_output_handler.cc
new file mode 100644
index 0000000..0492fe4
--- /dev/null
+++ b/paludis/messages_to_stdout_output_handler.cc
@@ -0,0 +1,171 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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 <paludis/messages_to_stdout_output_handler.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/discard_output_stream.hh>
+#include <paludis/util/sequence-impl.hh>
+#include <paludis/util/set.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/exception.hh>
+#include <paludis/util/map.hh>
+#include <paludis/util/stringify.hh>
+
+using namespace paludis;
+
+namespace paludis
+{
+ template <>
+ struct Implementation<MessagesToStdoutOutputManager>
+ {
+ DiscardOutputStream output_stream;
+ const std::tr1::shared_ptr<OutputManager> child;
+ const OutputManagerFactory::ReplaceVarsFunc replace_vars_func;
+ const std::string f_debug;
+ const std::string f_info;
+ const std::string f_warn;
+ const std::string f_error;
+ const std::string f_log;
+
+ Implementation(
+ const std::tr1::shared_ptr<OutputManager> & c,
+ const OutputManagerFactory::ReplaceVarsFunc & r,
+ const std::string & f_d,
+ const std::string & f_i,
+ const std::string & f_w,
+ const std::string & f_e,
+ const std::string & f_l) :
+ child(c),
+ replace_vars_func(r),
+ f_debug(f_d),
+ f_info(f_i),
+ f_warn(f_w),
+ f_error(f_e),
+ f_log(f_l)
+ {
+ }
+ };
+}
+
+MessagesToStdoutOutputManager::MessagesToStdoutOutputManager(
+ const std::tr1::shared_ptr<OutputManager> & s,
+ const OutputManagerFactory::ReplaceVarsFunc & replace_vars_func,
+ const std::string & f_debug,
+ const std::string & f_info,
+ const std::string & f_warn,
+ const std::string & f_error,
+ const std::string & f_log) :
+ PrivateImplementationPattern<MessagesToStdoutOutputManager>(new Implementation<MessagesToStdoutOutputManager>(s, replace_vars_func,
+ f_debug, f_info, f_warn, f_error, f_log))
+{
+}
+
+MessagesToStdoutOutputManager::~MessagesToStdoutOutputManager()
+{
+}
+
+std::ostream &
+MessagesToStdoutOutputManager::stdout_stream()
+{
+ return _imp->output_stream;
+}
+
+std::ostream &
+MessagesToStdoutOutputManager::stderr_stream()
+{
+ return _imp->output_stream;
+}
+
+void
+MessagesToStdoutOutputManager::succeeded()
+{
+ _imp->child->succeeded();
+}
+
+void
+MessagesToStdoutOutputManager::message(const MessageType t, const std::string & s)
+{
+ std::string msg;
+ std::tr1::shared_ptr<Map<std::string, std::string> > x(new Map<std::string, std::string>);
+ x->insert("message", s);
+
+ do
+ {
+ switch (t)
+ {
+ case mt_debug:
+ msg = _imp->replace_vars_func(_imp->f_debug, x);
+ continue;
+
+ case mt_info:
+ msg = _imp->replace_vars_func(_imp->f_info, x);
+ continue;
+
+ case mt_warn:
+ msg = _imp->replace_vars_func(_imp->f_warn, x);
+ continue;
+
+ case mt_error:
+ msg = _imp->replace_vars_func(_imp->f_error, x);
+ continue;
+
+ case mt_log:
+ msg = _imp->replace_vars_func(_imp->f_log, x);
+ continue;
+
+ case last_mt:
+ break;
+ }
+
+ throw InternalError(PALUDIS_HERE, "bad MessageType");
+ }
+ while (false);
+
+ if (! msg.empty())
+ _imp->child->stdout_stream() << msg << std::endl;
+}
+
+const std::tr1::shared_ptr<const Set<std::string> >
+MessagesToStdoutOutputManager::factory_managers()
+{
+ std::tr1::shared_ptr<Set<std::string> > result(new Set<std::string>);
+ result->insert("messages_to_stdout");
+ return result;
+}
+
+const std::tr1::shared_ptr<OutputManager>
+MessagesToStdoutOutputManager::factory_create(
+ const OutputManagerFactory::KeyFunction & key_func,
+ const OutputManagerFactory::CreateChildFunction & create_child,
+ const OutputManagerFactory::ReplaceVarsFunc & replace_vars_func)
+{
+ std::string child(key_func("child"));
+ if (child.empty())
+ throw ConfigurationError("No child specified for MessagesToStdoutOutputManager");
+
+ std::string f_d(key_func("format_debug")), f_i(key_func("format_info")), f_w(key_func("format_warn")),
+ f_e(key_func("format_error")), f_l(key_func("format_log"));
+
+ return make_shared_ptr(new MessagesToStdoutOutputManager(create_child(child), replace_vars_func,
+ f_d, f_i, f_w, f_e, f_l));
+}
+
+template class PrivateImplementationPattern<MessagesToStdoutOutputManager>;
+
diff --git a/paludis/messages_to_stdout_output_handler.hh b/paludis/messages_to_stdout_output_handler.hh
new file mode 100644
index 0000000..5591931
--- /dev/null
+++ b/paludis/messages_to_stdout_output_handler.hh
@@ -0,0 +1,71 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_MESSAGES_TO_STDOUT_OUTPUT_HANDLER_HH
+#define PALUDIS_GUARD_PALUDIS_MESSAGES_TO_STDOUT_OUTPUT_HANDLER_HH 1
+
+#include <paludis/messages_to_stdout_output_handler-fwd.hh>
+#include <paludis/output_manager.hh>
+#include <paludis/output_manager_factory.hh>
+#include <paludis/util/set-fwd.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/fs_entry-fwd.hh>
+#include <tr1/memory>
+#include <tr1/functional>
+
+namespace paludis
+{
+ class PALUDIS_VISIBLE MessagesToStdoutOutputManager :
+ private PrivateImplementationPattern<MessagesToStdoutOutputManager>,
+ public OutputManager
+ {
+ public:
+ MessagesToStdoutOutputManager(
+ const std::tr1::shared_ptr<OutputManager> &,
+ const OutputManagerFactory::ReplaceVarsFunc &,
+ const std::string & f_debug,
+ const std::string & f_info,
+ const std::string & f_warn,
+ const std::string & f_error,
+ const std::string & f_log);
+
+ ~MessagesToStdoutOutputManager();
+
+ virtual std::ostream & stdout_stream() PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual std::ostream & stderr_stream() PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual void succeeded();
+ virtual void message(const MessageType, const std::string &);
+
+ static const std::tr1::shared_ptr<const Set<std::string> > factory_managers()
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ static const std::tr1::shared_ptr<OutputManager> factory_create(
+ const OutputManagerFactory::KeyFunction &,
+ const OutputManagerFactory::CreateChildFunction &,
+ const OutputManagerFactory::ReplaceVarsFunc &)
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
+ extern template class PrivateImplementationPattern<MessagesToStdoutOutputManager>;
+#endif
+}
+
+#endif
diff --git a/paludis/ndbam_merger.cc b/paludis/ndbam_merger.cc
index f150f7b..3b60761 100644
--- a/paludis/ndbam_merger.cc
+++ b/paludis/ndbam_merger.cc
@@ -28,6 +28,7 @@
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/options.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/output_manager.hh>
#include <paludis/util/safe_ofstream.hh>
#include <paludis/util/safe_ifstream.hh>
#include <paludis/hook.hh>
@@ -37,7 +38,6 @@
#include <paludis/package_database.hh>
#include <paludis/ndbam_merger.hh>
#include <paludis/metadata_key.hh>
-#include <iostream>
#include <iomanip>
#include <list>
@@ -207,7 +207,7 @@ NDBAMMerger::on_error(bool is_check, const std::string & s)
make_check_fail();
if (is_check)
- std::cout << "." << std::endl << "!!! " << s << std::endl;
+ _imp->params.output_manager()->stdout_stream() << "." << std::endl << "!!! " << s << std::endl;
else
throw MergerError(s);
}
@@ -344,9 +344,9 @@ NDBAMMerger::merge()
bool
NDBAMMerger::check()
{
- std::cout << ">>> Checking whether we can merge to " << _imp->params.root() << " ";
+ _imp->params.output_manager()->stdout_stream() << ">>> Checking whether we can merge to " << _imp->params.root() << " ";
bool result(Merger::check());
- std::cout << std::endl;
+ _imp->params.output_manager()->stdout_stream() << std::endl;
return result;
}
@@ -356,12 +356,12 @@ NDBAMMerger::on_enter_dir(bool is_check, const FSEntry)
if (! is_check)
return;
- std::cout << "." << std::flush;
+ _imp->params.output_manager()->stdout_stream() << "." << std::flush;
}
void
NDBAMMerger::display_override(const std::string & message) const
{
- std::cout << message << std::endl;
+ _imp->params.output_manager()->stdout_stream() << message << std::endl;
}
diff --git a/paludis/ndbam_merger.hh b/paludis/ndbam_merger.hh
index 30baf69..bad12bc 100644
--- a/paludis/ndbam_merger.hh
+++ b/paludis/ndbam_merger.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
@@ -23,6 +23,7 @@
#include <paludis/merger.hh>
#include <paludis/package_id-fwd.hh>
#include <paludis/util/named_value.hh>
+#include <paludis/output_manager-fwd.hh>
#include <tr1/functional>
namespace paludis
@@ -37,6 +38,7 @@ namespace paludis
struct image;
struct install_under;
struct options;
+ struct output_manager;
struct package_id;
struct root;
}
@@ -51,6 +53,7 @@ namespace paludis
NamedValue<n::image, FSEntry> image;
NamedValue<n::install_under, FSEntry> install_under;
NamedValue<n::options, MergerOptions> options;
+ NamedValue<n::output_manager, std::tr1::shared_ptr<OutputManager> > output_manager;
NamedValue<n::package_id, std::tr1::shared_ptr<const PackageID> > package_id;
NamedValue<n::root, FSEntry> root;
};
diff --git a/paludis/ndbam_unmerger.cc b/paludis/ndbam_unmerger.cc
index 3b565e6..0a78659 100644
--- a/paludis/ndbam_unmerger.cc
+++ b/paludis/ndbam_unmerger.cc
@@ -37,13 +37,13 @@
#include <paludis/util/strip.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/output_manager.hh>
#include <paludis/util/safe_ifstream.hh>
#include <paludis/metadata_key.hh>
#include <tr1/functional>
#include <list>
#include <map>
#include <vector>
-#include <iostream>
using namespace paludis;
@@ -291,7 +291,7 @@ NDBAMUnmerger::check_dir(const FSEntry & f, const std::tr1::shared_ptr<ExtraInfo
void
NDBAMUnmerger::display(const std::string & message) const
{
- std::cout << message << std::endl;
+ _imp->options.output_manager()->stdout_stream() << message << std::endl;
}
NDBAMUnmergerError::NDBAMUnmergerError(const std::string & s) throw () :
diff --git a/paludis/ndbam_unmerger.hh b/paludis/ndbam_unmerger.hh
index a3366bc..2652ed3 100644
--- a/paludis/ndbam_unmerger.hh
+++ b/paludis/ndbam_unmerger.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
* Copyright (c) 2007 Piotr Jaroszyński
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -23,6 +23,7 @@
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/fs_entry.hh>
+#include <paludis/output_manager-fwd.hh>
#include <paludis/unmerger.hh>
#include <paludis/environment-fwd.hh>
#include <paludis/package_id-fwd.hh>
@@ -36,6 +37,7 @@ namespace paludis
struct contents_file;
struct environment;
struct ndbam;
+ struct output_manager;
struct package_id;
struct root;
}
@@ -49,6 +51,7 @@ namespace paludis
NamedValue<n::contents_file, FSEntry> contents_file;
NamedValue<n::environment, const Environment *> environment;
NamedValue<n::ndbam, const NDBAM *> ndbam;
+ NamedValue<n::output_manager, std::tr1::shared_ptr<OutputManager> > output_manager;
NamedValue<n::package_id, std::tr1::shared_ptr<const PackageID> > package_id;
NamedValue<n::root, FSEntry> root;
};
diff --git a/paludis/output_manager-fwd.hh b/paludis/output_manager-fwd.hh
new file mode 100644
index 0000000..72fb38f
--- /dev/null
+++ b/paludis/output_manager-fwd.hh
@@ -0,0 +1,34 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_OUTPUT_MANAGER_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_OUTPUT_MANAGER_FWD_HH 1
+
+#include <paludis/util/attributes.hh>
+#include <iosfwd>
+
+namespace paludis
+{
+
+#include <paludis/output_manager-se.hh>
+
+ class OutputManager;
+}
+
+#endif
diff --git a/paludis/output_manager.cc b/paludis/output_manager.cc
new file mode 100644
index 0000000..7692dd8
--- /dev/null
+++ b/paludis/output_manager.cc
@@ -0,0 +1,32 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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 <paludis/output_manager.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/exception.hh>
+#include <ostream>
+
+using namespace paludis;
+
+#include <paludis/output_manager-se.cc>
+
+OutputManager::~OutputManager()
+{
+}
+
diff --git a/paludis/output_manager.hh b/paludis/output_manager.hh
new file mode 100644
index 0000000..8c0dfa9
--- /dev/null
+++ b/paludis/output_manager.hh
@@ -0,0 +1,66 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_OUTPUT_MANAGER_HH
+#define PALUDIS_GUARD_PALUDIS_OUTPUT_MANAGER_HH 1
+
+#include <paludis/output_manager-fwd.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/util/instantiation_policy.hh>
+#include <iosfwd>
+
+namespace paludis
+{
+ class PALUDIS_VISIBLE OutputManager :
+ private InstantiationPolicy<OutputManager, instantiation_method::NonCopyableTag>
+ {
+ public:
+ virtual ~OutputManager() = 0;
+
+ virtual std::ostream & stdout_stream() PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ virtual std::ostream & stderr_stream() PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ /**
+ * An out of band message that might want to be logged or handled
+ * in a special way.
+ *
+ * The caller must still also display the message to
+ * stdout_stream() as appropriate.
+ */
+ virtual void message(const MessageType, const std::string &) = 0;
+
+ /**
+ * Called if an action succeeds. This can be used to, for example,
+ * unlink the files behind a to-disk logged output manager.
+ *
+ * If an OutputManager is destroyed without having had this method
+ * called, it should assume failure. This might mean keeping rather
+ * than removing log files, for example.
+ *
+ * Further messages and output may occur even after a call to this
+ * method.
+ *
+ * Calls to this method are done by the caller, not by whatever
+ * carries out the action in question.
+ */
+ virtual void succeeded() = 0;
+ };
+}
+
+#endif
diff --git a/paludis/output_manager.se b/paludis/output_manager.se
new file mode 100644
index 0000000..6169844
--- /dev/null
+++ b/paludis/output_manager.se
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+# vim: set sw=4 sts=4 et ft=sh :
+
+make_enum_MessageType()
+{
+ prefix mt
+
+ key mt_debug "A message only to be kept when debugging"
+ key mt_info "An informational message"
+ key mt_warn "A warning message"
+ key mt_error "An error message"
+ key mt_log "A message explicitly marked for logging"
+
+ doxygen_comment << "END"
+ /**
+ * Type of message for OutputManager.
+ *
+ * \see OutputManager
+ */
+END
+}
+
diff --git a/paludis/output_manager_factory-fwd.hh b/paludis/output_manager_factory-fwd.hh
new file mode 100644
index 0000000..853017e
--- /dev/null
+++ b/paludis/output_manager_factory-fwd.hh
@@ -0,0 +1,28 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_OUTPUT_MANAGER_FACTORY_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_OUTPUT_MANAGER_FACTORY_FWD_HH 1
+
+namespace paludis
+{
+ class OutputManagerFactory;
+}
+
+#endif
diff --git a/paludis/output_manager_factory.cc b/paludis/output_manager_factory.cc
new file mode 100644
index 0000000..c5ad781
--- /dev/null
+++ b/paludis/output_manager_factory.cc
@@ -0,0 +1,141 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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 <paludis/output_manager_factory.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/instantiation_policy-impl.hh>
+#include <paludis/util/member_iterator-impl.hh>
+#include <paludis/util/wrapped_forward_iterator-impl.hh>
+#include <paludis/util/join.hh>
+#include <paludis/util/named_value.hh>
+#include <paludis/util/make_named_values.hh>
+#include <paludis/util/set.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/system.hh>
+#include <paludis/util/dir_iterator.hh>
+#include <paludis/util/is_file_with_extension.hh>
+#include <paludis/about.hh>
+#include <tr1/unordered_map>
+#include <list>
+
+#include <paludis/file_output_manager.hh>
+#include <paludis/messages_to_stdout_output_handler.hh>
+#include <paludis/standard_output_manager.hh>
+#include <paludis/tee_output_manager.hh>
+
+using namespace paludis;
+
+namespace paludis
+{
+ namespace n
+ {
+ struct create_function;
+ }
+}
+
+namespace
+{
+ struct Funcs
+ {
+ NamedValue<n::create_function, OutputManagerFactory::CreateFunction> create_function;
+ };
+
+ typedef std::tr1::unordered_map<std::string, Funcs> Keys;
+
+ const Funcs & fetch(const Keys & keys, const std::string & key)
+ {
+ if (key.empty())
+ throw ConfigurationError("Key 'handler' not specified when creating an output manager");
+
+ Keys::const_iterator i(keys.find(key));
+ if (i == keys.end())
+ throw ConfigurationError("Format '" + key + "' not supported when creating an output manager (known formats are { "
+ + join(first_iterator(keys.begin()), first_iterator(keys.end()), ", ") + "})");
+
+ return i->second;
+ }
+}
+
+namespace paludis
+{
+ template <>
+ struct Implementation<OutputManagerFactory>
+ {
+ Keys keys;
+ std::list<void *> dl_opened;
+ };
+}
+
+OutputManagerFactory::OutputManagerFactory() :
+ PrivateImplementationPattern<OutputManagerFactory>(new Implementation<OutputManagerFactory>)
+{
+ /* we might want to make this plugin loadable at some point */
+ add_manager(FileOutputManager::factory_managers(), FileOutputManager::factory_create);
+ add_manager(MessagesToStdoutOutputManager::factory_managers(), MessagesToStdoutOutputManager::factory_create);
+ add_manager(StandardOutputManager::factory_managers(), StandardOutputManager::factory_create);
+ add_manager(TeeOutputManager::factory_managers(), TeeOutputManager::factory_create);
+}
+
+OutputManagerFactory::~OutputManagerFactory()
+{
+}
+
+const std::tr1::shared_ptr<OutputManager>
+OutputManagerFactory::create(
+ const KeyFunction & key_function,
+ const CreateChildFunction & create_child_function,
+ const ReplaceVarsFunc & replace_vars_func
+ ) const
+{
+ Context context("When creating output manager:");
+ return fetch(_imp->keys, key_function("handler")).create_function()(key_function, create_child_function, replace_vars_func);
+}
+
+OutputManagerFactory::ConstIterator
+OutputManagerFactory::begin_keys() const
+{
+ return first_iterator(_imp->keys.begin());
+}
+
+OutputManagerFactory::ConstIterator
+OutputManagerFactory::end_keys() const
+{
+ return first_iterator(_imp->keys.end());
+}
+
+void
+OutputManagerFactory::add_manager(
+ const std::tr1::shared_ptr<const Set<std::string> > & formats,
+ const CreateFunction & create_function
+ )
+{
+ for (Set<std::string>::ConstIterator f(formats->begin()), f_end(formats->end()) ;
+ f != f_end ; ++f)
+ {
+ if (! _imp->keys.insert(std::make_pair(*f, make_named_values<Funcs>(
+ value_for<n::create_function>(create_function)
+ ))).second)
+ throw ConfigurationError("Handler for output manager format '" + stringify(*f) + "' already exists");
+ }
+}
+
+template class PrivateImplementationPattern<OutputManagerFactory>;
+template class InstantiationPolicy<OutputManagerFactory, instantiation_method::SingletonTag>;
+template class WrappedForwardIterator<OutputManagerFactory::ConstIteratorTag, const std::string>;
+
diff --git a/paludis/output_manager_factory.hh b/paludis/output_manager_factory.hh
new file mode 100644
index 0000000..be627d9
--- /dev/null
+++ b/paludis/output_manager_factory.hh
@@ -0,0 +1,110 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_OUTPUT_MANAGER_FACTORY_HH
+#define PALUDIS_GUARD_PALUDIS_OUTPUT_MANAGER_FACTORY_HH 1
+
+#include <paludis/output_manager_factory-fwd.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/instantiation_policy.hh>
+#include <paludis/util/wrapped_forward_iterator-fwd.hh>
+#include <paludis/util/map-fwd.hh>
+#include <paludis/output_manager-fwd.hh>
+#include <paludis/util/set-fwd.hh>
+#include <tr1/functional>
+#include <tr1/memory>
+
+namespace paludis
+{
+ class PALUDIS_VISIBLE OutputManagerFactory :
+ private PrivateImplementationPattern<OutputManagerFactory>,
+ public InstantiationPolicy<OutputManagerFactory, instantiation_method::SingletonTag>
+ {
+ friend class InstantiationPolicy<OutputManagerFactory, instantiation_method::SingletonTag>;
+
+ private:
+ OutputManagerFactory();
+ ~OutputManagerFactory();
+
+ public:
+ typedef std::tr1::function<std::string (const std::string &)> KeyFunction;
+
+ typedef std::tr1::function<const std::tr1::shared_ptr<OutputManager> (
+ const std::string &)> CreateChildFunction;
+
+ typedef std::tr1::function<std::string (
+ const std::string & pattern,
+ const std::tr1::shared_ptr<const Map<std::string, std::string> > & extra_vars)> ReplaceVarsFunc;
+
+ typedef std::tr1::function<const std::tr1::shared_ptr<OutputManager>(
+ const KeyFunction &,
+ const CreateChildFunction &,
+ const ReplaceVarsFunc &
+ )> CreateFunction;
+
+ /**
+ * Construct a given OutputManager, or throw ConfigurationError.
+ *
+ * \param key_function should return the value for a given key. The
+ * 'handler' key must return a value (e.g. 'standard'), which is used
+ * to select the return type. Other key names are manager defined,
+ * but typically include things like 'location' and 'keep_on_success'.
+ *
+ * \param create_child_function is used by, for example,
+ * TeeOutputManager to create child streams. Given a single string,
+ * this function returns the appropriate child.
+ *
+ * \param replace_vars_func should replace '%{vars}' with their
+ * expanded forms. Variables include 'name', 'action' etc. This is
+ * used by, for example, FileOutputManager to allow the user to
+ * specify the output file names.
+ */
+ const std::tr1::shared_ptr<OutputManager> create(
+ const KeyFunction & key_function,
+ const CreateChildFunction & create_child_function,
+ const ReplaceVarsFunc & replace_vars_func
+ ) const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ /**
+ * Add a manager.
+ *
+ * \param managers must have at least one value, and no value may be
+ * specified more than once across all invocations.
+ *
+ * \param create_function is used to implement OutputManagerFactory::create.
+ */
+ void add_manager(
+ const std::tr1::shared_ptr<const Set<std::string> > & managers,
+ const CreateFunction & create_function
+ );
+
+ struct ConstIteratorTag;
+ typedef WrappedForwardIterator<ConstIteratorTag, const std::string> ConstIterator;
+ ConstIterator begin_keys() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ ConstIterator end_keys() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
+ extern template class PrivateImplementationPattern<OutputManagerFactory>;
+ extern template class InstantiationPolicy<OutputManagerFactory, instantiation_method::SingletonTag>;
+#endif
+}
+
+#endif
diff --git a/paludis/output_manager_from_environment-fwd.hh b/paludis/output_manager_from_environment-fwd.hh
new file mode 100644
index 0000000..4360a0a
--- /dev/null
+++ b/paludis/output_manager_from_environment-fwd.hh
@@ -0,0 +1,28 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_OUTPUT_MANAGER_FROM_ENVIRONMENT_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_OUTPUT_MANAGER_FROM_ENVIRONMENT_FWD_HH 1
+
+namespace paludis
+{
+ class OutputManagerFromEnvironment;
+}
+
+#endif
diff --git a/paludis/output_manager_from_environment.cc b/paludis/output_manager_from_environment.cc
new file mode 100644
index 0000000..0768f30
--- /dev/null
+++ b/paludis/output_manager_from_environment.cc
@@ -0,0 +1,88 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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 <paludis/output_manager_from_environment.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/log.hh>
+#include <paludis/environment.hh>
+#include <paludis/create_output_manager_info.hh>
+#include <paludis/standard_output_manager.hh>
+
+using namespace paludis;
+
+namespace paludis
+{
+ template <>
+ struct Implementation<OutputManagerFromEnvironment>
+ {
+ const Environment * const env;
+ const std::tr1::shared_ptr<const PackageID> id;
+ const OutputExclusivity output_exclusivity;
+
+ std::tr1::shared_ptr<OutputManager> result;
+
+ Implementation(const Environment * const e, const std::tr1::shared_ptr<const PackageID> & i,
+ const OutputExclusivity x) :
+ env(e),
+ id(i),
+ output_exclusivity(x)
+ {
+ }
+ };
+}
+
+OutputManagerFromEnvironment::OutputManagerFromEnvironment(
+ const Environment * const e,
+ const std::tr1::shared_ptr<const PackageID> & i,
+ const OutputExclusivity x) :
+ PrivateImplementationPattern<OutputManagerFromEnvironment>(new Implementation<OutputManagerFromEnvironment>(e, i, x))
+{
+}
+
+OutputManagerFromEnvironment::~OutputManagerFromEnvironment()
+{
+}
+
+const std::tr1::shared_ptr<OutputManager>
+OutputManagerFromEnvironment::operator() (const Action & a)
+{
+ if (! _imp->result)
+ _imp->result = _imp->env->create_output_manager(CreateOutputManagerForPackageIDActionInfo(_imp->id, a, _imp->output_exclusivity));
+ return _imp->result;
+}
+
+const std::tr1::shared_ptr<OutputManager>
+OutputManagerFromEnvironment::output_manager_if_constructed()
+{
+ return _imp->result;
+}
+
+void
+OutputManagerFromEnvironment::construct_standard_if_unconstructed()
+{
+ if (! _imp->result)
+ {
+ Log::get_instance()->message("output_manager_from_environment.constructed_standard", ll_warning, lc_context)
+ << "No output manager available, creating a standard output manager. This is probably a bug.";
+ _imp->result.reset(new StandardOutputManager);
+ }
+}
+
+template class PrivateImplementationPattern<OutputManagerFromEnvironment>;
+
diff --git a/paludis/output_manager_from_environment.hh b/paludis/output_manager_from_environment.hh
new file mode 100644
index 0000000..e4682d8
--- /dev/null
+++ b/paludis/output_manager_from_environment.hh
@@ -0,0 +1,57 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_OUTPUT_MANAGER_FROM_ENVIRONMENT_HH
+#define PALUDIS_GUARD_PALUDIS_OUTPUT_MANAGER_FROM_ENVIRONMENT_HH 1
+
+#include <paludis/output_manager_from_environment-fwd.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/output_manager-fwd.hh>
+#include <paludis/environment-fwd.hh>
+#include <paludis/package_id-fwd.hh>
+#include <paludis/action-fwd.hh>
+#include <paludis/create_output_manager_info-fwd.hh>
+
+namespace paludis
+{
+ class PALUDIS_VISIBLE OutputManagerFromEnvironment :
+ private PrivateImplementationPattern<OutputManagerFromEnvironment>
+ {
+ public:
+ OutputManagerFromEnvironment(
+ const Environment * const,
+ const std::tr1::shared_ptr<const PackageID> &,
+ const OutputExclusivity);
+
+ ~OutputManagerFromEnvironment();
+
+ const std::tr1::shared_ptr<OutputManager> operator() (const Action &);
+
+ const std::tr1::shared_ptr<OutputManager> output_manager_if_constructed();
+
+ void construct_standard_if_unconstructed();
+ };
+
+#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
+ extern template class PrivateImplementationPattern<OutputManagerFromEnvironment>;
+#endif
+}
+
+#endif
diff --git a/paludis/repositories/accounts/Makefile.am b/paludis/repositories/accounts/Makefile.am
index 0cb9ec1..0ab2044 100644
--- a/paludis/repositories/accounts/Makefile.am
+++ b/paludis/repositories/accounts/Makefile.am
@@ -77,6 +77,8 @@ TESTS_ENVIRONMENT = env \
TEST_SCRIPT_DIR="$(srcdir)/" \
PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \
PALUDIS_NO_CHOWN="yes" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
bash $(top_srcdir)/test/run_test.sh
TESTS = \
diff --git a/paludis/repositories/accounts/accounts_id.cc b/paludis/repositories/accounts/accounts_id.cc
index 2f4b6a8..a306a69 100644
--- a/paludis/repositories/accounts/accounts_id.cc
+++ b/paludis/repositories/accounts/accounts_id.cc
@@ -29,6 +29,7 @@
#include <paludis/util/tokeniser.hh>
#include <paludis/util/mutex.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/output_manager.hh>
#include <paludis/name.hh>
#include <paludis/version_spec.hh>
#include <paludis/literal_metadata_key.hh>
@@ -432,6 +433,9 @@ AccountsID::perform_action(Action & action) const
+ "' 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));
+
switch (install_action->options.want_phase()("merge"))
{
case wp_yes:
@@ -441,6 +445,7 @@ AccountsID::perform_action(Action & action) const
value_for<n::environment_file>(FSEntry("/dev/null")),
value_for<n::image_dir>(fs_location_key()->value()),
value_for<n::options>(MergerOptions() + mo_rewrite_symlinks + mo_allow_empty_dirs),
+ value_for<n::output_manager>(output_manager),
value_for<n::package_id>(shared_from_this()),
value_for<n::used_this_for_config_protect>(install_action->options.used_this_for_config_protect())
));
@@ -456,5 +461,7 @@ AccountsID::perform_action(Action & action) const
case last_wp:
throw InternalError(PALUDIS_HERE, "bad WantPhase");
}
+
+ output_manager->succeeded();
}
diff --git a/paludis/repositories/accounts/dummy_accounts_handler.cc b/paludis/repositories/accounts/dummy_accounts_handler.cc
index d811753..8bba557 100644
--- a/paludis/repositories/accounts/dummy_accounts_handler.cc
+++ b/paludis/repositories/accounts/dummy_accounts_handler.cc
@@ -18,9 +18,10 @@
*/
#include <paludis/repositories/accounts/dummy_accounts_handler.hh>
+#include <paludis/output_manager.hh>
#include <paludis/package_id.hh>
#include <paludis/repository.hh>
-#include <iostream>
+#include <ostream>
using namespace paludis;
using namespace paludis::accounts_repository;
@@ -28,7 +29,7 @@ using namespace paludis::accounts_repository;
void
DummyAccountsHandler::merge(const MergeParams & m)
{
- std::cout << ">>> Installing " << *m.package_id() << " using dummy handler" << std::endl;
- std::cout << ">>> Finished installing " << *m.package_id() << std::endl;
+ m.output_manager()->stdout_stream() << ">>> Installing " << *m.package_id() << " using dummy handler" << std::endl;
+ m.output_manager()->stdout_stream() << ">>> Finished installing " << *m.package_id() << std::endl;
}
diff --git a/paludis/repositories/accounts/passwd_accounts_handler.cc b/paludis/repositories/accounts/passwd_accounts_handler.cc
index 4415272..6001331 100644
--- a/paludis/repositories/accounts/passwd_accounts_handler.cc
+++ b/paludis/repositories/accounts/passwd_accounts_handler.cc
@@ -25,11 +25,11 @@
#include <paludis/util/set.hh>
#include <paludis/util/destringify.hh>
#include <paludis/util/join.hh>
+#include <paludis/output_manager.hh>
#include <paludis/action.hh>
#include <paludis/repository.hh>
#include <paludis/metadata_key.hh>
#include <paludis/package_id.hh>
-#include <iostream>
#include <sys/types.h>
#include <pwd.h>
#include <grp.h>
@@ -42,14 +42,14 @@ PasswdAccountsHandler::merge(const MergeParams & params)
{
Context context("When installing '" + stringify(*params.package_id()) + "':");
- std::cout << ">>> Installing " << *params.package_id() << " using passwd handler" << std::endl;
+ params.output_manager()->stdout_stream() << ">>> Installing " << *params.package_id() << " using passwd handler" << std::endl;
if (params.package_id()->end_metadata() != params.package_id()->find_metadata("groupname"))
merge_group(params);
else
merge_user(params);
- std::cout << ">>> Finished installing " << *params.package_id() << std::endl;
+ params.output_manager()->stdout_stream() << ">>> Finished installing " << *params.package_id() << std::endl;
}
void
@@ -111,7 +111,7 @@ PasswdAccountsHandler::merge_user(const MergeParams & params)
uid_t uid(destringify<uid_t>(preferred_uid));
if (getpwuid(uid))
{
- std::cout << ">>> Preferred UID " << uid << " already in use, not specifying an ID" << std::endl;
+ params.output_manager()->stdout_stream() << ">>> Preferred UID " << uid << " already in use, not specifying an ID" << std::endl;
preferred_uid = "";
}
@@ -247,7 +247,7 @@ PasswdAccountsHandler::merge_group(const MergeParams & params)
uid_t gid(destringify<uid_t>(preferred_gid));
if (getgrgid(gid))
{
- std::cout << ">>> Preferred GID " << gid << " already in use, not specifying an ID" << std::endl;
+ params.output_manager()->stdout_stream() << ">>> Preferred GID " << gid << " already in use, not specifying an ID" << std::endl;
preferred_gid = "";
}
diff --git a/paludis/repositories/cran/Makefile.am b/paludis/repositories/cran/Makefile.am
index e8168c2..0e0447b 100644
--- a/paludis/repositories/cran/Makefile.am
+++ b/paludis/repositories/cran/Makefile.am
@@ -128,6 +128,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_DISTRIBUTIONS_DIR="$(top_srcdir)/paludis/distributions/" \
PALUDIS_DISTRIBUTION="gentoo" \
PALUDIS_OPTIONS="" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
TEST_SCRIPT_DIR="$(srcdir)/" \
PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \
bash $(top_srcdir)/test/run_test.sh
diff --git a/paludis/repositories/cran/cran_repository.cc b/paludis/repositories/cran/cran_repository.cc
index 553f1cf..ba1c2bf 100644
--- a/paludis/repositories/cran/cran_repository.cc
+++ b/paludis/repositories/cran/cran_repository.cc
@@ -44,9 +44,9 @@
#include <paludis/util/is_file_with_extension.hh>
#include <paludis/util/hashes.hh>
#include <paludis/util/make_named_values.hh>
-#include <paludis/util/output_deviator.hh>
#include <paludis/util/wrapped_output_iterator.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/output_manager.hh>
#include <paludis/syncer.hh>
#include <tr1/unordered_map>
#include <tr1/functional>
@@ -368,7 +368,7 @@ CRANRepository::sets_list() const
}
bool
-CRANRepository::sync(const std::tr1::shared_ptr<const OutputDeviant> & output_deviant) const
+CRANRepository::sync(const std::tr1::shared_ptr<OutputManager> & output_manager) const
{
Context context("When syncing repository '" + stringify(name()) + "':");
Lock l(*_imp->big_nasty_mutex);
@@ -378,17 +378,10 @@ CRANRepository::sync(const std::tr1::shared_ptr<const OutputDeviant> & output_de
Command command1(Command(cmd).with_chdir(_imp->params.location()));
- if (output_deviant)
- command1
- .with_captured_stdout_stream(output_deviant->stdout_stream())
- .with_captured_stderr_stream(output_deviant->stderr_stream())
- ;
- else
- command1
- .with_stdout_prefix("sync " + stringify(name()) + "> ")
- .with_stderr_prefix("sync " + stringify(name()) + "> ")
- .with_prefix_blank_lines()
- ;
+ command1
+ .with_captured_stdout_stream(&output_manager->stdout_stream())
+ .with_captured_stderr_stream(&output_manager->stderr_stream())
+ ;
if (0 != run_command(command1))
throw SyncFailedError(stringify(_imp->params.location()), _imp->params.sync());
@@ -397,17 +390,10 @@ CRANRepository::sync(const std::tr1::shared_ptr<const OutputDeviant> & output_de
Command command2(Command(cmd).with_chdir(_imp->params.location()));
- if (output_deviant)
- command2
- .with_captured_stdout_stream(output_deviant->stdout_stream())
- .with_captured_stderr_stream(output_deviant->stderr_stream())
- ;
- else
- command2
- .with_stdout_prefix("sync " + stringify(name()) + "> ")
- .with_stderr_prefix("sync " + stringify(name()) + "> ")
- .with_prefix_blank_lines()
- ;
+ command2
+ .with_captured_stdout_stream(&output_manager->stdout_stream())
+ .with_captured_stderr_stream(&output_manager->stderr_stream())
+ ;
if (0 != run_command(command2))
throw SyncFailedError(stringify(_imp->params.location()), _imp->params.sync());
@@ -416,17 +402,10 @@ CRANRepository::sync(const std::tr1::shared_ptr<const OutputDeviant> & output_de
Command command3(Command(cmd).with_chdir(_imp->params.location()));
- if (output_deviant)
- command3
- .with_captured_stdout_stream(output_deviant->stdout_stream())
- .with_captured_stderr_stream(output_deviant->stderr_stream())
- ;
- else
- command3
- .with_stdout_prefix("sync " + stringify(name()) + "> ")
- .with_stderr_prefix("sync " + stringify(name()) + "> ")
- .with_prefix_blank_lines()
- ;
+ command3
+ .with_captured_stdout_stream(&output_manager->stdout_stream())
+ .with_captured_stderr_stream(&output_manager->stderr_stream())
+ ;
if (0 != run_command(command3))
throw SyncFailedError(stringify(_imp->params.location()), _imp->params.sync());
diff --git a/paludis/repositories/cran/cran_repository.hh b/paludis/repositories/cran/cran_repository.hh
index 6d458af..9baef2a 100644
--- a/paludis/repositories/cran/cran_repository.hh
+++ b/paludis/repositories/cran/cran_repository.hh
@@ -2,7 +2,7 @@
/*
* Copyright (c) 2006 Danny van Dyk
- * 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
@@ -134,7 +134,7 @@ namespace paludis
/* RepositorySyncableInterface */
- virtual bool sync(const std::tr1::shared_ptr<const OutputDeviant> & output_deviant) const;
+ virtual bool sync(const std::tr1::shared_ptr<OutputManager> & output_deviant) const;
/* Repository */
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index 7a16ca1..d6a36bf 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -444,6 +444,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_TESTS_KEEP_STDERR="yes" \
PALDUIS_TMPDIR="`pwd`" \
PALUDIS_BYPASS_USERPRIV_CHECKS="yes" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
LD_LIBRARY_PATH="`echo $$LD_LIBRARY_PATH: | sed -e 's,^:,,'`` \
$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories/e/`:` \
$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories/e/.libs/`" \
diff --git a/paludis/repositories/e/check_fetched_files_visitor.cc b/paludis/repositories/e/check_fetched_files_visitor.cc
index bbe4471..2f69de2 100644
--- a/paludis/repositories/e/check_fetched_files_visitor.cc
+++ b/paludis/repositories/e/check_fetched_files_visitor.cc
@@ -40,14 +40,13 @@
#include <paludis/util/sha256.hh>
#include <paludis/util/md5.hh>
#include <paludis/util/make_named_values.hh>
-#include <paludis/util/output_deviator.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/indirect_iterator.hh>
#include <paludis/util/accept_visitor.hh>
#include <paludis/util/safe_ifstream.hh>
+#include <paludis/output_manager.hh>
#include <algorithm>
-#include <iostream>
#include <list>
#include <set>
@@ -72,8 +71,7 @@ namespace paludis
const std::tr1::shared_ptr<Manifest2Reader> m2r;
const UseManifest use_manifest;
- const std::tr1::shared_ptr<OutputDeviant> maybe_output_deviant;
- std::ostream * out;
+ const std::tr1::shared_ptr<OutputManager> output_manager;
Implementation(
const Environment * const e,
@@ -83,7 +81,7 @@ namespace paludis
const bool n,
const FSEntry & m2,
const UseManifest um,
- const std::tr1::shared_ptr<OutputDeviant> & md,
+ const std::tr1::shared_ptr<OutputManager> & md,
const bool x) :
env(e),
id(i),
@@ -95,8 +93,7 @@ namespace paludis
in_nofetch(n),
m2r(new Manifest2Reader(m2)),
use_manifest(um),
- maybe_output_deviant(md),
- out(md ? maybe_output_deviant->stdout_stream() : &std::cout)
+ output_manager(md)
{
}
};
@@ -110,7 +107,7 @@ CheckFetchedFilesVisitor::CheckFetchedFilesVisitor(
const bool n,
const FSEntry & m2,
const UseManifest um,
- const std::tr1::shared_ptr<OutputDeviant> & md,
+ const std::tr1::shared_ptr<OutputManager> & md,
const bool x) :
PrivateImplementationPattern<CheckFetchedFilesVisitor>(new Implementation<CheckFetchedFilesVisitor>(e, i, d, c, n, m2, um, md, x))
{
@@ -226,7 +223,7 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile)
{
Log::get_instance()->message("e.manifest.no_size", ll_debug, lc_context)
<< "Malformed Manifest: no file size found";
- *_imp->out << "incorrect size";
+ _imp->output_manager->stdout_stream() << "incorrect size";
_imp->failures->push_back(make_named_values<FetchActionFailure>(
value_for<n::failed_automatic_fetching>(false),
value_for<n::failed_integrity_checks>("Incorrect file size"),
@@ -247,7 +244,7 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile)
{
Log::get_instance()->message("e.manifest.rmd160.failure", ll_debug, lc_context)
<< "Malformed Manifest: failed RMD160 checksum";
- *_imp->out << "failed RMD160";
+ _imp->output_manager->stdout_stream() << "failed RMD160";
_imp->failures->push_back(make_named_values<FetchActionFailure>(
value_for<n::failed_automatic_fetching>(false),
value_for<n::failed_integrity_checks>("Failed RMD160 checksum"),
@@ -269,7 +266,7 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile)
{
Log::get_instance()->message("e.manifest.sha1.failure", ll_debug, lc_context)
<< "Malformed Manifest: failed SHA1 checksum";
- *_imp->out << "failed SHA1";
+ _imp->output_manager->stdout_stream() << "failed SHA1";
_imp->failures->push_back(make_named_values<FetchActionFailure>(
value_for<n::failed_automatic_fetching>(false),
value_for<n::failed_integrity_checks>("Failed SHA1 checksum"),
@@ -291,7 +288,7 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile)
{
Log::get_instance()->message("e.manifest.sha256.failure", ll_debug, lc_context)
<< "Malformed Manifest: failed SHA256 checksum";
- *_imp->out << "failed SHA256";
+ _imp->output_manager->stdout_stream() << "failed SHA256";
_imp->failures->push_back(make_named_values<FetchActionFailure>(
value_for<n::failed_automatic_fetching>(false),
value_for<n::failed_integrity_checks>("Failed SHA256 checksum"),
@@ -313,7 +310,7 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile)
{
Log::get_instance()->message("e.manifest.md5.failure", ll_debug, lc_context)
<< "Malformed Manifest: failed MD5 checksum";
- *_imp->out << "failed MD5";
+ _imp->output_manager->stdout_stream() << "failed MD5";
_imp->failures->push_back(make_named_values<FetchActionFailure>(
value_for<n::failed_automatic_fetching>(false),
value_for<n::failed_integrity_checks>("Failed MD5 checksum"),
@@ -328,7 +325,7 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile)
}
catch (const SafeIFStreamError &)
{
- *_imp->out << "unreadable file";
+ _imp->output_manager->stdout_stream() << "unreadable file";
_imp->failures->push_back(make_named_values<FetchActionFailure>(
value_for<n::failed_automatic_fetching>(false),
value_for<n::failed_integrity_checks>("Unreadable file"),
@@ -341,7 +338,7 @@ CheckFetchedFilesVisitor::check_distfile_manifest(const FSEntry & distfile)
if (! found)
{
- *_imp->out << "not in Manifest";
+ _imp->output_manager->stdout_stream() << "not in Manifest";
_imp->failures->push_back(make_named_values<FetchActionFailure>(
value_for<n::failed_automatic_fetching>(false),
value_for<n::failed_integrity_checks>("Not in Manifest"),
@@ -367,7 +364,7 @@ CheckFetchedFilesVisitor::visit(const FetchableURISpecTree::NodeType<FetchableUR
}
_imp->done.insert(node.spec()->filename());
- *_imp->out << "Checking '" << node.spec()->filename() << "'... " << std::flush;
+ _imp->output_manager->stdout_stream() << "Checking '" << node.spec()->filename() << "'... " << std::flush;
if (! (_imp->distdir / node.spec()->filename()).is_regular_file())
{
@@ -377,7 +374,7 @@ CheckFetchedFilesVisitor::visit(const FetchableURISpecTree::NodeType<FetchableUR
{
Log::get_instance()->message("e.check_fetched_files.requires_manual", ll_debug, lc_context)
<< "Manual fetch required for '" << node.spec()->filename() << "'";
- *_imp->out << "requires manual fetch";
+ _imp->output_manager->stdout_stream() << "requires manual fetch";
_imp->need_nofetch = true;
_imp->failures->push_back(make_named_values<FetchActionFailure>(
value_for<n::failed_automatic_fetching>(false),
@@ -391,7 +388,7 @@ CheckFetchedFilesVisitor::visit(const FetchableURISpecTree::NodeType<FetchableUR
{
Log::get_instance()->message("e.check_fetched_files.does_not_exist", ll_debug, lc_context)
<< "Automatic fetch failed for '" << node.spec()->filename() << "'";
- *_imp->out << "does not exist";
+ _imp->output_manager->stdout_stream() << "does not exist";
_imp->failures->push_back(make_named_values<FetchActionFailure>(
value_for<n::failed_automatic_fetching>(true),
value_for<n::failed_integrity_checks>(""),
@@ -403,7 +400,7 @@ CheckFetchedFilesVisitor::visit(const FetchableURISpecTree::NodeType<FetchableUR
else if (0 == (_imp->distdir / node.spec()->filename()).file_size())
{
Log::get_instance()->message("e.check_fetched_files.empty", ll_debug, lc_context) << "Empty file for '" << node.spec()->filename() << "'";
- *_imp->out << "empty file";
+ _imp->output_manager->stdout_stream() << "empty file";
_imp->failures->push_back(make_named_values<FetchActionFailure>(
value_for<n::failed_automatic_fetching>(false),
value_for<n::failed_integrity_checks>("SIZE (empty file)"),
@@ -419,10 +416,10 @@ CheckFetchedFilesVisitor::visit(const FetchableURISpecTree::NodeType<FetchableUR
else
{
Log::get_instance()->message("e.check_fetched_files.success", ll_debug, lc_context) << "Success for '" << node.spec()->filename() << "'";
- *_imp->out << "ok";
+ _imp->output_manager->stdout_stream() << "ok";
}
- *_imp->out << std::endl;
+ _imp->output_manager->stdout_stream() << std::endl;
}
const std::tr1::shared_ptr<const Sequence<FetchActionFailure> >
diff --git a/paludis/repositories/e/check_fetched_files_visitor.hh b/paludis/repositories/e/check_fetched_files_visitor.hh
index c2215aa..90f4b49 100644
--- a/paludis/repositories/e/check_fetched_files_visitor.hh
+++ b/paludis/repositories/e/check_fetched_files_visitor.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
@@ -24,7 +24,7 @@
#include <paludis/util/attributes.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/fs_entry-fwd.hh>
-#include <paludis/util/output_deviator-fwd.hh>
+#include <paludis/output_manager-fwd.hh>
#include <paludis/dep_spec-fwd.hh>
#include <paludis/spec_tree.hh>
#include <paludis/package_id-fwd.hh>
@@ -51,7 +51,7 @@ namespace paludis
const bool fetch_restrict,
const FSEntry & m2,
const UseManifest um,
- const std::tr1::shared_ptr<OutputDeviant> & maybe_output_deviant,
+ const std::tr1::shared_ptr<OutputManager> & output_manager,
const bool exclude_unmirrorable);
~CheckFetchedFilesVisitor();
diff --git a/paludis/repositories/e/e_installed_repository.cc b/paludis/repositories/e/e_installed_repository.cc
index f385628..16ec3ef 100644
--- a/paludis/repositories/e/e_installed_repository.cc
+++ b/paludis/repositories/e/e_installed_repository.cc
@@ -246,7 +246,9 @@ EInstalledRepository::get_environment_variable(
}
void
-EInstalledRepository::perform_config(const std::tr1::shared_ptr<const ERepositoryID> & id) const
+EInstalledRepository::perform_config(
+ const std::tr1::shared_ptr<const ERepositoryID> & id,
+ const ConfigAction & a) const
{
Context context("When configuring '" + stringify(*id) + "':");
@@ -254,6 +256,8 @@ EInstalledRepository::perform_config(const std::tr1::shared_ptr<const ERepositor
throw InstallActionError("Couldn't configure '" + stringify(*id) +
"' because root ('" + stringify(_imp->params.root()) + "') is not a directory");
+ std::tr1::shared_ptr<OutputManager> output_manager(a.options.make_output_manager()(a));
+
FSEntry ver_dir(id->fs_location_key()->value());
std::tr1::shared_ptr<FSEntrySequence> eclassdirs(new FSEntrySequence);
@@ -275,6 +279,7 @@ EInstalledRepository::perform_config(const std::tr1::shared_ptr<const ERepositor
value_for<n::environment>(_imp->params.environment()),
value_for<n::exlibsdirs>(make_shared_ptr(new FSEntrySequence)),
value_for<n::files_dir>(ver_dir),
+ value_for<n::maybe_output_manager>(output_manager),
value_for<n::package_id>(id),
value_for<n::portdir>(ver_dir),
value_for<n::sandbox>(phase->option("sandbox")),
@@ -291,7 +296,9 @@ EInstalledRepository::perform_config(const std::tr1::shared_ptr<const ERepositor
}
void
-EInstalledRepository::perform_info(const std::tr1::shared_ptr<const ERepositoryID> & id) const
+EInstalledRepository::perform_info(
+ const std::tr1::shared_ptr<const ERepositoryID> & id,
+ const InfoAction & a) const
{
Context context("When infoing '" + stringify(*id) + "':");
@@ -299,6 +306,8 @@ EInstalledRepository::perform_info(const std::tr1::shared_ptr<const ERepositoryI
throw InstallActionError("Couldn't info '" + stringify(*id) +
"' because root ('" + stringify(_imp->params.root()) + "') is not a directory");
+ std::tr1::shared_ptr<OutputManager> output_manager(a.options.make_output_manager()(a));
+
FSEntry ver_dir(id->fs_location_key()->value());
std::tr1::shared_ptr<FSEntrySequence> eclassdirs(new FSEntrySequence);
@@ -374,6 +383,7 @@ EInstalledRepository::perform_info(const std::tr1::shared_ptr<const ERepositoryI
value_for<n::environment>(_imp->params.environment()),
value_for<n::exlibsdirs>(make_shared_ptr(new FSEntrySequence)),
value_for<n::files_dir>(ver_dir),
+ value_for<n::maybe_output_manager>(output_manager),
value_for<n::package_id>(id),
value_for<n::portdir>(ver_dir),
value_for<n::sandbox>(phase->option("sandbox")),
diff --git a/paludis/repositories/e/e_installed_repository.hh b/paludis/repositories/e/e_installed_repository.hh
index ab9c239..1368de1 100644
--- a/paludis/repositories/e/e_installed_repository.hh
+++ b/paludis/repositories/e/e_installed_repository.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 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
@@ -97,12 +97,18 @@ namespace paludis
///\name For use by EInstalledRepositoryID
///\{
- virtual void perform_uninstall(const std::tr1::shared_ptr<const erepository::ERepositoryID> & id,
- bool reinstalling, const std::string & merge_config_protect) const = 0;
+ virtual void perform_uninstall(
+ const std::tr1::shared_ptr<const erepository::ERepositoryID> & id,
+ const UninstallAction &,
+ bool reinstalling) const = 0;
- virtual void perform_config(const std::tr1::shared_ptr<const erepository::ERepositoryID> & id) const;
+ virtual void perform_config(
+ const std::tr1::shared_ptr<const erepository::ERepositoryID> & id,
+ const ConfigAction &) const;
- virtual void perform_info(const std::tr1::shared_ptr<const erepository::ERepositoryID> & id) const;
+ virtual void perform_info(
+ const std::tr1::shared_ptr<const erepository::ERepositoryID> & id,
+ const InfoAction &) const;
///\}
};
diff --git a/paludis/repositories/e/e_installed_repository_id.cc b/paludis/repositories/e/e_installed_repository_id.cc
index d009109..5cac0e3 100644
--- a/paludis/repositories/e/e_installed_repository_id.cc
+++ b/paludis/repositories/e/e_installed_repository_id.cc
@@ -42,6 +42,7 @@
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/safe_ifstream.hh>
+#include <paludis/output_manager.hh>
#include <paludis/literal_metadata_key.hh>
#include <iterator>
@@ -875,21 +876,22 @@ namespace
void visit(const UninstallAction & a)
{
- std::tr1::static_pointer_cast<const EInstalledRepository>(id->repository())->perform_uninstall(id, false, a.options.config_protect());
+ std::tr1::static_pointer_cast<const EInstalledRepository>(id->repository())->perform_uninstall(
+ id, a, false);
}
void visit(const InstalledAction &)
{
}
- void visit(const ConfigAction &)
+ void visit(const ConfigAction & a)
{
- std::tr1::static_pointer_cast<const EInstalledRepository>(id->repository())->perform_config(id);
+ std::tr1::static_pointer_cast<const EInstalledRepository>(id->repository())->perform_config(id, a);
}
- void visit(const InfoAction &)
+ void visit(const InfoAction & a)
{
- std::tr1::static_pointer_cast<const EInstalledRepository>(id->repository())->perform_info(id);
+ std::tr1::static_pointer_cast<const EInstalledRepository>(id->repository())->perform_info(id, a);
}
void visit(const InstallAction & a) PALUDIS_ATTRIBUTE((noreturn));
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index ffbd13a..7f2deb9 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -724,7 +724,7 @@ ERepository::sets_list() const
}
bool
-ERepository::sync(const std::tr1::shared_ptr<const OutputDeviant> & output_deviant) const
+ERepository::sync(const std::tr1::shared_ptr<OutputManager> & output_manager) const
{
Context context("When syncing repository '" + stringify(name()) + "':");
@@ -746,8 +746,7 @@ ERepository::sync(const std::tr1::shared_ptr<const OutputDeviant> & output_devia
SyncOptions opts(make_named_values<SyncOptions>(
value_for<n::filter_file>(_imp->layout->sync_filter_file()),
value_for<n::options>(_imp->params.sync_options()),
- value_for<n::output_deviant>(output_deviant),
- value_for<n::output_prefix>("sync " + stringify(name()) + "> ")
+ value_for<n::output_manager>(output_manager)
));
try
{
diff --git a/paludis/repositories/e/e_repository.hh b/paludis/repositories/e/e_repository.hh
index 2308664..3d81f92 100644
--- a/paludis/repositories/e/e_repository.hh
+++ b/paludis/repositories/e/e_repository.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 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
@@ -133,7 +133,7 @@ namespace paludis
/* RepositorySyncableInterface */
- virtual bool sync(const std::tr1::shared_ptr<const OutputDeviant> & output_deviant) const;
+ virtual bool sync(const std::tr1::shared_ptr<OutputManager> &) const;
/* RepositoryEnvironmentVariableInterface */
diff --git a/paludis/repositories/e/e_repository_TEST.cc b/paludis/repositories/e/e_repository_TEST.cc
index 3094db8..2c152c5 100644
--- a/paludis/repositories/e/e_repository_TEST.cc
+++ b/paludis/repositories/e/e_repository_TEST.cc
@@ -32,6 +32,7 @@
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/set.hh>
+#include <paludis/standard_output_manager.hh>
#include <paludis/util/safe_ifstream.hh>
#include <paludis/package_id.hh>
#include <paludis/metadata_key.hh>
@@ -57,6 +58,11 @@ using namespace paludis;
namespace
{
+ std::tr1::shared_ptr<OutputManager> make_standard_output_manager(const Action &)
+ {
+ return make_shared_ptr(new StandardOutputManager);
+ }
+
std::string from_keys(const std::tr1::shared_ptr<const Map<std::string, std::string> > & m,
const std::string & k)
{
@@ -922,7 +928,7 @@ namespace test_cases
FetchAction action(make_named_values<FetchActionOptions>(
value_for<n::exclude_unmirrorable>(false),
value_for<n::fetch_unneeded>(false),
- value_for<n::maybe_output_deviant>(make_null_shared_ptr()),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::safe_resume>(true)
));
@@ -1027,7 +1033,7 @@ namespace test_cases
FetchAction action(make_named_values<FetchActionOptions>(
value_for<n::exclude_unmirrorable>(false),
value_for<n::fetch_unneeded>(false),
- value_for<n::maybe_output_deviant>(make_null_shared_ptr()),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::safe_resume>(true)
));
@@ -1099,6 +1105,7 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::destination>(installed_repo),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
@@ -1354,6 +1361,7 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::destination>(installed_repo),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
@@ -1448,6 +1456,7 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::destination>(installed_repo),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
@@ -1572,6 +1581,7 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::destination>(installed_repo),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
@@ -1693,7 +1703,10 @@ namespace test_cases
std::tr1::shared_ptr<FakeInstalledRepository> installed_repo(new FakeInstalledRepository(&env, RepositoryName("installed")));
env.package_database()->add_repository(2, installed_repo);
- InfoAction action;
+ InfoActionOptions options(make_named_values<InfoActionOptions>(
+ value_for<n::make_output_manager>(&make_standard_output_manager)
+ ));
+ InfoAction action(options);
{
TestMessageSuffix suffix("info success kdebuild-1", true);
@@ -1774,6 +1787,7 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::destination>(installed_repo),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
@@ -2356,6 +2370,7 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::destination>(installed_repo),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
diff --git a/paludis/repositories/e/e_repository_TEST_ever.cc b/paludis/repositories/e/e_repository_TEST_ever.cc
index 10de8aa..8dccca8 100644
--- a/paludis/repositories/e/e_repository_TEST_ever.cc
+++ b/paludis/repositories/e/e_repository_TEST_ever.cc
@@ -32,6 +32,8 @@
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/set.hh>
+#include <paludis/output_manager.hh>
+#include <paludis/standard_output_manager.hh>
#include <paludis/package_id.hh>
#include <paludis/metadata_key.hh>
#include <paludis/action.hh>
@@ -56,6 +58,11 @@ using namespace paludis;
namespace
{
+ std::tr1::shared_ptr<OutputManager> make_standard_output_manager(const Action &)
+ {
+ return make_shared_ptr(new StandardOutputManager);
+ }
+
std::string from_keys(const std::tr1::shared_ptr<const Map<std::string, std::string> > & m,
const std::string & k)
{
@@ -138,6 +145,7 @@ namespace
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::destination>(installed_repo),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
diff --git a/paludis/repositories/e/e_repository_TEST_exlibs.cc b/paludis/repositories/e/e_repository_TEST_exlibs.cc
index 3dbd94d..19e5396 100644
--- a/paludis/repositories/e/e_repository_TEST_exlibs.cc
+++ b/paludis/repositories/e/e_repository_TEST_exlibs.cc
@@ -44,6 +44,7 @@
#include <paludis/selection.hh>
#include <paludis/repository_factory.hh>
#include <paludis/choice.hh>
+#include <paludis/standard_output_manager.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
#include <tr1/functional>
@@ -57,6 +58,11 @@ using namespace paludis;
namespace
{
+ std::tr1::shared_ptr<OutputManager> make_standard_output_manager(const Action &)
+ {
+ return make_shared_ptr(new StandardOutputManager);
+ }
+
std::string from_keys(const std::tr1::shared_ptr<const Map<std::string, std::string> > & m,
const std::string & k)
{
@@ -129,6 +135,7 @@ namespace
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::destination>(installed_repo),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
diff --git a/paludis/repositories/e/e_repository_entries.hh b/paludis/repositories/e/e_repository_entries.hh
index 612c74d..3e18f60 100644
--- a/paludis/repositories/e/e_repository_entries.hh
+++ b/paludis/repositories/e/e_repository_entries.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 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
@@ -27,6 +27,7 @@
#include <paludis/package_id-fwd.hh>
#include <paludis/environment-fwd.hh>
#include <paludis/util/instantiation_policy.hh>
+#include <paludis/output_manager-fwd.hh>
#include <paludis/repositories/e/e_repository_profile.hh>
#include <paludis/repositories/e/e_repository_params.hh>
#include <paludis/repositories/e/e_repository_id.hh>
@@ -82,13 +83,14 @@ namespace paludis
/**
* Handle an install.
*/
- virtual void install(const std::tr1::shared_ptr<const ERepositoryID> &, const InstallActionOptions &,
+ virtual void install(const std::tr1::shared_ptr<const ERepositoryID> &, const InstallAction &,
const std::tr1::shared_ptr<const ERepositoryProfile> &) const = 0;
/**
* Handle a fetch.
*/
- virtual void fetch(const std::tr1::shared_ptr<const ERepositoryID> &, const FetchActionOptions &,
+ virtual void fetch(const std::tr1::shared_ptr<const ERepositoryID> &,
+ const FetchAction &,
const std::tr1::shared_ptr<const ERepositoryProfile> &) const = 0;
/**
@@ -101,12 +103,14 @@ namespace paludis
* Handle a pretend.
*/
virtual bool pretend(const std::tr1::shared_ptr<const ERepositoryID> &,
+ const PretendAction &,
const std::tr1::shared_ptr<const ERepositoryProfile> &) const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
* Handle an info.
*/
virtual void info(const std::tr1::shared_ptr<const ERepositoryID> &,
+ const InfoAction &,
const std::tr1::shared_ptr<const ERepositoryProfile> &) const = 0;
/**
diff --git a/paludis/repositories/e/e_stripper.cc b/paludis/repositories/e/e_stripper.cc
index ada0484..5522543 100644
--- a/paludis/repositories/e/e_stripper.cc
+++ b/paludis/repositories/e/e_stripper.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 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
@@ -21,7 +21,8 @@
#include <paludis/util/fs_entry.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/make_named_values.hh>
-#include <iostream>
+#include <paludis/output_manager.hh>
+#include <ostream>
using namespace paludis;
using namespace paludis::erepository;
@@ -59,20 +60,20 @@ EStripper::~EStripper()
void
EStripper::on_strip(const FSEntry & f)
{
- std::cout << "str " << f.strip_leading(_imp->options.image_dir()) << std::endl;
+ _imp->options.output_manager()->stdout_stream() << "str " << f.strip_leading(_imp->options.image_dir()) << std::endl;
}
void
EStripper::on_split(const FSEntry & f, const FSEntry & g)
{
- std::cout << "spl " << f.strip_leading(_imp->options.image_dir()) <<
+ _imp->options.output_manager()->stdout_stream() << "spl " << f.strip_leading(_imp->options.image_dir()) <<
" -> " << g.strip_leading(_imp->options.image_dir()) << std::endl;
}
void
EStripper::on_unknown(const FSEntry & f)
{
- std::cout << "--- " << f.strip_leading(_imp->options.image_dir()) << std::endl;
+ _imp->options.output_manager()->stdout_stream() << "--- " << f.strip_leading(_imp->options.image_dir()) << std::endl;
}
void
@@ -88,7 +89,7 @@ EStripper::on_leave_dir(const FSEntry &)
void
EStripper::strip()
{
- std::cout << ">>> Stripping inside " << _imp->options.image_dir() << std::endl;
+ _imp->options.output_manager()->stdout_stream() << ">>> Stripping inside " << _imp->options.image_dir() << std::endl;
Stripper::strip();
}
diff --git a/paludis/repositories/e/e_stripper.hh b/paludis/repositories/e/e_stripper.hh
index c1dfb51..695cac1 100644
--- a/paludis/repositories/e/e_stripper.hh
+++ b/paludis/repositories/e/e_stripper.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 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
@@ -23,6 +23,7 @@
#include <paludis/stripper.hh>
#include <paludis/package_id-fwd.hh>
#include <paludis/util/fs_entry-fwd.hh>
+#include <paludis/output_manager-fwd.hh>
#include <tr1/memory>
namespace paludis
@@ -31,6 +32,7 @@ namespace paludis
{
struct debug_dir;
struct image_dir;
+ struct output_manager;
struct package_id;
struct split;
struct strip;
@@ -42,6 +44,7 @@ namespace paludis
{
NamedValue<n::debug_dir, FSEntry> debug_dir;
NamedValue<n::image_dir, FSEntry> image_dir;
+ NamedValue<n::output_manager, std::tr1::shared_ptr<OutputManager> > output_manager;
NamedValue<n::package_id, std::tr1::shared_ptr<const PackageID> > package_id;
NamedValue<n::split, bool> split;
NamedValue<n::strip, bool> strip;
diff --git a/paludis/repositories/e/ebuild.cc b/paludis/repositories/e/ebuild.cc
index bbd275d..5ae5627 100644
--- a/paludis/repositories/e/ebuild.cc
+++ b/paludis/repositories/e/ebuild.cc
@@ -40,7 +40,7 @@
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/set.hh>
#include <paludis/util/cookie.hh>
-#include <paludis/util/output_deviator.hh>
+#include <paludis/output_manager.hh>
#include <paludis/about.hh>
#include <paludis/environment.hh>
@@ -116,7 +116,9 @@ EbuildCommand::operator() ()
}
using namespace std::tr1::placeholders;
- cmd.with_pipe_command_handler(std::tr1::bind(&pipe_command_handler, params.environment(), params.package_id(), _1));
+
+ cmd.with_pipe_command_handler(std::tr1::bind(&pipe_command_handler, params.environment(),
+ params.package_id(), _1, params.maybe_output_manager()));
std::tr1::shared_ptr<const FSEntrySequence> syncers_dirs(params.environment()->syncers_dirs());
std::tr1::shared_ptr<const FSEntrySequence> bashrc_files(params.environment()->bashrc_files());
@@ -247,6 +249,11 @@ EbuildCommand::operator() ()
if (params.package_id()->eapi()->supported()->ebuild_options()->want_portage_emulation_vars())
cmd = add_portage_vars(cmd);
+ if (params.maybe_output_manager())
+ cmd
+ .with_captured_stderr_stream(&params.maybe_output_manager()->stderr_stream())
+ .with_captured_stdout_stream(&params.maybe_output_manager()->stdout_stream());
+
if (do_run_command(cmd))
return success();
else
@@ -677,11 +684,6 @@ EbuildNoFetchCommand::extend_command(const Command & cmd)
j(fetch_params.expand_vars()->end()) ; i != j ; ++i)
result.with_setenv(i->first, i->second);
- if (fetch_params.maybe_output_deviant())
- result
- .with_captured_stderr_stream(fetch_params.maybe_output_deviant()->stderr_stream())
- .with_captured_stdout_stream(fetch_params.maybe_output_deviant()->stdout_stream());
-
return result;
}
@@ -877,9 +879,15 @@ WriteVDBEntryCommand::operator() ()
params.package_id()->eapi()->supported()->ebuild_options()->ignore_pivot_env_variables())
.with_setenv("PALUDIS_EBUILD_MODULE_SUFFIXES",
params.package_id()->eapi()->supported()->ebuild_options()->ebuild_module_suffixes())
- .with_pipe_command_handler(std::tr1::bind(&pipe_command_handler, params.environment(), params.package_id(), _1))
+ .with_pipe_command_handler(std::tr1::bind(&pipe_command_handler, params.environment(),
+ params.package_id(), _1, params.maybe_output_manager()))
);
+ if (params.maybe_output_manager())
+ cmd
+ .with_captured_stderr_stream(&params.maybe_output_manager()->stderr_stream())
+ .with_captured_stdout_stream(&params.maybe_output_manager()->stdout_stream());
+
std::string defined_phases(params.package_id()->eapi()->supported()->ebuild_metadata_variables()->defined_phases()->name());
if (! defined_phases.empty())
if (params.package_id()->defined_phases_key())
@@ -1094,7 +1102,8 @@ WriteBinaryEbuildCommand::operator() ()
+ params.package_id()->eapi()->exported_name())->supported()->ebuild_environment_variables()->env_distdir())
.with_setenv("PALUDIS_EBUILD_MODULE_SUFFIXES",
params.package_id()->eapi()->supported()->ebuild_options()->ebuild_module_suffixes())
- .with_pipe_command_handler(std::tr1::bind(&pipe_command_handler, params.environment(), params.package_id(), _1))
+ .with_pipe_command_handler(std::tr1::bind(&pipe_command_handler, params.environment(),
+ params.package_id(), _1, params.maybe_output_manager()))
);
if (0 != (run_command(cmd)))
diff --git a/paludis/repositories/e/ebuild.hh b/paludis/repositories/e/ebuild.hh
index 2e4613b..fbd7637 100644
--- a/paludis/repositories/e/ebuild.hh
+++ b/paludis/repositories/e/ebuild.hh
@@ -65,7 +65,7 @@ namespace paludis
struct info_vars;
struct load_environment;
struct loadsaveenv_dir;
- struct maybe_output_deviant;
+ struct maybe_output_manager;
struct merger_options;
struct output_directory;
struct package_id;
@@ -106,6 +106,7 @@ namespace paludis
NamedValue<n::environment, const Environment *> environment;
NamedValue<n::exlibsdirs, std::tr1::shared_ptr<const FSEntrySequence> > exlibsdirs;
NamedValue<n::files_dir, FSEntry> files_dir;
+ NamedValue<n::maybe_output_manager, std::tr1::shared_ptr<OutputManager> > maybe_output_manager;
NamedValue<n::package_id, std::tr1::shared_ptr<const erepository::ERepositoryID> > package_id;
NamedValue<n::portdir, FSEntry> portdir;
NamedValue<n::sandbox, bool> sandbox;
@@ -124,7 +125,6 @@ namespace paludis
NamedValue<n::a, std::string> a;
NamedValue<n::aa, std::string> aa;
NamedValue<n::expand_vars, std::tr1::shared_ptr<const Map<std::string, std::string> > > expand_vars;
- NamedValue<n::maybe_output_deviant, std::tr1::shared_ptr<OutputDeviant> > maybe_output_deviant;
NamedValue<n::profiles, std::tr1::shared_ptr<const FSEntrySequence> > profiles;
NamedValue<n::root, std::string> root;
NamedValue<n::use, std::string> use;
@@ -249,6 +249,7 @@ namespace paludis
{
NamedValue<n::environment, const Environment *> environment;
NamedValue<n::environment_file, FSEntry> environment_file;
+ NamedValue<n::maybe_output_manager, std::tr1::shared_ptr<OutputManager> > maybe_output_manager;
NamedValue<n::output_directory, FSEntry> output_directory;
NamedValue<n::package_id, std::tr1::shared_ptr<const erepository::ERepositoryID> > package_id;
};
@@ -269,6 +270,7 @@ namespace paludis
NamedValue<n::environment, const Environment *> environment;
NamedValue<n::environment_file, FSEntry> environment_file;
NamedValue<n::image, FSEntry> image;
+ NamedValue<n::maybe_output_manager, std::tr1::shared_ptr<OutputManager> > maybe_output_manager;
NamedValue<n::merger_options, MergerOptions> merger_options;
NamedValue<n::package_id, std::tr1::shared_ptr<const erepository::ERepositoryID> > package_id;
};
diff --git a/paludis/repositories/e/ebuild/0/Makefile.am b/paludis/repositories/e/ebuild/0/Makefile.am
index a287dce..65e5a90 100644
--- a/paludis/repositories/e/ebuild/0/Makefile.am
+++ b/paludis/repositories/e/ebuild/0/Makefile.am
@@ -49,6 +49,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_DISTRIBUTIONS_DIR="$(top_srcdir)/paludis/distributions/" \
PALUDIS_EBUILD_LOG_LEVEL="warning" \
PALUDIS_OPTIONS="" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
TOP_BUILD_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/`" \
TEST_SCRIPT_DIR="$(srcdir)/" \
PALUDIS_TMPDIR="`pwd`/" \
diff --git a/paludis/repositories/e/ebuild/1/Makefile.am b/paludis/repositories/e/ebuild/1/Makefile.am
index 0a1b71c..a12fc77 100644
--- a/paludis/repositories/e/ebuild/1/Makefile.am
+++ b/paludis/repositories/e/ebuild/1/Makefile.am
@@ -17,6 +17,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_DISTRIBUTION="gentoo" \
PALUDIS_OPTIONS="" \
PALUDIS_EBUILD_LOG_LEVEL="warning" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
TOP_BUILD_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/`" \
TEST_SCRIPT_DIR="$(srcdir)/" \
PALUDIS_TMPDIR="`pwd`/" \
diff --git a/paludis/repositories/e/ebuild/2/Makefile.am b/paludis/repositories/e/ebuild/2/Makefile.am
index 2661886..2afb0a9 100644
--- a/paludis/repositories/e/ebuild/2/Makefile.am
+++ b/paludis/repositories/e/ebuild/2/Makefile.am
@@ -24,6 +24,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_DISTRIBUTION="gentoo" \
PALUDIS_OPTIONS="" \
PALUDIS_EBUILD_LOG_LEVEL="warning" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
TOP_BUILD_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/`" \
TEST_SCRIPT_DIR="$(srcdir)/" \
PALUDIS_TMPDIR="`pwd`/" \
diff --git a/paludis/repositories/e/ebuild/Makefile.am b/paludis/repositories/e/ebuild/Makefile.am
index fa58b96..b6ed8c8 100644
--- a/paludis/repositories/e/ebuild/Makefile.am
+++ b/paludis/repositories/e/ebuild/Makefile.am
@@ -31,6 +31,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_DISTRIBUTION="gentoo" \
PALUDIS_OPTIONS="" \
PALUDIS_EBUILD_LOG_LEVEL="warning" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
TOP_BUILD_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/`" \
TEST_SCRIPT_DIR="$(srcdir)/" \
PALUDIS_TMPDIR="`pwd`/" \
diff --git a/paludis/repositories/e/ebuild/exheres-0/Makefile.am b/paludis/repositories/e/ebuild/exheres-0/Makefile.am
index 841960e..45c189c 100644
--- a/paludis/repositories/e/ebuild/exheres-0/Makefile.am
+++ b/paludis/repositories/e/ebuild/exheres-0/Makefile.am
@@ -53,6 +53,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_OPTIONS="" \
PALUDIS_EBUILD_LOG_LEVEL="warning" \
PALUDIS_EBUILD_MODULE_SUFFIXES="exheres-0" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
TOP_BUILD_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/`" \
TEST_SCRIPT_DIR="$(srcdir)/" \
PALUDIS_TMPDIR="`pwd`/" \
diff --git a/paludis/repositories/e/ebuild/kdebuild-1/Makefile.am b/paludis/repositories/e/ebuild/kdebuild-1/Makefile.am
index 28fa511..87dfb0e 100644
--- a/paludis/repositories/e/ebuild/kdebuild-1/Makefile.am
+++ b/paludis/repositories/e/ebuild/kdebuild-1/Makefile.am
@@ -16,6 +16,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_DISTRIBUTION="gentoo" \
PALUDIS_OPTIONS="" \
PALUDIS_EBUILD_LOG_LEVEL="warning" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
TOP_BUILD_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/`" \
TEST_SCRIPT_DIR="$(srcdir)/" \
PALUDIS_TMPDIR="`pwd`/" \
diff --git a/paludis/repositories/e/ebuild/paludis-1/Makefile.am b/paludis/repositories/e/ebuild/paludis-1/Makefile.am
index 9d39226..8c84306 100644
--- a/paludis/repositories/e/ebuild/paludis-1/Makefile.am
+++ b/paludis/repositories/e/ebuild/paludis-1/Makefile.am
@@ -16,6 +16,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_DISTRIBUTION="gentoo" \
PALUDIS_OPTIONS="" \
PALUDIS_EBUILD_LOG_LEVEL="warning" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
TOP_BUILD_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/`" \
TEST_SCRIPT_DIR="$(srcdir)/" \
bash $(top_srcdir)/test/run_test.sh $(top_srcdir)/paludis/repositories/e/ebuild/run_test.bash
diff --git a/paludis/repositories/e/ebuild/pbin-1/Makefile.am b/paludis/repositories/e/ebuild/pbin-1/Makefile.am
index a29479f..71e726b 100644
--- a/paludis/repositories/e/ebuild/pbin-1/Makefile.am
+++ b/paludis/repositories/e/ebuild/pbin-1/Makefile.am
@@ -16,6 +16,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_DISTRIBUTION="gentoo" \
PALUDIS_OPTIONS="" \
PALUDIS_EBUILD_LOG_LEVEL="warning" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
TOP_BUILD_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/`" \
TEST_SCRIPT_DIR="$(srcdir)/" \
PALUDIS_TMPDIR="`pwd`/" \
diff --git a/paludis/repositories/e/ebuild_entries.cc b/paludis/repositories/e/ebuild_entries.cc
index 91d5521..dc41052 100644
--- a/paludis/repositories/e/ebuild_entries.cc
+++ b/paludis/repositories/e/ebuild_entries.cc
@@ -56,8 +56,8 @@
#include <paludis/util/instantiation_policy-impl.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/output_manager.hh>
#include <tr1/functional>
-#include <iostream>
#include <list>
#include <set>
#include <sys/types.h>
@@ -348,7 +348,7 @@ namespace
void
EbuildEntries::fetch(const std::tr1::shared_ptr<const ERepositoryID> & id,
- const FetchActionOptions & o, const std::tr1::shared_ptr<const ERepositoryProfile> & p) const
+ const FetchAction & fetch_action, const std::tr1::shared_ptr<const ERepositoryProfile> & p) const
{
using namespace std::tr1::placeholders;
@@ -425,6 +425,8 @@ EbuildEntries::fetch(const std::tr1::shared_ptr<const ERepositoryID> & id,
archives = strip_trailing(archives, " ");
all_archives = strip_trailing(all_archives, " ");
+ std::tr1::shared_ptr<OutputManager> output_manager(fetch_action.options.make_output_manager()(fetch_action));
+
if (id->fetches_key())
{
/* always use mirror://gentoo/, where gentoo is the name of our first master repository,
@@ -434,14 +436,16 @@ EbuildEntries::fetch(const std::tr1::shared_ptr<const ERepositoryID> & id,
stringify((*_imp->e_repository->params().master_repositories()->begin())->name()) :
stringify(_imp->e_repository->name()));
FetchVisitor f(_imp->params.environment(), id, *id->eapi(),
- _imp->e_repository->params().distdir(), o.fetch_unneeded(), fetch_userpriv_ok, mirrors_name,
- id->fetches_key()->initial_label(), o.safe_resume(), o.maybe_output_deviant());
+ _imp->e_repository->params().distdir(), fetch_action.options.fetch_unneeded(),
+ fetch_userpriv_ok, mirrors_name,
+ id->fetches_key()->initial_label(), fetch_action.options.safe_resume(),
+ output_manager);
id->fetches_key()->value()->root()->accept(f);
CheckFetchedFilesVisitor c(_imp->environment, id, _imp->e_repository->params().distdir(),
- o.fetch_unneeded(), fetch_restrict,
+ fetch_action.options.fetch_unneeded(), fetch_restrict,
((_imp->e_repository->layout()->package_directory(id->name())) / "Manifest"),
_imp->e_repository->params().use_manifest(),
- o.maybe_output_deviant(), o.exclude_unmirrorable());
+ output_manager, fetch_action.options.exclude_unmirrorable());
id->fetches_key()->value()->root()->accept(c);
if (c.need_nofetch())
@@ -469,6 +473,7 @@ EbuildEntries::fetch(const std::tr1::shared_ptr<const ERepositoryID> & id,
value_for<n::environment>(_imp->params.environment()),
value_for<n::exlibsdirs>(exlibsdirs),
value_for<n::files_dir>(_imp->e_repository->layout()->package_directory(id->name()) / "files"),
+ value_for<n::maybe_output_manager>(output_manager),
value_for<n::package_id>(id),
value_for<n::portdir>(
(_imp->params.master_repositories() && ! _imp->params.master_repositories()->empty()) ?
@@ -482,7 +487,6 @@ EbuildEntries::fetch(const std::tr1::shared_ptr<const ERepositoryID> & id,
value_for<n::a>(archives),
value_for<n::aa>(all_archives),
value_for<n::expand_vars>(expand_vars),
- value_for<n::maybe_output_deviant>(o.maybe_output_deviant()),
value_for<n::profiles>(_imp->params.profiles()),
value_for<n::root>("/"),
value_for<n::use>(use),
@@ -498,6 +502,8 @@ EbuildEntries::fetch(const std::tr1::shared_ptr<const ERepositoryID> & id,
if (! c.failures()->empty())
throw FetchActionError("Fetch of '" + stringify(*id) + "' failed", c.failures());
}
+
+ output_manager->succeeded();
}
void
@@ -519,12 +525,14 @@ EbuildEntries::pretend_fetch(const std::tr1::shared_ptr<const ERepositoryID> & i
void
EbuildEntries::install(const std::tr1::shared_ptr<const ERepositoryID> & id,
- const InstallActionOptions & o, const std::tr1::shared_ptr<const ERepositoryProfile> & p) const
+ const InstallAction & install_action, const std::tr1::shared_ptr<const ERepositoryProfile> & p) const
{
using namespace std::tr1::placeholders;
Context context("When installing '" + stringify(*id) + "':");
+ std::tr1::shared_ptr<OutputManager> output_manager(install_action.options.make_output_manager()(install_action));
+
bool userpriv_restrict, test_restrict, strip_restrict;
{
DepSpecFlattener<PlainTextSpecTree, PlainTextDepSpec> restricts(_imp->params.environment());
@@ -619,7 +627,7 @@ EbuildEntries::install(const std::tr1::shared_ptr<const ERepositoryID> & id,
bool skip(false);
do
{
- switch (o.want_phase()(phase->equal_option("skipname")))
+ switch (install_action.options.want_phase()(phase->equal_option("skipname")))
{
case wp_yes:
continue;
@@ -643,26 +651,27 @@ EbuildEntries::install(const std::tr1::shared_ptr<const ERepositoryID> & id,
if (can_skip_phase(id, *phase))
{
- std::cout << "--- No need to do anything for " << phase->equal_option("skipname") << " phase" << std::endl;
+ output_manager->stdout_stream() << "--- No need to do anything for " << phase->equal_option("skipname") << " phase" << std::endl;
continue;
}
if (phase->option("merge"))
{
- if (! (*o.destination()).destination_interface())
+ if (! (*install_action.options.destination()).destination_interface())
throw InstallActionError("Can't install '" + stringify(*id)
- + "' to destination '" + stringify(o.destination()->name())
+ + "' to destination '" + stringify(install_action.options.destination()->name())
+ "' because destination does not provide destination_interface");
- (*o.destination()).destination_interface()->merge(
+ (*install_action.options.destination()).destination_interface()->merge(
make_named_values<MergeParams>(
value_for<n::environment_file>(_imp->params.builddir() / (stringify(id->name().category()) + "-" +
stringify(id->name().package()) + "-" + stringify(id->version())) / "temp" / "loadsaveenv"),
value_for<n::image_dir>(_imp->params.builddir() / (stringify(id->name().category()) + "-" +
stringify(id->name().package()) + "-" + stringify(id->version())) / "image"),
value_for<n::options>(id->eapi()->supported()->merger_options()),
+ value_for<n::output_manager>(output_manager),
value_for<n::package_id>(id),
- value_for<n::used_this_for_config_protect>(o.used_this_for_config_protect())
+ value_for<n::used_this_for_config_protect>(install_action.options.used_this_for_config_protect())
));
}
else if (phase->option("strip"))
@@ -670,8 +679,8 @@ EbuildEntries::install(const std::tr1::shared_ptr<const ERepositoryID> & id,
if (! strip_restrict)
{
std::string libdir("lib");
- FSEntry root(o.destination()->installed_root_key() ?
- stringify(o.destination()->installed_root_key()->value()) : "/");
+ FSEntry root(install_action.options.destination()->installed_root_key() ?
+ stringify(install_action.options.destination()->installed_root_key()->value()) : "/");
if ((root / "usr" / "lib").is_symbolic_link())
{
libdir = (root / "usr" / "lib").readlink();
@@ -691,6 +700,7 @@ EbuildEntries::install(const std::tr1::shared_ptr<const ERepositoryID> & id,
stringify(id->name().package()) + "-" + stringify(id->version())) / "image" / "usr" / libdir / "debug"),
value_for<n::image_dir>(_imp->params.builddir() / (stringify(id->name().category()) + "-" +
stringify(id->name().package()) + "-" + stringify(id->version())) / "image"),
+ value_for<n::output_manager>(output_manager),
value_for<n::package_id>(id),
value_for<n::split>(split_choice && split_choice->enabled()),
value_for<n::strip>(strip_choice && strip_choice->enabled())
@@ -699,8 +709,8 @@ EbuildEntries::install(const std::tr1::shared_ptr<const ERepositoryID> & id,
}
}
else if ((! phase->option("prepost")) ||
- ((*o.destination()).destination_interface() &&
- (*o.destination()).destination_interface()->want_pre_post_phases()))
+ ((*install_action.options.destination()).destination_interface() &&
+ (*install_action.options.destination()).destination_interface()->want_pre_post_phases()))
{
if (phase->option("optional_tests"))
{
@@ -733,6 +743,7 @@ EbuildEntries::install(const std::tr1::shared_ptr<const ERepositoryID> & id,
value_for<n::environment>(_imp->params.environment()),
value_for<n::exlibsdirs>(exlibsdirs),
value_for<n::files_dir>(_imp->e_repository->layout()->package_directory(id->name()) / "files"),
+ value_for<n::maybe_output_manager>(output_manager),
value_for<n::package_id>(id),
value_for<n::portdir>(
(_imp->params.master_repositories() && ! _imp->params.master_repositories()->empty()) ?
@@ -750,7 +761,9 @@ EbuildEntries::install(const std::tr1::shared_ptr<const ERepositoryID> & id,
value_for<n::expand_vars>(expand_vars),
value_for<n::loadsaveenv_dir>(_imp->params.builddir() / (stringify(id->name().category()) + "-" + stringify(id->name().package()) + "-" + stringify(id->version())) / "temp"),
value_for<n::profiles>(_imp->params.profiles()),
- value_for<n::root>(o.destination()->installed_root_key() ? stringify(o.destination()->installed_root_key()->value()) : "/"),
+ value_for<n::root>(install_action.options.destination()->installed_root_key() ?
+ stringify(install_action.options.destination()->installed_root_key()->value()) :
+ "/"),
value_for<n::slot>(id->slot_key() ? stringify(id->slot_key()->value()) : ""),
value_for<n::use>(use),
value_for<n::use_expand>(join(p->use_expand()->begin(), p->use_expand()->end(), " ")),
@@ -761,16 +774,21 @@ EbuildEntries::install(const std::tr1::shared_ptr<const ERepositoryID> & id,
cmd();
}
}
+
+ output_manager->succeeded();
}
void
EbuildEntries::info(const std::tr1::shared_ptr<const ERepositoryID> & id,
+ const InfoAction & a,
const std::tr1::shared_ptr<const ERepositoryProfile> & p) const
{
using namespace std::tr1::placeholders;
Context context("When infoing '" + stringify(*id) + "':");
+ std::tr1::shared_ptr<OutputManager> output_manager(a.options.make_output_manager()(a));
+
bool userpriv_restrict;
{
DepSpecFlattener<PlainTextSpecTree, PlainTextDepSpec> restricts(_imp->params.environment());
@@ -813,6 +831,7 @@ EbuildEntries::info(const std::tr1::shared_ptr<const ERepositoryID> & id,
value_for<n::environment>(_imp->params.environment()),
value_for<n::exlibsdirs>(exlibsdirs),
value_for<n::files_dir>(_imp->e_repository->layout()->package_directory(id->name()) / "files"),
+ value_for<n::maybe_output_manager>(output_manager),
value_for<n::package_id>(id),
value_for<n::portdir>(
(_imp->params.master_repositories() && ! _imp->params.master_repositories()->empty()) ?
@@ -841,7 +860,8 @@ EbuildEntries::info(const std::tr1::shared_ptr<const ERepositoryID> & id,
}
std::string
-EbuildEntries::get_environment_variable(const std::tr1::shared_ptr<const ERepositoryID> & id,
+EbuildEntries::get_environment_variable(
+ const std::tr1::shared_ptr<const ERepositoryID> & id,
const std::string & var, const std::tr1::shared_ptr<const ERepositoryProfile> &) const
{
EAPIPhases phases(id->eapi()->supported()->ebuild_phases()->ebuild_variable());
@@ -880,6 +900,7 @@ EbuildEntries::get_environment_variable(const std::tr1::shared_ptr<const EReposi
value_for<n::environment>(_imp->params.environment()),
value_for<n::exlibsdirs>(exlibsdirs),
value_for<n::files_dir>(_imp->e_repository->layout()->package_directory(id->name()) / "files"),
+ value_for<n::maybe_output_manager>(make_null_shared_ptr()),
value_for<n::package_id>(id),
value_for<n::portdir>(
(_imp->params.master_repositories() && ! _imp->params.master_repositories()->empty()) ?
@@ -928,6 +949,7 @@ EbuildEntries::merge(const MergeParams & m)
value_for<n::environment>(_imp->params.environment()),
value_for<n::environment_file>(m.environment_file()),
value_for<n::image>(m.image_dir()),
+ value_for<n::maybe_output_manager>(m.output_manager()),
value_for<n::merger_options>(std::tr1::static_pointer_cast<const ERepositoryID>(m.package_id())->eapi()->supported()->merger_options()),
value_for<n::package_id>(std::tr1::static_pointer_cast<const ERepositoryID>(m.package_id()))
));
@@ -962,7 +984,9 @@ EbuildEntries::extract_package_file_version(const QualifiedPackageName & n, cons
}
bool
-EbuildEntries::pretend(const std::tr1::shared_ptr<const ERepositoryID> & id,
+EbuildEntries::pretend(
+ const std::tr1::shared_ptr<const ERepositoryID> & id,
+ const PretendAction & a,
const std::tr1::shared_ptr<const ERepositoryProfile> & p) const
{
using namespace std::tr1::placeholders;
@@ -999,6 +1023,8 @@ EbuildEntries::pretend(const std::tr1::shared_ptr<const ERepositoryID> & id,
std::tr1::shared_ptr<const FSEntrySequence> exlibsdirs(_imp->e_repository->layout()->exlibsdirs(id->name()));
+ std::tr1::shared_ptr<OutputManager> output_manager;
+
if (id->raw_myoptions_key())
{
MyOptionsRequirementsVerifier verifier(id);
@@ -1013,6 +1039,9 @@ EbuildEntries::pretend(const std::tr1::shared_ptr<const ERepositoryID> & id,
for (EAPIPhases::ConstIterator phase(phases.begin_phases()), phase_end(phases.end_phases()) ;
phase != phase_end ; ++phase)
{
+ if (! output_manager)
+ output_manager = a.options.make_output_manager()(a);
+
EbuildCommandParams command_params(make_named_values<EbuildCommandParams>(
value_for<n::builddir>(_imp->params.builddir()),
value_for<n::commands>(join(phase->begin_commands(), phase->end_commands(), " ")),
@@ -1023,6 +1052,7 @@ EbuildEntries::pretend(const std::tr1::shared_ptr<const ERepositoryID> & id,
value_for<n::environment>(_imp->params.environment()),
value_for<n::exlibsdirs>(exlibsdirs),
value_for<n::files_dir>(_imp->e_repository->layout()->package_directory(id->name()) / "files"),
+ value_for<n::maybe_output_manager>(output_manager),
value_for<n::package_id>(id),
value_for<n::portdir>(
(_imp->params.master_repositories() && ! _imp->params.master_repositories()->empty()) ?
@@ -1060,6 +1090,9 @@ EbuildEntries::pretend(const std::tr1::shared_ptr<const ERepositoryID> & id,
if (can_skip_phase(id, *phase))
continue;
+ if (! output_manager)
+ output_manager = a.options.make_output_manager()(a);
+
EbuildCommandParams command_params(make_named_values<EbuildCommandParams>(
value_for<n::builddir>(_imp->params.builddir()),
value_for<n::commands>(join(phase->begin_commands(), phase->end_commands(), " ")),
@@ -1070,6 +1103,7 @@ EbuildEntries::pretend(const std::tr1::shared_ptr<const ERepositoryID> & id,
value_for<n::environment>(_imp->params.environment()),
value_for<n::exlibsdirs>(exlibsdirs),
value_for<n::files_dir>(_imp->e_repository->layout()->package_directory(id->name()) / "files"),
+ value_for<n::maybe_output_manager>(output_manager),
value_for<n::package_id>(id),
value_for<n::portdir>(
(_imp->params.master_repositories() && ! _imp->params.master_repositories()->empty()) ?
diff --git a/paludis/repositories/e/ebuild_entries.hh b/paludis/repositories/e/ebuild_entries.hh
index f1c6e86..0868d17 100644
--- a/paludis/repositories/e/ebuild_entries.hh
+++ b/paludis/repositories/e/ebuild_entries.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 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
@@ -23,6 +23,7 @@
#include <paludis/repositories/e/e_repository_entries.hh>
#include <paludis/repositories/e/e_repository_params.hh>
#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/output_manager-fwd.hh>
/** \file
* Declaration for the EbuildEntries class.
@@ -81,19 +82,23 @@ namespace paludis
virtual std::string get_environment_variable(const std::tr1::shared_ptr<const ERepositoryID> &, const std::string & var,
const std::tr1::shared_ptr<const ERepositoryProfile> &) const;
- virtual void fetch(const std::tr1::shared_ptr<const ERepositoryID> &, const FetchActionOptions &,
+ virtual void fetch(const std::tr1::shared_ptr<const ERepositoryID> &,
+ const FetchAction &,
const std::tr1::shared_ptr<const ERepositoryProfile> &) const;
virtual void pretend_fetch(const std::tr1::shared_ptr<const ERepositoryID> &, PretendFetchAction &,
const std::tr1::shared_ptr<const ERepositoryProfile> &) const;
- virtual void install(const std::tr1::shared_ptr<const ERepositoryID> &, const InstallActionOptions &,
+ virtual void install(const std::tr1::shared_ptr<const ERepositoryID> &,
+ const InstallAction &,
const std::tr1::shared_ptr<const ERepositoryProfile> &) const;
virtual bool pretend(const std::tr1::shared_ptr<const ERepositoryID> &,
+ const PretendAction &,
const std::tr1::shared_ptr<const ERepositoryProfile> &) const;
virtual void info(const std::tr1::shared_ptr<const ERepositoryID> &,
+ const InfoAction &,
const std::tr1::shared_ptr<const ERepositoryProfile> &) const;
virtual std::string get_package_file_manifest_key(const FSEntry &, const QualifiedPackageName &) const;
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index 9a39e91..16cb3fb 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -243,6 +243,7 @@ EbuildID::need_keys_added() const
value_for<n::environment>(_imp->environment),
value_for<n::exlibsdirs>(_imp->repository->layout()->exlibsdirs(name())),
value_for<n::files_dir>(_imp->repository->layout()->package_directory(name()) / "files"),
+ value_for<n::maybe_output_manager>(make_null_shared_ptr()),
value_for<n::package_id>(shared_from_this()),
value_for<n::portdir>(
(_imp->repository->params().master_repositories() && ! _imp->repository->params().master_repositories()->empty()) ?
@@ -1058,14 +1059,16 @@ namespace
{
if (! std::tr1::static_pointer_cast<const ERepository>(id->repository())->entries()->pretend(
std::tr1::static_pointer_cast<const ERepositoryID>(id),
+ action,
std::tr1::static_pointer_cast<const ERepository>(id->repository())->profile()))
action.set_failed();
}
- void visit(InfoAction &)
+ void visit(InfoAction & action)
{
std::tr1::static_pointer_cast<const ERepository>(id->repository())->entries()->info(
std::tr1::static_pointer_cast<const ERepositoryID>(id),
+ action,
std::tr1::static_pointer_cast<const ERepository>(id->repository())->profile());
}
diff --git a/paludis/repositories/e/exndbam_repository.cc b/paludis/repositories/e/exndbam_repository.cc
index dbec255..f76d413 100644
--- a/paludis/repositories/e/exndbam_repository.cc
+++ b/paludis/repositories/e/exndbam_repository.cc
@@ -37,6 +37,7 @@
#include <paludis/util/system.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/safe_ifstream.hh>
+#include <paludis/output_manager.hh>
#include <paludis/distribution.hh>
#include <paludis/environment.hh>
#include <paludis/ndbam.hh>
@@ -47,7 +48,6 @@
#include <paludis/action.hh>
#include <paludis/literal_metadata_key.hh>
#include <tr1/functional>
-#include <iostream>
using namespace paludis;
using namespace paludis::erepository;
@@ -296,6 +296,11 @@ namespace
else
return ! b->slot_key();
}
+
+ std::tr1::shared_ptr<OutputManager> this_output_manager(const std::tr1::shared_ptr<OutputManager> & o, const Action &)
+ {
+ return o;
+ }
}
void
@@ -346,6 +351,7 @@ ExndbamRepository::merge(const MergeParams & m)
make_named_values<WriteVDBEntryParams>(
value_for<n::environment>(_imp->params.environment()),
value_for<n::environment_file>(m.environment_file()),
+ value_for<n::maybe_output_manager>(m.output_manager()),
value_for<n::output_directory>(target_ver_dir),
value_for<n::package_id>(std::tr1::static_pointer_cast<const ERepositoryID>(m.package_id()))
));
@@ -382,6 +388,7 @@ ExndbamRepository::merge(const MergeParams & m)
value_for<n::image>(m.image_dir()),
value_for<n::install_under>(FSEntry("/")),
value_for<n::options>(m.options()),
+ value_for<n::output_manager>(m.output_manager()),
value_for<n::package_id>(m.package_id()),
value_for<n::root>(installed_root_key()->value())
));
@@ -403,8 +410,13 @@ ExndbamRepository::merge(const MergeParams & m)
if (if_overwritten_id)
{
- perform_uninstall(std::tr1::static_pointer_cast<const ERepositoryID>(if_overwritten_id), true, config_protect);
+ UninstallActionOptions uo(make_named_values<UninstallActionOptions>(
+ value_for<n::config_protect>(config_protect),
+ value_for<n::make_output_manager>(std::tr1::bind(&this_output_manager, m.output_manager(), std::tr1::placeholders::_1))
+ ));
+ perform_uninstall(std::tr1::static_pointer_cast<const ERepositoryID>(if_overwritten_id), uo, true);
}
+
if (std::tr1::static_pointer_cast<const ERepositoryID>(m.package_id())
->eapi()->supported()->ebuild_phases()->ebuild_new_upgrade_phase_order())
{
@@ -414,7 +426,13 @@ ExndbamRepository::merge(const MergeParams & m)
{
std::tr1::shared_ptr<const ERepositoryID> candidate(std::tr1::static_pointer_cast<const ERepositoryID>(*it));
if (candidate != if_overwritten_id && slot_is_same(candidate, m.package_id()))
- perform_uninstall(candidate, false, "");
+ {
+ UninstallActionOptions uo(make_named_values<UninstallActionOptions>(
+ value_for<n::config_protect>(config_protect),
+ value_for<n::make_output_manager>(std::tr1::bind(&this_output_manager, m.output_manager(), std::tr1::placeholders::_1))
+ ));
+ perform_uninstall(candidate, uo, false);
+ }
}
}
@@ -427,8 +445,10 @@ ExndbamRepository::merge(const MergeParams & m)
}
void
-ExndbamRepository::perform_uninstall(const std::tr1::shared_ptr<const ERepositoryID> & id,
- bool replace, const std::string & merge_config_protect) const
+ExndbamRepository::perform_uninstall(
+ const std::tr1::shared_ptr<const ERepositoryID> & id,
+ const UninstallAction & a,
+ bool replace) const
{
Context context("When uninstalling '" + stringify(*id) + (replace ? "' for a reinstall:" : "':"));
@@ -436,6 +456,8 @@ ExndbamRepository::perform_uninstall(const std::tr1::shared_ptr<const ERepositor
throw InstallActionError("Couldn't uninstall '" + stringify(*id) +
"' because root ('" + stringify(_imp->params.root()) + "') is not a directory");
+ std::tr1::shared_ptr<OutputManager> output_manager(a.options.make_output_manager()(a));
+
FSEntry ver_dir(id->fs_location_key()->value());
std::tr1::shared_ptr<FSEntry> load_env(new FSEntry(ver_dir / "environment.bz2"));
@@ -448,7 +470,8 @@ ExndbamRepository::perform_uninstall(const std::tr1::shared_ptr<const ERepositor
{
if (can_skip_phase(id, *phase))
{
- std::cout << "--- No need to do anything for " << phase->equal_option("skipname") << " phase" << std::endl;
+ output_manager->stdout_stream() << "--- No need to do anything for " <<
+ phase->equal_option("skipname") << " phase" << std::endl;
continue;
}
@@ -477,7 +500,7 @@ ExndbamRepository::perform_uninstall(const std::tr1::shared_ptr<const ERepositor
{
}
- std::string final_config_protect(config_protect + " " + merge_config_protect);
+ std::string final_config_protect(config_protect + " " + a.options.config_protect());
/* unmerge */
NDBAMUnmerger unmerger(
@@ -487,6 +510,7 @@ ExndbamRepository::perform_uninstall(const std::tr1::shared_ptr<const ERepositor
value_for<n::contents_file>(ver_dir / "contents"),
value_for<n::environment>(_imp->params.environment()),
value_for<n::ndbam>(&_imp->ndbam),
+ value_for<n::output_manager>(output_manager),
value_for<n::package_id>(id),
value_for<n::root>(installed_root_key()->value())
));
@@ -506,6 +530,7 @@ ExndbamRepository::perform_uninstall(const std::tr1::shared_ptr<const ERepositor
value_for<n::environment>(_imp->params.environment()),
value_for<n::exlibsdirs>(make_shared_ptr(new FSEntrySequence)),
value_for<n::files_dir>(ver_dir),
+ value_for<n::maybe_output_manager>(output_manager),
value_for<n::package_id>(id),
value_for<n::portdir>(_imp->params.location()),
value_for<n::sandbox>(phase->option("sandbox")),
diff --git a/paludis/repositories/e/exndbam_repository.hh b/paludis/repositories/e/exndbam_repository.hh
index 6ea44a4..f5212ff 100644
--- a/paludis/repositories/e/exndbam_repository.hh
+++ b/paludis/repositories/e/exndbam_repository.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 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
@@ -115,8 +115,10 @@ namespace paludis
///\name For use by ExndbamID
///\{
- void perform_uninstall(const std::tr1::shared_ptr<const erepository::ERepositoryID> & id,
- bool reinstalling, const std::string & merge_config_protect) const;
+ void perform_uninstall(
+ const std::tr1::shared_ptr<const erepository::ERepositoryID> & id,
+ const UninstallAction &,
+ bool reinstalling) const;
///\}
diff --git a/paludis/repositories/e/exndbam_repository_TEST.cc b/paludis/repositories/e/exndbam_repository_TEST.cc
index 1a20613..71c81dd 100644
--- a/paludis/repositories/e/exndbam_repository_TEST.cc
+++ b/paludis/repositories/e/exndbam_repository_TEST.cc
@@ -25,6 +25,8 @@
#include <paludis/util/join.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/sequence.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/standard_output_manager.hh>
#include <paludis/action.hh>
#include <paludis/filtered_generator.hh>
#include <paludis/generator.hh>
@@ -38,6 +40,11 @@ using namespace paludis;
namespace
{
+ std::tr1::shared_ptr<OutputManager> make_standard_output_manager(const Action &)
+ {
+ return make_shared_ptr(new StandardOutputManager);
+ }
+
std::string from_keys(const std::tr1::shared_ptr<const Map<std::string, std::string> > & m,
const std::string & k)
{
@@ -122,12 +129,14 @@ namespace test_cases
InstallAction install_action(make_named_values<InstallActionOptions>(
value_for<n::destination>(exndbam_repo),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
UninstallAction uninstall_action(make_named_values<UninstallActionOptions>(
- value_for<n::config_protect>("")
+ value_for<n::config_protect>(""),
+ value_for<n::make_output_manager>(&make_standard_output_manager)
));
TEST_CHECK(exndbam_repo->package_ids(QualifiedPackageName("cat/pkg"))->empty());
diff --git a/paludis/repositories/e/fetch_visitor.cc b/paludis/repositories/e/fetch_visitor.cc
index 5c818af..53d9975 100644
--- a/paludis/repositories/e/fetch_visitor.cc
+++ b/paludis/repositories/e/fetch_visitor.cc
@@ -35,8 +35,7 @@
#include <paludis/util/join.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/make_shared_ptr.hh>
-#include <paludis/util/output_deviator.hh>
-#include <iostream>
+#include <paludis/output_manager.hh>
#include <list>
using namespace paludis;
@@ -56,7 +55,7 @@ namespace paludis
const std::string mirrors_name;
std::tr1::shared_ptr<const URILabel> default_label;
const bool safe_resume;
- const std::tr1::shared_ptr<OutputDeviant> maybe_output_deviant;
+ const std::tr1::shared_ptr<OutputManager> output_manager;
std::list<const URILabel *> labels;
@@ -70,7 +69,7 @@ namespace paludis
const std::string & m,
const std::tr1::shared_ptr<const URILabel> & n,
const bool sr,
- const std::tr1::shared_ptr<OutputDeviant> & md) :
+ const std::tr1::shared_ptr<OutputManager> & md) :
env(e),
id(i),
eapi(p),
@@ -80,7 +79,7 @@ namespace paludis
mirrors_name(m),
default_label(n),
safe_resume(sr),
- maybe_output_deviant(md)
+ output_manager(md)
{
labels.push_front(default_label.get());
}
@@ -97,7 +96,7 @@ FetchVisitor::FetchVisitor(
const std::string & m,
const std::tr1::shared_ptr<const URILabel> & n,
const bool sr,
- const std::tr1::shared_ptr<OutputDeviant> & md) :
+ const std::tr1::shared_ptr<OutputManager> & md) :
PrivateImplementationPattern<FetchVisitor>(new Implementation<FetchVisitor>(e, i, p, d, f, u, m, n, sr, md))
{
}
@@ -236,13 +235,12 @@ FetchVisitor::visit(const FetchableURISpecTree::NodeType<FetchableURIDepSpec>::T
cmd
.with_setenv("PALUDIS_USE_SAFE_RESUME", "yesplease");
- if (_imp->maybe_output_deviant)
- cmd
- .with_captured_stderr_stream(_imp->maybe_output_deviant->stderr_stream())
- .with_captured_stdout_stream(_imp->maybe_output_deviant->stdout_stream());
+ cmd
+ .with_captured_stderr_stream(&_imp->output_manager->stderr_stream())
+ .with_captured_stdout_stream(&_imp->output_manager->stdout_stream());
- (_imp->maybe_output_deviant ? *_imp->maybe_output_deviant->stdout_stream() : std::cout)
- << "Trying to fetch '" << i->first << "' to '" << i->second << "'..." << std::endl;
+ _imp->output_manager->stdout_stream() << "Trying to fetch '" << i->first << "' to '" <<
+ i->second << "'..." << std::endl;
if (0 != run_command(cmd))
destination.unlink();
diff --git a/paludis/repositories/e/fetch_visitor.hh b/paludis/repositories/e/fetch_visitor.hh
index 84013b2..a62799c 100644
--- a/paludis/repositories/e/fetch_visitor.hh
+++ b/paludis/repositories/e/fetch_visitor.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
@@ -24,7 +24,7 @@
#include <paludis/util/attributes.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/fs_entry-fwd.hh>
-#include <paludis/util/output_deviator-fwd.hh>
+#include <paludis/output_manager-fwd.hh>
#include <paludis/dep_spec.hh>
#include <paludis/spec_tree-fwd.hh>
#include <paludis/package_id-fwd.hh>
@@ -50,7 +50,7 @@ namespace paludis
const std::string & mirrors_name,
const std::tr1::shared_ptr<const URILabel> & initial_label,
const bool safe_resume,
- const std::tr1::shared_ptr<OutputDeviant> & maybe_output_deviant);
+ const std::tr1::shared_ptr<OutputManager> &);
~FetchVisitor();
diff --git a/paludis/repositories/e/fetch_visitor_TEST.cc b/paludis/repositories/e/fetch_visitor_TEST.cc
index 82e253e..41e4f9a 100644
--- a/paludis/repositories/e/fetch_visitor_TEST.cc
+++ b/paludis/repositories/e/fetch_visitor_TEST.cc
@@ -25,6 +25,7 @@
#include <paludis/environments/test/test_environment.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/standard_output_manager.hh>
#include <paludis/util/safe_ifstream.hh>
#include <paludis/package_database.hh>
#include <paludis/user_dep_spec.hh>
@@ -62,7 +63,7 @@ namespace test_cases
&env, UserPackageDepSpecOptions()), MatchPackageOptions()))]->begin(),
*eapi, FSEntry("fetch_visitor_TEST_dir/out"),
false, false, "test", make_shared_ptr(new URIListedThenMirrorsLabel("listed-then-mirrors")), false,
- make_null_shared_ptr());
+ make_shared_ptr(new StandardOutputManager));
parse_fetchable_uri("file:///" + stringify(FSEntry("fetch_visitor_TEST_dir/in/input1").realpath()), &env, id, *eapi)->root()->accept(v);
TEST_CHECK(FSEntry("fetch_visitor_TEST_dir/out/input1").is_regular_file());
diff --git a/paludis/repositories/e/pipe_command_handler.cc b/paludis/repositories/e/pipe_command_handler.cc
index 6bd0b5c..f315aca 100644
--- a/paludis/repositories/e/pipe_command_handler.cc
+++ b/paludis/repositories/e/pipe_command_handler.cc
@@ -33,6 +33,7 @@
#include <paludis/util/simple_visitor_cast.hh>
#include <paludis/util/set.hh>
#include <paludis/util/indirect_iterator.hh>
+#include <paludis/output_manager.hh>
#include <paludis/package_id.hh>
#include <paludis/environment.hh>
#include <paludis/package_database.hh>
@@ -58,7 +59,8 @@ namespace
std::string
paludis::erepository::pipe_command_handler(const Environment * const environment,
- const std::tr1::shared_ptr<const PackageID> & package_id, const std::string & s)
+ const std::tr1::shared_ptr<const PackageID> & package_id, const std::string & s,
+ const std::tr1::shared_ptr<OutputManager> & maybe_output_manager)
{
Context context("In ebuild pipe command handler for '" + s + "':");
@@ -93,7 +95,39 @@ paludis::erepository::pipe_command_handler(const Environment * const environment
{
Log::get_instance()->message("e.child.message", destringify<LogLevel>(tokens[2]), lc_context)
<< join(next(next(next(tokens.begin()))), tokens.end(), " ");
- return "O";
+ return "O0;";
+ }
+ }
+ else if (tokens[0] == "MESSAGE")
+ {
+ if (tokens.size() == 3)
+ {
+ /* don't barf on empty messages */
+ tokens.push_back(" ");
+ }
+
+ if (tokens.size() < 4)
+ {
+ Log::get_instance()->message("e.pipe_commands.message.bad", ll_warning, lc_context) << "Got bad MESSAGE pipe command";
+ return "Ebad MESSAGE command";
+ }
+ else
+ {
+ MessageType m;
+ if (tokens[2] == "einfo" || tokens[2] == "einfon" || tokens[2] == "ebegin")
+ m = mt_info;
+ else if (tokens[2] == "ewarn")
+ m = mt_warn;
+ else if (tokens[2] == "eerror")
+ m = mt_error;
+ else if (tokens[2] == "elog")
+ m = mt_log;
+ else
+ return "EUnknown message type " + tokens[2] + "";
+
+ if (maybe_output_manager)
+ maybe_output_manager->message(m, join(next(next(next(tokens.begin()))), tokens.end(), " "));
+ return "O0;";
}
}
else if (tokens[0] == "BEST_VERSION")
diff --git a/paludis/repositories/e/pipe_command_handler.hh b/paludis/repositories/e/pipe_command_handler.hh
index 446b435..abdc7c4 100644
--- a/paludis/repositories/e/pipe_command_handler.hh
+++ b/paludis/repositories/e/pipe_command_handler.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 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
@@ -22,6 +22,7 @@
#include <paludis/environment-fwd.hh>
#include <paludis/package_id-fwd.hh>
+#include <paludis/output_manager-fwd.hh>
#include <tr1/functional>
#include <string>
@@ -31,7 +32,8 @@ namespace paludis
{
std::string pipe_command_handler(const Environment * const,
const std::tr1::shared_ptr<const PackageID> &,
- const std::string & s);
+ const std::string & s,
+ const std::tr1::shared_ptr<OutputManager> & maybe_output_manager);
}
}
diff --git a/paludis/repositories/e/qa/Makefile.am b/paludis/repositories/e/qa/Makefile.am
index c70c3e7..5f23e87 100644
--- a/paludis/repositories/e/qa/Makefile.am
+++ b/paludis/repositories/e/qa/Makefile.am
@@ -138,6 +138,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_DISTRIBUTIONS_DIR="$(top_srcdir)/paludis/distributions/" \
PALUDIS_DISTRIBUTION="gentoo" \
PALUDIS_SKIP_CONFIG="yes" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
TEST_SCRIPT_DIR="$(srcdir)/" \
PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \
LD_LIBRARY_PATH="`echo $$LD_LIBRARY_PATH: | sed -e 's,^:,,'`` \
diff --git a/paludis/repositories/e/qa/manifest.cc b/paludis/repositories/e/qa/manifest.cc
index 4cfb9fa..b6ddd5a 100644
--- a/paludis/repositories/e/qa/manifest.cc
+++ b/paludis/repositories/e/qa/manifest.cc
@@ -18,7 +18,6 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <iostream>
#include "manifest.hh"
#include <paludis/qa.hh>
#include <paludis/spec_tree.hh>
diff --git a/paludis/repositories/e/vdb_merger.cc b/paludis/repositories/e/vdb_merger.cc
index 482d0ae..3acbd94 100644
--- a/paludis/repositories/e/vdb_merger.cc
+++ b/paludis/repositories/e/vdb_merger.cc
@@ -29,6 +29,7 @@
#include <paludis/util/strip.hh>
#include <paludis/util/options.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/output_manager.hh>
#include <paludis/util/safe_ofstream.hh>
#include <paludis/util/safe_ifstream.hh>
#include <paludis/hook.hh>
@@ -37,7 +38,6 @@
#include <paludis/environment.hh>
#include <paludis/package_database.hh>
#include <paludis/metadata_key.hh>
-#include <iostream>
#include <iomanip>
#include <list>
@@ -188,7 +188,7 @@ VDBMerger::on_error(bool is_check, const std::string & s)
make_check_fail();
if (is_check)
- std::cout << "." << std::endl << "!!! " << s << std::endl;
+ _imp->params.output_manager()->stdout_stream() << "." << std::endl << "!!! " << s << std::endl;
else
throw MergerError(s);
}
@@ -274,9 +274,9 @@ VDBMerger::merge()
bool
VDBMerger::check()
{
- std::cout << ">>> Checking whether we can merge to " << _imp->params.root() << " ";
+ _imp->params.output_manager()->stdout_stream() << ">>> Checking whether we can merge to " << _imp->params.root() << " ";
bool result(Merger::check());
- std::cout << std::endl;
+ _imp->params.output_manager()->stdout_stream() << std::endl;
return result;
}
@@ -286,7 +286,7 @@ VDBMerger::on_enter_dir(bool is_check, const FSEntry)
if (! is_check)
return;
- std::cout << "." << std::flush;
+ _imp->params.output_manager()->stdout_stream() << "." << std::flush;
}
void
@@ -324,7 +324,7 @@ VDBMerger::on_sym(bool is_check, const FSEntry & src, const FSEntry & dst)
void
VDBMerger::display_override(const std::string & message) const
{
- std::cout << message << std::endl;
+ _imp->params.output_manager()->stdout_stream() << message << std::endl;
}
std::string
diff --git a/paludis/repositories/e/vdb_merger.hh b/paludis/repositories/e/vdb_merger.hh
index ab694b9..880b9d5 100644
--- a/paludis/repositories/e/vdb_merger.hh
+++ b/paludis/repositories/e/vdb_merger.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
@@ -23,6 +23,7 @@
#include <paludis/merger.hh>
#include <paludis/package_id-fwd.hh>
#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/output_manager-fwd.hh>
namespace paludis
{
@@ -36,6 +37,7 @@ namespace paludis
struct environment;
struct image;
struct options;
+ struct output_manager;
struct package_id;
struct root;
}
@@ -57,6 +59,7 @@ namespace paludis
NamedValue<n::environment, Environment *> environment;
NamedValue<n::image, FSEntry> image;
NamedValue<n::options, MergerOptions> options;
+ NamedValue<n::output_manager, std::tr1::shared_ptr<OutputManager> > output_manager;
NamedValue<n::package_id, std::tr1::shared_ptr<const PackageID> > package_id;
NamedValue<n::root, FSEntry> root;
};
diff --git a/paludis/repositories/e/vdb_merger_TEST.cc b/paludis/repositories/e/vdb_merger_TEST.cc
index 6eb8647..9bcb1bb 100644
--- a/paludis/repositories/e/vdb_merger_TEST.cc
+++ b/paludis/repositories/e/vdb_merger_TEST.cc
@@ -22,7 +22,9 @@
#include <paludis/environments/test/test_environment.hh>
#include <paludis/repositories/fake/fake_repository.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/safe_ifstream.hh>
+#include <paludis/standard_output_manager.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
@@ -83,6 +85,7 @@ namespace
value_for<n::environment>(&env),
value_for<n::image>(FSEntry::cwd() / "vdb_merger_TEST_dir" / what / "image"),
value_for<n::options>(MergerOptions() + mo_rewrite_symlinks + mo_allow_empty_dirs),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::package_id>(std::tr1::shared_ptr<PackageID>()),
value_for<n::root>(root_dir)
))
diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc
index 199dc2d..e500317 100644
--- a/paludis/repositories/e/vdb_repository.cc
+++ b/paludis/repositories/e/vdb_repository.cc
@@ -69,12 +69,11 @@
#include <paludis/util/create_iterator-impl.hh>
#include <paludis/util/hashes.hh>
#include <paludis/util/make_named_values.hh>
-#include <paludis/util/safe_ofstream.hh>
+#include <paludis/output_manager.hh>
#include <paludis/util/safe_ifstream.hh>
-
+#include <paludis/util/safe_ofstream.hh>
#include <tr1/unordered_map>
#include <tr1/functional>
-#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
@@ -374,8 +373,10 @@ VDBRepositoryKeyReadError::VDBRepositoryKeyReadError(
}
void
-VDBRepository::perform_uninstall(const std::tr1::shared_ptr<const ERepositoryID> & id,
- bool reinstalling, const std::string & merge_config_protect) const
+VDBRepository::perform_uninstall(
+ const std::tr1::shared_ptr<const ERepositoryID> & id,
+ const UninstallAction & a,
+ bool reinstalling) const
{
Context context("When uninstalling '" + stringify(*id) + (reinstalling ? "' for a reinstall:" : "':"));
@@ -383,6 +384,8 @@ VDBRepository::perform_uninstall(const std::tr1::shared_ptr<const ERepositoryID>
throw InstallActionError("Couldn't uninstall '" + stringify(*id) +
"' because root ('" + stringify(_imp->params.root()) + "') is not a directory");
+ std::tr1::shared_ptr<OutputManager> output_manager(a.options.make_output_manager()(a));
+
std::string reinstalling_str(reinstalling ? "-reinstalling-" : "");
std::tr1::shared_ptr<FSEntrySequence> eclassdirs(new FSEntrySequence);
@@ -400,7 +403,7 @@ VDBRepository::perform_uninstall(const std::tr1::shared_ptr<const ERepositoryID>
{
if (can_skip_phase(id, *phase))
{
- std::cout << "--- No need to do anything for " << phase->equal_option("skipname") << " phase" << std::endl;
+ output_manager->stdout_stream() << "--- No need to do anything for " << phase->equal_option("skipname") << " phase" << std::endl;
continue;
}
@@ -429,7 +432,7 @@ VDBRepository::perform_uninstall(const std::tr1::shared_ptr<const ERepositoryID>
{
}
- std::string final_config_protect(config_protect + " " + merge_config_protect);
+ std::string final_config_protect(config_protect + " " + a.options.config_protect());
/* unmerge */
VDBUnmerger unmerger(
@@ -437,8 +440,8 @@ VDBRepository::perform_uninstall(const std::tr1::shared_ptr<const ERepositoryID>
value_for<n::config_protect>(final_config_protect),
value_for<n::config_protect_mask>(config_protect_mask),
value_for<n::contents_file>(pkg_dir / "CONTENTS"),
-
value_for<n::environment>(_imp->params.environment()),
+ value_for<n::output_manager>(output_manager),
value_for<n::package_id>(id),
value_for<n::root>(installed_root_key()->value())
));
@@ -457,6 +460,7 @@ VDBRepository::perform_uninstall(const std::tr1::shared_ptr<const ERepositoryID>
value_for<n::environment>(_imp->params.environment()),
value_for<n::exlibsdirs>(make_shared_ptr(new FSEntrySequence)),
value_for<n::files_dir>(pkg_dir),
+ value_for<n::maybe_output_manager>(output_manager),
value_for<n::package_id>(id),
value_for<n::portdir>(_imp->params.location()),
value_for<n::sandbox>(phase->option("sandbox")),
@@ -804,6 +808,11 @@ namespace
else
return ! b->slot_key();
}
+
+ std::tr1::shared_ptr<OutputManager> this_output_manager(const std::tr1::shared_ptr<OutputManager> & o, const Action &)
+ {
+ return o;
+ }
}
void
@@ -830,6 +839,7 @@ VDBRepository::merge(const MergeParams & m)
make_named_values<WriteVDBEntryParams>(
value_for<n::environment>(_imp->params.environment()),
value_for<n::environment_file>(m.environment_file()),
+ value_for<n::maybe_output_manager>(m.output_manager()),
value_for<n::output_directory>(tmp_vdb_dir),
value_for<n::package_id>(std::tr1::static_pointer_cast<const ERepositoryID>(m.package_id()))
));
@@ -868,6 +878,7 @@ VDBRepository::merge(const MergeParams & m)
value_for<n::environment>(_imp->params.environment()),
value_for<n::image>(m.image_dir()),
value_for<n::options>(m.options()),
+ value_for<n::output_manager>(m.output_manager()),
value_for<n::package_id>(m.package_id()),
value_for<n::root>(installed_root_key()->value())
));
@@ -901,7 +912,14 @@ VDBRepository::merge(const MergeParams & m)
merger.merge();
if (is_replace)
- perform_uninstall(is_replace, true, config_protect);
+ {
+ UninstallActionOptions uo(make_named_values<UninstallActionOptions>(
+ value_for<n::config_protect>(config_protect),
+ value_for<n::make_output_manager>(std::tr1::bind(&this_output_manager, m.output_manager(), std::tr1::placeholders::_1))
+ ));
+ perform_uninstall(is_replace, uo, true);
+ }
+
if (std::tr1::static_pointer_cast<const ERepositoryID>(m.package_id())
->eapi()->supported()->ebuild_phases()->ebuild_new_upgrade_phase_order())
{
@@ -911,7 +929,13 @@ VDBRepository::merge(const MergeParams & m)
{
std::tr1::shared_ptr<const ERepositoryID> candidate(std::tr1::static_pointer_cast<const ERepositoryID>(*it));
if (candidate != is_replace && slot_is_same(candidate, m.package_id()))
- perform_uninstall(candidate, false, "");
+ {
+ UninstallActionOptions uo(make_named_values<UninstallActionOptions>(
+ value_for<n::config_protect>(config_protect),
+ value_for<n::make_output_manager>(std::tr1::bind(&this_output_manager, m.output_manager(), std::tr1::placeholders::_1))
+ ));
+ perform_uninstall(candidate, uo, false);
+ }
}
}
diff --git a/paludis/repositories/e/vdb_repository.hh b/paludis/repositories/e/vdb_repository.hh
index 20a1d10..f5f0421 100644
--- a/paludis/repositories/e/vdb_repository.hh
+++ b/paludis/repositories/e/vdb_repository.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 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
@@ -119,8 +119,10 @@ namespace paludis
virtual void regenerate_cache() const;
- virtual void perform_uninstall(const std::tr1::shared_ptr<const erepository::ERepositoryID> & id,
- bool reinstalling, const std::string & merge_config_protect) const;
+ virtual void perform_uninstall(
+ const std::tr1::shared_ptr<const erepository::ERepositoryID> & id,
+ const UninstallAction &,
+ bool reinstalling) const;
/* RepositoryProvidesInterface */
diff --git a/paludis/repositories/e/vdb_repository_TEST.cc b/paludis/repositories/e/vdb_repository_TEST.cc
index b6dbf5c..8af7aec 100644
--- a/paludis/repositories/e/vdb_repository_TEST.cc
+++ b/paludis/repositories/e/vdb_repository_TEST.cc
@@ -27,6 +27,7 @@
#include <paludis/util/options.hh>
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/standard_output_manager.hh>
#include <paludis/util/safe_ifstream.hh>
#include <paludis/generator.hh>
#include <paludis/filter.hh>
@@ -50,6 +51,11 @@ using namespace paludis;
namespace
{
+ std::tr1::shared_ptr<OutputManager> make_standard_output_manager(const Action &)
+ {
+ return make_shared_ptr(new StandardOutputManager);
+ }
+
std::string from_keys(const std::tr1::shared_ptr<const Map<std::string, std::string> > & m,
const std::string & k)
{
@@ -351,16 +357,26 @@ namespace test_cases
InstallAction install_action(make_named_values<InstallActionOptions>(
value_for<n::destination>(vdb_repo),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
UninstallAction uninstall_action(make_named_values<UninstallActionOptions>(
- value_for<n::config_protect>("")
+ value_for<n::config_protect>(""),
+ value_for<n::make_output_manager>(&make_standard_output_manager)
));
- InfoAction info_action;
- ConfigAction config_action;
+ InfoActionOptions info_action_options(make_named_values<InfoActionOptions>(
+ value_for<n::make_output_manager>(&make_standard_output_manager)
+ ));
+
+ ConfigActionOptions config_action_options(make_named_values<ConfigActionOptions>(
+ value_for<n::make_output_manager>(&make_standard_output_manager)
+ ));
+
+ InfoAction info_action(info_action_options);
+ ConfigAction config_action(config_action_options);
{
TestMessageSuffix suffix("install", true);
@@ -467,16 +483,26 @@ namespace test_cases
InstallAction install_action(make_named_values<InstallActionOptions>(
value_for<n::destination>(vdb_repo),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
UninstallAction uninstall_action(make_named_values<UninstallActionOptions>(
- value_for<n::config_protect>("")
+ value_for<n::config_protect>(""),
+ value_for<n::make_output_manager>(&make_standard_output_manager)
));
- InfoAction info_action;
- ConfigAction config_action;
+ InfoActionOptions info_action_options(make_named_values<InfoActionOptions>(
+ value_for<n::make_output_manager>(&make_standard_output_manager)
+ ));
+
+ ConfigActionOptions config_action_options(make_named_values<ConfigActionOptions>(
+ value_for<n::make_output_manager>(&make_standard_output_manager)
+ ));
+
+ InfoAction info_action(info_action_options);
+ ConfigAction config_action(config_action_options);
{
TestMessageSuffix suffix("vars", true);
@@ -583,12 +609,14 @@ namespace test_cases
InstallAction install_action(make_named_values<InstallActionOptions>(
value_for<n::destination>(vdb_repo),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
UninstallAction uninstall_action(make_named_values<UninstallActionOptions>(
- value_for<n::config_protect>("")
+ value_for<n::config_protect>(""),
+ value_for<n::make_output_manager>(&make_standard_output_manager)
));
{
@@ -979,12 +1007,14 @@ namespace test_cases
InstallAction install_action(make_named_values<InstallActionOptions>(
value_for<n::destination>(vdb_repo),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
UninstallAction uninstall_action(make_named_values<UninstallActionOptions>(
- value_for<n::config_protect>("")
+ value_for<n::config_protect>(""),
+ value_for<n::make_output_manager>(&make_standard_output_manager)
));
TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\n");
@@ -1216,6 +1246,7 @@ namespace test_cases
InstallAction install_action(make_named_values<InstallActionOptions>(
value_for<n::destination>(vdb_repo),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
@@ -1307,12 +1338,14 @@ namespace test_cases
InstallAction install_action(make_named_values<InstallActionOptions>(
value_for<n::destination>(vdb_repo),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
UninstallAction uninstall_action(make_named_values<UninstallActionOptions>(
- value_for<n::config_protect>("")
+ value_for<n::config_protect>(""),
+ value_for<n::make_output_manager>(&make_standard_output_manager)
));
TEST_CHECK(vdb_repo->package_ids(QualifiedPackageName("cat/pkg"))->empty());
diff --git a/paludis/repositories/e/vdb_unmerger.cc b/paludis/repositories/e/vdb_unmerger.cc
index b7bedd0..4e87f47 100644
--- a/paludis/repositories/e/vdb_unmerger.cc
+++ b/paludis/repositories/e/vdb_unmerger.cc
@@ -39,12 +39,12 @@ using namespace paludis;
#include <paludis/util/tokeniser.hh>
#include <paludis/util/strip.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/output_manager.hh>
#include <paludis/util/safe_ifstream.hh>
#include <list>
#include <map>
#include <vector>
-#include <iostream>
namespace paludis
{
@@ -341,7 +341,7 @@ VDBUnmerger::check_dir(const FSEntry & f, const std::tr1::shared_ptr<ExtraInfo>
void
VDBUnmerger::display(const std::string & message) const
{
- std::cout << message << std::endl;
+ _imp->options.output_manager()->stdout_stream() << message << std::endl;
}
VDBUnmergerError::VDBUnmergerError(const std::string & s) throw () :
diff --git a/paludis/repositories/e/vdb_unmerger.hh b/paludis/repositories/e/vdb_unmerger.hh
index e02c6f3..d09aa97 100644
--- a/paludis/repositories/e/vdb_unmerger.hh
+++ b/paludis/repositories/e/vdb_unmerger.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
* Copyright (c) 2007 Piotr Jaroszyński
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -36,6 +36,7 @@ namespace paludis
struct config_protect_mask;
struct contents_file;
struct environment;
+ struct output_manager;
struct package_id;
struct root;
}
@@ -53,6 +54,7 @@ namespace paludis
NamedValue<n::config_protect_mask, std::string> config_protect_mask;
NamedValue<n::contents_file, FSEntry> contents_file;
NamedValue<n::environment, Environment *> environment;
+ NamedValue<n::output_manager, std::tr1::shared_ptr<OutputManager> > output_manager;
NamedValue<n::package_id, std::tr1::shared_ptr<const PackageID> > package_id;
NamedValue<n::root, FSEntry> root;
};
diff --git a/paludis/repositories/e/vdb_unmerger_TEST.cc b/paludis/repositories/e/vdb_unmerger_TEST.cc
index ac6a19e..68cb763 100644
--- a/paludis/repositories/e/vdb_unmerger_TEST.cc
+++ b/paludis/repositories/e/vdb_unmerger_TEST.cc
@@ -21,6 +21,8 @@
#include <paludis/environments/test/test_environment.hh>
#include <paludis/repositories/fake/fake_repository.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/standard_output_manager.hh>
+#include <paludis/util/make_shared_ptr.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
@@ -72,6 +74,7 @@ namespace
value_for<n::config_protect_mask>("/protected_dir/unprotected_file /protected_dir/unprotected_dir"),
value_for<n::contents_file>("vdb_unmerger_TEST_dir/CONTENTS/" + what),
value_for<n::environment>(&env),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
value_for<n::package_id>(std::tr1::shared_ptr<PackageID>()),
value_for<n::root>(root_dir)
))
diff --git a/paludis/repositories/fake/Makefile.am b/paludis/repositories/fake/Makefile.am
index 25514b6..77d6c1b 100644
--- a/paludis/repositories/fake/Makefile.am
+++ b/paludis/repositories/fake/Makefile.am
@@ -16,6 +16,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_DISTRIBUTION="gentoo" \
PALUDIS_OPTIONS="" \
PALUDIS_SKIP_CONFIG="yes" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
TEST_SCRIPT_DIR="$(srcdir)/" \
PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \
LD_LIBRARY_PATH="`echo $$LD_LIBRARY_PATH: | sed -e 's,^:,,'`` \
diff --git a/paludis/repositories/gems/Makefile.am b/paludis/repositories/gems/Makefile.am
index e759f68..ea27f9b 100644
--- a/paludis/repositories/gems/Makefile.am
+++ b/paludis/repositories/gems/Makefile.am
@@ -124,6 +124,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_DISTRIBUTION="gentoo" \
PALUDIS_OPTIONS="" \
PALUDIS_SKIP_CONFIG="yes" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
TEST_SCRIPT_DIR="$(srcdir)/" \
PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \
LD_LIBRARY_PATH="`echo $$LD_LIBRARY_PATH: | sed -e 's,^:,,'`` \
diff --git a/paludis/repositories/unavailable/Makefile.am b/paludis/repositories/unavailable/Makefile.am
index b03fe69..0775a29 100644
--- a/paludis/repositories/unavailable/Makefile.am
+++ b/paludis/repositories/unavailable/Makefile.am
@@ -71,6 +71,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_FETCHERS_DIR="$(top_srcdir)/paludis/fetchers/" \
PALUDIS_OPTIONS="" \
PALUDIS_SKIP_CONFIG="yes" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
TEST_SCRIPT_DIR="$(srcdir)/" \
PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \
PALUDIS_NO_CHOWN="yes" \
diff --git a/paludis/repositories/unavailable/unavailable_repository.cc b/paludis/repositories/unavailable/unavailable_repository.cc
index 37280b6..ed26457 100644
--- a/paludis/repositories/unavailable/unavailable_repository.cc
+++ b/paludis/repositories/unavailable/unavailable_repository.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 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
@@ -254,7 +254,7 @@ UnavailableRepository::some_ids_might_support_action(const SupportsActionTestBas
}
bool
-UnavailableRepository::sync(const std::tr1::shared_ptr<const OutputDeviant> & output_deviant) const
+UnavailableRepository::sync(const std::tr1::shared_ptr<OutputManager> & output_manager) const
{
Context context("When syncing repository '" + stringify(name()) + "':");
@@ -276,8 +276,7 @@ UnavailableRepository::sync(const std::tr1::shared_ptr<const OutputDeviant> & ou
SyncOptions opts(make_named_values<SyncOptions>(
value_for<n::filter_file>(FSEntry("/dev/null")),
value_for<n::options>(_imp->params.sync_options()),
- value_for<n::output_deviant>(output_deviant),
- value_for<n::output_prefix>("sync " + stringify(name()) + "> ")
+ value_for<n::output_manager>(output_manager)
));
try
{
diff --git a/paludis/repositories/unavailable/unavailable_repository.hh b/paludis/repositories/unavailable/unavailable_repository.hh
index eb40d33..68a15fb 100644
--- a/paludis/repositories/unavailable/unavailable_repository.hh
+++ b/paludis/repositories/unavailable/unavailable_repository.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 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
@@ -92,7 +92,7 @@ namespace paludis
virtual void invalidate();
virtual void invalidate_masks();
- virtual bool sync(const std::tr1::shared_ptr<const OutputDeviant> &) const;
+ virtual bool sync(const std::tr1::shared_ptr<OutputManager> &) const;
///\name RepositoryFactory functions
///\{
diff --git a/paludis/repositories/unpackaged/Makefile.am b/paludis/repositories/unpackaged/Makefile.am
index 8688874..42904db 100644
--- a/paludis/repositories/unpackaged/Makefile.am
+++ b/paludis/repositories/unpackaged/Makefile.am
@@ -110,6 +110,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_DISTRIBUTION="gentoo" \
PALUDIS_FETCHERS_DIR="$(top_srcdir)/paludis/fetchers/" \
PALUDIS_SKIP_CONFIG="yes" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
TEST_SCRIPT_DIR="$(srcdir)/" \
PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \
PALUDIS_NO_CHOWN="yes" \
diff --git a/paludis/repositories/unpackaged/installed_id.cc b/paludis/repositories/unpackaged/installed_id.cc
index 7fe0e1d..adb5a56 100644
--- a/paludis/repositories/unpackaged/installed_id.cc
+++ b/paludis/repositories/unpackaged/installed_id.cc
@@ -34,6 +34,7 @@
#include <paludis/util/make_named_values.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/safe_ifstream.hh>
+#include <paludis/output_manager.hh>
#include <paludis/name.hh>
#include <paludis/version_spec.hh>
#include <paludis/package_database.hh>
@@ -761,9 +762,11 @@ namespace
{
}
- void visit(UninstallAction &)
+ void visit(UninstallAction & a)
{
- id->uninstall(false);
+ std::tr1::shared_ptr<OutputManager> output_manager(a.options.make_output_manager()(a));
+ id->uninstall(false, output_manager);
+ output_manager->succeeded();
}
};
}
@@ -808,7 +811,7 @@ InstalledUnpackagedID::extra_hash_value() const
}
void
-InstalledUnpackagedID::uninstall(const bool replace) const
+InstalledUnpackagedID::uninstall(const bool replace, const std::tr1::shared_ptr<OutputManager> & output_manager) const
{
Context context("When uninstalling '" + stringify(*this) + "':");
@@ -838,6 +841,7 @@ InstalledUnpackagedID::uninstall(const bool replace) const
value_for<n::contents_file>(ver_dir / "contents"),
value_for<n::environment>(_imp->env),
value_for<n::ndbam>(_imp->ndbam),
+ value_for<n::output_manager>(output_manager),
value_for<n::package_id>(shared_from_this()),
value_for<n::root>(_imp->root)
));
diff --git a/paludis/repositories/unpackaged/installed_id.hh b/paludis/repositories/unpackaged/installed_id.hh
index a62bcdd..f70c16e 100644
--- a/paludis/repositories/unpackaged/installed_id.hh
+++ b/paludis/repositories/unpackaged/installed_id.hh
@@ -25,6 +25,7 @@
#include <paludis/action-fwd.hh>
#include <paludis/util/fs_entry-fwd.hh>
#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/output_manager-fwd.hh>
#include <paludis/ndbam-fwd.hh>
#include <tr1/memory>
@@ -87,7 +88,7 @@ namespace paludis
virtual std::size_t extra_hash_value() const
PALUDIS_ATTRIBUTE((warn_unused_result));
- void uninstall(const bool replace) const;
+ void uninstall(const bool replace, const std::tr1::shared_ptr<OutputManager> & output_manager) const;
};
}
}
diff --git a/paludis/repositories/unpackaged/installed_repository.cc b/paludis/repositories/unpackaged/installed_repository.cc
index 84c8333..f8be695 100644
--- a/paludis/repositories/unpackaged/installed_repository.cc
+++ b/paludis/repositories/unpackaged/installed_repository.cc
@@ -356,6 +356,7 @@ InstalledUnpackagedRepository::merge(const MergeParams & m)
value_for<n::image>(m.image_dir()),
value_for<n::install_under>(install_under),
value_for<n::options>(MergerOptions() + mo_rewrite_symlinks + mo_allow_empty_dirs),
+ value_for<n::output_manager>(m.output_manager()),
value_for<n::package_id>(m.package_id()),
value_for<n::root>(installed_root_key()->value())
));
@@ -374,7 +375,7 @@ InstalledUnpackagedRepository::merge(const MergeParams & m)
if (if_overwritten_id)
{
- std::tr1::static_pointer_cast<const InstalledUnpackagedID>(if_overwritten_id)->uninstall(true);
+ std::tr1::static_pointer_cast<const InstalledUnpackagedID>(if_overwritten_id)->uninstall(true, m.output_manager());
}
}
diff --git a/paludis/repositories/unpackaged/installed_repository_TEST.cc b/paludis/repositories/unpackaged/installed_repository_TEST.cc
index d98b450..649e0de 100644
--- a/paludis/repositories/unpackaged/installed_repository_TEST.cc
+++ b/paludis/repositories/unpackaged/installed_repository_TEST.cc
@@ -33,6 +33,7 @@
#include <paludis/util/join.hh>
#include <paludis/util/options.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/standard_output_manager.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
#include <algorithm>
@@ -43,6 +44,11 @@ using namespace paludis;
namespace
{
+ std::tr1::shared_ptr<OutputManager> make_standard_output_manager(const Action &)
+ {
+ return make_shared_ptr(new StandardOutputManager);
+ }
+
struct ContentsDumper
{
std::stringstream s;
@@ -263,7 +269,8 @@ namespace test_cases
const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::All())]->begin());
UninstallAction action(make_named_values<UninstallActionOptions>(
- value_for<n::config_protect>("")
+ value_for<n::config_protect>(""),
+ value_for<n::make_output_manager>(&make_standard_output_manager)
));
id->perform_action(action);
@@ -314,7 +321,8 @@ namespace test_cases
&env, UserPackageDepSpecOptions()), MatchPackageOptions()))]->begin());
UninstallAction action(make_named_values<UninstallActionOptions>(
- value_for<n::config_protect>("")
+ value_for<n::config_protect>(""),
+ value_for<n::make_output_manager>(&make_standard_output_manager)
));
id->perform_action(action);
@@ -398,6 +406,7 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::destination>(repo),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
@@ -453,6 +462,7 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::destination>(repo),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
@@ -511,6 +521,7 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::destination>(repo),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
@@ -552,7 +563,8 @@ namespace test_cases
}
UninstallAction action(make_named_values<UninstallActionOptions>(
- value_for<n::config_protect>("")
+ value_for<n::config_protect>(""),
+ value_for<n::make_output_manager>(&make_standard_output_manager)
));
(*env[selection::RequireExactlyOne(generator::Matches(
parse_user_package_dep_spec("cat/pkg4a",
@@ -594,7 +606,8 @@ namespace test_cases
}
UninstallAction action(make_named_values<UninstallActionOptions>(
- value_for<n::config_protect>("")
+ value_for<n::config_protect>(""),
+ value_for<n::make_output_manager>(&make_standard_output_manager)
));
(*env[selection::RequireExactlyOne(generator::Matches(
parse_user_package_dep_spec("cat/pkg4b",
diff --git a/paludis/repositories/unpackaged/unpackaged_id.cc b/paludis/repositories/unpackaged/unpackaged_id.cc
index 0564621..64468b3 100644
--- a/paludis/repositories/unpackaged/unpackaged_id.cc
+++ b/paludis/repositories/unpackaged/unpackaged_id.cc
@@ -30,6 +30,7 @@
#include <paludis/util/log.hh>
#include <paludis/util/hashes.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/output_manager.hh>
#include <paludis/name.hh>
#include <paludis/version_spec.hh>
#include <paludis/package_database.hh>
@@ -295,6 +296,8 @@ UnpackagedID::perform_action(Action & action) const
+ "' 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 libdir("lib");
FSEntry root(install_action->options.destination()->installed_root_key() ?
stringify(install_action->options.destination()->installed_root_key()->value()) : "/");
@@ -319,6 +322,7 @@ UnpackagedID::perform_action(Action & action) const
UnpackagedStripper stripper(make_named_values<UnpackagedStripperOptions>(
value_for<n::debug_dir>(fs_location_key()->value() / "usr" / libdir / "debug"),
value_for<n::image_dir>(fs_location_key()->value()),
+ value_for<n::output_manager>(output_manager),
value_for<n::package_id>(shared_from_this()),
value_for<n::split>(split_choice && split_choice->enabled()),
value_for<n::strip>(strip_choice && strip_choice->enabled())
@@ -347,6 +351,7 @@ UnpackagedID::perform_action(Action & action) const
value_for<n::environment_file>(FSEntry("/dev/null")),
value_for<n::image_dir>(fs_location_key()->value()),
value_for<n::options>(MergerOptions() + mo_rewrite_symlinks + mo_allow_empty_dirs),
+ value_for<n::output_manager>(output_manager),
value_for<n::package_id>(shared_from_this()),
value_for<n::used_this_for_config_protect>(install_action->options.used_this_for_config_protect())
));
@@ -362,6 +367,8 @@ UnpackagedID::perform_action(Action & action) const
case last_wp:
throw InternalError(PALUDIS_HERE, "bad WantPhase");
}
+
+ output_manager->succeeded();
}
void
diff --git a/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc b/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc
index 46913ab..c5c02cd 100644
--- a/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc
+++ b/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc
@@ -33,6 +33,7 @@
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/standard_output_manager.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
@@ -41,6 +42,11 @@ using namespace paludis;
namespace
{
+ std::tr1::shared_ptr<OutputManager> make_standard_output_manager(const Action &)
+ {
+ return make_shared_ptr(new StandardOutputManager);
+ }
+
void dummy_used_this_for_config_protect(const std::string &)
{
}
@@ -230,6 +236,7 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::destination>(installed_repo),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
@@ -284,6 +291,7 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::destination>(installed_repo),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
diff --git a/paludis/repositories/unpackaged/unpackaged_stripper.cc b/paludis/repositories/unpackaged/unpackaged_stripper.cc
index 29b89e3..ccfe4a7 100644
--- a/paludis/repositories/unpackaged/unpackaged_stripper.cc
+++ b/paludis/repositories/unpackaged/unpackaged_stripper.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 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
@@ -21,7 +21,8 @@
#include <paludis/util/fs_entry.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/make_named_values.hh>
-#include <iostream>
+#include <paludis/output_manager.hh>
+#include <ostream>
using namespace paludis;
using namespace paludis::unpackaged_repositories;
@@ -59,20 +60,20 @@ UnpackagedStripper::~UnpackagedStripper()
void
UnpackagedStripper::on_strip(const FSEntry & f)
{
- std::cout << "str " << f.strip_leading(_imp->options.image_dir()) << std::endl;
+ _imp->options.output_manager()->stdout_stream() << "str " << f.strip_leading(_imp->options.image_dir()) << std::endl;
}
void
UnpackagedStripper::on_split(const FSEntry & f, const FSEntry & g)
{
- std::cout << "spl " << f.strip_leading(_imp->options.image_dir()) <<
+ _imp->options.output_manager()->stdout_stream() << "spl " << f.strip_leading(_imp->options.image_dir()) <<
" -> " << g.strip_leading(_imp->options.image_dir()) << std::endl;
}
void
UnpackagedStripper::on_unknown(const FSEntry & f)
{
- std::cout << "--- " << f.strip_leading(_imp->options.image_dir()) << std::endl;
+ _imp->options.output_manager()->stdout_stream() << "--- " << f.strip_leading(_imp->options.image_dir()) << std::endl;
}
void
@@ -88,7 +89,7 @@ UnpackagedStripper::on_leave_dir(const FSEntry &)
void
UnpackagedStripper::strip()
{
- std::cout << ">>> Stripping inside " << _imp->options.image_dir() << std::endl;
+ _imp->options.output_manager()->stdout_stream() << ">>> Stripping inside " << _imp->options.image_dir() << std::endl;
Stripper::strip();
}
diff --git a/paludis/repositories/unpackaged/unpackaged_stripper.hh b/paludis/repositories/unpackaged/unpackaged_stripper.hh
index 9d32c51..4d289e2 100644
--- a/paludis/repositories/unpackaged/unpackaged_stripper.hh
+++ b/paludis/repositories/unpackaged/unpackaged_stripper.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 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
@@ -22,6 +22,7 @@
#include <paludis/stripper.hh>
#include <paludis/package_id-fwd.hh>
+#include <paludis/output_manager-fwd.hh>
#include <tr1/memory>
namespace paludis
@@ -30,6 +31,7 @@ namespace paludis
{
struct debug_dir;
struct image_dir;
+ struct output_manager;
struct package_id;
struct split;
struct strip;
@@ -41,6 +43,7 @@ namespace paludis
{
NamedValue<n::debug_dir, FSEntry> debug_dir;
NamedValue<n::image_dir, FSEntry> image_dir;
+ NamedValue<n::output_manager, std::tr1::shared_ptr<OutputManager> > output_manager;
NamedValue<n::package_id, std::tr1::shared_ptr<const PackageID> > package_id;
NamedValue<n::split, bool> split;
NamedValue<n::strip, bool> strip;
diff --git a/paludis/repositories/unwritten/Makefile.am b/paludis/repositories/unwritten/Makefile.am
index 1e8a674..1cf4e58 100644
--- a/paludis/repositories/unwritten/Makefile.am
+++ b/paludis/repositories/unwritten/Makefile.am
@@ -70,6 +70,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_FETCHERS_DIR="$(top_srcdir)/paludis/fetchers/" \
PALUDIS_OPTIONS="" \
PALUDIS_SKIP_CONFIG="yes" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.tests_output`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
TEST_SCRIPT_DIR="$(srcdir)/" \
PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \
PALUDIS_NO_CHOWN="yes" \
diff --git a/paludis/repositories/unwritten/unwritten_repository.cc b/paludis/repositories/unwritten/unwritten_repository.cc
index 86a7170..4eed1d9 100644
--- a/paludis/repositories/unwritten/unwritten_repository.cc
+++ b/paludis/repositories/unwritten/unwritten_repository.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 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
@@ -254,7 +254,7 @@ UnwrittenRepository::some_ids_might_support_action(const SupportsActionTestBase
}
bool
-UnwrittenRepository::sync(const std::tr1::shared_ptr<const OutputDeviant> & output_deviant) const
+UnwrittenRepository::sync(const std::tr1::shared_ptr<OutputManager> & output_manager) const
{
Context context("When syncing repository '" + stringify(name()) + "':");
@@ -276,8 +276,7 @@ UnwrittenRepository::sync(const std::tr1::shared_ptr<const OutputDeviant> & outp
SyncOptions opts(make_named_values<SyncOptions>(
value_for<n::filter_file>(FSEntry("/dev/null")),
value_for<n::options>(_imp->params.sync_options()),
- value_for<n::output_deviant>(output_deviant),
- value_for<n::output_prefix>("sync " + stringify(name()) + "> ")
+ value_for<n::output_manager>(output_manager)
));
try
{
diff --git a/paludis/repositories/unwritten/unwritten_repository.hh b/paludis/repositories/unwritten/unwritten_repository.hh
index a2a3e93..f61a687 100644
--- a/paludis/repositories/unwritten/unwritten_repository.hh
+++ b/paludis/repositories/unwritten/unwritten_repository.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 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
@@ -91,7 +91,7 @@ namespace paludis
virtual void invalidate();
virtual void invalidate_masks();
- virtual bool sync(const std::tr1::shared_ptr<const OutputDeviant> & output_deviant) const;
+ virtual bool sync(const std::tr1::shared_ptr<OutputManager> & output_manager) const;
///\name RepositoryFactory functions
///\{
diff --git a/paludis/repositories/virtuals/Makefile.am b/paludis/repositories/virtuals/Makefile.am
index a7fd2e2..fedd149 100644
--- a/paludis/repositories/virtuals/Makefile.am
+++ b/paludis/repositories/virtuals/Makefile.am
@@ -59,6 +59,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_DISTRIBUTION="gentoo" \
PALUDIS_OPTIONS="" \
PALUDIS_SKIP_CONFIG="yes" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
TEST_SCRIPT_DIR="$(srcdir)/" \
PALUDIS_REPOSITORY_SO_DIR="$(top_builddir)/paludis/repositories" \
LD_LIBRARY_PATH="`echo $$LD_LIBRARY_PATH: | sed -e 's,^:,,'`` \
diff --git a/paludis/repository.hh b/paludis/repository.hh
index e225e3d..9ccd40f 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -33,7 +33,7 @@
#include <paludis/util/wrapped_forward_iterator-fwd.hh>
#include <paludis/util/options.hh>
#include <paludis/util/named_value.hh>
-#include <paludis/util/output_deviator-fwd.hh>
+#include <paludis/output_manager-fwd.hh>
#include <paludis/version_spec.hh>
#include <paludis/metadata_key-fwd.hh>
#include <paludis/metadata_key_holder.hh>
@@ -66,6 +66,7 @@ namespace paludis
struct manifest_interface;
struct mirrors_interface;
struct options;
+ struct output_manager;
struct package_id;
struct path;
struct profile;
@@ -160,6 +161,7 @@ namespace paludis
NamedValue<n::environment_file, FSEntry> environment_file;
NamedValue<n::image_dir, FSEntry> image_dir;
NamedValue<n::options, MergerOptions> options;
+ NamedValue<n::output_manager, std::tr1::shared_ptr<OutputManager> > output_manager;
NamedValue<n::package_id, std::tr1::shared_ptr<const PackageID> > package_id;
NamedValue<n::used_this_for_config_protect, std::tr1::function<void (const std::string &)> > used_this_for_config_protect;
};
@@ -426,10 +428,9 @@ namespace paludis
/**
* Sync, if necessary.
*
- * \param output_deviant May be an empty pointer, for no deviation.
* \return True if we synced successfully, false if we skipped sync.
*/
- virtual bool sync(const std::tr1::shared_ptr<const OutputDeviant> & output_deviant) const = 0;
+ virtual bool sync(const std::tr1::shared_ptr<OutputManager> &) const = 0;
///\}
diff --git a/paludis/sohooks_TEST.cc b/paludis/sohooks_TEST.cc
index 3e65ec6..e8f981f 100644
--- a/paludis/sohooks_TEST.cc
+++ b/paludis/sohooks_TEST.cc
@@ -24,7 +24,6 @@
#include <paludis/util/stringify.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/safe_ofstream.hh>
-#include <iostream>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
diff --git a/paludis/standard_output_manager-fwd.hh b/paludis/standard_output_manager-fwd.hh
new file mode 100644
index 0000000..b85c14d
--- /dev/null
+++ b/paludis/standard_output_manager-fwd.hh
@@ -0,0 +1,28 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_STANDARD_OUTPUT_MANAGER_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_STANDARD_OUTPUT_MANAGER_FWD_HH 1
+
+namespace paludis
+{
+ class StandardOutputManager;
+}
+
+#endif
diff --git a/paludis/standard_output_manager.cc b/paludis/standard_output_manager.cc
new file mode 100644
index 0000000..881ffdd
--- /dev/null
+++ b/paludis/standard_output_manager.cc
@@ -0,0 +1,73 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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 <paludis/standard_output_manager.hh>
+#include <paludis/util/set.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <iostream>
+
+using namespace paludis;
+
+StandardOutputManager::StandardOutputManager()
+{
+}
+
+StandardOutputManager::~StandardOutputManager()
+{
+}
+
+std::ostream &
+StandardOutputManager::stdout_stream()
+{
+ return std::cout;
+}
+
+std::ostream &
+StandardOutputManager::stderr_stream()
+{
+ return std::cerr;
+}
+
+void
+StandardOutputManager::succeeded()
+{
+}
+
+void
+StandardOutputManager::message(const MessageType, const std::string &)
+{
+}
+
+const std::tr1::shared_ptr<const Set<std::string> >
+StandardOutputManager::factory_managers()
+{
+ std::tr1::shared_ptr<Set<std::string> > result(new Set<std::string>);
+ result->insert("standard");
+ return result;
+}
+
+const std::tr1::shared_ptr<OutputManager>
+StandardOutputManager::factory_create(
+ const OutputManagerFactory::KeyFunction &,
+ const OutputManagerFactory::CreateChildFunction &,
+ const OutputManagerFactory::ReplaceVarsFunc &)
+{
+ return make_shared_ptr(new StandardOutputManager);
+}
+
diff --git a/paludis/standard_output_manager.hh b/paludis/standard_output_manager.hh
new file mode 100644
index 0000000..5d2cf46
--- /dev/null
+++ b/paludis/standard_output_manager.hh
@@ -0,0 +1,56 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_STANDARD_OUTPUT_MANAGER_HH
+#define PALUDIS_GUARD_PALUDIS_STANDARD_OUTPUT_MANAGER_HH 1
+
+#include <paludis/standard_output_manager-fwd.hh>
+#include <paludis/util/set-fwd.hh>
+#include <paludis/output_manager.hh>
+#include <paludis/output_manager_factory.hh>
+#include <tr1/memory>
+#include <tr1/functional>
+
+namespace paludis
+{
+ class PALUDIS_VISIBLE StandardOutputManager :
+ public OutputManager
+ {
+ public:
+ StandardOutputManager();
+ ~StandardOutputManager();
+
+ virtual std::ostream & stdout_stream() PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual std::ostream & stderr_stream() PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual void succeeded();
+ virtual void message(const MessageType, const std::string &);
+
+ static const std::tr1::shared_ptr<const Set<std::string> > factory_managers()
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ static const std::tr1::shared_ptr<OutputManager> factory_create(
+ const OutputManagerFactory::KeyFunction &,
+ const OutputManagerFactory::CreateChildFunction &,
+ const OutputManagerFactory::ReplaceVarsFunc &)
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+}
+
+#endif
diff --git a/paludis/syncer.cc b/paludis/syncer.cc
index 22935c8..cf8e914 100644
--- a/paludis/syncer.cc
+++ b/paludis/syncer.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
* Copyright (c) 2006 Stephen Klimaszewski
* Copyright (c) 2007 David Leverton
*
@@ -28,7 +28,7 @@
#include <paludis/util/join.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/sequence.hh>
-#include <paludis/util/output_deviator.hh>
+#include <paludis/output_manager.hh>
#include <list>
using namespace paludis;
@@ -99,15 +99,9 @@ DefaultSyncer::sync(const SyncOptions & opts) const
.with_setenv("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis"))
.with_setenv("PALUDIS_SYNC_FILTER_FILE", stringify(opts.filter_file())));
- if (opts.output_deviant())
- cmd
- .with_captured_stderr_stream(opts.output_deviant()->stderr_stream())
- .with_captured_stdout_stream(opts.output_deviant()->stdout_stream());
- else if (! opts.output_prefix().empty())
- cmd
- .with_stdout_prefix(opts.output_prefix())
- .with_stderr_prefix(opts.output_prefix())
- .with_prefix_blank_lines();
+ cmd
+ .with_captured_stderr_stream(&opts.output_manager()->stderr_stream())
+ .with_captured_stdout_stream(&opts.output_manager()->stdout_stream());
if (run_command(cmd))
throw SyncFailedError(_local, _remote);
diff --git a/paludis/syncer.hh b/paludis/syncer.hh
index 2bf3a9c..5ce7ecf 100644
--- a/paludis/syncer.hh
+++ b/paludis/syncer.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 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
@@ -21,6 +21,7 @@
#define PALUDIS_GUARD_PALUDIS_SYNCER_HH 1
#include <paludis/util/exception.hh>
+#include <paludis/output_manager-fwd.hh>
#include <paludis/repository.hh>
#include <string>
@@ -43,8 +44,7 @@ namespace paludis
struct filter_file;
struct local;
struct options;
- struct output_deviant;
- struct output_prefix;
+ struct output_manager;
struct remote;
}
@@ -61,12 +61,9 @@ namespace paludis
NamedValue<n::options, std::string> options;
/**
- * May be a zero pointer.
- * \since 0.32
+ * \since 0.36
*/
- NamedValue<n::output_deviant, std::tr1::shared_ptr<const OutputDeviant> > output_deviant;
-
- NamedValue<n::output_prefix, std::string> output_prefix;
+ NamedValue<n::output_manager, std::tr1::shared_ptr<OutputManager> > output_manager;
};
/**
diff --git a/paludis/tee_output_manager-fwd.hh b/paludis/tee_output_manager-fwd.hh
new file mode 100644
index 0000000..a2af471
--- /dev/null
+++ b/paludis/tee_output_manager-fwd.hh
@@ -0,0 +1,34 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_TEE_OUTPUT_MANAGER_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_TEE_OUTPUT_MANAGER_FWD_HH 1
+
+#include <paludis/util/sequence-fwd.hh>
+#include <paludis/output_manager-fwd.hh>
+#include <tr1/memory>
+
+namespace paludis
+{
+ class TeeOutputManager;
+
+ typedef Sequence<std::tr1::shared_ptr<OutputManager> > OutputManagerSequence;
+}
+
+#endif
diff --git a/paludis/tee_output_manager.cc b/paludis/tee_output_manager.cc
new file mode 100644
index 0000000..167c11c
--- /dev/null
+++ b/paludis/tee_output_manager.cc
@@ -0,0 +1,122 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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 <paludis/tee_output_manager.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/tee_output_stream.hh>
+#include <paludis/util/sequence-impl.hh>
+#include <paludis/util/set.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/tokeniser.hh>
+#include <vector>
+
+using namespace paludis;
+
+namespace paludis
+{
+ template <>
+ struct Implementation<TeeOutputManager>
+ {
+ const std::tr1::shared_ptr<const Sequence<std::tr1::shared_ptr<OutputManager> > > streams;
+ TeeOutputStream stdout_stream;
+ TeeOutputStream stderr_stream;
+
+ Implementation(
+ const std::tr1::shared_ptr<const Sequence<std::tr1::shared_ptr<OutputManager> > > & s) :
+ streams(s)
+ {
+ }
+ };
+}
+
+TeeOutputManager::TeeOutputManager(
+ const std::tr1::shared_ptr<const OutputManagerSequence> & s) :
+ PrivateImplementationPattern<TeeOutputManager>(new Implementation<TeeOutputManager>(s))
+{
+ for (OutputManagerSequence::ConstIterator i(s->begin()), i_end(s->end()) ;
+ i != i_end ; ++i)
+ {
+ _imp->stdout_stream.add_stream(&(*i)->stdout_stream());
+ _imp->stderr_stream.add_stream(&(*i)->stderr_stream());
+ }
+}
+
+TeeOutputManager::~TeeOutputManager()
+{
+}
+
+std::ostream &
+TeeOutputManager::stdout_stream()
+{
+ return _imp->stdout_stream;
+}
+
+std::ostream &
+TeeOutputManager::stderr_stream()
+{
+ return _imp->stderr_stream;
+}
+
+void
+TeeOutputManager::succeeded()
+{
+ for (OutputManagerSequence::ConstIterator i(_imp->streams->begin()), i_end(_imp->streams->end()) ;
+ i != i_end ; ++i)
+ (*i)->succeeded();
+}
+
+void
+TeeOutputManager::message(const MessageType t, const std::string & s)
+{
+ for (OutputManagerSequence::ConstIterator i(_imp->streams->begin()), i_end(_imp->streams->end()) ;
+ i != i_end ; ++i)
+ (*i)->message(t, s);
+}
+
+const std::tr1::shared_ptr<const Set<std::string> >
+TeeOutputManager::factory_managers()
+{
+ std::tr1::shared_ptr<Set<std::string> > result(new Set<std::string>);
+ result->insert("tee");
+ return result;
+}
+
+const std::tr1::shared_ptr<OutputManager>
+TeeOutputManager::factory_create(
+ const OutputManagerFactory::KeyFunction & key_func,
+ const OutputManagerFactory::CreateChildFunction & create_child,
+ const OutputManagerFactory::ReplaceVarsFunc &)
+{
+ std::tr1::shared_ptr<OutputManagerSequence> children(new OutputManagerSequence);
+
+ std::vector<std::string> children_keys;
+ tokenise_whitespace(key_func("children"), std::back_inserter(children_keys));
+ if (children_keys.empty())
+ throw ConfigurationError("No children specified for TeeOutputManager");
+
+ for (std::vector<std::string>::const_iterator c(children_keys.begin()), c_end(children_keys.end()) ;
+ c != c_end ; ++c)
+ children->push_back(create_child(*c));
+
+ return make_shared_ptr(new TeeOutputManager(children));
+}
+
+template class PrivateImplementationPattern<TeeOutputManager>;
+
diff --git a/paludis/tee_output_manager.hh b/paludis/tee_output_manager.hh
new file mode 100644
index 0000000..2a47bfb
--- /dev/null
+++ b/paludis/tee_output_manager.hh
@@ -0,0 +1,63 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_TEE_OUTPUT_MANAGER_HH
+#define PALUDIS_GUARD_PALUDIS_TEE_OUTPUT_MANAGER_HH 1
+
+#include <paludis/tee_output_manager-fwd.hh>
+#include <paludis/output_manager.hh>
+#include <paludis/output_manager_factory.hh>
+#include <paludis/util/set-fwd.hh>
+#include <paludis/util/sequence-fwd.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <tr1/memory>
+#include <tr1/functional>
+
+namespace paludis
+{
+ class PALUDIS_VISIBLE TeeOutputManager :
+ private PrivateImplementationPattern<TeeOutputManager>,
+ public OutputManager
+ {
+ public:
+ TeeOutputManager(const std::tr1::shared_ptr<const OutputManagerSequence> &);
+ ~TeeOutputManager();
+
+ virtual std::ostream & stdout_stream() PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual std::ostream & stderr_stream() PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual void succeeded();
+ virtual void message(const MessageType, const std::string &);
+
+ static const std::tr1::shared_ptr<const Set<std::string> > factory_managers()
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ static const std::tr1::shared_ptr<OutputManager> factory_create(
+ const OutputManagerFactory::KeyFunction &,
+ const OutputManagerFactory::CreateChildFunction &,
+ const OutputManagerFactory::ReplaceVarsFunc &)
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
+ extern template class PrivateImplementationPattern<TeeOutputManager>;
+#endif
+}
+
+#endif
diff --git a/paludis/uninstall_task.cc b/paludis/uninstall_task.cc
index 0649730..7f9f3be 100644
--- a/paludis/uninstall_task.cc
+++ b/paludis/uninstall_task.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 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
@@ -39,6 +39,8 @@
#include <paludis/hook.hh>
#include <paludis/dep_tag.hh>
#include <paludis/repository.hh>
+#include <paludis/output_manager_from_environment.hh>
+#include <paludis/output_manager.hh>
#include <tr1/functional>
#include <map>
#include <set>
@@ -357,11 +359,16 @@ UninstallTask::execute()
try
{
+ OutputManagerFromEnvironment output_manager_holder(_imp->env, i->package_id(), oe_exclusive);
UninstallAction uninstall_action(
make_named_values<UninstallActionOptions>(
- value_for<n::config_protect>("")
+ value_for<n::config_protect>(""),
+ value_for<n::make_output_manager>(std::tr1::ref(output_manager_holder))
));
i->package_id()->perform_action(uninstall_action);
+
+ if (output_manager_holder.output_manager_if_constructed())
+ output_manager_holder.output_manager_if_constructed()->succeeded();
}
catch (const UninstallActionError & e)
{
diff --git a/paludis/util/discard_output_stream.cc b/paludis/util/discard_output_stream.cc
new file mode 100644
index 0000000..7386ee7
--- /dev/null
+++ b/paludis/util/discard_output_stream.cc
@@ -0,0 +1,40 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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 <paludis/util/discard_output_stream.hh>
+
+using namespace paludis;
+
+DiscardOutputStream::DiscardOutputStream() :
+ std::ostream(&buf)
+{
+}
+
+DiscardOutputStreamBuf::int_type
+DiscardOutputStreamBuf::overflow(int_type c)
+{
+ return c;
+}
+
+std::streamsize
+DiscardOutputStreamBuf::xsputn(const char *, std::streamsize num)
+{
+ return num;
+}
+
diff --git a/paludis/util/discard_output_stream.hh b/paludis/util/discard_output_stream.hh
new file mode 100644
index 0000000..a0577f8
--- /dev/null
+++ b/paludis/util/discard_output_stream.hh
@@ -0,0 +1,59 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 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
+ * 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_UTIL_DISCARD_OUTPUT_STREAM_HH
+#define PALUDIS_GUARD_PALUDIS_UTIL_DISCARD_OUTPUT_STREAM_HH 1
+
+#include <paludis/util/attributes.hh>
+#include <ostream>
+
+namespace paludis
+{
+ class PALUDIS_VISIBLE DiscardOutputStreamBuf :
+ public std::streambuf
+ {
+ protected:
+ virtual int_type
+ overflow(int_type c);
+
+ virtual std::streamsize
+ xsputn(const char * s, std::streamsize num);
+ };
+
+ class PALUDIS_VISIBLE DiscardOutputStreamBase
+ {
+ protected:
+ DiscardOutputStreamBuf buf;
+ };
+
+ class PALUDIS_VISIBLE DiscardOutputStream :
+ protected DiscardOutputStreamBase,
+ public std::ostream
+ {
+ public:
+ ///\name Basic operations
+ ///\{
+
+ DiscardOutputStream();
+
+ ///\}
+ };
+}
+
+#endif
diff --git a/paludis/util/echo_functions.bash.in b/paludis/util/echo_functions.bash.in
index 527d0a0..65ee50a 100644
--- a/paludis/util/echo_functions.bash.in
+++ b/paludis/util/echo_functions.bash.in
@@ -3,7 +3,7 @@
@GENERATED_FILE@
-# Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+# Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
#
# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005
# Gentoo Foundation and distributed under the terms of the GNU General
@@ -59,6 +59,11 @@ paludis_ecmd()
MESSAGE="${message}" perform_hook "${hook}"
fi
fi
+
+ if type paludis_pipe_command &>/dev/null ; then
+ local r=$(paludis_pipe_command MESSAGE "$EAPI" "$1" "$4" )
+ return ${r%%;*}
+ fi
}
einfon()
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index 8b790da..23d58fa 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -22,6 +22,7 @@ add(`damerau_levenshtein', `hh', `cc', `test')
add(`destringify', `hh', `cc', `test')
add(`deferred_construction_ptr', `hh', `cc', `fwd', `test')
add(`dir_iterator', `hh', `cc', `fwd', `se', `test', `testscript')
+add(`discard_output_stream', `hh', `cc')
add(`exception', `hh', `cc')
add(`fast_unique_copy', `hh', `test')
add(`forward_parallel_for_each', `hh', `test')
@@ -46,7 +47,6 @@ add(`named_value', `hh', `cc', `fwd')
add(`no_type', `hh')
add(`operators', `hh')
add(`options', `hh', `fwd', `cc', `test')
-add(`output_deviator', `hh', `fwd', `cc')
add(`output_wrapper', `test', `testscript')
add(`pipe', `hh', `cc')
add(`pretty_print', `hh', `cc', `test')
diff --git a/paludis/util/map.cc b/paludis/util/map.cc
index 4451fa4..5b06f88 100644
--- a/paludis/util/map.cc
+++ b/paludis/util/map.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 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
@@ -26,6 +26,7 @@
using namespace paludis;
template class Map<std::string, std::string>;
+template class DefaultMapComparator<std::string>;
template class WrappedForwardIterator<Map<std::string, std::string>::ConstIteratorTag, const std::pair<const std::string, std::string> >;
template class WrappedOutputIterator<Map<std::string, std::string>::InserterTag, std::pair<const std::string, std::string> >;
diff --git a/paludis/util/output_deviator.cc b/paludis/util/output_deviator.cc
deleted file mode 100644
index 2b247a5..0000000
--- a/paludis/util/output_deviator.cc
+++ /dev/null
@@ -1,144 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 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
- * 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 <paludis/util/output_deviator.hh>
-#include <paludis/util/private_implementation_pattern-impl.hh>
-#include <paludis/util/fs_entry.hh>
-#include <paludis/util/make_shared_ptr.hh>
-#include <paludis/util/stringify.hh>
-#include <paludis/util/log.hh>
-#include <paludis/util/tee_output_stream.hh>
-#include <paludis/util/tail_output_stream.hh>
-#include <paludis/util/safe_ofstream.hh>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <ctime>
-#include <unistd.h>
-#include <iostream>
-
-namespace paludis
-{
- template <>
- struct Implementation<OutputDeviator>
- {
- const FSEntry log_dir;
-
- Implementation(const FSEntry & l) :
- log_dir(l)
- {
- }
- };
-
- template <>
- struct Implementation<OutputDeviant>
- {
- const FSEntry file_name;
- std::tr1::shared_ptr<TeeOutputStream> tee_stream;
- std::tr1::shared_ptr<SafeOFStream> f_stream;
- std::tr1::shared_ptr<TailOutputStream> tail_stream;
-
- Implementation(const FSEntry & f, const unsigned int number_of_tail_lines) :
- file_name(f)
- {
- try
- {
- f_stream.reset(new SafeOFStream(file_name));
- tail_stream.reset(new TailOutputStream(number_of_tail_lines));
- tee_stream.reset(new TeeOutputStream(f_stream.get(), tail_stream.get()));
- }
- catch (const SafeOFStreamError &)
- {
- Log::get_instance()->message("output_deviator.open_failed", ll_warning, lc_context) << "Cannot open '"
- << file_name << + "' for write, sending output to stdout and stderr instead";
- f_stream.reset();
- }
- }
- };
-}
-
-OutputDeviator::OutputDeviator(const FSEntry & l) :
- PrivateImplementationPattern<OutputDeviator>(new Implementation<OutputDeviator>(l))
-{
-}
-
-OutputDeviator::~OutputDeviator()
-{
-}
-
-const std::tr1::shared_ptr<OutputDeviant>
-OutputDeviator::make_output_deviant(const std::string & n, const unsigned number_of_tail_lines)
-{
- return make_shared_ptr(new OutputDeviant(_imp->log_dir / (n + "." + stringify(std::time(0)) + ".log"), number_of_tail_lines));
-}
-
-OutputDeviant::OutputDeviant(const FSEntry & f, const unsigned int n) :
- PrivateImplementationPattern<OutputDeviant>(new Implementation<OutputDeviant>(f, n))
-{
-}
-
-OutputDeviant::~OutputDeviant()
-{
-}
-
-std::ostream *
-OutputDeviant::stdout_stream() const
-{
- if (_imp->tee_stream)
- return _imp->tee_stream.get();
- else
- return &std::cout;
-}
-
-std::ostream *
-OutputDeviant::stderr_stream() const
-{
- if (_imp->tee_stream)
- return _imp->tee_stream.get();
- else
- return &std::cerr;
-}
-
-void
-OutputDeviant::discard_log()
-{
- if (_imp->f_stream)
- if (-1 == ::unlink(stringify(_imp->file_name).c_str()))
- Log::get_instance()->message("output_deviant.unlink_failed", ll_warning, lc_context)
- << "Cannot unlink '" << _imp->file_name << "'";
-}
-
-const FSEntry
-OutputDeviant::log_file_name() const
-{
- return _imp->file_name;
-}
-
-const std::tr1::shared_ptr<const Sequence<std::string> >
-OutputDeviant::tail(const bool clear) const
-{
- if (_imp->tail_stream)
- return _imp->tail_stream->tail(clear);
- else
- return make_null_shared_ptr();
-}
-
-template class PrivateImplementationPattern<OutputDeviator>;
-template class PrivateImplementationPattern<OutputDeviant>;
-
diff --git a/paludis/util/output_deviator.hh b/paludis/util/output_deviator.hh
deleted file mode 100644
index f572e9c..0000000
--- a/paludis/util/output_deviator.hh
+++ /dev/null
@@ -1,71 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2008 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
- * 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_UTIL_OUTPUT_DEVIATOR_HH
-#define PALUDIS_GUARD_PALUDIS_UTIL_OUTPUT_DEVIATOR_HH 1
-
-#include <paludis/util/output_deviator-fwd.hh>
-#include <paludis/util/private_implementation_pattern.hh>
-#include <paludis/util/fs_entry-fwd.hh>
-#include <paludis/util/sequence-fwd.hh>
-#include <tr1/memory>
-
-using namespace paludis;
-
-namespace paludis
-{
- class PALUDIS_VISIBLE OutputDeviator :
- private PrivateImplementationPattern<OutputDeviator>
- {
- public:
- OutputDeviator(const FSEntry & log_dir);
- ~OutputDeviator();
-
- const std::tr1::shared_ptr<OutputDeviant> make_output_deviant(
- const std::string &, const unsigned int number_of_tail_lines) PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
- class PALUDIS_VISIBLE OutputDeviant :
- private PrivateImplementationPattern<OutputDeviant>
- {
- friend class OutputDeviator;
-
- private:
- OutputDeviant(const FSEntry &, const unsigned int);
-
- public:
- ~OutputDeviant();
-
- std::ostream * stdout_stream() const PALUDIS_ATTRIBUTE((warn_unused_result));
- std::ostream * stderr_stream() const PALUDIS_ATTRIBUTE((warn_unused_result));
-
- void discard_log();
- const FSEntry log_file_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
-
- const std::tr1::shared_ptr<const Sequence<std::string> > tail(const bool clear) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
- };
-
-#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
- extern template class PrivateImplementationPattern<OutputDeviator>;
- extern template class PrivateImplementationPattern<OutputDeviant>;
-#endif
-}
-
-#endif
diff --git a/paludis/util/tee_output_stream.cc b/paludis/util/tee_output_stream.cc
index b0b74e5..00cb71f 100644
--- a/paludis/util/tee_output_stream.cc
+++ b/paludis/util/tee_output_stream.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 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
@@ -18,6 +18,63 @@
*/
#include <paludis/util/tee_output_stream.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <list>
using namespace paludis;
+namespace paludis
+{
+ template <>
+ struct Implementation<TeeOutputStreamBuf>
+ {
+ std::list<std::ostream *> streams;
+ };
+}
+
+TeeOutputStreamBuf::TeeOutputStreamBuf() :
+ PrivateImplementationPattern<TeeOutputStreamBuf>(new Implementation<TeeOutputStreamBuf>)
+{
+}
+
+TeeOutputStreamBuf::~TeeOutputStreamBuf()
+{
+}
+
+TeeOutputStreamBuf::int_type
+TeeOutputStreamBuf::overflow(int_type c)
+{
+ for (std::list<std::ostream *>::iterator i(_imp->streams.begin()), i_end(_imp->streams.end()) ;
+ i != i_end ; ++i)
+ (*i)->put(c);
+ return c;
+}
+
+std::streamsize
+TeeOutputStreamBuf::xsputn(const char * s, std::streamsize num)
+{
+ for (std::list<std::ostream *>::iterator i(_imp->streams.begin()), i_end(_imp->streams.end()) ;
+ i != i_end ; ++i)
+ (*i)->write(s, num);
+ return num;
+}
+
+void
+TeeOutputStreamBuf::add_stream(std::ostream * const s)
+{
+ _imp->streams.push_back(s);
+}
+
+TeeOutputStream::TeeOutputStream() :
+ std::ostream(&buf)
+{
+}
+
+void
+TeeOutputStream::add_stream(std::ostream * const s)
+{
+ buf.add_stream(s);
+}
+
+template class PrivateImplementationPattern<TeeOutputStreamBuf>;
+
diff --git a/paludis/util/tee_output_stream.hh b/paludis/util/tee_output_stream.hh
index f3a736c..1e319bd 100644
--- a/paludis/util/tee_output_stream.hh
+++ b/paludis/util/tee_output_stream.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 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
@@ -22,55 +22,33 @@
#include <paludis/util/tee_output_stream-fwd.hh>
#include <paludis/util/attributes.hh>
+#include <paludis/util/private_implementation_pattern.hh>
#include <ostream>
namespace paludis
{
class PALUDIS_VISIBLE TeeOutputStreamBuf :
- public std::streambuf
+ public std::streambuf,
+ private PrivateImplementationPattern<TeeOutputStreamBuf>
{
- private:
- std::ostream * const s1;
- std::ostream * const s2;
-
protected:
virtual int_type
- overflow(int_type c)
- {
- if (c != traits_type::eof())
- {
- s1->put(c);
- s2->put(c);
- }
- return c;
- }
+ overflow(int_type c);
virtual std::streamsize
- xsputn(const char * s, std::streamsize num)
- {
- s1->write(s, num);
- s2->write(s, num);
- return num;
- }
+ xsputn(const char * s, std::streamsize num);
public:
- TeeOutputStreamBuf(std::ostream * const b1, std::ostream * const b2) :
- s1(b1),
- s2(b2)
- {
- }
+ TeeOutputStreamBuf();
+ ~TeeOutputStreamBuf();
+
+ void add_stream(std::ostream * const);
};
class PALUDIS_VISIBLE TeeOutputStreamBase
{
protected:
TeeOutputStreamBuf buf;
-
- public:
- TeeOutputStreamBase(std::ostream * const b1, std::ostream * const b2) :
- buf(b1, b2)
- {
- }
};
class PALUDIS_VISIBLE TeeOutputStream :
@@ -81,14 +59,16 @@ namespace paludis
///\name Basic operations
///\{
- TeeOutputStream(std::ostream * const b1, std::ostream * const b2) :
- TeeOutputStreamBase(b1, b2),
- std::ostream(&buf)
- {
- }
+ TeeOutputStream();
///\}
+
+ void add_stream(std::ostream * const);
};
+
+#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
+ extern template class PrivateImplementationPattern<TeeOutputStreamBuf>;
+#endif
}
#endif
diff --git a/python/Makefile.am b/python/Makefile.am
index 7318cd2..7434f57 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -130,6 +130,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_REPOSITORY_SO_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories`" \
PALUDIS_ENVIRONMENT_SO_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments`" \
PALUDIS_ENABLE_VIRTUALS_REPOSITORY="$(PALUDIS_ENABLE_VIRTUALS_REPOSITORY_VALUE)" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
SYSCONFDIR="$(sysconfdir)" \
LD_LIBRARY_PATH="`echo $$LD_LIBRARY_PATH: | sed -e 's,^:,,'`` \
echo "\`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/.libs\`: \
diff --git a/python/action.cc b/python/action.cc
index cd5805d..d84166a 100644
--- a/python/action.cc
+++ b/python/action.cc
@@ -23,6 +23,7 @@
#include <paludis/action.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/standard_output_manager.hh>
#include <paludis/repository.hh>
#include <tr1/memory>
@@ -59,11 +60,17 @@ namespace
return wp_yes;
}
+ std::tr1::shared_ptr<OutputManager> make_standard_output_manager(const Action &)
+ {
+ return make_shared_ptr(new StandardOutputManager);
+ }
+
InstallActionOptions * make_install_action_options(
const std::tr1::shared_ptr<paludis::Repository> & r)
{
return new InstallActionOptions(make_named_values<InstallActionOptions>(
value_for<n::destination>(r),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
@@ -73,7 +80,29 @@ namespace
const std::string & c)
{
return new UninstallActionOptions(make_named_values<UninstallActionOptions>(
- value_for<n::config_protect>(c)
+ value_for<n::config_protect>(c),
+ value_for<n::make_output_manager>(&make_standard_output_manager)
+ ));
+ }
+
+ InfoActionOptions * make_info_action_options()
+ {
+ return new InfoActionOptions(make_named_values<InfoActionOptions>(
+ value_for<n::make_output_manager>(&make_standard_output_manager)
+ ));
+ }
+
+ ConfigActionOptions * make_config_action_options()
+ {
+ return new ConfigActionOptions(make_named_values<ConfigActionOptions>(
+ value_for<n::make_output_manager>(&make_standard_output_manager)
+ ));
+ }
+
+ PretendActionOptions * make_pretend_action_options()
+ {
+ return new PretendActionOptions(make_named_values<PretendActionOptions>(
+ value_for<n::make_output_manager>(&make_standard_output_manager)
));
}
@@ -86,7 +115,7 @@ namespace
return new FetchActionOptions(make_named_values<FetchActionOptions>(
value_for<n::exclude_unmirrorable>(exclude_unmirrorable),
value_for<n::fetch_unneeded>(fetch_unneeded),
- value_for<n::maybe_output_deviant>(make_null_shared_ptr()),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::safe_resume>(safe_resume)
));
}
@@ -162,6 +191,54 @@ void expose_action()
;
/**
+ * ConfigActionOptions
+ */
+ bp::class_<ConfigActionOptions>
+ (
+ "ConfigActionOptions",
+ "Options for ConfigAction.",
+ bp::no_init
+ )
+
+ .def("__init__",
+ bp::make_constructor(&make_config_action_options),
+ "__init__()"
+ )
+ ;
+
+ /**
+ * InfoActionOptions
+ */
+ bp::class_<InfoActionOptions>
+ (
+ "InfoActionOptions",
+ "Options for InfoAction.",
+ bp::no_init
+ )
+
+ .def("__init__",
+ bp::make_constructor(&make_info_action_options),
+ "__init__()"
+ )
+ ;
+
+ /**
+ * PretendActionOptions
+ */
+ bp::class_<PretendActionOptions>
+ (
+ "PretendActionOptions",
+ "Options for PretendAction.",
+ bp::no_init
+ )
+
+ .def("__init__",
+ bp::make_constructor(&make_pretend_action_options),
+ "__init__()"
+ )
+ ;
+
+ /**
* FetchActionOptions
*/
bp::class_<FetchActionOptions>
@@ -257,7 +334,7 @@ void expose_action()
"PretendAction",
"A PretendAction is used by InstallTask to handle install-pretend-phase\n"
"checks on a PackageID.",
- bp::init<>("__init__()")
+ bp::init<const PretendActionOptions &>("__init__(PretendActionOptions)")
)
.add_property("failed", &PretendAction::failed,
"[ro] bool\n"
@@ -274,7 +351,7 @@ void expose_action()
"A ConfigAction is used via PackageID::perform_action to execute\n"
"post-install configuration (for example, via 'paludis --config')\n"
"on a PackageID.",
- bp::init<>("__init__()")
+ bp::init<ConfigActionOptions>("__init__(ConfigActionOptions)")
);
/**
@@ -286,7 +363,7 @@ void expose_action()
"An InfoAction is used via PackageID::perform_action to execute\n"
"additional information (for example, via 'paludis --info')\n"
"on a PackageID.",
- bp::init<>("__init__()")
+ bp::init<InfoActionOptions>("__init__(InfoActionOptions)")
);
/**
diff --git a/python/action_TEST.py b/python/action_TEST.py
index a123935..8bee223 100755
--- a/python/action_TEST.py
+++ b/python/action_TEST.py
@@ -84,15 +84,15 @@ class TestCase_07_InstalledAction(unittest.TestCase):
class TestCase_08_PretendAction(unittest.TestCase):
def test_01_create(self):
- PretendAction()
+ PretendAction(PretendActionOptions())
class TestCase_09_ConfigAction(unittest.TestCase):
def test_01_create(self):
- ConfigAction()
+ ConfigAction(ConfigActionOptions())
class TestCase_10_InfoAction(unittest.TestCase):
def test_01_create(self):
- InfoAction()
+ InfoAction(InfoActionOptions())
class TestCase_10_SupportsActionTests(unittest.TestCase):
def test_01_create(self):
diff --git a/python/environment.cc b/python/environment.cc
index fe15bd8..fcac437 100644
--- a/python/environment.cc
+++ b/python/environment.cc
@@ -35,6 +35,7 @@
#include <paludis/util/tribool.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/standard_output_manager.hh>
using namespace paludis;
using namespace paludis::python;
@@ -427,6 +428,12 @@ class EnvironmentImplementationWrapper :
{
throw PythonMethodNotImplemented("EnvironmentImplementation", "known_choice_value_names");
}
+
+ virtual const std::tr1::shared_ptr<OutputManager> create_output_manager(
+ const CreateOutputManagerInfo &) const
+ {
+ return make_shared_ptr(new StandardOutputManager);
+ }
};
struct NoConfigEnvironmentWrapper :
diff --git a/python/package_id_TEST.py b/python/package_id_TEST.py
index 1e243fa..231094d 100755
--- a/python/package_id_TEST.py
+++ b/python/package_id_TEST.py
@@ -84,9 +84,9 @@ class TestCase_01_PackageID(unittest.TestCase):
self.assert_(isinstance(self.pid.find_metadata("DEPEND"), MetadataDependencySpecTreeKey))
def test_10_perform_action(self):
- self.pid.perform_action(PretendAction())
- self.assertRaises(UnsupportedActionError, self.pid.perform_action, ConfigAction())
- self.assertRaises(UnsupportedActionError, self.ipid.perform_action, PretendAction())
+ self.pid.perform_action(PretendAction(PretendActionOptions()))
+ self.assertRaises(UnsupportedActionError, self.pid.perform_action, ConfigAction(ConfigActionOptions()))
+ self.assertRaises(UnsupportedActionError, self.ipid.perform_action, PretendAction(PretendActionOptions()))
def test_11_supports_action(self):
self.assert_(self.pid.supports_action(SupportsFetchActionTest()))
diff --git a/ruby/Makefile.am b/ruby/Makefile.am
index 5c9795d..870aeb9 100644
--- a/ruby/Makefile.am
+++ b/ruby/Makefile.am
@@ -112,6 +112,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_REPOSITORY_SO_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories`" \
PALUDIS_ENVIRONMENT_SO_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments`" \
PALUDIS_ENABLE_VIRTUALS_REPOSITORY="$(PALUDIS_ENABLE_VIRTUALS_REPOSITORY_VALUE)" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
SYSCONFDIR="$(sysconfdir)" \
LD_LIBRARY_PATH=`echo "\`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/.libs\`: \
\`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/util/.libs\`: \
diff --git a/ruby/action.cc b/ruby/action.cc
index 8f69a19..f058ffb 100644
--- a/ruby/action.cc
+++ b/ruby/action.cc
@@ -22,6 +22,7 @@
#include <paludis/action.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/standard_output_manager.hh>
#include <ruby.h>
using namespace paludis;
@@ -214,6 +215,11 @@ namespace
}
}
+ std::tr1::shared_ptr<OutputManager> make_standard_output_manager(const Action &)
+ {
+ return make_shared_ptr(new StandardOutputManager);
+ }
+
/*
* call-seq:
* FetchActionOptions.new(exclude_unmirrorable, fetch_unneeded, safe_resume) -> FetchActionOptions
@@ -256,7 +262,7 @@ namespace
ptr = new FetchActionOptions(make_named_values<FetchActionOptions>(
value_for<n::exclude_unmirrorable>(v_exclude_unmirrorable),
value_for<n::fetch_unneeded>(v_fetch_unneeded),
- value_for<n::maybe_output_deviant>(make_null_shared_ptr()),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::safe_resume>(v_safe_resume)
));
@@ -461,12 +467,37 @@ namespace
*
* Create new PretendAction
*/
- template <typename A_>
+ template <typename A_, typename O_>
struct EasyActionNew
{
static VALUE
easy_action_new(VALUE self)
{
+ O_ options(make_named_values<O_>(
+ value_for<n::make_output_manager>(&make_standard_output_manager)
+ ));
+
+ std::tr1::shared_ptr<Action> * a(new std::tr1::shared_ptr<Action>(new A_(options)));
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<std::tr1::shared_ptr<Action> >::free, a));
+ rb_obj_call_init(tdata, 1, &self);
+ return tdata;
+ }
+ };
+
+ /*
+ * Document-method InstalledAction.new
+ *
+ * call-seq:
+ * InstalledAction.new -> InstalledAction
+ *
+ * Create new InstalledAction
+ */
+ template <typename A_>
+ struct ReallyEasyActionNew
+ {
+ static VALUE
+ easy_action_new(VALUE self)
+ {
std::tr1::shared_ptr<Action> * a(new std::tr1::shared_ptr<Action>(new A_()));
VALUE tdata(Data_Wrap_Struct(self, 0, &Common<std::tr1::shared_ptr<Action> >::free, a));
rb_obj_call_init(tdata, 1, &self);
@@ -515,6 +546,7 @@ namespace
ptr = new InstallActionOptions(make_named_values<InstallActionOptions>(
value_for<n::destination>(v_destination),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect),
value_for<n::want_phase>(&want_all_phases)
));
@@ -599,7 +631,8 @@ namespace
}
ptr = new UninstallActionOptions(make_named_values<UninstallActionOptions>(
- value_for<n::config_protect>(v_config_protect)
+ value_for<n::config_protect>(v_config_protect),
+ value_for<n::make_output_manager>(&make_standard_output_manager)
));
VALUE tdata(Data_Wrap_Struct(self, 0, &Common<UninstallActionOptions>::free, ptr));
@@ -763,7 +796,7 @@ namespace
*/
c_info_action = rb_define_class_under(paludis_module(), "InfoAction", c_action);
rb_define_singleton_method(c_info_action, "new",
- RUBY_FUNC_CAST((&EasyActionNew<InfoAction>::easy_action_new)), 0);
+ RUBY_FUNC_CAST((&EasyActionNew<InfoAction, InfoActionOptions>::easy_action_new)), 0);
rb_define_method(c_info_action, "initialize", RUBY_FUNC_CAST(&empty_init), -1);
/*
@@ -773,7 +806,7 @@ namespace
*/
c_config_action = rb_define_class_under(paludis_module(), "ConfigAction", c_action);
rb_define_singleton_method(c_config_action, "new",
- RUBY_FUNC_CAST((&EasyActionNew<ConfigAction>::easy_action_new)), 0);
+ RUBY_FUNC_CAST((&EasyActionNew<ConfigAction, ConfigActionOptions>::easy_action_new)), 0);
rb_define_method(c_config_action, "initialize", RUBY_FUNC_CAST(&empty_init), -1);
/*
@@ -824,7 +857,7 @@ namespace
*/
c_installed_action = rb_define_class_under(paludis_module(), "InstalledAction", c_action);
rb_define_singleton_method(c_installed_action, "new",
- RUBY_FUNC_CAST((&EasyActionNew<InstalledAction>::easy_action_new)), 0);
+ RUBY_FUNC_CAST((&ReallyEasyActionNew<InstalledAction>::easy_action_new)), 0);
rb_define_method(c_installed_action, "initialize", RUBY_FUNC_CAST(&empty_init), -1);
/*
@@ -834,7 +867,7 @@ namespace
*/
c_pretend_action = rb_define_class_under(paludis_module(), "PretendAction", c_action);
rb_define_singleton_method(c_pretend_action, "new",
- RUBY_FUNC_CAST((&EasyActionNew<PretendAction>::easy_action_new)), 0);
+ RUBY_FUNC_CAST((&EasyActionNew<PretendAction, PretendActionOptions>::easy_action_new)), 0);
rb_define_method(c_pretend_action, "initialize", RUBY_FUNC_CAST(&empty_init), -1);
rb_define_method(c_pretend_action, "failed?", RUBY_FUNC_CAST(&pretend_action_failed), 0);
rb_define_method(c_pretend_action, "set_failed", RUBY_FUNC_CAST(&pretend_action_set_failed), 0);
diff --git a/ruby/demos/Makefile.am b/ruby/demos/Makefile.am
index c7517e2..180b415 100644
--- a/ruby/demos/Makefile.am
+++ b/ruby/demos/Makefile.am
@@ -33,6 +33,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_DISTRIBUTION="gentoo" \
PALUDIS_OPTIONS="" \
PALUDIS_REPOSITORY_SO_DIR="`$(top_srcdir)/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories`" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
SYSCONFDIR="$(sysconfdir)" \
LD_LIBRARY_PATH="`$(top_srcdir)/ebuild/utils/canonicalise $(top_builddir)/paludis/.libs`" \
bash $(top_srcdir)/test/run_test.sh "ruby -I ../.libs/"
diff --git a/src/clients/accerso/Makefile.am b/src/clients/accerso/Makefile.am
index 2e7062c..aedeacf 100644
--- a/src/clients/accerso/Makefile.am
+++ b/src/clients/accerso/Makefile.am
@@ -56,6 +56,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_NO_CHOWN="yupyup" \
PALUDIS_REDUCED_USERNAME="`id -un`" \
PALUDIS_OUTPUTWRAPPER_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/util/`" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
TEST_OUTPUT_WRAPPER="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/util/outputwrapper`" \
SYSCONFDIR="$(sysconfdir)" \
bash $(top_srcdir)/test/run_test.sh bash
diff --git a/src/clients/accerso/accerso.cc b/src/clients/accerso/accerso.cc
index 8db3333..54615cc 100644
--- a/src/clients/accerso/accerso.cc
+++ b/src/clients/accerso/accerso.cc
@@ -31,13 +31,16 @@
#include <paludis/util/map.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/standard_output_manager.hh>
#include <paludis/util/safe_ofstream.hh>
+#include <paludis/create_output_manager_info.hh>
#include <paludis/environments/no_config/no_config_environment.hh>
#include <paludis/selection.hh>
#include <paludis/generator.hh>
#include <paludis/filter.hh>
#include <paludis/filtered_generator.hh>
#include <paludis/package_database.hh>
+#include <paludis/output_manager_from_environment.hh>
#include <cstdlib>
#include <tr1/functional>
#include <iostream>
@@ -136,16 +139,19 @@ main(int argc, char *argv[])
try
{
- FetchAction a(make_named_values<FetchActionOptions>(
- value_for<n::exclude_unmirrorable>(true),
- value_for<n::fetch_unneeded>(true),
- value_for<n::maybe_output_deviant>(make_null_shared_ptr()),
- value_for<n::safe_resume>(true)
- ));
if ((*i)->supports_action(SupportsActionTest<FetchAction>()))
{
+ OutputManagerFromEnvironment output_manager_holder(&env, *i, oe_exclusive);
+ FetchAction a(make_named_values<FetchActionOptions>(
+ value_for<n::exclude_unmirrorable>(true),
+ value_for<n::fetch_unneeded>(true),
+ value_for<n::make_output_manager>(std::tr1::ref(output_manager_holder)),
+ value_for<n::safe_resume>(true)
+ ));
(*i)->perform_action(a);
++success;
+ if (output_manager_holder.output_manager_if_constructed())
+ output_manager_holder.output_manager_if_constructed()->succeeded();
}
else
results.insert(std::make_pair(*i, "Does not support fetching"));
diff --git a/src/clients/adjutrix/Makefile.am b/src/clients/adjutrix/Makefile.am
index 7d93425..ca88f5a 100644
--- a/src/clients/adjutrix/Makefile.am
+++ b/src/clients/adjutrix/Makefile.am
@@ -66,6 +66,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_DISTRIBUTION="gentoo" \
PALUDIS_OPTIONS="" \
PALUDIS_REPOSITORY_SO_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories`" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
SYSCONFDIR="$(sysconfdir)" \
ADJUTRIX_OPTIONS="" \
TEST_OUTPUT_WRAPPER="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/util/outputwrapper`" \
diff --git a/src/clients/appareo/Makefile.am b/src/clients/appareo/Makefile.am
index b6c34b4..fba5b65 100644
--- a/src/clients/appareo/Makefile.am
+++ b/src/clients/appareo/Makefile.am
@@ -53,6 +53,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_DISTRIBUTION="gentoo" \
PALUDIS_REPOSITORY_SO_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories`" \
PALUDIS_ENVIRONMENT_SO_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments`" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
PALUDIS_NO_CHOWN="yupyup" \
PALUDIS_REDUCED_USERNAME="`id -un`" \
PALUDIS_OUTPUTWRAPPER_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/util/`" \
diff --git a/src/clients/appareo/appareo.cc b/src/clients/appareo/appareo.cc
index 63617c4..29e9387 100644
--- a/src/clients/appareo/appareo.cc
+++ b/src/clients/appareo/appareo.cc
@@ -32,6 +32,7 @@
#include <paludis/util/map.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/standard_output_manager.hh>
#include <paludis/environments/no_config/no_config_environment.hh>
#include <paludis/selection.hh>
#include <paludis/generator.hh>
@@ -52,6 +53,11 @@ typedef std::multimap<std::tr1::shared_ptr<const PackageID>, std::string, Packag
namespace
{
+ std::tr1::shared_ptr<OutputManager> make_standard_output_manager(const Action &)
+ {
+ return make_shared_ptr(new StandardOutputManager);
+ }
+
FSEntry get_location_and_add_filters()
{
Context context("When determining tree location:");
@@ -98,7 +104,7 @@ namespace
FetchAction a(make_named_values<FetchActionOptions>(
value_for<n::exclude_unmirrorable>(false),
value_for<n::fetch_unneeded>(true),
- value_for<n::maybe_output_deviant>(make_null_shared_ptr()),
+ value_for<n::make_output_manager>(&make_standard_output_manager),
value_for<n::safe_resume>(true)
));
(*i)->perform_action(a);
diff --git a/src/clients/cave/Makefile.am b/src/clients/cave/Makefile.am
index 26f94ad..ba853d7 100644
--- a/src/clients/cave/Makefile.am
+++ b/src/clients/cave/Makefile.am
@@ -128,6 +128,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_NO_CHOWN="yupyup" \
PALUDIS_REDUCED_USERNAME="`id -un`" \
PALUDIS_OUTPUTWRAPPER_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/util/`" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
TEST_OUTPUT_WRAPPER="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/util/outputwrapper`" \
SYSCONFDIR="$(sysconfdir)" \
bash $(top_srcdir)/test/run_test.sh bash
diff --git a/src/clients/cave/cmd_sync.cc b/src/clients/cave/cmd_sync.cc
index 9227623..e84bba1 100644
--- a/src/clients/cave/cmd_sync.cc
+++ b/src/clients/cave/cmd_sync.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 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
@@ -25,11 +25,11 @@
#include <paludis/package_database.hh>
#include <paludis/util/action_queue.hh>
#include <paludis/util/mutex.hh>
-#include <paludis/util/output_deviator.hh>
#include <paludis/util/named_value.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/condition_variable.hh>
#include <paludis/util/thread.hh>
+#include <paludis/output_manager.hh>
#include <paludis/repository.hh>
#include <paludis/environment.hh>
#include <paludis/hook.hh>
@@ -50,7 +50,7 @@ namespace paludis
{
namespace n
{
- struct output_deviant;
+ struct output_manager;
struct success;
struct summary;
}
@@ -58,6 +58,46 @@ namespace paludis
namespace
{
+ struct TailAndLogOutputManager :
+ OutputManager
+ {
+ TailAndLogOutputManager(const std::string &)
+ {
+ }
+
+ virtual std::ostream & stdout_stream()
+ {
+ return std::cout;
+ }
+
+ virtual std::ostream & stderr_stream()
+ {
+ return std::cerr;
+ }
+
+ std::tr1::shared_ptr<const Sequence<std::string> > tail(const bool) const
+ {
+ return make_shared_ptr(new Sequence<std::string>);
+ }
+
+ void discard_log()
+ {
+ }
+
+ const FSEntry log_file_name() const
+ {
+ return FSEntry("/dev/null");
+ }
+
+ void succeeded()
+ {
+ }
+
+ virtual void message(const MessageType, const std::string &)
+ {
+ }
+ };
+
struct SyncCommandLine :
CaveCommandCommandLine
{
@@ -85,7 +125,7 @@ namespace
struct Message
{
- NamedValue<n::output_deviant, std::tr1::shared_ptr<OutputDeviant> > output_deviant;
+ NamedValue<n::output_manager, std::tr1::shared_ptr<TailAndLogOutputManager> > output_manager;
NamedValue<n::success, bool> success;
NamedValue<n::summary, std::string> summary;
};
@@ -94,7 +134,7 @@ namespace
void do_one_sync_notifier(const RepositoryName & r, Mutex & notifier_mutex,
Mutex & count_mutex, ConditionVariable & notifier_condition, int & np, int & na, int & nd,
- bool & finished, OutputDeviant & output_deviant)
+ bool & finished, TailAndLogOutputManager & output_manager)
{
bool first(true);
while (true)
@@ -107,7 +147,7 @@ namespace
if (! first)
{
cout << format_general_spad(f::sync_repo_active(), stringify(r), np, na, nd);
- std::tr1::shared_ptr<const Sequence<std::string> > tail(output_deviant.tail(true));
+ std::tr1::shared_ptr<const Sequence<std::string> > tail(output_manager.tail(true));
if (tail && tail->begin() != tail->end())
{
for (Sequence<std::string>::ConstIterator t(tail->begin()), t_end(tail->end()) ;
@@ -124,15 +164,10 @@ namespace
}
void do_one_sync(const std::tr1::shared_ptr<Environment> & env, const RepositoryName & r, Mutex & mutex,
- Messages & messages, int & retcode, int & np, int & na, int & nd,
- OutputDeviator & output_deviator)
+ Messages & messages, int & retcode, int & np, int & na, int & nd)
{
- std::tr1::shared_ptr<OutputDeviant> output_deviant;
-
- {
- Lock lock(mutex);
- output_deviant = output_deviator.make_output_deviant("sync-" + stringify(r), 10);
- }
+ std::tr1::shared_ptr<TailAndLogOutputManager> output_manager(
+ new TailAndLogOutputManager("sync-" + stringify(r)));
bool done_decrement(false);
@@ -166,11 +201,11 @@ namespace
std::tr1::ref(notifier_mutex), std::tr1::ref(mutex),
std::tr1::ref(notifier_condition),
std::tr1::ref(np), std::tr1::ref(na), std::tr1::ref(nd),
- std::tr1::ref(finished), std::tr1::ref(*output_deviant)));
+ std::tr1::ref(finished), std::tr1::ref(*output_manager)));
try
{
- result = repo->syncable_interface()->sync(output_deviant);
+ result = repo->syncable_interface()->sync(output_manager);
{
Lock lock(mutex);
@@ -209,7 +244,7 @@ namespace
{
Lock lock(mutex);
messages.insert(make_pair(stringify(r), make_named_values<Message>(
- value_for<n::output_deviant>(output_deviant),
+ value_for<n::output_manager>(output_manager),
value_for<n::success>(true),
value_for<n::summary>("success")
)));
@@ -219,7 +254,7 @@ namespace
{
Lock lock(mutex);
messages.insert(make_pair(stringify(r), make_named_values<Message>(
- value_for<n::output_deviant>(output_deviant),
+ value_for<n::output_manager>(output_manager),
value_for<n::success>(true),
value_for<n::summary>("no syncing required")
)));
@@ -239,13 +274,13 @@ namespace
retcode |= 1;
messages.insert(make_pair(stringify(r), make_named_values<Message>(
- value_for<n::output_deviant>(output_deviant),
+ value_for<n::output_manager>(output_manager),
value_for<n::success>(false),
value_for<n::summary>(e.message() + " (" + e.what() + ")")
)));
cout << format_general_spad(f::sync_repo_done_failure(), stringify(r), np, na, nd);
- std::tr1::shared_ptr<const Sequence<std::string> > tail(output_deviant->tail(true));
+ std::tr1::shared_ptr<const Sequence<std::string> > tail(output_manager->tail(true));
if (tail && tail->begin() != tail->end())
{
for (Sequence<std::string>::ConstIterator t(tail->begin()), t_end(tail->end()) ;
@@ -281,8 +316,6 @@ SyncCommand::run(
int retcode(0);
Messages messages;
- OutputDeviator output_deviator(FSEntry("/tmp"));
-
std::set<RepositoryName, RepositoryNameComparator> repos;
if (cmdline.begin_parameters() != cmdline.end_parameters())
for (SyncCommandLine::ParametersConstIterator p(cmdline.begin_parameters()), p_end(cmdline.end_parameters()) ;
@@ -313,7 +346,7 @@ SyncCommand::run(
r != r_end ; ++r)
actions.enqueue(std::tr1::bind(&do_one_sync, env, *r, std::tr1::ref(mutex),
std::tr1::ref(messages), std::tr1::ref(retcode), std::tr1::ref(pending),
- std::tr1::ref(active), std::tr1::ref(done), std::tr1::ref(output_deviator)));
+ std::tr1::ref(active), std::tr1::ref(done)));
}
if (0 != env->perform_hook(Hook("sync_all_post")
@@ -329,12 +362,12 @@ SyncCommand::run(
if (m->second.success())
{
cout << format_general_kv(f::sync_message_success(), m->first, m->second.summary());
- m->second.output_deviant()->discard_log();
+ m->second.output_manager()->discard_log();
}
else
{
cout << format_general_kv(f::sync_message_failure(), m->first, m->second.summary());
- cout << format_general_kv(f::sync_message_failure_message(), "Log file", stringify(m->second.output_deviant()->log_file_name()));
+ cout << format_general_kv(f::sync_message_failure_message(), "Log file", stringify(m->second.output_manager()->log_file_name()));
}
}
cout << endl;
diff --git a/src/clients/importare/Makefile.am b/src/clients/importare/Makefile.am
index b156374..c7bbbe4 100644
--- a/src/clients/importare/Makefile.am
+++ b/src/clients/importare/Makefile.am
@@ -50,6 +50,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_NO_CHOWN="yupyup" \
PALUDIS_REDUCED_USERNAME="`id -un`" \
PALUDIS_OUTPUTWRAPPER_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/util/`" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
TEST_OUTPUT_WRAPPER="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/util/outputwrapper`" \
SYSCONFDIR="$(sysconfdir)" \
bash $(top_srcdir)/test/run_test.sh bash
diff --git a/src/clients/inquisitio/Makefile.am b/src/clients/inquisitio/Makefile.am
index 9963ab5..08dff5a 100644
--- a/src/clients/inquisitio/Makefile.am
+++ b/src/clients/inquisitio/Makefile.am
@@ -62,6 +62,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_DISTRIBUTIONS_DIR="$(top_srcdir)/paludis/distributions/" \
PALUDIS_DISTRIBUTION="gentoo" \
PALUDIS_REPOSITORY_SO_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories`" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
SYSCONFDIR="$(sysconfdir)" \
bash $(top_srcdir)/test/run_test.sh bash
diff --git a/src/clients/instruo/Makefile.am b/src/clients/instruo/Makefile.am
index 0d5432a..68bcf27 100644
--- a/src/clients/instruo/Makefile.am
+++ b/src/clients/instruo/Makefile.am
@@ -55,6 +55,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_NO_CHOWN="yupyup" \
PALUDIS_REDUCED_USERNAME="`id -un`" \
PALUDIS_OUTPUTWRAPPER_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/util/`" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
TEST_OUTPUT_WRAPPER="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/util/outputwrapper`" \
SYSCONFDIR="$(sysconfdir)" \
bash $(top_srcdir)/test/run_test.sh bash
diff --git a/src/clients/paludis/Makefile.am b/src/clients/paludis/Makefile.am
index 852ecb9..b328c84 100644
--- a/src/clients/paludis/Makefile.am
+++ b/src/clients/paludis/Makefile.am
@@ -71,6 +71,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_REDUCED_USERNAME="`id -un`" \
PALUDIS_OUTPUTWRAPPER_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/util/`" \
PALUDIS_BYPASS_USERPRIV_CHECKS="yes" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
TEST_OUTPUT_WRAPPER="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/util/outputwrapper`" \
SYSCONFDIR="$(sysconfdir)" \
bash $(top_srcdir)/test/run_test.sh bash
diff --git a/src/clients/paludis/do_config.cc b/src/clients/paludis/do_config.cc
index 54685d0..fbd24d4 100644
--- a/src/clients/paludis/do_config.cc
+++ b/src/clients/paludis/do_config.cc
@@ -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
@@ -47,14 +47,20 @@ namespace
};
int
- do_one_config_entry(const std::tr1::shared_ptr<const PackageID> & p)
+ do_one_config_entry(const Environment * const env, const std::tr1::shared_ptr<const PackageID> & p)
{
int return_code(0);
- ConfigAction a;
+ OutputManagerFromEnvironment output_manager_holder(env, p, oe_exclusive);
+ ConfigActionOptions options(make_named_values<ConfigActionOptions>(
+ value_for<n::make_output_manager>(std::tr1::ref(output_manager_holder))
+ ));
+ ConfigAction a(options);
try
{
p->perform_action(a);
+ if (output_manager_holder.output_manager_if_constructed())
+ output_manager_holder.output_manager_if_constructed()->succeeded();
}
catch (const UnsupportedActionError &)
{
@@ -83,7 +89,7 @@ namespace
if (next(entries->begin()) != entries->end())
throw AmbiguousConfigTarget(entries);
- return do_one_config_entry(*entries->begin());
+ return do_one_config_entry(env.get(), *entries->begin());
}
}
diff --git a/src/clients/paludis/info.cc b/src/clients/paludis/info.cc
index 1ad15ba..6eba17a 100644
--- a/src/clients/paludis/info.cc
+++ b/src/clients/paludis/info.cc
@@ -25,6 +25,7 @@
#include <paludis/user_dep_spec.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/simple_visitor_cast.hh>
+#include <paludis/util/make_named_values.hh>
#include <paludis/package_database.hh>
#include <paludis/environment.hh>
#include <paludis/package_id.hh>
@@ -34,6 +35,9 @@
#include <paludis/filter.hh>
#include <paludis/filtered_generator.hh>
#include <paludis/selection.hh>
+#include <paludis/create_output_manager_info.hh>
+#include <paludis/output_manager_from_environment.hh>
+#include <paludis/output_manager.hh>
#include <iostream>
#include <iomanip>
#include <set>
@@ -239,13 +243,21 @@ int do_one_info(
for (PackageIDSequence::ConstIterator p(to_show_entries->begin()), p_end(to_show_entries->end()) ;
p != p_end ; ++p)
{
- InfoAction a;
+ OutputManagerFromEnvironment output_manager_holder(env.get(), *p, oe_exclusive);
+ InfoActionOptions options(make_named_values<InfoActionOptions>(
+ value_for<n::make_output_manager>(std::tr1::ref(output_manager_holder))
+ ));
+ InfoAction a(options);
+
try
{
cout << "Package " << colour(cl_package_name, **p) << ":" << endl;
cout << endl;
(*p)->perform_action(a);
cout << endl;
+
+ if (output_manager_holder.output_manager_if_constructed())
+ output_manager_holder.output_manager_if_constructed()->succeeded();
}
catch (const UnsupportedActionError &)
{
diff --git a/src/clients/reconcilio/Makefile.am b/src/clients/reconcilio/Makefile.am
index 6c4a78c..358a68d 100644
--- a/src/clients/reconcilio/Makefile.am
+++ b/src/clients/reconcilio/Makefile.am
@@ -70,6 +70,8 @@ TESTS_ENVIRONMENT = env \
PALUDIS_NO_CHOWN="yupyup" \
PALUDIS_REDUCED_USERNAME="`id -un`" \
PALUDIS_OUTPUTWRAPPER_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/util/`" \
+ PALUDIS_DEFAULT_OUTPUT_CONF="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/tests_output.conf`" \
+ PALUDIS_OUTPUT_MANAGERS_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments/paludis/output_managers/`" \
TEST_OUTPUT_WRAPPER="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/util/outputwrapper`" \
SYSCONFDIR="$(sysconfdir)" \
bash $(top_srcdir)/test/run_test.sh bash
diff --git a/src/output/console_install_task.cc b/src/output/console_install_task.cc
index 20ce007..d224b08 100644
--- a/src/output/console_install_task.cc
+++ b/src/output/console_install_task.cc
@@ -52,6 +52,9 @@
#include <paludis/filter.hh>
#include <paludis/filtered_generator.hh>
#include <paludis/choice.hh>
+#include <paludis/output_manager_from_environment.hh>
+#include <paludis/output_manager.hh>
+#include <paludis/dep_list.hh>
#include <tr1/functional>
#include <algorithm>
@@ -1260,8 +1263,11 @@ ConsoleInstallTask::display_merge_list_entry_distsize(const DepListEntry & d,
if (! d.package_id()->supports_action(action_test))
return;
- FindDistfilesSize action(fetch_action_options(), _already_downloaded);
+ OutputManagerFromEnvironment output_manager_holder(environment(), d.package_id(), oe_exclusive);
+ FindDistfilesSize action(make_fetch_action_options(d, output_manager_holder), _already_downloaded);
d.package_id()->perform_action(action);
+ if (output_manager_holder.output_manager_if_constructed())
+ output_manager_holder.output_manager_if_constructed()->succeeded();
if (! action.size)
return;
@@ -1519,60 +1525,60 @@ ConsoleInstallTask::on_ambiguous_package_name_error(const AmbiguousPackageNameEr
}
void
-ConsoleInstallTask::on_install_action_error(const InstallActionError & e)
+ConsoleInstallTask::on_install_action_error(const std::tr1::shared_ptr<OutputManager> & output_manager, const InstallActionError & e)
{
- output_stream() << endl;
- output_stream() << "Install error:" << endl;
- output_stream() << " * " << e.backtrace("\n * ");
- output_stream() << e.message() << endl;
- output_stream() << endl;
- output_stream() << endl;
+ output_manager->stdout_stream() << endl;
+ output_manager->stdout_stream() << "Install error:" << endl;
+ output_manager->stdout_stream() << " * " << e.backtrace("\n * ");
+ output_manager->stdout_stream() << e.message() << endl;
+ output_manager->stdout_stream() << endl;
+ output_manager->stdout_stream() << endl;
}
void
-ConsoleInstallTask::on_fetch_action_error(const FetchActionError & e)
+ConsoleInstallTask::on_fetch_action_error(const std::tr1::shared_ptr<OutputManager> & output_manager, const FetchActionError & e)
{
- output_stream() << endl;
- output_stream() << "Fetch error:" << endl;
- output_stream() << " * " << e.backtrace("\n * ");
- output_stream() << e.message() << endl;
- output_stream() << endl;
+ output_manager->stdout_stream() << endl;
+ output_manager->stdout_stream() << "Fetch error:" << endl;
+ output_manager->stdout_stream() << " * " << e.backtrace("\n * ");
+ output_manager->stdout_stream() << e.message() << endl;
+ output_manager->stdout_stream() << endl;
if (e.failures())
{
for (Sequence<FetchActionFailure>::ConstIterator f(e.failures()->begin()), f_end(e.failures()->end()) ;
f != f_end ; ++f)
{
- output_stream() << " * File '" << (*f).target_file() << "': ";
+ output_manager->stdout_stream() << " * File '" << (*f).target_file() << "': ";
bool need_comma(false);
if ((*f).requires_manual_fetching())
{
- output_stream() << "requires manual fetching";
+ output_manager->stdout_stream() << "requires manual fetching";
need_comma = true;
}
if ((*f).failed_automatic_fetching())
{
if (need_comma)
- output_stream() << ", ";
- output_stream() << "failed automatic fetching";
+ output_manager->stdout_stream() << ", ";
+ output_manager->stdout_stream() << "failed automatic fetching";
need_comma = true;
}
if (! (*f).failed_integrity_checks().empty())
{
if (need_comma)
- output_stream() << ", ";
- output_stream() << "failed integrity checks: " << (*f).failed_integrity_checks();
+ output_manager->stdout_stream() << ", ";
+ output_manager->stdout_stream() << "failed integrity checks: " << (*f).failed_integrity_checks();
need_comma = true;
}
- output_stream() << endl;
+ output_manager->stdout_stream() << endl;
}
}
- output_stream() << endl;
+ output_manager->stdout_stream() << endl;
}
void
@@ -1900,31 +1906,31 @@ ConsoleInstallTask::perform_hook(const Hook & hook) const
}
void
-ConsoleInstallTask::on_phase_skip(const std::string & phase)
+ConsoleInstallTask::on_phase_skip(const std::tr1::shared_ptr<OutputManager> & output_manager, const std::string & phase)
{
- output_starred_item("Skipping phase '" + phase + "' as instructed");
+ output_manager->stdout_stream() << "+++ Skipping phase '" + phase + "' as instructed" << endl;
}
void
-ConsoleInstallTask::on_phase_abort(const std::string & phase)
+ConsoleInstallTask::on_phase_abort(const std::tr1::shared_ptr<OutputManager> & output_manager, const std::string & phase)
{
- output_starred_item("Aborting at phase '" + phase + "' as instructed");
+ output_manager->stdout_stream() << "+++ Aborting at phase '" + phase + "' as instructed" << endl;
}
void
-ConsoleInstallTask::on_phase_skip_until(const std::string & phase)
+ConsoleInstallTask::on_phase_skip_until(const std::tr1::shared_ptr<OutputManager> & output_manager, const std::string & phase)
{
- output_starred_item("Skipping phase '" + phase + "' as instructed since it is before a start phase");
+ output_manager->stdout_stream() << "+++ Skipping phase '" + phase + "' as instructed since it is before a start phase" << endl;
}
void
-ConsoleInstallTask::on_phase_proceed_conditionally(const std::string & phase)
+ConsoleInstallTask::on_phase_proceed_conditionally(const std::tr1::shared_ptr<OutputManager> & output_manager, const std::string & phase)
{
- output_starred_item("Executing phase '" + phase + "' as instructed");
+ output_manager->stdout_stream() << "+++ Executing phase '" + phase + "' as instructed" << endl;
}
void
-ConsoleInstallTask::on_phase_proceed_unconditionally(const std::string &)
+ConsoleInstallTask::on_phase_proceed_unconditionally(const std::tr1::shared_ptr<OutputManager> &, const std::string &)
{
}
diff --git a/src/output/console_install_task.hh b/src/output/console_install_task.hh
index 06a9955..5262580 100644
--- a/src/output/console_install_task.hh
+++ b/src/output/console_install_task.hh
@@ -184,8 +184,8 @@ namespace paludis
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 &);
+ virtual void on_install_action_error(const std::tr1::shared_ptr<OutputManager> &, const InstallActionError &);
+ virtual void on_fetch_action_error(const std::tr1::shared_ptr<OutputManager> &, const FetchActionError &);
virtual void on_display_failure_summary_pre();
virtual void on_display_failure_summary_success(const DepListEntry &);
@@ -195,11 +195,11 @@ namespace paludis
virtual void on_display_failure_summary_totals(const int, const int, const int, const int, const int);
virtual void on_display_failure_summary_post();
- virtual void on_phase_skip(const std::string & phase);
- virtual void on_phase_abort(const std::string & phase);
- virtual void on_phase_skip_until(const std::string & phase);
- virtual void on_phase_proceed_conditionally(const std::string & phase);
- virtual void on_phase_proceed_unconditionally(const std::string & phase);
+ virtual void on_phase_skip(const std::tr1::shared_ptr<OutputManager> & output_manager, const std::string & phase);
+ virtual void on_phase_abort(const std::tr1::shared_ptr<OutputManager> & output_manager, const std::string & phase);
+ virtual void on_phase_skip_until(const std::tr1::shared_ptr<OutputManager> & output_manager, const std::string & phase);
+ virtual void on_phase_proceed_conditionally(const std::tr1::shared_ptr<OutputManager> & output_manager, const std::string & phase);
+ virtual void on_phase_proceed_unconditionally(const std::tr1::shared_ptr<OutputManager> & output_manager, const std::string & phase);
///\name More granular display routines
///\{