aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Tiziano Müller <dev-zero@gentoo.org> 2009-08-26 21:40:00 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-08-26 21:42:04 +0100
commita9845e708dd034246d5ad1d04dad123f521013cb (patch)
tree9dcddf3c7f8bb594cd5dc920af5a6e074003a56c
parente2395ddc7bd3b00bd6c70f841113010ddeea7a33 (diff)
downloadpaludis-a9845e708dd034246d5ad1d04dad123f521013cb.tar.gz
paludis-a9845e708dd034246d5ad1d04dad123f521013cb.tar.xz
respect root for output managers
Fixes: ticket:778
-rw-r--r--paludis/environments/paludis/bashable_conf.cc28
-rw-r--r--paludis/environments/paludis/bashable_conf.hh4
-rw-r--r--paludis/environments/paludis/output_managers.cc4
-rw-r--r--paludis/environments/paludis/output_managers.hh3
-rw-r--r--paludis/environments/paludis/output_managers/keep_stdout_as_messages.part.conf2
-rw-r--r--paludis/environments/paludis/output_managers/logged_only.part.conf2
-rw-r--r--paludis/environments/paludis/paludis_config.cc6
7 files changed, 40 insertions, 9 deletions
diff --git a/paludis/environments/paludis/bashable_conf.cc b/paludis/environments/paludis/bashable_conf.cc
index f1f6547..43edfca 100644
--- a/paludis/environments/paludis/bashable_conf.cc
+++ b/paludis/environments/paludis/bashable_conf.cc
@@ -24,10 +24,24 @@
#include <paludis/util/stringify.hh>
#include <paludis/util/log.hh>
#include <paludis/util/system.hh>
+#include <paludis/util/map.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
+#include <tr1/functional>
using namespace paludis;
using namespace paludis::paludis_environment;
+std::string defined_vars_to_kv_func(
+ const std::tr1::shared_ptr<const Map<std::string, std::string> > v,
+ const KeyValueConfigFile &,
+ const std::string & k)
+{
+ Map<std::string, std::string>::ConstIterator i(v->find(k));
+ if (i != v->end())
+ return i->second;
+ return "";
+}
+
std::tr1::shared_ptr<LineConfigFile>
paludis::paludis_environment::make_bashable_conf(const FSEntry & f)
{
@@ -60,7 +74,7 @@ paludis::paludis_environment::make_bashable_conf(const FSEntry & f)
}
std::tr1::shared_ptr<KeyValueConfigFile>
-paludis::paludis_environment::make_bashable_kv_conf(const FSEntry & f)
+paludis::paludis_environment::make_bashable_kv_conf(const FSEntry & f, const std::tr1::shared_ptr<const Map<std::string, std::string> > & predefined_variables)
{
Context context("When making a key=value config file out of '" + stringify(f) + "':");
@@ -74,6 +88,9 @@ paludis::paludis_environment::make_bashable_kv_conf(const FSEntry & f)
.with_setenv("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis"))
.with_stderr_prefix(f.basename() + "> ")
.with_captured_stdout_stream(&s));
+ for (Map<std::string, std::string>::ConstIterator i(predefined_variables->begin()),
+ end(predefined_variables->end()); i != end; ++i)
+ cmd.with_setenv(i->first, i->second);
int exit_status(run_command(cmd));
result.reset(new KeyValueConfigFile(s, KeyValueConfigFileOptions(), &KeyValueConfigFile::no_defaults,
&KeyValueConfigFile::no_transformation));
@@ -86,8 +103,15 @@ paludis::paludis_environment::make_bashable_kv_conf(const FSEntry & f)
}
}
else
- result.reset(new KeyValueConfigFile(f, KeyValueConfigFileOptions(), &KeyValueConfigFile::no_defaults,
+ {
+ result.reset(new KeyValueConfigFile(f, KeyValueConfigFileOptions(),
+ std::tr1::bind(
+ &defined_vars_to_kv_func,
+ predefined_variables,
+ std::tr1::placeholders::_1,
+ std::tr1::placeholders::_2),
&KeyValueConfigFile::no_transformation));
+ }
return result;
}
diff --git a/paludis/environments/paludis/bashable_conf.hh b/paludis/environments/paludis/bashable_conf.hh
index 6a6ede1..0b9495b 100644
--- a/paludis/environments/paludis/bashable_conf.hh
+++ b/paludis/environments/paludis/bashable_conf.hh
@@ -22,14 +22,16 @@
#include <paludis/util/fs_entry-fwd.hh>
#include <paludis/util/config_file-fwd.hh>
+#include <paludis/util/map-fwd.hh>
#include <tr1/memory>
+#include <string>
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 &);
+ std::tr1::shared_ptr<KeyValueConfigFile> make_bashable_kv_conf(const FSEntry &, const std::tr1::shared_ptr<const Map<std::string, std::string> > &);
}
}
diff --git a/paludis/environments/paludis/output_managers.cc b/paludis/environments/paludis/output_managers.cc
index cffd707..350da36 100644
--- a/paludis/environments/paludis/output_managers.cc
+++ b/paludis/environments/paludis/output_managers.cc
@@ -71,11 +71,11 @@ OutputManagers::~OutputManagers()
}
void
-OutputManagers::add(const FSEntry & filename)
+OutputManagers::add(const FSEntry & filename, const std::tr1::shared_ptr<const Map<std::string, std::string> > & predefined_variables)
{
Context context("When adding source '" + stringify(filename) + "' as an output manager file:");
- std::tr1::shared_ptr<KeyValueConfigFile> f(make_bashable_kv_conf(filename));
+ std::tr1::shared_ptr<KeyValueConfigFile> f(make_bashable_kv_conf(filename, predefined_variables));
if (! f)
return;
diff --git a/paludis/environments/paludis/output_managers.hh b/paludis/environments/paludis/output_managers.hh
index 80ad723..2c51480 100644
--- a/paludis/environments/paludis/output_managers.hh
+++ b/paludis/environments/paludis/output_managers.hh
@@ -28,6 +28,7 @@
#include <paludis/output_manager-fwd.hh>
#include <paludis/create_output_manager_info-fwd.hh>
#include <tr1/memory>
+#include <string>
namespace paludis
{
@@ -56,7 +57,7 @@ namespace paludis
/**
* Add another file.
*/
- void add(const FSEntry &);
+ void add(const FSEntry &, const std::tr1::shared_ptr<const Map<std::string, std::string> > &);
const std::tr1::shared_ptr<OutputManager> create_named_output_manager(
const std::string &,
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
index 9c0605e..112293f 100644
--- a/paludis/environments/paludis/output_managers/keep_stdout_as_messages.part.conf
+++ b/paludis/environments/paludis/output_managers/keep_stdout_as_messages.part.conf
@@ -1,7 +1,7 @@
# Keep message logs. For use by keep_messages.part; do not use directly.
handler = file
-stdout = /var/log/paludis/%{time}-%{action}-%{full_name}.messages
+stdout = ${root}/var/log/paludis/%{time}-%{action}-%{full_name}.messages
stderr = ${stdout}
keep_on_success = true
keep_on_empty = false
diff --git a/paludis/environments/paludis/output_managers/logged_only.part.conf b/paludis/environments/paludis/output_managers/logged_only.part.conf
index ecbe032..8b0d2b6 100644
--- a/paludis/environments/paludis/output_managers/logged_only.part.conf
+++ b/paludis/environments/paludis/output_managers/logged_only.part.conf
@@ -2,7 +2,7 @@
# not directly usable.
#
handler = file
-stdout = /var/log/paludis/%{time}-%{action}-%{full_name}.out
+stdout = ${root}/var/log/paludis/%{time}-%{action}-%{full_name}.out
stderr = ${stdout}
keep_on_success = false
keep_on_empty = true
diff --git a/paludis/environments/paludis/paludis_config.cc b/paludis/environments/paludis/paludis_config.cc
index 05aff48..cdae60e 100644
--- a/paludis/environments/paludis/paludis_config.cc
+++ b/paludis/environments/paludis/paludis_config.cc
@@ -728,7 +728,11 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
if (! file->exists())
continue;
- _imp->output_managers->add(*file);
+ std::tr1::shared_ptr<Map<std::string, std::string> > predefined_variables(
+ new Map<std::string, std::string>);
+ predefined_variables->insert("root", _imp->root);
+ predefined_variables->insert("ROOT", _imp->root);
+ _imp->output_managers->add(*file, predefined_variables);
any = true;
}