aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-05-17 12:45:17 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-05-17 12:45:17 +0000
commit5109758e7332f0704a3e74788d8b59a79e555cad (patch)
treefdf84eb8ac18c18a156109d9425a25759175ef42
parentc4cf902f5610a1a42a27c9a08340ed35e08178a6 (diff)
downloadpaludis-5109758e7332f0704a3e74788d8b59a79e555cad.tar.gz
paludis-5109758e7332f0704a3e74788d8b59a79e555cad.tar.xz
Make layout a configuration key
-rw-r--r--paludis/repositories/gentoo/layout.cc30
-rw-r--r--paludis/repositories/gentoo/layout.hh39
-rw-r--r--paludis/repositories/gentoo/make_ebin_repository.cc5
-rw-r--r--paludis/repositories/gentoo/make_ebuild_repository.cc5
-rw-r--r--paludis/repositories/gentoo/portage_repository.cc5
-rw-r--r--paludis/repositories/gentoo/portage_repository_params.sr1
6 files changed, 82 insertions, 3 deletions
diff --git a/paludis/repositories/gentoo/layout.cc b/paludis/repositories/gentoo/layout.cc
index 55d70fa..e284586 100644
--- a/paludis/repositories/gentoo/layout.cc
+++ b/paludis/repositories/gentoo/layout.cc
@@ -18,12 +18,19 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "layout.hh"
+#include <paludis/repositories/gentoo/layout.hh>
+#include <paludis/repositories/gentoo/traditional_layout.hh>
#include <paludis/util/collection_concrete.hh>
#include <paludis/util/fs_entry.hh>
+#include <paludis/util/virtual_constructor-impl.hh>
using namespace paludis;
+template class VirtualConstructor<std::string,
+ std::tr1::shared_ptr<Layout> (*) (const RepositoryName &, const FSEntry &,
+ std::tr1::shared_ptr<const PortageRepositoryEntries>),
+ virtual_constructor_not_found::ThrowException<NoSuchLayoutType> >;
+
Layout::Layout() :
_profiles_dirs(new FSEntryCollection::Concrete)
{
@@ -51,3 +58,24 @@ Layout::add_profiles_dir(const FSEntry & f)
_profiles_dirs->push_back(f);
}
+namespace
+{
+ template <typename T_>
+ std::tr1::shared_ptr<Layout>
+ make_layout(const RepositoryName & n, const FSEntry & b,
+ std::tr1::shared_ptr<const PortageRepositoryEntries> e)
+ {
+ return std::tr1::shared_ptr<Layout>(new T_(n, b, e));
+ }
+}
+
+LayoutMaker::LayoutMaker()
+{
+ register_maker("traditional", &make_layout<TraditionalLayout>);
+}
+
+NoSuchLayoutType::NoSuchLayoutType(const std::string & format) throw () :
+ ConfigurationError("No available maker for Portage repository layout type '" + format + "'")
+{
+}
+
diff --git a/paludis/repositories/gentoo/layout.hh b/paludis/repositories/gentoo/layout.hh
index 8795518..277054f 100644
--- a/paludis/repositories/gentoo/layout.hh
+++ b/paludis/repositories/gentoo/layout.hh
@@ -25,11 +25,15 @@
#include <paludis/version_spec-fwd.hh>
#include <paludis/util/attributes.hh>
#include <paludis/util/fs_entry-fwd.hh>
+#include <paludis/util/exception.hh>
+#include <paludis/util/virtual_constructor.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <tr1/memory>
namespace paludis
{
+ class PortageRepositoryEntries;
+
class PALUDIS_VISIBLE Layout
{
private:
@@ -97,6 +101,41 @@ namespace paludis
///\}
};
+
+ /**
+ * Thrown if a layout of the specified type does not exist.
+ *
+ * \ingroup grpexceptions
+ * \ingroup grprepository
+ * \nosubgrouping
+ */
+ class PALUDIS_VISIBLE NoSuchLayoutType :
+ public ConfigurationError
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ NoSuchLayoutType(const std::string & format) throw ();
+ };
+
+ /**
+ * Virtual constructor for Layout.
+ *
+ * \ingroup grprepository
+ */
+ class PALUDIS_VISIBLE LayoutMaker :
+ public VirtualConstructor<std::string,
+ std::tr1::shared_ptr<Layout> (*) (const RepositoryName &, const FSEntry &,
+ std::tr1::shared_ptr<const PortageRepositoryEntries>),
+ virtual_constructor_not_found::ThrowException<NoSuchLayoutType> >,
+ public InstantiationPolicy<LayoutMaker, instantiation_method::SingletonTag>
+ {
+ friend class InstantiationPolicy<LayoutMaker, instantiation_method::SingletonTag>;
+
+ private:
+ LayoutMaker();
+ };
}
#endif
diff --git a/paludis/repositories/gentoo/make_ebin_repository.cc b/paludis/repositories/gentoo/make_ebin_repository.cc
index e5a4a7c..4b4ab06 100644
--- a/paludis/repositories/gentoo/make_ebin_repository.cc
+++ b/paludis/repositories/gentoo/make_ebin_repository.cc
@@ -124,6 +124,10 @@ paludis::make_ebin_repository(
if (m->end() != m->find("sync_options"))
sync_options = m->find("sync_options")->second;
+ std::string layout;
+ if (m->end() == m->find("layout") || ((layout = m->find("layout")->second)).empty())
+ layout = "traditional";
+
if (m->end() != m->find("sync_exclude"))
{
Log::get_instance()->message(ll_warning, lc_no_context, "The sync_exclude key in '"
@@ -139,6 +143,7 @@ paludis::make_ebin_repository(
return std::tr1::shared_ptr<PortageRepository>(new PortageRepository(PortageRepositoryParams::create()
.entry_format("ebin")
+ .layout(layout)
.environment(env)
.location(location)
.profiles(profiles)
diff --git a/paludis/repositories/gentoo/make_ebuild_repository.cc b/paludis/repositories/gentoo/make_ebuild_repository.cc
index 8206227..f4c9742 100644
--- a/paludis/repositories/gentoo/make_ebuild_repository.cc
+++ b/paludis/repositories/gentoo/make_ebuild_repository.cc
@@ -165,8 +165,13 @@ paludis::make_ebuild_repository(
if (m->end() == m->find("buildroot") || ((buildroot = m->find("buildroot")->second)).empty())
buildroot = "/var/tmp/paludis";
+ std::string layout;
+ if (m->end() == m->find("layout") || ((layout = m->find("layout")->second)).empty())
+ layout = "traditional";
+
return std::tr1::shared_ptr<PortageRepository>(new PortageRepository(PortageRepositoryParams::create()
.entry_format("ebuild")
+ .layout(layout)
.environment(env)
.location(location)
.profiles(profiles)
diff --git a/paludis/repositories/gentoo/portage_repository.cc b/paludis/repositories/gentoo/portage_repository.cc
index c7e1cf3..2af0879 100644
--- a/paludis/repositories/gentoo/portage_repository.cc
+++ b/paludis/repositories/gentoo/portage_repository.cc
@@ -29,7 +29,6 @@
#include <paludis/repositories/gentoo/portage_virtual_version_metadata.hh>
#include <paludis/repositories/gentoo/use_desc.hh>
#include <paludis/repositories/gentoo/layout.hh>
-#include <paludis/repositories/gentoo/traditional_layout.hh>
#include <paludis/config_file.hh>
#include <paludis/dep_spec.hh>
@@ -140,7 +139,8 @@ namespace paludis
sets_ptr(new PortageRepositorySets(params.environment, r, p)),
entries_ptr(PortageRepositoryEntriesMaker::get_instance()->find_maker(
params.entry_format)(params.environment, r, p)),
- layout(new TraditionalLayout(repo->name(), params.location, entries_ptr))
+ layout(LayoutMaker::get_instance()->find_maker(
+ params.layout)(r->name(), params.location, entries_ptr))
{
if (params.master_repository)
layout->add_profiles_dir(params.master_repository->params().location / "profiles");
@@ -287,6 +287,7 @@ PortageRepository::PortageRepository(const PortageRepositoryParams & p) :
config_info->add_kv("setsdir", stringify(_imp->params.setsdir));
config_info->add_kv("newsdir", stringify(_imp->params.newsdir));
config_info->add_kv("format", _imp->params.entry_format);
+ config_info->add_kv("layout", _imp->params.layout);
config_info->add_kv("buildroot", stringify(_imp->params.buildroot));
config_info->add_kv("sync", _imp->params.sync);
config_info->add_kv("sync_options", _imp->params.sync_options);
diff --git a/paludis/repositories/gentoo/portage_repository_params.sr b/paludis/repositories/gentoo/portage_repository_params.sr
index be90cb6..9b9bb84 100644
--- a/paludis/repositories/gentoo/portage_repository_params.sr
+++ b/paludis/repositories/gentoo/portage_repository_params.sr
@@ -6,6 +6,7 @@ make_class_PortageRepositoryParams()
visible
key entry_format std::string
+ key layout std::string
key environment "Environment *"
key location FSEntry
key profiles "std::tr1::shared_ptr<const FSEntryCollection>"