aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-09-06 20:04:42 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-09-06 20:31:28 +0100
commit31c65620a222fcb6f0f8746016e28321ccbe24c1 (patch)
tree368eb9089c00e63f054187f3288cc8ebd99261dc
parenta6b1bd3ad2ce11cb27edf03801ba300a332af1a1 (diff)
downloadpaludis-31c65620a222fcb6f0f8746016e28321ccbe24c1.tar.gz
paludis-31c65620a222fcb6f0f8746016e28321ccbe24c1.tar.xz
Support licence groups
-rw-r--r--paludis/repositories/e/Makefile.am2
-rw-r--r--paludis/repositories/e/e_repository.cc26
-rw-r--r--paludis/repositories/e/exheres_layout.cc10
-rw-r--r--paludis/repositories/e/exheres_layout.hh3
-rw-r--r--paludis/repositories/e/layout.hh3
-rw-r--r--paludis/repositories/e/licence_groups.cc95
-rw-r--r--paludis/repositories/e/licence_groups.hh48
-rw-r--r--paludis/repositories/e/traditional_layout.cc10
-rw-r--r--paludis/repositories/e/traditional_layout.hh3
9 files changed, 197 insertions, 3 deletions
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index 035eb62..c3ecc85 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -72,6 +72,7 @@ noinst_HEADERS = \
fix_locked_dependencies.hh \
glsa.hh \
layout.hh \
+ licence_groups.hh \
make_archive_strings.hh \
make_use.hh \
manifest2_reader.hh \
@@ -152,6 +153,7 @@ libpaludiserepository_la_SOURCES = \
fix_locked_dependencies.cc \
glsa.cc \
layout.cc \
+ licence_groups.cc \
make_archive_strings.cc \
make_use.cc \
manifest2_reader.cc \
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index acde832..ae1ec73 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -42,6 +42,7 @@
#include <paludis/repositories/e/make_use.hh>
#include <paludis/repositories/e/a_finder.hh>
#include <paludis/repositories/e/file_suffixes.hh>
+#include <paludis/repositories/e/licence_groups.hh>
#include <paludis/about.hh>
#include <paludis/action.hh>
@@ -61,9 +62,11 @@
#include <paludis/syncer.hh>
#include <paludis/util/accept_visitor.hh>
+#include <paludis/util/active_object_ptr.hh>
#include <paludis/util/cookie.hh>
#include <paludis/util/config_file.hh>
#include <paludis/util/create_iterator-impl.hh>
+#include <paludis/util/deferred_construction_ptr.hh>
#include <paludis/util/destringify.hh>
#include <paludis/util/extract_host_from_url.hh>
#include <paludis/util/fs_stat.hh>
@@ -184,6 +187,15 @@ namespace
{
return r->arch_flags()->end() != r->arch_flags()->find(p);
}
+
+ std::shared_ptr<LicenceGroups>
+ make_licence_groups(const std::shared_ptr<const MetadataValueKey<FSPath> > & p)
+ {
+ auto result(std::make_shared<LicenceGroups>());
+ if (p)
+ result->add(p->parse_value());
+ return result;
+ }
}
namespace paludis
@@ -262,12 +274,15 @@ namespace paludis
std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > binary_keywords_filter;
std::shared_ptr<const MetadataValueKey<FSPath> > accounts_repository_data_location_key;
std::shared_ptr<const MetadataValueKey<FSPath> > e_updates_location_key;
+ std::shared_ptr<const MetadataValueKey<FSPath> > licence_groups_location_key;
std::shared_ptr<Map<std::string, std::string> > sync_hosts;
std::shared_ptr<const MetadataCollectionKey<Map<std::string, std::string> > > sync_host_key;
std::list<std::shared_ptr<const MetadataKey> > about_keys;
std::shared_ptr<EclassMtimes> eclass_mtimes;
time_t master_mtime;
+
+ const ActiveObjectPtr<DeferredConstructionPtr<std::shared_ptr<LicenceGroups> > > licence_groups;
};
Imp<ERepository>::Imp(ERepository * const r,
@@ -358,10 +373,13 @@ namespace paludis
make_binary_keywords_filter(params.binary_keywords_filter()))),
accounts_repository_data_location_key(layout->accounts_repository_data_location_key()),
e_updates_location_key(layout->e_updates_location_key()),
+ licence_groups_location_key(layout->licence_groups_location_key()),
sync_hosts(std::make_shared<Map<std::string, std::string> >()),
sync_host_key(std::make_shared<LiteralMetadataStringStringMapKey>("sync_host", "sync_host", mkt_internal, sync_hosts)),
eclass_mtimes(std::make_shared<EclassMtimes>(r, params.eclassdirs())),
- master_mtime(0)
+ master_mtime(0),
+ licence_groups(DeferredConstructionPtr<std::shared_ptr<LicenceGroups> > (
+ std::bind(&make_licence_groups, std::cref(licence_groups_location_key))))
{
if ((params.location() / "metadata" / "about.conf").stat().is_regular_file_or_symlink_to_regular_file())
{
@@ -570,6 +588,8 @@ ERepository::_add_metadata_keys() const
add_metadata_key(_imp->accounts_repository_data_location_key);
if (_imp->e_updates_location_key)
add_metadata_key(_imp->e_updates_location_key);
+ if (_imp->licence_groups_location_key)
+ add_metadata_key(_imp->licence_groups_location_key);
add_metadata_key(_imp->sync_host_key);
std::for_each(_imp->about_keys.begin(), _imp->about_keys.end(), std::bind(
@@ -1879,8 +1899,8 @@ ERepository::get_mirrors(const std::string & m) const
}
const std::shared_ptr<const Set<std::string> >
-ERepository::maybe_expand_licence_nonrecursively(const std::string &) const
+ERepository::maybe_expand_licence_nonrecursively(const std::string & s) const
{
- return make_null_shared_ptr();
+ return _imp->licence_groups->maybe_expand_licence_nonrecursively(s);
}
diff --git a/paludis/repositories/e/exheres_layout.cc b/paludis/repositories/e/exheres_layout.cc
index 1fd3e09..54b0553 100644
--- a/paludis/repositories/e/exheres_layout.cc
+++ b/paludis/repositories/e/exheres_layout.cc
@@ -663,6 +663,16 @@ ExheresLayout::e_updates_location_key() const
return make_null_shared_ptr();
}
+std::shared_ptr<MetadataValueKey<FSPath> >
+ExheresLayout::licence_groups_location_key() const
+{
+ if ((_imp->tree_root / "metadata" / "licence_groups.conf").stat().exists())
+ return std::make_shared<LiteralMetadataValueKey<FSPath>>("licence_groups_location",
+ "License groups data location", mkt_internal, _imp->tree_root / "metadata" / "licence_groups.conf");
+ else
+ return make_null_shared_ptr();
+}
+
std::shared_ptr<const MasksInfo>
ExheresLayout::repository_masks(const std::shared_ptr<const PackageID> & id) const
{
diff --git a/paludis/repositories/e/exheres_layout.hh b/paludis/repositories/e/exheres_layout.hh
index 57139e5..732a04d 100644
--- a/paludis/repositories/e/exheres_layout.hh
+++ b/paludis/repositories/e/exheres_layout.hh
@@ -132,6 +132,9 @@ namespace paludis
virtual std::shared_ptr<MetadataValueKey<FSPath> > e_updates_location_key() const
PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual std::shared_ptr<MetadataValueKey<FSPath> > licence_groups_location_key() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
virtual std::shared_ptr<const MasksInfo> repository_masks(const std::shared_ptr<const PackageID> &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
};
diff --git a/paludis/repositories/e/layout.hh b/paludis/repositories/e/layout.hh
index 1e6c109..1144360 100644
--- a/paludis/repositories/e/layout.hh
+++ b/paludis/repositories/e/layout.hh
@@ -155,6 +155,9 @@ namespace paludis
virtual std::shared_ptr<MetadataValueKey<FSPath> > e_updates_location_key() const
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ virtual std::shared_ptr<MetadataValueKey<FSPath> > licence_groups_location_key() const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
virtual FSPath sync_filter_file() const;
virtual std::shared_ptr<const MasksInfo> repository_masks(const std::shared_ptr<const PackageID> &) const
diff --git a/paludis/repositories/e/licence_groups.cc b/paludis/repositories/e/licence_groups.cc
new file mode 100644
index 0000000..c0be7ec
--- /dev/null
+++ b/paludis/repositories/e/licence_groups.cc
@@ -0,0 +1,95 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2011 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/repositories/e/licence_groups.hh>
+#include <paludis/util/pimp-impl.hh>
+#include <paludis/util/fs_path.hh>
+#include <paludis/util/config_file.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/tokeniser.hh>
+#include <paludis/util/set.hh>
+#include <paludis/util/options.hh>
+#include <paludis/util/wrapped_output_iterator.hh>
+#include <paludis/util/make_null_shared_ptr.hh>
+
+#include <vector>
+#include <map>
+
+using namespace paludis;
+using namespace paludis::erepository;
+
+namespace paludis
+{
+ template <>
+ struct Imp<LicenceGroups>
+ {
+ std::map<std::string, std::shared_ptr<Set<std::string> > > store;
+ };
+}
+
+LicenceGroups::LicenceGroups() :
+ _imp()
+{
+}
+
+LicenceGroups::~LicenceGroups()
+{
+}
+
+void
+LicenceGroups::add(const FSPath & p)
+{
+ try
+ {
+ LineConfigFile file(p, { });
+ for (auto l(file.begin()), l_end(file.end()) ;
+ l != l_end ; ++l)
+ {
+ std::vector<std::string> tokens;
+ tokenise_whitespace(*l, std::back_inserter(tokens));
+
+ if (tokens.size() < 2)
+ continue;
+
+ auto i(_imp->store.insert(std::make_pair(tokens.at(0), std::make_shared<Set<std::string> >())).first->second);
+ std::copy(tokens.begin() + 1, tokens.end(), i->inserter());
+ }
+ }
+ catch (const Exception & e)
+ {
+ Log::get_instance()->message("e.licence_groups.bad", ll_warning, lc_no_context)
+ << "Got error '" << e.message() << "' (" << e.what() << ") when parsing " << p;
+ }
+}
+
+const std::shared_ptr<const Set<std::string> >
+LicenceGroups::maybe_expand_licence_nonrecursively(const std::string & s) const
+{
+ if (0 == s.compare(0, 1, "@", 0, 1))
+ {
+ auto i(_imp->store.find(s.substr(1)));
+ if (_imp->store.end() == i)
+ return make_null_shared_ptr();
+ else
+ return i->second;
+ }
+ else
+ return make_null_shared_ptr();
+}
+
diff --git a/paludis/repositories/e/licence_groups.hh b/paludis/repositories/e/licence_groups.hh
new file mode 100644
index 0000000..7de7e6e
--- /dev/null
+++ b/paludis/repositories/e/licence_groups.hh
@@ -0,0 +1,48 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2011 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_LICENCE_GROUPS_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_LICENCE_GROUPS_HH 1
+
+#include <paludis/util/pimp.hh>
+#include <paludis/util/fs_path-fwd.hh>
+#include <memory>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ class LicenceGroups
+ {
+ private:
+ Pimp<LicenceGroups> _imp;
+
+ public:
+ LicenceGroups();
+ ~LicenceGroups();
+
+ void add(const FSPath &);
+
+ const std::shared_ptr<const Set<std::string> > maybe_expand_licence_nonrecursively(
+ const std::string &) const;
+ };
+ }
+}
+
+#endif
diff --git a/paludis/repositories/e/traditional_layout.cc b/paludis/repositories/e/traditional_layout.cc
index 6917db0..fec622e 100644
--- a/paludis/repositories/e/traditional_layout.cc
+++ b/paludis/repositories/e/traditional_layout.cc
@@ -685,6 +685,16 @@ TraditionalLayout::e_updates_location_key() const
return make_null_shared_ptr();
}
+std::shared_ptr<MetadataValueKey<FSPath> >
+TraditionalLayout::licence_groups_location_key() const
+{
+ if ((_imp->tree_root / "profiles" / "license_groups").stat().exists())
+ return std::make_shared<LiteralMetadataValueKey<FSPath>>("licence_groups_location",
+ "License groups data location", mkt_internal, _imp->tree_root / "profiles" / "license_groups");
+ else
+ return make_null_shared_ptr();
+}
+
std::shared_ptr<const MasksInfo>
TraditionalLayout::repository_masks(const std::shared_ptr<const PackageID> & id) const
{
diff --git a/paludis/repositories/e/traditional_layout.hh b/paludis/repositories/e/traditional_layout.hh
index 99e1c04..973dab5 100644
--- a/paludis/repositories/e/traditional_layout.hh
+++ b/paludis/repositories/e/traditional_layout.hh
@@ -136,6 +136,9 @@ namespace paludis
virtual std::shared_ptr<MetadataValueKey<FSPath> > e_updates_location_key() const
PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual std::shared_ptr<MetadataValueKey<FSPath> > licence_groups_location_key() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
virtual FSPath sync_filter_file() const;
virtual std::shared_ptr<const MasksInfo> repository_masks(const std::shared_ptr<const PackageID> &) const