aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-05-16 11:03:29 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-05-16 11:03:29 +0000
commitc4cf902f5610a1a42a27c9a08340ed35e08178a6 (patch)
tree193d58900d544a5f63a11c43852d38076cf4dac7
parent8801cefb2d3e916481bc021516663bea9667dc6d (diff)
downloadpaludis-c4cf902f5610a1a42a27c9a08340ed35e08178a6.tar.gz
paludis-c4cf902f5610a1a42a27c9a08340ed35e08178a6.tar.xz
More fwd headers. Split out PortageRepository layout logic
-rw-r--r--paludis/files.m44
-rw-r--r--paludis/name-fwd.hh194
-rw-r--r--paludis/name.hh132
-rw-r--r--paludis/repositories/gentoo/Makefile.am78
-rw-r--r--paludis/repositories/gentoo/ebin_entries.cc15
-rw-r--r--paludis/repositories/gentoo/ebin_entries.hh6
-rw-r--r--paludis/repositories/gentoo/ebuild_entries.cc18
-rw-r--r--paludis/repositories/gentoo/ebuild_entries.hh6
-rw-r--r--paludis/repositories/gentoo/layout.cc53
-rw-r--r--paludis/repositories/gentoo/layout.hh102
-rw-r--r--paludis/repositories/gentoo/portage_repository.cc469
-rw-r--r--paludis/repositories/gentoo/portage_repository.hh7
-rw-r--r--paludis/repositories/gentoo/portage_repository_entries.cc5
-rw-r--r--paludis/repositories/gentoo/portage_repository_entries.hh26
-rw-r--r--paludis/repositories/gentoo/traditional_layout.cc360
-rw-r--r--paludis/repositories/gentoo/traditional_layout.hh83
-rw-r--r--paludis/util/comparison_policy-fwd.hh74
-rw-r--r--paludis/util/comparison_policy.hh29
-rw-r--r--paludis/util/files.m46
-rw-r--r--paludis/util/fs_entry-fwd.hh75
-rw-r--r--paludis/util/fs_entry.hh25
-rw-r--r--paludis/util/validated-fwd.hh37
-rw-r--r--paludis/util/validated.hh14
-rw-r--r--paludis/version_spec-fwd.hh47
-rw-r--r--paludis/version_spec.hh15
25 files changed, 1198 insertions, 682 deletions
diff --git a/paludis/files.m4 b/paludis/files.m4
index be5c631..2a48309 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -24,7 +24,7 @@ add(`hooker', `hh', `cc', `test', `testscript')
add(`host_tuple_name', `hh', `cc', `sr', `test')
add(`mask_reasons', `hh', `cc', `se')
add(`match_package', `hh', `cc')
-add(`name', `hh', `cc', `test', `sr', `se')
+add(`name', `hh', `cc', `fwd', `test', `sr', `se')
add(`package_database', `hh', `cc', `test', `se')
add(`package_database_entry', `hh', `cc', `sr')
add(`paludis', `hh', `cc')
@@ -38,5 +38,5 @@ add(`syncer', `hh', `cc', `sr')
add(`version_metadata', `hh', `cc', `sr')
add(`version_operator', `hh', `cc', `se', `test')
add(`version_requirements', `hh', `cc', `sr')
-add(`version_spec', `hh', `cc', `sr', `test')
+add(`version_spec', `hh', `cc', `sr', `fwd', `test')
diff --git a/paludis/name-fwd.hh b/paludis/name-fwd.hh
new file mode 100644
index 0000000..80ffb4c
--- /dev/null
+++ b/paludis/name-fwd.hh
@@ -0,0 +1,194 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_NAME_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_NAME_FWD_HH 1
+
+#include <paludis/util/validated-fwd.hh>
+#include <paludis/util/collection-fwd.hh>
+#include <paludis/util/attributes.hh>
+#include <string>
+
+namespace paludis
+{
+ class PackageNamePartError;
+ class PackageNamePartValidator;
+
+ /**
+ * A PackageNamePart holds a std::string that is a valid name for the
+ * package part of a QualifiedPackageName.
+ *
+ * \ingroup grpnames
+ */
+ typedef Validated<std::string, PackageNamePartValidator> PackageNamePart;
+
+ /**
+ * Holds a set of PackageNamePart instances.
+ *
+ * \ingroup grpnames
+ */
+ typedef SortedCollection<PackageNamePart> PackageNamePartCollection;
+
+ class CategoryNamePartError;
+ class CategoryNamePartValidator;
+
+ /**
+ * A CategoryNamePart holds a std::string that is a valid name for the
+ * category part of a QualifiedPackageName.
+ *
+ * \ingroup grpnames
+ */
+ typedef Validated<std::string, CategoryNamePartValidator> CategoryNamePart;
+
+ /**
+ * Holds a set of CategoryNamePart instances.
+ *
+ * \ingroup grpnames
+ */
+ typedef SortedCollection<CategoryNamePart> CategoryNamePartCollection;
+
+ class UseFlagNameError;
+ class IUseFlagNameError;
+ class UseFlagNameValidator;
+
+ /**
+ * A UseFlagName holds a std::string that is a valid name for a USE flag.
+ *
+ * \ingroup grpnames
+ */
+ typedef Validated<std::string, UseFlagNameValidator> UseFlagName;
+
+ /**
+ * A collection of UseFlagName instances.
+ *
+ * \ingroup grpnames
+ */
+ typedef SortedCollection<UseFlagName> UseFlagNameCollection;
+
+#include <paludis/name-se.hh>
+
+ class QualifiedPackageName;
+ class IUseFlag;
+
+ /**
+ * Output a QualifiedPackageName to a stream.
+ *
+ * \ingroup grpnames
+ */
+ std::ostream & operator<< (std::ostream &, const QualifiedPackageName &) PALUDIS_VISIBLE;
+
+ /**
+ * Output an IUseFlag to a stream.
+ *
+ * \ingroup grpnames
+ */
+ std::ostream & operator<< (std::ostream &, const IUseFlag &) PALUDIS_VISIBLE;
+
+ /**
+ * Holds a collection of QualifiedPackageName instances.
+ *
+ * \ingroup grpnames
+ */
+ typedef SortedCollection<QualifiedPackageName> QualifiedPackageNameCollection;
+
+ class QualifiedPackageNameError;
+
+ inline const QualifiedPackageName
+ operator+ (const CategoryNamePart & c, const PackageNamePart & p) PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ class SlotNameError;
+ class SlotNameValidator;
+
+ /**
+ * A SlotName holds a std::string that is a valid name for a SLOT.
+ *
+ * \ingroup grpnames
+ */
+ typedef Validated<std::string, SlotNameValidator> SlotName;
+
+ class RepositoryNameError;
+ class RepositoryNameValidator;
+
+ /**
+ * A RepositoryName holds a std::string that is a valid name for a
+ * Repository.
+ *
+ * \ingroup grpnames
+ */
+ typedef Validated<std::string, RepositoryNameValidator, comparison_mode::EqualityComparisonTag> RepositoryName;
+
+ /**
+ * Holds a collection of RepositoryName instances.
+ *
+ * \ingroup grpnames
+ */
+ typedef SequentialCollection<RepositoryName> RepositoryNameCollection;
+
+ class RepositoryNameComparator;
+
+ class KeywordNameValidator;
+ class KeywordNameError;
+
+ /**
+ * A KeywordName holds a std::string that is a valid name for a KEYWORD.
+ *
+ * \ingroup grpnames
+ */
+ typedef Validated<std::string, KeywordNameValidator> KeywordName;
+
+ /**
+ * Holds a collection of KeywordName instances.
+ *
+ * \ingroup grpnames
+ */
+ typedef SortedCollection<KeywordName> KeywordNameCollection;
+
+ class SetNameValidator;
+ class SetNameError;
+
+ /**
+ * A SetName holds a std::string that is a valid name for a set.
+ *
+ * \ingroup grpnames
+ */
+ typedef Validated<std::string, SetNameValidator> SetName;
+
+ /**
+ * A collection of set names.
+ *
+ * \ingroup grpnames
+ */
+ typedef SortedCollection<SetName> SetNameCollection;
+
+ /**
+ * A collection of use flags.
+ *
+ * \ingroup grpnames
+ */
+ typedef SortedCollection<IUseFlag> IUseFlagCollection;
+
+ /**
+ * A collection of inherited packages.
+ *
+ * \ingroup grpnames
+ */
+ typedef SortedCollection<std::string> InheritedCollection;
+}
+
+#endif
diff --git a/paludis/name.hh b/paludis/name.hh
index 95dfc3e..2ca603e 100644
--- a/paludis/name.hh
+++ b/paludis/name.hh
@@ -20,6 +20,7 @@
#ifndef PALUDIS_GUARD_PALUDIS_NAME_HH
#define PALUDIS_GUARD_PALUDIS_NAME_HH 1
+#include <paludis/name-fwd.hh>
#include <paludis/util/collection.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/instantiation_policy.hh>
@@ -70,21 +71,6 @@ namespace paludis
};
/**
- * A PackageNamePart holds a std::string that is a valid name for the
- * package part of a QualifiedPackageName.
- *
- * \ingroup grpnames
- */
- typedef Validated<std::string, PackageNamePartValidator> PackageNamePart;
-
- /**
- * Holds a set of PackageNamePart instances.
- *
- * \ingroup grpnames
- */
- typedef SortedCollection<PackageNamePart> PackageNamePartCollection;
-
- /**
* A CategoryNamePartError is thrown if an invalid value is assigned to
* a CategoryNamePart.
*
@@ -117,21 +103,6 @@ namespace paludis
};
/**
- * A CategoryNamePart holds a std::string that is a valid name for the
- * category part of a QualifiedPackageName.
- *
- * \ingroup grpnames
- */
- typedef Validated<std::string, CategoryNamePartValidator> CategoryNamePart;
-
- /**
- * Holds a set of CategoryNamePart instances.
- *
- * \ingroup grpnames
- */
- typedef SortedCollection<CategoryNamePart> CategoryNamePartCollection;
-
- /**
* A UseFlagNameError is thrown if an invalid value is assigned to
* a UseFlagName.
*
@@ -183,46 +154,9 @@ namespace paludis
static void validate(const std::string &);
};
- /**
- * A UseFlagName holds a std::string that is a valid name for a USE flag.
- *
- * \ingroup grpnames
- */
- typedef Validated<std::string, UseFlagNameValidator> UseFlagName;
-
- /**
- * A collection of UseFlagName instances.
- *
- * \ingroup grpnames
- */
- typedef SortedCollection<UseFlagName> UseFlagNameCollection;
-
-
-#include <paludis/name-se.hh>
#include <paludis/name-sr.hh>
/**
- * Output a QualifiedPackageName to a stream.
- *
- * \ingroup grpnames
- */
- std::ostream & operator<< (std::ostream &, const QualifiedPackageName &) PALUDIS_VISIBLE;
-
- /**
- * Output an IUseFlag to a stream.
- *
- * \ingroup grpnames
- */
- std::ostream & operator<< (std::ostream &, const IUseFlag &) PALUDIS_VISIBLE;
-
- /**
- * Holds a collection of QualifiedPackageName instances.
- *
- * \ingroup grpnames
- */
- typedef SortedCollection<QualifiedPackageName> QualifiedPackageNameCollection;
-
- /**
* A QualifiedPackageNameError may be thrown if an invalid name is
* assigned to a QualifiedPackageName (alternatively, the exception
* raised may be a PackageNamePartError or a CategoryNamePartError).
@@ -284,13 +218,6 @@ namespace paludis
};
/**
- * A SlotName holds a std::string that is a valid name for a SLOT.
- *
- * \ingroup grpnames
- */
- typedef Validated<std::string, SlotNameValidator> SlotName;
-
- /**
* A RepositoryNameError is thrown if an invalid value is assigned to
* a RepositoryName.
*
@@ -323,21 +250,6 @@ namespace paludis
};
/**
- * A RepositoryName holds a std::string that is a valid name for a
- * Repository.
- *
- * \ingroup grpnames
- */
- typedef Validated<std::string, RepositoryNameValidator, comparison_mode::EqualityComparisonTag> RepositoryName;
-
- /**
- * Holds a collection of RepositoryName instances.
- *
- * \ingroup grpnames
- */
- typedef SequentialCollection<RepositoryName> RepositoryNameCollection;
-
- /**
* Arbitrary useless comparator for RepositoryName.
*
* \ingroup grpnames
@@ -386,20 +298,6 @@ namespace paludis
};
/**
- * A KeywordName holds a std::string that is a valid name for a KEYWORD.
- *
- * \ingroup grpnames
- */
- typedef Validated<std::string, KeywordNameValidator> KeywordName;
-
- /**
- * Holds a collection of KeywordName instances.
- *
- * \ingroup grpnames
- */
- typedef SortedCollection<KeywordName> KeywordNameCollection;
-
- /**
* A SetNameValidator handles validation rules for the value of a
* SetName.
*
@@ -430,34 +328,6 @@ namespace paludis
*/
SetNameError(const std::string & name) throw ();
};
-
- /**
- * A SetName holds a std::string that is a valid name for a set.
- *
- * \ingroup grpnames
- */
- typedef Validated<std::string, SetNameValidator> SetName;
-
- /**
- * A collection of set names.
- *
- * \ingroup grpnames
- */
- typedef SortedCollection<SetName> SetNameCollection;
-
- /**
- * A collection of use flags.
- *
- * \ingroup grpnames
- */
- typedef SortedCollection<IUseFlag> IUseFlagCollection;
-
- /**
- * A collection of inherited packages.
- *
- * \ingroup grpnames
- */
- typedef SortedCollection<std::string> InheritedCollection;
}
#endif
diff --git a/paludis/repositories/gentoo/Makefile.am b/paludis/repositories/gentoo/Makefile.am
index 265b817..51bfb9b 100644
--- a/paludis/repositories/gentoo/Makefile.am
+++ b/paludis/repositories/gentoo/Makefile.am
@@ -20,23 +20,6 @@ DEFS= \
paludis_repositories_libdir = $(libdir)/paludis/repositories
-if MONOLITHIC
-
-if ENABLE_GLSA
-
-noinst_LTLIBRARIES = \
- libpaludisgentoorepository.la \
- libpaludisgentoorepositoryxmlthings.la
-
-else
-
-noinst_LTLIBRARIES = \
- libpaludisgentoorepository.la
-
-endif
-
-else
-
paludis_repositories_lib_LTLIBRARIES = libpaludisgentoorepository.la
if ENABLE_GLSA
@@ -45,8 +28,6 @@ lib_LTLIBRARIES = libpaludisgentoorepositoryxmlthings.la
endif
-endif
-
paludis_repositories_gentoo_includedir = $(includedir)/paludis/repositories/gentoo/
libpaludisgentoorepository_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0
@@ -82,7 +63,9 @@ paludis_repositories_gentoo_include_HEADERS = \
vdb_merger-sr.hh \
vdb_merger.hh \
vdb_unmerger-sr.hh \
- vdb_unmerger.hh
+ vdb_unmerger.hh \
+ layout.hh \
+ traditional_layout.hh
libpaludisgentoorepository_la_SOURCES = \
ebuild.cc \
@@ -109,18 +92,10 @@ libpaludisgentoorepository_la_SOURCES = \
vdb_version_metadata.cc \
vdb_merger.cc \
vdb_unmerger.cc \
+ layout.cc \
+ traditional_layout.cc \
$(paludis_repositories_gentoo_include_HEADERS)
-if MONOLITHIC
-
-libpaludisgentoorepository_la_LIBADD = \
- $(top_builddir)/paludis/merger/libpaludismerger.la \
- $(top_builddir)/paludis/digests/libpaludisdigests.la \
- libpaludisgentoorepositoryxmlthings.la \
- $(DYNAMIC_LD_LIBS)
-
-else
-
libpaludisgentoorepository_la_LIBADD = \
$(top_builddir)/paludis/repositories/libpaludisrepositories.la \
$(top_builddir)/paludis/merger/libpaludismerger.la \
@@ -129,12 +104,8 @@ libpaludisgentoorepository_la_LIBADD = \
$(top_builddir)/paludis/util/libpaludisutil.la \
$(DYNAMIC_LD_LIBS)
-endif
-
portage_repository_TEST_SOURCES = portage_repository_TEST.cc
-if MONOLITHIC
-
portage_repository_TEST_LDADD = \
libpaludisgentoorepository.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
@@ -144,19 +115,6 @@ portage_repository_TEST_LDADD = \
$(top_builddir)/test/libtest.a \
$(DYNAMIC_LD_LIBS)
-else
-
-portage_repository_TEST_LDADD = \
- libpaludisgentoorepository.la \
- $(top_builddir)/paludis/util/libpaludisutil.la \
- $(top_builddir)/paludis/util/test_extras.o \
- $(top_builddir)/paludis/libpaludis.la \
- $(top_builddir)/paludis/environments/test/libpaludistestenvironment.la \
- $(top_builddir)/test/libtest.a \
- $(DYNAMIC_LD_LIBS)
-
-endif
-
portage_repository_TEST_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir)
EXTRA_DIST = \
@@ -289,19 +247,10 @@ ebin-se.cc : ebin.se $(top_srcdir)/misc/make_se.bash
libpaludisgentoorepositoryxmlthings_la_SOURCES = xml_things.cc xml_things.hh
libpaludisgentoorepositoryxmlthings_la_CXXFLAGS = $(AM_CXXFLAGS) @LIBXML2DEPS_CFLAGS@
-if MONOLITHIC
-
-libpaludisgentoorepositoryxmlthings_la_LIBADD = @LIBXML2DEPS_LIBS@ \
- $(DYNAMIC_LD_LIBS)
-
-else
-
libpaludisgentoorepositoryxmlthings_la_LIBADD = @LIBXML2DEPS_LIBS@ \
$(top_builddir)/paludis/util/libpaludisutil.la \
$(top_builddir)/paludis/libpaludis.la
-endif
-
libpaludisgentoorepositoryxmlthings_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0
if ENABLE_GLSA
@@ -309,21 +258,6 @@ if ENABLE_GLSA
GLSA_TESTS = xml_things_TEST
xml_things_TEST_SOURCES = xml_things_TEST.cc
-if MONOLITHIC
-
-xml_things_TEST_LDADD = \
- $(top_builddir)/paludis/util/test_extras.o \
- $(top_builddir)/test/libtest.a \
- libpaludisgentoorepository.la \
- $(top_builddir)/paludis/libpaludis.la \
- $(top_builddir)/paludis/environments/test/libpaludistestenvironment.la \
- $(top_builddir)/test/libtest.a \
- libpaludisgentoorepositoryxmlthings.la \
- $(top_builddir)/paludis/util/libpaludisutil.la \
- $(DYNAMIC_LD_LIBS)
-
-else
-
xml_things_TEST_LDADD = \
$(top_builddir)/paludis/util/test_extras.o \
$(top_builddir)/test/libtest.a \
@@ -336,8 +270,6 @@ xml_things_TEST_LDADD = \
endif
-endif
-
TESTS = portage_repository_TEST $(GLSA_TESTS)
check_PROGRAMS = $(TESTS)
diff --git a/paludis/repositories/gentoo/ebin_entries.cc b/paludis/repositories/gentoo/ebin_entries.cc
index b3e0d70..8a7bd83 100644
--- a/paludis/repositories/gentoo/ebin_entries.cc
+++ b/paludis/repositories/gentoo/ebin_entries.cc
@@ -28,6 +28,7 @@
#include <paludis/util/log.hh>
#include <paludis/util/system.hh>
#include <paludis/util/join.hh>
+#include <paludis/util/is_file_with_extension.hh>
#include <paludis/dep_spec_pretty_printer.hh>
#include <set>
#include <fstream>
@@ -55,7 +56,6 @@ namespace paludis
EbinEntries::EbinEntries(
const Environment * const e, PortageRepository * const p, const PortageRepositoryParams & k) :
- PortageRepositoryEntries(".ebin"),
PrivateImplementationPattern<EbinEntries>(new Implementation<EbinEntries>(e, p, k))
{
}
@@ -447,3 +447,16 @@ EbinEntries::merge(const MergeOptions & m)
ebin_file_name.rename(real_ebin_file_name);
}
+bool
+EbinEntries::is_package_file(const QualifiedPackageName & n, const FSEntry & e) const
+{
+ return is_file_with_prefix_extension(e, stringify(n.package) + "-", ".ebin", IsFileWithOptions());
+}
+
+VersionSpec
+EbinEntries::extract_package_file_version(const QualifiedPackageName & n, const FSEntry & e) const
+{
+ Context context("When extracting version from '" + stringify(e) + "':");
+ return VersionSpec(strip_leading_string(strip_trailing_string(e.basename(), ".ebin"), stringify(n.package) + "-"));
+}
+
diff --git a/paludis/repositories/gentoo/ebin_entries.hh b/paludis/repositories/gentoo/ebin_entries.hh
index b1c2ffe..b21e0b0 100644
--- a/paludis/repositories/gentoo/ebin_entries.hh
+++ b/paludis/repositories/gentoo/ebin_entries.hh
@@ -67,6 +67,12 @@ namespace paludis
const InstallOptions &, std::tr1::shared_ptr<const PortageRepositoryProfile>) const;
virtual void merge(const MergeOptions &);
+
+ virtual bool is_package_file(const QualifiedPackageName &, const FSEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual VersionSpec extract_package_file_version(const QualifiedPackageName &, const FSEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
};
}
diff --git a/paludis/repositories/gentoo/ebuild_entries.cc b/paludis/repositories/gentoo/ebuild_entries.cc
index c203000..9bfadf0 100644
--- a/paludis/repositories/gentoo/ebuild_entries.cc
+++ b/paludis/repositories/gentoo/ebuild_entries.cc
@@ -32,6 +32,7 @@
#include <paludis/util/strip.hh>
#include <paludis/util/tokeniser.hh>
#include <paludis/util/system.hh>
+#include <paludis/util/is_file_with_extension.hh>
#include <fstream>
#include <list>
@@ -77,9 +78,7 @@ namespace paludis
EbuildEntries::EbuildEntries(
const Environment * const e, PortageRepository * const p, const PortageRepositoryParams & k) :
- PortageRepositoryEntries(".ebuild"),
- PrivateImplementationPattern<EbuildEntries>(new
- Implementation<EbuildEntries>(e, p, k))
+ PrivateImplementationPattern<EbuildEntries>(new Implementation<EbuildEntries>(e, p, k))
{
}
@@ -665,3 +664,16 @@ EbuildEntries::merge(const MergeOptions &)
throw InternalError(PALUDIS_HERE, "Cannot merge to PortageRepository with ebuild entries");
}
+bool
+EbuildEntries::is_package_file(const QualifiedPackageName & n, const FSEntry & e) const
+{
+ return is_file_with_prefix_extension(e, stringify(n.package) + "-", ".ebuild", IsFileWithOptions());
+}
+
+VersionSpec
+EbuildEntries::extract_package_file_version(const QualifiedPackageName & n, const FSEntry & e) const
+{
+ Context context("When extracting version from '" + stringify(e) + "':");
+ return VersionSpec(strip_leading_string(strip_trailing_string(e.basename(), ".ebuild"), stringify(n.package) + "-"));
+}
+
diff --git a/paludis/repositories/gentoo/ebuild_entries.hh b/paludis/repositories/gentoo/ebuild_entries.hh
index 4e51f0f..0614302 100644
--- a/paludis/repositories/gentoo/ebuild_entries.hh
+++ b/paludis/repositories/gentoo/ebuild_entries.hh
@@ -73,6 +73,12 @@ namespace paludis
const InstallOptions &, std::tr1::shared_ptr<const PortageRepositoryProfile>) const;
virtual void merge(const MergeOptions &) PALUDIS_ATTRIBUTE((noreturn));
+
+ virtual bool is_package_file(const QualifiedPackageName &, const FSEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual VersionSpec extract_package_file_version(const QualifiedPackageName &, const FSEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
};
}
diff --git a/paludis/repositories/gentoo/layout.cc b/paludis/repositories/gentoo/layout.cc
new file mode 100644
index 0000000..55d70fa
--- /dev/null
+++ b/paludis/repositories/gentoo/layout.cc
@@ -0,0 +1,53 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006 Danny van Dyk <kugelfang@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "layout.hh"
+#include <paludis/util/collection_concrete.hh>
+#include <paludis/util/fs_entry.hh>
+
+using namespace paludis;
+
+Layout::Layout() :
+ _profiles_dirs(new FSEntryCollection::Concrete)
+{
+}
+
+Layout::~Layout()
+{
+}
+
+Layout::ProfilesDirsIterator
+Layout::begin_profiles_dirs() const
+{
+ return ProfilesDirsIterator(_profiles_dirs->begin());
+}
+
+Layout::ProfilesDirsIterator
+Layout::end_profiles_dirs() const
+{
+ return ProfilesDirsIterator(_profiles_dirs->end());
+}
+
+void
+Layout::add_profiles_dir(const FSEntry & f)
+{
+ _profiles_dirs->push_back(f);
+}
+
diff --git a/paludis/repositories/gentoo/layout.hh b/paludis/repositories/gentoo/layout.hh
new file mode 100644
index 0000000..8795518
--- /dev/null
+++ b/paludis/repositories/gentoo/layout.hh
@@ -0,0 +1,102 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006 Danny van Dyk <kugelfang@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_GENTOO_LAYOUT_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_GENTOO_LAYOUT_HH 1
+
+#include <paludis/name-fwd.hh>
+#include <paludis/version_spec-fwd.hh>
+#include <paludis/util/attributes.hh>
+#include <paludis/util/fs_entry-fwd.hh>
+#include <libwrapiter/libwrapiter_forward_iterator.hh>
+#include <tr1/memory>
+
+namespace paludis
+{
+ class PALUDIS_VISIBLE Layout
+ {
+ private:
+ std::tr1::shared_ptr<FSEntryCollection> _profiles_dirs;
+
+ protected:
+ Layout();
+
+ public:
+ ///\name Basic operations
+ ///\{
+
+ virtual ~Layout() = 0;
+
+ ///\}
+
+ ///\name Configuration options
+ ///\{
+
+ void add_profiles_dir(const FSEntry &);
+
+ typedef libwrapiter::ForwardIterator<Layout, const FSEntry> ProfilesDirsIterator;
+ ProfilesDirsIterator begin_profiles_dirs() const;
+ ProfilesDirsIterator end_profiles_dirs() const;
+
+ ///\}
+
+ ///\name Layout operations
+ ///\{
+
+ virtual bool has_category_named(const CategoryNamePart &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual bool has_package_named(const QualifiedPackageName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual std::tr1::shared_ptr<const CategoryNamePartCollection> category_names() const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual std::tr1::shared_ptr<const QualifiedPackageNameCollection> package_names(
+ const CategoryNamePart &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual std::tr1::shared_ptr<const VersionSpecCollection> version_specs(
+ const QualifiedPackageName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual bool has_version(const QualifiedPackageName &, const VersionSpec &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual FSEntry package_mask_file(const FSEntry & dir) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual FSEntry arch_list_file(const FSEntry & dir) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual FSEntry mirrors_file(const FSEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual FSEntry info_packages_file(const FSEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual FSEntry info_variables_file(const FSEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ ///\}
+ };
+}
+
+#endif
diff --git a/paludis/repositories/gentoo/portage_repository.cc b/paludis/repositories/gentoo/portage_repository.cc
index ea14efc..c7e1cf3 100644
--- a/paludis/repositories/gentoo/portage_repository.cc
+++ b/paludis/repositories/gentoo/portage_repository.cc
@@ -28,6 +28,8 @@
#include <paludis/repositories/gentoo/portage_repository_entries.hh>
#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>
@@ -75,32 +77,16 @@
using namespace paludis;
+typedef MakeHashedMap<QualifiedPackageName, std::list<std::tr1::shared_ptr<const PackageDepSpec> > >::Type RepositoryMaskMap;
+typedef MakeHashedMap<QualifiedPackageName, bool>::Type PackagesMap;
+typedef MakeHashedMultiMap<std::string, std::string>::Type MirrorMap;
+typedef MakeHashedMap<std::pair<QualifiedPackageName, VersionSpec>,
+ std::tr1::shared_ptr<VersionMetadata> >::Type MetadataMap;
+typedef MakeHashedMap<QualifiedPackageName, std::tr1::shared_ptr<const PackageDepSpec> >::Type VirtualsMap;
+typedef std::list<RepositoryPortageInterface::ProfilesDescLine> ProfilesDesc;
+
namespace paludis
{
- /// Map for versions.
- typedef MakeHashedMap<QualifiedPackageName, std::tr1::shared_ptr<VersionSpecCollection> >::Type VersionsMap;
-
- /// Map for repository masks.
- typedef MakeHashedMap<QualifiedPackageName, std::list<std::tr1::shared_ptr<const PackageDepSpec> > >::Type RepositoryMaskMap;
-
- /// Map for categories.
- typedef MakeHashedMap<CategoryNamePart, bool>::Type CategoryMap;
-
- /// Map for packages.
- typedef MakeHashedMap<QualifiedPackageName, bool>::Type PackagesMap;
-
- /// Map for mirrors.
- typedef MakeHashedMultiMap<std::string, std::string>::Type MirrorMap;
-
- /// Map for metadata.
- typedef MakeHashedMap<std::pair<QualifiedPackageName, VersionSpec>,
- std::tr1::shared_ptr<VersionMetadata> >::Type MetadataMap;
-
- /// Map for virtuals.
- typedef MakeHashedMap<QualifiedPackageName, std::tr1::shared_ptr<const PackageDepSpec> >::Type VirtualsMap;
-
- typedef std::list<RepositoryPortageInterface::ProfilesDescLine> ProfilesDesc;
-
/**
* Implementation data for a PortageRepository.
*
@@ -109,109 +95,58 @@ namespace paludis
template <>
struct Implementation<PortageRepository>
{
- /// Our parameters
+ PortageRepository * const repo;
const PortageRepositoryParams params;
- /// Have we loaded our category names?
- mutable bool has_category_names;
-
- /// Our category names, and whether we have a fully loaded list
- /// of package names for that category.
- mutable CategoryMap category_names;
-
- /// Our package names, and whether we have a fully loaded list of
- /// version specs for that category.
- mutable PackagesMap package_names;
-
- /// Our version specs for each package.
- mutable VersionsMap version_specs;
-
- /// Metadata cache.
mutable MetadataMap metadata;
+ std::tr1::shared_ptr<RepositoryNameCache> names_cache;
- /// Repository mask.
mutable RepositoryMaskMap repo_mask;
-
- /// Have repository mask?
mutable bool has_repo_mask;
- /// Have virtual names?
- mutable bool has_virtuals;
+ mutable VirtualsMap our_virtuals;
+ const std::map<QualifiedPackageName, QualifiedPackageName> provide_map;
- /// Arch flags
mutable std::tr1::shared_ptr<UseFlagNameCollection> arch_flags;
- /// Do we have mirrors?
mutable bool has_mirrors;
-
- /// Mirrors.
mutable MirrorMap mirrors;
- /// Constructor.
- Implementation(PortageRepository * const, const PortageRepositoryParams &);
-
- /// Destructor.
- ~Implementation();
-
- /// (Empty) provides map.
- const std::map<QualifiedPackageName, QualifiedPackageName> provide_map;
-
- /// Load profiles, if we haven't already.
- inline void need_profiles() const;
-
- void need_profiles_desc() const;
+ mutable bool has_profiles_desc;
+ mutable ProfilesDesc profiles_desc;
+ mutable std::list<std::tr1::shared_ptr<UseDesc> > use_desc;
- /// Our profile handler.
mutable std::tr1::shared_ptr<PortageRepositoryProfile> profile_ptr;
-
- std::list<FSEntry> profiles_dir_locations;
-
- /// Our news handler.
mutable std::tr1::shared_ptr<PortageRepositoryNews> news_ptr;
-
- /// Our sets handler.
mutable std::tr1::shared_ptr<PortageRepositorySets> sets_ptr;
-
- /// Our metadata handler.
mutable std::tr1::shared_ptr<PortageRepositoryEntries> entries_ptr;
+ mutable std::tr1::shared_ptr<Layout> layout;
- /// Our virtuals
- mutable VirtualsMap our_virtuals;
-
- /// Have we loaded our virtuals?
- bool has_our_virtuals;
-
- mutable bool has_profiles_desc;
-
- mutable ProfilesDesc profiles_desc;
-
- std::tr1::shared_ptr<RepositoryNameCache> names_cache;
-
- mutable std::list<std::tr1::shared_ptr<UseDesc> > use_desc;
+ Implementation(PortageRepository * const, const PortageRepositoryParams &);
+ ~Implementation();
- PortageRepository * const repo;
+ void need_profiles() const;
+ void need_profiles_desc() const;
};
Implementation<PortageRepository>::Implementation(PortageRepository * const r,
const PortageRepositoryParams & p) :
+ repo(r),
params(p),
- has_category_names(false),
+ names_cache(new RepositoryNameCache(p.names_cache, r)),
has_repo_mask(false),
- has_virtuals(false),
has_mirrors(false),
+ has_profiles_desc(false),
sets_ptr(new PortageRepositorySets(params.environment, r, p)),
entries_ptr(PortageRepositoryEntriesMaker::get_instance()->find_maker(
params.entry_format)(params.environment, r, p)),
- has_our_virtuals(false),
- has_profiles_desc(false),
- names_cache(new RepositoryNameCache(p.names_cache, r)),
- repo(r)
+ layout(new TraditionalLayout(repo->name(), params.location, entries_ptr))
{
if (params.master_repository)
- profiles_dir_locations.push_back(params.master_repository->params().location / "profiles");
+ layout->add_profiles_dir(params.master_repository->params().location / "profiles");
if ((params.location / "profiles").exists())
- profiles_dir_locations.push_back(params.location / "profiles");
+ layout->add_profiles_dir(params.location / "profiles");
}
Implementation<PortageRepository>::~Implementation()
@@ -237,8 +172,8 @@ namespace paludis
Context context("When loading profiles.desc:");
bool found_one(false);
- for (std::list<FSEntry>::const_iterator p(profiles_dir_locations.begin()),
- p_end(profiles_dir_locations.end()) ; p != p_end ; ++p)
+ for (Layout::ProfilesDirsIterator p(layout->begin_profiles_dirs()), p_end(layout->end_profiles_dirs()) ;
+ p != p_end ; ++p)
{
if (! (*p / "profiles.desc").exists())
continue;
@@ -272,8 +207,46 @@ namespace paludis
}
}
+namespace
+{
+ RepositoryName
+ fetch_repo_name(const FSEntry & tree_root)
+ {
+ try
+ {
+ do
+ {
+ FSEntry name_file(tree_root);
+ name_file /= "profiles";
+ name_file /= "repo_name";
+
+ if (! name_file.is_regular_file())
+ break;
+
+ LineConfigFile f(name_file, LineConfigFileOptions());
+ if (f.begin() == f.end())
+ break;
+ return RepositoryName(*f.begin());
+
+ } while (false);
+ }
+ catch (...)
+ {
+ }
+
+ std::string modified_location(tree_root.basename());
+ std::replace(modified_location.begin(), modified_location.end(), '/', '-');
+
+ Log::get_instance()->message(ll_qa, lc_no_context, "Couldn't open repo_name file in '"
+ + stringify(tree_root) + "/profiles/', falling back to generated name 'x-" + modified_location +
+ "' (ignore this message if you have yet to sync this repository).");
+
+ return RepositoryName("x-" + modified_location);
+ }
+}
+
PortageRepository::PortageRepository(const PortageRepositoryParams & p) :
- Repository(PortageRepository::fetch_repo_name(stringify(p.location)),
+ Repository(fetch_repo_name(p.location),
RepositoryCapabilities::create()
.mask_interface(this)
.installable_interface(this)
@@ -330,44 +303,13 @@ PortageRepository::~PortageRepository()
bool
PortageRepository::do_has_category_named(const CategoryNamePart & c) const
{
- Context context("When checking for category '" + stringify(c) +
- "' in " + stringify(name()) + ":");
-
- need_category_names();
- return _imp->category_names.end() !=
- _imp->category_names.find(c);
+ return _imp->layout->has_category_named(c);
}
bool
PortageRepository::do_has_package_named(const QualifiedPackageName & q) const
{
- Context context("When checking for package '" + stringify(q) + "' in " +
- stringify(name()) + ":");
-
- need_category_names();
-
- CategoryMap::iterator cat_iter(_imp->category_names.find(q.category));
-
- if (_imp->category_names.end() == cat_iter)
- return false;
-
- if (cat_iter->second)
- return _imp->package_names.find(q) !=
- _imp->package_names.end();
- else
- {
- if (_imp->package_names.find(q) !=
- _imp->package_names.end())
- return true;
-
- FSEntry fs(_imp->params.location);
- fs /= stringify(q.category);
- fs /= stringify(q.package);
- if (! fs.is_directory_or_symlink_to_directory())
- return false;
- _imp->package_names.insert(std::make_pair(q, false));
- return true;
- }
+ return _imp->layout->has_package_named(q);
}
namespace
@@ -400,251 +342,36 @@ namespace
std::tr1::shared_ptr<const CategoryNamePartCollection>
PortageRepository::do_category_names() const
{
- Context context("When fetching category names in " + stringify(name()) + ":");
-
- need_category_names();
-
- std::tr1::shared_ptr<CategoryNamePartCollection> result(new CategoryNamePartCollection::Concrete);
- CategoryMap::const_iterator i(_imp->category_names.begin()),
- i_end(_imp->category_names.end());
- for ( ; i != i_end ; ++i)
- result->insert(i->first);
- return result;
+ return _imp->layout->category_names();
}
std::tr1::shared_ptr<const QualifiedPackageNameCollection>
PortageRepository::do_package_names(const CategoryNamePart & c) const
{
- using namespace std::tr1::placeholders;
-
- /* this isn't particularly fast because it isn't called very often. avoid
- * changing the data structures used to make this faster at the expense of
- * slowing down single item queries. */
-
- Context context("When fetching package names in category '" + stringify(c)
- + "' in " + stringify(name()) + ":");
-
- need_category_names();
-
- if (_imp->category_names.end() == _imp->category_names.find(c))
- return std::tr1::shared_ptr<QualifiedPackageNameCollection>(new QualifiedPackageNameCollection::Concrete);
-
- if ((_imp->params.location / stringify(c)).is_directory_or_symlink_to_directory())
- for (DirIterator d(_imp->params.location / stringify(c)), d_end ; d != d_end ; ++d)
- {
- if (! d->is_directory_or_symlink_to_directory())
- continue;
- if (DirIterator() == std::find_if(DirIterator(*d), DirIterator(),
- std::tr1::bind(&is_file_with_extension, _1, _imp->entries_ptr->file_extension(), IsFileWithOptions())))
- continue;
-
- try
- {
- _imp->package_names.insert(std::make_pair(c + PackageNamePart(d->basename()), false));
- }
- catch (const NameError & e)
- {
- Log::get_instance()->message(ll_warning, lc_context, "Skipping entry '" +
- d->basename() + "' in category '" + stringify(c) + "' in repository '"
- + stringify(name()) + "' (" + e.message() + ")");
- }
- }
-
- _imp->category_names[c] = true;
-
- std::tr1::shared_ptr<QualifiedPackageNameCollection> result(new QualifiedPackageNameCollection::Concrete);
-
- std::copy(_imp->package_names.begin(), _imp->package_names.end(),
- transform_inserter(filter_inserter(result->inserter(), CategoryFilter(c)),
- SelectFirst<const QualifiedPackageName, bool>()));
-
- return result;
+ return _imp->layout->package_names(c);
}
std::tr1::shared_ptr<const VersionSpecCollection>
PortageRepository::do_version_specs(const QualifiedPackageName & n) const
{
- Context context("When fetching versions of '" + stringify(n) + "' in "
- + stringify(name()) + ":");
-
- if (has_package_named(n))
- {
- need_version_names(n);
- return _imp->version_specs.find(n)->second;
- }
- else
- return std::tr1::shared_ptr<VersionSpecCollection>(new VersionSpecCollection::Concrete);
+ return _imp->layout->version_specs(n);
}
bool
PortageRepository::do_has_version(const QualifiedPackageName & q,
const VersionSpec & v) const
{
- Context context("When checking for version '" + stringify(v) + "' in '"
- + stringify(q) + "' in " + stringify(name()) + ":");
-
- if (has_package_named(q))
- {
- need_version_names(q);
- std::tr1::shared_ptr<VersionSpecCollection> vv(_imp->version_specs.find(q)->second);
- return vv->end() != vv->find(v);
- }
- else
- return false;
-}
-
-void
-PortageRepository::need_category_names() const
-{
- if (_imp->has_category_names)
- return;
-
- Context context("When loading category names for " + stringify(name()) + ":");
-
- Log::get_instance()->message(ll_debug, lc_context, "need_category_names");
-
- bool found_one(false);
-
- for (std::list<FSEntry>::const_iterator p(_imp->profiles_dir_locations.begin()),
- p_end(_imp->profiles_dir_locations.end()) ; p != p_end ; ++p)
- {
- if (! (*p / "categories").exists())
- continue;
-
- LineConfigFile cats(*p / "categories", LineConfigFileOptions());
-
- for (LineConfigFile::Iterator line(cats.begin()), line_end(cats.end()) ;
- line != line_end ; ++line)
- {
- try
- {
- _imp->category_names.insert(std::make_pair(CategoryNamePart(*line), false));
- }
- catch (const NameError & e)
- {
- Log::get_instance()->message(ll_warning, lc_context, "Skipping line '"
- + *line + "' in '" + stringify(*p / "categories") + "' due to exception '"
- + stringify(e.message()) + "' ('" + e.what() + ")");
- }
- }
-
- found_one = true;
- }
-
- if (! found_one)
- {
- Log::get_instance()->message(ll_qa, lc_context, "No categories file for repository at '"
- + stringify(_imp->params.location) + "', faking it");
- for (DirIterator d(_imp->params.location), d_end ; d != d_end ; ++d)
- {
- if (! d->is_directory_or_symlink_to_directory())
- continue;
-
- std::string n(d->basename());
- if (n == "CVS" || n == "distfiles" || n == "scripts" || n == "eclass" || n == "licences"
- || n == "packages")
- continue;
-
- try
- {
- _imp->category_names.insert(std::make_pair(CategoryNamePart(n), false));
- }
- catch (const NameError &)
- {
- }
- }
- }
-
- _imp->has_category_names = true;
-}
-
-void
-PortageRepository::need_version_names(const QualifiedPackageName & n) const
-{
- if (_imp->package_names[n])
- return;
-
- Context context("When loading versions for '" + stringify(n) + "' in "
- + stringify(name()) + ":");
-
- std::tr1::shared_ptr<VersionSpecCollection> v(new VersionSpecCollection::Concrete);
-
- FSEntry path(_imp->params.location / stringify(n.category) /
- stringify(n.package));
-
- for (DirIterator e(path), e_end ; e != e_end ; ++e)
- {
- if (! is_file_with_prefix_extension(*e, stringify(n.package) + "-", _imp->entries_ptr->file_extension(),
- IsFileWithOptions()))
- continue;
-
- try
- {
- if (! v->insert(VersionSpec(strip_leading_string(
- strip_trailing_string(e->basename(), _imp->entries_ptr->file_extension()),
- stringify(n.package) + "-"))))
- Log::get_instance()->message(ll_warning, lc_context, "Ignoring entry '" + stringify(*e)
- + "' for '" + stringify(n) + "' in repository '" + stringify(name())
- + "' because another equivalent version already exists");
- }
- catch (const Exception & ee)
- {
- Log::get_instance()->message(ll_warning, lc_context, "Skipping entry '"
- + stringify(*e) + "' for '" + stringify(n) + "' in repository '"
- + stringify(name()) + "' due to exception '" + ee.message() + "' ("
- + ee.what() + ")'");
- }
- }
-
- _imp->version_specs.insert(std::make_pair(n, v));
- _imp->package_names[n] = true;
-}
-
-RepositoryName
-PortageRepository::fetch_repo_name(const std::string & location)
-{
- try
- {
- do
- {
- FSEntry name_file(location);
- name_file /= "profiles";
- name_file /= "repo_name";
-
- if (! name_file.is_regular_file())
- break;
-
- LineConfigFile f(name_file, LineConfigFileOptions());
- if (f.begin() == f.end())
- break;
- return RepositoryName(*f.begin());
-
- } while (false);
- }
- catch (...)
- {
- }
-
- std::string modified_location(FSEntry(location).basename());
- std::replace(modified_location.begin(), modified_location.end(), '/', '-');
-
- Log::get_instance()->message(ll_qa, lc_no_context, "Couldn't open repo_name file in '"
- + location + "/profiles/', falling back to generated name 'x-" + modified_location +
- "' (ignore this message if you have yet to sync this repository).");
-
- return RepositoryName("x-" + modified_location);
+ return _imp->layout->has_version(q, v);
}
std::tr1::shared_ptr<const VersionMetadata>
PortageRepository::do_version_metadata(
const QualifiedPackageName & q, const VersionSpec & v) const
{
- if (_imp->metadata.end() != _imp->metadata.find(
- std::make_pair(q, v)))
+ if (_imp->metadata.end() != _imp->metadata.find(std::make_pair(q, v)))
return _imp->metadata.find(std::make_pair(q, v))->second;
- Context context("When fetching metadata for '" + stringify(q) +
- "-" + stringify(v) + "':");
+ Context context("When fetching metadata for '" + stringify(q) + "-" + stringify(v) + "':");
if (! has_version(q, v))
throw NoSuchPackageError(stringify(PackageDatabaseEntry(q, v, name())));
@@ -662,10 +389,10 @@ PortageRepository::do_query_repository_masks(const QualifiedPackageName & q, con
Context context("When querying repository mask for '" + stringify(q) + "-"
+ stringify(v) + "':");
- for (std::list<FSEntry>::const_iterator p(_imp->profiles_dir_locations.begin()),
- p_end(_imp->profiles_dir_locations.end()) ; p != p_end ; ++p)
+ for (Layout::ProfilesDirsIterator p(_imp->layout->begin_profiles_dirs()), p_end(_imp->layout->end_profiles_dirs()) ;
+ p != p_end ; ++p)
{
- FSEntry fff(*p / "package.mask");
+ FSEntry fff(_imp->layout->package_mask_file(*p));
Context context_local("When reading '" + stringify(fff) + "':");
if (fff.exists())
@@ -680,13 +407,13 @@ PortageRepository::do_query_repository_masks(const QualifiedPackageName & q, con
if (a->package_ptr())
_imp->repo_mask[*a->package_ptr()].push_back(a);
else
- Log::get_instance()->message(ll_warning, lc_context, "Loading package.mask spec '"
+ Log::get_instance()->message(ll_warning, lc_context, "Loading package mask spec '"
+ stringify(*line) + "' failed because specification does not restrict to a "
"unique package");
}
catch (const Exception & e)
{
- Log::get_instance()->message(ll_warning, lc_context, "Loading package.mask spec '"
+ Log::get_instance()->message(ll_warning, lc_context, "Loading package mask spec '"
+ stringify(*line) + "' failed due to exception '" + e.message() + "' ("
+ e.what() + ")");
}
@@ -748,10 +475,10 @@ PortageRepository::do_arch_flags() const
_imp->arch_flags.reset(new UseFlagNameCollection::Concrete);
bool found_one(false);
- for (std::list<FSEntry>::const_iterator p(_imp->profiles_dir_locations.begin()),
- p_end(_imp->profiles_dir_locations.end()) ; p != p_end ; ++p)
+ for (Layout::ProfilesDirsIterator p(_imp->layout->begin_profiles_dirs()), p_end(_imp->layout->end_profiles_dirs()) ;
+ p != p_end ; ++p)
{
- FSEntry a(*p / "arch.list");
+ FSEntry a(_imp->layout->arch_list_file(*p));
if (! a.exists())
continue;
@@ -777,8 +504,7 @@ PortageRepository::do_license_exists(const std::string & license) const
if (_imp->params.master_repository)
{
- FSEntry l(_imp->params.master_repository->params().location /
- "licenses" / license);
+ FSEntry l(_imp->params.master_repository->params().location / "licenses" / license);
if (l.exists() && l.is_regular_file_or_symlink_to_regular_file())
p.reset(new FSEntry(l));
}
@@ -796,12 +522,12 @@ PortageRepository::need_mirrors() const
if (! _imp->has_mirrors)
{
bool found_one(false);
- for (std::list<FSEntry>::const_iterator p(_imp->profiles_dir_locations.begin()),
- p_end(_imp->profiles_dir_locations.end()) ; p != p_end ; ++p)
+ for (Layout::ProfilesDirsIterator p(_imp->layout->begin_profiles_dirs()), p_end(_imp->layout->end_profiles_dirs()) ;
+ p != p_end ; ++p)
{
- if ((*p / "thirdpartymirrors").exists())
+ if (_imp->layout->mirrors_file(*p).exists())
{
- LineConfigFile mirrors(*p / "thirdpartymirrors", LineConfigFileOptions());
+ LineConfigFile mirrors(_imp->layout->mirrors_file(*p), LineConfigFileOptions());
for (LineConfigFile::Iterator line(mirrors.begin()) ; line != mirrors.end() ; ++line)
{
std::vector<std::string> entries;
@@ -888,7 +614,7 @@ PortageRepository::do_sync() const
continue;
}
- ok=true;
+ ok = true;
break;
}
@@ -942,9 +668,9 @@ PortageRepository::info(bool verbose) const
// don't inherit from master_repository, just causes clutter
std::set<std::string> info_pkgs;
- if ((_imp->params.location / "profiles" / "info_pkgs").exists())
+ if ((_imp->layout->info_packages_file(_imp->params.location / "profiles")).exists())
{
- LineConfigFile vars(_imp->params.location / "profiles" / "info_pkgs", LineConfigFileOptions());
+ LineConfigFile vars(_imp->layout->info_packages_file(_imp->params.location / "profiles"), LineConfigFileOptions());
info_pkgs.insert(vars.begin(), vars.end());
}
@@ -977,9 +703,9 @@ PortageRepository::info(bool verbose) const
// don't inherit from master_repository, just causes clutter
std::set<std::string> info_vars;
- if ((_imp->params.location / "profiles" / "info_vars").exists())
+ if (_imp->layout->info_variables_file(_imp->params.location / "profiles").exists())
{
- LineConfigFile vars(_imp->params.location / "profiles" / "info_vars", LineConfigFileOptions());
+ LineConfigFile vars(_imp->layout->info_variables_file(_imp->params.location / "profiles"), LineConfigFileOptions());
info_vars.insert(vars.begin(), vars.end());
}
@@ -1036,7 +762,6 @@ PortageRepository::virtual_packages() const
+ stringify(name()) + "'");
_imp->need_profiles();
- need_category_names();
std::tr1::shared_ptr<VirtualsCollection> result(new VirtualsCollection::Concrete);
@@ -1214,8 +939,8 @@ PortageRepository::do_describe_use_flag(const UseFlagName & f,
const PackageDatabaseEntry & e) const
{
if (_imp->use_desc.empty())
- for (std::list<FSEntry>::const_iterator p(_imp->profiles_dir_locations.begin()),
- p_end(_imp->profiles_dir_locations.end()) ; p != p_end ; ++p)
+ for (Layout::ProfilesDirsIterator p(_imp->layout->begin_profiles_dirs()), p_end(_imp->layout->end_profiles_dirs()) ;
+ p != p_end ; ++p)
_imp->use_desc.push_back(std::tr1::shared_ptr<UseDesc>(new UseDesc(*p)));
std::string result;
diff --git a/paludis/repositories/gentoo/portage_repository.hh b/paludis/repositories/gentoo/portage_repository.hh
index 416e582..e7895b6 100644
--- a/paludis/repositories/gentoo/portage_repository.hh
+++ b/paludis/repositories/gentoo/portage_repository.hh
@@ -63,18 +63,11 @@ namespace paludis
private PrivateImplementationPattern<PortageRepository>
{
private:
- void need_category_names() const;
- void need_version_names(const QualifiedPackageName &) const;
void need_mirrors() const;
PackageDatabaseEntryCollection::Iterator find_best(PackageDatabaseEntryCollection & c,
const PackageDatabaseEntry & e) const;
protected:
- /**
- * Try to get the repository name for a particular repository.
- */
- static RepositoryName fetch_repo_name(const std::string & location);
-
virtual bool do_has_category_named(const CategoryNamePart &) const;
virtual bool do_has_package_named(const QualifiedPackageName &) const;
diff --git a/paludis/repositories/gentoo/portage_repository_entries.cc b/paludis/repositories/gentoo/portage_repository_entries.cc
index 1928e21..75a58ab 100644
--- a/paludis/repositories/gentoo/portage_repository_entries.cc
+++ b/paludis/repositories/gentoo/portage_repository_entries.cc
@@ -29,11 +29,6 @@ template class VirtualConstructor<std::string,
const PortageRepositoryParams &),
virtual_constructor_not_found::ThrowException<NoSuchPortageRepositoryEntriesType> >;
-PortageRepositoryEntries::PortageRepositoryEntries(const std::string & ext) :
- _ext(ext)
-{
-}
-
PortageRepositoryEntries::~PortageRepositoryEntries()
{
}
diff --git a/paludis/repositories/gentoo/portage_repository_entries.hh b/paludis/repositories/gentoo/portage_repository_entries.hh
index 77400f1..b73a61b 100644
--- a/paludis/repositories/gentoo/portage_repository_entries.hh
+++ b/paludis/repositories/gentoo/portage_repository_entries.hh
@@ -49,33 +49,19 @@ namespace paludis
*/
class PALUDIS_VISIBLE PortageRepositoryEntries
{
- private:
- const std::string _ext;
-
- protected:
- ///\name Basic operations
- ///\{
-
- /// Constructor, with our file extension
- PortageRepositoryEntries(const std::string & ext);
-
- ///\}
-
public:
///\name Basic operations
///\{
- virtual ~PortageRepositoryEntries();
+ virtual ~PortageRepositoryEntries() = 0;
///\}
- /**
- * Return our file extension, including the dot.
- */
- std::string file_extension() const
- {
- return _ext;
- }
+ virtual bool is_package_file(const QualifiedPackageName &, const FSEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual VersionSpec extract_package_file_version(const QualifiedPackageName &, const FSEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
* Generate version metadata.
diff --git a/paludis/repositories/gentoo/traditional_layout.cc b/paludis/repositories/gentoo/traditional_layout.cc
new file mode 100644
index 0000000..626ed4a
--- /dev/null
+++ b/paludis/repositories/gentoo/traditional_layout.cc
@@ -0,0 +1,360 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006 Danny van Dyk <kugelfang@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/repositories/gentoo/traditional_layout.hh>
+#include <paludis/repositories/gentoo/portage_repository_entries.hh>
+#include <paludis/config_file.hh>
+#include <paludis/hashed_containers.hh>
+#include <paludis/util/dir_iterator.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/collection_concrete.hh>
+#include <paludis/util/is_file_with_extension.hh>
+#include <paludis/util/iterator.hh>
+#include <paludis/util/strip.hh>
+
+#include <tr1/functional>
+#include <functional>
+#include <algorithm>
+
+using namespace paludis;
+
+typedef MakeHashedMap<CategoryNamePart, bool>::Type CategoryMap;
+typedef MakeHashedMap<QualifiedPackageName, bool>::Type PackagesMap;
+typedef MakeHashedMap<QualifiedPackageName, std::tr1::shared_ptr<VersionSpecCollection> >::Type VersionsMap;
+
+namespace paludis
+{
+ template<>
+ struct Implementation<TraditionalLayout>
+ {
+ const RepositoryName name;
+ const FSEntry tree_root;
+
+ mutable bool has_category_names;
+ mutable CategoryMap category_names;
+ mutable PackagesMap package_names;
+ mutable VersionsMap version_specs;
+
+ mutable std::tr1::shared_ptr<CategoryNamePartCollection> category_names_collection;
+ std::tr1::shared_ptr<const PortageRepositoryEntries> entries;
+
+ Implementation(const RepositoryName & n, const FSEntry & t,
+ std::tr1::shared_ptr<const PortageRepositoryEntries> e) :
+ name(n),
+ tree_root(t),
+ has_category_names(false),
+ entries(e)
+ {
+ }
+ };
+}
+
+TraditionalLayout::TraditionalLayout(const RepositoryName & name, const FSEntry & tree_root,
+ std::tr1::shared_ptr<const PortageRepositoryEntries> e) :
+ PrivateImplementationPattern<TraditionalLayout>(new Implementation<TraditionalLayout>(name, tree_root, e))
+{
+}
+
+TraditionalLayout::~TraditionalLayout()
+{
+}
+
+void
+TraditionalLayout::need_category_names() const
+{
+ if (_imp->has_category_names)
+ return;
+
+ Context context("When loading category names for " + stringify(_imp->name) + ":");
+
+ Log::get_instance()->message(ll_debug, lc_context, "need_category_names");
+
+ bool found_one(false);
+
+ for (ProfilesDirsIterator p(begin_profiles_dirs()), p_end(end_profiles_dirs()) ;
+ p != p_end ; ++p)
+ {
+ if (! (*p / "categories").exists())
+ continue;
+
+ LineConfigFile cats(*p / "categories", LineConfigFileOptions());
+
+ for (LineConfigFile::Iterator line(cats.begin()), line_end(cats.end()) ;
+ line != line_end ; ++line)
+ {
+ try
+ {
+ _imp->category_names.insert(std::make_pair(CategoryNamePart(*line), false));
+ }
+ catch (const NameError & e)
+ {
+ Log::get_instance()->message(ll_warning, lc_context, "Skipping line '"
+ + *line + "' in '" + stringify(*p / "categories") + "' due to exception '"
+ + stringify(e.message()) + "' ('" + e.what() + ")");
+ }
+ }
+
+ found_one = true;
+ }
+
+ if (! found_one)
+ {
+ Log::get_instance()->message(ll_qa, lc_context, "No categories file for repository at '"
+ + stringify(_imp->tree_root) + "', faking it");
+ for (DirIterator d(_imp->tree_root), d_end ; d != d_end ; ++d)
+ {
+ if (! d->is_directory_or_symlink_to_directory())
+ continue;
+
+ std::string n(d->basename());
+ if (n == "CVS" || n == "distfiles" || n == "scripts" || n == "eclass" || n == "licences"
+ || n == "packages")
+ continue;
+
+ try
+ {
+ _imp->category_names.insert(std::make_pair(CategoryNamePart(n), false));
+ }
+ catch (const NameError &)
+ {
+ }
+ }
+ }
+
+ _imp->has_category_names = true;
+}
+
+void
+TraditionalLayout::need_version_specs(const QualifiedPackageName & n) const
+{
+ if (_imp->package_names[n])
+ return;
+
+ Context context("When loading versions for '" + stringify(n) + "' in "
+ + stringify(_imp->name) + ":");
+
+ std::tr1::shared_ptr<VersionSpecCollection> v(new VersionSpecCollection::Concrete);
+
+ FSEntry path(_imp->tree_root / stringify(n.category) / stringify(n.package));
+
+ for (DirIterator e(path), e_end ; e != e_end ; ++e)
+ {
+ if (! _imp->entries->is_package_file(n, *e))
+ continue;
+
+ try
+ {
+ if (! v->insert(VersionSpec(_imp->entries->extract_package_file_version(n, *e))))
+ Log::get_instance()->message(ll_warning, lc_context, "Ignoring entry '" + stringify(*e)
+ + "' for '" + stringify(n) + "' in repository '" + stringify(_imp->name)
+ + "' because another equivalent version already exists");
+ }
+ catch (const Exception & ee)
+ {
+ Log::get_instance()->message(ll_warning, lc_context, "Skipping entry '"
+ + stringify(*e) + "' for '" + stringify(n) + "' in repository '"
+ + stringify(_imp->name) + "' due to exception '" + ee.message() + "' ("
+ + ee.what() + ")'");
+ }
+ }
+
+ _imp->version_specs.insert(std::make_pair(n, v));
+ _imp->package_names[n] = true;
+}
+
+bool
+TraditionalLayout::has_category_named(const CategoryNamePart & c) const
+{
+ Context context("When checking for category '" + stringify(c) + "' in '" + stringify(_imp->name) + "':");
+
+ need_category_names();
+ return _imp->category_names.end() != _imp->category_names.find(c);
+}
+
+bool
+TraditionalLayout::has_package_named(const QualifiedPackageName & q) const
+{
+ Context context("When checking for package '" + stringify(q) + "' in '" + stringify(_imp->name) + ":");
+
+ need_category_names();
+
+ CategoryMap::iterator cat_iter(_imp->category_names.find(q.category));
+
+ if (_imp->category_names.end() == cat_iter)
+ return false;
+
+ if (cat_iter->second)
+ {
+ /* this category's package names are fully loaded */
+ return _imp->package_names.find(q) != _imp->package_names.end();
+ }
+ else
+ {
+ /* package names are only partially loaded or not loaded */
+ if (_imp->package_names.find(q) != _imp->package_names.end())
+ return true;
+
+ FSEntry fs(_imp->tree_root);
+ fs /= stringify(q.category);
+ fs /= stringify(q.package);
+ if (! fs.is_directory_or_symlink_to_directory())
+ return false;
+ _imp->package_names.insert(std::make_pair(q, false));
+ return true;
+ }
+}
+
+void
+TraditionalLayout::need_category_names_collection() const
+{
+ if (_imp->category_names_collection)
+ return;
+
+ need_category_names();
+
+ _imp->category_names_collection.reset(new CategoryNamePartCollection::Concrete);
+ std::copy(_imp->category_names.begin(), _imp->category_names.end(),
+ transform_inserter(_imp->category_names_collection->inserter(),
+ SelectFirst<const CategoryNamePart, bool>()));
+}
+
+std::tr1::shared_ptr<const CategoryNamePartCollection>
+TraditionalLayout::category_names() const
+{
+ Context context("When fetching category names in " + stringify(stringify(_imp->name)) + ":");
+
+ need_category_names_collection();
+ return _imp->category_names_collection;
+}
+
+std::tr1::shared_ptr<const QualifiedPackageNameCollection>
+TraditionalLayout::package_names(const CategoryNamePart & c) const
+{
+ using namespace std::tr1::placeholders;
+
+ /* this isn't particularly fast because it isn't called very often. avoid
+ * changing the data structures used to make this faster at the expense of
+ * slowing down single item queries. */
+
+ Context context("When fetching package names in category '" + stringify(c)
+ + "' in " + stringify(_imp->name) + ":");
+
+ need_category_names();
+
+ if (_imp->category_names.end() == _imp->category_names.find(c))
+ return std::tr1::shared_ptr<QualifiedPackageNameCollection>(new QualifiedPackageNameCollection::Concrete);
+
+ if ((_imp->tree_root / stringify(c)).is_directory_or_symlink_to_directory())
+ for (DirIterator d(_imp->tree_root / stringify(c)), d_end ; d != d_end ; ++d)
+ {
+ try
+ {
+ if (! d->is_directory_or_symlink_to_directory())
+ continue;
+
+ if (DirIterator() == std::find_if(DirIterator(*d), DirIterator(),
+ std::tr1::bind(&PortageRepositoryEntries::is_package_file, _imp->entries.get(),
+ c + PackageNamePart(d->basename()), _1)))
+ continue;
+
+ _imp->package_names.insert(std::make_pair(c + PackageNamePart(d->basename()), false));
+ }
+ catch (const NameError & e)
+ {
+ Log::get_instance()->message(ll_warning, lc_context, "Skipping entry '" +
+ d->basename() + "' in category '" + stringify(c) + "' in repository '"
+ + stringify(_imp->name) + "' (" + e.message() + ")");
+ }
+ }
+
+ _imp->category_names[c] = true;
+
+ std::tr1::shared_ptr<QualifiedPackageNameCollection> result(new QualifiedPackageNameCollection::Concrete);
+
+ std::copy(_imp->package_names.begin(), _imp->package_names.end(),
+ transform_inserter(filter_inserter(result->inserter(),
+ std::tr1::bind(std::equal_to<CategoryNamePart>(), c,
+ std::tr1::bind(SelectMember<const QualifiedPackageName, CategoryNamePart, &QualifiedPackageName::category>(), _1))),
+ SelectFirst<const QualifiedPackageName, bool>()));
+
+ return result;
+}
+
+std::tr1::shared_ptr<const VersionSpecCollection>
+TraditionalLayout::version_specs(const QualifiedPackageName & n) const
+{
+ Context context("When fetching versions of '" + stringify(n) + "' in " + stringify(_imp->name) + ":");
+
+ if (has_package_named(n))
+ {
+ need_version_specs(n);
+ return _imp->version_specs.find(n)->second;
+ }
+ else
+ return std::tr1::shared_ptr<VersionSpecCollection>(new VersionSpecCollection::Concrete);
+}
+
+bool
+TraditionalLayout::has_version(const QualifiedPackageName & q, const VersionSpec & v) const
+{
+ Context context("When checking for version '" + stringify(v) + "' in '"
+ + stringify(q) + "' in " + stringify(_imp->name) + ":");
+
+ if (has_package_named(q))
+ {
+ need_version_specs(q);
+ std::tr1::shared_ptr<VersionSpecCollection> vv(_imp->version_specs.find(q)->second);
+ return vv->end() != vv->find(v);
+ }
+ else
+ return false;
+}
+
+FSEntry
+TraditionalLayout::package_mask_file(const FSEntry & dir) const
+{
+ return dir / "package.mask";
+}
+
+FSEntry
+TraditionalLayout::arch_list_file(const FSEntry & dir) const
+{
+ return dir / "arch.list";
+}
+
+FSEntry
+TraditionalLayout::mirrors_file(const FSEntry & dir) const
+{
+ return dir / "thirdpartymirrors";
+}
+
+FSEntry
+TraditionalLayout::info_packages_file(const FSEntry & dir) const
+{
+ return dir / "info_pkgs";
+}
+
+FSEntry
+TraditionalLayout::info_variables_file(const FSEntry & dir) const
+{
+ return dir / "info_vars";
+}
+
diff --git a/paludis/repositories/gentoo/traditional_layout.hh b/paludis/repositories/gentoo/traditional_layout.hh
new file mode 100644
index 0000000..df9ade6
--- /dev/null
+++ b/paludis/repositories/gentoo/traditional_layout.hh
@@ -0,0 +1,83 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006 Danny van Dyk <kugelfang@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_GENTOO_TRADITIONAL_LAYOUT_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_GENTOO_TRADITIONAL_LAYOUT_HH 1
+
+#include <paludis/repositories/gentoo/layout.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+
+namespace paludis
+{
+ class PortageRepositoryEntries;
+
+ class PALUDIS_VISIBLE TraditionalLayout :
+ public Layout,
+ private PrivateImplementationPattern<TraditionalLayout>
+ {
+ private:
+ void need_category_names() const;
+ void need_category_names_collection() const;
+ void need_version_specs(const QualifiedPackageName &) const;
+
+ public:
+ TraditionalLayout(const RepositoryName &, const FSEntry &,
+ std::tr1::shared_ptr<const PortageRepositoryEntries>);
+
+ virtual ~TraditionalLayout();
+
+ virtual bool has_category_named(const CategoryNamePart &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool has_package_named(const QualifiedPackageName &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::tr1::shared_ptr<const CategoryNamePartCollection> category_names() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::tr1::shared_ptr<const QualifiedPackageNameCollection> package_names(
+ const CategoryNamePart &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::tr1::shared_ptr<const VersionSpecCollection> version_specs(
+ const QualifiedPackageName & n) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual bool has_version(const QualifiedPackageName &, const VersionSpec &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual FSEntry package_mask_file(const FSEntry & dir) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual FSEntry arch_list_file(const FSEntry & dir) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual FSEntry mirrors_file(const FSEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual FSEntry info_packages_file(const FSEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual FSEntry info_variables_file(const FSEntry &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+}
+
+#endif
diff --git a/paludis/util/comparison_policy-fwd.hh b/paludis/util/comparison_policy-fwd.hh
new file mode 100644
index 0000000..16372da
--- /dev/null
+++ b/paludis/util/comparison_policy-fwd.hh
@@ -0,0 +1,74 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_UTIL_COMPARISON_POLICY_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_UTIL_COMPARISON_POLICY_FWD_HH 1
+
+namespace paludis
+{
+ namespace comparison_mode
+ {
+ struct NoComparisonTag;
+ struct EqualityComparisonTag;
+ struct FullComparisonTag;
+ }
+
+ namespace comparison_method
+ {
+ template <typename>
+ struct CompareByMemberTag;
+
+ struct CompareByMemberComparisonFunctionTag;
+
+ template <typename>
+ struct CompareByMemberFetchFunctionTag;
+ }
+
+ template <typename OurType_, typename ComparisonModeTag_, typename ComparisonMethodTag_>
+ struct ComparisonPolicy;
+
+ template <typename OurType_, typename ComparisonMethodTag_>
+ class ComparisonPolicy<OurType_, comparison_mode::NoComparisonTag, ComparisonMethodTag_>;
+
+ template <typename OurType_, typename MemberType_>
+ class ComparisonPolicy<OurType_, comparison_mode::EqualityComparisonTag,
+ comparison_method::CompareByMemberTag<MemberType_> >;
+
+ template <typename OurType_>
+ class ComparisonPolicy<OurType_, comparison_mode::EqualityComparisonTag,
+ comparison_method::CompareByMemberComparisonFunctionTag>;
+
+ template <typename OurType_, typename MemberType_>
+ class ComparisonPolicy<OurType_, comparison_mode::FullComparisonTag,
+ comparison_method::CompareByMemberTag<MemberType_> >;
+
+ template <typename OurType_>
+ class ComparisonPolicy<OurType_, comparison_mode::FullComparisonTag,
+ comparison_method::CompareByMemberComparisonFunctionTag>;
+
+ template <typename OurType_, typename MemberType_>
+ class ComparisonPolicy<OurType_, comparison_mode::EqualityComparisonTag,
+ comparison_method::CompareByMemberFetchFunctionTag<MemberType_> >;
+
+ template <typename OurType_, typename MemberType_>
+ class ComparisonPolicy<OurType_, comparison_mode::FullComparisonTag,
+ comparison_method::CompareByMemberFetchFunctionTag<MemberType_> >;
+}
+
+#endif
diff --git a/paludis/util/comparison_policy.hh b/paludis/util/comparison_policy.hh
index 59a01e2..d4a2558 100644
--- a/paludis/util/comparison_policy.hh
+++ b/paludis/util/comparison_policy.hh
@@ -1,3 +1,5 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
/*
* Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
@@ -24,6 +26,8 @@
* \ingroup grpcompare
*/
+#include <paludis/util/comparison_policy-fwd.hh>
+
namespace paludis
{
/**
@@ -38,27 +42,21 @@ namespace paludis
*
* \ingroup grpcompare
*/
- struct NoComparisonTag
- {
- };
+ struct NoComparisonTag;
/**
* Comparisons can be made via operator== and operator!=.
*
* \ingroup grpcompare
*/
- struct EqualityComparisonTag
- {
- };
+ struct EqualityComparisonTag;
/**
* The full range of comparison operators is available.
*
* \ingroup grpcompare
*/
- struct FullComparisonTag
- {
- };
+ struct FullComparisonTag;
}
/**
@@ -74,9 +72,7 @@ namespace paludis
* \ingroup grpcompare
*/
template <typename MemberType_>
- struct CompareByMemberTag
- {
- };
+ struct CompareByMemberTag;
/**
* Comparisons are done by a member function that returns an integer
@@ -85,10 +81,7 @@ namespace paludis
*
* \ingroup grpcompare
*/
- struct CompareByMemberComparisonFunctionTag
- {
- };
-
+ struct CompareByMemberComparisonFunctionTag;
/**
* Comparisons are done via a member function that returns an item of
@@ -97,9 +90,7 @@ namespace paludis
* \ingroup grpcompare
*/
template <typename MemberType_>
- struct CompareByMemberFetchFunctionTag
- {
- };
+ struct CompareByMemberFetchFunctionTag;
}
template <typename OurType_, typename ComparisonModeTag_, typename ComparisonMethodTag_>
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index 481b428..f9f6481 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -12,13 +12,13 @@ add(`attributes', `hh')
add(`collection', `hh', `fwd')
add(`collection_concrete', `hh')
add(`compare', `hh')
-add(`comparison_policy', `hh')
+add(`comparison_policy', `hh', `fwd')
add(`destringify', `hh', `cc', `test')
add(`dir_iterator', `hh', `cc', `test', `testscript')
add(`exception', `hh', `cc')
add(`fast_unique_copy', `hh', `test')
add(`fd_output_stream', `hh')
-add(`fs_entry', `hh', `cc', `test', `testscript')
+add(`fs_entry', `hh', `cc', `fwd', `test', `testscript')
add(`fd_holder', `hh')
add(`graph', `hh', `cc', `impl', `test')
add(`iterator', `hh', `test')
@@ -38,7 +38,7 @@ add(`strip', `hh', `cc', `test')
add(`system', `hh', `cc', `test', `testscript')
add(`tokeniser', `hh', `cc', `test')
add(`util', `hh')
-add(`validated', `hh', `test')
+add(`validated', `hh', `fwd', `test')
add(`virtual_constructor', `hh', `impl', `test')
add(`visitor', `hh', `fwd', `test')
diff --git a/paludis/util/fs_entry-fwd.hh b/paludis/util/fs_entry-fwd.hh
new file mode 100644
index 0000000..9c89d5e
--- /dev/null
+++ b/paludis/util/fs_entry-fwd.hh
@@ -0,0 +1,75 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006 Mark Loeser <halcy0n@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_UTIL_FS_ENTRY_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_UTIL_FS_ENTRY_FWD_HH 1
+
+#include <iosfwd>
+#include <paludis/util/collection-fwd.hh>
+#include <paludis/util/attributes.hh>
+
+namespace paludis
+{
+ class FSError;
+
+ /**
+ * File permissions used by FSEntry.
+ *
+ * \ingroup grpfilesystem
+ */
+ enum FSPermission
+ {
+ fs_perm_read, ///< read permission on file
+ fs_perm_write, ///< write permission on file
+ fs_perm_execute ///< execute permission on file
+ };
+
+ /**
+ * User classes used by FSEntry.
+ *
+ * \ingroup grpfilesystem
+ */
+ enum FSUserGroup
+ {
+ fs_ug_owner, ///< owner permission
+ fs_ug_group, ///< group permission
+ fs_ug_others ///< others permission
+ };
+
+ class FSEntry;
+
+ /**
+ * An FSEntry can be written to an ostream.
+ *
+ * \ingroup grpfilesystem
+ */
+ std::ostream & operator<< (std::ostream & s, const FSEntry & f) PALUDIS_VISIBLE;
+
+ template <typename T_> class SequentialCollection;
+
+ /**
+ * An ordered group of FSEntry instances.
+ *
+ * \ingroup grpfilesystem
+ */
+ typedef SequentialCollection<FSEntry> FSEntryCollection;
+}
+
+#endif
diff --git a/paludis/util/fs_entry.hh b/paludis/util/fs_entry.hh
index b6da79e..b4e429d 100644
--- a/paludis/util/fs_entry.hh
+++ b/paludis/util/fs_entry.hh
@@ -21,6 +21,7 @@
#ifndef PALUDIS_GUARD_PALUDIS_FS_ENTRY_HH
#define PALUDIS_GUARD_PALUDIS_FS_ENTRY_HH 1
+#include <paludis/util/fs_entry-fwd.hh>
#include <paludis/util/comparison_policy.hh>
#include <paludis/util/exception.hh>
#include <string>
@@ -57,30 +58,6 @@ namespace paludis
};
/**
- * File permissions used by FSEntry.
- *
- * \ingroup grpfilesystem
- */
- enum FSPermission
- {
- fs_perm_read, ///< read permission on file
- fs_perm_write, ///< write permission on file
- fs_perm_execute ///< execute permission on file
- };
-
- /**
- * User classes used by FSEntry.
- *
- * \ingroup grpfilesystem
- */
- enum FSUserGroup
- {
- fs_ug_owner, ///< owner permission
- fs_ug_group, ///< group permission
- fs_ug_others ///< others permission
- };
-
- /**
* Represents an entry (which may or may not exist) in the filesystem.
*
* \ingroup grpfilesystem
diff --git a/paludis/util/validated-fwd.hh b/paludis/util/validated-fwd.hh
new file mode 100644
index 0000000..9a6748f
--- /dev/null
+++ b/paludis/util/validated-fwd.hh
@@ -0,0 +1,37 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_UTIL_VALIDATED_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_UTIL_VALIDATED_FWD_HH 1
+
+#include <iosfwd>
+#include <paludis/util/comparison_policy-fwd.hh>
+
+namespace paludis
+{
+ template <typename, typename,
+ typename ComparisonMode_ = comparison_mode::FullComparisonTag>
+ class Validated;
+
+ template <typename D_, typename V_, typename C_>
+ std::ostream &
+ operator<< (std::ostream & s, const Validated<D_, V_, C_> & v);
+}
+
+#endif
diff --git a/paludis/util/validated.hh b/paludis/util/validated.hh
index d324bb7..6f3161f 100644
--- a/paludis/util/validated.hh
+++ b/paludis/util/validated.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -21,6 +21,7 @@
#define PALUDIS_GUARD_PALUDIS_VALIDATED_HH 1
#include <iosfwd>
+#include <paludis/util/validated-fwd.hh>
#include <paludis/util/comparison_policy.hh>
/** \file
@@ -37,12 +38,10 @@ namespace paludis
*
* \ingroup grpvalidated
*/
- template <typename ValidatedDataType_, typename Validator_,
- typename ComparisonMode_ = comparison_mode::FullComparisonTag>
- class Validated : public ComparisonPolicy<
- Validated<ValidatedDataType_, Validator_, ComparisonMode_>,
- ComparisonMode_,
- comparison_method::CompareByMemberTag<ValidatedDataType_> >
+ template <typename ValidatedDataType_, typename Validator_, typename ComparisonMode_>
+ class Validated :
+ public ComparisonPolicy<Validated<ValidatedDataType_, Validator_, ComparisonMode_>,
+ ComparisonMode_, comparison_method::CompareByMemberTag<ValidatedDataType_> >
{
private:
ValidatedDataType_ _value;
@@ -83,7 +82,6 @@ namespace paludis
}
};
-
template <typename ValidatedDataType_, typename Validator_, typename ComparisonMode_>
Validated<ValidatedDataType_, Validator_, ComparisonMode_>::Validated(
const Validated<ValidatedDataType_, Validator_, ComparisonMode_> & other) :
diff --git a/paludis/version_spec-fwd.hh b/paludis/version_spec-fwd.hh
new file mode 100644
index 0000000..c465d18
--- /dev/null
+++ b/paludis/version_spec-fwd.hh
@@ -0,0 +1,47 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_VERSION_SPEC_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_VERSION_SPEC_FWD_HH 1
+
+#include <iosfwd>
+#include <paludis/util/attributes.hh>
+#include <paludis/util/collection-fwd.hh>
+
+namespace paludis
+{
+ class BadVersionSpecError;
+ class VersionSpec;
+
+ /**
+ * Output a VersionSpec to a stream.
+ *
+ * \ingroup grpversions
+ */
+ std::ostream & operator<< (std::ostream &, const VersionSpec &) PALUDIS_VISIBLE;
+
+ /**
+ * Holds a collection of VersionSpec instances.
+ *
+ * \ingroup grpversions
+ */
+ typedef SortedCollection<VersionSpec> VersionSpecCollection;
+}
+
+#endif
diff --git a/paludis/version_spec.hh b/paludis/version_spec.hh
index 76a8d2c..18a5294 100644
--- a/paludis/version_spec.hh
+++ b/paludis/version_spec.hh
@@ -20,6 +20,7 @@
#ifndef PALUDIS_GUARD_PALUDIS_VERSION_SPEC_HH
#define PALUDIS_GUARD_PALUDIS_VERSION_SPEC_HH 1
+#include <paludis/version_spec-fwd.hh>
#include <paludis/util/comparison_policy.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/private_implementation_pattern.hh>
@@ -151,20 +152,6 @@ namespace paludis
*/
bool has_scm_part() const;
};
-
- /**
- * Output a VersionSpec to a stream.
- *
- * \ingroup grpversions
- */
- std::ostream & operator<< (std::ostream &, const VersionSpec &) PALUDIS_VISIBLE;
-
- /**
- * Holds a collection of VersionSpec instances.
- *
- * \ingroup grpversions
- */
- typedef SortedCollection<VersionSpec> VersionSpecCollection;
}
#endif