aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-02-16 01:17:35 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-02-16 01:17:35 +0000
commitb1b078016b00a567b5d7bebb472780dec7eba1b9 (patch)
tree75b0ca8e58b4c0c01da783c16ee86a4b089e138c
parent3a6bed347ad110a42a10011d610f605ac196bde7 (diff)
parent0db602cec77b3ff600428126357e9a40d4f1cedb (diff)
downloadpaludis-b1b078016b00a567b5d7bebb472780dec7eba1b9.tar.gz
paludis-b1b078016b00a567b5d7bebb472780dec7eba1b9.tar.xz
Merge branch 'contents-metadata'
-rw-r--r--doc/api/cplusplus/examples/example_contents.cc24
-rw-r--r--paludis/contents-fwd.hh13
-rw-r--r--paludis/contents.cc86
-rw-r--r--paludis/contents.hh120
-rw-r--r--paludis/literal_metadata_key.cc55
-rw-r--r--paludis/literal_metadata_key.hh30
-rw-r--r--paludis/ndbam.cc20
-rw-r--r--paludis/ndbam.hh8
-rw-r--r--paludis/ndbam_unmerger.cc96
-rw-r--r--paludis/ndbam_unmerger.hh16
-rw-r--r--paludis/repositories/e/e_key.cc30
-rw-r--r--paludis/repositories/e/exndbam_id.cc29
-rw-r--r--paludis/repositories/e/vdb_repository.cc4
-rw-r--r--paludis/repositories/e/vdb_repository_TEST.cc46
-rw-r--r--paludis/repositories/e/vdb_unmerger.cc170
-rw-r--r--paludis/repositories/e/vdb_unmerger.hh13
-rw-r--r--paludis/repositories/e/vdb_unmerger_TEST.cc218
-rwxr-xr-xpaludis/repositories/e/vdb_unmerger_TEST_setup.sh71
-rw-r--r--paludis/repositories/unpackaged/installed_id.cc6
-rw-r--r--paludis/repositories/unpackaged/installed_repository_TEST.cc20
-rw-r--r--paludis/unmerger.cc159
-rw-r--r--paludis/unmerger.hh59
-rw-r--r--python/contents.cc64
-rwxr-xr-xpython/contents_TEST.py41
-rw-r--r--ruby/contents.cc107
-rw-r--r--ruby/contents_TEST.rb56
-rw-r--r--ruby/package_id.cc2
-rw-r--r--ruby/repository_TEST.rb13
-rw-r--r--src/clients/cave/cmd_print_owners.cc6
-rw-r--r--src/clients/cave/cmd_show.cc26
-rw-r--r--src/clients/cave/format_plain_contents_entry.cc23
-rw-r--r--src/clients/cave/formats.cc14
-rw-r--r--src/clients/cave/formats.hh4
-rw-r--r--src/clients/paludis/do_contents.cc22
-rw-r--r--src/clients/paludis/do_executables.cc18
-rw-r--r--src/clients/paludis/owner.cc22
-rw-r--r--src/clients/reconcilio/broken_linkage_finder/broken_linkage_finder.cc2
-rw-r--r--src/output/colour.hh6
38 files changed, 803 insertions, 916 deletions
diff --git a/doc/api/cplusplus/examples/example_contents.cc b/doc/api/cplusplus/examples/example_contents.cc
index 2aa398f..b2ad342 100644
--- a/doc/api/cplusplus/examples/example_contents.cc
+++ b/doc/api/cplusplus/examples/example_contents.cc
@@ -32,35 +32,27 @@ namespace
class ContentsPrinter
{
public:
- void visit(const ContentsDevEntry & d)
- {
- cout << left << setw(10) << "device" << d.name() << endl;
- }
-
- void visit(const ContentsMiscEntry & d)
- {
- cout << left << setw(10) << "misc" << d.name() << endl;
- }
-
void visit(const ContentsFileEntry & d)
{
- cout << left << setw(10) << "file" << d.name() << endl;
+ cout << left << setw(10) << "file" << d.location_key()->value() << endl;
}
void visit(const ContentsDirEntry & d)
{
- cout << left << setw(10) << "dir" << d.name() << endl;
+ cout << left << setw(10) << "dir" << d.location_key()->value() << endl;
}
- void visit(const ContentsFifoEntry & d)
+ void visit(const ContentsSymEntry & d)
{
- cout << left << setw(10) << "fifo" << d.name() << endl;
+ cout << left << setw(10) << "sym" << d.location_key()->value()
+ << " -> " << d.target_key()->value() << endl;
}
- void visit(const ContentsSymEntry & d)
+ void visit(const ContentsOtherEntry & d)
{
- cout << left << setw(10) << "sym" << d.name() << " -> " << d.target() << endl;
+ cout << left << setw(10) << "other" << d.location_key()->value() << endl;
}
+
};
}
diff --git a/paludis/contents-fwd.hh b/paludis/contents-fwd.hh
index 37659b9..b3590d7 100644
--- a/paludis/contents-fwd.hh
+++ b/paludis/contents-fwd.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009 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
@@ -35,18 +35,9 @@ namespace paludis
struct ContentsFileEntry;
struct ContentsDirEntry;
struct ContentsSymEntry;
- struct ContentsFifoEntry;
- struct ContentsDevEntry;
- struct ContentsMiscEntry;
+ struct ContentsOtherEntry;
struct Contents;
-
- /**
- * Write a ContentsEntry to a stream.
- *
- * \ingroup g_contents
- */
- std::ostream & operator<< (std::ostream &, const ContentsEntry &) PALUDIS_VISIBLE;
}
#endif
diff --git a/paludis/contents.cc b/paludis/contents.cc
index 37f0b1e..948878d 100644
--- a/paludis/contents.cc
+++ b/paludis/contents.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009 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
@@ -20,60 +20,88 @@
#include <paludis/contents.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/wrapped_forward_iterator-impl.hh>
+#include <paludis/literal_metadata_key.hh>
#include <list>
using namespace paludis;
-ContentsEntry::ContentsEntry(const std::string & n) :
- _name(n)
+namespace paludis
+{
+ template <>
+ struct Implementation<ContentsEntry>
+ {
+ const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > location_key;
+
+ Implementation(const FSEntry & n) :
+ location_key(make_shared_ptr(new LiteralMetadataValueKey<FSEntry>("location", "location", mkt_significant, n)))
+ {
+ }
+ };
+}
+
+ContentsEntry::ContentsEntry(const FSEntry & n) :
+ PrivateImplementationPattern<ContentsEntry>(new Implementation<ContentsEntry>(n)),
+ _imp(PrivateImplementationPattern<ContentsEntry>::_imp)
{
+ add_metadata_key(_imp->location_key);
}
ContentsEntry::~ContentsEntry()
{
}
-std::string
-ContentsEntry::name() const
+void
+ContentsEntry::need_keys_added() const
{
- return _name;
}
-ContentsFileEntry::ContentsFileEntry(const std::string & our_name) :
- ContentsEntry(our_name)
+const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> >
+ContentsEntry::location_key() const
{
+ return _imp->location_key;
}
-ContentsDirEntry::ContentsDirEntry(const std::string & our_name) :
+ContentsFileEntry::ContentsFileEntry(const FSEntry & our_name) :
ContentsEntry(our_name)
{
}
-ContentsMiscEntry::ContentsMiscEntry(const std::string & our_name) :
+ContentsDirEntry::ContentsDirEntry(const FSEntry & our_name) :
ContentsEntry(our_name)
{
}
-ContentsFifoEntry::ContentsFifoEntry(const std::string & our_name) :
+ContentsOtherEntry::ContentsOtherEntry(const FSEntry & our_name) :
ContentsEntry(our_name)
{
}
-ContentsDevEntry::ContentsDevEntry(const std::string & our_name) :
- ContentsEntry(our_name)
+namespace paludis
{
+ template <>
+ struct Implementation<ContentsSymEntry>
+ {
+ const std::tr1::shared_ptr<const MetadataValueKey<std::string> > target_key;
+
+ Implementation(const std::string & t) :
+ target_key(make_shared_ptr(new LiteralMetadataValueKey<std::string>("target", "target", mkt_normal, t)))
+ {
+ }
+ };
}
-ContentsSymEntry::ContentsSymEntry(const std::string & our_name, const std::string & our_target) :
+ContentsSymEntry::ContentsSymEntry(const FSEntry & our_name, const std::string & our_target) :
+ PrivateImplementationPattern<ContentsSymEntry>(new Implementation<ContentsSymEntry>(our_target)),
ContentsEntry(our_name),
- _target(our_target)
+ _imp(PrivateImplementationPattern<ContentsSymEntry>::_imp)
{
+ add_metadata_key(_imp->target_key);
}
-std::string
-ContentsSymEntry::target() const
+const std::tr1::shared_ptr<const MetadataValueKey<std::string> >
+ContentsSymEntry::target_key() const
{
- return _target;
+ return _imp->target_key;
}
namespace paludis
@@ -112,29 +140,11 @@ Contents::end() const
return ConstIterator(_imp->c.end());
}
-std::ostream &
-paludis::operator<< (std::ostream & s, const ContentsEntry & e)
-{
- s << e.as_string();
- return s;
-}
-
-const std::string
-ContentsEntry::as_string() const
-{
- return name();
-}
-
-const std::string
-ContentsSymEntry::as_string() const
-{
- return name() + " -> " + target();
-}
-
-template class InstantiationPolicy<ContentsEntry, instantiation_method::NonCopyableTag>;
template class InstantiationPolicy<Contents, instantiation_method::NonCopyableTag>;
template class PrivateImplementationPattern<Contents>;
+template class PrivateImplementationPattern<ContentsEntry>;
+template class PrivateImplementationPattern<ContentsSymEntry>;
template class WrappedForwardIterator<Contents::ConstIteratorTag, const std::tr1::shared_ptr<const ContentsEntry> >;
diff --git a/paludis/contents.hh b/paludis/contents.hh
index 7054d1c..cb39628 100644
--- a/paludis/contents.hh
+++ b/paludis/contents.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009 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
@@ -26,6 +26,8 @@
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/type_list.hh>
#include <paludis/util/wrapped_forward_iterator-fwd.hh>
+#include <paludis/util/fs_entry-fwd.hh>
+#include <paludis/metadata_key_holder.hh>
#include <tr1/memory>
#include <string>
@@ -44,42 +46,57 @@ namespace paludis
/**
* Base class for a contents entry.
*
+ * \since 0.36 for MetadataKeyHolder methods.
+ *
* \ingroup g_contents
* \nosubgrouping
*/
class PALUDIS_VISIBLE ContentsEntry :
- private InstantiationPolicy<ContentsEntry, instantiation_method::NonCopyableTag>,
+ private PrivateImplementationPattern<ContentsEntry>,
+ public MetadataKeyHolder,
public virtual DeclareAbstractAcceptMethods<ContentsEntry, MakeTypeList<
- ContentsFileEntry, ContentsDirEntry, ContentsSymEntry, ContentsFifoEntry, ContentsDevEntry, ContentsMiscEntry>::Type>
+ ContentsFileEntry, ContentsDirEntry, ContentsSymEntry, ContentsOtherEntry>::Type>
{
- friend std::ostream & operator<< (std::ostream &, const ContentsEntry &);
-
private:
- std::string _name;
+ PrivateImplementationPattern<ContentsEntry>::ImpPtr & _imp;
protected:
+ virtual void need_keys_added() const;
+
+ public:
///\name Basic operations
///\{
- ContentsEntry(const std::string & our_name);
+ ContentsEntry(const FSEntry & path);
+ virtual ~ContentsEntry() = 0;
+
+ ///\}
+
+ ///\name Metadata key operations
+ ///\{
/**
- * Used to implement the ostream operator<<.
+ * Must be called straight after construction.
+ *
+ * \since 0.36
*/
- virtual const std::string as_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ using MetadataKeyHolder::add_metadata_key;
///\}
- public:
- ///\name Basic operations
+ ///\name Specific metadata keys
///\{
- virtual ~ContentsEntry();
+ /**
+ * Our path on disk. Must not be zero. Not modified for root.
+ *
+ * \since 0.36
+ */
+ const std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > location_key() const;
///\}
- /// Our name.
- std::string name() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ ///\}
};
/**
@@ -96,7 +113,7 @@ namespace paludis
///\name Basic operations
///\{
- ContentsFileEntry(const std::string & name);
+ ContentsFileEntry(const FSEntry &);
///\}
};
@@ -115,64 +132,27 @@ namespace paludis
///\name Basic operations
///\{
- ContentsDirEntry(const std::string & name);
+ ContentsDirEntry(const FSEntry &);
///\}
};
/**
- * A misc contents entry.
+ * An 'other' contents entry, which we can't handle.
*
+ * \since 0.36
* \ingroup g_contents
* \nosubgrouping
*/
- class PALUDIS_VISIBLE ContentsMiscEntry :
+ class PALUDIS_VISIBLE ContentsOtherEntry :
public ContentsEntry,
- public ImplementAcceptMethods<ContentsEntry, ContentsMiscEntry>
+ public ImplementAcceptMethods<ContentsEntry, ContentsOtherEntry>
{
public:
///\name Basic operations
///\{
- ContentsMiscEntry(const std::string & name);
-
- ///\}
- };
-
- /**
- * A fifo contents entry.
- *
- * \ingroup g_contents
- * \nosubgrouping
- */
- class PALUDIS_VISIBLE ContentsFifoEntry :
- public ContentsEntry,
- public ImplementAcceptMethods<ContentsEntry, ContentsFifoEntry>
- {
- public:
- ///\name Basic operations
- ///\{
-
- ContentsFifoEntry(const std::string & name);
-
- ///\}
- };
-
- /**
- * A device contents entry.
- *
- * \ingroup g_contents
- * \nosubgrouping
- */
- class PALUDIS_VISIBLE ContentsDevEntry :
- public ContentsEntry,
- public ImplementAcceptMethods<ContentsEntry, ContentsDevEntry>
- {
- public:
- ///\name Basic operations
- ///\{
-
- ContentsDevEntry(const std::string & name);
+ ContentsOtherEntry(const FSEntry &);
///\}
};
@@ -184,25 +164,32 @@ namespace paludis
* \nosubgrouping
*/
class PALUDIS_VISIBLE ContentsSymEntry :
+ private PrivateImplementationPattern<ContentsSymEntry>,
public ContentsEntry,
public ImplementAcceptMethods<ContentsEntry, ContentsSymEntry>
{
private:
- std::string _target;
-
- protected:
- virtual const std::string as_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ PrivateImplementationPattern<ContentsSymEntry>::ImpPtr & _imp;
public:
///\name Basic operations
///\{
- ContentsSymEntry(const std::string & name, const std::string & target);
+ ContentsSymEntry(const FSEntry &, const std::string & target);
///\}
- /// Our target (as per readlink).
- std::string target() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ ///\name Specific metadata keys
+ ///\{
+
+ /**
+ * Our target, as per readlink. Must not be zero.
+ *
+ * \since 0.36
+ */
+ const std::tr1::shared_ptr<const MetadataValueKey<std::string> > target_key() const;
+
+ ///\}
};
/**
@@ -243,9 +230,10 @@ namespace paludis
};
#ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
- extern template class InstantiationPolicy<ContentsEntry, instantiation_method::NonCopyableTag>;
extern template class InstantiationPolicy<Contents, instantiation_method::NonCopyableTag>;
extern template class PrivateImplementationPattern<Contents>;
+ extern template class PrivateImplementationPattern<ContentsEntry>;
+ extern template class PrivateImplementationPattern<ContentsSymEntry>;
#endif
}
diff --git a/paludis/literal_metadata_key.cc b/paludis/literal_metadata_key.cc
index 4fcb044..f6321bc 100644
--- a/paludis/literal_metadata_key.cc
+++ b/paludis/literal_metadata_key.cc
@@ -341,6 +341,61 @@ LiteralMetadataValueKey<T_>::value() const
return _imp->value;
}
+namespace paludis
+{
+ template <>
+ struct Implementation<LiteralMetadataTimeKey>
+ {
+ const std::string raw_name;
+ const std::string human_name;
+ const MetadataKeyType type;
+ const time_t value;
+
+ Implementation(const std::string & r, const std::string & h, const MetadataKeyType t, const time_t v) :
+ raw_name(r),
+ human_name(h),
+ type(t),
+ value(v)
+ {
+ }
+ };
+}
+
+LiteralMetadataTimeKey::LiteralMetadataTimeKey(
+ const std::string & r, const std::string & h, const MetadataKeyType k, const time_t v) :
+ PrivateImplementationPattern<LiteralMetadataTimeKey>(new Implementation<LiteralMetadataTimeKey>(r, h, k, v)),
+ _imp(PrivateImplementationPattern<LiteralMetadataTimeKey>::_imp)
+{
+}
+
+LiteralMetadataTimeKey::~LiteralMetadataTimeKey()
+{
+}
+
+const std::string
+LiteralMetadataTimeKey::human_name() const
+{
+ return _imp->human_name;
+}
+
+const std::string
+LiteralMetadataTimeKey::raw_name() const
+{
+ return _imp->raw_name;
+}
+
+MetadataKeyType
+LiteralMetadataTimeKey::type() const
+{
+ return _imp->type;
+}
+
+time_t
+LiteralMetadataTimeKey::value() const
+{
+ return _imp->value;
+}
+
template class LiteralMetadataValueKey<FSEntry>;
template class LiteralMetadataValueKey<std::string>;
template class LiteralMetadataValueKey<SlotName>;
diff --git a/paludis/literal_metadata_key.hh b/paludis/literal_metadata_key.hh
index f1dea9d..3895618 100644
--- a/paludis/literal_metadata_key.hh
+++ b/paludis/literal_metadata_key.hh
@@ -240,6 +240,36 @@ namespace paludis
virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
+
+ /**
+ * A LiteralMetadataTimeKey is a MetadataTimeKey whose value is known at
+ * construction time.
+ *
+ * \ingroup g_literal_metadata_key
+ * \since 0.36
+ */
+ class PALUDIS_VISIBLE LiteralMetadataTimeKey :
+ public MetadataTimeKey,
+ private PrivateImplementationPattern<LiteralMetadataTimeKey>
+ {
+ private:
+ PrivateImplementationPattern<LiteralMetadataTimeKey>::ImpPtr & _imp;
+
+ public:
+ ///\name Basic operations
+ ///\{
+
+ LiteralMetadataTimeKey(const std::string &, const std::string &, const MetadataKeyType, const time_t);
+ ~LiteralMetadataTimeKey();
+
+ ///\}
+
+ virtual time_t value() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
}
#endif
diff --git a/paludis/ndbam.cc b/paludis/ndbam.cc
index 206a5f1..991630e 100644
--- a/paludis/ndbam.cc
+++ b/paludis/ndbam.cc
@@ -34,6 +34,8 @@
#include <paludis/package_id.hh>
#include <paludis/metadata_key.hh>
#include <paludis/name.hh>
+#include <paludis/contents.hh>
+#include <paludis/literal_metadata_key.hh>
#include <tr1/functional>
#include <tr1/unordered_map>
#include <functional>
@@ -355,9 +357,9 @@ NDBAM::entries(const QualifiedPackageName & q)
void
NDBAM::parse_contents(const PackageID & id,
- const std::tr1::function<void (const FSEntry &, const std::string & md5, const time_t mtime)> & on_file,
- const std::tr1::function<void (const FSEntry &)> & on_dir,
- const std::tr1::function<void (const FSEntry &, const std::string & target, const time_t mtime)> & on_sym
+ const std::tr1::function<void (const std::tr1::shared_ptr<const ContentsEntry> &)> & on_file,
+ const std::tr1::function<void (const std::tr1::shared_ptr<const ContentsEntry> &)> & on_dir,
+ const std::tr1::function<void (const std::tr1::shared_ptr<const ContentsEntry> &)> & on_sym
) const
{
Context c("When fetching contents for '" + stringify(id) + "':");
@@ -473,11 +475,15 @@ NDBAM::parse_contents(const PackageID & id,
}
time_t mtime(destringify<time_t>(tokens.find("mtime")->second));
- on_file(path, md5, mtime);
+ std::tr1::shared_ptr<ContentsFileEntry> entry(make_shared_ptr(new ContentsFileEntry(path)));
+ entry->add_metadata_key(make_shared_ptr(new LiteralMetadataValueKey<std::string>("md5", "md5", mkt_normal, md5)));
+ entry->add_metadata_key(make_shared_ptr(new LiteralMetadataTimeKey("mtime", "mtime", mkt_normal, mtime)));
+ on_file(entry);
}
else if ("dir" == type)
{
- on_dir(path);
+ std::tr1::shared_ptr<ContentsDirEntry> entry(make_shared_ptr(new ContentsDirEntry(path)));
+ on_dir(entry);
}
else if ("sym" == type)
{
@@ -497,7 +503,9 @@ NDBAM::parse_contents(const PackageID & id,
}
time_t mtime(destringify<time_t>(tokens.find("mtime")->second));
- on_sym(path, target, mtime);
+ std::tr1::shared_ptr<ContentsSymEntry> entry(make_shared_ptr(new ContentsSymEntry(path, target)));
+ entry->add_metadata_key(make_shared_ptr(new LiteralMetadataTimeKey("mtime", "mtime", mkt_normal, mtime)));
+ on_sym(entry);
}
else
Log::get_instance()->message("ndbam.contents.unknown_type", ll_warning, lc_context) <<
diff --git a/paludis/ndbam.hh b/paludis/ndbam.hh
index 5b70e63..902d268 100644
--- a/paludis/ndbam.hh
+++ b/paludis/ndbam.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 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
@@ -109,9 +109,9 @@ namespace paludis
* Parse the contents file for a given ID, using the provided callbacks.
*/
void parse_contents(const PackageID &,
- const std::tr1::function<void (const FSEntry &, const std::string & md5, const time_t mtime)> & on_file,
- const std::tr1::function<void (const FSEntry &)> & on_dir,
- const std::tr1::function<void (const FSEntry &, const std::string & target, const time_t mtime)> & on_sym
+ const std::tr1::function<void (const std::tr1::shared_ptr<const ContentsEntry> &)> & on_file,
+ const std::tr1::function<void (const std::tr1::shared_ptr<const ContentsEntry> &)> & on_dir,
+ const std::tr1::function<void (const std::tr1::shared_ptr<const ContentsEntry> &)> & on_sym
) const;
/**
diff --git a/paludis/ndbam_unmerger.cc b/paludis/ndbam_unmerger.cc
index 0a78659..376838d 100644
--- a/paludis/ndbam_unmerger.cc
+++ b/paludis/ndbam_unmerger.cc
@@ -37,8 +37,10 @@
#include <paludis/util/strip.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/make_named_values.hh>
-#include <paludis/output_manager.hh>
+#include <paludis/util/simple_visitor_cast.hh>
#include <paludis/util/safe_ifstream.hh>
+#include <paludis/util/set.hh>
+#include <paludis/output_manager.hh>
#include <paludis/metadata_key.hh>
#include <tr1/functional>
#include <list>
@@ -66,42 +68,6 @@ namespace paludis
};
}
-class NDBAMUnmerger::FileExtraInfo :
- public Unmerger::ExtraInfo
-{
- public:
- std::string _md5sum;
- time_t _mtime;
-
- FileExtraInfo(std::string md5sum, time_t mtime) :
- _md5sum(md5sum),
- _mtime(mtime)
- {
- }
-
- virtual ~FileExtraInfo()
- {
- }
-};
-
-class NDBAMUnmerger::SymlinkExtraInfo :
- public Unmerger::ExtraInfo
-{
- public:
- std::string _dest;
- time_t _mtime;
-
- SymlinkExtraInfo(std::string dest, time_t mtime) :
- _dest(dest),
- _mtime(mtime)
- {
- }
-
- virtual ~SymlinkExtraInfo()
- {
- }
-};
-
NDBAMUnmerger::NDBAMUnmerger(const NDBAMUnmergerOptions & o) :
Unmerger(make_named_values<UnmergerOptions>(
value_for<n::environment>(o.environment()),
@@ -188,21 +154,21 @@ NDBAMUnmerger::make_tidy(const FSEntry & f) const
}
void
-NDBAMUnmerger::_add_file(const FSEntry & f, const std::string & md5, const time_t mtime)
+NDBAMUnmerger::_add_file(const std::tr1::shared_ptr<const ContentsEntry> & e)
{
- add_unmerge_entry(stringify(f), et_file, make_shared_ptr(new FileExtraInfo(md5, mtime)));
+ add_unmerge_entry(et_file, e);
}
void
-NDBAMUnmerger::_add_dir(const FSEntry & f)
+NDBAMUnmerger::_add_dir(const std::tr1::shared_ptr<const ContentsEntry> & e)
{
- add_unmerge_entry(stringify(f), et_dir, std::tr1::shared_ptr<ExtraInfo>());
+ add_unmerge_entry(et_dir, e);
}
void
-NDBAMUnmerger::_add_sym(const FSEntry & f, const std::string & target, const time_t mtime)
+NDBAMUnmerger::_add_sym(const std::tr1::shared_ptr<const ContentsEntry> & e)
{
- add_unmerge_entry(stringify(f), et_sym, make_shared_ptr(new SymlinkExtraInfo(target, mtime)));
+ add_unmerge_entry(et_sym, e);
}
void
@@ -210,22 +176,39 @@ NDBAMUnmerger::populate_unmerge_set()
{
using namespace std::tr1::placeholders;
_imp->options.ndbam()->parse_contents(*_imp->options.package_id(),
- std::tr1::bind(&NDBAMUnmerger::_add_file, this, _1, _2, _3),
+ std::tr1::bind(&NDBAMUnmerger::_add_file, this, _1),
std::tr1::bind(&NDBAMUnmerger::_add_dir, this, _1),
- std::tr1::bind(&NDBAMUnmerger::_add_sym, this, _1, _2, _3)
+ std::tr1::bind(&NDBAMUnmerger::_add_sym, this, _1)
);
}
+namespace
+{
+ template <typename T_>
+ const T_ & require_key(const MetadataKeyHolder & h, const std::string & r)
+ {
+ MetadataKeyHolder::MetadataConstIterator m(h.find_metadata(r));
+ if (m == h.end_metadata())
+ throw InternalError(PALUDIS_HERE, "Expected key '" + r + "' not found");
+
+ const T_ * const c(simple_visitor_cast<const T_>(**m));
+ if (! c)
+ throw InternalError(PALUDIS_HERE, "Key '" + r + "' is of wrong type");
+
+ return *c;
+ }
+}
+
bool
-NDBAMUnmerger::check_file(const FSEntry & f, const std::tr1::shared_ptr<ExtraInfo> & ei) const
+NDBAMUnmerger::check_file(const std::tr1::shared_ptr<const ContentsEntry> & e) const
{
- std::tr1::shared_ptr<FileExtraInfo> fie(std::tr1::static_pointer_cast<FileExtraInfo>(ei));
+ const FSEntry f(e->location_key()->value());
if (! (_imp->options.root() / f).exists())
display("--- [gone ] " + stringify(f));
else if (! (_imp->options.root() / f).is_regular_file())
display("--- [!type] " + stringify(f));
- else if ((_imp->options.root() / f).mtime() != fie->_mtime)
+ else if ((_imp->options.root() / f).mtime() != require_key<MetadataTimeKey>(*e, "mtime").value())
display("--- [!time] " + stringify(f));
else
{
@@ -236,7 +219,7 @@ NDBAMUnmerger::check_file(const FSEntry & f, const std::tr1::shared_ptr<ExtraInf
(_imp->options.root() / f) << "'";
display("--- [!md5?] " + stringify(f));
}
- else if (MD5(md5_file).hexsum() != fie->_md5sum)
+ else if (MD5(md5_file).hexsum() != require_key<MetadataValueKey<std::string> >(*e, "md5").value())
display("--- [!md5 ] " + stringify(f));
else if (config_protected(_imp->options.root() / f))
display("--- [cfgpr] " + stringify(f));
@@ -248,18 +231,17 @@ NDBAMUnmerger::check_file(const FSEntry & f, const std::tr1::shared_ptr<ExtraInf
}
bool
-NDBAMUnmerger::check_sym(const FSEntry & f, const std::tr1::shared_ptr<ExtraInfo> & ei) const
+NDBAMUnmerger::check_sym(const std::tr1::shared_ptr<const ContentsEntry> & e) const
{
- std::tr1::shared_ptr<SymlinkExtraInfo> sie(std::tr1::static_pointer_cast<SymlinkExtraInfo>(ei));
-
+ const FSEntry f(e->location_key()->value());
if (! (_imp->options.root() / f).exists())
display("--- [gone ] " + stringify(f));
else if (! (_imp->options.root() / f).is_symbolic_link())
display("--- [!type] " + stringify(f));
- else if ((_imp->options.root() / f).mtime() != sie->_mtime)
+ else if ((_imp->options.root() / f).mtime() != require_key<MetadataTimeKey>(*e, "mtime").value())
display("--- [!time] " + stringify(f));
- else if ((_imp->options.root() / f).readlink() != sie->_dest)
+ else if ((_imp->options.root() / f).readlink() != require_key<MetadataValueKey<std::string> >(*e, "target").value())
display("--- [!dest] " + stringify(f));
else
return true;
@@ -268,14 +250,16 @@ NDBAMUnmerger::check_sym(const FSEntry & f, const std::tr1::shared_ptr<ExtraInfo
}
bool
-NDBAMUnmerger::check_misc(const FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const
+NDBAMUnmerger::check_misc(const std::tr1::shared_ptr<const ContentsEntry> &) const
{
return false;
}
bool
-NDBAMUnmerger::check_dir(const FSEntry & f, const std::tr1::shared_ptr<ExtraInfo> &) const
+NDBAMUnmerger::check_dir(const std::tr1::shared_ptr<const ContentsEntry> & e) const
{
+ const FSEntry f(e->location_key()->value());
+
if (! (_imp->options.root() / f).exists())
display("--- [gone ] " + stringify(f));
else if (! (_imp->options.root() / f).is_directory())
diff --git a/paludis/ndbam_unmerger.hh b/paludis/ndbam_unmerger.hh
index 2652ed3..dc7014c 100644
--- a/paludis/ndbam_unmerger.hh
+++ b/paludis/ndbam_unmerger.hh
@@ -75,12 +75,10 @@ namespace paludis
{
private:
Implementation<NDBAMUnmerger> * _imp;
- class FileExtraInfo;
- class SymlinkExtraInfo;
- void _add_file(const FSEntry & f, const std::string & md5, const time_t mtime);
- void _add_dir(const FSEntry & f);
- void _add_sym(const FSEntry & f, const std::string & target, const time_t mtime);
+ void _add_file(const std::tr1::shared_ptr<const ContentsEntry> &);
+ void _add_dir(const std::tr1::shared_ptr<const ContentsEntry> &);
+ void _add_sym(const std::tr1::shared_ptr<const ContentsEntry> &);
protected:
bool config_protected(const FSEntry &) const;
@@ -90,10 +88,10 @@ namespace paludis
void display(const std::string &) const;
- bool check_file(const FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const;
- bool check_dir(const FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const;
- bool check_sym(const FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const;
- bool check_misc(const FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const;
+ bool check_file(const std::tr1::shared_ptr<const ContentsEntry> &) const;
+ bool check_dir(const std::tr1::shared_ptr<const ContentsEntry> &) const;
+ bool check_sym(const std::tr1::shared_ptr<const ContentsEntry> &) const;
+ bool check_misc(const std::tr1::shared_ptr<const ContentsEntry> &) const;
public:
///\name Basic operations
diff --git a/paludis/repositories/e/e_key.cc b/paludis/repositories/e/e_key.cc
index f756176..38fdb5a 100644
--- a/paludis/repositories/e/e_key.cc
+++ b/paludis/repositories/e/e_key.cc
@@ -40,13 +40,15 @@
#include <paludis/util/tribool.hh>
#include <paludis/util/member_iterator-impl.hh>
#include <paludis/util/sequence.hh>
+#include <paludis/util/safe_ifstream.hh>
+#include <paludis/util/destringify.hh>
#include <paludis/contents.hh>
#include <paludis/repository.hh>
#include <paludis/environment.hh>
#include <paludis/stringify_formatter-impl.hh>
#include <paludis/dep_spec_flattener.hh>
-#include <paludis/util/safe_ifstream.hh>
+#include <paludis/literal_metadata_key.hh>
#include <tr1/functional>
#include <list>
@@ -1006,17 +1008,25 @@ EContentsKey::value() const
}
if ("obj" == tokens.at(0))
- _imp->value->add(std::tr1::shared_ptr<ContentsEntry>(new ContentsFileEntry(tokens.at(1))));
+ {
+ std::tr1::shared_ptr<ContentsEntry> e(new ContentsFileEntry(tokens.at(1)));
+ e->add_metadata_key(make_shared_ptr(new LiteralMetadataTimeKey("mtime", "mtime", mkt_normal, destringify<time_t>(tokens.at(3)))));
+ e->add_metadata_key(make_shared_ptr(new LiteralMetadataValueKey<std::string>("md5", "md5", mkt_normal, tokens.at(2))));
+ _imp->value->add(e);
+ }
else if ("dir" == tokens.at(0))
- _imp->value->add(std::tr1::shared_ptr<ContentsEntry>(new ContentsDirEntry(tokens.at(1))));
- else if ("misc" == tokens.at(0))
- _imp->value->add(std::tr1::shared_ptr<ContentsEntry>(new ContentsMiscEntry(tokens.at(1))));
- else if ("fif" == tokens.at(0))
- _imp->value->add(std::tr1::shared_ptr<ContentsEntry>(new ContentsFifoEntry(tokens.at(1))));
- else if ("dev" == tokens.at(0))
- _imp->value->add(std::tr1::shared_ptr<ContentsEntry>(new ContentsDevEntry(tokens.at(1))));
+ {
+ std::tr1::shared_ptr<ContentsEntry> e(new ContentsDirEntry(tokens.at(1)));
+ _imp->value->add(e);
+ }
else if ("sym" == tokens.at(0))
- _imp->value->add(std::tr1::shared_ptr<ContentsEntry>(new ContentsSymEntry(tokens.at(1), tokens.at(2))));
+ {
+ std::tr1::shared_ptr<ContentsEntry> e(new ContentsSymEntry(tokens.at(1), tokens.at(2)));
+ e->add_metadata_key(make_shared_ptr(new LiteralMetadataTimeKey("mtime", "mtime", mkt_normal, destringify<time_t>(tokens.at(3)))));
+ _imp->value->add(e);
+ }
+ else if ("misc" == tokens.at(0) || "fif" == tokens.at(0) || "dev" == tokens.at(0))
+ _imp->value->add(std::tr1::shared_ptr<ContentsEntry>(new ContentsOtherEntry(tokens.at(1))));
}
return _imp->value;
diff --git a/paludis/repositories/e/exndbam_id.cc b/paludis/repositories/e/exndbam_id.cc
index 073781f..d611f00 100644
--- a/paludis/repositories/e/exndbam_id.cc
+++ b/paludis/repositories/e/exndbam_id.cc
@@ -32,23 +32,8 @@ using namespace paludis::erepository;
namespace
{
- void create_file(Contents & c, const FSEntry & f)
- {
- c.add(make_shared_ptr(new ContentsFileEntry(stringify(f))));
- }
-
- void create_dir(Contents & c, const FSEntry & f)
- {
- c.add(make_shared_ptr(new ContentsDirEntry(stringify(f))));
- }
-
- void create_sym(Contents & c, const FSEntry & f, const FSEntry & t)
- {
- c.add(make_shared_ptr(new ContentsSymEntry(stringify(f), stringify(t))));
- }
-
class ExndbamContentsKey :
- public MetadataValueKey<std::tr1::shared_ptr<const Contents> >
+ public MetadataValueKey<std::tr1::shared_ptr<const Contents> >
{
private:
const PackageID * const _id;
@@ -72,9 +57,9 @@ namespace
using namespace std::tr1::placeholders;
_v.reset(new Contents);
_db->parse_contents(*_id,
- std::tr1::bind(&create_file, std::tr1::ref(*_v), _1),
- std::tr1::bind(&create_dir, std::tr1::ref(*_v), _1),
- std::tr1::bind(&create_sym, std::tr1::ref(*_v), _1, _2)
+ std::tr1::bind(&Contents::add, _v.get(), std::tr1::placeholders::_1),
+ std::tr1::bind(&Contents::add, _v.get(), std::tr1::placeholders::_1),
+ std::tr1::bind(&Contents::add, _v.get(), std::tr1::placeholders::_1)
);
return _v;
}
@@ -93,6 +78,12 @@ namespace
{
return mkt_internal;
}
+
+ virtual void invalidate() const
+ {
+ Lock l(_mutex);
+ _v.reset();
+ }
};
}
diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc
index 3b71e3c..6a83bad 100644
--- a/paludis/repositories/e/vdb_repository.cc
+++ b/paludis/repositories/e/vdb_repository.cc
@@ -439,7 +439,6 @@ VDBRepository::perform_uninstall(
make_named_values<VDBUnmergerOptions>(
value_for<n::config_protect>(final_config_protect),
value_for<n::config_protect_mask>(config_protect_mask),
- value_for<n::contents_file>(pkg_dir / "CONTENTS"),
value_for<n::environment>(_imp->params.environment()),
value_for<n::output_manager>(output_manager),
value_for<n::package_id>(id),
@@ -896,6 +895,9 @@ VDBRepository::merge(const MergeParams & m)
if (is_replace)
{
+ /* hack: before we nuke its vdb dir, preload CONTENTS */
+ is_replace->contents_key()->value();
+
FSEntry old_vdb_dir(_imp->params.location());
old_vdb_dir /= stringify(is_replace->name().category());
old_vdb_dir /= (stringify(is_replace->name().package()) + "-" + stringify(is_replace->version()));
diff --git a/paludis/repositories/e/vdb_repository_TEST.cc b/paludis/repositories/e/vdb_repository_TEST.cc
index 8af7aec..3bbec00 100644
--- a/paludis/repositories/e/vdb_repository_TEST.cc
+++ b/paludis/repositories/e/vdb_repository_TEST.cc
@@ -169,44 +169,30 @@ namespace test_cases
void visit(const ContentsFileEntry & e)
{
_str += "file\n";
- _str += stringify(e.name());
+ _str += stringify(e.location_key()->value());
_str += '\n';
}
void visit(const ContentsDirEntry & e)
{
_str += "directory\n";
- _str += stringify(e.name());
+ _str += stringify(e.location_key()->value());
_str += '\n';
}
void visit(const ContentsSymEntry & e)
{
_str += "symlink\n";
- _str += stringify(e.name());
+ _str += stringify(e.location_key()->value());
_str += '\n';
- _str += stringify(e.target());
+ _str += stringify(e.target_key()->value());
_str += '\n';
}
- void visit(const ContentsMiscEntry & e)
+ void visit(const ContentsOtherEntry & e)
{
- _str += "miscellaneous\n";
- _str += stringify(e.name());
- _str += '\n';
- }
-
- void visit(const ContentsFifoEntry & e)
- {
- _str += "fifo\n";
- _str += stringify(e.name());
- _str += '\n';
- }
-
- void visit(const ContentsDevEntry & e)
- {
- _str += "device\n";
- _str += stringify(e.name());
+ _str += "other\n";
+ _str += stringify(e.location_key()->value());
_str += '\n';
}
};
@@ -250,15 +236,15 @@ namespace test_cases
"symlink\n/symlink\ntarget with trailing space \n"
"symlink\n/symlink\n target with leading space\n"
"symlink\n/symlink with trailing space \ntarget\n"
- "fifo\n/fifo\n"
- "fifo\n/fifo with spaces\n"
- "fifo\n/fifo with consecutive spaces\n"
- "device\n/device\n"
- "device\n/device with spaces\n"
- "device\n/device with consecutive spaces\n"
- "miscellaneous\n/miscellaneous\n"
- "miscellaneous\n/miscellaneous with spaces\n"
- "miscellaneous\n/miscellaneous with consecutive spaces\n");
+ "other\n/fifo\n"
+ "other\n/fifo with spaces\n"
+ "other\n/fifo with consecutive spaces\n"
+ "other\n/device\n"
+ "other\n/device with spaces\n"
+ "other\n/device with consecutive spaces\n"
+ "other\n/miscellaneous\n"
+ "other\n/miscellaneous with spaces\n"
+ "other\n/miscellaneous with consecutive spaces\n");
}
} vdb_repository_contents_test;
diff --git a/paludis/repositories/e/vdb_unmerger.cc b/paludis/repositories/e/vdb_unmerger.cc
index 4e87f47..9e4c134 100644
--- a/paludis/repositories/e/vdb_unmerger.cc
+++ b/paludis/repositories/e/vdb_unmerger.cc
@@ -39,6 +39,8 @@ using namespace paludis;
#include <paludis/util/tokeniser.hh>
#include <paludis/util/strip.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/util/simple_visitor_cast.hh>
+#include <paludis/util/set.hh>
#include <paludis/output_manager.hh>
#include <paludis/util/safe_ifstream.hh>
@@ -65,58 +67,6 @@ namespace paludis
};
}
-class VDBUnmerger::FileExtraInfo :
- public Unmerger::ExtraInfo
-{
- public:
- std::string _md5sum;
- time_t _mtime;
-
- FileExtraInfo(std::string md5sum, time_t mtime) :
- _md5sum(md5sum),
- _mtime(mtime)
- {
- }
-
- virtual ~FileExtraInfo()
- {
- }
-};
-
-class VDBUnmerger::SymlinkExtraInfo :
- public Unmerger::ExtraInfo
-{
- public:
- std::string _dest;
- time_t _mtime;
-
- SymlinkExtraInfo(std::string dest, time_t mtime) :
- _dest(dest),
- _mtime(mtime)
- {
- }
-
- virtual ~SymlinkExtraInfo()
- {
- }
-};
-
-class VDBUnmerger::MiscExtraInfo :
- public Unmerger::ExtraInfo
-{
- public:
- std::string _type;
-
- MiscExtraInfo(std::string type) :
- _type(type)
- {
- }
-
- virtual ~MiscExtraInfo()
- {
- }
-};
-
VDBUnmerger::VDBUnmerger(const VDBUnmergerOptions & o) :
Unmerger(make_named_values<UnmergerOptions>(
value_for<n::environment>(o.environment()),
@@ -202,74 +152,83 @@ VDBUnmerger::make_tidy(const FSEntry & f) const
return f_str.substr(root_str.length());
}
-void
-VDBUnmerger::populate_unmerge_set()
+namespace
{
- SafeIFStream c(_imp->options.contents_file());
- if (! c)
- throw VDBUnmergerError("Cannot read '" + stringify(_imp->options.contents_file()) + "'");
-
- std::string line;
- while (std::getline(c, line))
+ struct GetET
{
- std::vector<std::string> tokens;
- if (! erepository::VDBContentsTokeniser::tokenise(line, std::back_inserter(tokens)))
+ EntryType visit(const ContentsFileEntry &) const
{
- Log::get_instance()->message("e.vdb.contents.malformed", ll_warning, lc_no_context) << "Malformed VDB entry '" << line << "'";
- continue;
+ return et_file;
}
- if ("obj" == tokens.at(0))
+ EntryType visit(const ContentsDirEntry &) const
{
- std::string md5sum(tokens.at(2));
- time_t mtime(destringify<time_t>(tokens.at(3)));
- std::tr1::shared_ptr<ExtraInfo> extra(new FileExtraInfo(md5sum, mtime));
- add_unmerge_entry(tokens.at(1), et_file, extra);
-
+ return et_dir;
}
- else if ("sym" == tokens.at(0))
- {
- std::string dest(tokens.at(2));
- time_t mtime(destringify<time_t>(tokens.at(3)));
- std::tr1::shared_ptr<ExtraInfo> extra(new SymlinkExtraInfo(dest, mtime));
- add_unmerge_entry(tokens.at(1), et_sym, extra);
- }
- else if ("misc" == tokens.at(0))
- {
- }
- else if ("fif" == tokens.at(0) || "dev" == tokens.at(0))
+
+ EntryType visit(const ContentsSymEntry &) const
{
- std::string type(tokens.at(0));
- std::tr1::shared_ptr<ExtraInfo> extra(new MiscExtraInfo(type));
- add_unmerge_entry(tokens.at(1), et_misc, extra);
+ return et_sym;
}
- else if ("dir" == tokens.at(0))
+
+ EntryType visit(const ContentsOtherEntry &) const
{
- add_unmerge_entry(tokens.at(1), et_dir, std::tr1::shared_ptr<ExtraInfo>());
+ return et_misc;
}
- else
- Log::get_instance()->message("e.vdb.contents.malformed", ll_warning, lc_no_context)
- << "Malformed VDB entry '" << line << "'";
+ };
+
+ EntryType get_et(const ContentsEntry & e)
+ {
+ GetET v;
+ return e.accept_returning<EntryType>(v);
}
}
-bool
-VDBUnmerger::check_file(const FSEntry & f, const std::tr1::shared_ptr<ExtraInfo> & ei) const
+void
+VDBUnmerger::populate_unmerge_set()
+{
+ if (! _imp->options.package_id()->contents_key()->value())
+ throw VDBUnmergerError("Id '" + stringify(*_imp->options.package_id()) + "' has no contents key");
+
+ std::tr1::shared_ptr<const Contents> contents(_imp->options.package_id()->contents_key()->value());
+ for (Contents::ConstIterator c(contents->begin()), c_end(contents->end()) ;
+ c != c_end ; ++c)
+ add_unmerge_entry(get_et(**c), *c);
+}
+
+namespace
{
- std::tr1::shared_ptr<FileExtraInfo> fie(std::tr1::static_pointer_cast<FileExtraInfo>(ei));
+ template <typename T_>
+ const T_ & require_key(const MetadataKeyHolder & h, const std::string & r)
+ {
+ MetadataKeyHolder::MetadataConstIterator m(h.find_metadata(r));
+ if (m == h.end_metadata())
+ throw InternalError(PALUDIS_HERE, "Expected key '" + r + "' not found");
+ const T_ * const c(simple_visitor_cast<const T_>(**m));
+ if (! c)
+ throw InternalError(PALUDIS_HERE, "Key '" + r + "' is of wrong type");
+
+ return *c;
+ }
+}
+
+bool
+VDBUnmerger::check_file(const std::tr1::shared_ptr<const ContentsEntry> & e) const
+{
+ const FSEntry f(e->location_key()->value());
if (! (_imp->options.root() / f).exists())
display("--- [gone ] " + stringify(f));
else if (! (_imp->options.root() / f).is_regular_file())
display("--- [!type] " + stringify(f));
- else if ((_imp->options.root() / f).mtime() != fie->_mtime)
+ else if ((_imp->options.root() / f).mtime() != require_key<MetadataTimeKey>(*e, "mtime").value())
display("--- [!time] " + stringify(f));
else
{
try
{
SafeIFStream md5_file(_imp->options.root() / f);
- if (MD5(md5_file).hexsum() != fie->_md5sum)
+ if (MD5(md5_file).hexsum() != require_key<MetadataValueKey<std::string> >(*e, "md5").value())
display("--- [!md5 ] " + stringify(f));
else if (config_protected(_imp->options.root() / f))
display("--- [cfgpr] " + stringify(f));
@@ -288,17 +247,17 @@ VDBUnmerger::check_file(const FSEntry & f, const std::tr1::shared_ptr<ExtraInfo>
}
bool
-VDBUnmerger::check_sym(const FSEntry & f, const std::tr1::shared_ptr<ExtraInfo> & ei) const
+VDBUnmerger::check_sym(const std::tr1::shared_ptr<const ContentsEntry> & e) const
{
- std::tr1::shared_ptr<SymlinkExtraInfo> sie(std::tr1::static_pointer_cast<SymlinkExtraInfo>(ei));
+ const FSEntry f(e->location_key()->value());
if (! (_imp->options.root() / f).exists())
display("--- [gone ] " + stringify(f));
else if (! (_imp->options.root() / f).is_symbolic_link())
display("--- [!type] " + stringify(f));
- else if ((_imp->options.root() / f).mtime() != sie->_mtime)
+ else if ((_imp->options.root() / f).mtime() != require_key<MetadataTimeKey>(*e, "mtime").value())
display("--- [!time] " + stringify(f));
- else if ((_imp->options.root() / f).readlink() != sie->_dest)
+ else if ((_imp->options.root() / f).readlink() != require_key<MetadataValueKey<std::string> >(*e, "target").value())
display("--- [!dest] " + stringify(f));
else
return true;
@@ -307,25 +266,20 @@ VDBUnmerger::check_sym(const FSEntry & f, const std::tr1::shared_ptr<ExtraInfo>
}
bool
-VDBUnmerger::check_misc(const FSEntry & f, const std::tr1::shared_ptr<ExtraInfo> & ei) const
+VDBUnmerger::check_misc(const std::tr1::shared_ptr<const ContentsEntry> & e) const
{
- std::tr1::shared_ptr<MiscExtraInfo> mie(std::tr1::static_pointer_cast<MiscExtraInfo>(ei));
+ const FSEntry f(e->location_key()->value());
if (! (_imp->options.root() / f).exists())
display("--- [gone ] " + stringify(f));
- else if ("fif" == mie->_type && ! (_imp->options.root() / f).is_fifo())
- display("--- [!type] " + stringify(f));
- else if ("dev" == mie->_type && ! (_imp->options.root() / f).is_device())
- display("--- [!type] " + stringify(f));
- else
- return true;
-
return false;
}
bool
-VDBUnmerger::check_dir(const FSEntry & f, const std::tr1::shared_ptr<ExtraInfo> &) const
+VDBUnmerger::check_dir(const std::tr1::shared_ptr<const ContentsEntry> & e) const
{
+ const FSEntry f(e->location_key()->value());
+
if (! (_imp->options.root() / f).exists())
display("--- [gone ] " + stringify(f));
else if (! (_imp->options.root() / f).is_directory())
diff --git a/paludis/repositories/e/vdb_unmerger.hh b/paludis/repositories/e/vdb_unmerger.hh
index d09aa97..858ced5 100644
--- a/paludis/repositories/e/vdb_unmerger.hh
+++ b/paludis/repositories/e/vdb_unmerger.hh
@@ -34,7 +34,6 @@ namespace paludis
{
struct config_protect;
struct config_protect_mask;
- struct contents_file;
struct environment;
struct output_manager;
struct package_id;
@@ -52,7 +51,6 @@ namespace paludis
{
NamedValue<n::config_protect, std::string> config_protect;
NamedValue<n::config_protect_mask, std::string> config_protect_mask;
- NamedValue<n::contents_file, FSEntry> contents_file;
NamedValue<n::environment, Environment *> environment;
NamedValue<n::output_manager, std::tr1::shared_ptr<OutputManager> > output_manager;
NamedValue<n::package_id, std::tr1::shared_ptr<const PackageID> > package_id;
@@ -90,9 +88,6 @@ namespace paludis
{
private:
Implementation<VDBUnmerger> * _imp;
- class FileExtraInfo;
- class SymlinkExtraInfo;
- class MiscExtraInfo;
protected:
bool config_protected(const FSEntry &) const;
@@ -102,10 +97,10 @@ namespace paludis
void display(const std::string &) const;
- bool check_file(const FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const;
- bool check_dir(const FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const;
- bool check_sym(const FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const;
- bool check_misc(const FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const;
+ bool check_file(const std::tr1::shared_ptr<const ContentsEntry> &) const;
+ bool check_dir(const std::tr1::shared_ptr<const ContentsEntry> &) const;
+ bool check_sym(const std::tr1::shared_ptr<const ContentsEntry> &) const;
+ bool check_misc(const std::tr1::shared_ptr<const ContentsEntry> &) const;
public:
///\name Basic operations
diff --git a/paludis/repositories/e/vdb_unmerger_TEST.cc b/paludis/repositories/e/vdb_unmerger_TEST.cc
index 68cb763..dd360a8 100644
--- a/paludis/repositories/e/vdb_unmerger_TEST.cc
+++ b/paludis/repositories/e/vdb_unmerger_TEST.cc
@@ -17,20 +17,41 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "vdb_unmerger.hh"
+#include <paludis/repositories/e/vdb_unmerger.hh>
+#include <paludis/repositories/e/vdb_repository.hh>
#include <paludis/environments/test/test_environment.hh>
#include <paludis/repositories/fake/fake_repository.hh>
#include <paludis/util/make_named_values.hh>
-#include <paludis/standard_output_manager.hh>
#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/map.hh>
+#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/standard_output_manager.hh>
+#include <paludis/user_dep_spec.hh>
+#include <paludis/package_database.hh>
+#include <paludis/generator.hh>
+#include <paludis/selection.hh>
+#include <paludis/filtered_generator.hh>
+#include <paludis/filter.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
+#include <algorithm>
using namespace paludis;
using namespace test;
namespace
{
+ std::string from_keys(const std::tr1::shared_ptr<const Map<std::string, std::string> > & m,
+ const std::string & k)
+ {
+ Map<std::string, std::string>::ConstIterator mm(m->find(k));
+ if (m->end() == mm)
+ return "";
+ else
+ return mm->second;
+ }
+
class VDBUnmergerNoDisplay :
public VDBUnmerger
{
@@ -48,15 +69,24 @@ namespace
}
};
+ std::string fix(const std::string & s)
+ {
+ std::string result(s);
+ std::replace(result.begin(), result.end(), ' ', '_');
+ std::replace(result.begin(), result.end(), '\t', '_');
+ return result;
+ }
+
class VDBUnmergerTest :
public TestCase
{
public:
-
+ const std::string what;
FSEntry root_dir;
std::string target;
TestEnvironment env;
- VDBUnmergerNoDisplay unmerger;
+ std::tr1::shared_ptr<Repository> repo;
+ std::tr1::shared_ptr<VDBUnmergerNoDisplay> unmerger;
bool repeatable() const
{
@@ -64,22 +94,42 @@ namespace
}
protected:
-
- VDBUnmergerTest(const std::string & what) :
- TestCase("unmerge '" + what + "' test"),
+ VDBUnmergerTest(const std::string & w) :
+ TestCase("unmerge '" + w + "' test"),
+ what(w),
root_dir("vdb_unmerger_TEST_dir/root"),
- target(what),
- unmerger(make_named_values<VDBUnmergerOptions>(
- value_for<n::config_protect>("/protected_file /protected_dir"),
- value_for<n::config_protect_mask>("/protected_dir/unprotected_file /protected_dir/unprotected_dir"),
- value_for<n::contents_file>("vdb_unmerger_TEST_dir/CONTENTS/" + what),
- value_for<n::environment>(&env),
- value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
- value_for<n::package_id>(std::tr1::shared_ptr<PackageID>()),
- value_for<n::root>(root_dir)
- ))
+ target(w)
{
}
+
+ virtual void main_run() = 0;
+
+ public:
+ void run()
+ {
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "vdb");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("provides_cache", "/var/empty");
+ keys->insert("location", stringify(FSEntry::cwd() / "vdb_unmerger_TEST_dir" / "repo"));
+ keys->insert("builddir", stringify(FSEntry::cwd() / "vdb_unmerger_TEST_dir" / "build"));
+ repo = VDBRepository::repository_factory_create(&env, std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1));
+ env.package_database()->add_repository(0, repo);
+
+ unmerger.reset(new VDBUnmergerNoDisplay(make_named_values<VDBUnmergerOptions>(
+ value_for<n::config_protect>("/protected_file /protected_dir"),
+ value_for<n::config_protect_mask>("/protected_dir/unprotected_file /protected_dir/unprotected_dir"),
+ value_for<n::environment>(&env),
+ value_for<n::output_manager>(make_shared_ptr(new StandardOutputManager)),
+ value_for<n::package_id>(*env[selection::RequireExactlyOne(generator::Matches(
+ parse_user_package_dep_spec("cat/" + fix(what), &env, UserPackageDepSpecOptions()),
+ MatchPackageOptions()))]->begin()),
+ value_for<n::root>(root_dir)
+ )));
+
+ main_run();
+ }
};
}
@@ -89,11 +139,11 @@ namespace test_cases
{
VDBUnmergerTestFileOk() : VDBUnmergerTest("file_ok") { }
- void run()
+ void main_run()
{
TEST_CHECK((root_dir / target).is_regular_file());
- unmerger.unmerge();
+ unmerger->unmerge();
TEST_CHECK(! (root_dir / target).exists());
}
@@ -103,11 +153,11 @@ namespace test_cases
{
VDBUnmergerTestFileWithSpaces() : VDBUnmergerTest("file_ with spaces") { }
- void run()
+ void main_run()
{
TEST_CHECK((root_dir / target).is_regular_file());
- unmerger.unmerge();
+ unmerger->unmerge();
TEST_CHECK(! (root_dir / target).exists());
}
@@ -117,11 +167,11 @@ namespace test_cases
{
VDBUnmergerTestFileWithLotsOfSpaces() : VDBUnmergerTest("file_ with lots of spaces") { }
- void run()
+ void main_run()
{
TEST_CHECK((root_dir / target).is_regular_file());
- unmerger.unmerge();
+ unmerger->unmerge();
TEST_CHECK(! (root_dir / target).exists());
}
@@ -131,11 +181,11 @@ namespace test_cases
{
VDBUnmergerTestFileWithTrailingSpace() : VDBUnmergerTest("file_ with trailing space\t ") { }
- void run()
+ void main_run()
{
TEST_CHECK((root_dir / target).is_regular_file());
- unmerger.unmerge();
+ unmerger->unmerge();
TEST_CHECK(! (root_dir / target).exists());
}
@@ -145,11 +195,11 @@ namespace test_cases
{
VDBUnmergerTestFileBadType() : VDBUnmergerTest("file_bad_type") { }
- void run()
+ void main_run()
{
TEST_CHECK((root_dir / target).is_directory());
- unmerger.unmerge();
+ unmerger->unmerge();
TEST_CHECK((root_dir / target).is_directory());
}
@@ -159,11 +209,11 @@ namespace test_cases
{
VDBUnmergerTestFileBadMd5sum() : VDBUnmergerTest("file_bad_md5sum") { }
- void run()
+ void main_run()
{
TEST_CHECK((root_dir / target).is_regular_file());
- unmerger.unmerge();
+ unmerger->unmerge();
TEST_CHECK((root_dir / target).is_regular_file());
}
@@ -173,11 +223,11 @@ namespace test_cases
{
VDBUnmergerTestFileBadMtime() : VDBUnmergerTest("file_bad_mtime") { }
- void run()
+ void main_run()
{
TEST_CHECK((root_dir / target).is_regular_file());
- unmerger.unmerge();
+ unmerger->unmerge();
TEST_CHECK((root_dir / target).is_regular_file());
}
@@ -187,9 +237,9 @@ namespace test_cases
{
VDBUnmergerTestFileReplacesDirectory() : VDBUnmergerTest("file_replaces_dir") { }
- void run()
+ void main_run()
{
- unmerger.unmerge();
+ unmerger->unmerge();
}
} test_vdb_unmerger_file_replaces_directory;
@@ -197,11 +247,11 @@ namespace test_cases
{
VDBUnmergerTestDirOk() : VDBUnmergerTest("dir_ok") { }
- void run()
+ void main_run()
{
TEST_CHECK((root_dir / target).is_directory());
- unmerger.unmerge();
+ unmerger->unmerge();
TEST_CHECK(! (root_dir / target).exists());
}
@@ -211,11 +261,11 @@ namespace test_cases
{
VDBUnmergerTestDirWithSpaces() : VDBUnmergerTest("dir_ with spaces") { }
- void run()
+ void main_run()
{
TEST_CHECK((root_dir / target).is_directory());
- unmerger.unmerge();
+ unmerger->unmerge();
TEST_CHECK(! (root_dir / target).exists());
}
@@ -225,11 +275,11 @@ namespace test_cases
{
VDBUnmergerTestDirWithLotsOfSpaces() : VDBUnmergerTest("dir_ with lots of spaces") { }
- void run()
+ void main_run()
{
TEST_CHECK((root_dir / target).is_directory());
- unmerger.unmerge();
+ unmerger->unmerge();
TEST_CHECK(! (root_dir / target).exists());
}
@@ -239,11 +289,11 @@ namespace test_cases
{
VDBUnmergerTestDirBadType() : VDBUnmergerTest("dir_bad_type") { }
- void run()
+ void main_run()
{
TEST_CHECK((root_dir / target).is_regular_file());
- unmerger.unmerge();
+ unmerger->unmerge();
TEST_CHECK((root_dir / target).is_regular_file());
}
@@ -253,11 +303,11 @@ namespace test_cases
{
VDBUnmergerTestDirNotEmpty() : VDBUnmergerTest("dir_not_empty") { }
- void run()
+ void main_run()
{
TEST_CHECK((root_dir / target).is_directory());
- unmerger.unmerge();
+ unmerger->unmerge();
TEST_CHECK((root_dir / target).is_directory());
}
@@ -267,11 +317,11 @@ namespace test_cases
{
VDBUnmergerTestSymOk() : VDBUnmergerTest("sym_ok") { }
- void run()
+ void main_run()
{
TEST_CHECK((root_dir / target).is_symbolic_link());
- unmerger.unmerge();
+ unmerger->unmerge();
TEST_CHECK(! (root_dir / target).exists());
}
@@ -281,11 +331,11 @@ namespace test_cases
{
VDBUnmergerTestSymWithSpaces() : VDBUnmergerTest("sym_ with spaces") { }
- void run()
+ void main_run()
{
TEST_CHECK((root_dir / target).is_symbolic_link());
- unmerger.unmerge();
+ unmerger->unmerge();
TEST_CHECK(! (root_dir / target).exists());
}
@@ -295,11 +345,11 @@ namespace test_cases
{
VDBUnmergerTestSymWithLotsOfSpaces() : VDBUnmergerTest("sym_ with lots of spaces") { }
- void run()
+ void main_run()
{
TEST_CHECK((root_dir / target).is_symbolic_link());
- unmerger.unmerge();
+ unmerger->unmerge();
TEST_CHECK(! (root_dir / target).exists());
}
@@ -309,11 +359,11 @@ namespace test_cases
{
VDBUnmergerTestSymWithManyArrows() : VDBUnmergerTest("sym with many arrows") { }
- void run()
+ void main_run()
{
TEST_CHECK((root_dir / target).is_symbolic_link());
- unmerger.unmerge();
+ unmerger->unmerge();
TEST_CHECK(! (root_dir / target).exists());
}
@@ -323,11 +373,11 @@ namespace test_cases
{
VDBUnmergerTestSymBadType() : VDBUnmergerTest("sym_bad_type") { }
- void run()
+ void main_run()
{
TEST_CHECK((root_dir / target).is_regular_file());
- unmerger.unmerge();
+ unmerger->unmerge();
TEST_CHECK((root_dir / target).is_regular_file());
}
@@ -337,12 +387,12 @@ namespace test_cases
{
VDBUnmergerTestSymBadDst() : VDBUnmergerTest("sym_bad_dst") { }
- void run()
+ void main_run()
{
TEST_CHECK((root_dir / target).is_symbolic_link());
TEST_CHECK(! (root_dir / "sym_dst_bad").exists());
- unmerger.unmerge();
+ unmerger->unmerge();
TEST_CHECK((root_dir / target).is_symbolic_link());
}
@@ -352,11 +402,11 @@ namespace test_cases
{
VDBUnmergerTestSymBadMtime() : VDBUnmergerTest("sym_bad_mtime") { }
- void run()
+ void main_run()
{
TEST_CHECK((root_dir / target).is_symbolic_link());
- unmerger.unmerge();
+ unmerger->unmerge();
TEST_CHECK((root_dir / target).is_symbolic_link());
@@ -367,11 +417,11 @@ namespace test_cases
{
VDBUnmergerTestSymBadEntry1() : VDBUnmergerTest("sym_bad_entry_1") { }
- void run()
+ void main_run()
{
TEST_CHECK((root_dir / target).is_symbolic_link());
- unmerger.unmerge();
+ unmerger->unmerge();
TEST_CHECK((root_dir / target).is_symbolic_link());
}
@@ -381,63 +431,21 @@ namespace test_cases
{
VDBUnmergerTestSymBadEntry2() : VDBUnmergerTest("sym_bad_entry_2") { }
- void run()
+ void main_run()
{
TEST_CHECK((root_dir / target).is_symbolic_link());
- unmerger.unmerge();
+ unmerger->unmerge();
TEST_CHECK((root_dir / target).is_symbolic_link());
}
} test_vdb_unmerger_sym_bad_entry_2;
- struct VDBUnmergerTestFifoOk : VDBUnmergerTest
- {
- VDBUnmergerTestFifoOk() : VDBUnmergerTest("fifo_ok") { }
-
- void run()
- {
- TEST_CHECK((root_dir / target).is_fifo());
-
- unmerger.unmerge();
-
- TEST_CHECK(! (root_dir / target).exists());
- }
- } test_vdb_unmerger_fifo_ok;
-
- struct VDBUnmergerTestFifoWithSpaces : VDBUnmergerTest
- {
- VDBUnmergerTestFifoWithSpaces() : VDBUnmergerTest("fifo_ with spaces") { }
-
- void run()
- {
- TEST_CHECK((root_dir / target).is_fifo());
-
- unmerger.unmerge();
-
- TEST_CHECK(! (root_dir / target).exists());
- }
- } test_vdb_unmerger_fifo_with_spaces;
-
- struct VDBUnmergerTestFifoBadType : VDBUnmergerTest
- {
- VDBUnmergerTestFifoBadType() : VDBUnmergerTest("fifo_bad_type") { }
-
- void run()
- {
- TEST_CHECK((root_dir / target).is_regular_file());
-
- unmerger.unmerge();
-
- TEST_CHECK((root_dir / target).is_regular_file());
- }
- } test_vdb_unmerger_fifo_bad_type;
-
struct VDBUnmergerTestConfigProtect : VDBUnmergerTest
{
VDBUnmergerTestConfigProtect() : VDBUnmergerTest("config_protect") { }
- void run()
+ void main_run()
{
TEST_CHECK((root_dir / "protected_file").is_regular_file());
TEST_CHECK((root_dir / "unprotected_file").is_regular_file());
@@ -453,7 +461,7 @@ namespace test_cases
TEST_CHECK((root_dir / "protected_dir_not_really/unprotected_file").is_regular_file());
- unmerger.unmerge();
+ unmerger->unmerge();
TEST_CHECK((root_dir / "protected_file").exists());
TEST_CHECK(! (root_dir / "unprotected_file").exists());
diff --git a/paludis/repositories/e/vdb_unmerger_TEST_setup.sh b/paludis/repositories/e/vdb_unmerger_TEST_setup.sh
index 35ce29d..903c800 100755
--- a/paludis/repositories/e/vdb_unmerger_TEST_setup.sh
+++ b/paludis/repositories/e/vdb_unmerger_TEST_setup.sh
@@ -4,17 +4,32 @@
mkdir vdb_unmerger_TEST_dir || exit 2
cd vdb_unmerger_TEST_dir || exit 3
-mkdir CONTENTS
-
+mkdir -p repo/cat
mkdir root
cd root
+fix() {
+ tr ' \t' '__' <<<"$1"
+}
+
+make_vdb() {
+ mkdir -p "../repo/cat/$1-1234"
+ for i in SLOT EAPI ; do
+ echo "0" > "../repo/cat/$1-1234/${i}"
+ done
+ for i in DEPEND RDEPEND LICENSE INHERITED IUSE PDEPEND PROVIDE ; do
+ touch "../repo/cat/$1-1234/${i}"
+ done
+}
+
make_file() {
echo "foo" > "file_$1"
md5=${2:-$(md5sum "file_$1" | cut -f1 -d' ')}
mtime=${3:-$(${PALUDIS_EBUILD_DIR}/utils/wrapped_getmtime "file_$1")}
- echo "obj /file_$1 ${md5} ${mtime}" > "../CONTENTS/file_$1"
+
+ make_vdb "file_$(fix "$1" )"
+ echo "obj /file_$1 ${md5} ${mtime}" > "../repo/cat/file_$(fix "$1" )-1234/CONTENTS"
}
make_sym() {
@@ -25,7 +40,9 @@ make_sym() {
ln -s "${dst}" "${src}"
mtime=${3:-$(${PALUDIS_EBUILD_DIR}/utils/wrapped_getmtime "sym_$1")}
- echo "sym /${src} -> sym_$1_dst ${mtime}" > "../CONTENTS/sym_$1"
+
+ make_vdb "sym_$(fix "$1" )"
+ echo "sym /${src} -> sym_$1_dst ${mtime}" > "../repo/cat/sym_$(fix "$1" )-1234/CONTENTS"
}
make_file "ok"
@@ -42,35 +59,44 @@ mkdir file_bad_type
make_file "bad_md5sum" "bad_md5sum"
make_file "bad_mtime" "" "123"
-echo "obj /file_bad_entry foo" > ../CONTENTS/file_bad_entry
-echo "dir /file_replaces_dir" > ../CONTENTS/file_replaces_dir
-echo "obj /file_replaces_dir/foo 00000000000000000000000 123" >> ../CONTENTS/file_replaces_dir
+make_vdb file_bad_entry
+echo "obj /file_bad_entry foo" > ../repo/cat/file_bad_entry-1234/CONTENTS
+
+make_vdb file_replaces_dir
+echo "dir /file_replaces_dir" > ../repo/cat/file_replaces_dir-1234/CONTENTS
+echo "obj /file_replaces_dir/foo 00000000000000000000000 123" >> ../repo/cat/file_replaces_dir-1234/CONTENTS
> file_replaces_dir
+make_vdb dir_ok
mkdir dir_ok
-echo "dir /dir_ok" > ../CONTENTS/dir_ok
+echo "dir /dir_ok" > ../repo/cat/dir_ok-1234/CONTENTS
+make_vdb "dir__with_spaces"
mkdir "dir_ with spaces"
-echo "dir /dir_ with spaces" > "../CONTENTS/dir_ with spaces"
+echo "dir /dir_ with spaces" > "../repo/cat/dir__with_spaces-1234/CONTENTS"
+make_vdb "dir__with_lots__of___spaces"
mkdir "dir_ with lots of spaces"
-echo "dir /dir_ with lots of spaces" > "../CONTENTS/dir_ with lots of spaces"
+echo "dir /dir_ with lots of spaces" > "../repo/cat/dir__with_lots__of___spaces-1234/CONTENTS"
+make_vdb "dir_bad_type"
> dir_bad_type
-echo "dir /dir_bad_type" > ../CONTENTS/dir_bad_type
+echo "dir /dir_bad_type" > ../repo/cat/dir_bad_type-1234/CONTENTS
+make_vdb "dir_not_empty"
mkdir -p dir_not_empty/foo
-echo "dir /dir_not_empty" > ../CONTENTS/dir_not_empty
+echo "dir /dir_not_empty" > ../repo/cat/dir_not_empty-1234/CONTENTS
make_sym "ok"
make_sym " with spaces"
make_sym " with lots of spaces"
+make_vdb sym_with_many_arrows
> "sym -> with -> many -> arrows -> dst"
ln -s "sym -> with -> many -> arrows -> dst" "sym with many arrows"
mtime=${3:-$(${PALUDIS_EBUILD_DIR}/utils/wrapped_getmtime "sym with many arrows")}
-echo "sym /sym with many arrows -> sym -> with -> many -> arrows -> dst ${mtime}" > "../CONTENTS/sym with many arrows"
+echo "sym /sym with many arrows -> sym -> with -> many -> arrows -> dst ${mtime}" > "../repo/cat/sym_with_many_arrows-1234/CONTENTS"
make_sym "bad_type"
rm sym_bad_type
@@ -79,19 +105,13 @@ rm sym_bad_type
make_sym "bad_dst" "sym_dst_bad"
make_sym "bad_mtime" "" "123"
+make_vdb sym_bad_entry_1
ln -s foo sym_bad_entry_1
-echo "sym /sym_bad_entry_1 -> foo" > "../CONTENTS/sym_bad_entry_1"
-ln -s foo sym_bad_entry_2
-echo "sym /sym_bad_entry_2 >> foo 123" > "../CONTENTS/sym_bad_entry_2"
+echo "sym /sym_bad_entry_1 -> foo" > "../repo/cat/sym_bad_entry_1-1234/CONTENTS"
-mkfifo fifo_ok
-echo "fif /fifo_ok" > "../CONTENTS/fifo_ok"
-
-mkfifo "fifo_ with spaces"
-echo "fif /fifo_ with spaces" > "../CONTENTS/fifo_ with spaces"
-
-> fifo_bad_type
-echo "fif /fifo_bad_type" > "../CONTENTS/fifo_bad_type"
+make_vdb sym_bad_entry_2
+ln -s foo sym_bad_entry_2
+echo "sym /sym_bad_entry_2 >> foo 123" > "../repo/cat/sym_bad_entry_2-1234/CONTENTS"
touch protected_file
touch unprotected_file
@@ -111,7 +131,8 @@ touch protected_dir/unprotected_dir_not_really/protected_file
mkdir protected_dir_not_really
touch protected_dir_not_really/unprotected_file
+make_vdb config_protect
find . -name '*protected*' -type f -print | while read file; do
echo obj "${file#.}" "$(md5sum "${file}" | cut -f1 -d' ')" "$(${PALUDIS_EBUILD_DIR}/utils/wrapped_getmtime "${file}")"
-done >../CONTENTS/config_protect
+done >../repo/cat/config_protect-1234/CONTENTS
diff --git a/paludis/repositories/unpackaged/installed_id.cc b/paludis/repositories/unpackaged/installed_id.cc
index adb5a56..78013ab 100644
--- a/paludis/repositories/unpackaged/installed_id.cc
+++ b/paludis/repositories/unpackaged/installed_id.cc
@@ -128,9 +128,9 @@ namespace
using namespace std::tr1::placeholders;
_v.reset(new Contents);
_db->parse_contents(*_id,
- std::tr1::bind(&create_file, std::tr1::ref(*_v), _1),
- std::tr1::bind(&create_dir, std::tr1::ref(*_v), _1),
- std::tr1::bind(&create_sym, std::tr1::ref(*_v), _1, _2)
+ std::tr1::bind(&Contents::add, _v.get(), std::tr1::placeholders::_1),
+ std::tr1::bind(&Contents::add, _v.get(), std::tr1::placeholders::_1),
+ std::tr1::bind(&Contents::add, _v.get(), std::tr1::placeholders::_1)
);
return _v;
}
diff --git a/paludis/repositories/unpackaged/installed_repository_TEST.cc b/paludis/repositories/unpackaged/installed_repository_TEST.cc
index 649e0de..fdec71a 100644
--- a/paludis/repositories/unpackaged/installed_repository_TEST.cc
+++ b/paludis/repositories/unpackaged/installed_repository_TEST.cc
@@ -55,32 +55,22 @@ namespace
void visit(const ContentsFileEntry & f)
{
- s << "file<" << f.name() << ">";
+ s << "file<" << f.location_key()->value() << ">";
}
void visit(const ContentsDirEntry & f)
{
- s << "dir<" << f.name() << ">";
+ s << "dir<" << f.location_key()->value() << ">";
}
void visit(const ContentsSymEntry & f)
{
- s << "sym<" << f.name() << "=" << f.target() << ">";
- }
-
- void visit(const ContentsMiscEntry & f)
- {
- s << "misc<" << f.name() << ">";
- }
+ s << "sym<" << f.location_key()->value() << "=" << f.target_key()->value() << ">";
- void visit(const ContentsDevEntry & f)
- {
- s << "dev<" << f.name() << ">";
}
-
- void visit(const ContentsFifoEntry & f)
+ void visit(const ContentsOtherEntry & f)
{
- s << "fifo<" << f.name() << ">";
+ s << "other<" << f.location_key()->value() << ">";
}
};
diff --git a/paludis/unmerger.cc b/paludis/unmerger.cc
index 9471cba..fd1289f 100644
--- a/paludis/unmerger.cc
+++ b/paludis/unmerger.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
* Copyright (c) 2007 Piotr Jaroszyński
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -22,6 +22,8 @@
#include <paludis/environment.hh>
#include <paludis/hook.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/contents.hh>
+#include <paludis/metadata_key.hh>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -32,20 +34,21 @@ using namespace paludis;
namespace paludis
{
+ typedef std::multimap<std::string, std::pair<EntryType, std::tr1::shared_ptr<const ContentsEntry> > > UnmergeEntries;
+ typedef UnmergeEntries::reverse_iterator UnmergeEntriesIterator;
+
template<>
struct Implementation<Unmerger>
{
UnmergerOptions options;
- std::multimap<std::string, std::pair<EntryType, std::tr1::shared_ptr<Unmerger::ExtraInfo> > > unmerge_entries;
+ UnmergeEntries unmerge_entries;
Implementation(const UnmergerOptions & o) :
options(o)
{
}
};
-
- typedef std::multimap<std::string, std::pair<EntryType, std::tr1::shared_ptr<Unmerger::ExtraInfo> > >::reverse_iterator UnmergeEntriesIterator;
}
UnmergerError::UnmergerError(const std::string & s) throw () :
@@ -53,10 +56,6 @@ UnmergerError::UnmergerError(const std::string & s) throw () :
{
}
-Unmerger::ExtraInfo::~ExtraInfo()
-{
-}
-
Unmerger::Unmerger(const UnmergerOptions & o) :
PrivateImplementationPattern<Unmerger>(new Implementation<Unmerger>(o))
{
@@ -67,9 +66,9 @@ Unmerger::~Unmerger()
}
void
-Unmerger::add_unmerge_entry(const std::string & f, EntryType et, const std::tr1::shared_ptr<ExtraInfo> & ei)
+Unmerger::add_unmerge_entry(const EntryType et, const std::tr1::shared_ptr<const ContentsEntry> & e)
{
- _imp->unmerge_entries.insert(std::make_pair(f, std::make_pair(et, ei)));
+ _imp->unmerge_entries.insert(std::make_pair(stringify(e->location_key()->value()), std::make_pair(et, e)));
}
void
@@ -88,19 +87,19 @@ Unmerger::unmerge()
switch (i->second.first)
{
case et_dir:
- unmerge_dir(f, i->second.second);
+ unmerge_dir(i->second.second);
continue;
case et_file:
- unmerge_file(f, i->second.second);
+ unmerge_file(i->second.second);
continue;
case et_sym:
- unmerge_sym(f, i->second.second);
+ unmerge_sym(i->second.second);
continue;
case et_misc:
- unmerge_misc(f, i->second.second);
+ unmerge_misc(i->second.second);
continue;
case et_nothing:
@@ -118,9 +117,9 @@ Unmerger::unmerge()
}
void
-Unmerger::unmerge_file(FSEntry & f, const std::tr1::shared_ptr<ExtraInfo> & ei) const
+Unmerger::unmerge_file(const std::tr1::shared_ptr<const ContentsEntry> & e) const
{
- FSEntry f_real(_imp->options.root() / f);
+ FSEntry f_real(_imp->options.root() / e->location_key()->value());
HookResult hr(_imp->options.environment()->perform_hook(extend_hook(
Hook("unmerger_unlink_file_override")
@@ -128,25 +127,25 @@ Unmerger::unmerge_file(FSEntry & f, const std::tr1::shared_ptr<ExtraInfo> & ei)
.grab_output(Hook::AllowedOutputValues()("skip")("force")))));
if (hr.max_exit_status() != 0)
- throw UnmergerError("Unmerge of '" + stringify(f) + "' aborted by hook");
+ throw UnmergerError("Unmerge of '" + stringify(e->location_key()->value()) + "' aborted by hook");
else if (hr.output() == "skip")
- display("--- [skip ] " + stringify(f));
+ display("--- [skip ] " + stringify(e->location_key()->value()));
else if (hr.output() == "force")
{
- display("<<< [force] " + stringify(f));
- unlink_file(f_real, ei);
+ display("<<< [force] " + stringify(e->location_key()->value()));
+ unlink_file(f_real, e);
}
- else if (check_file(f, ei))
+ else if (check_file(e))
{
- display("<<< " + stringify(f));
- unlink_file(f_real, ei);
+ display("<<< " + stringify(e->location_key()->value()));
+ unlink_file(f_real, e);
}
}
void
-Unmerger::unmerge_sym(FSEntry & f, const std::tr1::shared_ptr<ExtraInfo> & ei) const
+Unmerger::unmerge_sym(const std::tr1::shared_ptr<const ContentsEntry> & e) const
{
- FSEntry f_real(_imp->options.root() / f);
+ FSEntry f_real(_imp->options.root() / e->location_key()->value());
HookResult hr(_imp->options.environment()->perform_hook(extend_hook(
Hook("unmerger_unlink_sym_override")
@@ -154,25 +153,25 @@ Unmerger::unmerge_sym(FSEntry & f, const std::tr1::shared_ptr<ExtraInfo> & ei) c
.grab_output(Hook::AllowedOutputValues()("skip")("force")))));
if (hr.max_exit_status() != 0)
- throw UnmergerError("Unmerge of '" + stringify(f) + "' aborted by hook");
+ throw UnmergerError("Unmerge of '" + stringify(e->location_key()->value()) + "' aborted by hook");
else if (hr.output() == "skip")
- display("--- [skip ] " + stringify(f));
+ display("--- [skip ] " + stringify(e->location_key()->value()));
else if (hr.output() == "force")
{
- display("<<< [force] " + stringify(f));
- unlink_sym(f_real, ei);
+ display("<<< [force] " + stringify(e->location_key()->value()));
+ unlink_sym(f_real, e);
}
- else if (check_sym(f, ei))
+ else if (check_sym(e))
{
- display("<<< " + stringify(f));
- unlink_sym(f_real, ei);
+ display("<<< " + stringify(e->location_key()->value()));
+ unlink_sym(f_real, e);
}
}
void
-Unmerger::unmerge_dir(FSEntry & f, const std::tr1::shared_ptr<ExtraInfo> & ei) const
+Unmerger::unmerge_dir(const std::tr1::shared_ptr<const ContentsEntry> & e) const
{
- FSEntry f_real(_imp->options.root() / f);
+ FSEntry f_real(_imp->options.root() / e->location_key()->value());
HookResult hr(_imp->options.environment()->perform_hook(extend_hook(
Hook("unmerger_unlink_dir_override")
@@ -180,20 +179,20 @@ Unmerger::unmerge_dir(FSEntry & f, const std::tr1::shared_ptr<ExtraInfo> & ei) c
.grab_output(Hook::AllowedOutputValues()("skip")))));
if (hr.max_exit_status() != 0)
- throw UnmergerError("Unmerge of '" + stringify(f) + "' aborted by hook");
+ throw UnmergerError("Unmerge of '" + stringify(e->location_key()->value()) + "' aborted by hook");
else if (hr.output() == "skip")
- display("--- [skip ] " + stringify(f));
- else if (check_dir(f, ei))
+ display("--- [skip ] " + stringify(e->location_key()->value()));
+ else if (check_dir(e))
{
- display("<<< " + stringify(f));
- unlink_dir(f_real, ei);
+ display("<<< " + stringify(e->location_key()->value()));
+ unlink_dir(f_real, e);
}
}
void
-Unmerger::unmerge_misc(FSEntry & f, const std::tr1::shared_ptr<ExtraInfo> & ei) const
+Unmerger::unmerge_misc(const std::tr1::shared_ptr<const ContentsEntry> & e) const
{
- FSEntry f_real(_imp->options.root() / f);
+ FSEntry f_real(_imp->options.root() / e->location_key()->value());
HookResult hr(_imp->options.environment()->perform_hook(extend_hook(
Hook("unmerger_unlink_misc_override")
@@ -201,28 +200,28 @@ Unmerger::unmerge_misc(FSEntry & f, const std::tr1::shared_ptr<ExtraInfo> & ei)
.grab_output(Hook::AllowedOutputValues()("skip")("force")))));
if (hr.max_exit_status() != 0)
- throw UnmergerError("Unmerge of '" + stringify(f) + "' aborted by hook");
+ throw UnmergerError("Unmerge of '" + stringify(e->location_key()->value()) + "' aborted by hook");
else if (hr.output() == "skip")
- display("--- [skip ] " + stringify(f));
+ display("--- [skip ] " + stringify(e->location_key()->value()));
else if (hr.output() == "force")
{
- display("<<< [force] " + stringify(f));
- unlink_misc(f_real, ei);
+ display("<<< [force] " + stringify(e->location_key()->value()));
+ unlink_misc(f_real, e);
}
- else if (check_misc(f, ei))
+ else if (check_misc(e))
{
- display("<<< " + stringify(f));
- unlink_misc(f_real, ei);
+ display("<<< " + stringify(e->location_key()->value()));
+ unlink_misc(f_real, e);
}
}
void
-Unmerger::unlink_file(FSEntry & f, const std::tr1::shared_ptr<ExtraInfo> &) const
+Unmerger::unlink_file(FSEntry f, const std::tr1::shared_ptr<const ContentsEntry> & e) const
{
if (0 != _imp->options.environment()->perform_hook(extend_hook(
Hook("unmerger_unlink_file_pre")
- ("UNLINK_TARGET", stringify(f)))).max_exit_status())
- throw UnmergerError("Unmerge of '" + stringify(f) + "' aborted by hook");
+ ("UNLINK_TARGET", stringify(e->location_key()->value())))).max_exit_status())
+ throw UnmergerError("Unmerge of '" + stringify(e->location_key()->value()) + "' aborted by hook");
if (f.is_regular_file())
{
@@ -238,56 +237,56 @@ Unmerger::unlink_file(FSEntry & f, const std::tr1::shared_ptr<ExtraInfo> &) cons
if (0 != _imp->options.environment()->perform_hook(extend_hook(
Hook("unmerger_unlink_file_post")
- ("UNLINK_TARGET", stringify(f)))).max_exit_status())
- throw UnmergerError("Unmerge of '" + stringify(f) + "' aborted by hook");
+ ("UNLINK_TARGET", stringify(e->location_key()->value())))).max_exit_status())
+ throw UnmergerError("Unmerge of '" + stringify(e->location_key()->value()) + "' aborted by hook");
}
void
-Unmerger::unlink_sym(FSEntry & f, const std::tr1::shared_ptr<ExtraInfo> &) const
+Unmerger::unlink_sym(FSEntry f, const std::tr1::shared_ptr<const ContentsEntry> & e) const
{
if (0 != _imp->options.environment()->perform_hook(extend_hook(
Hook("unmerger_unlink_sym_pre")
- ("UNLINK_TARGET", stringify(f)))).max_exit_status())
- throw UnmergerError("Unmerge of '" + stringify(f) + "' aborted by hook");
+ ("UNLINK_TARGET", stringify(e->location_key()->value())))).max_exit_status())
+ throw UnmergerError("Unmerge of '" + stringify(e->location_key()->value()) + "' aborted by hook");
f.unlink();
if (0 != _imp->options.environment()->perform_hook(extend_hook(
Hook("unmerger_unlink_sym_post")
- ("UNLINK_TARGET", stringify(f)))).max_exit_status())
- throw UnmergerError("Unmerge of '" + stringify(f) + "' aborted by hook");
+ ("UNLINK_TARGET", stringify(e->location_key()->value())))).max_exit_status())
+ throw UnmergerError("Unmerge of '" + stringify(e->location_key()->value()) + "' aborted by hook");
}
void
-Unmerger::unlink_dir(FSEntry & f, const std::tr1::shared_ptr<ExtraInfo> &) const
+Unmerger::unlink_dir(FSEntry f, const std::tr1::shared_ptr<const ContentsEntry> & e) const
{
if (0 != _imp->options.environment()->perform_hook(extend_hook(
Hook("unmerger_unlink_dir_pre")
- ("UNLINK_TARGET", stringify(f)))).max_exit_status())
- throw UnmergerError("Unmerge of '" + stringify(f) + "' aborted by hook");
+ ("UNLINK_TARGET", stringify(e->location_key()->value())))).max_exit_status())
+ throw UnmergerError("Unmerge of '" + stringify(e->location_key()->value()) + "' aborted by hook");
f.rmdir();
if (0 != _imp->options.environment()->perform_hook(extend_hook(
Hook("unmerger_unlink_dir_post")
- ("UNLINK_TARGET", stringify(f)))).max_exit_status())
- throw UnmergerError("Unmerge of '" + stringify(f) + "' aborted by hook");
+ ("UNLINK_TARGET", stringify(e->location_key()->value())))).max_exit_status())
+ throw UnmergerError("Unmerge of '" + stringify(e->location_key()->value()) + "' aborted by hook");
}
void
-Unmerger::unlink_misc(FSEntry & f, const std::tr1::shared_ptr<ExtraInfo> &) const
+Unmerger::unlink_misc(FSEntry f, const std::tr1::shared_ptr<const ContentsEntry> & e) const
{
if (0 != _imp->options.environment()->perform_hook(extend_hook(
Hook("unmerger_unlink_misc_pre")
- ("UNLINK_TARGET", stringify(f)))).max_exit_status())
- throw UnmergerError("Unmerge of '" + stringify(f) + "' aborted by hook");
+ ("UNLINK_TARGET", stringify(e->location_key()->value())))).max_exit_status())
+ throw UnmergerError("Unmerge of '" + stringify(e->location_key()->value()) + "' aborted by hook");
f.unlink();
if (0 != _imp->options.environment()->perform_hook(extend_hook(
Hook("unmerger_unlink_misc_post")
- ("UNLINK_TARGET", stringify(f)))).max_exit_status())
- throw UnmergerError("Unmerge of '" + stringify(f) + "' aborted by hook");
+ ("UNLINK_TARGET", stringify(e->location_key()->value())))).max_exit_status())
+ throw UnmergerError("Unmerge of '" + stringify(e->location_key()->value()) + "' aborted by hook");
}
Hook
@@ -297,3 +296,27 @@ Unmerger::extend_hook(const Hook & h) const
("ROOT", stringify(_imp->options.root()));
}
+bool
+Unmerger::check_file(const std::tr1::shared_ptr<const ContentsEntry> &) const
+{
+ return true;
+}
+
+bool
+Unmerger::check_dir(const std::tr1::shared_ptr<const ContentsEntry> &) const
+{
+ return true;
+}
+
+bool
+Unmerger::check_sym(const std::tr1::shared_ptr<const ContentsEntry> &) const
+{
+ return true;
+}
+
+bool
+Unmerger::check_misc(const std::tr1::shared_ptr<const ContentsEntry> &) const
+{
+ return true;
+}
+
diff --git a/paludis/unmerger.hh b/paludis/unmerger.hh
index 0307f6e..4053b8e 100644
--- a/paludis/unmerger.hh
+++ b/paludis/unmerger.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
* Copyright (c) 2007 Piotr Jaroszyński
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -26,6 +26,7 @@
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/named_value.hh>
#include <paludis/merger_entry_type.hh>
+#include <paludis/contents-fwd.hh>
/** \file
* Declarations for the Unmerger class, which can be used by Repository
@@ -99,24 +100,9 @@ namespace paludis
///\}
/**
- * Base class for extra information associated with a file
- * to be unmerged.
- *
- * \ingroup g_repository
- * \nosubgrouping
- */
- class PALUDIS_VISIBLE ExtraInfo
- {
- public:
- virtual ~ExtraInfo();
- };
-
- friend class Implementation<Unmerger>;
-
- /**
* Add entry to the unmerge set.
*/
- void add_unmerge_entry(const std::string &, EntryType, const std::tr1::shared_ptr<ExtraInfo> &);
+ void add_unmerge_entry(const EntryType, const std::tr1::shared_ptr<const ContentsEntry> &);
/**
* Populate the unmerge set.
@@ -131,45 +117,30 @@ namespace paludis
///\name Unmerge operations
///\{
- virtual void unmerge_file(FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const;
- virtual void unmerge_dir(FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const;
- virtual void unmerge_sym(FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const;
- virtual void unmerge_misc(FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const;
+ virtual void unmerge_file(const std::tr1::shared_ptr<const ContentsEntry> &) const;
+ virtual void unmerge_dir(const std::tr1::shared_ptr<const ContentsEntry> &) const;
+ virtual void unmerge_sym(const std::tr1::shared_ptr<const ContentsEntry> &) const;
+ virtual void unmerge_misc(const std::tr1::shared_ptr<const ContentsEntry> &) const;
///\}
///\name Check operations
///\{
- virtual bool check_file(const FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const
- {
- return true;
- }
-
- virtual bool check_dir(const FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const
- {
- return true;
- }
-
- virtual bool check_sym(const FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const
- {
- return true;
- }
-
- virtual bool check_misc(const FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const
- {
- return true;
- }
+ virtual bool check_file(const std::tr1::shared_ptr<const ContentsEntry> &) const;
+ virtual bool check_dir(const std::tr1::shared_ptr<const ContentsEntry> &) const;
+ virtual bool check_sym(const std::tr1::shared_ptr<const ContentsEntry> &) const;
+ virtual bool check_misc(const std::tr1::shared_ptr<const ContentsEntry> &) const;
///\}
///\name Unlink operations
///\{
- virtual void unlink_file(FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const;
- virtual void unlink_dir(FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const;
- virtual void unlink_sym(FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const;
- virtual void unlink_misc(FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const;
+ virtual void unlink_file(FSEntry, const std::tr1::shared_ptr<const ContentsEntry> &) const;
+ virtual void unlink_dir(FSEntry, const std::tr1::shared_ptr<const ContentsEntry> &) const;
+ virtual void unlink_sym(FSEntry, const std::tr1::shared_ptr<const ContentsEntry> &) const;
+ virtual void unlink_misc(FSEntry, const std::tr1::shared_ptr<const ContentsEntry> &) const;
///\}
diff --git a/python/contents.cc b/python/contents.cc
index f1a66f2..c04b170 100644
--- a/python/contents.cc
+++ b/python/contents.cc
@@ -18,7 +18,8 @@
*/
#include <python/paludis_python.hh>
-#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/wrapped_forward_iterator-impl.hh>
+#include <paludis/util/fs_entry.hh>
#include <paludis/contents.hh>
using namespace paludis;
@@ -55,12 +56,21 @@ void expose_contents()
"Base class for a contents entry.",
bp::no_init
)
- .add_property("name", &ContentsEntry::name,
- "[ro] string\n"
- "Our name."
+
+ .add_property("metadata", bp::range(&ContentsEntry::begin_metadata, &ContentsEntry::end_metadata),
+ "[ro] Iterable of MetadataKey\n"
+ "NEED_DOC"
)
- .def(bp::self_ns::str(bp::self))
+ .def("find_metadata", &ContentsEntry::find_metadata,
+ "find_metadata(string) -> MetadataKey\n"
+ "NEED_DOC"
+ )
+
+ .def("location_key", &ContentsEntry::location_key,
+ "The location_key, which will not be None, provides the path on the filesystem\n"
+ "of the entry. It is not modified for root."
+ )
;
/**
@@ -70,7 +80,7 @@ void expose_contents()
(
"ContentsFileEntry",
"A file contents entry.",
- bp::init<const std::string &>("__init__(name_string)")
+ bp::init<const FSEntry &>("__init__(location)")
);
/**
@@ -80,37 +90,17 @@ void expose_contents()
(
"ContentsDirEntry",
"A directory contents entry.",
- bp::init<const std::string &>("__init__(name_string)")
- );
-
- /**
- * ContentsMiscEntry
- */
- class_contents<ContentsMiscEntry>
- (
- "ContentsMiscEntry",
- "A misc contents entry.",
- bp::init<const std::string &>("__init__(name_string)")
- );
-
- /**
- * ContentsFifoEntry
- */
- class_contents<ContentsFifoEntry>
- (
- "ContentsFifoEntry",
- "A fifo contents entry.",
- bp::init<const std::string &>("__init__(name_string)")
+ bp::init<const FSEntry &>("__init__(location)")
);
/**
- * ContentsDevEntry
+ * ContentsOtherEntry
*/
- class_contents<ContentsDevEntry>
+ class_contents<ContentsOtherEntry>
(
- "ContentsDevEntry",
- "A dev contents entry.",
- bp::init<const std::string &>("__init__(name_string)")
+ "ContentsOtherEntry",
+ "An 'other' contents entry.",
+ bp::init<const FSEntry &>("__init__(location)")
);
/**
@@ -120,14 +110,12 @@ void expose_contents()
(
"ContentsSymEntry",
"A sym contents entry.",
- bp::init<const std::string &, const std::string &>("__init__(name_string, target_string)")
+ bp::init<const FSEntry &, const std::string &>("__init__(location, target_string)")
)
- .add_property("target", &ContentsSymEntry::target,
- "[ro] string\n"
- "Our target (as per readlink)."
- )
- .def(bp::self_ns::str(bp::self))
+ .def("target_key", &ContentsSymEntry::target_key,
+ "The target_key, which will not be None, holds the symlink's target (as per readlink)."
+ )
;
/**
diff --git a/python/contents_TEST.py b/python/contents_TEST.py
index 047255f..6cadb9b 100755
--- a/python/contents_TEST.py
+++ b/python/contents_TEST.py
@@ -29,63 +29,44 @@ class TestCase_Contents(unittest.TestCase):
e = ContentsFileEntry("/foo")
self.assert_(isinstance(e, ContentsEntry))
- self.assertEquals(str(e), "/foo")
- self.assertEquals(e.name, "/foo")
+ self.assertEquals(e.location_key().value(), "/foo")
def test_03_dir_entry(self):
e = ContentsDirEntry("/foo")
self.assert_(isinstance(e, ContentsEntry))
- self.assertEquals(str(e), "/foo")
- self.assertEquals(e.name, "/foo")
+ self.assertEquals(e.location_key().value(), "/foo")
- def test_04_misc_entry(self):
- e = ContentsMiscEntry("/foo")
+ def test_04_other_entry(self):
+ e = ContentsOtherEntry("/foo")
self.assert_(isinstance(e, ContentsEntry))
- self.assertEquals(str(e), "/foo")
- self.assertEquals(e.name, "/foo")
-
- def test_05_fifo_entry(self):
- e = ContentsFifoEntry("/foo")
-
- self.assert_(isinstance(e, ContentsEntry))
- self.assertEquals(str(e), "/foo")
- self.assertEquals(e.name, "/foo")
-
- def test_06_dev_entry(self):
- e = ContentsDevEntry("/foo")
-
- self.assert_(isinstance(e, ContentsEntry))
- self.assertEquals(str(e), "/foo")
- self.assertEquals(e.name, "/foo")
+ self.assertEquals(e.location_key().value(), "/foo")
def test_07_sym_entry(self):
e = ContentsSymEntry("/foo", "/blah")
self.assert_(isinstance(e, ContentsEntry))
- self.assertEquals(str(e), "/foo -> /blah")
- self.assertEquals(e.name, "/foo")
- self.assertEquals(e.target, "/blah")
+ self.assertEquals(e.location_key().value(), "/foo")
+ self.assertEquals(e.target_key().value(), "/blah")
def test_08_contents(self):
entries = []
entries.append(ContentsSymEntry("/foo", "/blah"))
entries.append(ContentsFileEntry("/foo"))
- entries.append(ContentsDevEntry("/dev/foo"))
+ entries.append(ContentsOtherEntry("/dev/foo"))
entries.append(ContentsDirEntry("/bar"))
- entries.append(ContentsFifoEntry("/baz"))
c = Contents()
for entry in entries:
c.add(entry)
for (i, entry) in enumerate(c):
- self.assertEquals(entry.name, entries[i].name)
+ self.assertEquals(entry.location_key().value(), entries[i].location_key().value())
self.assertEquals(type(entry), type(entries[i]))
if i==0:
- self.assertEquals(entry.target, entries[i].target)
- if i>4:
+ self.assertEquals(entry.target_key().value(), entries[i].target_key().value())
+ if i>3:
self.assertEquals("TOO MANY ENTRIES", "OK")
if __name__ == "__main__":
diff --git a/ruby/contents.cc b/ruby/contents.cc
index 15978c5..cd2bb15 100644
--- a/ruby/contents.cc
+++ b/ruby/contents.cc
@@ -2,6 +2,7 @@
/*
* Copyright (c) 2006, 2007 Richard Brown
+ * Copyright (c) 2009 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
@@ -32,9 +33,7 @@ namespace
static VALUE c_contents_file_entry;
static VALUE c_contents_dir_entry;
static VALUE c_contents_sym_entry;
- static VALUE c_contents_misc_entry;
- static VALUE c_contents_dev_entry;
- static VALUE c_contents_fifo_entry;
+ static VALUE c_contents_other_entry;
struct V
{
@@ -58,9 +57,9 @@ namespace
new std::tr1::shared_ptr<const ContentsEntry>(mm));
}
- void visit(const ContentsMiscEntry &)
+ void visit(const ContentsOtherEntry &)
{
- value = Data_Wrap_Struct(c_contents_misc_entry, 0, &Common<std::tr1::shared_ptr<const ContentsEntry> >::free,
+ value = Data_Wrap_Struct(c_contents_other_entry, 0, &Common<std::tr1::shared_ptr<const ContentsEntry> >::free,
new std::tr1::shared_ptr<const ContentsEntry>(mm));
}
@@ -69,18 +68,6 @@ namespace
value = Data_Wrap_Struct(c_contents_sym_entry, 0, &Common<std::tr1::shared_ptr<const ContentsEntry> >::free,
new std::tr1::shared_ptr<const ContentsEntry>(mm));
}
-
- void visit(const ContentsFifoEntry &)
- {
- value = Data_Wrap_Struct(c_contents_fifo_entry, 0, &Common<std::tr1::shared_ptr<const ContentsEntry> >::free,
- new std::tr1::shared_ptr<const ContentsEntry>(mm));
- }
-
- void visit(const ContentsDevEntry &)
- {
- value = Data_Wrap_Struct(c_contents_dev_entry, 0, &Common<std::tr1::shared_ptr<const ContentsEntry> >::free,
- new std::tr1::shared_ptr<const ContentsEntry>(mm));
- }
};
VALUE
@@ -186,7 +173,8 @@ namespace
{
if (1 == argc)
{
- ptr = new std::tr1::shared_ptr<const ContentsEntry>(new A_(StringValuePtr(argv[0])));
+ ptr = new std::tr1::shared_ptr<const ContentsEntry>(new A_(
+ FSEntry(StringValuePtr(argv[0]))));
}
else
{
@@ -211,7 +199,8 @@ namespace
{
if (2 == argc)
{
- ptr = new std::tr1::shared_ptr<const ContentsEntry>(new ContentsSymEntry(StringValuePtr(argv[0]), StringValuePtr(argv[1])));
+ ptr = new std::tr1::shared_ptr<const ContentsEntry>(new ContentsSymEntry(
+ FSEntry(StringValuePtr(argv[0])), StringValuePtr(argv[1])));
}
else
{
@@ -229,26 +218,51 @@ namespace
}
/*
- * Document-method: name
+ * Document-method: location_key
*
- * Returns our name
+ * Returns our location
*/
+ static VALUE
+ contents_entry_location_key(VALUE self)
+ {
+ std::tr1::shared_ptr<const ContentsEntry> * ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<const ContentsEntry>, ptr);
+ return metadata_key_to_value((*ptr)->location_key());
+ }
+
/*
- * Document-method: target
+ * Document-method: target_key
*
- * Returns the target
+ * Returns our target (as per readlink)
*/
- template <typename T_, std::string (T_::* m_) () const>
- struct ContentsThings
+ static VALUE
+ contents_sym_entry_target_key(VALUE self)
{
- static VALUE
- fetch(VALUE self)
+ std::tr1::shared_ptr<const ContentsEntry> * ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<const ContentsEntry>, ptr);
+ return metadata_key_to_value((std::tr1::static_pointer_cast<const ContentsSymEntry>(*ptr))->target_key());
+ }
+
+ /*
+ * call-seq:
+ * each_metadata {|key| block } -> Nil
+ *
+ * Our metadata.
+ */
+ VALUE
+ contents_entry_each_metadata(VALUE self)
+ {
+ std::tr1::shared_ptr<const ContentsEntry> * self_ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<const ContentsEntry>, self_ptr);
+ for (ContentsEntry::MetadataConstIterator it((*self_ptr)->begin_metadata()),
+ it_end((*self_ptr)->end_metadata()); it_end != it; ++it)
{
- std::tr1::shared_ptr<const ContentsEntry> * ptr;
- Data_Get_Struct(self, std::tr1::shared_ptr<const ContentsEntry>, ptr);
- return rb_str_new2((((*std::tr1::static_pointer_cast<const T_>(*ptr)).*m_)()).c_str());
+ VALUE val(metadata_key_to_value(*it));
+ if (Qnil != val)
+ rb_yield(val);
}
- };
+ return Qnil;
+ }
void do_register_contents()
{
@@ -272,9 +286,9 @@ namespace
*/
c_contents_entry = rb_define_class_under(paludis_module(), "ContentsEntry", rb_cObject);
rb_funcall(c_contents_entry, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_define_method(c_contents_entry, "name", RUBY_FUNC_CAST((&ContentsThings<ContentsEntry,&ContentsEntry::name>::fetch)), 0);
+ rb_define_method(c_contents_entry, "location_key", RUBY_FUNC_CAST(&contents_entry_location_key), 0);
rb_define_method(c_contents_entry, "initialize", RUBY_FUNC_CAST(&contents_entry_init),-1);
- rb_define_method(c_contents_entry, "to_s", RUBY_FUNC_CAST(&Common<std::tr1::shared_ptr<const ContentsEntry> >::to_s_via_ptr), 0);
+ rb_define_method(c_contents_entry, "each_metadata", RUBY_FUNC_CAST(&contents_entry_each_metadata), 0);
/*
* Document-class: Paludis::ContentsFileEntry
@@ -293,39 +307,22 @@ namespace
rb_define_singleton_method(c_contents_dir_entry, "new", RUBY_FUNC_CAST((&ContentsNew<ContentsDirEntry>::contents_entry_new)), -1);
/*
- * Document-class: Paludis::ContentsMiscEntry
+ * Document-class: Paludis::ContentsOtherEntry
*
- * A miscellaneous ContentsEntry
+ * An 'other' ContentsEntry
*/
- c_contents_misc_entry = rb_define_class_under(paludis_module(), "ContentsMiscEntry", c_contents_entry);
- rb_define_singleton_method(c_contents_misc_entry, "new", RUBY_FUNC_CAST((&ContentsNew<ContentsMiscEntry>::contents_entry_new)), -1);
+ c_contents_other_entry = rb_define_class_under(paludis_module(), "ContentsOtherEntry", c_contents_entry);
+ rb_define_singleton_method(c_contents_other_entry, "new", RUBY_FUNC_CAST((&ContentsNew<ContentsOtherEntry>::contents_entry_new)), -1);
/*
- * Document-class: Paludis::ContentsFifoEntry
- *
- * A fifo ContentsEntry
- */
- c_contents_fifo_entry = rb_define_class_under(paludis_module(), "ContentsFifoEntry", c_contents_entry);
- rb_define_singleton_method(c_contents_fifo_entry, "new", RUBY_FUNC_CAST((&ContentsNew<ContentsFifoEntry>::contents_entry_new)), -1);
-
-
- /*
- * Document-class: Paludis::ContentsDevEntry
- *
- * A device ContentsEntry
- */
- c_contents_dev_entry = rb_define_class_under(paludis_module(), "ContentsDevEntry", c_contents_entry);
- rb_define_singleton_method(c_contents_dev_entry, "new", RUBY_FUNC_CAST((&ContentsNew<ContentsDevEntry>::contents_entry_new)), -1);
-
- /*
* Document-class: Paludis::ContentsSymEntry
*
* A symlink ContentsEntry
*/
c_contents_sym_entry = rb_define_class_under(paludis_module(), "ContentsSymEntry", c_contents_entry);
rb_define_singleton_method(c_contents_sym_entry, "new", RUBY_FUNC_CAST(&contents_sym_entry_new), -1);
- rb_define_method(c_contents_sym_entry, "target", RUBY_FUNC_CAST((&ContentsThings<ContentsSymEntry,&ContentsSymEntry::target>::fetch)), 0);
+ rb_define_method(c_contents_sym_entry, "target_key", RUBY_FUNC_CAST(&contents_sym_entry_target_key), 0);
}
}
diff --git a/ruby/contents_TEST.rb b/ruby/contents_TEST.rb
index 2c903fa..d53b5f9 100644
--- a/ruby/contents_TEST.rb
+++ b/ruby/contents_TEST.rb
@@ -54,17 +54,12 @@ module Paludis
def test_respond_to
ce = get_ce
- assert_respond_to ce, :name
+ assert_respond_to ce, :location_key
end
def test_name
ce = get_ce
- assert_equal 'test', ce.name
- end
-
- def test_to_s
- ce = get_ce
- assert_equal 'test', ce.to_s
+ assert_equal 'test', ce.location_key.value
end
end
@@ -93,23 +88,18 @@ module Paludis
def test_respond_to
ce = get_ce
- assert_respond_to ce, :name
+ assert_respond_to ce, :location_key
end
def test_name
ce = get_ce
- assert_equal 'test', ce.name
- end
-
- def test_to_s
- ce = get_ce
- assert_equal 'test', ce.to_s
+ assert_equal 'test', ce.location_key.value
end
end
- class TestCase_ContentsMiscEntry < Test::Unit::TestCase
+ class TestCase_ContentsOtherEntry < Test::Unit::TestCase
def get_ce
- ContentsMiscEntry.new('test')
+ ContentsOtherEntry.new('test')
end
def test_create
@@ -118,31 +108,26 @@ module Paludis
def test_create_error
assert_raise ArgumentError do
- ContentsMiscEntry.new
+ ContentsOtherEntry.new
end
assert_raise ArgumentError do
- ContentsMiscEntry.new('a','b')
+ ContentsOtherEntry.new('a','b')
end
assert_raise TypeError do
- ContentsMiscEntry.new(1)
+ ContentsOtherEntry.new(1)
end
end
def test_respond_to
ce = get_ce
- assert_respond_to ce, :name
+ assert_respond_to ce, :location_key
end
def test_name
ce = get_ce
- assert_equal 'test', ce.name
- end
-
- def test_to_s
- ce = get_ce
- assert_equal 'test', ce.to_s
+ assert_equal 'test', ce.location_key.value
end
end
@@ -179,23 +164,18 @@ module Paludis
def test_respond_to
ce = get_ce
- assert_respond_to ce, :name
- assert_respond_to ce, :target
+ assert_respond_to ce, :location_key
+ assert_respond_to ce, :target_key
end
def test_name
ce = get_ce
- assert_equal 'test_name', ce.name
+ assert_equal 'test_name', ce.location_key.value
end
def test_target
ce = get_ce
- assert_equal 'test_target', ce.target
- end
-
- def test_to_s
- ce = get_ce
- assert_equal "test_name -> test_target", ce.to_s
+ assert_equal 'test_target', ce.target_key.value
end
end
class TestCase_Contents < Test::Unit::TestCase
@@ -236,13 +216,13 @@ module Paludis
c.add(cfe)
assert_equal 1, c.entries.length
- assert_equal cfe.to_s, c.entries.first.to_s
+ assert_equal cfe.location_key.value, c.entries.first.location_key.value
c.add(cse)
assert_equal 2, c.entries.length
- assert_equal cfe.to_s, c.entries.first.to_s
- assert_equal cse.to_s, c.entries.last.to_s
+ assert_equal cfe.location_key.value, c.entries.first.location_key.value
+ assert_equal cse.location_key.value, c.entries.last.location_key.value
end
end
diff --git a/ruby/package_id.cc b/ruby/package_id.cc
index 010d40b..74bd3da 100644
--- a/ruby/package_id.cc
+++ b/ruby/package_id.cc
@@ -165,7 +165,7 @@ namespace
if (Qnil != val)
rb_yield(val);
}
- return Qnil;
+ return Qnil;
}
/*
diff --git a/ruby/repository_TEST.rb b/ruby/repository_TEST.rb
index 848052d..e0e5e5d 100644
--- a/ruby/repository_TEST.rb
+++ b/ruby/repository_TEST.rb
@@ -2,7 +2,7 @@
# vim: set sw=4 sts=4 et tw=80 :
#
-# Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+# Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
# Copyright (c) 2006, 2007, 2008 Richard Brown
#
# This file is part of the Paludis package manager. Paludis is free software;
@@ -259,23 +259,20 @@ module Paludis
def test_first_entry
assert_kind_of ContentsEntry, entries[0]
assert_kind_of ContentsDirEntry, entries[0]
- assert_equal '//test', entries[0].to_s
- assert_equal '//test', entries[0].name
+ assert_equal '/test', entries[0].location_key.value
end
def test_second_entry
assert_kind_of ContentsEntry, entries[1]
assert_kind_of ContentsFileEntry, entries[1]
- assert_equal '/test/test_file', entries[1].to_s
- assert_equal '/test/test_file', entries[1].name
+ assert_equal '/test/test_file', entries[1].location_key.value
end
def test_third_entry
assert_kind_of ContentsEntry, entries[2]
assert_kind_of ContentsSymEntry, entries[2]
- assert_equal '/test/test_link -> /test/test_file', entries[2].to_s
- assert_equal '/test/test_file', entries[2].target
- assert_equal '/test/test_link', entries[2].name
+ assert_equal '/test/test_file', entries[2].target_key.value
+ assert_equal '/test/test_link', entries[2].location_key.value
end
end
diff --git a/src/clients/cave/cmd_print_owners.cc b/src/clients/cave/cmd_print_owners.cc
index ad9e031..9d0af4f 100644
--- a/src/clients/cave/cmd_print_owners.cc
+++ b/src/clients/cave/cmd_print_owners.cc
@@ -87,17 +87,17 @@ namespace
bool handle_full(const std::string & q, const std::tr1::shared_ptr<const ContentsEntry> & e)
{
- return q == e->name();
+ return q == stringify(e->location_key()->value());
}
bool handle_basename(const std::string & q, const std::tr1::shared_ptr<const ContentsEntry> & e)
{
- return q == FSEntry(e->name()).basename();
+ return q == e->location_key()->value().basename();
}
bool handle_partial(const std::string & q, const std::tr1::shared_ptr<const ContentsEntry> & e)
{
- return std::string::npos != e->name().find(q);
+ return std::string::npos != stringify(e->location_key()->value()).find(q);
}
}
diff --git a/src/clients/cave/cmd_show.cc b/src/clients/cave/cmd_show.cc
index 86b7ed8..6e7d3fb 100644
--- a/src/clients/cave/cmd_show.cc
+++ b/src/clients/cave/cmd_show.cc
@@ -213,39 +213,27 @@ namespace
void visit(const ContentsFileEntry & e)
{
- s << format_general_rhvib(f::show_contents_file(), e.name(), FSEntry(e.name()).basename(),
+ s << format_general_rhvib(f::show_contents_file(), stringify(e.location_key()->value()), e.location_key()->value().basename(),
"", indent, indent);
}
void visit(const ContentsDirEntry & e)
{
- s << format_general_rhvib(f::show_contents_dir(), e.name(), FSEntry(e.name()).basename(),
+ s << format_general_rhvib(f::show_contents_dir(), stringify(e.location_key()->value()), e.location_key()->value().basename(),
"", indent, indent);
}
- void visit(const ContentsMiscEntry & e)
- {
- s << format_general_rhvib(f::show_contents_misc(), e.name(), FSEntry(e.name()).basename(),
- "", indent, indent);
- }
-
- void visit(const ContentsDevEntry & e)
+ void visit(const ContentsSymEntry & e)
{
- s << format_general_rhvib(f::show_contents_dev(), e.name(), FSEntry(e.name()).basename(),
- "", indent, indent);
+ s << format_general_rhvib(f::show_contents_sym(), stringify(e.location_key()->value()), e.location_key()->value().basename(),
+ e.target_key()->value(), indent, indent);
}
- void visit(const ContentsFifoEntry & e)
+ void visit(const ContentsOtherEntry & e)
{
- s << format_general_rhvib(f::show_contents_fifo(), e.name(), FSEntry(e.name()).basename(),
+ s << format_general_rhvib(f::show_contents_other(), stringify(e.location_key()->value()), e.location_key()->value().basename(),
"", indent, indent);
}
-
- void visit(const ContentsSymEntry & e)
- {
- s << format_general_rhvib(f::show_contents_sym(), e.name(), FSEntry(e.name()).basename(),
- e.target(), indent, indent);
- }
};
struct InfoDisplayer
diff --git a/src/clients/cave/format_plain_contents_entry.cc b/src/clients/cave/format_plain_contents_entry.cc
index 3625c86..274bf15 100644
--- a/src/clients/cave/format_plain_contents_entry.cc
+++ b/src/clients/cave/format_plain_contents_entry.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 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
@@ -24,6 +24,7 @@
#include <paludis/util/fs_entry.hh>
#include <paludis/util/stringify.hh>
#include <paludis/contents.hh>
+#include <paludis/metadata_key.hh>
#include <sstream>
using namespace paludis;
@@ -47,18 +48,10 @@ namespace
void visit(const ContentsSymEntry & c)
{
- target = c.target();
+ target = c.target_key()->value();
}
- void visit(const ContentsMiscEntry &)
- {
- }
-
- void visit(const ContentsDevEntry &)
- {
- }
-
- void visit(const ContentsFifoEntry &)
+ void visit(const ContentsOtherEntry &)
{
}
};
@@ -82,12 +75,12 @@ paludis::cave::format_plain_contents_entry(
c->accept(v);
std::tr1::shared_ptr<Map<char, std::string> > m(new Map<char, std::string>);
- m->insert('n', c->name());
- m->insert('d', stringify(FSEntry(c->name()).dirname()));
- m->insert('b', stringify(FSEntry(c->name()).basename()));
+ m->insert('n', stringify(c->location_key()->value()));
+ m->insert('d', stringify(c->location_key()->value().dirname()));
+ m->insert('b', stringify(c->location_key()->value().basename()));
m->insert('t', v.target);
m->insert('a', v.target.empty() ? "" : " -> ");
- m->insert('i', std::string(number_of_parents(FSEntry(c->name())), ' '));
+ m->insert('i', std::string(number_of_parents(c->location_key()->value()), ' '));
m->insert('/', v.slash);
return format_string(f, m);
diff --git a/src/clients/cave/formats.cc b/src/clients/cave/formats.cc
index 919f03a..62f48a2 100644
--- a/src/clients/cave/formats.cc
+++ b/src/clients/cave/formats.cc
@@ -359,13 +359,7 @@ paludis::cave::f::show_contents_file()
}
const std::string
-paludis::cave::f::show_contents_dev()
-{
- return "%{if b}%{column 30}%{endif}%r%{if b}\\n%{else} %{endif}";
-}
-
-const std::string
-paludis::cave::f::show_contents_misc()
+paludis::cave::f::show_contents_other()
{
return "%{if b}%{column 30}%{endif}%r%{if b}\\n%{else} %{endif}";
}
@@ -377,12 +371,6 @@ paludis::cave::f::show_contents_dir()
}
const std::string
-paludis::cave::f::show_contents_fifo()
-{
- return "%{if b}%{column 30}%{endif}%r%{if b}\\n%{else} %{endif}";
-}
-
-const std::string
paludis::cave::f::show_contents_sym()
{
return "%{if b}%{column 30}%{endif}%r -> %v%{if b}\\n%{else} %{endif}";
diff --git a/src/clients/cave/formats.hh b/src/clients/cave/formats.hh
index ef96523..f3869f1 100644
--- a/src/clients/cave/formats.hh
+++ b/src/clients/cave/formats.hh
@@ -71,10 +71,8 @@ namespace paludis
const std::string show_contents_file();
const std::string show_contents_dir();
- const std::string show_contents_misc();
- const std::string show_contents_dev();
- const std::string show_contents_fifo();
const std::string show_contents_sym();
+ const std::string show_contents_other();
const std::string show_choice_forced_enabled();
const std::string show_choice_enabled();
diff --git a/src/clients/paludis/do_contents.cc b/src/clients/paludis/do_contents.cc
index 237f543..b6e7ab8 100644
--- a/src/clients/paludis/do_contents.cc
+++ b/src/clients/paludis/do_contents.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009 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
@@ -36,32 +36,22 @@ namespace
{
void visit(const ContentsFileEntry & e)
{
- cout << " " << colour(cl_file, e.name()) << endl;
+ cout << " " << colour(cl_file, stringify(e.location_key()->value())) << endl;
}
void visit(const ContentsDirEntry & e)
{
- cout << " " << colour(cl_dir, e.name()) << endl;
+ cout << " " << colour(cl_dir, stringify(e.location_key()->value()) )<< endl;
}
void visit(const ContentsSymEntry & e)
{
- cout << " " << colour(cl_sym, e.name()) << " -> " << e.target() << endl;
+ cout << " " << colour(cl_sym, stringify(e.location_key()->value())) << " -> " << e.target_key()->value() << endl;
}
- void visit(const ContentsMiscEntry & e)
+ void visit(const ContentsOtherEntry & e)
{
- cout << " " << colour(cl_misc, e.name()) << endl;
- }
-
- void visit(const ContentsFifoEntry & e)
- {
- cout << " " << colour(cl_fifo, e.name()) << endl;
- }
-
- void visit(const ContentsDevEntry & e)
- {
- cout << " " << colour(cl_dev, e.name()) << endl;
+ cout << " " << colour(cl_other, stringify(e.location_key()->value())) << endl;
}
};
}
diff --git a/src/clients/paludis/do_executables.cc b/src/clients/paludis/do_executables.cc
index e3c2bf3..9ecafe1 100644
--- a/src/clients/paludis/do_executables.cc
+++ b/src/clients/paludis/do_executables.cc
@@ -62,8 +62,8 @@ namespace
void visit(const ContentsFileEntry & e)
{
- if (is_file_in_path(FSEntry(e.name())))
- cout << " " << colour(cl_file, e.name()) << endl;
+ if (is_file_in_path(e.location_key()->value()))
+ cout << " " << colour(cl_file, e.location_key()->value()) << endl;
}
void visit(const ContentsDirEntry &)
@@ -72,22 +72,14 @@ namespace
void visit(const ContentsSymEntry & e)
{
- FSEntry sym(e.name());
+ FSEntry sym(e.location_key()->value());
FSEntry real(sym.realpath_if_exists());
if (sym != real)
if (is_file_in_path(sym))
- cout << " " << colour(cl_sym, e.name()) << endl;
+ cout << " " << colour(cl_sym, e.location_key()->value()) << endl;
}
- void visit(const ContentsMiscEntry &)
- {
- }
-
- void visit(const ContentsFifoEntry &)
- {
- }
-
- void visit(const ContentsDevEntry &)
+ void visit(const ContentsOtherEntry &)
{
}
};
diff --git a/src/clients/paludis/owner.cc b/src/clients/paludis/owner.cc
index ba39a3a..5b63de5 100644
--- a/src/clients/paludis/owner.cc
+++ b/src/clients/paludis/owner.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009 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
@@ -61,32 +61,22 @@ namespace
void visit(const ContentsFileEntry & e)
{
- handle(e.name());
+ handle(stringify(e.location_key()->value()));
}
void visit(const ContentsDirEntry & e)
{
- handle(e.name());
+ handle(stringify(e.location_key()->value()));
}
void visit(const ContentsSymEntry & e)
{
- handle(e.name());
+ handle(stringify(e.location_key()->value()));
}
- void visit(const ContentsMiscEntry & e)
+ void visit(const ContentsOtherEntry & e)
{
- handle(e.name());
- }
-
- void visit(const ContentsFifoEntry & e)
- {
- handle(e.name());
- }
-
- void visit(const ContentsDevEntry & e)
- {
- handle(e.name());
+ handle(stringify(e.location_key()->value()));
}
};
}
diff --git a/src/clients/reconcilio/broken_linkage_finder/broken_linkage_finder.cc b/src/clients/reconcilio/broken_linkage_finder/broken_linkage_finder.cc
index 2d8ff2f..5b5b0e7 100644
--- a/src/clients/reconcilio/broken_linkage_finder/broken_linkage_finder.cc
+++ b/src/clients/reconcilio/broken_linkage_finder/broken_linkage_finder.cc
@@ -349,7 +349,7 @@ Implementation<BrokenLinkageFinder>::gather_package(const std::tr1::shared_ptr<c
if (0 != file)
{
Lock l(mutex);
- files.insert(std::make_pair(file->name(), pkg));
+ files.insert(std::make_pair(stringify(file->location_key()->value()), pkg));
}
}
}
diff --git a/src/output/colour.hh b/src/output/colour.hh
index ac3a3a7..ffd74f6 100644
--- a/src/output/colour.hh
+++ b/src/output/colour.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009 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
@@ -76,9 +76,7 @@ enum Colour
cl_file = cl_none,
cl_dir = cl_blue,
cl_sym = cl_pink,
- cl_misc = cl_red,
- cl_fifo = cl_red,
- cl_dev = cl_red
+ cl_other = cl_red
};
bool PALUDIS_VISIBLE use_colour();