aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-18 22:44:26 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-18 22:48:57 +0000
commitbdf2d8a162a597af3a758e84e68c5f65ce088ef3 (patch)
treec079bf31cb6af8203dd572069dddcc0d293f394e
parent48c9c785ecd6a96f056b9ecefb6df980967dda22 (diff)
downloadpaludis-bdf2d8a162a597af3a758e84e68c5f65ce088ef3.tar.gz
paludis-bdf2d8a162a597af3a758e84e68c5f65ce088ef3.tar.xz
Split out helpers
-rw-r--r--paludis/repositories/e/e_repository.cc43
-rw-r--r--paludis/repositories/e/e_repository.hh7
-rw-r--r--paludis/repositories/e/exheres_layout.cc8
-rw-r--r--paludis/repositories/e/file_suffixes.cc50
-rw-r--r--paludis/repositories/e/file_suffixes.hh14
-rw-r--r--paludis/repositories/e/traditional_layout.cc8
6 files changed, 70 insertions, 60 deletions
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index 6a3047c..bf17eff 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -1693,7 +1693,7 @@ ERepository::make_id(const QualifiedPackageName & q, const FSPath & f) const
std::shared_ptr<EbuildID> result(std::make_shared<EbuildID>(q, extract_package_file_version(q, f),
_imp->params.environment(),
- name(), f, _guess_eapi(q, f),
+ name(), f, FileSuffixes::get_instance()->guess_eapi_from_filename(q, f),
_imp->master_mtime, _imp->eclass_mtimes));
return result;
}
@@ -1921,22 +1921,6 @@ ERepository::merge(const MergeParams & m)
}
}
-bool
-ERepository::is_package_file(const QualifiedPackageName & n, const FSPath & e) const
-{
- Context context("When working out whether '" + stringify(e) + "' is a package file for '" + stringify(n) + "':");
-
- if (0 != e.basename().compare(0, stringify(n.package()).length() + 1, stringify(n.package()) + "-"))
- return false;
-
- std::string::size_type p(e.basename().rfind('.'));
- if (std::string::npos == p)
- return false;
-
- std::string suffix(e.basename().substr(p + 1));
- return FileSuffixes::get_instance()->is_known_suffix(suffix);
-}
-
VersionSpec
ERepository::extract_package_file_version(const QualifiedPackageName & n, const FSPath & e) const
{
@@ -1950,36 +1934,11 @@ ERepository::extract_package_file_version(const QualifiedPackageName & n, const
}
const std::string
-ERepository::get_package_file_manifest_key(const FSPath & e, const QualifiedPackageName & q) const
-{
- if (! is_package_file(q, e))
- return "";
-
- std::string::size_type p(e.basename().rfind('.'));
- if (std::string::npos == p)
- return "EBUILD";
-
- std::string suffix(e.basename().substr(p + 1));
- return FileSuffixes::get_instance()->manifest_key(suffix);
-}
-
-const std::string
ERepository::binary_ebuild_name(const QualifiedPackageName & q, const VersionSpec & v, const std::string & e) const
{
return stringify(q.package()) + "-" + stringify(v) + "." + e;
}
-const std::string
-ERepository::_guess_eapi(const QualifiedPackageName &, const FSPath & e) const
-{
- std::string::size_type p(e.basename().rfind('.'));
- if (std::string::npos == p)
- return "";
-
- std::string suffix(e.basename().substr(p + 1));
- return FileSuffixes::get_instance()->guess_eapi(suffix);
-}
-
const std::shared_ptr<const MirrorsSequence>
ERepository::get_mirrors(const std::string & m) const
{
diff --git a/paludis/repositories/e/e_repository.hh b/paludis/repositories/e/e_repository.hh
index ef94d81..ff07862 100644
--- a/paludis/repositories/e/e_repository.hh
+++ b/paludis/repositories/e/e_repository.hh
@@ -64,8 +64,6 @@ namespace paludis
void need_mirrors() const;
- const std::string _guess_eapi(const QualifiedPackageName &, const FSPath & e) const;
-
protected:
virtual void need_keys_added() const;
@@ -208,9 +206,6 @@ namespace paludis
///\name Entries
///\{
- bool is_package_file(const QualifiedPackageName &, const FSPath &) const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
VersionSpec extract_package_file_version(const QualifiedPackageName &, const FSPath &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -218,8 +213,6 @@ namespace paludis
const QualifiedPackageName &, const FSPath &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- const std::string get_package_file_manifest_key(const FSPath &, const QualifiedPackageName &) const;
-
const std::string binary_ebuild_name(const QualifiedPackageName &, const VersionSpec &, const std::string &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
diff --git a/paludis/repositories/e/exheres_layout.cc b/paludis/repositories/e/exheres_layout.cc
index 5cc01c7..4704ab0 100644
--- a/paludis/repositories/e/exheres_layout.cc
+++ b/paludis/repositories/e/exheres_layout.cc
@@ -20,6 +20,8 @@
#include <paludis/repositories/e/exheres_layout.hh>
#include <paludis/repositories/e/e_repository_exceptions.hh>
#include <paludis/repositories/e/e_repository.hh>
+#include <paludis/repositories/e/file_suffixes.hh>
+
#include <paludis/util/config_file.hh>
#include <paludis/package_id.hh>
#include <paludis/package_database.hh>
@@ -233,7 +235,7 @@ ExheresLayout::need_package_ids(const QualifiedPackageName & n) const
for (FSIterator e(path, { }), e_end ; e != e_end ; ++e)
{
- if (! _imp->repository->is_package_file(n, *e))
+ if (! FileSuffixes::get_instance()->is_package_file(n, *e))
continue;
try
@@ -608,8 +610,8 @@ ExheresLayout::manifest_files(const QualifiedPackageName & qpn) const
continue;
std::string file_type("MISC");
- if (_imp->repository->is_package_file(qpn, (*f)))
- file_type=_imp->repository->get_package_file_manifest_key((*f), qpn);
+ if (FileSuffixes::get_instance()->is_package_file(qpn, (*f)))
+ file_type = FileSuffixes::get_instance()->get_package_file_manifest_key((*f), qpn);
result->insert((*f), file_type);
}
diff --git a/paludis/repositories/e/file_suffixes.cc b/paludis/repositories/e/file_suffixes.cc
index cf6a61a..c6d88b0 100644
--- a/paludis/repositories/e/file_suffixes.cc
+++ b/paludis/repositories/e/file_suffixes.cc
@@ -25,6 +25,7 @@
#include <paludis/util/fs_path.hh>
#include <paludis/util/log.hh>
#include <paludis/util/options.hh>
+#include <paludis/name.hh>
using namespace paludis;
using namespace paludis::erepository;
@@ -57,13 +58,24 @@ FileSuffixes::is_known_suffix(const std::string & s) const
return ! _imp->file.get("suffix_" + s + "_known").empty();
}
-std::string
-FileSuffixes::guess_eapi(const std::string & s) const
+const std::string
+FileSuffixes::guess_eapi_without_hint(const std::string & s) const
{
return _imp->file.get("guess_eapi_" + s);
}
-std::string
+const std::string
+FileSuffixes::guess_eapi_from_filename(const QualifiedPackageName &, const FSPath & e) const
+{
+ std::string::size_type p(e.basename().rfind('.'));
+ if (std::string::npos == p)
+ return "";
+
+ std::string suffix(e.basename().substr(p + 1));
+ return guess_eapi_without_hint(suffix);
+}
+
+const std::string
FileSuffixes::manifest_key(const std::string & s) const
{
std::string result(_imp->file.get("manifest_key_" + s));
@@ -77,3 +89,35 @@ FileSuffixes::manifest_key(const std::string & s) const
return result;
}
+bool
+FileSuffixes::is_package_file(const QualifiedPackageName & n, const FSPath & e) const
+{
+ Context context("When working out whether '" + stringify(e) + "' is a package file for '" + stringify(n) + "':");
+
+ if (0 != e.basename().compare(0, stringify(n.package()).length() + 1, stringify(n.package()) + "-"))
+ return false;
+
+ std::string::size_type p(e.basename().rfind('.'));
+ if (std::string::npos == p)
+ return false;
+
+ std::string suffix(e.basename().substr(p + 1));
+ return is_known_suffix(suffix);
+}
+
+const std::string
+FileSuffixes::get_package_file_manifest_key(const FSPath & e, const QualifiedPackageName & q) const
+{
+ if (! is_package_file(q, e))
+ return "";
+
+ std::string::size_type p(e.basename().rfind('.'));
+ if (std::string::npos == p)
+ return "EBUILD";
+
+ std::string suffix(e.basename().substr(p + 1));
+ return manifest_key(suffix);
+}
+
+template class Singleton<FileSuffixes>;
+
diff --git a/paludis/repositories/e/file_suffixes.hh b/paludis/repositories/e/file_suffixes.hh
index 4637a38..e4d17e9 100644
--- a/paludis/repositories/e/file_suffixes.hh
+++ b/paludis/repositories/e/file_suffixes.hh
@@ -22,6 +22,8 @@
#include <paludis/util/pimp.hh>
#include <paludis/util/singleton.hh>
+#include <paludis/util/fs_path-fwd.hh>
+#include <paludis/name-fwd.hh>
#include <string>
namespace paludis
@@ -42,11 +44,19 @@ namespace paludis
public:
bool is_known_suffix(const std::string & s) const;
- std::string guess_eapi(const std::string & s) const;
+ const std::string manifest_key(const std::string & s) const;
- std::string manifest_key(const std::string & s) const;
+ const std::string get_package_file_manifest_key(const FSPath & e, const QualifiedPackageName & q) const;
+
+ bool is_package_file(const QualifiedPackageName & n, const FSPath & e) const;
+
+ const std::string guess_eapi_without_hint(const std::string & s) const;
+
+ const std::string guess_eapi_from_filename(const QualifiedPackageName &, const FSPath & e) const;
};
}
+
+ extern template class Singleton<erepository::FileSuffixes>;
}
#endif
diff --git a/paludis/repositories/e/traditional_layout.cc b/paludis/repositories/e/traditional_layout.cc
index b057b02..49b1ea6 100644
--- a/paludis/repositories/e/traditional_layout.cc
+++ b/paludis/repositories/e/traditional_layout.cc
@@ -20,6 +20,8 @@
#include <paludis/repositories/e/traditional_layout.hh>
#include <paludis/repositories/e/e_repository.hh>
+#include <paludis/repositories/e/file_suffixes.hh>
+
#include <paludis/util/config_file.hh>
#include <paludis/package_id.hh>
#include <paludis/package_database.hh>
@@ -246,7 +248,7 @@ TraditionalLayout::need_package_ids(const QualifiedPackageName & n) const
for (FSIterator e(path, { fsio_inode_sort }), e_end ; e != e_end ; ++e)
{
- if (! _imp->repository->is_package_file(n, *e))
+ if (! FileSuffixes::get_instance()->is_package_file(n, *e))
continue;
try
@@ -618,8 +620,8 @@ TraditionalLayout::manifest_files(const QualifiedPackageName & qpn) const
continue;
std::string file_type("MISC");
- if (_imp->repository->is_package_file(qpn, (*f)))
- file_type=_imp->repository->get_package_file_manifest_key((*f), qpn);
+ if (FileSuffixes::get_instance()->is_package_file(qpn, (*f)))
+ file_type = FileSuffixes::get_instance()->get_package_file_manifest_key((*f), qpn);
result->insert((*f), file_type);
}