aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-11-06 19:53:51 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-11-06 20:34:59 +0000
commit78fae8c23f0aa4070ed495ced4c4f20434f91c62 (patch)
treeadf844644b946f069e660796b12c65e87554dc9a
parent374a0586092fc10b7d08dba9a2af9fb689758cd4 (diff)
downloadpaludis-78fae8c23f0aa4070ed495ced4c4f20434f91c62.tar.gz
paludis-78fae8c23f0aa4070ed495ced4c4f20434f91c62.tar.xz
unwritten/repository.conf
-rw-r--r--paludis/repositories/unwritten/unwritten_repository.cc5
-rw-r--r--paludis/repositories/unwritten/unwritten_repository_file.cc22
-rw-r--r--paludis/repositories/unwritten/unwritten_repository_file.hh2
-rw-r--r--paludis/repositories/unwritten/unwritten_repository_store.cc53
-rw-r--r--paludis/repositories/unwritten/unwritten_repository_store.hh18
5 files changed, 72 insertions, 28 deletions
diff --git a/paludis/repositories/unwritten/unwritten_repository.cc b/paludis/repositories/unwritten/unwritten_repository.cc
index f3e6823..341fa5b 100644
--- a/paludis/repositories/unwritten/unwritten_repository.cc
+++ b/paludis/repositories/unwritten/unwritten_repository.cc
@@ -339,7 +339,10 @@ UnwrittenRepository::repository_factory_name(
const std::function<std::string (const std::string &)> & f)
{
if (f("name").empty())
- return RepositoryName("unwritten");
+ {
+ UnwrittenRepositoryInformation info(UnwrittenRepositoryStore::repository_information(FSPath(f("location"))));
+ return RepositoryName(info.name());
+ }
else
return RepositoryName(f("name"));
}
diff --git a/paludis/repositories/unwritten/unwritten_repository_file.cc b/paludis/repositories/unwritten/unwritten_repository_file.cc
index cc6d690..01018f6 100644
--- a/paludis/repositories/unwritten/unwritten_repository_file.cc
+++ b/paludis/repositories/unwritten/unwritten_repository_file.cc
@@ -55,12 +55,6 @@ namespace paludis
struct Imp<UnwrittenRepositoryFile>
{
Entries entries;
- bool is_graveyard;
-
- Imp() :
- is_graveyard(false)
- {
- }
};
template <>
@@ -203,16 +197,6 @@ UnwrittenRepositoryFile::_load(const FSPath & f)
throw UnwrittenRepositoryConfigurationError(
"Unsupported format '" + value + "' in '" + stringify(f) + "'");
}
- else if (key == "role")
- {
- if (value == "graveyard")
- _imp->is_graveyard = true;
- else if (value == "unwritten")
- _imp->is_graveyard = false;
- else
- Log::get_instance()->message("unwritten_repository.file.unknown_key", ll_warning, lc_context)
- << "Ignoring unknown key value '" << value << "' for key '" << key << "'";
- }
else
Log::get_instance()->message("unwritten_repository.file.unknown_key", ll_warning, lc_context)
<< "Ignoring unknown key '" << key << "' with value '" << value << "'";
@@ -380,12 +364,6 @@ UnwrittenRepositoryFile::_load(const FSPath & f)
_imp->entries.push_back(*entry);
}
-bool
-UnwrittenRepositoryFile::is_graveyard() const
-{
- return _imp->is_graveyard;
-}
-
template class Pimp<UnwrittenRepositoryFile>;
template class WrappedForwardIterator<UnwrittenRepositoryFile::ConstIteratorTag,
const UnwrittenRepositoryFileEntry>;
diff --git a/paludis/repositories/unwritten/unwritten_repository_file.hh b/paludis/repositories/unwritten/unwritten_repository_file.hh
index aac231f..b206c87 100644
--- a/paludis/repositories/unwritten/unwritten_repository_file.hh
+++ b/paludis/repositories/unwritten/unwritten_repository_file.hh
@@ -81,8 +81,6 @@ namespace paludis
typedef WrappedForwardIterator<ConstIteratorTag, const UnwrittenRepositoryFileEntry> ConstIterator;
ConstIterator begin() const PALUDIS_ATTRIBUTE((warn_unused_result));
ConstIterator end() const PALUDIS_ATTRIBUTE((warn_unused_result));
-
- bool is_graveyard() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
}
diff --git a/paludis/repositories/unwritten/unwritten_repository_store.cc b/paludis/repositories/unwritten/unwritten_repository_store.cc
index d680322..ed93a6e 100644
--- a/paludis/repositories/unwritten/unwritten_repository_store.cc
+++ b/paludis/repositories/unwritten/unwritten_repository_store.cc
@@ -30,6 +30,8 @@
#include <paludis/util/log.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/fs_iterator.hh>
+#include <paludis/util/fs_stat.hh>
+#include <paludis/util/config_file.hh>
#include <paludis/name.hh>
#include <paludis/version_spec.hh>
#include <paludis/literal_metadata_key.hh>
@@ -61,9 +63,13 @@ namespace paludis
mutable PackageNames package_names;
mutable IDs ids;
+ std::string entry_suffix;
+ bool is_graveyard;
+
Imp(const UnwrittenRepository * const r) :
repo(r),
- categories(std::make_shared<CategoryNamePartSet>())
+ categories(std::make_shared<CategoryNamePartSet>()),
+ is_graveyard(false)
{
}
};
@@ -75,6 +81,18 @@ UnwrittenRepositoryStore::UnwrittenRepositoryStore(
const FSPath & f) :
Pimp<UnwrittenRepositoryStore>(repo)
{
+ UnwrittenRepositoryInformation info(repository_information(f));
+ _imp->entry_suffix = info.entry_suffix();
+
+ if (info.role() == "unwritten")
+ {
+ }
+ else if (info.role() == "graveyard")
+ _imp->is_graveyard = true;
+ else
+ Log::get_instance()->message("unwritten_repository.unknown_role", ll_warning, lc_context)
+ << "Role '" << info.role() << "' unknown for '" << f << "'";
+
_populate(env, f);
}
@@ -95,14 +113,14 @@ UnwrittenRepositoryStore::_populate(const Environment * const env, const FSPath
void
UnwrittenRepositoryStore::_populate_one(const Environment * const env, const FSPath & f)
{
- if (! is_file_with_extension(f, ".conf", { }))
+ if (! is_file_with_extension(f, _imp->entry_suffix, { }))
return;
Context context("When populating UnwrittenRepository from file '" + stringify(f) + "':");
UnwrittenRepositoryFile file(f);
- std::shared_ptr<Mask> mask(file.is_graveyard() ?
+ std::shared_ptr<Mask> mask(_imp->is_graveyard ?
std::shared_ptr<Mask>(std::make_shared<GraveyardMask>()) :
std::shared_ptr<Mask>(std::make_shared<UnwrittenMask>()));
@@ -201,5 +219,34 @@ UnwrittenRepositoryStore::package_ids(const QualifiedPackageName & p) const
return i->second;
}
+UnwrittenRepositoryInformation
+UnwrittenRepositoryStore::repository_information(const FSPath & p)
+{
+ UnwrittenRepositoryInformation result(make_named_values<UnwrittenRepositoryInformation>(
+ n::entry_suffix() = ".conf",
+ n::name() = p.basename(),
+ n::role() = "unwritten"
+ ));
+
+ if ((p / "repository.conf").stat().exists())
+ {
+ KeyValueConfigFile file(p / "repository.conf", { },
+ &KeyValueConfigFile::no_defaults, &KeyValueConfigFile::no_transformation);
+
+ if (! file.get("entry_suffix").empty())
+ result.entry_suffix() = "." + file.get("entry_suffix");
+ else
+ result.entry_suffix() = ".unwritten";
+
+ if (! file.get("name").empty())
+ result.name() = file.get("name");
+
+ if (! file.get("role").empty())
+ result.role() = file.get("role");
+ }
+
+ return result;
+}
+
template class Pimp<unwritten_repository::UnwrittenRepositoryStore>;
diff --git a/paludis/repositories/unwritten/unwritten_repository_store.hh b/paludis/repositories/unwritten/unwritten_repository_store.hh
index 3c43d0e..766ee94 100644
--- a/paludis/repositories/unwritten/unwritten_repository_store.hh
+++ b/paludis/repositories/unwritten/unwritten_repository_store.hh
@@ -22,6 +22,7 @@
#include <paludis/util/pimp.hh>
#include <paludis/util/fs_path-fwd.hh>
+#include <paludis/util/named_value.hh>
#include <paludis/name-fwd.hh>
#include <paludis/package_id-fwd.hh>
#include <paludis/environment-fwd.hh>
@@ -29,10 +30,24 @@
namespace paludis
{
+ namespace n
+ {
+ typedef Name<struct entry_suffix_name> entry_suffix;
+ typedef Name<struct name_name> name;
+ typedef Name<struct role_name> role;
+ }
+
namespace unwritten_repository
{
struct UnwrittenRepository;
+ struct UnwrittenRepositoryInformation
+ {
+ NamedValue<n::entry_suffix, std::string> entry_suffix;
+ NamedValue<n::name, std::string> name;
+ NamedValue<n::role, std::string> role;
+ };
+
class PALUDIS_VISIBLE UnwrittenRepositoryStore :
private Pimp<UnwrittenRepositoryStore>
{
@@ -64,6 +79,9 @@ namespace paludis
std::shared_ptr<const PackageIDSequence> package_ids(
const QualifiedPackageName & p) const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ static UnwrittenRepositoryInformation repository_information(
+ const FSPath &) PALUDIS_ATTRIBUTE((warn_unused_result));
};
}