aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-07-14 03:03:20 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-07-14 03:13:56 +0100
commit3b627dbc6471f30a359cad3817bc99090ca8a7ca (patch)
tree7a7b903ce822bf04fcd7b02449fee75e75096e7d
parenteb2e3b17d993e13cd781c9e6242443739a24f491 (diff)
downloadpaludis-3b627dbc6471f30a359cad3817bc99090ca8a7ca.tar.gz
paludis-3b627dbc6471f30a359cad3817bc99090ca8a7ca.tar.xz
Update Unpackaged for previous (continued)
-rw-r--r--paludis/repositories/unpackaged/installed_id.cc83
-rw-r--r--paludis/repositories/unpackaged/installed_id.hh3
-rw-r--r--paludis/repositories/unpackaged/unpackaged_id.cc12
-rw-r--r--paludis/repositories/unpackaged/unpackaged_id.hh3
4 files changed, 68 insertions, 33 deletions
diff --git a/paludis/repositories/unpackaged/installed_id.cc b/paludis/repositories/unpackaged/installed_id.cc
index 39ceed6..1aa9546 100644
--- a/paludis/repositories/unpackaged/installed_id.cc
+++ b/paludis/repositories/unpackaged/installed_id.cc
@@ -49,6 +49,11 @@ using namespace paludis::unpackaged_repositories;
namespace
{
+ std::string format_string(const std::string & i, const Formatter<std::string> & f)
+ {
+ return f.format(i, format::Plain());
+ }
+
class InstalledUnpackagedFSEntryKey :
public MetadataValueKey<FSEntry>
{
@@ -168,6 +173,54 @@ namespace
}
};
+ class InstalledUnpackagedStringSetKey :
+ public MetadataCollectionKey<Set<std::string> >
+ {
+ private:
+ mutable std::tr1::shared_ptr<Set<std::string> > _v;
+ mutable Mutex _mutex;
+ FSEntrySequence _f;
+
+ public:
+ InstalledUnpackagedStringSetKey(const std::string & r, const std::string & h, const MetadataKeyType t) :
+ MetadataCollectionKey<Set<std::string> > (r, h, t)
+ {
+ }
+
+ void add_source(const FSEntry & f)
+ {
+ _f.push_back(f);
+ }
+
+ const std::tr1::shared_ptr<const Set<std::string> > value() const
+ {
+ Lock l(_mutex);
+ if (_v)
+ return _v;
+
+ _v.reset(new Set<std::string>());
+ for (FSEntrySequence::ConstIterator a(_f.begin()), a_end(_f.end()) ;
+ a != a_end ; ++a)
+ {
+ std::ifstream f(stringify(*a).c_str());
+ if (! f)
+ {
+ Context context("When reading '" + stringify(*a) + "' as an InstalledUnpackagedStringKey:");
+ throw FSError("Couldn't open '" + stringify(*a) + "' for read");
+ }
+ _v->insert(strip_trailing(std::string((std::istreambuf_iterator<char>(f)),
+ std::istreambuf_iterator<char>()), "\n"));
+ }
+ return _v;
+ }
+
+ std::string pretty_print_flat(const Formatter<std::string> & f) const
+ {
+ using namespace std::tr1::placeholders;
+ return join(value()->begin(), value()->end(), " ", std::tr1::bind(&format_string, _1, f));
+ }
+ };
+
class InstalledUnpackagedDependencyKey :
public MetadataSpecTreeKey<DependencySpecTree>
{
@@ -248,8 +301,7 @@ namespace paludis
std::tr1::shared_ptr<InstalledUnpackagedFSEntryKey> fs_location_key;
std::tr1::shared_ptr<InstalledUnpackagedContentsKey> contents_key;
std::tr1::shared_ptr<InstalledUnpackagedTimeKey> installed_time_key;
- std::tr1::shared_ptr<InstalledUnpackagedStringKey> source_origin_key;
- std::tr1::shared_ptr<InstalledUnpackagedStringKey> binary_origin_key;
+ std::tr1::shared_ptr<InstalledUnpackagedStringSetKey> from_repositories_key;
std::tr1::shared_ptr<InstalledUnpackagedStringKey> description_key;
std::tr1::shared_ptr<InstalledUnpackagedDependencyKey> build_dependencies_key;
std::tr1::shared_ptr<InstalledUnpackagedDependencyKey> run_dependencies_key;
@@ -284,13 +336,12 @@ namespace paludis
installed_time_key.reset(new InstalledUnpackagedTimeKey(l / "contents"));
}
+ from_repositories_key.reset(new InstalledUnpackagedStringSetKey("source_repository",
+ "Source repository", mkt_normal));
if ((l / "source_repository").exists())
- source_origin_key.reset(new InstalledUnpackagedStringKey("source_repository", "Source repository", l / "source_repository",
- mkt_normal));
-
+ from_repositories_key->add_source(l / "source_repository");
if ((l / "binary_repository").exists())
- binary_origin_key.reset(new InstalledUnpackagedStringKey("binary_repository", "Binary repository", l / "binary_repository",
- mkt_normal));
+ from_repositories_key->add_source(l / "binary_repository");
if ((l / "description").exists())
description_key.reset(new InstalledUnpackagedStringKey("description", "Description", l / "description", mkt_significant));
@@ -319,10 +370,8 @@ InstalledUnpackagedID::InstalledUnpackagedID(const Environment * const e, const
add_metadata_key(_imp->contents_key);
if (_imp->installed_time_key)
add_metadata_key(_imp->installed_time_key);
- if (_imp->source_origin_key)
- add_metadata_key(_imp->source_origin_key);
- if (_imp->binary_origin_key)
- add_metadata_key(_imp->binary_origin_key);
+ if (_imp->from_repositories_key)
+ add_metadata_key(_imp->from_repositories_key);
if (_imp->description_key)
add_metadata_key(_imp->description_key);
if (_imp->build_dependencies_key)
@@ -488,16 +537,10 @@ InstalledUnpackagedID::installed_time_key() const
return _imp->installed_time_key;
}
-const std::tr1::shared_ptr<const MetadataValueKey<std::string> >
-InstalledUnpackagedID::source_origin_key() const
-{
- return _imp->source_origin_key;
-}
-
-const std::tr1::shared_ptr<const MetadataValueKey<std::string> >
-InstalledUnpackagedID::binary_origin_key() const
+const std::tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > >
+InstalledUnpackagedID::from_repositories_key() const
{
- return _imp->binary_origin_key;
+ return _imp->from_repositories_key;
}
const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> >
diff --git a/paludis/repositories/unpackaged/installed_id.hh b/paludis/repositories/unpackaged/installed_id.hh
index 46823d5..aa68682 100644
--- a/paludis/repositories/unpackaged/installed_id.hh
+++ b/paludis/repositories/unpackaged/installed_id.hh
@@ -73,10 +73,9 @@ namespace paludis
virtual const std::tr1::shared_ptr<const MetadataValueKey<std::string> > long_description_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<std::tr1::shared_ptr<const Contents> > > contents_key() const;
virtual const std::tr1::shared_ptr<const MetadataTimeKey> installed_time_key() const;
- virtual const std::tr1::shared_ptr<const MetadataValueKey<std::string> > source_origin_key() const;
- virtual const std::tr1::shared_ptr<const MetadataValueKey<std::string> > binary_origin_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > fs_location_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<bool> > transient_key() const;
+ virtual const std::tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > > from_repositories_key() const;
virtual bool supports_action(const SupportsActionTestBase &) const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void perform_action(Action &) const;
diff --git a/paludis/repositories/unpackaged/unpackaged_id.cc b/paludis/repositories/unpackaged/unpackaged_id.cc
index 31be89c..fc132c8 100644
--- a/paludis/repositories/unpackaged/unpackaged_id.cc
+++ b/paludis/repositories/unpackaged/unpackaged_id.cc
@@ -259,16 +259,10 @@ UnpackagedID::installed_time_key() const
return std::tr1::shared_ptr<const MetadataTimeKey>();
}
-const std::tr1::shared_ptr<const MetadataValueKey<std::string> >
-UnpackagedID::source_origin_key() const
+const std::tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > >
+UnpackagedID::from_repositories_key() const
{
- return std::tr1::shared_ptr<const MetadataValueKey<std::string> >();
-}
-
-const std::tr1::shared_ptr<const MetadataValueKey<std::string> >
-UnpackagedID::binary_origin_key() const
-{
- return std::tr1::shared_ptr<const MetadataValueKey<std::string> >();
+ return std::tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > >();
}
const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> >
diff --git a/paludis/repositories/unpackaged/unpackaged_id.hh b/paludis/repositories/unpackaged/unpackaged_id.hh
index 1a9351e..a66a397 100644
--- a/paludis/repositories/unpackaged/unpackaged_id.hh
+++ b/paludis/repositories/unpackaged/unpackaged_id.hh
@@ -71,10 +71,9 @@ namespace paludis
virtual const std::tr1::shared_ptr<const MetadataValueKey<std::string> > long_description_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<std::tr1::shared_ptr<const Contents> > > contents_key() const;
virtual const std::tr1::shared_ptr<const MetadataTimeKey> installed_time_key() const;
- virtual const std::tr1::shared_ptr<const MetadataValueKey<std::string> > source_origin_key() const;
- virtual const std::tr1::shared_ptr<const MetadataValueKey<std::string> > binary_origin_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > fs_location_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<bool> > transient_key() const;
+ virtual const std::tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > > from_repositories_key() const;
virtual bool supports_action(const SupportsActionTestBase &) const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void perform_action(Action &) const;