aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Fernando J. Pereda <ferdy@ferdyx.org> 2007-02-14 19:33:02 +0000
committerAvatar Fernando J. Pereda <ferdy@ferdyx.org> 2007-02-14 19:33:02 +0000
commitf988baf83c2a6279e6ae9cd550493bcc9308d52a (patch)
tree13ee15a0f237d8665be61529836c8d2f48c9366f
parentd40f6d1309d74122941ab148a624a9976b3c4449 (diff)
downloadpaludis-f988baf83c2a6279e6ae9cd550493bcc9308d52a.tar.gz
paludis-f988baf83c2a6279e6ae9cd550493bcc9308d52a.tar.xz
Implement licenses interface.
-rw-r--r--paludis/qa/license_check.cc6
-rw-r--r--paludis/repositories/cran/cran_installed_repository.cc3
-rw-r--r--paludis/repositories/cran/cran_repository.cc9
-rw-r--r--paludis/repositories/cran/cran_repository.hh2
-rw-r--r--paludis/repositories/fake/fake_installed_repository.cc3
-rw-r--r--paludis/repositories/fake/fake_repository.cc3
-rw-r--r--paludis/repositories/gems/gems_repository.cc9
-rw-r--r--paludis/repositories/gems/gems_repository.hh2
-rw-r--r--paludis/repositories/gentoo/portage_repository.cc26
-rw-r--r--paludis/repositories/gentoo/portage_repository.hh4
-rw-r--r--paludis/repositories/gentoo/vdb_repository.cc9
-rw-r--r--paludis/repositories/gentoo/vdb_repository.hh2
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.cc9
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.hh2
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc3
-rw-r--r--paludis/repository.cc3
-rw-r--r--paludis/repository.hh62
-rw-r--r--paludis/repository.sr1
18 files changed, 84 insertions, 74 deletions
diff --git a/paludis/qa/license_check.cc b/paludis/qa/license_check.cc
index 409401a..e761aa2 100644
--- a/paludis/qa/license_check.cc
+++ b/paludis/qa/license_check.cc
@@ -52,8 +52,10 @@ namespace
void visit(const PlainTextDepAtom * const a)
{
- if (! env->package_database()->fetch_repository(
- env->portage_repository()->name())->is_license(a->text()))
+ RepositoryLicensesInterface *li(env->package_database()->fetch_repository(
+ env->portage_repository()->name())->licenses_interface);
+
+ if (li && ! li->license_exists(a->text()))
result << Message(qal_major, "Item '" + a->text() + "' is not a licence");
}
diff --git a/paludis/repositories/cran/cran_installed_repository.cc b/paludis/repositories/cran/cran_installed_repository.cc
index 2d6ca7b..4a359b4 100644
--- a/paludis/repositories/cran/cran_installed_repository.cc
+++ b/paludis/repositories/cran/cran_installed_repository.cc
@@ -185,7 +185,8 @@ CRANInstalledRepository::CRANInstalledRepository(const CRANInstalledRepositoryPa
.virtuals_interface(0)
.provides_interface(0)
.config_interface(0)
- .destination_interface(this),
+ .destination_interface(this)
+ .licenses_interface(0),
"cran_installed"),
PrivateImplementationPattern<CRANInstalledRepository>(new Implementation<CRANInstalledRepository>(p))
{
diff --git a/paludis/repositories/cran/cran_repository.cc b/paludis/repositories/cran/cran_repository.cc
index 3598952..8601e41 100644
--- a/paludis/repositories/cran/cran_repository.cc
+++ b/paludis/repositories/cran/cran_repository.cc
@@ -179,7 +179,8 @@ CRANRepository::CRANRepository(const CRANRepositoryParams & p) :
.destination_interface(0)
.virtuals_interface(0)
.config_interface(0)
- .contents_interface(0),
+ .contents_interface(0)
+ .licenses_interface(0),
"cran"),
PrivateImplementationPattern<CRANRepository>(new Implementation<CRANRepository>(p))
{
@@ -467,12 +468,6 @@ CRANRepositoryConfigurationError::CRANRepositoryConfigurationError(
{
}
-bool
-CRANRepository::do_is_licence(const std::string &) const
-{
- return false;
-}
-
void
CRANRepository::do_install(const QualifiedPackageName &q, const VersionSpec &vn,
const InstallOptions &o) const
diff --git a/paludis/repositories/cran/cran_repository.hh b/paludis/repositories/cran/cran_repository.hh
index 4bfa4a5..f718120 100644
--- a/paludis/repositories/cran/cran_repository.hh
+++ b/paludis/repositories/cran/cran_repository.hh
@@ -80,8 +80,6 @@ namespace paludis
const QualifiedPackageName &,
const VersionSpec &) const;
- virtual bool do_is_licence(const std::string &) const;
-
virtual void do_install(const QualifiedPackageName &, const VersionSpec &,
const InstallOptions &) const;
diff --git a/paludis/repositories/fake/fake_installed_repository.cc b/paludis/repositories/fake/fake_installed_repository.cc
index 7eb85a8..65a584d 100644
--- a/paludis/repositories/fake/fake_installed_repository.cc
+++ b/paludis/repositories/fake/fake_installed_repository.cc
@@ -42,7 +42,8 @@ FakeInstalledRepository::FakeInstalledRepository(const Environment * const e, co
.provides_interface(this)
.virtuals_interface(0)
.config_interface(0)
- .destination_interface(this),
+ .destination_interface(this)
+ .licenses_interface(0),
"fake_installed")
{
}
diff --git a/paludis/repositories/fake/fake_repository.cc b/paludis/repositories/fake/fake_repository.cc
index d5ca058..472aa1f 100644
--- a/paludis/repositories/fake/fake_repository.cc
+++ b/paludis/repositories/fake/fake_repository.cc
@@ -40,7 +40,8 @@ FakeRepository::FakeRepository(const Environment * const e, const RepositoryName
.provides_interface(0)
.virtuals_interface(this)
.config_interface(0)
- .destination_interface(0),
+ .destination_interface(0)
+ .licenses_interface(0),
"fake"),
_virtual_packages(new VirtualsCollection::Concrete)
{
diff --git a/paludis/repositories/gems/gems_repository.cc b/paludis/repositories/gems/gems_repository.cc
index 9feeb54..2d188a2 100644
--- a/paludis/repositories/gems/gems_repository.cc
+++ b/paludis/repositories/gems/gems_repository.cc
@@ -175,12 +175,6 @@ GemsRepository::do_version_metadata(const QualifiedPackageName & q, const Versio
return j->second.metadata;
}
-bool
-GemsRepository::do_is_licence(const std::string &) const
-{
- return false;
-}
-
void
GemsRepository::do_install(const QualifiedPackageName &, const VersionSpec &, const InstallOptions &) const
{
@@ -261,7 +255,8 @@ GemsRepository::GemsRepository(const GemsRepositoryParams & p) :
.virtuals_interface(0)
.provides_interface(0)
.config_interface(0)
- .destination_interface(0),
+ .destination_interface(0)
+ .licenses_interface(0),
"gems"),
PrivateImplementationPattern<GemsRepository>(new Implementation<GemsRepository>(p))
{
diff --git a/paludis/repositories/gems/gems_repository.hh b/paludis/repositories/gems/gems_repository.hh
index 7927b60..ebed433 100644
--- a/paludis/repositories/gems/gems_repository.hh
+++ b/paludis/repositories/gems/gems_repository.hh
@@ -40,8 +40,6 @@ namespace paludis
const QualifiedPackageName &,
const VersionSpec &) const;
- virtual bool do_is_licence(const std::string &) const;
-
virtual void do_install(const QualifiedPackageName &, const VersionSpec &,
const InstallOptions &) const;
diff --git a/paludis/repositories/gentoo/portage_repository.cc b/paludis/repositories/gentoo/portage_repository.cc
index bbd9665..26c2962 100644
--- a/paludis/repositories/gentoo/portage_repository.cc
+++ b/paludis/repositories/gentoo/portage_repository.cc
@@ -290,7 +290,8 @@ PortageRepository::PortageRepository(const PortageRepositoryParams & p) :
.provides_interface(0)
.contents_interface(0)
.config_interface(0)
- .destination_interface(0),
+ .destination_interface(0)
+ .licenses_interface(this),
p.entry_format),
PrivateImplementationPattern<PortageRepository>(new Implementation<PortageRepository>(this, p))
{
@@ -744,17 +745,24 @@ PortageRepository::do_arch_flags() const
return _imp->arch_flags;
}
-bool
-PortageRepository::do_is_licence(const std::string & s) const
+std::tr1::shared_ptr<FSEntry>
+PortageRepository::do_license_exists(const std::string & license) const
{
- FSEntry l(_imp->params.location);
- l /= "licenses";
+ std::tr1::shared_ptr<FSEntry> p;
- if (! l.is_directory())
- return false;
+ if (_imp->params.master_repository)
+ {
+ FSEntry l(_imp->params.master_repository->params().location /
+ "licenses" / license);
+ if (l.exists() && l.is_regular_file())
+ p.reset(new FSEntry(l));
+ }
+
+ FSEntry l(_imp->params.location / "licenses" / license);
+ if (l.exists() && l.is_regular_file())
+ p.reset(new FSEntry(l));
- l /= s;
- return l.exists() && l.is_regular_file();
+ return p;
}
void
diff --git a/paludis/repositories/gentoo/portage_repository.hh b/paludis/repositories/gentoo/portage_repository.hh
index 26a0803..23ff2ed 100644
--- a/paludis/repositories/gentoo/portage_repository.hh
+++ b/paludis/repositories/gentoo/portage_repository.hh
@@ -59,6 +59,7 @@ namespace paludis
public RepositoryEnvironmentVariableInterface,
public RepositoryMirrorsInterface,
public RepositoryVirtualsInterface,
+ public RepositoryLicensesInterface,
private PrivateImplementationPattern<PortageRepository>
{
private:
@@ -101,7 +102,8 @@ namespace paludis
virtual bool do_query_profile_masks(const QualifiedPackageName &,
const VersionSpec &) const;
- virtual bool do_is_licence(const std::string &) const;
+ virtual std::tr1::shared_ptr<FSEntry> do_license_exists(
+ const std::string & license) const;
virtual void do_install(const QualifiedPackageName &, const VersionSpec &,
const InstallOptions &) const;
diff --git a/paludis/repositories/gentoo/vdb_repository.cc b/paludis/repositories/gentoo/vdb_repository.cc
index 87061fe..0758b02 100644
--- a/paludis/repositories/gentoo/vdb_repository.cc
+++ b/paludis/repositories/gentoo/vdb_repository.cc
@@ -519,7 +519,8 @@ VDBRepository::VDBRepository(const VDBRepositoryParams & p) :
.virtuals_interface(0)
.destination_interface(this)
.config_interface(this)
- .contents_interface(this),
+ .contents_interface(this)
+ .licenses_interface(0),
"vdb"),
PrivateImplementationPattern<VDBRepository>(new Implementation<VDBRepository>(this, p))
{
@@ -906,12 +907,6 @@ VDBRepositoryKeyReadError::VDBRepositoryKeyReadError(
{
}
-bool
-VDBRepository::do_is_licence(const std::string &) const
-{
- return false;
-}
-
void
VDBRepository::do_uninstall(const QualifiedPackageName & q, const VersionSpec & v, const UninstallOptions & o) const
{
diff --git a/paludis/repositories/gentoo/vdb_repository.hh b/paludis/repositories/gentoo/vdb_repository.hh
index 9b5b27c..38179ac 100644
--- a/paludis/repositories/gentoo/vdb_repository.hh
+++ b/paludis/repositories/gentoo/vdb_repository.hh
@@ -94,8 +94,6 @@ namespace paludis
const QualifiedPackageName &,
const VersionSpec &) const;
- virtual bool do_is_licence(const std::string &) const;
-
virtual void do_uninstall(const QualifiedPackageName &, const VersionSpec &,
const UninstallOptions &) const;
diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.cc b/paludis/repositories/virtuals/installed_virtuals_repository.cc
index 006e0a0..786c329 100644
--- a/paludis/repositories/virtuals/installed_virtuals_repository.cc
+++ b/paludis/repositories/virtuals/installed_virtuals_repository.cc
@@ -100,7 +100,8 @@ InstalledVirtualsRepository::InstalledVirtualsRepository(const Environment * con
.virtuals_interface(0)
.contents_interface(0)
.config_interface(0)
- .destination_interface(0),
+ .destination_interface(0)
+ .licenses_interface(0),
"installed_virtuals"),
PrivateImplementationPattern<InstalledVirtualsRepository>(
new Implementation<InstalledVirtualsRepository>(env, r))
@@ -321,12 +322,6 @@ InstalledVirtualsRepository::do_has_category_named(const CategoryNamePart & c) c
return p.first != p.second;
}
-bool
-InstalledVirtualsRepository::do_is_licence(const std::string &) const
-{
- return false;
-}
-
void
InstalledVirtualsRepository::invalidate()
{
diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.hh b/paludis/repositories/virtuals/installed_virtuals_repository.hh
index 2f032b1..b901e1d 100644
--- a/paludis/repositories/virtuals/installed_virtuals_repository.hh
+++ b/paludis/repositories/virtuals/installed_virtuals_repository.hh
@@ -64,8 +64,6 @@ namespace paludis
virtual bool do_has_category_named(const CategoryNamePart &) const;
- virtual bool do_is_licence(const std::string &) const;
-
public:
///\name Basic operations
//\{
diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc
index db0f581..2abb68b 100644
--- a/paludis/repositories/virtuals/virtuals_repository.cc
+++ b/paludis/repositories/virtuals/virtuals_repository.cc
@@ -90,7 +90,8 @@ VirtualsRepository::VirtualsRepository(const Environment * const env) :
.virtuals_interface(0)
.destination_interface(0)
.config_interface(0)
- .contents_interface(0),
+ .contents_interface(0)
+ .licenses_interface(0),
"virtuals"),
PrivateImplementationPattern<VirtualsRepository>(
new Implementation<VirtualsRepository>(env))
diff --git a/paludis/repository.cc b/paludis/repository.cc
index 25bf8bf..2d06675 100644
--- a/paludis/repository.cc
+++ b/paludis/repository.cc
@@ -275,3 +275,6 @@ RepositoryConfigInterface::~RepositoryConfigInterface()
{
}
+RepositoryLicensesInterface::~RepositoryLicensesInterface()
+{
+}
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 2618254..45941d1 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -65,6 +65,7 @@ namespace paludis
class RepositoryDestinationInterface;
class RepositoryContentsInterface;
class RepositoryConfigInterface;
+ class RepositoryLicensesInterface;
/**
* What debug build option to use when installing a package.
@@ -248,20 +249,6 @@ namespace paludis
///\}
- /**
- * \name Implementations: misc files
- *
- * Various utility functions related to misc files.
- */
- ///\{
-
- /**
- * Override in descendents: is this a licence?
- */
- virtual bool do_is_licence(const std::string &) const = 0;
-
- ///\}
-
public:
///\name Basic operations
///\{
@@ -370,14 +357,6 @@ namespace paludis
return do_version_metadata(q, v);
}
- /**
- * Query whether the specified item is a licence.
- */
- bool is_license(const std::string & u) const
- {
- return do_is_licence(u);
- }
-
///\}
///\name Repository behaviour methods
@@ -1115,6 +1094,45 @@ namespace paludis
};
/**
+ * Interface for handling actions relating to licenses.
+ *
+ * \see Repository
+ * \ingroup grprepository
+ * \nosubgrouping
+ */
+ class RepositoryLicensesInterface
+ {
+ protected:
+ ///\name Implementation details
+ ///\{
+
+ /**
+ * Override in descendents: do the actual check,
+ */
+ virtual std::tr1::shared_ptr<FSEntry>
+ do_license_exists(const std::string & license) const = 0;
+
+ ///\}
+
+ public:
+ ///\name License related queries
+ ///\{
+
+ /**
+ * Check if a license exists
+ */
+ std::tr1::shared_ptr<FSEntry>
+ license_exists(const std::string & license) const
+ {
+ return do_license_exists(license);
+ }
+
+ ///\}
+
+ virtual ~RepositoryLicensesInterface();
+ };
+
+ /**
* Thrown if a repository of the specified type does not exist.
*
* \ingroup grpexceptions
diff --git a/paludis/repository.sr b/paludis/repository.sr
index f1efb5f..7878ad0 100644
--- a/paludis/repository.sr
+++ b/paludis/repository.sr
@@ -51,6 +51,7 @@ make_class_RepositoryCapabilities()
key destination_interface "RepositoryDestinationInterface *"
key contents_interface "RepositoryContentsInterface *"
key config_interface "RepositoryConfigInterface *"
+ key licenses_interface "RepositoryLicensesInterface *"
doxygen_comment << "END"
/**