aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-02-01 00:38:57 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-02-01 00:38:57 +0000
commitbbbe1389d57d3d5be50bf5f3883de194884aacf7 (patch)
tree740cfffc7e2b408d46baec4444d6ef4968595c28
parentd10178c32cc88440c5e9182c87ef0a4a5900c89f (diff)
downloadpaludis-bbbe1389d57d3d5be50bf5f3883de194884aacf7.tar.gz
paludis-bbbe1389d57d3d5be50bf5f3883de194884aacf7.tar.xz
Allow running qualudis from a subdirectory.
-rw-r--r--src/clients/qualudis/qualudis.cc20
-rw-r--r--src/clients/qualudis/qualudis_command_line.cc3
-rw-r--r--src/clients/qualudis/qualudis_command_line.hh3
3 files changed, 25 insertions, 1 deletions
diff --git a/src/clients/qualudis/qualudis.cc b/src/clients/qualudis/qualudis.cc
index 5a05953..8624c34 100644
--- a/src/clients/qualudis/qualudis.cc
+++ b/src/clients/qualudis/qualudis.cc
@@ -55,6 +55,24 @@ namespace
{
};
+ FSEntry
+ get_location()
+ {
+ Context context("When determining tree location:");
+
+ if (QualudisCommandLine::get_instance()->a_repository_directory.specified())
+ return FSEntry(QualudisCommandLine::get_instance()->a_repository_directory.argument());
+
+ if ((FSEntry::cwd() / "profiles").is_directory())
+ return FSEntry::cwd();
+ if ((FSEntry::cwd().dirname() / "profiles").is_directory())
+ return FSEntry::cwd().dirname();
+ if ((FSEntry::cwd().dirname().dirname() / "profiles").is_directory())
+ return FSEntry::cwd().dirname().dirname();
+
+ throw ConfigurationError("Cannot find tree location (try specifying --repository-dir)");
+ }
+
struct MetadataKeyPrettyPrinter :
ConstVisitor<MetadataKeyVisitorTypes>
{
@@ -315,7 +333,7 @@ int main(int argc, char *argv[])
QualudisCommandLine::get_instance()->a_master_repository_dir.set_argument("/var/empty");
tr1::shared_ptr<NoConfigEnvironment> env(new NoConfigEnvironment(no_config_environment::Params::create()
- .repository_dir(FSEntry::cwd())
+ .repository_dir(get_location())
.write_cache(QualudisCommandLine::get_instance()->a_write_cache_dir.argument())
.accept_unstable(false)
.repository_type(no_config_environment::ncer_ebuild)
diff --git a/src/clients/qualudis/qualudis_command_line.cc b/src/clients/qualudis/qualudis_command_line.cc
index 9f31266..a9b4332 100644
--- a/src/clients/qualudis/qualudis_command_line.cc
+++ b/src/clients/qualudis/qualudis_command_line.cc
@@ -54,6 +54,9 @@ QualudisCommandLine::QualudisCommandLine() :
("always", "Always show metadata keys"),
"once"),
+ a_repository_directory(&check_options, "repository-dir", 'D',
+ "Where to find the repository (default: detected from ./ or ../ or ../..)"),
+
configuration_options(this, "Configuration options",
"Options that control general configuration."),
a_write_cache_dir(&configuration_options, "write-cache-dir", '\0',
diff --git a/src/clients/qualudis/qualudis_command_line.hh b/src/clients/qualudis/qualudis_command_line.hh
index 149c2c2..e8ca68e 100644
--- a/src/clients/qualudis/qualudis_command_line.hh
+++ b/src/clients/qualudis/qualudis_command_line.hh
@@ -62,6 +62,9 @@ class QualudisCommandLine :
/// --show-associated-keys
paludis::args::EnumArg a_show_associated_keys;
+ /// --repository-dir
+ paludis::args::StringArg a_repository_directory;
+
///\}
///\name Configuration options