aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-02-20 13:58:38 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-02-20 13:58:38 +0000
commit690aca7a8de4bf9b682be59abbed08a8d12a21d8 (patch)
tree74c37c1b81064c41dfff690cbaf53573d35bad77
parentabc0d8ffc4ec1a5ecb75702c4b758027b059d657 (diff)
downloadpaludis-690aca7a8de4bf9b682be59abbed08a8d12a21d8.tar.gz
paludis-690aca7a8de4bf9b682be59abbed08a8d12a21d8.tar.xz
More sr -> kc work
-rw-r--r--paludis/files.m44
-rw-r--r--paludis/merger-fwd.hh21
-rw-r--r--paludis/merger.cc135
-rw-r--r--paludis/merger.hh6
-rw-r--r--paludis/merger.sr28
-rw-r--r--paludis/merger_TEST.cc24
-rw-r--r--paludis/ndbam_merger.cc12
-rw-r--r--paludis/ndbam_unmerger.cc6
-rw-r--r--paludis/repositories/e/Makefile.am26
-rw-r--r--paludis/repositories/e/vdb_merger.cc50
-rw-r--r--paludis/repositories/e/vdb_merger.hh22
-rw-r--r--paludis/repositories/e/vdb_merger.sr33
-rw-r--r--paludis/repositories/e/vdb_merger_TEST.cc18
-rw-r--r--paludis/repositories/e/vdb_repository.cc32
-rw-r--r--paludis/repositories/e/vdb_unmerger.cc63
-rw-r--r--paludis/repositories/e/vdb_unmerger.hh21
-rw-r--r--paludis/repositories/e/vdb_unmerger.sr30
-rw-r--r--paludis/repositories/e/vdb_unmerger_TEST.cc14
-rw-r--r--paludis/unmerger.cc50
-rw-r--r--paludis/unmerger.hh17
-rw-r--r--paludis/unmerger.sr23
-rw-r--r--paludis/util/kc.hh2
-rw-r--r--paludis/util/keys.hh9
23 files changed, 287 insertions, 359 deletions
diff --git a/paludis/files.m4 b/paludis/files.m4
index 93eec59..885b2dd 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -36,7 +36,7 @@ add(`install_task', `hh', `cc', `se')
add(`literal_metadata_key', `hh', `cc')
add(`mask', `hh', `cc', `fwd')
add(`match_package', `hh', `cc')
-add(`merger', `hh', `cc', `fwd', `se', `sr', `test', `testscript')
+add(`merger', `hh', `cc', `fwd', `se', `test', `testscript')
add(`merger_entry_type', `hh', `cc', `se')
add(`metadata_key', `hh', `cc', `se', `fwd')
add(`metadata_key_holder', `hh', `cc', `fwd')
@@ -67,7 +67,7 @@ add(`sync_task', `hh', `cc')
add(`tasks_exceptions', `hh', `cc')
add(`uninstall_list', `hh', `cc', `se', `sr', `test')
add(`uninstall_task', `hh', `cc')
-add(`unmerger', `hh', `cc', `sr')
+add(`unmerger', `hh', `cc')
add(`version_operator', `hh', `cc', `fwd', `se', `test')
add(`version_requirements', `hh', `cc', `fwd', `sr')
add(`version_spec', `hh', `cc', `fwd', `test')
diff --git a/paludis/merger-fwd.hh b/paludis/merger-fwd.hh
index 3b8a5ff..9ef7709 100644
--- a/paludis/merger-fwd.hh
+++ b/paludis/merger-fwd.hh
@@ -23,6 +23,10 @@
#include <iosfwd>
#include <paludis/util/attributes.hh>
#include <paludis/util/options-fwd.hh>
+#include <paludis/util/kc-fwd.hh>
+#include <paludis/util/keys.hh>
+#include <paludis/util/fs_entry-fwd.hh>
+#include <paludis/environment-fwd.hh>
/** \file
* Forward declarations for paludis/merger.hh .
@@ -50,7 +54,22 @@ namespace paludis
*/
typedef Options<MergeStatusFlag> MergeStatusFlags;
- class MergerParams;
+ /**
+ * Parameters for a basic Merger.
+ *
+ * \see Merger
+ * \ingroup g_repository
+ * \nosubgrouping
+ * \since 0.26
+ */
+ typedef kc::KeyedClass<
+ kc::Field<k::environment, Environment *>,
+ kc::Field<k::image, FSEntry>,
+ kc::Field<k::root, FSEntry>,
+ kc::Field<k::no_chown, bool>,
+ kc::Field<k::options, MergerOptions>
+ > MergerParams;
+
class MergerError;
class Merger;
}
diff --git a/paludis/merger.cc b/paludis/merger.cc
index ec628ca..31302a1 100644
--- a/paludis/merger.cc
+++ b/paludis/merger.cc
@@ -36,7 +36,6 @@
using namespace paludis;
-#include <paludis/merger-sr.cc>
#include <paludis/merger-se.cc>
MergerError::MergerError(const std::string & s) throw () :
@@ -58,21 +57,21 @@ Merger::~Merger()
bool
Merger::check()
{
- Context context("When checking merge from '" + stringify(_params.image) + "' to '"
- + stringify(_params.root) + "':");
+ Context context("When checking merge from '" + stringify(_params[k::image()]) + "' to '"
+ + stringify(_params[k::root()]) + "':");
- if (0 != _params.environment->perform_hook(extend_hook(
+ if (0 != _params[k::environment()]->perform_hook(extend_hook(
Hook("merger_check_pre")
- ("INSTALL_SOURCE", stringify(_params.image))
- ("INSTALL_DESTINATION", stringify(_params.root)))).max_exit_status)
+ ("INSTALL_SOURCE", stringify(_params[k::image()]))
+ ("INSTALL_DESTINATION", stringify(_params[k::root()])))).max_exit_status)
make_check_fail();
- do_dir_recursive(true, _params.image, _params.root);
+ do_dir_recursive(true, _params[k::image()], _params[k::root()]);
- if (0 != _params.environment->perform_hook(extend_hook(
+ if (0 != _params[k::environment()]->perform_hook(extend_hook(
Hook("merger_check_post")
- ("INSTALL_SOURCE", stringify(_params.image))
- ("INSTALL_DESTINATION", stringify(_params.root)))).max_exit_status)
+ ("INSTALL_SOURCE", stringify(_params[k::image()]))
+ ("INSTALL_DESTINATION", stringify(_params[k::root()])))).max_exit_status)
make_check_fail();
return _result;
@@ -87,8 +86,8 @@ Merger::make_check_fail()
void
Merger::merge()
{
- Context context("When performing merge from '" + stringify(_params.image) + "' to '"
- + stringify(_params.root) + "':");
+ Context context("When performing merge from '" + stringify(_params[k::image()]) + "' to '"
+ + stringify(_params[k::root()]) + "':");
struct SaveUmask
{
@@ -105,21 +104,21 @@ Merger::merge()
}
} old_umask(::umask(0000));
- if (0 != _params.environment->perform_hook(extend_hook(
+ if (0 != _params[k::environment()]->perform_hook(extend_hook(
Hook("merger_install_pre")
- ("INSTALL_SOURCE", stringify(_params.image))
- ("INSTALL_DESTINATION", stringify(_params.root)))).max_exit_status)
+ ("INSTALL_SOURCE", stringify(_params[k::image()]))
+ ("INSTALL_DESTINATION", stringify(_params[k::root()])))).max_exit_status)
Log::get_instance()->message(ll_warning, lc_context,
- "Merge of '" + stringify(_params.image) + "' to '" + stringify(_params.root) + "' pre hooks returned non-zero");
+ "Merge of '" + stringify(_params[k::image()]) + "' to '" + stringify(_params[k::root()]) + "' pre hooks returned non-zero");
- do_dir_recursive(false, _params.image, _params.root.realpath());
+ do_dir_recursive(false, _params[k::image()], _params[k::root()].realpath());
- if (0 != _params.environment->perform_hook(extend_hook(
+ if (0 != _params[k::environment()]->perform_hook(extend_hook(
Hook("merger_install_post")
- ("INSTALL_SOURCE", stringify(_params.image))
- ("INSTALL_DESTINATION", stringify(_params.root)))).max_exit_status)
+ ("INSTALL_SOURCE", stringify(_params[k::image()]))
+ ("INSTALL_DESTINATION", stringify(_params[k::root()])))).max_exit_status)
Log::get_instance()->message(ll_warning, lc_context,
- "Merge of '" + stringify(_params.image) + "' to '" + stringify(_params.root) + "' post hooks returned non-zero");
+ "Merge of '" + stringify(_params[k::image()]) + "' to '" + stringify(_params[k::root()]) + "' post hooks returned non-zero");
}
EntryType
@@ -157,9 +156,9 @@ Merger::do_dir_recursive(bool is_check, const FSEntry & src, const FSEntry & dst
DirIterator d(src, DirIteratorOptions() + dio_include_dotfiles + dio_inode_sort), d_end;
- if (is_check && d == d_end && dst != _params.root.realpath())
+ if (is_check && d == d_end && dst != _params[k::root()].realpath())
{
- if (_params.options[mo_allow_empty_dirs])
+ if (_params[k::options()][mo_allow_empty_dirs])
Log::get_instance()->message(ll_warning, lc_context) << "Installing empty directory '"
<< stringify(dst) << "'";
else
@@ -214,7 +213,7 @@ Merger::on_file(bool is_check, const FSEntry & src, const FSEntry & dst)
EntryType m(entry_type(dst / src.basename()));
if (is_check &&
- 0 != _params.environment->perform_hook(extend_hook(
+ 0 != _params[k::environment()]->perform_hook(extend_hook(
Hook("merger_check_file_pre")
("INSTALL_SOURCE", stringify(src))
("INSTALL_DESTINATION", stringify(dst / src.basename())))).max_exit_status)
@@ -222,7 +221,7 @@ Merger::on_file(bool is_check, const FSEntry & src, const FSEntry & dst)
if (! is_check)
{
- HookResult hr(_params.environment->perform_hook(extend_hook(
+ HookResult hr(_params[k::environment()]->perform_hook(extend_hook(
Hook("merger_install_file_override")
("INSTALL_SOURCE", stringify(src))
("INSTALL_DESTINATION", stringify(dst / src.basename()))
@@ -233,7 +232,7 @@ Merger::on_file(bool is_check, const FSEntry & src, const FSEntry & dst)
<< stringify(src) << "' to '" << stringify(dst) << "' skip hooks returned non-zero";
else if (hr.output == "skip")
{
- std::string tidy(stringify((dst / src.basename()).strip_leading(_params.root.realpath())));
+ std::string tidy(stringify((dst / src.basename()).strip_leading(_params[k::root()].realpath())));
display_override("--- [skp] " + tidy);
return;
}
@@ -271,7 +270,7 @@ Merger::on_file(bool is_check, const FSEntry & src, const FSEntry & dst)
} while (false);
if (is_check &&
- 0 != _params.environment->perform_hook(extend_hook(
+ 0 != _params[k::environment()]->perform_hook(extend_hook(
Hook("merger_check_file_post")
("INSTALL_SOURCE", stringify(src))
("INSTALL_DESTINATION", stringify(dst / src.basename())))).max_exit_status)
@@ -286,7 +285,7 @@ Merger::on_dir(bool is_check, const FSEntry & src, const FSEntry & dst)
EntryType m(entry_type(dst / src.basename()));
if (is_check &&
- 0 != _params.environment->perform_hook(extend_hook(
+ 0 != _params[k::environment()]->perform_hook(extend_hook(
Hook("merger_check_dir_pre")
("INSTALL_SOURCE", stringify(src))
("INSTALL_DESTINATION", stringify(dst / src.basename())))).max_exit_status)
@@ -294,7 +293,7 @@ Merger::on_dir(bool is_check, const FSEntry & src, const FSEntry & dst)
if (! is_check)
{
- HookResult hr(_params.environment->perform_hook(extend_hook(
+ HookResult hr(_params[k::environment()]->perform_hook(extend_hook(
Hook("merger_install_dir_override")
("INSTALL_SOURCE", stringify(src))
("INSTALL_DESTINATION", stringify(dst / src.basename()))
@@ -305,7 +304,7 @@ Merger::on_dir(bool is_check, const FSEntry & src, const FSEntry & dst)
<< stringify(src) << "' to '" << stringify(dst) << "' skip hooks returned non-zero";
else if (hr.output == "skip")
{
- std::string tidy(stringify((dst / src.basename()).strip_leading(_params.root.realpath())));
+ std::string tidy(stringify((dst / src.basename()).strip_leading(_params[k::root()].realpath())));
display_override("--- [skp] " + tidy);
_skip_dir = true;
return;
@@ -345,7 +344,7 @@ Merger::on_dir(bool is_check, const FSEntry & src, const FSEntry & dst)
} while (false);
if (is_check &&
- 0 != _params.environment->perform_hook(extend_hook(
+ 0 != _params[k::environment()]->perform_hook(extend_hook(
Hook("merger_check_dir_post")
("INSTALL_SOURCE", stringify(src))
("INSTALL_DESTINATION", stringify(dst / src.basename())))).max_exit_status)
@@ -360,7 +359,7 @@ Merger::on_sym(bool is_check, const FSEntry & src, const FSEntry & dst)
EntryType m(entry_type(dst / src.basename()));
if (is_check &&
- 0 != _params.environment->perform_hook(extend_hook(
+ 0 != _params[k::environment()]->perform_hook(extend_hook(
Hook("merger_check_sym_post")
("INSTALL_SOURCE", stringify(src))
("INSTALL_DESTINATION", stringify(dst / src.basename())))).max_exit_status)
@@ -368,7 +367,7 @@ Merger::on_sym(bool is_check, const FSEntry & src, const FSEntry & dst)
if (! is_check)
{
- HookResult hr(_params.environment->perform_hook(extend_hook(
+ HookResult hr(_params[k::environment()]->perform_hook(extend_hook(
Hook("merger_install_sym_override")
("INSTALL_SOURCE", stringify(src))
("INSTALL_DESTINATION", stringify(dst / src.basename()))
@@ -379,14 +378,14 @@ Merger::on_sym(bool is_check, const FSEntry & src, const FSEntry & dst)
<< stringify(src) << "' to '" << stringify(dst) << "' skip hooks returned non-zero";
else if (hr.output == "skip")
{
- std::string tidy(stringify((dst / src.basename()).strip_leading(_params.root.realpath())));
+ std::string tidy(stringify((dst / src.basename()).strip_leading(_params[k::root()].realpath())));
display_override("--- [skp] " + tidy);
return;
}
}
else
{
- if (symlink_needs_rewriting(src) && ! _params.options[mo_rewrite_symlinks])
+ if (symlink_needs_rewriting(src) && ! _params[k::options()][mo_rewrite_symlinks])
on_error(is_check, "Symlink to image detected at: " + stringify(src) + " (" + src.readlink() + ")");
}
@@ -422,7 +421,7 @@ Merger::on_sym(bool is_check, const FSEntry & src, const FSEntry & dst)
} while (false);
if (is_check &&
- 0 != _params.environment->perform_hook(extend_hook(
+ 0 != _params[k::environment()]->perform_hook(extend_hook(
Hook("merger_check_sym_post")
("INSTALL_SOURCE", stringify(src))
("INSTALL_DESTINATION", stringify(dst / src.basename())))).max_exit_status)
@@ -615,7 +614,7 @@ Merger::install_file(const FSEntry & src, const FSEntry & dst_dir, const std::st
+ stringify(dst_name) + "':");
MergeStatusFlags result;
- if (0 != _params.environment->perform_hook(extend_hook(
+ if (0 != _params[k::environment()]->perform_hook(extend_hook(
Hook("merger_install_file_pre")
("INSTALL_SOURCE", stringify(src))
("INSTALL_DESTINATION", stringify(dst_dir / src.basename())))).max_exit_status)
@@ -638,10 +637,10 @@ Merger::install_file(const FSEntry & src, const FSEntry & dst_dir, const std::st
uid_t dest_uid(src.owner());
gid_t dest_gid(src.group());
- if (! _params.no_chown)
+ if (! _params[k::no_chown()])
{
- uid_t new_uid(dest_uid == _params.environment->reduced_uid() ? 0 : -1);
- gid_t new_gid(dest_gid == _params.environment->reduced_gid() ? 0 : -1);
+ uid_t new_uid(dest_uid == _params[k::environment()]->reduced_uid() ? 0 : -1);
+ gid_t new_gid(dest_gid == _params[k::environment()]->reduced_gid() ? 0 : -1);
if (uid_t(-1) != new_uid || gid_t(-1) != new_gid)
{
FSEntry(src).chown(new_uid, new_gid);
@@ -673,7 +672,7 @@ Merger::install_file(const FSEntry & src, const FSEntry & dst_dir, const std::st
if (-1 == output_fd)
throw MergerError("Cannot write '" + stringify(dst) + "': " + stringify(::strerror(errno)));
- if (! _params.no_chown)
+ if (! _params[k::no_chown()])
if (0 != ::fchown(output_fd, dest_uid, dest_gid))
throw MergerError("Cannot fchown '" + stringify(dst) + "': " + stringify(::strerror(errno)));
@@ -694,7 +693,7 @@ Merger::install_file(const FSEntry & src, const FSEntry & dst_dir, const std::st
"rename(" + stringify(dst) + ", " + stringify(dst_real) + ") failed: " + stringify(::strerror(errno)));
}
- if (0 != _params.environment->perform_hook(extend_hook(
+ if (0 != _params[k::environment()]->perform_hook(extend_hook(
Hook("merger_install_file_post")
("INSTALL_SOURCE", stringify(src))
("INSTALL_DESTINATION", stringify(dst_dir / src.basename())))).max_exit_status)
@@ -708,7 +707,7 @@ bool
Merger::symlink_needs_rewriting(const FSEntry & sym)
{
std::string target(sym.readlink());
- std::string real_image(stringify(_params.image.realpath()));
+ std::string real_image(stringify(_params[k::image()].realpath()));
return (0 == target.compare(0, real_image.length(), real_image));
}
@@ -721,7 +720,7 @@ Merger::rewrite_symlink_as_needed(const FSEntry & src, const FSEntry & dst_dir)
FSCreateCon createcon(MatchPathCon::get_instance()->match(stringify(dst_dir / src.basename()), S_IFLNK));
- FSEntry real_image(_params.image.realpath());
+ FSEntry real_image(_params[k::image()].realpath());
FSEntry dst(src.readlink());
std::string fixed_dst(stringify(dst.strip_leading(real_image)));
@@ -738,10 +737,10 @@ Merger::record_renamed_dir_recursive(const FSEntry & dst)
{
for (DirIterator d(dst, DirIteratorOptions() + dio_include_dotfiles + dio_inode_sort), d_end ; d != d_end ; ++d)
{
- if (! _params.no_chown)
+ if (! _params[k::no_chown()])
{
- uid_t new_uid(d->owner() == _params.environment->reduced_uid() ? 0 : -1);
- gid_t new_gid(d->group() == _params.environment->reduced_gid() ? 0 : -1);
+ uid_t new_uid(d->owner() == _params[k::environment()]->reduced_uid() ? 0 : -1);
+ gid_t new_gid(d->group() == _params[k::environment()]->reduced_gid() ? 0 : -1);
if (uid_t(-1) != new_uid || gid_t(-1) != new_gid)
{
FSEntry f(*d);
@@ -812,7 +811,7 @@ Merger::install_dir(const FSEntry & src, const FSEntry & dst_dir)
MergeStatusFlags result;
- if (0 != _params.environment->perform_hook(extend_hook(
+ if (0 != _params[k::environment()]->perform_hook(extend_hook(
Hook("merger_install_dir_pre")
("INSTALL_SOURCE", stringify(src))
("INSTALL_DESTINATION", stringify(dst_dir / src.basename())))).max_exit_status)
@@ -826,10 +825,10 @@ Merger::install_dir(const FSEntry & src, const FSEntry & dst_dir)
if (0 != (mode & (S_ISVTX | S_ISUID | S_ISGID)))
result += msi_setid_bits;
- if (! _params.no_chown)
+ if (! _params[k::no_chown()])
{
- uid_t new_uid(dest_uid == _params.environment->reduced_uid() ? 0 : -1);
- gid_t new_gid(dest_gid == _params.environment->reduced_gid() ? 0 : -1);
+ uid_t new_uid(dest_uid == _params[k::environment()]->reduced_uid() ? 0 : -1);
+ gid_t new_gid(dest_gid == _params[k::environment()]->reduced_gid() ? 0 : -1);
if (uid_t(-1) != new_uid)
mode &= ~S_ISUID;
if (gid_t(-1) != new_gid)
@@ -865,13 +864,13 @@ Merger::install_dir(const FSEntry & src, const FSEntry & dst_dir)
{
Log::get_instance()->message(ll_debug, lc_context, "rename failed. Falling back to recursive copy.");
dst.mkdir(mode);
- if (! _params.no_chown)
+ if (! _params[k::no_chown()])
dst.chown(dest_uid, dest_gid);
/* pick up set*id bits */
dst.chmod(mode);
}
- if (0 != _params.environment->perform_hook(extend_hook(
+ if (0 != _params[k::environment()]->perform_hook(extend_hook(
Hook("merger_install_dir_post")
("INSTALL_SOURCE", stringify(src))
("INSTALL_DESTINATION", stringify(dst_dir / src.basename())))).max_exit_status)
@@ -888,15 +887,15 @@ Merger::install_sym(const FSEntry & src, const FSEntry & dst_dir)
MergeStatusFlags result;
- if (0 != _params.environment->perform_hook(extend_hook(
+ if (0 != _params[k::environment()]->perform_hook(extend_hook(
Hook("merger_install_sym_pre")
("INSTALL_SOURCE", stringify(src))
("INSTALL_DESTINATION", stringify(dst_dir / src.basename())))).max_exit_status)
Log::get_instance()->message(ll_warning, lc_context,
"Merge of '" + stringify(src) + "' to '" + stringify(dst_dir) + "' pre hooks returned non-zero");
- uid_t dest_uid(src.owner() == _params.environment->reduced_uid() ? 0 : src.owner());
- gid_t dest_gid(src.group() == _params.environment->reduced_gid() ? 0 : src.group());
+ uid_t dest_uid(src.owner() == _params[k::environment()]->reduced_uid() ? 0 : src.owner());
+ gid_t dest_gid(src.group() == _params[k::environment()]->reduced_gid() ? 0 : src.group());
if (0 != (src.permissions() & (S_ISVTX | S_ISUID | S_ISGID)))
result += msi_setid_bits;
@@ -911,14 +910,14 @@ Merger::install_sym(const FSEntry & src, const FSEntry & dst_dir)
+ stringify(::strerror(errno)));
}
- if (! _params.no_chown)
+ if (! _params[k::no_chown()])
{
if (src.owner() != dest_uid || src.group() != dest_gid)
result += msi_fixed_ownership;
FSEntry(dst_dir / src.basename()).lchown(dest_uid, dest_gid);
}
- if (0 != _params.environment->perform_hook(extend_hook(
+ if (0 != _params[k::environment()]->perform_hook(extend_hook(
Hook("merger_install_sym_post")
("INSTALL_SOURCE", stringify(src))
("INSTALL_DESTINATION", stringify(dst_dir / src.basename())))).max_exit_status)
@@ -931,7 +930,7 @@ Merger::install_sym(const FSEntry & src, const FSEntry & dst_dir)
void
Merger::unlink_file(FSEntry d)
{
- if (0 != _params.environment->perform_hook(extend_hook(
+ if (0 != _params[k::environment()]->perform_hook(extend_hook(
Hook("merger_unlink_file_pre")
("UNLINK_TARGET", stringify(d)))).max_exit_status)
Log::get_instance()->message(ll_warning, lc_context,
@@ -949,7 +948,7 @@ Merger::unlink_file(FSEntry d)
d.unlink();
- if (0 != _params.environment->perform_hook(extend_hook(
+ if (0 != _params[k::environment()]->perform_hook(extend_hook(
Hook("merger_unlink_file_post")
("UNLINK_TARGET", stringify(d)))).max_exit_status)
Log::get_instance()->message(ll_warning, lc_context,
@@ -959,7 +958,7 @@ Merger::unlink_file(FSEntry d)
void
Merger::unlink_sym(FSEntry d)
{
- if (0 != _params.environment->perform_hook(extend_hook(
+ if (0 != _params[k::environment()]->perform_hook(extend_hook(
Hook("merger_unlink_sym_pre")
("UNLINK_TARGET", stringify(d)))).max_exit_status)
Log::get_instance()->message(ll_warning, lc_context,
@@ -967,7 +966,7 @@ Merger::unlink_sym(FSEntry d)
d.unlink();
- if (0 != _params.environment->perform_hook(extend_hook(
+ if (0 != _params[k::environment()]->perform_hook(extend_hook(
Hook("merger_unlink_sym_post")
("UNLINK_TARGET", stringify(d)))).max_exit_status)
Log::get_instance()->message(ll_warning, lc_context,
@@ -977,7 +976,7 @@ Merger::unlink_sym(FSEntry d)
void
Merger::unlink_dir(FSEntry d)
{
- if (0 != _params.environment->perform_hook(extend_hook(
+ if (0 != _params[k::environment()]->perform_hook(extend_hook(
Hook("merger_unlink_dir_pre")
("UNLINK_TARGET", stringify(d)))).max_exit_status)
Log::get_instance()->message(ll_warning, lc_context,
@@ -985,7 +984,7 @@ Merger::unlink_dir(FSEntry d)
d.rmdir();
- if (0 != _params.environment->perform_hook(extend_hook(
+ if (0 != _params[k::environment()]->perform_hook(extend_hook(
Hook("merger_unlink_dir_post")
("UNLINK_TARGET", stringify(d)))).max_exit_status)
Log::get_instance()->message(ll_warning, lc_context,
@@ -995,7 +994,7 @@ Merger::unlink_dir(FSEntry d)
void
Merger::unlink_misc(FSEntry d)
{
- if (0 != _params.environment->perform_hook(extend_hook(
+ if (0 != _params[k::environment()]->perform_hook(extend_hook(
Hook("merger_unlink_misc_pre")
("UNLINK_TARGET", stringify(d)))).max_exit_status)
Log::get_instance()->message(ll_warning, lc_context,
@@ -1003,7 +1002,7 @@ Merger::unlink_misc(FSEntry d)
d.unlink();
- if (0 != _params.environment->perform_hook(extend_hook(
+ if (0 != _params[k::environment()]->perform_hook(extend_hook(
Hook("merger_unlink_misc_post")
("UNLINK_TARGET", stringify(d)))).max_exit_status)
Log::get_instance()->message(ll_warning, lc_context,
@@ -1014,7 +1013,7 @@ Hook
Merger::extend_hook(const Hook & h)
{
return h
- ("ROOT", stringify(_params.root))
- ("IMAGE", stringify(_params.image));
+ ("ROOT", stringify(_params[k::root()]))
+ ("IMAGE", stringify(_params[k::image()]));
}
diff --git a/paludis/merger.hh b/paludis/merger.hh
index 1f10903..d1892fd 100644
--- a/paludis/merger.hh
+++ b/paludis/merger.hh
@@ -20,11 +20,11 @@
#ifndef PALUDIS_GUARD_PALUDIS_MERGER_HH
#define PALUDIS_GUARD_PALUDIS_MERGER_HH 1
-#include "merger-fwd.hh"
-#include <paludis/util/sr.hh>
+#include <paludis/merger-fwd.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/options.hh>
+#include <paludis/util/kc.hh>
#include <paludis/merger_entry_type.hh>
#include <iosfwd>
@@ -44,8 +44,6 @@ namespace paludis
class Environment;
class Hook;
-#include <paludis/merger-sr.hh>
-
/**
* Thrown if an error occurs during a Merger operation.
*
diff --git a/paludis/merger.sr b/paludis/merger.sr
deleted file mode 100644
index 9af3522..0000000
--- a/paludis/merger.sr
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/bash
-# vim: set sw=4 sts=4 et :
-
-make_class_MergerParams()
-{
- visible
-
- key environment "Environment *"
- key image "FSEntry"
- key root "FSEntry"
- key no_chown bool
- key options "MergerOptions"
-
- allow_named_args
-
- doxygen_comment << "END"
- /**
- * Parameters for a basic Merger.
- *
- * \see Merger
- * \ingroup g_repository
- * \nosubgrouping
- * \since 0.26
- */
-END
-}
-
-
diff --git a/paludis/merger_TEST.cc b/paludis/merger_TEST.cc
index d1af105..9c34492 100644
--- a/paludis/merger_TEST.cc
+++ b/paludis/merger_TEST.cc
@@ -148,12 +148,12 @@ namespace
root_dir("merger_TEST_dir/" + stringify(src_type) + "_over_" + stringify(dst_type)
+ (0 == n ? "" : "_" + stringify(n)) + "_dir/root"),
env(FSEntry("merger_TEST_dir/hooks")),
- merger(MergerParams::create()
- .image(image_dir)
- .root(root_dir)
- .environment(&env)
- .no_chown(true)
- .options(MergerOptions() + mo_rewrite_symlinks + mo_allow_empty_dirs))
+ merger(MergerParams::named_create()
+ (k::image(), image_dir)
+ (k::root(), root_dir)
+ (k::environment(), &env)
+ (k::no_chown(), true)
+ (k::options(), MergerOptions() + mo_rewrite_symlinks + mo_allow_empty_dirs))
{
}
@@ -162,12 +162,12 @@ namespace
image_dir("merger_TEST_dir/" + custom_test + "/image"),
root_dir("merger_TEST_dir/" + custom_test + "/root"),
env(FSEntry("merger_TEST_dir/hooks")),
- merger(MergerParams::create()
- .image(image_dir)
- .root(root_dir)
- .environment(&env)
- .no_chown(true)
- .options(o))
+ merger(MergerParams::named_create()
+ (k::image(), image_dir)
+ (k::root(), root_dir)
+ (k::environment(), &env)
+ (k::no_chown(), true)
+ (k::options(), o))
{
}
};
diff --git a/paludis/ndbam_merger.cc b/paludis/ndbam_merger.cc
index de6c36e..af92eba 100644
--- a/paludis/ndbam_merger.cc
+++ b/paludis/ndbam_merger.cc
@@ -65,12 +65,12 @@ namespace paludis
}
NDBAMMerger::NDBAMMerger(const NDBAMMergerParams & p) :
- Merger(MergerParams::create()
- .environment(p.environment)
- .image(p.image)
- .root(p.root)
- .no_chown(! getenv_with_default("PALUDIS_NO_CHOWN", "").empty())
- .options(p.options)),
+ Merger(MergerParams::named_create()
+ (k::environment(), p.environment)
+ (k::image(), p.image)
+ (k::root(), p.root)
+ (k::no_chown(), ! getenv_with_default("PALUDIS_NO_CHOWN", "").empty())
+ (k::options(), p.options)),
PrivateImplementationPattern<NDBAMMerger>(new Implementation<NDBAMMerger>(p))
{
}
diff --git a/paludis/ndbam_unmerger.cc b/paludis/ndbam_unmerger.cc
index 43e7e0c..5a0a062 100644
--- a/paludis/ndbam_unmerger.cc
+++ b/paludis/ndbam_unmerger.cc
@@ -104,9 +104,9 @@ class NDBAMUnmerger::SymlinkExtraInfo :
};
NDBAMUnmerger::NDBAMUnmerger(const NDBAMUnmergerOptions & o) :
- Unmerger(UnmergerOptions::create()
- .environment(o.environment)
- .root(o.root)),
+ Unmerger(UnmergerOptions::named_create()
+ (k::environment(), o.environment)
+ (k::root(), o.root)),
PrivateImplementationPattern<NDBAMUnmerger>(new Implementation<NDBAMUnmerger>(o)),
_imp(PrivateImplementationPattern<NDBAMUnmerger>::_imp.get())
{
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index 1001c4f..0b1eb2f 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -7,8 +7,6 @@ DISTCLEANFILES = \
e_repository_params-se.hh e_repository_params-se.cc \
vdb_repository-sr.hh vdb_repository-sr.cc \
ebuild-sr.hh ebuild-sr.cc \
- vdb_merger-sr.hh vdb_merger-sr.cc \
- vdb_unmerger-sr.hh vdb_unmerger-sr.cc \
eapi-sr.hh eapi-sr.cc \
dep_parser-se.hh dep_parser-se.cc \
manifest2_entry-sr.hh manifest2_entry-sr.cc
@@ -91,11 +89,9 @@ paludis_repositories_e_include_HEADERS = \
use_requirements.hh \
vdb_contents_tokeniser.hh \
vdb_id.hh \
- vdb_merger-sr.hh \
vdb_merger.hh \
vdb_repository-sr.hh \
vdb_repository.hh \
- vdb_unmerger-sr.hh \
vdb_unmerger.hh
libpaludiserepository_la_SOURCES = \
@@ -362,12 +358,6 @@ EXTRA_DIST = \
vdb_repository-sr.hh \
vdb_repository-sr.cc \
vdb_repository.sr \
- vdb_merger.sr \
- vdb_merger-sr.hh \
- vdb_merger-sr.cc \
- vdb_unmerger.sr \
- vdb_unmerger-sr.hh \
- vdb_unmerger-sr.cc \
vdb_merger_TEST.cc \
vdb_merger_TEST_setup.sh \
vdb_merger_TEST_cleanup.sh \
@@ -392,10 +382,6 @@ BUILT_SOURCES = \
vdb_repository-sr.cc \
ebuild-sr.hh \
ebuild-sr.cc \
- vdb_merger-sr.hh \
- vdb_merger-sr.cc \
- vdb_unmerger-sr.hh \
- vdb_unmerger-sr.cc \
eapi-sr.hh \
eapi-sr.cc \
manifest2_entry-sr.hh \
@@ -447,18 +433,6 @@ manifest2_entry-sr.hh : manifest2_entry.sr $(top_srcdir)/misc/make_sr.bash
manifest2_entry-sr.cc : manifest2_entry.sr $(top_srcdir)/misc/make_sr.bash
$(top_srcdir)/misc/make_sr.bash --source $(srcdir)/manifest2_entry.sr > $@
-vdb_merger-sr.hh : vdb_merger.sr $(top_srcdir)/misc/make_sr.bash
- $(top_srcdir)/misc/make_sr.bash --header $(srcdir)/vdb_merger.sr > $@
-
-vdb_merger-sr.cc : vdb_merger.sr $(top_srcdir)/misc/make_sr.bash
- $(top_srcdir)/misc/make_sr.bash --source $(srcdir)/vdb_merger.sr > $@
-
-vdb_unmerger-sr.hh : vdb_unmerger.sr $(top_srcdir)/misc/make_sr.bash
- $(top_srcdir)/misc/make_sr.bash --header $(srcdir)/vdb_unmerger.sr > $@
-
-vdb_unmerger-sr.cc : vdb_unmerger.sr $(top_srcdir)/misc/make_sr.bash
- $(top_srcdir)/misc/make_sr.bash --source $(srcdir)/vdb_unmerger.sr > $@
-
ebuild-sr.hh : ebuild.sr $(top_srcdir)/misc/make_sr.bash
$(top_srcdir)/misc/make_sr.bash --header $(srcdir)/ebuild.sr > $@
diff --git a/paludis/repositories/e/vdb_merger.cc b/paludis/repositories/e/vdb_merger.cc
index 3913cd7..b4f9d39 100644
--- a/paludis/repositories/e/vdb_merger.cc
+++ b/paludis/repositories/e/vdb_merger.cc
@@ -40,7 +40,7 @@
using namespace paludis;
-#include <paludis/repositories/e/vdb_merger-sr.cc>
+#include <iostream>
namespace paludis
{
@@ -56,21 +56,21 @@ namespace paludis
Implementation(const VDBMergerParams & p) :
params(p),
- realroot(params.root.realpath())
+ realroot(params[k::root()].realpath())
{
- tokenise_whitespace(p.config_protect, std::back_inserter(config_protect));
- tokenise_whitespace(p.config_protect_mask, std::back_inserter(config_protect_mask));
+ tokenise_whitespace(params[k::config_protect()], std::back_inserter(config_protect));
+ tokenise_whitespace(params[k::config_protect_mask()], std::back_inserter(config_protect_mask));
}
};
}
VDBMerger::VDBMerger(const VDBMergerParams & p) :
- Merger(MergerParams::create()
- .environment(p.environment)
- .image(p.image)
- .root(p.root)
- .no_chown(! getenv_with_default("PALUDIS_NO_CHOWN", "").empty())
- .options(p.options)),
+ Merger(MergerParams::named_create()
+ (k::environment(), p[k::environment()])
+ (k::image(), p[k::image()])
+ (k::root(), p[k::root()])
+ (k::no_chown(), ! getenv_with_default("PALUDIS_NO_CHOWN", "").empty())
+ (k::options(), p[k::options()])),
PrivateImplementationPattern<VDBMerger>(new Implementation<VDBMerger>(p))
{
}
@@ -82,33 +82,33 @@ VDBMerger::~VDBMerger()
Hook
VDBMerger::extend_hook(const Hook & h)
{
- tr1::shared_ptr<const FSEntrySequence> bashrc_files(_imp->params.environment->bashrc_files());
+ tr1::shared_ptr<const FSEntrySequence> bashrc_files(_imp->params[k::environment()]->bashrc_files());
- if (_imp->params.package_id)
+ if (_imp->params[k::package_id()])
{
- std::string cat(stringify(_imp->params.package_id->name().category));
- std::string pn(stringify(_imp->params.package_id->name().package));
- std::string pvr(stringify(_imp->params.package_id->version()));
- std::string pv(stringify(_imp->params.package_id->version().remove_revision()));
- std::string slot(stringify(_imp->params.package_id->slot()));
+ std::string cat(stringify(_imp->params[k::package_id()]->name().category));
+ std::string pn(stringify(_imp->params[k::package_id()]->name().package));
+ std::string pvr(stringify(_imp->params[k::package_id()]->version()));
+ std::string pv(stringify(_imp->params[k::package_id()]->version().remove_revision()));
+ std::string slot(stringify(_imp->params[k::package_id()]->slot()));
return Merger::extend_hook(h)
("P", pn + "-" + pv)
("PN", pn)
("CATEGORY", cat)
- ("PR", _imp->params.package_id->version().revision_only())
+ ("PR", _imp->params[k::package_id()]->version().revision_only())
("PV", pv)
("PVR", pvr)
("PF", pn + "-" + pvr)
("SLOT", slot)
- ("CONFIG_PROTECT", _imp->params.config_protect)
- ("CONFIG_PROTECT_MASK", _imp->params.config_protect_mask)
+ ("CONFIG_PROTECT", _imp->params[k::config_protect()])
+ ("CONFIG_PROTECT_MASK", _imp->params[k::config_protect_mask()])
("PALUDIS_BASHRC_FILES", join(bashrc_files->begin(), bashrc_files->end(), " "));
}
else
return Merger::extend_hook(h)
- ("CONFIG_PROTECT", _imp->params.config_protect)
- ("CONFIG_PROTECT_MASK", _imp->params.config_protect_mask)
+ ("CONFIG_PROTECT", _imp->params[k::config_protect()])
+ ("CONFIG_PROTECT_MASK", _imp->params[k::config_protect_mask()])
("PALUDIS_BASHRC_FILES", join(bashrc_files->begin(), bashrc_files->end(), " "));
}
@@ -235,15 +235,15 @@ VDBMerger::make_config_protect_name(const FSEntry & src, const FSEntry & dst)
void
VDBMerger::merge()
{
- display_override(">>> Merging to " + stringify(_imp->params.root));
- _imp->contents_file.reset(new std::ofstream(stringify(_imp->params.contents_file).c_str()));
+ display_override(">>> Merging to " + stringify(_imp->params[k::root()]));
+ _imp->contents_file.reset(new std::ofstream(stringify(_imp->params[k::contents_file()]).c_str()));
Merger::merge();
}
bool
VDBMerger::check()
{
- std::cout << ">>> Checking whether we can merge to " << _imp->params.root << " ";
+ std::cout << ">>> Checking whether we can merge to " << _imp->params[k::root()] << " ";
bool result(Merger::check());
std::cout << std::endl;
return result;
diff --git a/paludis/repositories/e/vdb_merger.hh b/paludis/repositories/e/vdb_merger.hh
index 999bdd2..2ff780d 100644
--- a/paludis/repositories/e/vdb_merger.hh
+++ b/paludis/repositories/e/vdb_merger.hh
@@ -23,12 +23,32 @@
#include <paludis/merger.hh>
#include <paludis/package_id-fwd.hh>
#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/kc.hh>
+#include <paludis/util/keys.hh>
namespace paludis
{
class Hook;
-#include <paludis/repositories/e/vdb_merger-sr.hh>
+ /**
+ * Parameters for a VDBMerger.
+ *
+ * \see VDBMerger
+ * \ingroup grpmerger
+ * \ingroup grpvdbrepository
+ * \nosubgrouping
+ * \since 0.26
+ */
+ typedef kc::KeyedClass<
+ kc::Field<k::environment, Environment *>,
+ kc::Field<k::image, FSEntry>,
+ kc::Field<k::root, FSEntry>,
+ kc::Field<k::contents_file, FSEntry>,
+ kc::Field<k::config_protect, std::string>,
+ kc::Field<k::config_protect_mask, std::string>,
+ kc::Field<k::package_id, tr1::shared_ptr<const PackageID> >,
+ kc::Field<k::options, MergerOptions>
+ > VDBMergerParams;
/**
* Merger for VDBRepository.
diff --git a/paludis/repositories/e/vdb_merger.sr b/paludis/repositories/e/vdb_merger.sr
deleted file mode 100644
index 2e6cc11..0000000
--- a/paludis/repositories/e/vdb_merger.sr
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/bash
-# vim: set sw=4 sts=4 et :
-
-make_class_VDBMergerParams()
-{
- visible
-
- key environment "Environment *"
- key image "FSEntry"
- key root "FSEntry"
- key contents_file "FSEntry"
- key config_protect std::string
- key config_protect_mask std::string
- key package_id "tr1::shared_ptr<const PackageID>"
- key options "MergerOptions"
-
- allow_named_args
-
- doxygen_comment << "END"
- /**
- * Parameters for a VDBMerger.
- *
- * \see VDBMerger
- * \ingroup grpmerger
- * \ingroup grpvdbrepository
- * \nosubgrouping
- * \since 0.26
- */
-END
-}
-
-
-
diff --git a/paludis/repositories/e/vdb_merger_TEST.cc b/paludis/repositories/e/vdb_merger_TEST.cc
index 5e4d36e..f568033 100644
--- a/paludis/repositories/e/vdb_merger_TEST.cc
+++ b/paludis/repositories/e/vdb_merger_TEST.cc
@@ -75,15 +75,15 @@ namespace
TestCase("merge '" + what + "' test"),
root_dir(FSEntry::cwd() / "vdb_merger_TEST_dir" / what / "root"),
target(what),
- merger(VDBMergerParams::create()
- .environment(&env)
- .image(FSEntry::cwd() / "vdb_merger_TEST_dir" / what / "image")
- .root(root_dir)
- .contents_file(FSEntry::cwd() / "vdb_merger_TEST_dir/CONTENTS" / what)
- .config_protect("/protected_file /protected_dir")
- .config_protect_mask("/protected_dir/unprotected_file /protected_dir/unprotected_dir")
- .package_id(tr1::shared_ptr<PackageID>())
- .options(MergerOptions() + mo_rewrite_symlinks + mo_allow_empty_dirs))
+ merger(VDBMergerParams::named_create()
+ (k::environment(), &env)
+ (k::image(), FSEntry::cwd() / "vdb_merger_TEST_dir" / what / "image")
+ (k::root(), root_dir)
+ (k::contents_file(), FSEntry::cwd() / "vdb_merger_TEST_dir/CONTENTS" / what)
+ (k::config_protect(), "/protected_file /protected_dir")
+ (k::config_protect_mask(), "/protected_dir/unprotected_file /protected_dir/unprotected_dir")
+ (k::package_id(), tr1::shared_ptr<PackageID>())
+ (k::options(), MergerOptions() + mo_rewrite_symlinks + mo_allow_empty_dirs))
{
}
};
diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc
index 83996c2..30066f3 100644
--- a/paludis/repositories/e/vdb_repository.cc
+++ b/paludis/repositories/e/vdb_repository.cc
@@ -397,13 +397,13 @@ VDBRepository::perform_uninstall(const tr1::shared_ptr<const ERepositoryID> & id
/* unmerge */
VDBUnmerger unmerger(
- VDBUnmergerOptions::create()
- .environment(_imp->params.environment)
- .root(installed_root_key()->value())
- .contents_file(pkg_dir / "CONTENTS")
- .config_protect(config_protect)
- .config_protect_mask(config_protect_mask)
- .package_id(id));
+ VDBUnmergerOptions::named_create()
+ (k::environment(), _imp->params.environment)
+ (k::root(), installed_root_key()->value())
+ (k::contents_file(), pkg_dir / "CONTENTS")
+ (k::config_protect(), config_protect)
+ (k::config_protect_mask(), config_protect_mask)
+ (k::package_id(), id));
unmerger.unmerge();
}
@@ -737,15 +737,15 @@ VDBRepository::merge(const MergeParams & m)
vdb_dir /= (stringify(m.package_id->name().package) + "-" + stringify(m.package_id->version()));
VDBMerger merger(
- VDBMergerParams::create()
- .environment(_imp->params.environment)
- .image(m.image_dir)
- .root(installed_root_key()->value())
- .contents_file(vdb_dir / "CONTENTS")
- .config_protect(config_protect)
- .config_protect_mask(config_protect_mask)
- .package_id(m.package_id)
- .options(m.options));
+ VDBMergerParams::named_create()
+ (k::environment(), _imp->params.environment)
+ (k::image(), m.image_dir)
+ (k::root(), installed_root_key()->value())
+ (k::contents_file(), vdb_dir / "CONTENTS")
+ (k::config_protect(), config_protect)
+ (k::config_protect_mask(), config_protect_mask)
+ (k::package_id(), m.package_id)
+ (k::options(), m.options));
if (! merger.check())
{
diff --git a/paludis/repositories/e/vdb_unmerger.cc b/paludis/repositories/e/vdb_unmerger.cc
index be298d2..5acc4af 100644
--- a/paludis/repositories/e/vdb_unmerger.cc
+++ b/paludis/repositories/e/vdb_unmerger.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 2008 Ciaran McCreesh
* Copyright (c) 2007 Piotr Jaroszyński
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -29,7 +29,6 @@ using namespace paludis;
#include <paludis/hook.hh>
#include <paludis/package_database.hh>
#include <paludis/package_id.hh>
-#include <paludis/repositories/e/vdb_unmerger-sr.cc>
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/join.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
@@ -58,8 +57,8 @@ namespace paludis
Implementation(const VDBUnmergerOptions & o) :
options(o)
{
- tokenise_whitespace(o.config_protect, std::back_inserter(config_protect));
- tokenise_whitespace(o.config_protect_mask, std::back_inserter(config_protect_mask));
+ tokenise_whitespace(o[k::config_protect()], std::back_inserter(config_protect));
+ tokenise_whitespace(o[k::config_protect_mask()], std::back_inserter(config_protect_mask));
}
};
}
@@ -117,9 +116,9 @@ class VDBUnmerger::MiscExtraInfo :
};
VDBUnmerger::VDBUnmerger(const VDBUnmergerOptions & o) :
- Unmerger(UnmergerOptions::create()
- .environment(o.environment)
- .root(o.root)),
+ Unmerger(UnmergerOptions::named_create()
+ (k::environment(), o[k::environment()])
+ (k::root(), o[k::root()])),
PrivateImplementationPattern<VDBUnmerger>(new Implementation<VDBUnmerger>(o)),
_imp(PrivateImplementationPattern<VDBUnmerger>::_imp.get())
{
@@ -132,29 +131,29 @@ VDBUnmerger::~VDBUnmerger()
Hook
VDBUnmerger::extend_hook(const Hook & h) const
{
- tr1::shared_ptr<const FSEntrySequence> bashrc_files(_imp->options.environment->bashrc_files());
+ tr1::shared_ptr<const FSEntrySequence> bashrc_files(_imp->options[k::environment()]->bashrc_files());
Hook result(Unmerger::extend_hook(h)
- ("CONFIG_PROTECT", _imp->options.config_protect)
- ("CONFIG_PROTECT_MASK", _imp->options.config_protect_mask)
+ ("CONFIG_PROTECT", _imp->options[k::config_protect()])
+ ("CONFIG_PROTECT_MASK", _imp->options[k::config_protect_mask()])
("PALUDIS_BASHRC_FILES", join(bashrc_files->begin(), bashrc_files->end(), " ")));
- if (_imp->options.package_id)
+ if (_imp->options[k::package_id()])
{
- std::string cat(stringify(_imp->options.package_id->name().category));
- std::string pn(stringify(_imp->options.package_id->name().package));
- std::string pvr(stringify(_imp->options.package_id->version()));
- std::string pv(stringify(_imp->options.package_id->version().remove_revision()));
+ std::string cat(stringify(_imp->options[k::package_id()]->name().category));
+ std::string pn(stringify(_imp->options[k::package_id()]->name().package));
+ std::string pvr(stringify(_imp->options[k::package_id()]->version()));
+ std::string pv(stringify(_imp->options[k::package_id()]->version().remove_revision()));
return result
("P", pn + "-" + pv)
("PN", pn)
("CATEGORY", cat)
- ("PR", _imp->options.package_id->version().revision_only())
+ ("PR", _imp->options[k::package_id()]->version().revision_only())
("PV", pv)
("PVR", pvr)
("PF", pn + "-" + pvr)
- ("SLOT", stringify(_imp->options.package_id->slot()));
+ ("SLOT", stringify(_imp->options[k::package_id()]->slot()));
}
return result;
@@ -188,7 +187,7 @@ VDBUnmerger::config_protected(const FSEntry & f) const
std::string
VDBUnmerger::make_tidy(const FSEntry & f) const
{
- std::string root_str(stringify(_imp->options.root)), f_str(stringify(f));
+ std::string root_str(stringify(_imp->options[k::root()])), f_str(stringify(f));
if (root_str == "/")
root_str.clear();
if (0 != f_str.compare(0, root_str.length(), root_str))
@@ -199,9 +198,9 @@ VDBUnmerger::make_tidy(const FSEntry & f) const
void
VDBUnmerger::populate_unmerge_set()
{
- std::ifstream c(stringify(_imp->options.contents_file).c_str());
+ std::ifstream c(stringify(_imp->options[k::contents_file()]).c_str());
if (! c)
- throw VDBUnmergerError("Cannot read '" + stringify(_imp->options.contents_file) + "'");
+ throw VDBUnmergerError("Cannot read '" + stringify(_imp->options[k::contents_file()]) + "'");
std::string line;
while (std::getline(c, line))
@@ -251,22 +250,22 @@ VDBUnmerger::check_file(const FSEntry & f, tr1::shared_ptr<ExtraInfo> ei) const
{
tr1::shared_ptr<FileExtraInfo> fie(tr1::static_pointer_cast<FileExtraInfo>(ei));
- if (! (_imp->options.root / f).is_regular_file())
+ if (! (_imp->options[k::root()] / f).is_regular_file())
display("--- [!type] " + stringify(f));
- else if ((_imp->options.root / f).mtime() != fie->_mtime)
+ else if ((_imp->options[k::root()] / f).mtime() != fie->_mtime)
display("--- [!time] " + stringify(f));
else
{
- std::ifstream md5_file(stringify(_imp->options.root / f).c_str());
+ std::ifstream md5_file(stringify(_imp->options[k::root()] / f).c_str());
if (! md5_file)
{
Log::get_instance()->message(ll_warning, lc_no_context, "Cannot get md5 for '" +
- stringify(_imp->options.root / f) + "'");
+ stringify(_imp->options[k::root()] / f) + "'");
display("--- [!md5?] " + stringify(f));
}
else if (MD5(md5_file).hexsum() != fie->_md5sum)
display("--- [!md5 ] " + stringify(f));
- else if (config_protected(_imp->options.root / f))
+ else if (config_protected(_imp->options[k::root()] / f))
display("--- [cfgpr] " + stringify(f));
else
return true;
@@ -280,11 +279,11 @@ VDBUnmerger::check_sym(const FSEntry & f, tr1::shared_ptr<ExtraInfo> ei) const
{
tr1::shared_ptr<SymlinkExtraInfo> sie(tr1::static_pointer_cast<SymlinkExtraInfo>(ei));
- if (! (_imp->options.root / f).is_symbolic_link())
+ if (! (_imp->options[k::root()] / f).is_symbolic_link())
display("--- [!type] " + stringify(f));
- else if ((_imp->options.root / f).mtime() != sie->_mtime)
+ else if ((_imp->options[k::root()] / f).mtime() != sie->_mtime)
display("--- [!time] " + stringify(f));
- else if ((_imp->options.root / f).readlink() != sie->_dest)
+ else if ((_imp->options[k::root()] / f).readlink() != sie->_dest)
display("--- [!dest] " + stringify(f));
else
return true;
@@ -297,9 +296,9 @@ VDBUnmerger::check_misc(const FSEntry & f, tr1::shared_ptr<ExtraInfo> ei) const
{
tr1::shared_ptr<MiscExtraInfo> mie(tr1::static_pointer_cast<MiscExtraInfo>(ei));
- if ("fif" == mie->_type && ! (_imp->options.root / f).is_fifo())
+ if ("fif" == mie->_type && ! (_imp->options[k::root()] / f).is_fifo())
display("--- [!type] " + stringify(f));
- else if ("dev" == mie->_type && ! (_imp->options.root / f).is_device())
+ else if ("dev" == mie->_type && ! (_imp->options[k::root()] / f).is_device())
display("--- [!type] " + stringify(f));
else
return true;
@@ -310,9 +309,9 @@ VDBUnmerger::check_misc(const FSEntry & f, tr1::shared_ptr<ExtraInfo> ei) const
bool
VDBUnmerger::check_dir(const FSEntry & f, tr1::shared_ptr<ExtraInfo>) const
{
- if (! (_imp->options.root / f).is_directory())
+ if (! (_imp->options[k::root()] / f).is_directory())
display("--- [!type] " + stringify(f));
- else if (DirIterator(_imp->options.root / f, DirIteratorOptions() + dio_include_dotfiles + dio_first_only) != DirIterator())
+ else if (DirIterator(_imp->options[k::root()] / f, DirIteratorOptions() + dio_include_dotfiles + dio_first_only) != DirIterator())
display("--- [!empt] " + stringify(f));
else
return true;
diff --git a/paludis/repositories/e/vdb_unmerger.hh b/paludis/repositories/e/vdb_unmerger.hh
index 892b97f..8520e91 100644
--- a/paludis/repositories/e/vdb_unmerger.hh
+++ b/paludis/repositories/e/vdb_unmerger.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 2008 Ciaran McCreesh
* Copyright (c) 2007 Piotr Jaroszyński
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -22,8 +22,9 @@
#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_GENTOO_VDB_UNMERGER_HH 1
#include <paludis/repository.hh>
+#include <paludis/util/kc.hh>
+#include <paludis/util/keys.hh>
#include <paludis/util/private_implementation_pattern.hh>
-#include <paludis/util/sr.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/unmerger.hh>
@@ -31,7 +32,21 @@ namespace paludis
{
class Environment;
-#include <paludis/repositories/e/vdb_unmerger-sr.hh>
+ /**
+ * Options for a VDBUnmerger.
+ *
+ * \see VDBUnmerger
+ * \ingroup grpvdbrepository
+ * \nosubgrouping
+ */
+ typedef kc::KeyedClass<
+ kc::Field<k::environment, Environment *>,
+ kc::Field<k::root, FSEntry>,
+ kc::Field<k::contents_file, FSEntry>,
+ kc::Field<k::config_protect, std::string>,
+ kc::Field<k::config_protect_mask, std::string>,
+ kc::Field<k::package_id, tr1::shared_ptr<const PackageID> >
+ > VDBUnmergerOptions;
/**
* Thrown if an unmerge from a VDBRepository using VDBUnmerger fails.
diff --git a/paludis/repositories/e/vdb_unmerger.sr b/paludis/repositories/e/vdb_unmerger.sr
deleted file mode 100644
index ea070b6..0000000
--- a/paludis/repositories/e/vdb_unmerger.sr
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/bash
-# vim: set sw=4 sts=4 et :
-
-make_class_VDBUnmergerOptions()
-{
- visible
-
- key environment "Environment *"
- key root "FSEntry"
- key contents_file "FSEntry"
- key config_protect std::string
- key config_protect_mask std::string
- key package_id "tr1::shared_ptr<const PackageID>"
-
- allow_named_args
-
- doxygen_comment << "END"
- /**
- * Options for a VDBUnmerger.
- *
- * \see VDBUnmerger
- * \ingroup grpvdbrepository
- * \nosubgrouping
- */
-END
-}
-
-
-
-
diff --git a/paludis/repositories/e/vdb_unmerger_TEST.cc b/paludis/repositories/e/vdb_unmerger_TEST.cc
index 7036ec8..f385c74 100644
--- a/paludis/repositories/e/vdb_unmerger_TEST.cc
+++ b/paludis/repositories/e/vdb_unmerger_TEST.cc
@@ -66,13 +66,13 @@ namespace
TestCase("unmerge '" + what + "' test"),
root_dir("vdb_unmerger_TEST_dir/root"),
target(what),
- unmerger(VDBUnmergerOptions::create()
- .environment(&env)
- .root(root_dir)
- .contents_file("vdb_unmerger_TEST_dir/CONTENTS/" + what)
- .config_protect("/protected_file /protected_dir")
- .config_protect_mask("/protected_dir/unprotected_file /protected_dir/unprotected_dir")
- .package_id(tr1::shared_ptr<PackageID>()))
+ unmerger(VDBUnmergerOptions::named_create()
+ (k::environment(), &env)
+ (k::root(), root_dir)
+ (k::contents_file(), "vdb_unmerger_TEST_dir/CONTENTS/" + what)
+ (k::config_protect(), "/protected_file /protected_dir")
+ (k::config_protect_mask(), "/protected_dir/unprotected_file /protected_dir/unprotected_dir")
+ (k::package_id(), tr1::shared_ptr<PackageID>()))
{
}
};
diff --git a/paludis/unmerger.cc b/paludis/unmerger.cc
index e8ebc69..6d601e4 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 Ciaran McCreesh
+ * Copyright (c) 2007, 2008 Ciaran McCreesh
* Copyright (c) 2007 Piotr Jaroszyński
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -30,8 +30,6 @@
using namespace paludis;
-#include <paludis/unmerger-sr.cc>
-
namespace paludis
{
template<>
@@ -79,10 +77,10 @@ Unmerger::unmerge()
{
populate_unmerge_set();
- if (0 != _imp->options.environment->perform_hook(extend_hook(
+ if (0 != _imp->options[k::environment()]->perform_hook(extend_hook(
Hook("unmerger_unlink_pre")
- ("UNLINK_TARGET", stringify(_imp->options.root)))).max_exit_status)
- throw UnmergerError("Unmerge from '" + stringify(_imp->options.root) + "' aborted by hook");
+ ("UNLINK_TARGET", stringify(_imp->options[k::root()])))).max_exit_status)
+ throw UnmergerError("Unmerge from '" + stringify(_imp->options[k::root()]) + "' aborted by hook");
for (UnmergeEntriesIterator i(_imp->unmerge_entries.rbegin()), i_end(_imp->unmerge_entries.rend()) ; i != i_end ; ++i)
{
@@ -113,18 +111,18 @@ Unmerger::unmerge()
throw InternalError(PALUDIS_HERE, "Unexpected entry_type '" + stringify((*i).second.first) + "'");
}
- if (0 != _imp->options.environment->perform_hook(extend_hook(
+ if (0 != _imp->options[k::environment()]->perform_hook(extend_hook(
Hook("unmerger_unlink_post")
- ("UNLINK_TARGET", stringify(_imp->options.root)))).max_exit_status)
- throw UnmergerError("Unmerge from '" + stringify(_imp->options.root) + "' aborted by hook");
+ ("UNLINK_TARGET", stringify(_imp->options[k::root()])))).max_exit_status)
+ throw UnmergerError("Unmerge from '" + stringify(_imp->options[k::root()]) + "' aborted by hook");
}
void
Unmerger::unmerge_file(FSEntry & f, tr1::shared_ptr<ExtraInfo> ei) const
{
- FSEntry f_real(_imp->options.root / f);
+ FSEntry f_real(_imp->options[k::root()] / f);
- HookResult hr(_imp->options.environment->perform_hook(extend_hook(
+ HookResult hr(_imp->options[k::environment()]->perform_hook(extend_hook(
Hook("unmerger_unlink_file_override")
("UNLINK_TARGET", stringify(f_real))
.grab_output(Hook::AllowedOutputValues()("skip")("force")))));
@@ -148,9 +146,9 @@ Unmerger::unmerge_file(FSEntry & f, tr1::shared_ptr<ExtraInfo> ei) const
void
Unmerger::unmerge_sym(FSEntry & f, tr1::shared_ptr<ExtraInfo> ei) const
{
- FSEntry f_real(_imp->options.root / f);
+ FSEntry f_real(_imp->options[k::root()] / f);
- HookResult hr(_imp->options.environment->perform_hook(extend_hook(
+ HookResult hr(_imp->options[k::environment()]->perform_hook(extend_hook(
Hook("unmerger_unlink_sym_override")
("UNLINK_TARGET", stringify(f_real))
.grab_output(Hook::AllowedOutputValues()("skip")("force")))));
@@ -174,9 +172,9 @@ Unmerger::unmerge_sym(FSEntry & f, tr1::shared_ptr<ExtraInfo> ei) const
void
Unmerger::unmerge_dir(FSEntry & f, tr1::shared_ptr<ExtraInfo> ei) const
{
- FSEntry f_real(_imp->options.root / f);
+ FSEntry f_real(_imp->options[k::root()] / f);
- HookResult hr(_imp->options.environment->perform_hook(extend_hook(
+ HookResult hr(_imp->options[k::environment()]->perform_hook(extend_hook(
Hook("unmerger_unlink_dir_override")
("UNLINK_TARGET", stringify(f_real))
.grab_output(Hook::AllowedOutputValues()("skip")))));
@@ -195,9 +193,9 @@ Unmerger::unmerge_dir(FSEntry & f, tr1::shared_ptr<ExtraInfo> ei) const
void
Unmerger::unmerge_misc(FSEntry & f, tr1::shared_ptr<ExtraInfo> ei) const
{
- FSEntry f_real(_imp->options.root / f);
+ FSEntry f_real(_imp->options[k::root()] / f);
- HookResult hr(_imp->options.environment->perform_hook(extend_hook(
+ HookResult hr(_imp->options[k::environment()]->perform_hook(extend_hook(
Hook("unmerger_unlink_misc_override")
("UNLINK_TARGET", stringify(f_real))
.grab_output(Hook::AllowedOutputValues()("skip")("force")))));
@@ -221,7 +219,7 @@ Unmerger::unmerge_misc(FSEntry & f, tr1::shared_ptr<ExtraInfo> ei) const
void
Unmerger::unlink_file(FSEntry & f, tr1::shared_ptr<ExtraInfo>) const
{
- if (0 != _imp->options.environment->perform_hook(extend_hook(
+ if (0 != _imp->options[k::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");
@@ -238,7 +236,7 @@ Unmerger::unlink_file(FSEntry & f, tr1::shared_ptr<ExtraInfo>) const
f.unlink();
- if (0 != _imp->options.environment->perform_hook(extend_hook(
+ if (0 != _imp->options[k::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");
@@ -247,14 +245,14 @@ Unmerger::unlink_file(FSEntry & f, tr1::shared_ptr<ExtraInfo>) const
void
Unmerger::unlink_sym(FSEntry & f, tr1::shared_ptr<ExtraInfo>) const
{
- if (0 != _imp->options.environment->perform_hook(extend_hook(
+ if (0 != _imp->options[k::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");
f.unlink();
- if (0 != _imp->options.environment->perform_hook(extend_hook(
+ if (0 != _imp->options[k::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");
@@ -263,14 +261,14 @@ Unmerger::unlink_sym(FSEntry & f, tr1::shared_ptr<ExtraInfo>) const
void
Unmerger::unlink_dir(FSEntry & f, tr1::shared_ptr<ExtraInfo>) const
{
- if (0 != _imp->options.environment->perform_hook(extend_hook(
+ if (0 != _imp->options[k::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");
f.rmdir();
- if (0 != _imp->options.environment->perform_hook(extend_hook(
+ if (0 != _imp->options[k::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");
@@ -279,14 +277,14 @@ Unmerger::unlink_dir(FSEntry & f, tr1::shared_ptr<ExtraInfo>) const
void
Unmerger::unlink_misc(FSEntry & f, tr1::shared_ptr<ExtraInfo>) const
{
- if (0 != _imp->options.environment->perform_hook(extend_hook(
+ if (0 != _imp->options[k::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");
f.unlink();
- if (0 != _imp->options.environment->perform_hook(extend_hook(
+ if (0 != _imp->options[k::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");
@@ -296,6 +294,6 @@ Hook
Unmerger::extend_hook(const Hook & h) const
{
return h
- ("ROOT", stringify(_imp->options.root));
+ ("ROOT", stringify(_imp->options[k::root()]));
}
diff --git a/paludis/unmerger.hh b/paludis/unmerger.hh
index 544d9d4..4eec08e 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 Ciaran McCreesh
+ * Copyright (c) 2007, 2008 Ciaran McCreesh
* Copyright (c) 2007 Piotr Jaroszyński
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -23,8 +23,9 @@
#include <paludis/util/exception.hh>
#include <paludis/util/fs_entry.hh>
-#include <paludis/util/sr.hh>
#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/kc.hh>
+#include <paludis/util/keys.hh>
#include <paludis/merger_entry_type.hh>
/** \file
@@ -43,7 +44,17 @@ namespace paludis
class Hook;
class Environment;
-#include <paludis/unmerger-sr.hh>
+ /**
+ * Options for a basic Unmerger.
+ *
+ * \see Unmerger
+ * \ingroup g_repository
+ * \nosubgrouping
+ */
+ typedef kc::KeyedClass<
+ kc::Field<k::environment, const Environment *>,
+ kc::Field<k::root, FSEntry>
+ > UnmergerOptions;
/**
* Thrown if an error occurs during an unmerge.
diff --git a/paludis/unmerger.sr b/paludis/unmerger.sr
deleted file mode 100644
index fd61ae1..0000000
--- a/paludis/unmerger.sr
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-# vim: set sw=4 sts=4 et :
-
-make_class_UnmergerOptions()
-{
- visible
-
- key environment "const Environment *"
- key root "FSEntry"
-
- allow_named_args
-
- doxygen_comment << "END"
- /**
- * Options for a basic Unmerger.
- *
- * \see Unmerger
- * \ingroup g_repository
- * \nosubgrouping
- */
-END
-}
-
diff --git a/paludis/util/kc.hh b/paludis/util/kc.hh
index 5ccc311..60bac08 100644
--- a/paludis/util/kc.hh
+++ b/paludis/util/kc.hh
@@ -83,7 +83,7 @@ namespace paludis
template <unsigned id_, typename T_>
struct NamedField<true, Field<Key<id_>, T_> >
{
- const T_ & value;
+ T_ value;
NamedField(const T_ & v) :
value(v)
diff --git a/paludis/util/keys.hh b/paludis/util/keys.hh
index 4998ba8..38555f3 100644
--- a/paludis/util/keys.hh
+++ b/paludis/util/keys.hh
@@ -59,6 +59,15 @@ namespace paludis
typedef kc::Key<31> value;
typedef kc::Key<32> mask_file;
typedef kc::Key<33> comment;
+ typedef kc::Key<34> environment;
+ typedef kc::Key<35> image;
+ typedef kc::Key<36> root;
+ typedef kc::Key<37> no_chown;
+ typedef kc::Key<38> options;
+ typedef kc::Key<39> contents_file;
+ typedef kc::Key<40> config_protect;
+ typedef kc::Key<41> config_protect_mask;
+ typedef kc::Key<42> package_id;
}
}