aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-11-10 16:21:44 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-11-10 16:21:44 +0000
commitbe067ed19d0e19325b6d308a726f1949131cb79d (patch)
treee68d82a1c97daeae279a71694aaa80eceeffff22
parent8e4026aa6b52032e6573c78eeee88edfbba33d6f (diff)
downloadpaludis-be067ed19d0e19325b6d308a726f1949131cb79d.tar.gz
paludis-be067ed19d0e19325b6d308a726f1949131cb79d.tar.xz
Let unwritten repos specify their name
-rw-r--r--paludis/repositories/unwritten/unwritten_repository.cc17
1 files changed, 13 insertions, 4 deletions
diff --git a/paludis/repositories/unwritten/unwritten_repository.cc b/paludis/repositories/unwritten/unwritten_repository.cc
index d6059c8..3d719d2 100644
--- a/paludis/repositories/unwritten/unwritten_repository.cc
+++ b/paludis/repositories/unwritten/unwritten_repository.cc
@@ -27,6 +27,7 @@
#include <paludis/util/make_named_values.hh>
#include <paludis/util/extract_host_from_url.hh>
#include <paludis/util/make_null_shared_ptr.hh>
+#include <paludis/util/fs_stat.hh>
#include <paludis/literal_metadata_key.hh>
#include <paludis/action.hh>
#include <paludis/syncer.hh>
@@ -325,14 +326,22 @@ UnwrittenRepository::repository_factory_create(
{
Context context("When making unwritten repository from repo_file '" + f("repo_file") + "':");
- std::string name_str(f("name"));
- if (name_str.empty())
- name_str = "unwritten";
-
std::string location(f("location"));
if (location.empty())
throw UnwrittenRepositoryConfigurationError("Key 'location' not specified or empty");
+ FSPath location_path(location);
+
+ std::string name_str(f("name"));
+ if (name_str.empty() && location_path.stat().exists())
+ {
+ auto info(UnwrittenRepositoryStore::repository_information(location_path));
+ name_str = info.name();
+ }
+
+ if (name_str.empty())
+ name_str = "x-" + FSPath(f("location")).basename();
+
auto sync(std::make_shared<Map<std::string, std::string> >());
std::vector<std::string> sync_tokens;
tokenise_whitespace(f("sync"), std::back_inserter(sync_tokens));