aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-09-06 16:51:19 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-09-06 16:51:19 +0100
commitcea9adc3df54e1bdeac88ff628cd91b53b9e549e (patch)
tree24ed874efc9139bc9184f24cbe0e7e360dc18a7d
parent39d5d8c84aba37c41f0e689a544615bd21c5c60d (diff)
downloadpaludis-cea9adc3df54e1bdeac88ff628cd91b53b9e549e.tar.gz
paludis-cea9adc3df54e1bdeac88ff628cd91b53b9e549e.tar.xz
Framework for licence groups
-rw-r--r--paludis/environment.hh12
-rw-r--r--paludis/environment_implementation.cc31
-rw-r--r--paludis/environment_implementation.hh3
-rw-r--r--paludis/repositories/accounts/accounts_repository.cc6
-rw-r--r--paludis/repositories/accounts/accounts_repository.hh2
-rw-r--r--paludis/repositories/e/e_installed_repository.cc6
-rw-r--r--paludis/repositories/e/e_installed_repository.hh3
-rw-r--r--paludis/repositories/e/e_repository.cc6
-rw-r--r--paludis/repositories/e/e_repository.hh3
-rw-r--r--paludis/repositories/fake/fake_installed_repository.cc6
-rw-r--r--paludis/repositories/fake/fake_installed_repository.hh3
-rw-r--r--paludis/repositories/fake/fake_repository.cc6
-rw-r--r--paludis/repositories/fake/fake_repository.hh3
-rw-r--r--paludis/repositories/gemcutter/gemcutter_repository.cc7
-rw-r--r--paludis/repositories/gemcutter/gemcutter_repository.hh3
-rw-r--r--paludis/repositories/repository/repository_repository.cc7
-rw-r--r--paludis/repositories/repository/repository_repository.hh3
-rw-r--r--paludis/repositories/unavailable/unavailable_repository.cc7
-rw-r--r--paludis/repositories/unavailable/unavailable_repository.hh3
-rw-r--r--paludis/repositories/unpackaged/installed_repository.cc6
-rw-r--r--paludis/repositories/unpackaged/installed_repository.hh3
-rw-r--r--paludis/repositories/unpackaged/unpackaged_repository.cc6
-rw-r--r--paludis/repositories/unpackaged/unpackaged_repository.hh3
-rw-r--r--paludis/repositories/unwritten/unwritten_repository.cc7
-rw-r--r--paludis/repositories/unwritten/unwritten_repository.hh3
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.cc6
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.hh3
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc6
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.hh3
-rw-r--r--paludis/repository.hh16
30 files changed, 182 insertions, 0 deletions
diff --git a/paludis/environment.hh b/paludis/environment.hh
index eec7e61..8e6b5ff 100644
--- a/paludis/environment.hh
+++ b/paludis/environment.hh
@@ -309,6 +309,18 @@ namespace paludis
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
/**
+ * Expand a licence group into its constituent licences, recursively (if any
+ * of our repositories thinks it is a group).
+ *
+ * The original group is included in the result.
+ *
+ * \since 0.68
+ */
+ virtual const std::shared_ptr<const Set<std::string> > expand_licence(
+ const std::string &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ /**
* Do we accept any of the specified keywords for a particular package?
*
* If the collection includes "*", should return true.
diff --git a/paludis/environment_implementation.cc b/paludis/environment_implementation.cc
index af27080..a47a3dc 100644
--- a/paludis/environment_implementation.cc
+++ b/paludis/environment_implementation.cc
@@ -618,6 +618,37 @@ EnvironmentImplementation::end_repositories() const
return RepositoryConstIterator(_imp->repositories.end());
}
+const std::shared_ptr<const Set<std::string> >
+EnvironmentImplementation::expand_licence(
+ const std::string & s) const
+{
+ auto result(std::make_shared<Set<std::string> >());
+
+ std::set<std::string> todo;
+ todo.insert(s);
+
+ while (! todo.empty())
+ {
+ std::string t(*todo.begin());
+ todo.erase(todo.begin());
+
+ result->insert(t);
+
+ for (auto r(begin_repositories()), r_end(end_repositories()) ;
+ r != r_end ; ++r)
+ {
+ auto l((*r)->maybe_expand_licence_nonrecursively(t));
+ if (l)
+ for (auto i(l->begin()), i_end(l->end()) ;
+ i != i_end ; ++i)
+ if (result->end() == result->find(*i))
+ todo.insert(*i);
+ }
+ }
+
+ return result;
+}
+
DuplicateSetError::DuplicateSetError(const SetName & s) throw () :
Exception("A set named '" + stringify(s) + "' already exists")
{
diff --git a/paludis/environment_implementation.hh b/paludis/environment_implementation.hh
index c256ce0..d32fbad 100644
--- a/paludis/environment_implementation.hh
+++ b/paludis/environment_implementation.hh
@@ -128,6 +128,9 @@ namespace paludis
virtual RepositoryConstIterator end_repositories() const
PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const std::shared_ptr<const Set<std::string> > expand_licence(
+ const std::string &) const;
};
class PALUDIS_VISIBLE DuplicateSetError :
diff --git a/paludis/repositories/accounts/accounts_repository.cc b/paludis/repositories/accounts/accounts_repository.cc
index 1ae6254..ea00958 100644
--- a/paludis/repositories/accounts/accounts_repository.cc
+++ b/paludis/repositories/accounts/accounts_repository.cc
@@ -441,6 +441,12 @@ AccountsRepository::sync(
return false;
}
+const std::shared_ptr<const Set<std::string> >
+AccountsRepository::maybe_expand_licence_nonrecursively(const std::string &) const
+{
+ return make_null_shared_ptr();
+}
+
namespace paludis
{
template class Pimp<AccountsRepository>;
diff --git a/paludis/repositories/accounts/accounts_repository.hh b/paludis/repositories/accounts/accounts_repository.hh
index 5f8eb72..54b844a 100644
--- a/paludis/repositories/accounts/accounts_repository.hh
+++ b/paludis/repositories/accounts/accounts_repository.hh
@@ -130,6 +130,8 @@ namespace paludis
virtual std::shared_ptr<const PackageIDSequence> package_ids(const QualifiedPackageName & p, const RepositoryContentMayExcludes &) const;
virtual bool some_ids_might_support_action(const SupportsActionTestBase &) const;
virtual bool some_ids_might_not_be_masked() const;
+ virtual const std::shared_ptr<const Set<std::string> > maybe_expand_licence_nonrecursively(
+ const std::string &) const;
///\}
diff --git a/paludis/repositories/e/e_installed_repository.cc b/paludis/repositories/e/e_installed_repository.cc
index 7d8ebff..e021f77 100644
--- a/paludis/repositories/e/e_installed_repository.cc
+++ b/paludis/repositories/e/e_installed_repository.cc
@@ -414,3 +414,9 @@ EInstalledRepository::sync(const std::string &, const std::string &, const std::
return false;
}
+const std::shared_ptr<const Set<std::string> >
+EInstalledRepository::maybe_expand_licence_nonrecursively(const std::string &) const
+{
+ return make_null_shared_ptr();
+}
+
diff --git a/paludis/repositories/e/e_installed_repository.hh b/paludis/repositories/e/e_installed_repository.hh
index 3656263..977407c 100644
--- a/paludis/repositories/e/e_installed_repository.hh
+++ b/paludis/repositories/e/e_installed_repository.hh
@@ -95,6 +95,9 @@ namespace paludis
const std::string &,
const std::shared_ptr<OutputManager> &) const;
+ virtual const std::shared_ptr<const Set<std::string> > maybe_expand_licence_nonrecursively(
+ const std::string &) const;
+
///\name For use by EInstalledRepositoryID
///\{
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index 3322420..acde832 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -1878,3 +1878,9 @@ ERepository::get_mirrors(const std::string & m) const
return i->second;
}
+const std::shared_ptr<const Set<std::string> >
+ERepository::maybe_expand_licence_nonrecursively(const std::string &) const
+{
+ return make_null_shared_ptr();
+}
+
diff --git a/paludis/repositories/e/e_repository.hh b/paludis/repositories/e/e_repository.hh
index 3c52aa7..f3fc5dc 100644
--- a/paludis/repositories/e/e_repository.hh
+++ b/paludis/repositories/e/e_repository.hh
@@ -144,6 +144,9 @@ namespace paludis
virtual std::shared_ptr<const CategoryNamePartSet> unimportant_category_names(const RepositoryContentMayExcludes &) const;
virtual const bool is_unimportant() const;
+ virtual const std::shared_ptr<const Set<std::string> > maybe_expand_licence_nonrecursively(
+ const std::string &) const;
+
/**
* Update GLEP 42 news files.
*/
diff --git a/paludis/repositories/fake/fake_installed_repository.cc b/paludis/repositories/fake/fake_installed_repository.cc
index 1859153..b54aab1 100644
--- a/paludis/repositories/fake/fake_installed_repository.cc
+++ b/paludis/repositories/fake/fake_installed_repository.cc
@@ -212,3 +212,9 @@ FakeInstalledRepository::sync_host_key() const
return make_null_shared_ptr();
}
+const std::shared_ptr<const Set<std::string> >
+FakeInstalledRepository::maybe_expand_licence_nonrecursively(const std::string &) const
+{
+ return make_null_shared_ptr();
+}
+
diff --git a/paludis/repositories/fake/fake_installed_repository.hh b/paludis/repositories/fake/fake_installed_repository.hh
index 5b61bba..8772531 100644
--- a/paludis/repositories/fake/fake_installed_repository.hh
+++ b/paludis/repositories/fake/fake_installed_repository.hh
@@ -88,6 +88,9 @@ namespace paludis
virtual const std::shared_ptr<const MetadataValueKey<FSPath> > installed_root_key() const;
virtual const std::shared_ptr<const MetadataCollectionKey<Map<std::string, std::string> > > sync_host_key() const;
+ virtual const std::shared_ptr<const Set<std::string> > maybe_expand_licence_nonrecursively(
+ const std::string &) const;
+
///\name RepositoryFactory functions
///\{
diff --git a/paludis/repositories/fake/fake_repository.cc b/paludis/repositories/fake/fake_repository.cc
index 459a25d..dea5a10 100644
--- a/paludis/repositories/fake/fake_repository.cc
+++ b/paludis/repositories/fake/fake_repository.cc
@@ -154,3 +154,9 @@ FakeRepository::sync_host_key() const
return make_null_shared_ptr();
}
+const std::shared_ptr<const Set<std::string> >
+FakeRepository::maybe_expand_licence_nonrecursively(const std::string &) const
+{
+ return make_null_shared_ptr();
+}
+
diff --git a/paludis/repositories/fake/fake_repository.hh b/paludis/repositories/fake/fake_repository.hh
index e6720fb..9c8abeb 100644
--- a/paludis/repositories/fake/fake_repository.hh
+++ b/paludis/repositories/fake/fake_repository.hh
@@ -73,6 +73,9 @@ namespace paludis
virtual const bool is_unimportant() const;
+ virtual const std::shared_ptr<const Set<std::string> > maybe_expand_licence_nonrecursively(
+ const std::string &) const;
+
/* Keys */
virtual const std::shared_ptr<const MetadataValueKey<std::string> > format_key() const;
diff --git a/paludis/repositories/gemcutter/gemcutter_repository.cc b/paludis/repositories/gemcutter/gemcutter_repository.cc
index 6495132..381febb 100644
--- a/paludis/repositories/gemcutter/gemcutter_repository.cc
+++ b/paludis/repositories/gemcutter/gemcutter_repository.cc
@@ -302,7 +302,14 @@ GemcutterRepository::sync_host_key() const
return make_null_shared_ptr();
}
+const std::shared_ptr<const Set<std::string> >
+GemcutterRepository::maybe_expand_licence_nonrecursively(const std::string &) const
+{
+ return make_null_shared_ptr();
+}
+
namespace paludis
{
template class Pimp<gemcutter_repository::GemcutterRepository>;
}
+
diff --git a/paludis/repositories/gemcutter/gemcutter_repository.hh b/paludis/repositories/gemcutter/gemcutter_repository.hh
index e93a0c0..4fc5658 100644
--- a/paludis/repositories/gemcutter/gemcutter_repository.hh
+++ b/paludis/repositories/gemcutter/gemcutter_repository.hh
@@ -88,6 +88,9 @@ namespace paludis
virtual bool sync(const std::string &, const std::string &, const std::shared_ptr<OutputManager> &) const;
+ virtual const std::shared_ptr<const Set<std::string> > maybe_expand_licence_nonrecursively(
+ const std::string &) const;
+
///\name RepositoryFactory functions
///\{
diff --git a/paludis/repositories/repository/repository_repository.cc b/paludis/repositories/repository/repository_repository.cc
index b4a4039..ac7598c 100644
--- a/paludis/repositories/repository/repository_repository.cc
+++ b/paludis/repositories/repository/repository_repository.cc
@@ -472,7 +472,14 @@ RepositoryRepository::merge(const MergeParams & m)
}
}
+const std::shared_ptr<const Set<std::string> >
+RepositoryRepository::maybe_expand_licence_nonrecursively(const std::string &) const
+{
+ return make_null_shared_ptr();
+}
+
namespace paludis
{
template class Pimp<repository_repository::RepositoryRepository>;
}
+
diff --git a/paludis/repositories/repository/repository_repository.hh b/paludis/repositories/repository/repository_repository.hh
index 8b2a683..1cbfb2e 100644
--- a/paludis/repositories/repository/repository_repository.hh
+++ b/paludis/repositories/repository/repository_repository.hh
@@ -102,6 +102,9 @@ namespace paludis
virtual void merge(const MergeParams &);
+ virtual const std::shared_ptr<const Set<std::string> > maybe_expand_licence_nonrecursively(
+ const std::string &) const;
+
///\name RepositoryFactory functions
///\{
diff --git a/paludis/repositories/unavailable/unavailable_repository.cc b/paludis/repositories/unavailable/unavailable_repository.cc
index ce0da35..9ce2619 100644
--- a/paludis/repositories/unavailable/unavailable_repository.cc
+++ b/paludis/repositories/unavailable/unavailable_repository.cc
@@ -454,7 +454,14 @@ UnavailableRepository::sync_host_key() const
return _imp->sync_host_key;
}
+const std::shared_ptr<const Set<std::string> >
+UnavailableRepository::maybe_expand_licence_nonrecursively(const std::string &) const
+{
+ return make_null_shared_ptr();
+}
+
namespace paludis
{
template class Pimp<unavailable_repository::UnavailableRepository>;
}
+
diff --git a/paludis/repositories/unavailable/unavailable_repository.hh b/paludis/repositories/unavailable/unavailable_repository.hh
index f751006..6403f7c 100644
--- a/paludis/repositories/unavailable/unavailable_repository.hh
+++ b/paludis/repositories/unavailable/unavailable_repository.hh
@@ -93,6 +93,9 @@ namespace paludis
virtual bool sync(const std::string &, const std::string &, const std::shared_ptr<OutputManager> &) const;
+ virtual const std::shared_ptr<const Set<std::string> > maybe_expand_licence_nonrecursively(
+ const std::string &) const;
+
///\name RepositoryFactory functions
///\{
diff --git a/paludis/repositories/unpackaged/installed_repository.cc b/paludis/repositories/unpackaged/installed_repository.cc
index 3b61b5f..3d85034 100644
--- a/paludis/repositories/unpackaged/installed_repository.cc
+++ b/paludis/repositories/unpackaged/installed_repository.cc
@@ -516,3 +516,9 @@ InstalledUnpackagedRepository::sync_host_key() const
return make_null_shared_ptr();
}
+const std::shared_ptr<const Set<std::string> >
+InstalledUnpackagedRepository::maybe_expand_licence_nonrecursively(const std::string &) const
+{
+ return make_null_shared_ptr();
+}
+
diff --git a/paludis/repositories/unpackaged/installed_repository.hh b/paludis/repositories/unpackaged/installed_repository.hh
index 9b1c2d4..d8c7e6e 100644
--- a/paludis/repositories/unpackaged/installed_repository.hh
+++ b/paludis/repositories/unpackaged/installed_repository.hh
@@ -102,6 +102,9 @@ namespace paludis
virtual const bool is_unimportant() const;
+ virtual const std::shared_ptr<const Set<std::string> > maybe_expand_licence_nonrecursively(
+ const std::string &) const;
+
/* Keys */
virtual const std::shared_ptr<const MetadataValueKey<std::string> > format_key() const;
diff --git a/paludis/repositories/unpackaged/unpackaged_repository.cc b/paludis/repositories/unpackaged/unpackaged_repository.cc
index 1d3df37..a829cf1 100644
--- a/paludis/repositories/unpackaged/unpackaged_repository.cc
+++ b/paludis/repositories/unpackaged/unpackaged_repository.cc
@@ -312,3 +312,9 @@ UnpackagedRepository::sync_host_key() const
return make_null_shared_ptr();
}
+const std::shared_ptr<const Set<std::string> >
+UnpackagedRepository::maybe_expand_licence_nonrecursively(const std::string &) const
+{
+ return make_null_shared_ptr();
+}
+
diff --git a/paludis/repositories/unpackaged/unpackaged_repository.hh b/paludis/repositories/unpackaged/unpackaged_repository.hh
index a11936d..d49255e 100644
--- a/paludis/repositories/unpackaged/unpackaged_repository.hh
+++ b/paludis/repositories/unpackaged/unpackaged_repository.hh
@@ -110,6 +110,9 @@ namespace paludis
virtual bool sync(const std::string &, const std::string &, const std::shared_ptr<OutputManager> &) const;
+ virtual const std::shared_ptr<const Set<std::string> > maybe_expand_licence_nonrecursively(
+ const std::string &) const;
+
/* Keys */
virtual const std::shared_ptr<const MetadataValueKey<std::string> > format_key() const;
diff --git a/paludis/repositories/unwritten/unwritten_repository.cc b/paludis/repositories/unwritten/unwritten_repository.cc
index e2afa53..445b31d 100644
--- a/paludis/repositories/unwritten/unwritten_repository.cc
+++ b/paludis/repositories/unwritten/unwritten_repository.cc
@@ -413,7 +413,14 @@ UnwrittenRepository::sync_host_key() const
return _imp->sync_host_key;
}
+const std::shared_ptr<const Set<std::string> >
+UnwrittenRepository::maybe_expand_licence_nonrecursively(const std::string &) const
+{
+ return make_null_shared_ptr();
+}
+
namespace paludis
{
template class Pimp<unwritten_repository::UnwrittenRepository>;
}
+
diff --git a/paludis/repositories/unwritten/unwritten_repository.hh b/paludis/repositories/unwritten/unwritten_repository.hh
index 60cabff..6b67665 100644
--- a/paludis/repositories/unwritten/unwritten_repository.hh
+++ b/paludis/repositories/unwritten/unwritten_repository.hh
@@ -92,6 +92,9 @@ namespace paludis
virtual bool sync(const std::string &, const std::string &, const std::shared_ptr<OutputManager> & output_manager) const;
+ virtual const std::shared_ptr<const Set<std::string> > maybe_expand_licence_nonrecursively(
+ const std::string &) const;
+
///\name RepositoryFactory functions
///\{
diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.cc b/paludis/repositories/virtuals/installed_virtuals_repository.cc
index 27de04c..70e3a91 100644
--- a/paludis/repositories/virtuals/installed_virtuals_repository.cc
+++ b/paludis/repositories/virtuals/installed_virtuals_repository.cc
@@ -270,3 +270,9 @@ InstalledVirtualsRepository::sync_host_key() const
return make_null_shared_ptr();
}
+const std::shared_ptr<const Set<std::string> >
+InstalledVirtualsRepository::maybe_expand_licence_nonrecursively(const std::string &) const
+{
+ return make_null_shared_ptr();
+}
+
diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.hh b/paludis/repositories/virtuals/installed_virtuals_repository.hh
index 88ff6ba..49dc75e 100644
--- a/paludis/repositories/virtuals/installed_virtuals_repository.hh
+++ b/paludis/repositories/virtuals/installed_virtuals_repository.hh
@@ -106,6 +106,9 @@ namespace paludis
virtual bool sync(const std::string &, const std::string &, const std::shared_ptr<OutputManager> &) const;
+ virtual const std::shared_ptr<const Set<std::string> > maybe_expand_licence_nonrecursively(
+ const std::string &) const;
+
/* Keys */
virtual const std::shared_ptr<const MetadataValueKey<std::string> > format_key() const;
diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc
index 8dcb6b3..e85fe84 100644
--- a/paludis/repositories/virtuals/virtuals_repository.cc
+++ b/paludis/repositories/virtuals/virtuals_repository.cc
@@ -219,3 +219,9 @@ VirtualsRepository::sync_host_key() const
return make_null_shared_ptr();
}
+const std::shared_ptr<const Set<std::string> >
+VirtualsRepository::maybe_expand_licence_nonrecursively(const std::string &) const
+{
+ return make_null_shared_ptr();
+}
+
diff --git a/paludis/repositories/virtuals/virtuals_repository.hh b/paludis/repositories/virtuals/virtuals_repository.hh
index ba610a9..09ea90c 100644
--- a/paludis/repositories/virtuals/virtuals_repository.hh
+++ b/paludis/repositories/virtuals/virtuals_repository.hh
@@ -76,6 +76,9 @@ namespace paludis
virtual const bool is_unimportant() const;
+ virtual const std::shared_ptr<const Set<std::string> > maybe_expand_licence_nonrecursively(
+ const std::string &) const;
+
/* Repository */
virtual std::shared_ptr<const PackageIDSequence> package_ids(
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 3d0c523..02b7562 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -373,6 +373,22 @@ namespace paludis
*/
virtual bool some_ids_might_not_be_masked() const = 0;
+ /**
+ * Possibly expand a licence.
+ *
+ * May return a null pointer, if we don't define any licence
+ * groups, or if the thing being passed in doesn't look like a
+ * licence group.
+ *
+ * This should not be recursive.
+ *
+ * Callers should Environment::expand_licence, not this method.
+ *
+ * \since 0.66
+ */
+ virtual const std::shared_ptr<const Set<std::string> > maybe_expand_licence_nonrecursively(
+ const std::string &) const = 0;
+
///\}
///\name Repository behaviour methods