aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2012-05-13 18:37:46 +0100
committerAvatar David Leverton <levertond@googlemail.com> 2012-05-13 18:40:50 +0100
commit471ede08c4eb2ac6dec49ce23c84aba28785ee87 (patch)
tree6ecb26a87e817906002681d7bf3957c5c1ef17b5
parent666e567c8a75123e4738b828dff4c35e1df86a99 (diff)
downloadpaludis-471ede08c4eb2ac6dec49ce23c84aba28785ee87.tar.gz
paludis-471ede08c4eb2ac6dec49ce23c84aba28785ee87.tar.xz
Use EAPI from suffix for version parsing
Also removes the need for EbuildID::EbuildID to fetch eapi_when_unknown, since that's already done by the caller.
-rw-r--r--paludis/repositories/e/e_repository.cc11
-rw-r--r--paludis/repositories/e/e_repository.hh2
-rw-r--r--paludis/repositories/e/ebuild_id.cc14
3 files changed, 9 insertions, 18 deletions
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index 7fd726f..1e4dbac 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -1695,9 +1695,12 @@ ERepository::make_id(const QualifiedPackageName & q, const FSPath & f) const
{
Context context("When creating ID for '" + stringify(q) + "' from '" + stringify(f) + "':");
- std::shared_ptr<EbuildID> result(std::make_shared<EbuildID>(q, extract_package_file_version(q, f),
+ std::string suffix_eapi(FileSuffixes::get_instance()->guess_eapi_from_filename(q, f));
+ std::string eapi(suffix_eapi.empty() ? _imp->params.eapi_when_unknown() : suffix_eapi);
+
+ std::shared_ptr<EbuildID> result(std::make_shared<EbuildID>(q, extract_package_file_version(q, f, eapi),
_imp->params.environment(),
- name(), f, FileSuffixes::get_instance()->guess_eapi_from_filename(q, f),
+ name(), f, eapi,
_imp->master_mtime, _imp->eclass_mtimes));
return result;
}
@@ -1929,7 +1932,7 @@ ERepository::merge(const MergeParams & m)
}
VersionSpec
-ERepository::extract_package_file_version(const QualifiedPackageName & n, const FSPath & e) const
+ERepository::extract_package_file_version(const QualifiedPackageName & n, const FSPath & e, const std::string & eapi) const
{
Context context("When extracting version from '" + stringify(e) + "':");
std::string::size_type p(e.basename().rfind('.'));
@@ -1937,7 +1940,7 @@ ERepository::extract_package_file_version(const QualifiedPackageName & n, const
throw InternalError(PALUDIS_HERE, "got npos");
return VersionSpec(strip_leading_string(e.basename().substr(0, p), stringify(n.package()) + "-"),
EAPIData::get_instance()->eapi_from_string(
- _imp->params.eapi_when_unknown())->supported()->version_spec_options());
+ eapi)->supported()->version_spec_options());
}
const std::string
diff --git a/paludis/repositories/e/e_repository.hh b/paludis/repositories/e/e_repository.hh
index f3fc5dc..fcfe236 100644
--- a/paludis/repositories/e/e_repository.hh
+++ b/paludis/repositories/e/e_repository.hh
@@ -199,7 +199,7 @@ namespace paludis
///\name Entries
///\{
- VersionSpec extract_package_file_version(const QualifiedPackageName &, const FSPath &) const
+ VersionSpec extract_package_file_version(const QualifiedPackageName &, const FSPath &, const std::string &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
const std::shared_ptr<const erepository::ERepositoryID> make_id(
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index 09283e2..ae6ae97 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -204,18 +204,6 @@ namespace paludis
};
}
-namespace
-{
- std::string guess_eapi(const std::string & g, const Environment * const env, const RepositoryName & repo_name)
- {
- if (! g.empty())
- return g;
- auto repo(env->fetch_repository(repo_name));
- auto e_repo(std::static_pointer_cast<const ERepository>(repo));
- return e_repo->params().eapi_when_unknown();
- }
-}
-
EbuildID::EbuildID(const QualifiedPackageName & q, const VersionSpec & v,
const Environment * const e,
const RepositoryName & r,
@@ -223,7 +211,7 @@ EbuildID::EbuildID(const QualifiedPackageName & q, const VersionSpec & v,
const std::string & g,
const time_t t,
const std::shared_ptr<const EclassMtimes> & m) :
- _imp(q, v, e, r, f, guess_eapi(g, e, r), t, m)
+ _imp(q, v, e, r, f, g, t, m)
{
}