aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-02-13 13:23:51 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-02-13 13:23:51 +0000
commit326664dfc0b65ce8b36de1a758225ed41e8a49e5 (patch)
treefa9c84d180bce494747fc29fcece266c4b6de76d
parentc62b7ee2842cc48bcbb211dadab2b914e26bfa7d (diff)
downloadpaludis-326664dfc0b65ce8b36de1a758225ed41e8a49e5.tar.gz
paludis-326664dfc0b65ce8b36de1a758225ed41e8a49e5.tar.xz
Common unmerger base class. Add hooks for merge actions
-rw-r--r--hooks/Makefile.am.m430
-rw-r--r--paludis/merger/Makefile.am19
-rw-r--r--paludis/merger/merger.cc236
-rw-r--r--paludis/merger/merger.hh3
-rw-r--r--paludis/merger/unmerger.cc118
-rw-r--r--paludis/merger/unmerger.hh61
-rw-r--r--paludis/merger/unmerger.sr21
-rw-r--r--paludis/repositories/gentoo/vdb_unmerger.cc21
-rw-r--r--paludis/repositories/gentoo/vdb_unmerger.hh6
9 files changed, 437 insertions, 78 deletions
diff --git a/hooks/Makefile.am.m4 b/hooks/Makefile.am.m4
index 7dcf0bf..43c0860 100644
--- a/hooks/Makefile.am.m4
+++ b/hooks/Makefile.am.m4
@@ -124,11 +124,41 @@ userhook(`ebuild_prerm_post')
userhook(`ebuild_postrm_pre')
userhook(`ebuild_postrm_fail')
userhook(`ebuild_postrm_post')
+
userhook(`einfo')
userhook(`ewarn')
userhook(`eerror')
userhook(`elog')
+userhook(`merger_unlink_file_pre')
+userhook(`merger_unlink_file_post')
+userhook(`merger_unlink_dir_pre')
+userhook(`merger_unlink_dir_post')
+userhook(`merger_unlink_sym_pre')
+userhook(`merger_unlink_sym_post')
+userhook(`merger_unlink_misc_pre')
+userhook(`merger_unlink_misc_post')
+userhook(`merger_install_file_pre')
+userhook(`merger_install_file_post')
+userhook(`merger_install_sym_pre')
+userhook(`merger_install_sym_post')
+userhook(`merger_install_dir_pre')
+userhook(`merger_install_dir_post')
+userhook(`merger_check_file_pre')
+userhook(`merger_check_file_post')
+userhook(`merger_check_sym_pre')
+userhook(`merger_check_sym_post')
+userhook(`merger_check_dir_pre')
+userhook(`merger_check_dir_post')
+userhook(`unmerger_unlink_file_pre')
+userhook(`unmerger_unlink_file_post')
+userhook(`unmerger_unlink_dir_pre')
+userhook(`unmerger_unlink_dir_post')
+userhook(`unmerger_unlink_sym_pre')
+userhook(`unmerger_unlink_sym_post')
+userhook(`unmerger_unlink_misc_pre')
+userhook(`unmerger_unlink_misc_post')
+
define(`systemhook', `
installsystemhooks$1dir = $(libexecdir)/paludis/hooks/$1
installsystemhooks$1_DATA = .keep')
diff --git a/paludis/merger/Makefile.am b/paludis/merger/Makefile.am
index c3d336a..8746e10 100644
--- a/paludis/merger/Makefile.am
+++ b/paludis/merger/Makefile.am
@@ -1,7 +1,8 @@
CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda
DISTCLEANFILES = \
- merger-sr.hh merger-sr.cc merger-se.hh merger-se.cc
+ merger-sr.hh merger-sr.cc merger-se.hh merger-se.cc \
+ unmerger-sr.hh unmerger-sr.cc
BUILT_SOURCES = $(DISTCLEANFILES)
MAINTAINERCLEANFILES = Makefile.in
@@ -17,10 +18,13 @@ paludis_merger_includedir = $(includedir)/paludis/merger
paludis_merger_include_HEADERS = \
merger.hh \
merger-sr.hh \
- merger-se.cc
+ merger-se.hh \
+ unmerger.hh \
+ unmerger-sr.hh
libpaludismerger_la_SOURCES = \
- merger.cc merger.hh
+ merger.cc merger.hh \
+ unmerger.cc unmerger.hh
libpaludismerger_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0
@@ -34,7 +38,8 @@ lib_LTLIBRARIES = libpaludismerger.la
EXTRA_DIST = \
merger_TEST.cc merger_TEST_setup.sh merger_TEST_cleanup.sh \
merger-sr.hh merger-sr.cc merger.sr \
- merger-se.hh merger-se.cc merger.se
+ merger-se.hh merger-se.cc merger.se \
+ unmerger-sr.hh unmerger-sr.cc unmerger.sr
TESTS = \
merger_TEST
@@ -67,6 +72,12 @@ merger-sr.hh : merger.sr $(top_srcdir)/misc/make_sr.bash
merger-sr.cc : merger.sr $(top_srcdir)/misc/make_sr.bash
if ! $(top_srcdir)/misc/make_sr.bash --source $(srcdir)/merger.sr > $@ ; then rm -f $@ ; exit 1 ; fi
+unmerger-sr.hh : unmerger.sr $(top_srcdir)/misc/make_sr.bash
+ if ! $(top_srcdir)/misc/make_sr.bash --header $(srcdir)/unmerger.sr > $@ ; then rm -f $@ ; exit 1 ; fi
+
+unmerger-sr.cc : unmerger.sr $(top_srcdir)/misc/make_sr.bash
+ if ! $(top_srcdir)/misc/make_sr.bash --source $(srcdir)/unmerger.sr > $@ ; then rm -f $@ ; exit 1 ; fi
+
merger-se.hh : merger.se $(top_srcdir)/misc/make_se.bash
if ! $(top_srcdir)/misc/make_se.bash --header $(srcdir)/merger.se > $@ ; then rm -f $@ ; exit 1 ; fi
diff --git a/paludis/merger/merger.cc b/paludis/merger/merger.cc
index eba3a26..18644c4 100644
--- a/paludis/merger/merger.cc
+++ b/paludis/merger/merger.cc
@@ -22,6 +22,7 @@
#include <paludis/util/stringify.hh>
#include <paludis/util/fd_holder.hh>
#include <paludis/selinux/security_context.hh>
+#include <paludis/environment.hh>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -157,33 +158,48 @@ Merger::on_file(bool is_check, const FSEntry & src, const FSEntry & dst)
{
MergerEntryType m(entry_type(dst / src.basename()));
- switch (m)
+ if (is_check)
+ _options.environment->perform_hook(extend_hook(
+ Hook("merger_check_file_pre")
+ ("INSTALL_SOURCE", stringify(src))
+ ("INSTALL_DESTINATION", stringify(dst / src.basename()))));
+
+ do
{
- case met_nothing:
- on_file_over_nothing(is_check, src, dst);
- return;
+ switch (m)
+ {
+ case met_nothing:
+ on_file_over_nothing(is_check, src, dst);
+ continue;
- case met_sym:
- on_file_over_sym(is_check, src, dst);
- return;
+ case met_sym:
+ on_file_over_sym(is_check, src, dst);
+ continue;
+
+ case met_dir:
+ on_file_over_dir(is_check, src, dst);
+ continue;
- case met_dir:
- on_file_over_dir(is_check, src, dst);
- return;
+ case met_misc:
+ on_file_over_misc(is_check, src, dst);
+ continue;
- case met_misc:
- on_file_over_misc(is_check, src, dst);
- return;
+ case met_file:
+ on_file_over_file(is_check, src, dst);
+ continue;
- case met_file:
- on_file_over_file(is_check, src, dst);
- return;
+ case last_met:
+ ;
+ }
- case last_met:
- ;
- }
+ throw InternalError(PALUDIS_HERE, "Unexpected entry_type '" + stringify(m) + "'");
+ } while (false);
- throw InternalError(PALUDIS_HERE, "Unexpected entry_type '" + stringify(m) + "'");
+ if (is_check)
+ _options.environment->perform_hook(extend_hook(
+ Hook("merger_check_file_post")
+ ("INSTALL_SOURCE", stringify(src))
+ ("INSTALL_DESTINATION", stringify(dst / src.basename()))));
}
void
@@ -191,33 +207,49 @@ Merger::on_dir(bool is_check, const FSEntry & src, const FSEntry & dst)
{
MergerEntryType m(entry_type(dst / src.basename()));
- switch (m)
+ if (is_check)
+ _options.environment->perform_hook(extend_hook(
+ Hook("merger_check_dir_pre")
+ ("INSTALL_SOURCE", stringify(src))
+ ("INSTALL_DESTINATION", stringify(dst / src.basename()))));
+
+ do
{
- case met_nothing:
- on_dir_over_nothing(is_check, src, dst);
- return;
+ switch (m)
+ {
+ case met_nothing:
+ on_dir_over_nothing(is_check, src, dst);
+ continue;
+
+ case met_sym:
+ on_dir_over_sym(is_check, src, dst);
+ continue;
- case met_sym:
- on_dir_over_sym(is_check, src, dst);
- return;
+ case met_dir:
+ on_dir_over_dir(is_check, src, dst);
+ continue;
- case met_dir:
- on_dir_over_dir(is_check, src, dst);
- return;
+ case met_misc:
+ on_dir_over_misc(is_check, src, dst);
+ continue;
- case met_misc:
- on_dir_over_misc(is_check, src, dst);
- return;
+ case met_file:
+ on_dir_over_file(is_check, src, dst);
+ continue;
- case met_file:
- on_dir_over_file(is_check, src, dst);
- return;
+ case last_met:
+ ;
+ }
- case last_met:
- ;
- }
+ throw InternalError(PALUDIS_HERE, "Unexpected entry_type '" + stringify(m) + "'");
+
+ } while (false);
- throw InternalError(PALUDIS_HERE, "Unexpected entry_type '" + stringify(m) + "'");
+ if (is_check)
+ _options.environment->perform_hook(extend_hook(
+ Hook("merger_check_dir_post")
+ ("INSTALL_SOURCE", stringify(src))
+ ("INSTALL_DESTINATION", stringify(dst / src.basename()))));
}
void
@@ -225,33 +257,48 @@ Merger::on_sym(bool is_check, const FSEntry & src, const FSEntry & dst)
{
MergerEntryType m(entry_type(dst / src.basename()));
- switch (m)
+ if (is_check)
+ _options.environment->perform_hook(extend_hook(
+ Hook("merger_check_sym_post")
+ ("INSTALL_SOURCE", stringify(src))
+ ("INSTALL_DESTINATION", stringify(dst / src.basename()))));
+
+ do
{
- case met_nothing:
- on_sym_over_nothing(is_check, src, dst);
- return;
+ switch (m)
+ {
+ case met_nothing:
+ on_sym_over_nothing(is_check, src, dst);
+ continue;
- case met_sym:
- on_sym_over_sym(is_check, src, dst);
- return;
+ case met_sym:
+ on_sym_over_sym(is_check, src, dst);
+ continue;
- case met_dir:
- on_sym_over_dir(is_check, src, dst);
- return;
+ case met_dir:
+ on_sym_over_dir(is_check, src, dst);
+ continue;
- case met_misc:
- on_sym_over_misc(is_check, src, dst);
- return;
+ case met_misc:
+ on_sym_over_misc(is_check, src, dst);
+ continue;
- case met_file:
- on_sym_over_file(is_check, src, dst);
- return;
+ case met_file:
+ on_sym_over_file(is_check, src, dst);
+ continue;
- case last_met:
- ;
- }
+ case last_met:
+ ;
+ }
+
+ throw InternalError(PALUDIS_HERE, "Unexpected entry_type '" + stringify(m) + "'");
+ } while (false);
- throw InternalError(PALUDIS_HERE, "Unexpected entry_type '" + stringify(m) + "'");
+ if (is_check)
+ _options.environment->perform_hook(extend_hook(
+ Hook("merger_check_sym_post")
+ ("INSTALL_SOURCE", stringify(src))
+ ("INSTALL_DESTINATION", stringify(dst / src.basename()))));
}
void
@@ -443,6 +490,11 @@ Merger::on_sym_over_misc(bool is_check, const FSEntry & src, const FSEntry & dst
void
Merger::install_file(const FSEntry & src, const FSEntry & dst_dir, const std::string & dst_name)
{
+ _options.environment->perform_hook(extend_hook(
+ Hook("merger_install_file_pre")
+ ("INSTALL_SOURCE", stringify(src))
+ ("INSTALL_DESTINATION", stringify(dst_dir / src.basename()))));
+
FSCreateCon createcon(MatchPathCon::get_instance()->match(stringify(dst_dir/dst_name), src.permissions()));
FDHolder input_fd(::open(stringify(src).c_str(), O_RDONLY), false);
if (-1 == input_fd)
@@ -464,11 +516,21 @@ Merger::install_file(const FSEntry & src, const FSEntry & dst_dir, const std::st
ssize_t count;
while ((count = read(input_fd, buf, 4096)) > 0)
write(output_fd, buf, count);
+
+ _options.environment->perform_hook(extend_hook(
+ Hook("merger_install_file_post")
+ ("INSTALL_SOURCE", stringify(src))
+ ("INSTALL_DESTINATION", stringify(dst_dir / src.basename()))));
}
void
Merger::install_dir(const FSEntry & src, const FSEntry & dst_dir)
{
+ _options.environment->perform_hook(extend_hook(
+ Hook("merger_install_dir_pre")
+ ("INSTALL_SOURCE", stringify(src))
+ ("INSTALL_DESTINATION", stringify(dst_dir / src.basename()))));
+
mode_t mode(src.permissions());
FSEntry dst(dst_dir / src.basename());
FSCreateCon createcon(MatchPathCon::get_instance()->match(stringify(dst), mode));
@@ -476,19 +538,38 @@ Merger::install_dir(const FSEntry & src, const FSEntry & dst_dir)
dst.chown(src.owner(), src.group());
/* pick up set*id bits */
dst.chmod(src.permissions());
+
+ _options.environment->perform_hook(extend_hook(
+ Hook("merger_install_dir_post")
+ ("INSTALL_SOURCE", stringify(src))
+ ("INSTALL_DESTINATION", stringify(dst_dir / src.basename()))));
}
void
Merger::install_sym(const FSEntry & src, const FSEntry & dst_dir)
{
+ _options.environment->perform_hook(extend_hook(
+ Hook("merger_install_sym_pre")
+ ("INSTALL_SOURCE", stringify(src))
+ ("INSTALL_DESTINATION", stringify(dst_dir / src.basename()))));
+
FSCreateCon createcon(MatchPathCon::get_instance()->match(stringify(dst_dir / src.basename()), S_IFLNK));
if (0 != ::symlink(stringify(src.readlink()).c_str(), stringify(dst_dir / src.basename()).c_str()))
throw MergerError("Couldn't create symlink at '" + stringify(dst_dir / src.basename()) + "'");
+
+ _options.environment->perform_hook(extend_hook(
+ Hook("merger_install_sym_post")
+ ("INSTALL_SOURCE", stringify(src))
+ ("INSTALL_DESTINATION", stringify(dst_dir / src.basename()))));
}
void
Merger::unlink_file(FSEntry d)
{
+ _options.environment->perform_hook(extend_hook(
+ Hook("merger_unlink_file_pre")
+ ("UNLINK_TARGET", stringify(d))));
+
if (d.is_regular_file())
{
mode_t mode(d.permissions());
@@ -500,24 +581,59 @@ Merger::unlink_file(FSEntry d)
}
d.unlink();
+
+ _options.environment->perform_hook(extend_hook(
+ Hook("merger_unlink_file_post")
+ ("UNLINK_TARGET", stringify(d))));
}
void
Merger::unlink_sym(FSEntry d)
{
+ _options.environment->perform_hook(extend_hook(
+ Hook("merger_unlink_sym_pre")
+ ("UNLINK_TARGET", stringify(d))));
+
d.unlink();
+
+ _options.environment->perform_hook(extend_hook(
+ Hook("merger_unlink_sym_post")
+ ("UNLINK_TARGET", stringify(d))));
}
void
Merger::unlink_dir(FSEntry d)
{
+ _options.environment->perform_hook(extend_hook(
+ Hook("merger_unlink_dir_pre")
+ ("UNLINK_TARGET", stringify(d))));
+
d.rmdir();
+
+ _options.environment->perform_hook(extend_hook(
+ Hook("merger_unlink_dir_post")
+ ("UNLINK_TARGET", stringify(d))));
}
void
Merger::unlink_misc(FSEntry d)
{
+ _options.environment->perform_hook(extend_hook(
+ Hook("merger_unlink_misc_pre")
+ ("UNLINK_TARGET", stringify(d))));
+
d.unlink();
+
+ _options.environment->perform_hook(extend_hook(
+ Hook("merger_unlink_misc_post")
+ ("UNLINK_TARGET", stringify(d))));
}
+Hook
+Merger::extend_hook(const Hook & h)
+{
+ return h
+ ("ROOT", stringify(_options.root))
+ ("IMAGE", stringify(_options.image));
+}
diff --git a/paludis/merger/merger.hh b/paludis/merger/merger.hh
index 527b046..098f182 100644
--- a/paludis/merger/merger.hh
+++ b/paludis/merger/merger.hh
@@ -28,6 +28,7 @@
namespace paludis
{
class Environment;
+ class Hook;
#include <paludis/merger/merger-se.hh>
#include <paludis/merger/merger-sr.hh>
@@ -50,6 +51,8 @@ namespace paludis
void make_check_fail();
+ virtual Hook extend_hook(const Hook &);
+
virtual MergerEntryType entry_type(const FSEntry &);
virtual void do_dir_recursive(bool is_check, const FSEntry &, const FSEntry &);
diff --git a/paludis/merger/unmerger.cc b/paludis/merger/unmerger.cc
new file mode 100644
index 0000000..37fc695
--- /dev/null
+++ b/paludis/merger/unmerger.cc
@@ -0,0 +1,118 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "unmerger.hh"
+#include <paludis/environment.hh>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+using namespace paludis;
+
+#include <paludis/merger/unmerger-sr.cc>
+
+UnmergerError::UnmergerError(const std::string & s) throw () :
+ Exception(s)
+{
+}
+
+Unmerger::Unmerger(const UnmergerOptions & o) :
+ _options(o)
+{
+}
+
+Unmerger::~Unmerger()
+{
+}
+
+void
+Unmerger::unlink_file(FSEntry d)
+{
+ _options.environment->perform_hook(extend_hook(
+ Hook("unmerger_unlink_file_pre")
+ ("UNLINK_TARGET", stringify(d))));
+
+ if (d.is_regular_file())
+ {
+ mode_t mode(d.permissions());
+ if ((mode & S_ISUID) || (mode & S_ISGID))
+ {
+ mode &= 0400;
+ d.chmod(mode);
+ }
+ }
+
+ d.unlink();
+
+ _options.environment->perform_hook(extend_hook(
+ Hook("unmerger_unlink_file_post")
+ ("UNLINK_TARGET", stringify(d))));
+}
+
+void
+Unmerger::unlink_sym(FSEntry d)
+{
+ _options.environment->perform_hook(extend_hook(
+ Hook("unmerger_unlink_sym_pre")
+ ("UNLINK_TARGET", stringify(d))));
+
+ d.unlink();
+
+ _options.environment->perform_hook(extend_hook(
+ Hook("unmerger_unlink_sym_post")
+ ("UNLINK_TARGET", stringify(d))));
+}
+
+void
+Unmerger::unlink_dir(FSEntry d)
+{
+ _options.environment->perform_hook(extend_hook(
+ Hook("unmerger_unlink_dir_pre")
+ ("UNLINK_TARGET", stringify(d))));
+
+ d.rmdir();
+
+ _options.environment->perform_hook(extend_hook(
+ Hook("unmerger_unlink_dir_post")
+ ("UNLINK_TARGET", stringify(d))));
+}
+
+void
+Unmerger::unlink_misc(FSEntry d)
+{
+ _options.environment->perform_hook(extend_hook(
+ Hook("unmerger_unlink_misc_pre")
+ ("UNLINK_TARGET", stringify(d))));
+
+ d.unlink();
+
+ _options.environment->perform_hook(extend_hook(
+ Hook("unmerger_unlink_misc_post")
+ ("UNLINK_TARGET", stringify(d))));
+}
+
+Hook
+Unmerger::extend_hook(const Hook & h)
+{
+ return h
+ ("ROOT", stringify(_options.root));
+}
+
+
diff --git a/paludis/merger/unmerger.hh b/paludis/merger/unmerger.hh
new file mode 100644
index 0000000..2aff8a4
--- /dev/null
+++ b/paludis/merger/unmerger.hh
@@ -0,0 +1,61 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_MERGER_UNMERGER_HH
+#define PALUDIS_GUARD_PALUDIS_MERGER_UNMERGER_HH 1
+
+#include <paludis/util/exception.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/sr.hh>
+
+namespace paludis
+{
+ class Hook;
+ class Environment;
+
+#include <paludis/merger/unmerger-sr.hh>
+
+ class UnmergerError :
+ public Exception
+ {
+ public:
+ UnmergerError(const std::string & msg) throw ();
+ };
+
+ class Unmerger
+ {
+ private:
+ UnmergerOptions _options;
+
+ protected:
+ Unmerger(const UnmergerOptions &);
+
+ virtual Hook extend_hook(const Hook &);
+
+ virtual void unlink_file(FSEntry);
+ virtual void unlink_dir(FSEntry);
+ virtual void unlink_sym(FSEntry);
+ virtual void unlink_misc(FSEntry);
+
+ public:
+ virtual ~Unmerger();
+ };
+}
+
+#endif
diff --git a/paludis/merger/unmerger.sr b/paludis/merger/unmerger.sr
new file mode 100644
index 0000000..170452c
--- /dev/null
+++ b/paludis/merger/unmerger.sr
@@ -0,0 +1,21 @@
+#!/bin/bash
+# vim: set sw=4 sts=4 et :
+
+make_class_UnmergerOptions()
+{
+ key environment "Environment *"
+ key root "FSEntry"
+
+ allow_named_args
+
+ doxygen_comment << "END"
+ /**
+ * Options for a basic Unmerger.
+ *
+ * \see Unmerger
+ * \ingroup grpmerger
+ * \nosubgrouping
+ */
+END
+}
+
diff --git a/paludis/repositories/gentoo/vdb_unmerger.cc b/paludis/repositories/gentoo/vdb_unmerger.cc
index a101311..7179b90 100644
--- a/paludis/repositories/gentoo/vdb_unmerger.cc
+++ b/paludis/repositories/gentoo/vdb_unmerger.cc
@@ -56,7 +56,10 @@ namespace paludis
}
VDBUnmerger::VDBUnmerger(const VDBUnmergerOptions & o) :
- PrivateImplementationPattern<VDBUnmerger>(new Implementation<VDBUnmerger>(o))
+ PrivateImplementationPattern<VDBUnmerger>(new Implementation<VDBUnmerger>(o)),
+ Unmerger(UnmergerOptions::create()
+ .environment(o.environment)
+ .root(o.root))
{
}
@@ -156,13 +159,7 @@ VDBUnmerger::unmerge_non_directories(I_ cur, const I_ end)
else
{
std::cout << "<<< " << tokens.at(1) << std::endl;
- mode_t mode((_imp->options.root / tokens.at(1)).permissions());
- if ((mode & S_ISUID) || (mode & S_ISGID))
- {
- mode &= 0400;
- (_imp->options.root / tokens.at(1)).chmod(mode);
- }
- (_imp->options.root / tokens.at(1)).unlink();
+ unlink_file(_imp->options.root / tokens.at(1));
}
}
}
@@ -207,7 +204,7 @@ VDBUnmerger::unmerge_non_directories(I_ cur, const I_ end)
else
{
std::cout << "<<< " << tokens.at(1) << std::endl;
- (_imp->options.root / tokens.at(1)).unlink();
+ unlink_sym(_imp->options.root / tokens.at(1));
}
}
else if ("misc" == tokens.at(0))
@@ -235,7 +232,7 @@ VDBUnmerger::unmerge_non_directories(I_ cur, const I_ end)
else
{
std::cout << "<<< " << tokens.at(1) << std::endl;
- (_imp->options.root / tokens.at(1)).unlink();
+ unlink_misc(_imp->options.root / tokens.at(1));
}
}
else if ("dir" == tokens.at(0))
@@ -279,13 +276,13 @@ VDBUnmerger::unmerge_directories(I_ cur, const I_ end)
else
{
std::cout << "<<< " << tokens.at(1) << std::endl;
- (_imp->options.root / tokens.at(1)).rmdir();
+ unlink_dir(_imp->options.root / tokens.at(1));
}
}
}
VDBUnmergerError::VDBUnmergerError(const std::string & s) throw () :
- Exception(s)
+ UnmergerError(s)
{
}
diff --git a/paludis/repositories/gentoo/vdb_unmerger.hh b/paludis/repositories/gentoo/vdb_unmerger.hh
index 0e01b08..8e64332 100644
--- a/paludis/repositories/gentoo/vdb_unmerger.hh
+++ b/paludis/repositories/gentoo/vdb_unmerger.hh
@@ -23,6 +23,7 @@
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/sr.hh>
#include <paludis/util/fs_entry.hh>
+#include <paludis/merger/unmerger.hh>
namespace paludis
{
@@ -31,14 +32,15 @@ namespace paludis
#include <paludis/repositories/gentoo/vdb_unmerger-sr.hh>
class VDBUnmergerError :
- public Exception
+ public UnmergerError
{
public:
VDBUnmergerError(const std::string &) throw ();
};
class VDBUnmerger :
- private PrivateImplementationPattern<VDBUnmerger>
+ private PrivateImplementationPattern<VDBUnmerger>,
+ public Unmerger
{
protected:
bool config_protected(const FSEntry &);