aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-03-08 11:45:27 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-03-08 11:45:27 +0000
commitc78ad6f074ed0e796594ed97defd1304f7d119e4 (patch)
tree6ac31ba9e81c4fb66ff2fa6977f4e6ffe608e444
parent89e8818060814655dbe6804a0b61d9024a75ba12 (diff)
downloadpaludis-c78ad6f074ed0e796594ed97defd1304f7d119e4.tar.gz
paludis-c78ad6f074ed0e796594ed97defd1304f7d119e4.tar.xz
Support category and package restrictions
-rw-r--r--paludis/dep_spec.hh18
-rw-r--r--paludis/match_package.cc6
-rw-r--r--paludis/query.cc50
3 files changed, 61 insertions, 13 deletions
diff --git a/paludis/dep_spec.hh b/paludis/dep_spec.hh
index db1c17f..4e8d148 100644
--- a/paludis/dep_spec.hh
+++ b/paludis/dep_spec.hh
@@ -320,6 +320,8 @@ namespace paludis
{
private:
std::tr1::shared_ptr<QualifiedPackageName> _package_ptr;
+ std::tr1::shared_ptr<CategoryNamePart> _category_name_part_ptr;
+ std::tr1::shared_ptr<PackageNamePart> _package_name_part_ptr;
std::tr1::shared_ptr<VersionRequirements> _version_requirements;
VersionRequirementsMode _version_requirements_mode;
std::tr1::shared_ptr<SlotName> _slot;
@@ -361,6 +363,22 @@ namespace paludis
}
/**
+ * Fetch the package name part, if wildcarded.
+ */
+ std::tr1::shared_ptr<const PackageNamePart> package_name_part_ptr() const
+ {
+ return _package_name_part_ptr;
+ }
+
+ /**
+ * Fetch the category name part, if wildcarded.
+ */
+ std::tr1::shared_ptr<const CategoryNamePart> category_name_part_ptr() const
+ {
+ return _category_name_part_ptr;
+ }
+
+ /**
* Fetch the version requirements (may be a zero pointer).
*/
std::tr1::shared_ptr<const VersionRequirements> version_requirements_ptr() const
diff --git a/paludis/match_package.cc b/paludis/match_package.cc
index b67becc..c395d89 100644
--- a/paludis/match_package.cc
+++ b/paludis/match_package.cc
@@ -36,6 +36,12 @@ paludis::match_package(
if (spec.package_ptr() && *spec.package_ptr() != entry.name)
return false;
+ if (spec.package_name_part_ptr() && *spec.package_name_part_ptr() != entry.name.package)
+ return false;
+
+ if (spec.category_name_part_ptr() && *spec.category_name_part_ptr() != entry.name.category)
+ return false;
+
if (spec.version_requirements_ptr())
switch (spec.version_requirements_mode())
{
diff --git a/paludis/query.cc b/paludis/query.cc
index 52b211f..dd3436f 100644
--- a/paludis/query.cc
+++ b/paludis/query.cc
@@ -108,25 +108,49 @@ namespace
categories(const Environment & e,
std::tr1::shared_ptr<const RepositoryNameCollection> r) const
{
- if (! spec.package_ptr())
+ if (spec.package_ptr())
+ {
+ std::tr1::shared_ptr<CategoryNamePartCollection> result(new CategoryNamePartCollection::Concrete);
+ result->insert(spec.package_ptr()->category);
+ return result;
+ }
+ else if (spec.category_name_part_ptr())
+ {
+ std::tr1::shared_ptr<CategoryNamePartCollection> result(new CategoryNamePartCollection::Concrete);
+ result->insert(*spec.category_name_part_ptr());
+ return result;
+ }
+ else
return QueryDelegate::categories(e, r);
-
- std::tr1::shared_ptr<CategoryNamePartCollection> result(new CategoryNamePartCollection::Concrete);
- result->insert(spec.package_ptr()->category);
- return result;
}
std::tr1::shared_ptr<QualifiedPackageNameCollection>
packages(const Environment & e,
- std::tr1::shared_ptr<const RepositoryNameCollection> r,
- std::tr1::shared_ptr<const CategoryNamePartCollection> c) const
+ std::tr1::shared_ptr<const RepositoryNameCollection> repos,
+ std::tr1::shared_ptr<const CategoryNamePartCollection> cats) const
{
- if (! spec.package_ptr())
- return QueryDelegate::packages(e, r, c);
-
- std::tr1::shared_ptr<QualifiedPackageNameCollection> result(new QualifiedPackageNameCollection::Concrete);
- result->insert(*spec.package_ptr());
- return result;
+ if (spec.package_ptr())
+ {
+ std::tr1::shared_ptr<QualifiedPackageNameCollection> result(
+ new QualifiedPackageNameCollection::Concrete);
+ result->insert(*spec.package_ptr());
+ return result;
+ }
+ else if (spec.package_name_part_ptr())
+ {
+ std::tr1::shared_ptr<QualifiedPackageNameCollection> result(
+ new QualifiedPackageNameCollection::Concrete);
+ for (RepositoryNameCollection::Iterator r(repos->begin()), r_end(repos->end()) ;
+ r != r_end ; ++r)
+ for (CategoryNamePartCollection::Iterator c(cats->begin()), c_end(cats->end()) ;
+ c != c_end ; ++c)
+ if (e.package_database()->fetch_repository(*r)->has_package_named(*c +
+ *spec.package_name_part_ptr()))
+ result->insert(*c + *spec.package_name_part_ptr());
+ return result;
+ }
+ else
+ return QueryDelegate::packages(e, repos, cats);
}
std::tr1::shared_ptr<PackageDatabaseEntryCollection>