diff options
author | 2011-09-06 16:51:19 +0100 | |
---|---|---|
committer | 2011-09-06 16:51:19 +0100 | |
commit | cea9adc3df54e1bdeac88ff628cd91b53b9e549e (patch) | |
tree | 24ed874efc9139bc9184f24cbe0e7e360dc18a7d | |
parent | 39d5d8c84aba37c41f0e689a544615bd21c5c60d (diff) | |
download | paludis-cea9adc3df54e1bdeac88ff628cd91b53b9e549e.tar.gz paludis-cea9adc3df54e1bdeac88ff628cd91b53b9e549e.tar.xz |
Framework for licence groups
30 files changed, 182 insertions, 0 deletions
diff --git a/paludis/environment.hh b/paludis/environment.hh index eec7e619d..8e6b5ff55 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 af27080ef..a47a3dc07 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 c256ce0a2..d32fbad85 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 1ae62541f..ea00958cc 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 5f8eb72b5..54b844a2e 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 7d8ebfff4..e021f777b 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 365626386..977407c38 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 332242029..acde8325e 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 3c52aa7d5..f3fc5dc39 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 18591535b..b54aab1c9 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 5b61bbaf5..87725315d 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 459a25d5c..dea5a108b 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 e6720fb35..9c8abeb39 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 649513274..381febbdc 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 e93a0c08b..4fc5658e0 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 b4a40394d..ac7598c21 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 8b2a683ca..1cbfb2e27 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 ce0da3552..9ce26190a 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 f75100601..6403f7c3b 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 3b61b5f67..3d85034b9 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 9b1c2d428..d8c7e6ead 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 1d3df374d..a829cf187 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 a11936d1e..d49255ef9 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 e2afa53e4..445b31d25 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 60cabffd5..6b67665dd 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 27de04c8f..70e3a9154 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 88ff6bafc..49dc75e5e 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 8dcb6b3c0..e85fe848e 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 ba610a96c..09ea90cc6 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 3d0c523b1..02b7562ec 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 |