aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-12-18 16:07:48 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-12-18 16:07:48 +0000
commit101d43eed4a8199d15aa17ee863dd31a68961068 (patch)
treefe953e28c97a5aa9d1b563ede088d03c702825ef
parentd94710fb9bffe18a45628107e7a8976caae60cbe (diff)
downloadpaludis-101d43eed4a8199d15aa17ee863dd31a68961068.tar.gz
paludis-101d43eed4a8199d15aa17ee863dd31a68961068.tar.xz
Add a new RepositoryDestinationInterface. Make repositories aware of their own format. Make PortageRepository's format match its entry format
-rw-r--r--paludis/repositories/cran/cran_installed_repository.cc10
-rw-r--r--paludis/repositories/cran/cran_installed_repository.hh3
-rw-r--r--paludis/repositories/cran/cran_repository.cc4
-rw-r--r--paludis/repositories/fake/fake_installed_repository.cc11
-rw-r--r--paludis/repositories/fake/fake_installed_repository.hh5
-rw-r--r--paludis/repositories/fake/fake_repository.cc4
-rw-r--r--paludis/repositories/fake/fake_repository_base.cc5
-rw-r--r--paludis/repositories/fake/fake_repository_base.hh3
-rw-r--r--paludis/repositories/gems/gems_repository.cc4
-rw-r--r--paludis/repositories/nothing/nothing_repository.cc4
-rw-r--r--paludis/repositories/portage/portage_repository.cc6
-rw-r--r--paludis/repositories/vdb/vdb_repository.cc10
-rw-r--r--paludis/repositories/vdb/vdb_repository.hh3
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.cc4
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc4
-rw-r--r--paludis/repository.cc10
-rw-r--r--paludis/repository.hh30
-rw-r--r--paludis/repository.sr1
-rw-r--r--ruby/repository_TEST.rb2
19 files changed, 105 insertions, 18 deletions
diff --git a/paludis/repositories/cran/cran_installed_repository.cc b/paludis/repositories/cran/cran_installed_repository.cc
index 737af8d..fc49132 100644
--- a/paludis/repositories/cran/cran_installed_repository.cc
+++ b/paludis/repositories/cran/cran_installed_repository.cc
@@ -166,7 +166,9 @@ CRANInstalledRepository::CRANInstalledRepository(const CRANInstalledRepositoryPa
.environment_variable_interface(0)
.mirrors_interface(0)
.virtuals_interface(0)
- .provides_interface(0)),
+ .provides_interface(0)
+ .destination_interface(this),
+ "cran_installed"),
PrivateImplementationPattern<CRANInstalledRepository>(new Implementation<CRANInstalledRepository>(p))
{
RepositoryInfoSection::Pointer config_info(new RepositoryInfoSection("Configuration information"));
@@ -652,6 +654,12 @@ CRANInstalledRepository::remove_from_world(const QualifiedPackageName & n) const
std::ostream_iterator<std::string>(world_file, "\n"));
}
+bool
+CRANInstalledRepository::is_suitable_destination_for(const PackageDatabaseEntry & e) const
+{
+ return _imp->env->package_database()->fetch_repository(e.repository)->format() == "cran";
+}
+
#ifdef PALUDIS_ENABLE_VISIBILITY
# pragma GCC visibility push(default)
#endif
diff --git a/paludis/repositories/cran/cran_installed_repository.hh b/paludis/repositories/cran/cran_installed_repository.hh
index 6c81da6..04bf660 100644
--- a/paludis/repositories/cran/cran_installed_repository.hh
+++ b/paludis/repositories/cran/cran_installed_repository.hh
@@ -49,6 +49,7 @@ namespace paludis
public RepositoryUninstallableInterface,
public RepositorySetsInterface,
public RepositoryWorldInterface,
+ public RepositoryDestinationInterface,
public PrivateImplementationPattern<CRANInstalledRepository>
{
protected:
@@ -112,6 +113,8 @@ namespace paludis
virtual void add_to_world(const QualifiedPackageName &) const;
virtual void remove_from_world(const QualifiedPackageName &) const;
+
+ virtual bool is_suitable_destination_for(const PackageDatabaseEntry &) const;
};
/**
diff --git a/paludis/repositories/cran/cran_repository.cc b/paludis/repositories/cran/cran_repository.cc
index 8fc62b1..54d5512 100644
--- a/paludis/repositories/cran/cran_repository.cc
+++ b/paludis/repositories/cran/cran_repository.cc
@@ -194,7 +194,9 @@ CRANRepository::CRANRepository(const CRANRepositoryParams & p) :
.environment_variable_interface(0)
.mirrors_interface(0)
.provides_interface(0)
- .virtuals_interface(0)),
+ .destination_interface(0)
+ .virtuals_interface(0),
+ "cran"),
PrivateImplementationPattern<CRANRepository>(new Implementation<CRANRepository>(p))
{
RepositoryInfoSection::Pointer config_info(new RepositoryInfoSection("Configuration information"));
diff --git a/paludis/repositories/fake/fake_installed_repository.cc b/paludis/repositories/fake/fake_installed_repository.cc
index 9117f6e..29f43d5 100644
--- a/paludis/repositories/fake/fake_installed_repository.cc
+++ b/paludis/repositories/fake/fake_installed_repository.cc
@@ -35,7 +35,9 @@ FakeInstalledRepository::FakeInstalledRepository(const RepositoryName & our_name
.mirrors_interface(0)
.environment_variable_interface(0)
.provides_interface(0)
- .virtuals_interface(0))
+ .virtuals_interface(0)
+ .destination_interface(this),
+ "fake_installed")
{
}
@@ -47,3 +49,10 @@ FakeInstalledRepository::do_contents(const QualifiedPackageName &,
return result;
}
+bool
+FakeInstalledRepository::is_suitable_destination_for(const PackageDatabaseEntry &) const
+{
+ return true;
+}
+
+
diff --git a/paludis/repositories/fake/fake_installed_repository.hh b/paludis/repositories/fake/fake_installed_repository.hh
index a7a1399..34a7658 100644
--- a/paludis/repositories/fake/fake_installed_repository.hh
+++ b/paludis/repositories/fake/fake_installed_repository.hh
@@ -31,7 +31,8 @@ namespace paludis
*/
class PALUDIS_VISIBLE FakeInstalledRepository :
public FakeRepositoryBase,
- public RepositoryInstalledInterface
+ public RepositoryInstalledInterface,
+ public RepositoryDestinationInterface
{
protected:
virtual Contents::ConstPointer do_contents(
@@ -40,6 +41,8 @@ namespace paludis
public:
FakeInstalledRepository(const RepositoryName &);
+
+ bool is_suitable_destination_for(const PackageDatabaseEntry &) const;
};
}
diff --git a/paludis/repositories/fake/fake_repository.cc b/paludis/repositories/fake/fake_repository.cc
index b69bcb3..d58fdb2 100644
--- a/paludis/repositories/fake/fake_repository.cc
+++ b/paludis/repositories/fake/fake_repository.cc
@@ -35,7 +35,9 @@ FakeRepository::FakeRepository(const RepositoryName & our_name) :
.mirrors_interface(0)
.environment_variable_interface(0)
.provides_interface(0)
- .virtuals_interface(0))
+ .virtuals_interface(0)
+ .destination_interface(0),
+ "fake")
{
}
diff --git a/paludis/repositories/fake/fake_repository_base.cc b/paludis/repositories/fake/fake_repository_base.cc
index 5aa9037..b6b5b01 100644
--- a/paludis/repositories/fake/fake_repository_base.cc
+++ b/paludis/repositories/fake/fake_repository_base.cc
@@ -73,8 +73,9 @@ namespace paludis
}
}
-FakeRepositoryBase::FakeRepositoryBase(const RepositoryName & our_name, const RepositoryCapabilities & caps) :
- Repository(our_name, caps),
+FakeRepositoryBase::FakeRepositoryBase(const RepositoryName & our_name, const RepositoryCapabilities & caps,
+ const std::string & f) :
+ Repository(our_name, caps, f),
RepositoryMaskInterface(),
RepositoryUseInterface(),
PrivateImplementationPattern<FakeRepositoryBase>(new Implementation<FakeRepositoryBase>)
diff --git a/paludis/repositories/fake/fake_repository_base.hh b/paludis/repositories/fake/fake_repository_base.hh
index c1e9530..5d0090f 100644
--- a/paludis/repositories/fake/fake_repository_base.hh
+++ b/paludis/repositories/fake/fake_repository_base.hh
@@ -95,7 +95,8 @@ namespace paludis
/**
* Constructor.
*/
- FakeRepositoryBase(const RepositoryName & name, const RepositoryCapabilities & caps);
+ FakeRepositoryBase(const RepositoryName & name, const RepositoryCapabilities & caps,
+ const std::string &);
public:
/**
diff --git a/paludis/repositories/gems/gems_repository.cc b/paludis/repositories/gems/gems_repository.cc
index 7b0da16..26f77ca 100644
--- a/paludis/repositories/gems/gems_repository.cc
+++ b/paludis/repositories/gems/gems_repository.cc
@@ -259,7 +259,9 @@ GemsRepository::GemsRepository(const GemsRepositoryParams & p) :
.environment_variable_interface(0)
.mirrors_interface(0)
.virtuals_interface(0)
- .provides_interface(0)),
+ .provides_interface(0)
+ .destination_interface(0),
+ "gems"),
PrivateImplementationPattern<GemsRepository>(new Implementation<GemsRepository>(p))
{
}
diff --git a/paludis/repositories/nothing/nothing_repository.cc b/paludis/repositories/nothing/nothing_repository.cc
index 4960daf..3b69f0d 100644
--- a/paludis/repositories/nothing/nothing_repository.cc
+++ b/paludis/repositories/nothing/nothing_repository.cc
@@ -100,7 +100,9 @@ NothingRepository::NothingRepository(const NothingRepositoryParams & p) try :
.environment_variable_interface(0)
.mirrors_interface(0)
.virtuals_interface(0)
- .provides_interface(0)),
+ .provides_interface(0)
+ .destination_interface(0),
+ "nothing"),
PrivateImplementationPattern<NothingRepository>(new Implementation<NothingRepository>(p))
{
RepositoryInfoSection::Pointer config_info(new RepositoryInfoSection("Configuration information"));
diff --git a/paludis/repositories/portage/portage_repository.cc b/paludis/repositories/portage/portage_repository.cc
index cfccd7a..64f3088 100644
--- a/paludis/repositories/portage/portage_repository.cc
+++ b/paludis/repositories/portage/portage_repository.cc
@@ -286,7 +286,9 @@ PortageRepository::PortageRepository(const PortageRepositoryParams & p) :
.environment_variable_interface(this)
.mirrors_interface(this)
.virtuals_interface(this)
- .provides_interface(0)),
+ .provides_interface(0)
+ .destination_interface(0),
+ p.entry_format),
PrivateImplementationPattern<PortageRepository>(new Implementation<PortageRepository>(this, p))
{
// the info_vars and info_pkgs info is only added on demand, since it's
@@ -306,7 +308,7 @@ PortageRepository::PortageRepository(const PortageRepositoryParams & p) :
config_info->add_kv("securitydir", stringify(_imp->params.securitydir));
config_info->add_kv("setsdir", stringify(_imp->params.setsdir));
config_info->add_kv("newsdir", stringify(_imp->params.newsdir));
- config_info->add_kv("format", "portage");
+ config_info->add_kv("format", _imp->params.entry_format);
config_info->add_kv("root", stringify(_imp->params.root));
config_info->add_kv("buildroot", stringify(_imp->params.buildroot));
config_info->add_kv("sync", _imp->params.sync);
diff --git a/paludis/repositories/vdb/vdb_repository.cc b/paludis/repositories/vdb/vdb_repository.cc
index f8195d0..e492945 100644
--- a/paludis/repositories/vdb/vdb_repository.cc
+++ b/paludis/repositories/vdb/vdb_repository.cc
@@ -507,7 +507,9 @@ VDBRepository::VDBRepository(const VDBRepositoryParams & p) :
.environment_variable_interface(this)
.mirrors_interface(0)
.provides_interface(this)
- .virtuals_interface(0)),
+ .virtuals_interface(0)
+ .destination_interface(this),
+ "vdb"),
PrivateImplementationPattern<VDBRepository>(new Implementation<VDBRepository>(this, p))
{
RepositoryInfoSection::Pointer config_info(new RepositoryInfoSection("Configuration information"));
@@ -1427,6 +1429,12 @@ VDBRepository::do_category_names_containing_package(const PackageNamePart & p) c
return result ? result : Repository::do_category_names_containing_package(p);
}
+bool
+VDBRepository::is_suitable_destination_for(const PackageDatabaseEntry & e) const
+{
+ return _imp->env->package_database()->fetch_repository(e.repository)->format() == "ebuild";
+}
+
#ifdef PALUDIS_ENABLE_VISIBILITY
# pragma GCC visibility push(default)
#endif
diff --git a/paludis/repositories/vdb/vdb_repository.hh b/paludis/repositories/vdb/vdb_repository.hh
index 9ed53de..4d1b39f 100644
--- a/paludis/repositories/vdb/vdb_repository.hh
+++ b/paludis/repositories/vdb/vdb_repository.hh
@@ -53,6 +53,7 @@ namespace paludis
public RepositoryWorldInterface,
public RepositoryEnvironmentVariableInterface,
public RepositoryProvidesInterface,
+ public RepositoryDestinationInterface,
public PrivateImplementationPattern<VDBRepository>
{
private:
@@ -150,6 +151,8 @@ namespace paludis
virtual SetsCollection::ConstPointer sets_list() const;
+ virtual bool is_suitable_destination_for(const PackageDatabaseEntry &) const;
+
typedef CountedPtr<VDBRepository, count_policy::InternalCountTag> Pointer;
typedef CountedPtr<const VDBRepository, count_policy::InternalCountTag> ConstPointer;
};
diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.cc b/paludis/repositories/virtuals/installed_virtuals_repository.cc
index 6c8807c..4317cef 100644
--- a/paludis/repositories/virtuals/installed_virtuals_repository.cc
+++ b/paludis/repositories/virtuals/installed_virtuals_repository.cc
@@ -62,7 +62,9 @@ InstalledVirtualsRepository::InstalledVirtualsRepository(const Environment * con
.environment_variable_interface(0)
.world_interface(0)
.provides_interface(0)
- .virtuals_interface(0)),
+ .virtuals_interface(0)
+ .destination_interface(0),
+ "installed_virtuals"),
PrivateImplementationPattern<InstalledVirtualsRepository>(
new Implementation<InstalledVirtualsRepository>(env))
{
diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc
index adb05b2..6382f2f 100644
--- a/paludis/repositories/virtuals/virtuals_repository.cc
+++ b/paludis/repositories/virtuals/virtuals_repository.cc
@@ -88,7 +88,9 @@ VirtualsRepository::VirtualsRepository(const Environment * const env) :
.environment_variable_interface(0)
.world_interface(0)
.provides_interface(0)
- .virtuals_interface(0)),
+ .virtuals_interface(0)
+ .destination_interface(0),
+ "virtuals"),
PrivateImplementationPattern<VirtualsRepository>(
new Implementation<VirtualsRepository>(env))
{
diff --git a/paludis/repository.cc b/paludis/repository.cc
index 707f7e6..a40d111 100644
--- a/paludis/repository.cc
+++ b/paludis/repository.cc
@@ -36,9 +36,11 @@ using namespace paludis;
Repository::Repository(
const RepositoryName & our_name,
- const RepositoryCapabilities & caps) :
+ const RepositoryCapabilities & caps,
+ const std::string & f) :
RepositoryCapabilities(caps),
_name(our_name),
+ _format(f),
_info(new RepositoryInfo)
{
}
@@ -200,3 +202,9 @@ Repository::regenerate_cache() const
{
}
+std::string
+Repository::format() const
+{
+ return _format;
+}
+
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 4d06154..e5c279a 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -61,6 +61,7 @@ namespace paludis
class RepositoryMirrorsInterface;
class RepositoryProvidesInterface;
class RepositoryVirtualsInterface;
+ class RepositoryDestinationInterface;
/**
* What debug build option to use when installing a package.
@@ -170,6 +171,7 @@ namespace paludis
{
private:
const RepositoryName _name;
+ std::string _format;
protected:
///\name Implementation data
@@ -185,7 +187,8 @@ namespace paludis
///\name Basic operations
///\{
- Repository(const RepositoryName &, const RepositoryCapabilities &);
+ Repository(const RepositoryName &, const RepositoryCapabilities &,
+ const std::string & our_format);
///\}
@@ -281,6 +284,11 @@ namespace paludis
const RepositoryName & name() const PALUDIS_ATTRIBUTE((nothrow));
/**
+ * Return our format.
+ */
+ std::string format() const;
+
+ /**
* Are we allowed to be favourite repository?
*/
virtual bool can_be_favourite_repository() const
@@ -969,6 +977,26 @@ namespace paludis
};
/**
+ * Interface for repositories that can be used as an install destination.
+ *
+ * \see Repository
+ * \ingroup grprepository
+ * \nosubgrouping
+ */
+ class RepositoryDestinationInterface
+ {
+ public:
+ ///\name Destination functions
+ ///\{
+
+ virtual bool is_suitable_destination_for(const PackageDatabaseEntry &) const = 0;
+
+ ///\}
+
+ virtual ~RepositoryDestinationInterface() { }
+ };
+
+ /**
* Thrown if a repository of the specified type does not exist.
*
* \ingroup grpexceptions
diff --git a/paludis/repository.sr b/paludis/repository.sr
index 09d3cde..6480aaf 100644
--- a/paludis/repository.sr
+++ b/paludis/repository.sr
@@ -32,6 +32,7 @@ make_class_RepositoryCapabilities()
key environment_variable_interface "RepositoryEnvironmentVariableInterface *"
key provides_interface "RepositoryProvidesInterface *"
key virtuals_interface "RepositoryVirtualsInterface *"
+ key destination_interface "RepositoryDestinationInterface *"
doxygen_comment << "END"
/**
diff --git a/ruby/repository_TEST.rb b/ruby/repository_TEST.rb
index 563e4a8..363f730 100644
--- a/ruby/repository_TEST.rb
+++ b/ruby/repository_TEST.rb
@@ -231,7 +231,7 @@ module Paludis
def test_section_kvs
assert_kind_of Hash, repo.info(false).sections.first.kvs
- assert_equal 'portage', repo.info(false).sections.first.kvs['format']
+ assert_equal 'ebuild', repo.info(false).sections.first.kvs['format']
assert_equal 'vdb', installed_repo.info(false).sections.first.kvs['format']
end
end