diff options
Diffstat (limited to 'paludis')
21 files changed, 150 insertions, 113 deletions
diff --git a/paludis/action.hh b/paludis/action.hh index 0416b10f4..a8b1957a0 100644 --- a/paludis/action.hh +++ b/paludis/action.hh @@ -54,13 +54,13 @@ namespace paludis struct failed_automatic_fetching; struct failed_integrity_checks; struct fetch_unneeded; + struct is_overwrite; struct make_output_manager; struct perform_uninstall; struct replacing; struct requires_manual_fetching; struct safe_resume; struct target_file; - struct used_this_for_config_protect; struct want_phase; } @@ -120,7 +120,10 @@ namespace paludis * * \since 0.36 */ - NamedValue<n::perform_uninstall, std::tr1::function<void (const std::tr1::shared_ptr<const PackageID> &)> > perform_uninstall; + NamedValue<n::perform_uninstall, std::tr1::function<void ( + const std::tr1::shared_ptr<const PackageID> &, + const UninstallActionOptions & + )> > perform_uninstall; /** * We must replace these. @@ -129,7 +132,6 @@ namespace paludis */ NamedValue<n::replacing, std::tr1::shared_ptr<const PackageIDSequence> > replacing; - NamedValue<n::used_this_for_config_protect, std::tr1::function<void (const std::string &)> > used_this_for_config_protect; NamedValue<n::want_phase, std::tr1::function<WantPhase (const std::string &)> > want_phase; }; @@ -145,6 +147,14 @@ namespace paludis NamedValue<n::config_protect, std::string> config_protect; /** + * Some repositories need to do special handlings for direct overwrites + * (foo-1.2 replacing foo-1.2). Clients should set this to false. + * + * \since 0.36 + */ + NamedValue<n::is_overwrite, bool> is_overwrite; + + /** * This is a function to avoid chicken / egg problems when using * Environment::create_output_manager. * diff --git a/paludis/install_task.cc b/paludis/install_task.cc index 9e65718b3..975717c80 100644 --- a/paludis/install_task.cc +++ b/paludis/install_task.cc @@ -126,8 +126,6 @@ namespace paludis Environment * const env; DepList dep_list; - std::string config_protect; - std::list<std::string> raw_targets; std::tr1::shared_ptr<SetSpecTree> targets; std::tr1::shared_ptr<std::string> add_to_world_spec; @@ -158,7 +156,6 @@ namespace paludis std::tr1::shared_ptr<const DestinationsSet> d) : env(e), dep_list(e, o), - config_protect(""), targets(new SetSpecTree(make_shared_ptr(new AllDepSpec))), destinations(d), pretend(false), @@ -178,11 +175,6 @@ namespace paludis had_resolution_failures(false) { } - - void assign_config_protect(const std::string & s) - { - config_protect = s; - } }; } @@ -729,6 +721,7 @@ void InstallTask::_clean( const DepList::Iterator dep, const std::tr1::shared_ptr<const PackageID> & id, + const UninstallActionOptions & options, const std::string & cpvr, const int x, const int y, const int s, const int f) { @@ -740,15 +733,8 @@ InstallTask::_clean( try { - OutputManagerFromEnvironment output_manager_holder(_imp->env, id, oe_exclusive); - UninstallAction uninstall_action( - make_named_values<UninstallActionOptions>( - value_for<n::config_protect>(_imp->config_protect), - value_for<n::make_output_manager>(std::tr1::ref(output_manager_holder)) - )); + UninstallAction uninstall_action(options); id->perform_action(uninstall_action); - if (output_manager_holder.output_manager_if_constructed()) - output_manager_holder.output_manager_if_constructed()->succeeded(); } catch (const UninstallActionError & e) { @@ -835,11 +821,8 @@ InstallTask::_one(const DepList::Iterator dep, const int x, const int y, const i value_for<n::destination>(dep->destination()), value_for<n::make_output_manager>(std::tr1::ref(*output_manager_holder)), value_for<n::perform_uninstall>(std::tr1::bind(&InstallTask::_clean, this, dep, - std::tr1::placeholders::_1, cpvr, x, y, s, f)), + std::tr1::placeholders::_1, std::tr1::placeholders::_2, cpvr, x, y, s, f)), value_for<n::replacing>(replacing), - value_for<n::used_this_for_config_protect>(std::tr1::bind( - &Implementation<InstallTask>::assign_config_protect, - _imp.get(), std::tr1::placeholders::_1)), value_for<n::want_phase>(std::tr1::function<WantPhase (const std::string &)>()) )); diff --git a/paludis/install_task.hh b/paludis/install_task.hh index 39472df0e..f3a4f3725 100644 --- a/paludis/install_task.hh +++ b/paludis/install_task.hh @@ -66,6 +66,7 @@ namespace paludis void _one(const DepList::Iterator, const int, const int, const int, const int, const bool is_first, const bool is_last, std::tr1::shared_ptr<OutputManagerFromEnvironment> &); void _clean(const DepList::Iterator, const std::tr1::shared_ptr<const PackageID> & id, + const UninstallActionOptions &, const std::string & cpvr, const int x, const int y, const int s, const int f); void _display_failure_summary(); diff --git a/paludis/repositories/accounts/accounts_id.cc b/paludis/repositories/accounts/accounts_id.cc index b1d10bfc9..a89cc840f 100644 --- a/paludis/repositories/accounts/accounts_id.cc +++ b/paludis/repositories/accounts/accounts_id.cc @@ -421,6 +421,19 @@ AccountsID::supports_action(const SupportsActionTestBase & test) const return simple_visitor_cast<const SupportsActionTest<InstallAction> >(test); } +namespace +{ + std::tr1::shared_ptr<OutputManager> this_output_manager(const std::tr1::shared_ptr<OutputManager> & o, const Action &) + { + return o; + } + + void used_this_for_config_protect(std::string & s, const std::string & v) + { + s = v; + } +} + void AccountsID::perform_action(Action & action) const { @@ -436,6 +449,8 @@ AccountsID::perform_action(Action & action) const std::tr1::shared_ptr<OutputManager> output_manager(install_action->options.make_output_manager()( *install_action)); + std::string used_config_protect; + switch (install_action->options.want_phase()("merge")) { case wp_yes: @@ -447,7 +462,9 @@ AccountsID::perform_action(Action & action) const value_for<n::options>(MergerOptions() + mo_rewrite_symlinks + mo_allow_empty_dirs), value_for<n::output_manager>(output_manager), value_for<n::package_id>(shared_from_this()), - value_for<n::used_this_for_config_protect>(install_action->options.used_this_for_config_protect()) + value_for<n::perform_uninstall>(install_action->options.perform_uninstall()), + value_for<n::used_this_for_config_protect>(std::tr1::bind( + &used_this_for_config_protect, std::tr1::ref(used_config_protect), std::tr1::placeholders::_1)) )); } break; @@ -462,8 +479,6 @@ AccountsID::perform_action(Action & action) const throw InternalError(PALUDIS_HERE, "bad WantPhase"); } - output_manager->succeeded(); - for (PackageIDSequence::ConstIterator i(install_action->options.replacing()->begin()), i_end(install_action->options.replacing()->end()) ; i != i_end ; ++i) { @@ -472,7 +487,16 @@ AccountsID::perform_action(Action & action) const && (*i)->name() == name()) continue; else - install_action->options.perform_uninstall()(*i); + { + UninstallActionOptions uo(make_named_values<UninstallActionOptions>( + value_for<n::config_protect>(used_config_protect), + value_for<n::is_overwrite>(false), + value_for<n::make_output_manager>(std::tr1::bind(&this_output_manager, output_manager, std::tr1::placeholders::_1)) + )); + install_action->options.perform_uninstall()(*i, uo); + } } + + output_manager->succeeded(); } diff --git a/paludis/repositories/e/e_installed_repository.hh b/paludis/repositories/e/e_installed_repository.hh index 1368de1fb..ca1adbace 100644 --- a/paludis/repositories/e/e_installed_repository.hh +++ b/paludis/repositories/e/e_installed_repository.hh @@ -99,8 +99,7 @@ namespace paludis virtual void perform_uninstall( const std::tr1::shared_ptr<const erepository::ERepositoryID> & id, - const UninstallAction &, - bool reinstalling) const = 0; + const UninstallAction &) const = 0; virtual void perform_config( const std::tr1::shared_ptr<const erepository::ERepositoryID> & id, diff --git a/paludis/repositories/e/e_installed_repository_id.cc b/paludis/repositories/e/e_installed_repository_id.cc index 5cac0e355..d7c8e3ed5 100644 --- a/paludis/repositories/e/e_installed_repository_id.cc +++ b/paludis/repositories/e/e_installed_repository_id.cc @@ -876,8 +876,7 @@ namespace void visit(const UninstallAction & a) { - std::tr1::static_pointer_cast<const EInstalledRepository>(id->repository())->perform_uninstall( - id, a, false); + std::tr1::static_pointer_cast<const EInstalledRepository>(id->repository())->perform_uninstall(id, a); } void visit(const InstalledAction &) diff --git a/paludis/repositories/e/e_repository_TEST.cc b/paludis/repositories/e/e_repository_TEST.cc index 5bf166558..402107590 100644 --- a/paludis/repositories/e/e_repository_TEST.cc +++ b/paludis/repositories/e/e_repository_TEST.cc @@ -58,7 +58,7 @@ using namespace paludis; namespace { - void cannot_uninstall(const std::tr1::shared_ptr<const PackageID> & id) + void cannot_uninstall(const std::tr1::shared_ptr<const PackageID> & id, const UninstallActionOptions &) { if (id) throw InternalError(PALUDIS_HERE, "cannot uninstall"); @@ -79,10 +79,6 @@ namespace return mm->second; } - void dummy_used_this_for_config_protect(const std::string &) - { - } - WantPhase want_all_phases(const std::string &) { return wp_yes; @@ -1114,7 +1110,6 @@ namespace test_cases value_for<n::make_output_manager>(&make_standard_output_manager), value_for<n::perform_uninstall>(&cannot_uninstall), value_for<n::replacing>(make_shared_ptr(new PackageIDSequence)), - value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect), value_for<n::want_phase>(&want_all_phases) )); @@ -1372,7 +1367,6 @@ namespace test_cases value_for<n::make_output_manager>(&make_standard_output_manager), value_for<n::perform_uninstall>(&cannot_uninstall), value_for<n::replacing>(make_shared_ptr(new PackageIDSequence)), - value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect), value_for<n::want_phase>(&want_all_phases) )); @@ -1469,7 +1463,6 @@ namespace test_cases value_for<n::make_output_manager>(&make_standard_output_manager), value_for<n::perform_uninstall>(&cannot_uninstall), value_for<n::replacing>(make_shared_ptr(new PackageIDSequence)), - value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect), value_for<n::want_phase>(&want_all_phases) )); @@ -1596,7 +1589,6 @@ namespace test_cases value_for<n::make_output_manager>(&make_standard_output_manager), value_for<n::perform_uninstall>(&cannot_uninstall), value_for<n::replacing>(make_shared_ptr(new PackageIDSequence)), - value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect), value_for<n::want_phase>(&want_all_phases) )); @@ -1804,7 +1796,6 @@ namespace test_cases value_for<n::make_output_manager>(&make_standard_output_manager), value_for<n::perform_uninstall>(&cannot_uninstall), value_for<n::replacing>(make_shared_ptr(new PackageIDSequence)), - value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect), value_for<n::want_phase>(&want_all_phases) )); @@ -2389,7 +2380,6 @@ namespace test_cases value_for<n::make_output_manager>(&make_standard_output_manager), value_for<n::perform_uninstall>(&cannot_uninstall), value_for<n::replacing>(make_shared_ptr(new PackageIDSequence)), - value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect), value_for<n::want_phase>(&want_all_phases) )); diff --git a/paludis/repositories/e/e_repository_TEST_ever.cc b/paludis/repositories/e/e_repository_TEST_ever.cc index 71320c725..830cba84b 100644 --- a/paludis/repositories/e/e_repository_TEST_ever.cc +++ b/paludis/repositories/e/e_repository_TEST_ever.cc @@ -58,7 +58,7 @@ using namespace paludis; namespace { - void cannot_uninstall(const std::tr1::shared_ptr<const PackageID> & id) + void cannot_uninstall(const std::tr1::shared_ptr<const PackageID> & id, const UninstallActionOptions &) { if (id) throw InternalError(PALUDIS_HERE, "cannot uninstall"); @@ -79,10 +79,6 @@ namespace return mm->second; } - void dummy_used_this_for_config_protect(const std::string &) - { - } - WantPhase want_all_phases(const std::string &) { return wp_yes; @@ -154,7 +150,6 @@ namespace value_for<n::make_output_manager>(&make_standard_output_manager), value_for<n::perform_uninstall>(&cannot_uninstall), value_for<n::replacing>(make_shared_ptr(new PackageIDSequence)), - value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect), value_for<n::want_phase>(&want_all_phases) )); diff --git a/paludis/repositories/e/e_repository_TEST_exlibs.cc b/paludis/repositories/e/e_repository_TEST_exlibs.cc index 20fa8f39d..1dbead3e0 100644 --- a/paludis/repositories/e/e_repository_TEST_exlibs.cc +++ b/paludis/repositories/e/e_repository_TEST_exlibs.cc @@ -58,7 +58,7 @@ using namespace paludis; namespace { - void cannot_uninstall(const std::tr1::shared_ptr<const PackageID> & id) + void cannot_uninstall(const std::tr1::shared_ptr<const PackageID> & id, const UninstallActionOptions &) { if (id) throw InternalError(PALUDIS_HERE, "cannot uninstall"); @@ -144,7 +144,6 @@ namespace value_for<n::make_output_manager>(&make_standard_output_manager), value_for<n::perform_uninstall>(&cannot_uninstall), value_for<n::replacing>(make_shared_ptr(new PackageIDSequence)), - value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect), value_for<n::want_phase>(&want_all_phases) )); diff --git a/paludis/repositories/e/ebuild_entries.cc b/paludis/repositories/e/ebuild_entries.cc index 1c78c5434..c8a0e231e 100644 --- a/paludis/repositories/e/ebuild_entries.cc +++ b/paludis/repositories/e/ebuild_entries.cc @@ -534,6 +534,16 @@ namespace else return ! b->slot_key(); } + + void used_this_for_config_protect(std::string & s, const std::string & v) + { + s = v; + } + + std::tr1::shared_ptr<OutputManager> this_output_manager(const std::tr1::shared_ptr<OutputManager> & o, const Action &) + { + return o; + } } void @@ -639,6 +649,8 @@ EbuildEntries::install(const std::tr1::shared_ptr<const ERepositoryID> & id, FSEntry package_builddir(_imp->params.builddir() / (stringify(id->name().category()) + "-" + stringify(id->name().package()) + "-" + stringify(id->version()))); + std::string used_config_protect; + EAPIPhases phases(id->eapi()->supported()->ebuild_phases()->ebuild_install()); for (EAPIPhases::ConstIterator phase(phases.begin_phases()), phase_end(phases.end_phases()) ; phase != phase_end ; ++phase) @@ -688,7 +700,9 @@ EbuildEntries::install(const std::tr1::shared_ptr<const ERepositoryID> & id, value_for<n::options>(id->eapi()->supported()->merger_options()), value_for<n::output_manager>(output_manager), value_for<n::package_id>(id), - value_for<n::used_this_for_config_protect>(install_action.options.used_this_for_config_protect()) + value_for<n::perform_uninstall>(install_action.options.perform_uninstall()), + value_for<n::used_this_for_config_protect>(std::tr1::bind( + &used_this_for_config_protect, std::tr1::ref(used_config_protect), std::tr1::placeholders::_1)) )); } else if (phase->option("strip")) @@ -791,8 +805,6 @@ EbuildEntries::install(const std::tr1::shared_ptr<const ERepositoryID> & id, } } - output_manager->succeeded(); - for (PackageIDSequence::ConstIterator i(install_action.options.replacing()->begin()), i_end(install_action.options.replacing()->end()) ; i != i_end ; ++i) { @@ -804,8 +816,15 @@ EbuildEntries::install(const std::tr1::shared_ptr<const ERepositoryID> & id, if ((*i)->name() == id->name() && slot_is_same(*i, id)) continue; - install_action.options.perform_uninstall()(*i); + UninstallActionOptions uo(make_named_values<UninstallActionOptions>( + value_for<n::config_protect>(used_config_protect), + value_for<n::is_overwrite>(false), + value_for<n::make_output_manager>(std::tr1::bind(&this_output_manager, output_manager, std::tr1::placeholders::_1)) + )); + install_action.options.perform_uninstall()(*i, uo); } + + output_manager->succeeded(); } void diff --git a/paludis/repositories/e/exndbam_repository.cc b/paludis/repositories/e/exndbam_repository.cc index 67821f831..f50db3620 100644 --- a/paludis/repositories/e/exndbam_repository.cc +++ b/paludis/repositories/e/exndbam_repository.cc @@ -412,9 +412,10 @@ ExndbamRepository::merge(const MergeParams & m) { UninstallActionOptions uo(make_named_values<UninstallActionOptions>( value_for<n::config_protect>(config_protect), + value_for<n::is_overwrite>(true), value_for<n::make_output_manager>(std::tr1::bind(&this_output_manager, m.output_manager(), std::tr1::placeholders::_1)) )); - perform_uninstall(std::tr1::static_pointer_cast<const ERepositoryID>(if_overwritten_id), uo, true); + m.perform_uninstall()(if_overwritten_id, uo); } if (std::tr1::static_pointer_cast<const ERepositoryID>(m.package_id()) @@ -429,9 +430,10 @@ ExndbamRepository::merge(const MergeParams & m) { UninstallActionOptions uo(make_named_values<UninstallActionOptions>( value_for<n::config_protect>(config_protect), + value_for<n::is_overwrite>(false), value_for<n::make_output_manager>(std::tr1::bind(&this_output_manager, m.output_manager(), std::tr1::placeholders::_1)) )); - perform_uninstall(candidate, uo, false); + m.perform_uninstall()(candidate, uo); } } } @@ -447,10 +449,9 @@ ExndbamRepository::merge(const MergeParams & m) void ExndbamRepository::perform_uninstall( const std::tr1::shared_ptr<const ERepositoryID> & id, - const UninstallAction & a, - bool replace) const + const UninstallAction & a) const { - Context context("When uninstalling '" + stringify(*id) + (replace ? "' for a reinstall:" : "':")); + Context context("When uninstalling '" + stringify(*id) + (a.options.is_overwrite() ? "' for an overwrite:" : "':")); if (! _imp->params.root().is_directory()) throw InstallActionError("Couldn't uninstall '" + stringify(*id) + diff --git a/paludis/repositories/e/exndbam_repository.hh b/paludis/repositories/e/exndbam_repository.hh index f5212ff47..609f5ed5a 100644 --- a/paludis/repositories/e/exndbam_repository.hh +++ b/paludis/repositories/e/exndbam_repository.hh @@ -117,8 +117,7 @@ namespace paludis void perform_uninstall( const std::tr1::shared_ptr<const erepository::ERepositoryID> & id, - const UninstallAction &, - bool reinstalling) const; + const UninstallAction &) const; ///\} diff --git a/paludis/repositories/e/exndbam_repository_TEST.cc b/paludis/repositories/e/exndbam_repository_TEST.cc index 9608cfa8f..d03bd5f2e 100644 --- a/paludis/repositories/e/exndbam_repository_TEST.cc +++ b/paludis/repositories/e/exndbam_repository_TEST.cc @@ -40,10 +40,10 @@ using namespace paludis; namespace { - void cannot_uninstall(const std::tr1::shared_ptr<const PackageID> & id) + void do_uninstall(const std::tr1::shared_ptr<const PackageID> & id, const UninstallActionOptions & u) { - if (id) - throw InternalError(PALUDIS_HERE, "cannot uninstall"); + UninstallAction a(u); + id->perform_action(a); } std::tr1::shared_ptr<OutputManager> make_standard_output_manager(const Action &) @@ -61,10 +61,6 @@ namespace return mm->second; } - void dummy_used_this_for_config_protect(const std::string &) - { - } - WantPhase want_all_phases(const std::string &) { return wp_yes; @@ -136,14 +132,14 @@ namespace test_cases InstallAction install_action(make_named_values<InstallActionOptions>( value_for<n::destination>(exndbam_repo), value_for<n::make_output_manager>(&make_standard_output_manager), - value_for<n::perform_uninstall>(&cannot_uninstall), + value_for<n::perform_uninstall>(&do_uninstall), value_for<n::replacing>(make_shared_ptr(new PackageIDSequence)), - value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect), value_for<n::want_phase>(&want_all_phases) )); UninstallAction uninstall_action(make_named_values<UninstallActionOptions>( value_for<n::config_protect>(""), + value_for<n::is_overwrite>(false), value_for<n::make_output_manager>(&make_standard_output_manager) )); diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc index 6a83bad65..c0007b290 100644 --- a/paludis/repositories/e/vdb_repository.cc +++ b/paludis/repositories/e/vdb_repository.cc @@ -375,10 +375,9 @@ VDBRepositoryKeyReadError::VDBRepositoryKeyReadError( void VDBRepository::perform_uninstall( const std::tr1::shared_ptr<const ERepositoryID> & id, - const UninstallAction & a, - bool reinstalling) const + const UninstallAction & a) const { - Context context("When uninstalling '" + stringify(*id) + (reinstalling ? "' for a reinstall:" : "':")); + Context context("When uninstalling '" + stringify(*id) + (a.options.is_overwrite() ? "' for an overwrite:" : "':")); if (! _imp->params.root().is_directory()) throw InstallActionError("Couldn't uninstall '" + stringify(*id) + @@ -386,7 +385,7 @@ VDBRepository::perform_uninstall( std::tr1::shared_ptr<OutputManager> output_manager(a.options.make_output_manager()(a)); - std::string reinstalling_str(reinstalling ? "-reinstalling-" : ""); + std::string reinstalling_str(a.options.is_overwrite() ? "-reinstalling-" : ""); std::tr1::shared_ptr<FSEntrySequence> eclassdirs(new FSEntrySequence); eclassdirs->push_back(FSEntry(_imp->params.location() / stringify(id->name().category()) / @@ -484,7 +483,7 @@ VDBRepository::perform_uninstall( FSEntry(*d).unlink(); pkg_dir.rmdir(); - if (! reinstalling) + if (! a.options.is_overwrite()) { std::tr1::shared_ptr<const PackageIDSequence> ids(package_ids(id->name())); bool only(true); @@ -918,9 +917,10 @@ VDBRepository::merge(const MergeParams & m) { UninstallActionOptions uo(make_named_values<UninstallActionOptions>( value_for<n::config_protect>(config_protect), + value_for<n::is_overwrite>(true), value_for<n::make_output_manager>(std::tr1::bind(&this_output_manager, m.output_manager(), std::tr1::placeholders::_1)) )); - perform_uninstall(is_replace, uo, true); + m.perform_uninstall()(is_replace, uo); } if (std::tr1::static_pointer_cast<const ERepositoryID>(m.package_id()) @@ -935,9 +935,10 @@ VDBRepository::merge(const MergeParams & m) { UninstallActionOptions uo(make_named_values<UninstallActionOptions>( value_for<n::config_protect>(config_protect), + value_for<n::is_overwrite>(false), value_for<n::make_output_manager>(std::tr1::bind(&this_output_manager, m.output_manager(), std::tr1::placeholders::_1)) )); - perform_uninstall(candidate, uo, false); + m.perform_uninstall()(candidate, uo); } } } diff --git a/paludis/repositories/e/vdb_repository.hh b/paludis/repositories/e/vdb_repository.hh index f5f042121..971c59ac3 100644 --- a/paludis/repositories/e/vdb_repository.hh +++ b/paludis/repositories/e/vdb_repository.hh @@ -121,8 +121,7 @@ namespace paludis virtual void perform_uninstall( const std::tr1::shared_ptr<const erepository::ERepositoryID> & id, - const UninstallAction &, - bool reinstalling) const; + const UninstallAction &) const; /* RepositoryProvidesInterface */ diff --git a/paludis/repositories/e/vdb_repository_TEST.cc b/paludis/repositories/e/vdb_repository_TEST.cc index b8d95b714..d703fec8d 100644 --- a/paludis/repositories/e/vdb_repository_TEST.cc +++ b/paludis/repositories/e/vdb_repository_TEST.cc @@ -51,10 +51,10 @@ using namespace paludis; namespace { - void cannot_uninstall(const std::tr1::shared_ptr<const PackageID> & id) + void do_uninstall(const std::tr1::shared_ptr<const PackageID> & id, const UninstallActionOptions & u) { - if (id) - throw InternalError(PALUDIS_HERE, "cannot uninstall"); + UninstallAction a(u); + id->perform_action(a); } std::tr1::shared_ptr<OutputManager> make_standard_output_manager(const Action &) @@ -72,10 +72,6 @@ namespace return mm->second; } - void dummy_used_this_for_config_protect(const std::string &) - { - } - WantPhase want_all_phases(const std::string &) { return wp_yes; @@ -350,14 +346,14 @@ namespace test_cases InstallAction install_action(make_named_values<InstallActionOptions>( value_for<n::destination>(vdb_repo), value_for<n::make_output_manager>(&make_standard_output_manager), - value_for<n::perform_uninstall>(&cannot_uninstall), + value_for<n::perform_uninstall>(&do_uninstall), value_for<n::replacing>(make_shared_ptr(new PackageIDSequence)), - value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect), value_for<n::want_phase>(&want_all_phases) )); UninstallAction uninstall_action(make_named_values<UninstallActionOptions>( value_for<n::config_protect>(""), + value_for<n::is_overwrite>(false), value_for<n::make_output_manager>(&make_standard_output_manager) )); @@ -478,14 +474,14 @@ namespace test_cases InstallAction install_action(make_named_values<InstallActionOptions>( value_for<n::destination>(vdb_repo), value_for<n::make_output_manager>(&make_standard_output_manager), - value_for<n::perform_uninstall>(&cannot_uninstall), + value_for<n::perform_uninstall>(&do_uninstall), value_for<n::replacing>(make_shared_ptr(new PackageIDSequence)), - value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect), value_for<n::want_phase>(&want_all_phases) )); UninstallAction uninstall_action(make_named_values<UninstallActionOptions>( value_for<n::config_protect>(""), + value_for<n::is_overwrite>(false), value_for<n::make_output_manager>(&make_standard_output_manager) )); @@ -606,14 +602,14 @@ namespace test_cases InstallAction install_action(make_named_values<InstallActionOptions>( value_for<n::destination>(vdb_repo), value_for<n::make_output_manager>(&make_standard_output_manager), - value_for<n::perform_uninstall>(&cannot_uninstall), + value_for<n::perform_uninstall>(&do_uninstall), value_for<n::replacing>(make_shared_ptr(new PackageIDSequence)), - value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect), value_for<n::want_phase>(&want_all_phases) )); UninstallAction uninstall_action(make_named_values<UninstallActionOptions>( value_for<n::config_protect>(""), + value_for<n::is_overwrite>(false), value_for<n::make_output_manager>(&make_standard_output_manager) )); @@ -1006,14 +1002,14 @@ namespace test_cases InstallAction install_action(make_named_values<InstallActionOptions>( value_for<n::destination>(vdb_repo), value_for<n::make_output_manager>(&make_standard_output_manager), - value_for<n::perform_uninstall>(&cannot_uninstall), + value_for<n::perform_uninstall>(&do_uninstall), value_for<n::replacing>(make_shared_ptr(new PackageIDSequence)), - value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect), value_for<n::want_phase>(&want_all_phases) )); UninstallAction uninstall_action(make_named_values<UninstallActionOptions>( value_for<n::config_protect>(""), + value_for<n::is_overwrite>(false), value_for<n::make_output_manager>(&make_standard_output_manager) )); @@ -1247,9 +1243,8 @@ namespace test_cases InstallAction install_action(make_named_values<InstallActionOptions>( value_for<n::destination>(vdb_repo), value_for<n::make_output_manager>(&make_standard_output_manager), - value_for<n::perform_uninstall>(&cannot_uninstall), + value_for<n::perform_uninstall>(&do_uninstall), value_for<n::replacing>(make_shared_ptr(new PackageIDSequence)), - value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect), value_for<n::want_phase>(&want_all_phases) )); @@ -1341,14 +1336,14 @@ namespace test_cases InstallAction install_action(make_named_values<InstallActionOptions>( value_for<n::destination>(vdb_repo), value_for<n::make_output_manager>(&make_standard_output_manager), - value_for<n::perform_uninstall>(&cannot_uninstall), + value_for<n::perform_uninstall>(&do_uninstall), value_for<n::replacing>(make_shared_ptr(new PackageIDSequence)), - value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect), value_for<n::want_phase>(&want_all_phases) )); UninstallAction uninstall_action(make_named_values<UninstallActionOptions>( value_for<n::config_protect>(""), + value_for<n::is_overwrite>(false), value_for<n::make_output_manager>(&make_standard_output_manager) )); diff --git a/paludis/repositories/unpackaged/installed_repository_TEST.cc b/paludis/repositories/unpackaged/installed_repository_TEST.cc index 202d7567e..a677a0cc8 100644 --- a/paludis/repositories/unpackaged/installed_repository_TEST.cc +++ b/paludis/repositories/unpackaged/installed_repository_TEST.cc @@ -44,7 +44,7 @@ using namespace paludis; namespace { - void cannot_uninstall(const std::tr1::shared_ptr<const PackageID> & id) + void cannot_uninstall(const std::tr1::shared_ptr<const PackageID> & id, const UninstallActionOptions &) { if (id) throw InternalError(PALUDIS_HERE, "cannot uninstall"); @@ -80,10 +80,6 @@ namespace } }; - void dummy_used_this_for_config_protect(const std::string &) - { - } - WantPhase want_all_phases(const std::string &) { return wp_yes; @@ -266,6 +262,7 @@ namespace test_cases UninstallAction action(make_named_values<UninstallActionOptions>( value_for<n::config_protect>(""), + value_for<n::is_overwrite>(false), value_for<n::make_output_manager>(&make_standard_output_manager) )); id->perform_action(action); @@ -318,6 +315,7 @@ namespace test_cases UninstallAction action(make_named_values<UninstallActionOptions>( value_for<n::config_protect>(""), + value_for<n::is_overwrite>(false), value_for<n::make_output_manager>(&make_standard_output_manager) )); id->perform_action(action); @@ -405,7 +403,6 @@ namespace test_cases value_for<n::make_output_manager>(&make_standard_output_manager), value_for<n::perform_uninstall>(&cannot_uninstall), value_for<n::replacing>(make_shared_ptr(new PackageIDSequence)), - value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect), value_for<n::want_phase>(&want_all_phases) )); (*env[selection::RequireExactlyOne(generator::InRepository(RepositoryName("unpackaged")))]->begin())->perform_action(action); @@ -463,7 +460,6 @@ namespace test_cases value_for<n::make_output_manager>(&make_standard_output_manager), value_for<n::perform_uninstall>(&cannot_uninstall), value_for<n::replacing>(make_shared_ptr(new PackageIDSequence)), - value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect), value_for<n::want_phase>(&want_all_phases) )); (*env[selection::RequireExactlyOne(generator::InRepository(RepositoryName("unpackaged")))]->begin())->perform_action(action); @@ -524,7 +520,6 @@ namespace test_cases value_for<n::make_output_manager>(&make_standard_output_manager), value_for<n::perform_uninstall>(&cannot_uninstall), value_for<n::replacing>(make_shared_ptr(new PackageIDSequence)), - value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect), value_for<n::want_phase>(&want_all_phases) )); (*env[selection::RequireExactlyOne(generator::InRepository(RepositoryName("unpackaged")))]->begin())->perform_action(action); @@ -566,6 +561,7 @@ namespace test_cases UninstallAction action(make_named_values<UninstallActionOptions>( value_for<n::config_protect>(""), + value_for<n::is_overwrite>(false), value_for<n::make_output_manager>(&make_standard_output_manager) )); (*env[selection::RequireExactlyOne(generator::Matches( @@ -609,6 +605,7 @@ namespace test_cases UninstallAction action(make_named_values<UninstallActionOptions>( value_for<n::config_protect>(""), + value_for<n::is_overwrite>(false), value_for<n::make_output_manager>(&make_standard_output_manager) )); (*env[selection::RequireExactlyOne(generator::Matches( diff --git a/paludis/repositories/unpackaged/unpackaged_id.cc b/paludis/repositories/unpackaged/unpackaged_id.cc index ced8e4875..77c8f1032 100644 --- a/paludis/repositories/unpackaged/unpackaged_id.cc +++ b/paludis/repositories/unpackaged/unpackaged_id.cc @@ -294,6 +294,16 @@ namespace else return ! b->slot_key(); } + + void used_this_for_config_protect(std::string & s, const std::string & v) + { + s = v; + } + + std::tr1::shared_ptr<OutputManager> this_output_manager(const std::tr1::shared_ptr<OutputManager> & o, const Action &) + { + return o; + } } void @@ -327,6 +337,8 @@ UnpackagedID::perform_action(Action & action) const std::tr1::shared_ptr<const ChoiceValue> split_choice(choices_key()->value()->find_by_name_with_prefix( ELikeSplitChoiceValue::canonical_name_with_prefix())); + std::string used_config_protect; + switch (install_action->options.want_phase()("strip")) { case wp_yes: @@ -365,7 +377,9 @@ UnpackagedID::perform_action(Action & action) const value_for<n::options>(MergerOptions() + mo_rewrite_symlinks + mo_allow_empty_dirs), value_for<n::output_manager>(output_manager), value_for<n::package_id>(shared_from_this()), - value_for<n::used_this_for_config_protect>(install_action->options.used_this_for_config_protect()) + value_for<n::perform_uninstall>(install_action->options.perform_uninstall()), + value_for<n::used_this_for_config_protect>(std::tr1::bind( + &used_this_for_config_protect, std::tr1::ref(used_config_protect), std::tr1::placeholders::_1)) )); } break; @@ -380,8 +394,6 @@ UnpackagedID::perform_action(Action & action) const throw InternalError(PALUDIS_HERE, "bad WantPhase"); } - output_manager->succeeded(); - for (PackageIDSequence::ConstIterator i(install_action->options.replacing()->begin()), i_end(install_action->options.replacing()->end()) ; i != i_end ; ++i) { @@ -389,8 +401,15 @@ UnpackagedID::perform_action(Action & action) const if ((*i)->name() == name() && (*i)->version() == version() && slot_is_same(*i, this)) continue; - install_action->options.perform_uninstall()(*i); + UninstallActionOptions uo(make_named_values<UninstallActionOptions>( + value_for<n::config_protect>(used_config_protect), + value_for<n::is_overwrite>(false), + value_for<n::make_output_manager>(std::tr1::bind(&this_output_manager, output_manager, std::tr1::placeholders::_1)) + )); + install_action->options.perform_uninstall()(*i, uo); } + + output_manager->succeeded(); } void diff --git a/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc b/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc index 2a030c1f3..f663d8d91 100644 --- a/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc +++ b/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc @@ -42,7 +42,7 @@ using namespace paludis; namespace { - void cannot_uninstall(const std::tr1::shared_ptr<const PackageID> & id) + void cannot_uninstall(const std::tr1::shared_ptr<const PackageID> & id, const UninstallActionOptions &) { if (id) throw InternalError(PALUDIS_HERE, "cannot uninstall"); @@ -245,7 +245,6 @@ namespace test_cases value_for<n::make_output_manager>(&make_standard_output_manager), value_for<n::perform_uninstall>(&cannot_uninstall), value_for<n::replacing>(make_shared_ptr(new PackageIDSequence)), - value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect), value_for<n::want_phase>(&want_all_phases) )); id->perform_action(action); @@ -302,7 +301,6 @@ namespace test_cases value_for<n::make_output_manager>(&make_standard_output_manager), value_for<n::perform_uninstall>(&cannot_uninstall), value_for<n::replacing>(make_shared_ptr(new PackageIDSequence)), - value_for<n::used_this_for_config_protect>(&dummy_used_this_for_config_protect), value_for<n::want_phase>(&want_all_phases) )); id->perform_action(action); diff --git a/paludis/repository.hh b/paludis/repository.hh index 9ccd40f22..7068a744d 100644 --- a/paludis/repository.hh +++ b/paludis/repository.hh @@ -69,6 +69,7 @@ namespace paludis struct output_manager; struct package_id; struct path; + struct perform_uninstall; struct profile; struct provided_by; struct provided_by_spec; @@ -163,6 +164,17 @@ namespace paludis NamedValue<n::options, MergerOptions> options; NamedValue<n::output_manager, std::tr1::shared_ptr<OutputManager> > output_manager; NamedValue<n::package_id, std::tr1::shared_ptr<const PackageID> > package_id; + + /** + * Some merges need to do an uninstall mid-way through the merge process. + * + * \see InstallActionOptions::perform_uninstall + * \since 0.36 + */ + NamedValue<n::perform_uninstall, std::tr1::function<void ( + const std::tr1::shared_ptr<const PackageID> &, + const UninstallActionOptions &)> > perform_uninstall; + 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 7f9f3be99..1cb493363 100644 --- a/paludis/uninstall_task.cc +++ b/paludis/uninstall_task.cc @@ -363,6 +363,7 @@ UninstallTask::execute() UninstallAction uninstall_action( make_named_values<UninstallActionOptions>( value_for<n::config_protect>(""), + value_for<n::is_overwrite>(false), value_for<n::make_output_manager>(std::tr1::ref(output_manager_holder)) )); i->package_id()->perform_action(uninstall_action); |