aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-05 15:56:46 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-05 15:56:46 +0000
commit08332bcd420d9accd6928d62504967fbe06b791e (patch)
tree903040bf8a7f03aec1baf12eb72639196a415182
parent1826f9551b5d8a411a301247f885a10a716b0ee3 (diff)
downloadpaludis-08332bcd420d9accd6928d62504967fbe06b791e.tar.gz
paludis-08332bcd420d9accd6928d62504967fbe06b791e.tar.xz
paludis_command voodoo
-rw-r--r--ebuild/builtin_init.bash2
-rw-r--r--ebuild/portage_stubs.bash6
-rw-r--r--paludis/Makefile.am.m41
-rw-r--r--paludis/default_config.cc6
-rw-r--r--paludis/default_config.hh14
-rw-r--r--paludis/default_environment.cc7
-rw-r--r--paludis/default_environment.hh2
-rw-r--r--paludis/environment.hh5
-rw-r--r--paludis/portage_repository.cc2
-rw-r--r--paludis/qa/environment.hh5
-rw-r--r--paludis/test_environment.hh5
-rw-r--r--src/Makefile.am6
-rw-r--r--src/paludis.cc13
13 files changed, 64 insertions, 10 deletions
diff --git a/ebuild/builtin_init.bash b/ebuild/builtin_init.bash
index e735796..73c8b6f 100644
--- a/ebuild/builtin_init.bash
+++ b/ebuild/builtin_init.bash
@@ -22,7 +22,7 @@ builtin_init()
local a
for a in P PV PR PN PVR PF CATEGORY FILESDIR ECLASSDIR PORTDIR \
DISTDIR KV PALUDIS_TMPDIR PALUDIS_EBUILD_LOG_LEVEL PALUDIS_EBUILD_DIR \
- USERLAND KERNEL ARCH CHOST ; do
+ USERLAND KERNEL ARCH CHOST PALUDIS_COMMAND ; do
[[ -z "${!a}" ]] && die "\$${a} unset or empty"
declare -r ${a}="${!a}"
done
diff --git a/ebuild/portage_stubs.bash b/ebuild/portage_stubs.bash
index 6d74d7b..ea59893 100644
--- a/ebuild/portage_stubs.bash
+++ b/ebuild/portage_stubs.bash
@@ -23,8 +23,7 @@
has_version()
{
- # \todo Don't hardcode paludis, config dirs etc
- paludis --has-version "$@"
+ ${PALUDIS_COMMAND} --has-version "$@"
}
portageq()
@@ -51,8 +50,7 @@ portageq()
best_version()
{
- # \todo Don't hardcode paludis, config dirs etc
- paludis --best-version "$@"
+ ${PALUDIS_COMMAND} --best-version "$@"
}
check_KV()
diff --git a/paludis/Makefile.am.m4 b/paludis/Makefile.am.m4
index f86273e..e2e2903 100644
--- a/paludis/Makefile.am.m4
+++ b/paludis/Makefile.am.m4
@@ -47,6 +47,7 @@ TESTS = testlist
TESTS_ENVIRONMENT = env \
PALUDIS_EBUILD_DIR="$(srcdir)/ebuild/" \
+ PALUDIS_SKIP_CONFIG="yes" \
TEST_SCRIPT_DIR="$(srcdir)/" \
$(SHELL) $(top_srcdir)/test/run_test.sh
diff --git a/paludis/default_config.cc b/paludis/default_config.cc
index 5455d3d..e4736a4 100644
--- a/paludis/default_config.cc
+++ b/paludis/default_config.cc
@@ -40,12 +40,16 @@ DefaultConfigError::DefaultConfigError(const std::string & msg) throw () :
{
}
-DefaultConfig::DefaultConfig()
+DefaultConfig::DefaultConfig() :
+ _paludis_command("paludis")
{
_config_suffix_can_be_set = false;
Context context("When loading default configuration:");
+ if (! getenv_with_default("PALUDIS_SKIP_CONFIG", "").empty())
+ return;
+
Tokeniser<delim_kind::AnyOfTag, delim_mode::DelimiterTag> tokeniser(" \t\n");
/* indirection */
diff --git a/paludis/default_config.hh b/paludis/default_config.hh
index 3ec867d..081fee8 100644
--- a/paludis/default_config.hh
+++ b/paludis/default_config.hh
@@ -117,6 +117,7 @@ namespace paludis
private:
static std::string _config_suffix;
static bool _config_suffix_can_be_set;
+ std::string _paludis_command;
std::string _bashrc_files;
@@ -344,6 +345,19 @@ namespace paludis
* Our bashrc files.
*/
std::string bashrc_files() const;
+
+ /**
+ * The paludis command.
+ */
+ std::string paludis_command() const
+ {
+ return _paludis_command;
+ }
+
+ void set_paludis_command(const std::string & s)
+ {
+ _paludis_command = s;
+ }
};
}
diff --git a/paludis/default_environment.cc b/paludis/default_environment.cc
index 9c8e3ad..5d08c31 100644
--- a/paludis/default_environment.cc
+++ b/paludis/default_environment.cc
@@ -216,3 +216,10 @@ DefaultEnvironment::bashrc_files() const
{
return DefaultConfig::get_instance()->bashrc_files();
}
+
+std::string
+DefaultEnvironment::paludis_command() const
+{
+ return DefaultConfig::get_instance()->paludis_command();
+}
+
diff --git a/paludis/default_environment.hh b/paludis/default_environment.hh
index 2c55cb2..c98c139 100644
--- a/paludis/default_environment.hh
+++ b/paludis/default_environment.hh
@@ -58,6 +58,8 @@ namespace paludis
virtual bool query_user_unmasks(const PackageDatabaseEntry &) const;
virtual std::string bashrc_files() const;
+
+ virtual std::string paludis_command() const;
};
}
#endif
diff --git a/paludis/environment.hh b/paludis/environment.hh
index e9fbd74..9db6cc8 100644
--- a/paludis/environment.hh
+++ b/paludis/environment.hh
@@ -94,6 +94,11 @@ namespace paludis
virtual std::string bashrc_files() const = 0;
/**
+ * How to run paludis.
+ */
+ virtual std::string paludis_command() const = 0;
+
+ /**
* Destructor.
*/
virtual ~Environment();
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index 051f07c..7b775e4 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -757,6 +757,7 @@ PortageRepository::do_version_metadata(
("DISTDIR", stringify(_imp->distdir))
("PALUDIS_TMPDIR", BIGTEMPDIR "/paludis/")
("PALUDIS_BASHRC_FILES", _imp->env->bashrc_files())
+ ("PALUDIS_COMMAND", _imp->env->paludis_command())
("KV", kernel_version())
("PALUDIS_EBUILD_LOG_LEVEL", log_level_string())
("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis")));
@@ -1185,6 +1186,7 @@ PortageRepository::do_install(const QualifiedPackageName & q, const VersionSpec
("PALUDIS_CONFIG_DIR", SYSCONFDIR "/paludis/")
("PALUDIS_PROFILE_DIR", _imp->profile)
("PALUDIS_BASHRC_FILES", _imp->env->bashrc_files())
+ ("PALUDIS_COMMAND", _imp->env->paludis_command())
("KV", kernel_version())
("PALUDIS_EBUILD_LOG_LEVEL", log_level_string())
("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis")));
diff --git a/paludis/qa/environment.hh b/paludis/qa/environment.hh
index 08506b3..33950b5 100644
--- a/paludis/qa/environment.hh
+++ b/paludis/qa/environment.hh
@@ -62,6 +62,11 @@ namespace paludis
{
return "";
}
+
+ virtual std::string paludis_command() const
+ {
+ throw InternalError(PALUDIS_HERE, "Cannot use paludis_command in a QA environment");
+ }
};
}
}
diff --git a/paludis/test_environment.hh b/paludis/test_environment.hh
index f41ebb7..1ff5d28 100644
--- a/paludis/test_environment.hh
+++ b/paludis/test_environment.hh
@@ -50,6 +50,11 @@ namespace paludis
{
return "";
}
+
+ virtual std::string paludis_command() const
+ {
+ throw InternalError(PALUDIS_HERE, "Cannot use paludis_command in a test environment");
+ }
};
}
diff --git a/src/Makefile.am b/src/Makefile.am
index b9abd25..deeeaa2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -24,7 +24,11 @@ paludis_LDADD = \
$(top_builddir)/paludis/args/libpaludisargs.a \
$(top_builddir)/paludis/util/libpaludisutil.a
-TESTS_ENVIRONMENT = env TEST_SCRIPT_DIR="$(srcdir)/" $(SHELL) $(top_srcdir)/test/run_test.sh bash
+TESTS_ENVIRONMENT = env \
+ TEST_SCRIPT_DIR="$(srcdir)/" \
+ PALUDIS_SKIP_CONFIG="yes" \
+ $(SHELL) $(top_srcdir)/test/run_test.sh bash
+
TESTS = version_TEST list_sync_formats_TEST list_repository_formats_TEST
version_TEST : paludis
diff --git a/src/paludis.cc b/src/paludis.cc
index 1107b0c..42a06f2 100644
--- a/src/paludis.cc
+++ b/src/paludis.cc
@@ -57,6 +57,9 @@ main(int argc, char *argv[])
if (CommandLine::get_instance()->a_help.specified())
throw DoHelp();
+ if (CommandLine::get_instance()->a_version.specified())
+ throw DoVersion();
+
if (! CommandLine::get_instance()->a_log_level.specified())
p::Log::get_instance()->set_log_level(p::ll_qa);
else if (CommandLine::get_instance()->a_log_level.argument() == "debug")
@@ -71,7 +74,14 @@ main(int argc, char *argv[])
throw DoHelp("bad value for --log-level");
if (CommandLine::get_instance()->a_config_suffix.specified())
+ {
p::DefaultConfig::set_config_suffix(CommandLine::get_instance()->a_config_suffix.argument());
+ p::DefaultConfig::get_instance()->set_paludis_command(
+ std::string(argv[0]) + " --config-suffix " +
+ CommandLine::get_instance()->a_config_suffix.argument());
+ }
+ else
+ p::DefaultConfig::get_instance()->set_paludis_command(std::string(argv[0]));
if (1 != (CommandLine::get_instance()->a_query.specified() +
CommandLine::get_instance()->a_version.specified() +
@@ -107,9 +117,6 @@ main(int argc, char *argv[])
throw DoHelp("you should specify exactly one action");
}
- if (CommandLine::get_instance()->a_version.specified())
- throw DoVersion();
-
if (CommandLine::get_instance()->a_query.specified())
{
if (CommandLine::get_instance()->empty())