aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-03-15 16:58:35 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-03-15 16:58:35 +0000
commite1a313c8906a710663cb90657f3945b0e068dd70 (patch)
tree5d4a3e9b7ffc307c6709f6586392ea30e3fe63cb
parentad49b4e5029174059d9149640cd1b506e6c72168 (diff)
downloadpaludis-e1a313c8906a710663cb90657f3945b0e068dd70.tar.gz
paludis-e1a313c8906a710663cb90657f3945b0e068dd70.tar.xz
More install work
-rw-r--r--ebuild/echo_functions.bash2
-rw-r--r--paludis/portage_repository.cc49
-rw-r--r--paludis/util/system.cc25
-rw-r--r--paludis/util/system.hh23
-rw-r--r--paludis/util/system_TEST.cc21
5 files changed, 94 insertions, 26 deletions
diff --git a/ebuild/echo_functions.bash b/ebuild/echo_functions.bash
index 862ca42..6b2859f 100644
--- a/ebuild/echo_functions.bash
+++ b/ebuild/echo_functions.bash
@@ -82,6 +82,6 @@ ebuild_notice()
ebuild_section()
{
- echo ">>> $*" 1>&2
+ echo ">>> $*"
}
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index 1eaf410..cc8c601 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -925,31 +925,32 @@ PortageRepository::do_install(const QualifiedPackageName & q, const VersionSpec
}
}
- std::string cmd(
- "env P='" + stringify(q.get<qpn_package>()) + "-" + stringify(v.remove_revision()) + "' " +
- "PV='" + stringify(v.remove_revision()) + "' " +
- "PR='" + v.revision_only() + "' " +
- "PN='" + stringify(q.get<qpn_package>()) + "' " +
- "PVR='" + stringify(v.remove_revision()) + "-" + v.revision_only() + "' " +
- "PF='" + stringify(q.get<qpn_package>()) + "-" + stringify(v) + "' " +
- "A='" + archives + "' " +
- "FLAT_SRC_URI='" + flat_src_uri + "' " +
- "CATEGORY='" + stringify(q.get<qpn_category>()) + "' " +
- "FILESDIR='" + stringify(_imp->location) + "/" + stringify(q.get<qpn_category>()) + "/" +
- stringify(q.get<qpn_package>()) + "/files/' " +
- "ECLASSDIR='" + stringify(_imp->location) + "/eclass/' " +
- "PORTDIR='" + stringify(_imp->location) + "/' " +
- "DISTDIR='" + stringify(_imp->location) + "/distfiles/' " +
- "PALUDIS_TMPDIR='" BIGTEMPDIR "/paludis/' " +
- "KV='" + kernel_version() + "' " +
- "PALUDIS_EBUILD_LOG_LEVEL='" + log_level_string() + "' " +
- "PALUDIS_EBUILD_DIR='" + getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis") + "' " +
- getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis") +
- "/ebuild.bash '" +
- stringify(_imp->location) + "/" + stringify(q.get<qpn_category>()) + "/" +
+ std::string cmd(make_env_command(
+ getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis") +
+ "/ebuild.bash '" +
+ stringify(_imp->location) + "/" +
+ stringify(q.get<qpn_category>()) + "/" +
stringify(q.get<qpn_package>()) + "/" +
- stringify(q.get<qpn_package>()) + "-" + stringify(v) + ".ebuild' "
- "init fetch setup unpack compile test install preinst merge postinst tidyup");
+ stringify(q.get<qpn_package>()) + "-" + stringify(v) + ".ebuild' " +
+ "init fetch setup unpack compile test install preinst merge postinst tidyup")
+ ("P", stringify(q.get<qpn_package>()) + "-" + stringify(v.remove_revision()))
+ ("PV", stringify(v.remove_revision()))
+ ("PR", v.revision_only())
+ ("PN", stringify(q.get<qpn_package>()))
+ ("PVR", stringify(v.remove_revision()) + "-" + v.revision_only())
+ ("PF", stringify(q.get<qpn_package>()) + "-" + stringify(v))
+ ("A", archives)
+ ("FLAT_SRC_URI", flat_src_uri)
+ ("CATEGORY", stringify(q.get<qpn_category>()))
+ ("FILESDIR", stringify(_imp->location) + "/" + stringify(q.get<qpn_category>()) + "/" +
+ stringify(q.get<qpn_package>()) + "/files/")
+ ("ECLASSDIR", stringify(_imp->location) + "/eclass/")
+ ("PORTDIR", stringify(_imp->location) + "/")
+ ("DISTDIR", stringify(_imp->location) + "/distfiles/")
+ ("PALUDIS_TMPDIR", BIGTEMPDIR "/paludis/")
+ ("KV", kernel_version())
+ ("PALUDIS_EBUILD_LOG_LEVEL", log_level_string())
+ ("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis")));
if (0 != run_command(cmd))
throw InternalError(PALUDIS_HERE, "todo"); /// \todo fixme
diff --git a/paludis/util/system.cc b/paludis/util/system.cc
index 22a4622..441aaa8 100644
--- a/paludis/util/system.cc
+++ b/paludis/util/system.cc
@@ -87,3 +87,28 @@ paludis::run_command(const std::string & cmd)
return status;
}
+system_internals::MakeEnvCommand::MakeEnvCommand(const std::string & c,
+ const std::string & a) :
+ cmd(c),
+ args(a)
+{
+}
+
+system_internals::MakeEnvCommand
+system_internals::MakeEnvCommand::operator() (const std::string & k,
+ const std::string & v) const
+{
+ return MakeEnvCommand(cmd, args + k + "='" + v + "' ");
+}
+
+system_internals::MakeEnvCommand::operator std::string() const
+{
+ return "/usr/bin/env " + args + cmd;
+}
+
+const system_internals::MakeEnvCommand
+paludis::make_env_command(const std::string & cmd)
+{
+ return system_internals::MakeEnvCommand(cmd, "");
+}
+
diff --git a/paludis/util/system.hh b/paludis/util/system.hh
index 0138b98..bbad8da 100644
--- a/paludis/util/system.hh
+++ b/paludis/util/system.hh
@@ -62,6 +62,29 @@ namespace paludis
* Use PStream instead if you need to capture stdout.
*/
int run_command(const std::string & cmd);
+
+ namespace system_internals
+ {
+ class MakeEnvCommand
+ {
+ private:
+ std::string cmd;
+ std::string args;
+
+ public:
+ explicit MakeEnvCommand(const std::string &, const std::string &);
+
+ MakeEnvCommand operator() (const std::string &, const std::string &) const;
+
+ operator std::string() const;
+ };
+ }
+
+ /**
+ * Run a command, with environment.
+ */
+ const system_internals::MakeEnvCommand make_env_command(const std::string & cmd);
}
#endif
+
diff --git a/paludis/util/system_TEST.cc b/paludis/util/system_TEST.cc
index e6d7f0c..ef2f809 100644
--- a/paludis/util/system_TEST.cc
+++ b/paludis/util/system_TEST.cc
@@ -93,7 +93,26 @@ namespace test_cases
void run()
{
TEST_CHECK(0 == run_command("true"));
- TEST_CHECK(0 != run_command("nosuchcommand"));
+ TEST_CHECK(0 != run_command("false"));
}
} test_run_command;
+
+ /**
+ * \test Test make_env_command.
+ *
+ * \ingroup Test
+ */
+ struct MakeEnvCommandTest : TestCase
+ {
+ MakeEnvCommandTest() : TestCase("make_env_command") { }
+
+ void run()
+ {
+ TEST_CHECK(0 != run_command(make_env_command("printenv PALUDUS_TEST_ENV_VAR")));
+ TEST_CHECK(0 == run_command(make_env_command("test -z `printenv PALUDUS_TEST_ENV_VAR`")(
+ "PALUDUS_TEST_ENV_VAR", "")));
+ TEST_CHECK(0 == run_command(make_env_command("test -n `printenv PALUDUS_TEST_ENV_VAR`")(
+ "PALUDUS_TEST_ENV_VAR", "foo")));
+ }
+ } test_make_env_command;
}