aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Fernando J. Pereda <ferdy@ferdyx.org> 2008-08-30 12:06:45 +0000
committerAvatar Fernando J. Pereda <ferdy@ferdyx.org> 2008-09-02 16:17:54 +0000
commit73b0085bb9e598911b7651ef4aa40b6f1215f527 (patch)
treea58b80375b0d4b0df12a444721cde223b552a176
parentd98625c61d292ea5368d008fd88dcd9caf0019a1 (diff)
downloadpaludis-73b0085bb9e598911b7651ef4aa40b6f1215f527.tar.gz
paludis-73b0085bb9e598911b7651ef4aa40b6f1215f527.tar.xz
Pass and merge CONFIG_PROTECT from InstallAction to UninstallAction
Fixes: ticket:618
-rw-r--r--paludis/action-fwd.hh1
-rw-r--r--paludis/action.cc19
-rw-r--r--paludis/action.hh22
-rw-r--r--paludis/install_task.cc18
-rw-r--r--paludis/repositories/e/e_installed_repository.hh2
-rw-r--r--paludis/repositories/e/e_installed_repository_id.cc4
-rw-r--r--paludis/repositories/e/e_repository_TEST.cc22
-rw-r--r--paludis/repositories/e/ebuild_entries.cc3
-rw-r--r--paludis/repositories/e/exndbam_repository.cc13
-rw-r--r--paludis/repositories/e/exndbam_repository.hh2
-rw-r--r--paludis/repositories/e/exndbam_repository_TEST.cc11
-rw-r--r--paludis/repositories/e/vdb_repository.cc13
-rw-r--r--paludis/repositories/e/vdb_repository.hh2
-rw-r--r--paludis/repositories/e/vdb_repository_TEST.cc42
-rw-r--r--paludis/repositories/unpackaged/installed_repository_TEST.cc29
-rw-r--r--paludis/repositories/unpackaged/unpackaged_id.cc3
-rw-r--r--paludis/repositories/unpackaged/unpackaged_repository_TEST.cc13
-rw-r--r--paludis/repository.hh3
-rw-r--r--paludis/uninstall_task.cc6
-rw-r--r--python/action.cc39
-rwxr-xr-xpython/action_TEST.py2
-rw-r--r--ruby/action.cc129
-rw-r--r--ruby/action_TEST.rb10
23 files changed, 347 insertions, 61 deletions
diff --git a/paludis/action-fwd.hh b/paludis/action-fwd.hh
index a3ec657..85d3ad5 100644
--- a/paludis/action-fwd.hh
+++ b/paludis/action-fwd.hh
@@ -58,6 +58,7 @@ namespace paludis
struct FetchActionOptions;
struct InstallActionOptions;
+ struct UninstallActionOptions;
struct FetchActionFailure;
diff --git a/paludis/action.cc b/paludis/action.cc
index 3b76783..d151ace 100644
--- a/paludis/action.cc
+++ b/paludis/action.cc
@@ -80,7 +80,23 @@ FetchAction::~FetchAction()
{
}
-UninstallAction::UninstallAction()
+namespace paludis
+{
+ template <>
+ struct Implementation<UninstallAction>
+ {
+ const UninstallActionOptions options;
+
+ Implementation(const UninstallActionOptions & o) :
+ options(o)
+ {
+ }
+ };
+}
+
+UninstallAction::UninstallAction(const UninstallActionOptions & o) :
+ PrivateImplementationPattern<UninstallAction>(new Implementation<UninstallAction>(o)),
+ options(_imp->options)
{
}
@@ -312,6 +328,7 @@ template class PrivateImplementationPattern<FetchAction>;
template class PrivateImplementationPattern<InstallAction>;
template class PrivateImplementationPattern<PretendAction>;
template class PrivateImplementationPattern<PretendFetchAction>;
+template class PrivateImplementationPattern<UninstallAction>;
template class Sequence<FetchActionFailure>;
diff --git a/paludis/action.hh b/paludis/action.hh
index 62796be..6bd6518 100644
--- a/paludis/action.hh
+++ b/paludis/action.hh
@@ -30,6 +30,7 @@
#include <paludis/util/sequence-fwd.hh>
#include <paludis/util/named_value.hh>
#include <paludis/util/fs_entry-fwd.hh>
+#include <tr1/functional>
/** \file
* Declarations for action-related classes.
@@ -46,6 +47,7 @@ namespace paludis
namespace n
{
struct checks;
+ struct config_protect;
struct debug_build;
struct destination;
struct failed_automatic_fetching;
@@ -54,6 +56,7 @@ namespace paludis
struct requires_manual_fetching;
struct safe_resume;
struct target_file;
+ struct used_this_for_config_protect;
}
/**
@@ -81,6 +84,19 @@ namespace paludis
NamedValue<n::checks, InstallActionChecksOption> checks;
NamedValue<n::debug_build, InstallActionDebugOption> debug_build;
NamedValue<n::destination, std::tr1::shared_ptr<Repository> > destination;
+ NamedValue<n::used_this_for_config_protect, std::tr1::function<void (const std::string &)> > used_this_for_config_protect;
+ };
+
+ /**
+ * Options for an UninstallAction.
+ *
+ * \see UninstallAction
+ * \ingroup g_actions
+ * \since 0.30
+ */
+ struct UninstallActionOptions
+ {
+ NamedValue<n::config_protect, std::string> config_protect;
};
/**
@@ -225,16 +241,20 @@ namespace paludis
*/
class PALUDIS_VISIBLE UninstallAction :
public Action,
+ private PrivateImplementationPattern<UninstallAction>,
public AcceptInterfaceVisitsThis<ActionVisitorTypes, UninstallAction>
{
public:
///\name Basic operations
///\{
- UninstallAction();
+ UninstallAction(const UninstallActionOptions &);
~UninstallAction();
///\}
+
+ /// Options for the action.
+ const UninstallActionOptions & options;
};
/**
diff --git a/paludis/install_task.cc b/paludis/install_task.cc
index 683b399..7ce6205 100644
--- a/paludis/install_task.cc
+++ b/paludis/install_task.cc
@@ -70,6 +70,8 @@ namespace paludis
FetchActionOptions fetch_options;
InstallActionOptions install_options;
+ std::string config_protect;
+
std::list<std::string> raw_targets;
std::tr1::shared_ptr<ConstTreeSequence<SetSpecTree, AllDepSpec> > targets;
std::tr1::shared_ptr<std::string> add_to_world_spec;
@@ -100,8 +102,12 @@ namespace paludis
make_named_values<InstallActionOptions>(
value_for<n::checks>(iaco_default),
value_for<n::debug_build>(iado_none),
- value_for<n::destination>(std::tr1::shared_ptr<Repository>())
+ value_for<n::destination>(std::tr1::shared_ptr<Repository>()),
+ value_for<n::used_this_for_config_protect>(std::tr1::bind(
+ &Implementation<InstallTask>::assign_config_protect,
+ this, std::tr1::placeholders::_1))
)),
+ config_protect(""),
targets(new ConstTreeSequence<SetSpecTree, AllDepSpec>(std::tr1::shared_ptr<AllDepSpec>(new AllDepSpec))),
destinations(d),
pretend(false),
@@ -114,6 +120,11 @@ namespace paludis
had_resolution_failures(false)
{
}
+
+ void assign_config_protect(const std::string & s)
+ {
+ config_protect = s;
+ }
};
}
@@ -782,7 +793,10 @@ InstallTask::_one(const DepList::Iterator dep, const int x, const int y, const i
try
{
- UninstallAction uninstall_action;
+ UninstallAction uninstall_action(
+ make_named_values<UninstallActionOptions>(
+ value_for<n::config_protect>(_imp->config_protect)
+ ));
(*c)->perform_action(uninstall_action);
}
catch (const UninstallActionError & e)
diff --git a/paludis/repositories/e/e_installed_repository.hh b/paludis/repositories/e/e_installed_repository.hh
index 8a972ab..d23b7be 100644
--- a/paludis/repositories/e/e_installed_repository.hh
+++ b/paludis/repositories/e/e_installed_repository.hh
@@ -118,7 +118,7 @@ namespace paludis
///\{
virtual void perform_uninstall(const std::tr1::shared_ptr<const erepository::ERepositoryID> & id,
- bool reinstalling) const = 0;
+ bool reinstalling, const std::string & merge_config_protect) const = 0;
virtual void perform_config(const std::tr1::shared_ptr<const erepository::ERepositoryID> & id) const;
diff --git a/paludis/repositories/e/e_installed_repository_id.cc b/paludis/repositories/e/e_installed_repository_id.cc
index 1833871..c2f8e65 100644
--- a/paludis/repositories/e/e_installed_repository_id.cc
+++ b/paludis/repositories/e/e_installed_repository_id.cc
@@ -789,9 +789,9 @@ namespace
{
}
- void visit(const UninstallAction &)
+ void visit(const UninstallAction & a)
{
- std::tr1::static_pointer_cast<const EInstalledRepository>(id->repository())->perform_uninstall(id, false);
+ std::tr1::static_pointer_cast<const EInstalledRepository>(id->repository())->perform_uninstall(id, false, a.options.config_protect());
}
void visit(const InstalledAction &)
diff --git a/paludis/repositories/e/e_repository_TEST.cc b/paludis/repositories/e/e_repository_TEST.cc
index f4fd2be..4d80645 100644
--- a/paludis/repositories/e/e_repository_TEST.cc
+++ b/paludis/repositories/e/e_repository_TEST.cc
@@ -66,6 +66,10 @@ namespace
else
return mm->second;
}
+
+ void dummy_used_this_for_config_protect(const std::string &)
+ {
+ }
}
namespace test_cases
@@ -1041,7 +1045,8 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::checks>(iaco_default),
value_for<n::debug_build>(iado_none),
- value_for<n::destination>(installed_repo)
+ value_for<n::destination>(installed_repo),
+ value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect)
));
#ifdef ENABLE_VIRTUALS_REPOSITORY
@@ -1296,7 +1301,8 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::checks>(iaco_default),
value_for<n::debug_build>(iado_none),
- value_for<n::destination>(installed_repo)
+ value_for<n::destination>(installed_repo),
+ value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect)
));
{
@@ -1391,7 +1397,8 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::checks>(iaco_default),
value_for<n::debug_build>(iado_none),
- value_for<n::destination>(installed_repo)
+ value_for<n::destination>(installed_repo),
+ value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect)
));
{
@@ -1556,7 +1563,8 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::checks>(iaco_default),
value_for<n::debug_build>(iado_none),
- value_for<n::destination>(installed_repo)
+ value_for<n::destination>(installed_repo),
+ value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect)
));
{
@@ -1758,7 +1766,8 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::checks>(iaco_default),
value_for<n::debug_build>(iado_none),
- value_for<n::destination>(installed_repo)
+ value_for<n::destination>(installed_repo),
+ value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect)
));
{
@@ -2242,7 +2251,8 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::checks>(iaco_default),
value_for<n::debug_build>(iado_none),
- value_for<n::destination>(installed_repo)
+ value_for<n::destination>(installed_repo),
+ value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect)
));
const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
diff --git a/paludis/repositories/e/ebuild_entries.cc b/paludis/repositories/e/ebuild_entries.cc
index 528125a..149f042 100644
--- a/paludis/repositories/e/ebuild_entries.cc
+++ b/paludis/repositories/e/ebuild_entries.cc
@@ -635,7 +635,8 @@ EbuildEntries::install(const std::tr1::shared_ptr<const ERepositoryID> & id,
value_for<n::image_dir>(_imp->params.builddir / (stringify(id->name().category) + "-" +
stringify(id->name().package) + "-" + stringify(id->version())) / "image"),
value_for<n::options>(id->eapi()->supported()->merger_options()),
- value_for<n::package_id>(id)
+ value_for<n::package_id>(id),
+ value_for<n::used_this_for_config_protect>(o.used_this_for_config_protect())
));
}
else if (phase->option("strip"))
diff --git a/paludis/repositories/e/exndbam_repository.cc b/paludis/repositories/e/exndbam_repository.cc
index 7789f7e..d2f4054 100644
--- a/paludis/repositories/e/exndbam_repository.cc
+++ b/paludis/repositories/e/exndbam_repository.cc
@@ -383,6 +383,8 @@ ExndbamRepository::merge(const MergeParams & m)
value_for<n::root>(installed_root_key()->value())
));
+ (m.used_this_for_config_protect())(config_protect);
+
if (! merger.check())
{
for (DirIterator d(target_ver_dir, DirIteratorOptions() + dio_include_dotfiles), d_end
@@ -398,7 +400,7 @@ ExndbamRepository::merge(const MergeParams & m)
if (if_overwritten_id)
{
- perform_uninstall(std::tr1::static_pointer_cast<const ERepositoryID>(if_overwritten_id), true);
+ perform_uninstall(std::tr1::static_pointer_cast<const ERepositoryID>(if_overwritten_id), true, config_protect);
}
if (std::tr1::static_pointer_cast<const ERepositoryID>(m.package_id())
->eapi()->supported()->ebuild_phases()->ebuild_new_upgrade_phase_order())
@@ -409,7 +411,7 @@ ExndbamRepository::merge(const MergeParams & m)
{
std::tr1::shared_ptr<const ERepositoryID> candidate(std::tr1::static_pointer_cast<const ERepositoryID>(*it));
if (candidate != if_overwritten_id && candidate->slot() == m.package_id()->slot())
- perform_uninstall(candidate, false);
+ perform_uninstall(candidate, false, "");
}
}
@@ -422,7 +424,8 @@ ExndbamRepository::merge(const MergeParams & m)
}
void
-ExndbamRepository::perform_uninstall(const std::tr1::shared_ptr<const ERepositoryID> & id, bool replace) const
+ExndbamRepository::perform_uninstall(const std::tr1::shared_ptr<const ERepositoryID> & id,
+ bool replace, const std::string & merge_config_protect) const
{
Context context("When uninstalling '" + stringify(*id) + (replace ? "' for a reinstall:" : "':"));
@@ -454,10 +457,12 @@ ExndbamRepository::perform_uninstall(const std::tr1::shared_ptr<const ERepositor
" " + getenv_with_default("CONFIG_PROTECT_MASK", "");
}
+ std::string final_config_protect(config_protect + " " + merge_config_protect);
+
/* unmerge */
NDBAMUnmerger unmerger(
make_named_values<NDBAMUnmergerOptions>(
- value_for<n::config_protect>(config_protect),
+ value_for<n::config_protect>(final_config_protect),
value_for<n::config_protect_mask>(config_protect_mask),
value_for<n::contents_file>(ver_dir / "contents"),
value_for<n::environment>(_imp->params.environment),
diff --git a/paludis/repositories/e/exndbam_repository.hh b/paludis/repositories/e/exndbam_repository.hh
index 7a77d9b..d734a9d 100644
--- a/paludis/repositories/e/exndbam_repository.hh
+++ b/paludis/repositories/e/exndbam_repository.hh
@@ -102,7 +102,7 @@ namespace paludis
///\{
void perform_uninstall(const std::tr1::shared_ptr<const erepository::ERepositoryID> & id,
- bool reinstalling) const;
+ bool reinstalling, const std::string & merge_config_protect) const;
///\}
diff --git a/paludis/repositories/e/exndbam_repository_TEST.cc b/paludis/repositories/e/exndbam_repository_TEST.cc
index bdc8476..28be5d3 100644
--- a/paludis/repositories/e/exndbam_repository_TEST.cc
+++ b/paludis/repositories/e/exndbam_repository_TEST.cc
@@ -47,6 +47,10 @@ namespace
else
return mm->second;
}
+
+ void dummy_used_this_for_config_protect(const std::string &)
+ {
+ }
}
namespace test_cases
@@ -113,10 +117,13 @@ namespace test_cases
InstallAction install_action(make_named_values<InstallActionOptions>(
value_for<n::checks>(iaco_default),
value_for<n::debug_build>(iado_none),
- value_for<n::destination>(exndbam_repo)
+ value_for<n::destination>(exndbam_repo),
+ value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect)
));
- UninstallAction uninstall_action;
+ UninstallAction uninstall_action(make_named_values<UninstallActionOptions>(
+ value_for<n::config_protect>("")
+ ));
TEST_CHECK(exndbam_repo->package_ids(QualifiedPackageName("cat/pkg"))->empty());
diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc
index be7f276..7891da0 100644
--- a/paludis/repositories/e/vdb_repository.cc
+++ b/paludis/repositories/e/vdb_repository.cc
@@ -391,7 +391,8 @@ VDBRepositoryKeyReadError::VDBRepositoryKeyReadError(
}
void
-VDBRepository::perform_uninstall(const std::tr1::shared_ptr<const ERepositoryID> & id, bool reinstalling) const
+VDBRepository::perform_uninstall(const std::tr1::shared_ptr<const ERepositoryID> & id,
+ bool reinstalling, const std::string & merge_config_protect) const
{
Context context("When uninstalling '" + stringify(*id) + (reinstalling ? "' for a reinstall:" : "':"));
@@ -428,10 +429,12 @@ VDBRepository::perform_uninstall(const std::tr1::shared_ptr<const ERepositoryID>
" " + getenv_with_default("CONFIG_PROTECT_MASK", "");
}
+ std::string final_config_protect(config_protect + " " + merge_config_protect);
+
/* unmerge */
VDBUnmerger unmerger(
make_named_values<VDBUnmergerOptions>(
- value_for<n::config_protect>(config_protect),
+ 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"),
@@ -844,6 +847,8 @@ VDBRepository::merge(const MergeParams & m)
value_for<n::root>(installed_root_key()->value())
));
+ (m.used_this_for_config_protect())(config_protect);
+
if (! merger.check())
{
for (DirIterator d(tmp_vdb_dir, DirIteratorOptions() + dio_include_dotfiles), d_end ; d != d_end ; ++d)
@@ -871,7 +876,7 @@ VDBRepository::merge(const MergeParams & m)
merger.merge();
if (is_replace)
- perform_uninstall(is_replace, true);
+ perform_uninstall(is_replace, true, config_protect);
if (std::tr1::static_pointer_cast<const ERepositoryID>(m.package_id())
->eapi()->supported()->ebuild_phases()->ebuild_new_upgrade_phase_order())
{
@@ -881,7 +886,7 @@ VDBRepository::merge(const MergeParams & m)
{
std::tr1::shared_ptr<const ERepositoryID> candidate(std::tr1::static_pointer_cast<const ERepositoryID>(*it));
if (candidate != is_replace && candidate->slot() == m.package_id()->slot())
- perform_uninstall(candidate, false);
+ perform_uninstall(candidate, false, "");
}
}
diff --git a/paludis/repositories/e/vdb_repository.hh b/paludis/repositories/e/vdb_repository.hh
index 6610b98..3edc3d3 100644
--- a/paludis/repositories/e/vdb_repository.hh
+++ b/paludis/repositories/e/vdb_repository.hh
@@ -98,7 +98,7 @@ namespace paludis
virtual void regenerate_cache() const;
virtual void perform_uninstall(const std::tr1::shared_ptr<const erepository::ERepositoryID> & id,
- bool reinstalling) const;
+ bool reinstalling, const std::string & merge_config_protect) const;
/* RepositoryProvidesInterface */
diff --git a/paludis/repositories/e/vdb_repository_TEST.cc b/paludis/repositories/e/vdb_repository_TEST.cc
index 1e71c7c..a747436 100644
--- a/paludis/repositories/e/vdb_repository_TEST.cc
+++ b/paludis/repositories/e/vdb_repository_TEST.cc
@@ -59,6 +59,10 @@ namespace
else
return mm->second;
}
+
+ void dummy_used_this_for_config_protect(const std::string &)
+ {
+ }
}
namespace test_cases
@@ -337,10 +341,13 @@ namespace test_cases
InstallAction install_action(make_named_values<InstallActionOptions>(
value_for<n::checks>(iaco_default),
value_for<n::debug_build>(iado_none),
- value_for<n::destination>(vdb_repo)
+ value_for<n::destination>(vdb_repo),
+ value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect)
));
- UninstallAction uninstall_action;
+ UninstallAction uninstall_action(make_named_values<UninstallActionOptions>(
+ value_for<n::config_protect>("")
+ ));
InfoAction info_action;
ConfigAction config_action;
@@ -451,10 +458,13 @@ namespace test_cases
InstallAction install_action(make_named_values<InstallActionOptions>(
value_for<n::checks>(iaco_default),
value_for<n::debug_build>(iado_none),
- value_for<n::destination>(vdb_repo)
+ value_for<n::destination>(vdb_repo),
+ value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect)
));
- UninstallAction uninstall_action;
+ UninstallAction uninstall_action(make_named_values<UninstallActionOptions>(
+ value_for<n::config_protect>("")
+ ));
InfoAction info_action;
ConfigAction config_action;
@@ -565,10 +575,13 @@ namespace test_cases
InstallAction install_action(make_named_values<InstallActionOptions>(
value_for<n::checks>(iaco_default),
value_for<n::debug_build>(iado_none),
- value_for<n::destination>(vdb_repo)
+ value_for<n::destination>(vdb_repo),
+ value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect)
));
- UninstallAction uninstall_action;
+ UninstallAction uninstall_action(make_named_values<UninstallActionOptions>(
+ value_for<n::config_protect>("")
+ ));
{
std::vector<FSEntry> cache_contents;
@@ -954,10 +967,13 @@ namespace test_cases
InstallAction install_action(make_named_values<InstallActionOptions>(
value_for<n::checks>(iaco_default),
value_for<n::debug_build>(iado_none),
- value_for<n::destination>(vdb_repo)
+ value_for<n::destination>(vdb_repo),
+ value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect)
));
- UninstallAction uninstall_action;
+ UninstallAction uninstall_action(make_named_values<UninstallActionOptions>(
+ value_for<n::config_protect>("")
+ ));
TEST_CHECK_EQUAL(read_file(provides_cache), "paludis-3\ninstalled\n");
@@ -1189,7 +1205,8 @@ namespace test_cases
InstallAction install_action(make_named_values<InstallActionOptions>(
value_for<n::checks>(iaco_default),
value_for<n::debug_build>(iado_none),
- value_for<n::destination>(vdb_repo)
+ value_for<n::destination>(vdb_repo),
+ value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect)
));
TEST_CHECK(vdb_repo->package_ids(QualifiedPackageName("cat/pkg"))->empty());
@@ -1280,10 +1297,13 @@ namespace test_cases
InstallAction install_action(make_named_values<InstallActionOptions>(
value_for<n::checks>(iaco_default),
value_for<n::debug_build>(iado_none),
- value_for<n::destination>(vdb_repo)
+ value_for<n::destination>(vdb_repo),
+ value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect)
));
- UninstallAction uninstall_action;
+ UninstallAction uninstall_action(make_named_values<UninstallActionOptions>(
+ value_for<n::config_protect>("")
+ ));
TEST_CHECK(vdb_repo->package_ids(QualifiedPackageName("cat/pkg"))->empty());
diff --git a/paludis/repositories/unpackaged/installed_repository_TEST.cc b/paludis/repositories/unpackaged/installed_repository_TEST.cc
index d29355c..7ef9a18 100644
--- a/paludis/repositories/unpackaged/installed_repository_TEST.cc
+++ b/paludis/repositories/unpackaged/installed_repository_TEST.cc
@@ -79,6 +79,10 @@ namespace
s << "fifo<" << f.name() << ">";
}
};
+
+ void dummy_used_this_for_config_protect(const std::string &)
+ {
+ }
}
namespace test_cases
@@ -255,7 +259,9 @@ namespace test_cases
const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::All())]->begin());
- UninstallAction action;
+ UninstallAction action(make_named_values<UninstallActionOptions>(
+ value_for<n::config_protect>("")
+ ));
id->perform_action(action);
TEST_CHECK(! FSEntry("installed_repository_TEST_dir/root2/first").exists());
@@ -304,7 +310,9 @@ namespace test_cases
generator::Matches(parse_user_package_dep_spec("cat-one/foo:fred",
&env, UserPackageDepSpecOptions())))]->begin());
- UninstallAction action;
+ UninstallAction action(make_named_values<UninstallActionOptions>(
+ value_for<n::config_protect>("")
+ ));
id->perform_action(action);
TEST_CHECK(FSEntry("installed_repository_TEST_dir/repo3/indices/categories/cat-one/foo").is_symbolic_link());
@@ -388,7 +396,8 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::checks>(iaco_default),
value_for<n::debug_build>(iado_none),
- value_for<n::destination>(repo)
+ value_for<n::destination>(repo),
+ value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect)
));
(*env[selection::RequireExactlyOne(generator::InRepository(RepositoryName("unpackaged")))]->begin())->perform_action(action);
@@ -443,7 +452,8 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::checks>(iaco_default),
value_for<n::debug_build>(iado_none),
- value_for<n::destination>(repo)
+ value_for<n::destination>(repo),
+ value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect)
));
(*env[selection::RequireExactlyOne(generator::InRepository(RepositoryName("unpackaged")))]->begin())->perform_action(action);
@@ -501,7 +511,8 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::checks>(iaco_default),
value_for<n::debug_build>(iado_none),
- value_for<n::destination>(repo)
+ value_for<n::destination>(repo),
+ value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect)
));
(*env[selection::RequireExactlyOne(generator::InRepository(RepositoryName("unpackaged")))]->begin())->perform_action(action);
@@ -540,7 +551,9 @@ namespace test_cases
"cat/pkg4a-1.0:foo::installed-unpackaged cat/pkg4b-1.0:foo::installed-unpackaged");
}
- UninstallAction action;
+ UninstallAction action(make_named_values<UninstallActionOptions>(
+ value_for<n::config_protect>("")
+ ));
(*env[selection::RequireExactlyOne(generator::Matches(
parse_user_package_dep_spec("cat/pkg4a",
&env, UserPackageDepSpecOptions())))]->begin())->perform_action(action);
@@ -580,7 +593,9 @@ namespace test_cases
"cat/pkg4b-1.0:foo::installed-unpackaged");
}
- UninstallAction action;
+ UninstallAction action(make_named_values<UninstallActionOptions>(
+ value_for<n::config_protect>("")
+ ));
(*env[selection::RequireExactlyOne(generator::Matches(
parse_user_package_dep_spec("cat/pkg4b",
&env, UserPackageDepSpecOptions())))]->begin())->perform_action(action);
diff --git a/paludis/repositories/unpackaged/unpackaged_id.cc b/paludis/repositories/unpackaged/unpackaged_id.cc
index d51bde3..62bdf13 100644
--- a/paludis/repositories/unpackaged/unpackaged_id.cc
+++ b/paludis/repositories/unpackaged/unpackaged_id.cc
@@ -321,7 +321,8 @@ UnpackagedID::perform_action(Action & action) const
value_for<n::environment_file>(FSEntry("/dev/null")),
value_for<n::image_dir>(fs_location_key()->value()),
value_for<n::options>(MergerOptions() + mo_rewrite_symlinks + mo_allow_empty_dirs),
- value_for<n::package_id>(shared_from_this())
+ value_for<n::package_id>(shared_from_this()),
+ value_for<n::used_this_for_config_protect>(install_action->options.used_this_for_config_protect())
));
}
diff --git a/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc b/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc
index 5cbddbd..f9f88ae 100644
--- a/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc
+++ b/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc
@@ -40,6 +40,13 @@
using namespace test;
using namespace paludis;
+namespace
+{
+ void dummy_used_this_for_config_protect(const std::string &)
+ {
+ }
+}
+
namespace test_cases
{
struct MembersTest : TestCase
@@ -220,7 +227,8 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::checks>(iaco_default),
value_for<n::debug_build>(iado_none),
- value_for<n::destination>(installed_repo)
+ value_for<n::destination>(installed_repo),
+ value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect)
));
id->perform_action(action);
@@ -274,7 +282,8 @@ namespace test_cases
InstallAction action(make_named_values<InstallActionOptions>(
value_for<n::checks>(iaco_default),
value_for<n::debug_build>(iado_none),
- value_for<n::destination>(installed_repo)
+ value_for<n::destination>(installed_repo),
+ value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect)
));
id->perform_action(action);
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 2926345..638a248 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -39,6 +39,7 @@
#include <paludis/metadata_key_holder.hh>
#include <paludis/merger-fwd.hh>
#include <string>
+#include <tr1/functional>
/** \file
* Declarations for Repository classes.
@@ -76,6 +77,7 @@ namespace paludis
struct status;
struct syncable_interface;
struct use_interface;
+ struct used_this_for_config_protect;
struct virtual_name;
struct virtuals_interface;
}
@@ -161,6 +163,7 @@ namespace paludis
NamedValue<n::image_dir, FSEntry> image_dir;
NamedValue<n::options, MergerOptions> options;
NamedValue<n::package_id, std::tr1::shared_ptr<const PackageID> > package_id;
+ NamedValue<n::used_this_for_config_protect, std::tr1::function<void (const std::string &)> > used_this_for_config_protect;
};
/**
diff --git a/paludis/uninstall_task.cc b/paludis/uninstall_task.cc
index dddd72d..41321ab 100644
--- a/paludis/uninstall_task.cc
+++ b/paludis/uninstall_task.cc
@@ -35,6 +35,7 @@
#include <paludis/util/sequence.hh>
#include <paludis/util/wrapped_forward_iterator-impl.hh>
#include <paludis/util/options.hh>
+#include <paludis/util/make_named_values.hh>
#include <paludis/package_database.hh>
#include <paludis/hook.hh>
#include <paludis/dep_tag.hh>
@@ -358,7 +359,10 @@ UninstallTask::execute()
try
{
- UninstallAction uninstall_action;
+ UninstallAction uninstall_action(
+ make_named_values<UninstallActionOptions>(
+ value_for<n::config_protect>("")
+ ));
i->package_id->perform_action(uninstall_action);
}
catch (const UninstallActionError & e)
diff --git a/python/action.cc b/python/action.cc
index 3e74732..1666ba1 100644
--- a/python/action.cc
+++ b/python/action.cc
@@ -50,6 +50,10 @@ class class_supports_action_test :
namespace
{
+ void dummy_used_this_for_config_protect(const std::string &)
+ {
+ }
+
InstallActionOptions * make_install_action_options(
const InstallActionChecksOption & c, const InstallActionDebugOption & d,
const std::tr1::shared_ptr<paludis::Repository> & r)
@@ -57,7 +61,16 @@ namespace
return new InstallActionOptions(make_named_values<InstallActionOptions>(
value_for<n::checks>(c),
value_for<n::debug_build>(d),
- value_for<n::destination>(r)
+ value_for<n::destination>(r),
+ value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect)
+ ));
+ }
+
+ UninstallActionOptions * make_uninstall_action_options(
+ const std::string & c)
+ {
+ return new UninstallActionOptions(make_named_values<UninstallActionOptions>(
+ value_for<n::config_protect>(c)
));
}
@@ -145,6 +158,28 @@ void expose_action()
;
/**
+ * UninstallActionOptions
+ */
+ bp::class_<UninstallActionOptions>
+ (
+ "UninstallActionOptions",
+ "Options for UninstallAction.",
+ bp::no_init
+ )
+
+ .def("__init__",
+ bp::make_constructor(&make_uninstall_action_options),
+ "__init__(String)"
+ )
+
+ .add_property("config_protect",
+ &named_values_getter<UninstallActionOptions, n::config_protect, std::string, &UninstallActionOptions::config_protect>,
+ &named_values_setter<UninstallActionOptions, n::config_protect, std::string, &UninstallActionOptions::config_protect>,
+ "[rw] String"
+ )
+ ;
+
+ /**
* FetchActionOptions
*/
bp::class_<FetchActionOptions>
@@ -212,7 +247,7 @@ void expose_action()
(
"UninstallAction",
"An UninstallAction is used by UninstallTask to uninstall a PackageID.",
- bp::init<>("__init__()")
+ bp::init<const UninstallActionOptions &>("__init__(UninstallActionOptions)")
);
/**
diff --git a/python/action_TEST.py b/python/action_TEST.py
index a8a30fe..42f8953 100755
--- a/python/action_TEST.py
+++ b/python/action_TEST.py
@@ -81,7 +81,7 @@ class TestCase_05_FetchAction(unittest.TestCase):
class TestCase_06_UninstallAction(unittest.TestCase):
def test_01_create(self):
- UninstallAction()
+ UninstallAction(UninstallActionOptions("monkey"))
class TestCase_07_InstalledAction(unittest.TestCase):
def test_01_create(self):
diff --git a/ruby/action.cc b/ruby/action.cc
index 0300890..a296f02 100644
--- a/ruby/action.cc
+++ b/ruby/action.cc
@@ -32,6 +32,13 @@ using namespace paludis::ruby;
namespace
{
+ void dummy_used_this_for_config_protect(const std::string &)
+ {
+ }
+}
+
+namespace
+{
static VALUE c_supports_action_test;
static VALUE c_action;
@@ -47,6 +54,7 @@ namespace
static VALUE c_install_action_checks_option;
static VALUE c_install_action;
+ static VALUE c_uninstall_action_options;
static VALUE c_uninstall_action;
static VALUE c_installed_action;
@@ -129,6 +137,36 @@ namespace
}
}
+ const UninstallActionOptions
+ value_to_uninstall_action_options(VALUE v)
+ {
+ if (rb_obj_is_kind_of(v, c_uninstall_action_options))
+ {
+ UninstallActionOptions * v_ptr;
+ Data_Get_Struct(v, UninstallActionOptions, v_ptr);
+ return *v_ptr;
+ }
+ else
+ {
+ rb_raise(rb_eTypeError, "Can't convert %s into UninstallActionOptions", rb_obj_classname(v));
+ }
+ }
+
+ VALUE
+ uninstall_action_options_to_value(const UninstallActionOptions & m)
+ {
+ UninstallActionOptions * m_ptr(new UninstallActionOptions(m));
+ try
+ {
+ return Data_Wrap_Struct(c_install_action_options, 0, &Common<InstallActionOptions>::free, m_ptr);
+ }
+ catch (const std::exception & e)
+ {
+ delete m_ptr;
+ exception_to_ruby_exception(e);
+ }
+ }
+
const FetchActionFailure
value_to_fetch_action_failure(VALUE v)
{
@@ -532,7 +570,8 @@ namespace
ptr = new InstallActionOptions(make_named_values<InstallActionOptions>(
value_for<n::checks>(v_checks),
value_for<n::debug_build>(v_debug_build),
- value_for<n::destination>(v_destination)
+ value_for<n::destination>(v_destination),
+ value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect)
));
VALUE tdata(Data_Wrap_Struct(self, 0, &Common<InstallActionOptions>::free, ptr));
@@ -595,13 +634,52 @@ namespace
/*
* call-seq:
- * UninstallAction.new -> UninstallAction
+ * UninstallActionOptions.new(config_protect) -> UninstallActionOptions
+ */
+ VALUE
+ uninstall_action_options_new(int argc, VALUE *argv, VALUE self)
+ {
+ UninstallActionOptions * ptr(0);
+ try
+ {
+ std::string v_config_protect;
+
+ if (1 == argc)
+ {
+ v_config_protect = std::string(StringValuePtr(argv[0]));
+ }
+ else
+ {
+ rb_raise(rb_eArgError, "UninstallActionOptions expects one argument, but got %d",argc);
+ }
+
+ ptr = new UninstallActionOptions(make_named_values<UninstallActionOptions>(
+ value_for<n::config_protect>(v_config_protect)
+ ));
+
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<UninstallActionOptions>::free, ptr));
+ rb_obj_call_init(tdata, argc, argv);
+ return tdata;
+ }
+ catch (const std::exception & e)
+ {
+ delete ptr;
+ exception_to_ruby_exception(e);
+ }
+ }
+
+ /*
+ * call-seq:
+ * UninstallAction.new(uninstall_action_options) -> UninstallAction
+ *
+ * Create a new UninstallAction.
*/
VALUE
- uninstall_action_new(VALUE self)
+ uninstall_action_new(VALUE self, VALUE opts)
{
+ const UninstallActionOptions opts_ptr(value_to_uninstall_action_options(opts));
std::tr1::shared_ptr<Action> * a(
- new std::tr1::shared_ptr<Action>(new UninstallAction));
+ new std::tr1::shared_ptr<Action>(new UninstallAction(opts_ptr)));
VALUE tdata(Data_Wrap_Struct(self, 0, &Common<std::tr1::shared_ptr<Action> >::free, a));
rb_obj_call_init(tdata, 1, &self);
return tdata;
@@ -609,6 +687,36 @@ namespace
/*
* call-seq:
+ * options -> UninstallActionOptions
+ *
+ * Our UninstallActionOptions.
+ */
+ VALUE
+ uninstall_action_options(VALUE self)
+ {
+ std::tr1::shared_ptr<Action> * p;
+ Data_Get_Struct(self, std::tr1::shared_ptr<Action>, p);
+ return uninstall_action_options_to_value(std::tr1::static_pointer_cast<UninstallAction>(*p)->options);
+ }
+
+ /*
+ * Document-method: config_protect
+ *
+ * call-seq:
+ * config_protect -> String
+ *
+ * Our config_protect value
+ */
+ VALUE
+ uninstall_action_options_config_protect(VALUE self)
+ {
+ UninstallActionOptions * p;
+ Data_Get_Struct(self, UninstallActionOptions, p);
+ return rb_str_new2((*p).config_protect().c_str());
+ }
+
+ /*
+ * call-seq:
* failed? -> true or false
*
* Did our pretend phase fail?
@@ -775,13 +883,24 @@ namespace
rb_define_method(c_install_action, "options", RUBY_FUNC_CAST(&install_action_options), 0);
/*
+ * Document-class: Paludis::UninstallActionOptions
+ *
+ * Options for Paludis::UninstallAction.
+ */
+ c_uninstall_action_options = rb_define_class_under(paludis_module(), "UninstallActionOptions", rb_cObject);
+ rb_define_singleton_method(c_uninstall_action_options, "new", RUBY_FUNC_CAST(&uninstall_action_options_new), -1);
+ rb_define_method(c_uninstall_action_options, "initialize", RUBY_FUNC_CAST(&empty_init), -1);
+ rb_define_method(c_uninstall_action_options, "config_protect", RUBY_FUNC_CAST(&uninstall_action_options_config_protect), 0);
+
+ /*
* Document-class: Paludis::UninstallAction
*
* An UninstallAction is used by UninstallTask to uninstall a PackageID.
*/
c_uninstall_action = rb_define_class_under(paludis_module(), "UninstallAction", c_action);
- rb_define_singleton_method(c_uninstall_action, "new", RUBY_FUNC_CAST(&uninstall_action_new), 0);
+ rb_define_singleton_method(c_uninstall_action, "new", RUBY_FUNC_CAST(&uninstall_action_new), 1);
rb_define_method(c_uninstall_action, "initialize", RUBY_FUNC_CAST(&empty_init), -1);
+ rb_define_method(c_uninstall_action, "options", RUBY_FUNC_CAST(&uninstall_action_options), 0);
/*
* Document-class: Paludis::InstalledAction
diff --git a/ruby/action_TEST.rb b/ruby/action_TEST.rb
index 842cd14..f4bcb0e 100644
--- a/ruby/action_TEST.rb
+++ b/ruby/action_TEST.rb
@@ -240,17 +240,17 @@ module Paludis
class TestCase_UninstallAction < Test::Unit::TestCase
def test_create
- assert_kind_of UninstallAction, UninstallAction.new
- assert_kind_of Action, UninstallAction.new
+ assert_kind_of UninstallAction, UninstallAction.new(UninstallActionOptions.new("monkey"))
+ assert_kind_of Action, UninstallAction.new(UninstallActionOptions.new("monkey"))
end
def test_bad_create
- assert_raise ArgumentError do
+ assert_raise TypeError do
UninstallAction.new("foo")
end
- assert_raise ArgumentError do
- InstallAction.new(InstallActionOptions.new({:monkey => false}))
+ assert_raise TypeError do
+ UninstallAction.new(UninstallActionOptions.new({:monkey => false}))
end
end
end