aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-07-18 10:27:50 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-07-18 10:27:50 +0100
commitb584bf5adb0f3eefb2a2f176f390db2b00befd87 (patch)
tree3fb6079cbce87be68e640ca0408b04d230446e75
parent33b50256a23f195509ffc3a8ce6fc9d629cd550d (diff)
downloadpaludis-b584bf5adb0f3eefb2a2f176f390db2b00befd87.tar.gz
paludis-b584bf5adb0f3eefb2a2f176f390db2b00befd87.tar.xz
Don't load ebuild metadata via stdout
-rw-r--r--paludis/repositories/e/ebuild.cc26
-rw-r--r--paludis/repositories/e/ebuild.hh1
-rw-r--r--paludis/repositories/e/ebuild/0/builtin_metadata.bash4
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/builtin_metadata.bash4
-rw-r--r--paludis/repositories/e/ebuild_id.cc9
-rw-r--r--paludis/repositories/e/ebuild_id.hh1
6 files changed, 33 insertions, 12 deletions
diff --git a/paludis/repositories/e/ebuild.cc b/paludis/repositories/e/ebuild.cc
index 6cdaa83..bf48f0a 100644
--- a/paludis/repositories/e/ebuild.cc
+++ b/paludis/repositories/e/ebuild.cc
@@ -411,17 +411,20 @@ EbuildMetadataCommand::do_run_command(const Command & cmd)
bool ok(false);
keys.reset(new Map<std::string, std::string>);
- std::string input;
try
{
Context context("When running ebuild command to generate metadata for '" + stringify(*params.package_id()) + "':");
- std::stringstream prog, prog_err;
+ std::stringstream prog, prog_err, metadata;
Command real_cmd(cmd);
- int exit_status(run_command(real_cmd.with_captured_stdout_stream(&prog).with_captured_stderr_stream(&prog_err)));
- input.assign((std::istreambuf_iterator<char>(prog)), std::istreambuf_iterator<char>());
- std::stringstream input_stream(input);
- KeyValueConfigFile f(input_stream, KeyValueConfigFileOptions() + kvcfo_disallow_continuations + kvcfo_disallow_comments
+ real_cmd
+ .with_captured_stdout_stream(&prog)
+ .with_captured_stderr_stream(&prog_err)
+ .with_output_stream(&metadata, -1, "PALUDIS_METADATA_FD");
+
+ int exit_status(run_command(real_cmd));
+
+ KeyValueConfigFile f(metadata, KeyValueConfigFileOptions() + kvcfo_disallow_continuations + kvcfo_disallow_comments
+ kvcfo_disallow_space_around_equals + kvcfo_disallow_unquoted_values + kvcfo_disallow_source
+ kvcfo_disallow_variables + kvcfo_preserve_whitespace,
&KeyValueConfigFile::no_defaults, &KeyValueConfigFile::no_transformation);
@@ -430,6 +433,7 @@ EbuildMetadataCommand::do_run_command(const Command & cmd)
if (0 == exit_status)
ok = true;
+ captured_stdout = prog.str();
captured_stderr = prog_err.str();
}
catch (const InternalError &)
@@ -440,7 +444,7 @@ EbuildMetadataCommand::do_run_command(const Command & cmd)
{
Log::get_instance()->message("e.ebuild.cache_failure", ll_warning, lc_context) << "Caught exception '"
<< e.message() << "' (" << e.what() << ") when generating cache for '"
- << *params.package_id() << "', input is '" << purdy(input) << "', stderr is '" << captured_stderr << "'";
+ << *params.package_id() << "'";
}
if (ok)
@@ -448,7 +452,7 @@ EbuildMetadataCommand::do_run_command(const Command & cmd)
else
{
Log::get_instance()->message("e.ebuild.cache_failure", ll_warning, lc_context) << "Could not generate cache for '"
- << *params.package_id() << "' stderr says '" << captured_stderr << "'";
+ << *params.package_id() << "', stdout says '" << captured_stdout << "' and stderr says '" << captured_stderr << "'";
keys.reset(new Map<std::string, std::string>);
keys->insert("EAPI", EAPIData::get_instance()->unknown_eapi()->name());
@@ -480,6 +484,8 @@ EbuildMetadataCommand::load(const std::tr1::shared_ptr<const EbuildID> & id)
Log::get_instance()->message("e.ebuild.preload_eapi.unsupported", ll_debug, lc_context)
<< "ID pre-load EAPI '" << id->eapi()->name() << "' not supported";
+ if (! captured_stdout.empty())
+ id->load_captured_stdout("STDERR", "Captured stdout", mkt_normal, captured_stdout);
if (! captured_stderr.empty())
id->load_captured_stderr("STDERR", "Captured stderr", mkt_normal, captured_stderr);
@@ -499,6 +505,8 @@ EbuildMetadataCommand::load(const std::tr1::shared_ptr<const EbuildID> & id)
{
Log::get_instance()->message("e.ebuild.postload_eapi.unsupported", ll_debug, lc_context)
<< "ID post-load EAPI '" << id->eapi()->name() << "' not supported";
+ if (! captured_stdout.empty())
+ id->load_captured_stdout("STDERR", "Captured stdout", mkt_normal, captured_stdout);
if (! captured_stderr.empty())
id->load_captured_stderr("STDERR", "Captured stderr", mkt_normal, captured_stderr);
return;
@@ -507,6 +515,8 @@ EbuildMetadataCommand::load(const std::tr1::shared_ptr<const EbuildID> & id)
Log::get_instance()->message("e.ebuild.postload_eapi.supported", ll_debug, lc_context)
<< "ID post-load EAPI '" << id->eapi()->name() << "' is supported";
+ if (! captured_stdout.empty())
+ id->load_captured_stdout("STDERR", "Captured stdout", mkt_internal, captured_stdout);
if (! captured_stderr.empty())
id->load_captured_stderr("STDERR", "Captured stderr", mkt_internal, captured_stderr);
diff --git a/paludis/repositories/e/ebuild.hh b/paludis/repositories/e/ebuild.hh
index baa7228..f4ccd74 100644
--- a/paludis/repositories/e/ebuild.hh
+++ b/paludis/repositories/e/ebuild.hh
@@ -725,6 +725,7 @@ namespace paludis
{
private:
std::tr1::shared_ptr<Map<std::string, std::string> > keys;
+ std::string captured_stdout;
std::string captured_stderr;
public:
diff --git a/paludis/repositories/e/ebuild/0/builtin_metadata.bash b/paludis/repositories/e/ebuild/0/builtin_metadata.bash
index c2cb71e..ed17d03 100644
--- a/paludis/repositories/e/ebuild/0/builtin_metadata.bash
+++ b/paludis/repositories/e/ebuild/0/builtin_metadata.bash
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# vim: set sw=4 sts=4 et :
-# Copyright (c) 2006, 2007 Ciaran McCreesh
+# Copyright (c) 2006, 2007, 2010 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
@@ -34,7 +34,7 @@ ebuild_f_metadata()
k=${k//\\/\\\\}
k=${k//\"/\\\"}
k=${k//\$/\\\$}
- echo "${key}=\""${k}"\""
+ echo "${key}=\""${k}"\"" 1>&${PALUDIS_METADATA_FD:-1}
set +o noglob
done
}
diff --git a/paludis/repositories/e/ebuild/exheres-0/builtin_metadata.bash b/paludis/repositories/e/ebuild/exheres-0/builtin_metadata.bash
index 25d8008..eed4357 100644
--- a/paludis/repositories/e/ebuild/exheres-0/builtin_metadata.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/builtin_metadata.bash
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# vim: set sw=4 sts=4 et :
-# Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+# Copyright (c) 2006, 2007, 2008, 2010 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
@@ -34,7 +34,7 @@ exheres_internal_metadata()
k=${k//\\/\\\\}
k=${k//\"/\\\"}
k=${k//\$/\\\$}
- echo "${key}=\""${k}"\""
+ echo "${key}=\""${k}"\"" 1>&${PALUDIS_METADATA_FD:-1}
set +o noglob
done
}
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index d597554..850270a 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -84,6 +84,7 @@ namespace paludis
mutable std::tr1::shared_ptr<const LiteralMetadataValueKey<FSEntry> > fs_location;
mutable std::tr1::shared_ptr<const LiteralMetadataValueKey<std::string> > short_description;
mutable std::tr1::shared_ptr<const LiteralMetadataValueKey<std::string> > long_description;
+ mutable std::tr1::shared_ptr<const LiteralMetadataValueKey<std::string> > captured_stdout_key;
mutable std::tr1::shared_ptr<const LiteralMetadataValueKey<std::string> > captured_stderr_key;
mutable std::tr1::shared_ptr<const EDependenciesKey> raw_dependencies;
mutable std::tr1::shared_ptr<const EDependenciesKey> build_dependencies;
@@ -879,6 +880,14 @@ EbuildID::load_captured_stderr(const std::string & r, const std::string & h, con
}
void
+EbuildID::load_captured_stdout(const std::string & r, const std::string & h, const MetadataKeyType t, const std::string & v) const
+{
+ Lock l(_imp->mutex);
+ _imp->captured_stdout_key.reset(new LiteralMetadataValueKey<std::string> (r, h, t, v));
+ add_metadata_key(_imp->captured_stdout_key);
+}
+
+void
EbuildID::load_short_description(const std::string & r, const std::string & h, const std::string & v) const
{
Lock l(_imp->mutex);
diff --git a/paludis/repositories/e/ebuild_id.hh b/paludis/repositories/e/ebuild_id.hh
index 8ddf0cc..404f63e 100644
--- a/paludis/repositories/e/ebuild_id.hh
+++ b/paludis/repositories/e/ebuild_id.hh
@@ -117,6 +117,7 @@ namespace paludis
std::string guessed_eapi_name() const;
void load_short_description(const std::string &, const std::string &, const std::string &) const;
+ void load_captured_stdout(const std::string &, const std::string &, const MetadataKeyType, const std::string &) const;
void load_captured_stderr(const std::string &, const std::string &, const MetadataKeyType, const std::string &) const;
void load_raw_depend(const std::string &, const std::string &, const std::string &) const;
void load_build_depend(const std::string &, const std::string &, const std::string &,