aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-12-04 13:03:11 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-12-04 14:20:44 +0000
commit4f4c68ece8df66eaea5a0e9a9b7a6b70e60c958d (patch)
treefdd3ac3bcef0bb92dbc7d4454eb04f9f2b700c08
parentbaa3ed749d36afd7b0312764dc82681a329241de (diff)
downloadpaludis-4f4c68ece8df66eaea5a0e9a9b7a6b70e60c958d.tar.gz
paludis-4f4c68ece8df66eaea5a0e9a9b7a6b70e60c958d.tar.xz
Replacing in pretend too
-rw-r--r--paludis/action.hh7
-rw-r--r--paludis/legacy/install_task.cc15
-rw-r--r--paludis/repositories/e/e_repository.cc1
-rw-r--r--paludis/repositories/e/e_repository_TEST_4.cc3
-rw-r--r--paludis/repositories/e/ebuild.cc21
-rw-r--r--paludis/repositories/e/ebuild.hh1
-rw-r--r--python/action.cc3
-rw-r--r--ruby/action.cc3
-rw-r--r--src/clients/cave/cmd_perform.cc37
9 files changed, 69 insertions, 22 deletions
diff --git a/paludis/action.hh b/paludis/action.hh
index 15b97b6..4aecaad 100644
--- a/paludis/action.hh
+++ b/paludis/action.hh
@@ -374,6 +374,13 @@ namespace paludis
*/
NamedValue<n::make_output_manager, std::function<std::shared_ptr<OutputManager> (
const PretendAction &)> > make_output_manager;
+
+ /**
+ * We will replace these.
+ *
+ * \since 0.55
+ */
+ NamedValue<n::replacing, std::shared_ptr<const PackageIDSequence> > replacing;
};
/**
diff --git a/paludis/legacy/install_task.cc b/paludis/legacy/install_task.cc
index f6bc660..95b66e5 100644
--- a/paludis/legacy/install_task.cc
+++ b/paludis/legacy/install_task.cc
@@ -747,9 +747,22 @@ InstallTask::_pretend()
bool success(true);
if (dep->package_id()->supports_action(pretend_action_query))
{
+ std::shared_ptr<PackageIDSequence> replacing;
+
+ // look for packages with the same name in the same slot in the destination repos
+ if (dep->destination())
+ replacing = (*_imp->env)[selection::AllVersionsSorted(
+ (generator::Package(dep->package_id()->name()) &
+ generator::InRepository(dep->destination()->name())) |
+ filter::SupportsAction<UninstallAction>() |
+ filter::SameSlot(dep->package_id()))];
+ else
+ replacing = std::make_shared<PackageIDSequence>();
+
PretendActionOptions options(make_named_values<PretendActionOptions>(
n::destination() = dep->destination(),
- n::make_output_manager() = std::ref(output_manager_holder)
+ n::make_output_manager() = std::ref(output_manager_holder),
+ n::replacing() = replacing
));
PretendAction pretend_action(options);
dep->package_id()->perform_action(pretend_action);
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index 7a6662c..22269fa 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -3093,6 +3093,7 @@ ERepository::pretend(
n::expand_vars() = expand_vars,
n::profiles() = _imp->params.profiles(),
n::profiles_with_parents() = profile()->profiles_with_parents(),
+ n::replacing_ids() = a.options.replacing(),
n::use() = use,
n::use_expand() = join(profile()->use_expand()->begin(), profile()->use_expand()->end(), " "),
n::use_expand_hidden() = join(profile()->use_expand_hidden()->begin(), profile()->use_expand_hidden()->end(), " ")
diff --git a/paludis/repositories/e/e_repository_TEST_4.cc b/paludis/repositories/e/e_repository_TEST_4.cc
index 6971d52..04269af 100644
--- a/paludis/repositories/e/e_repository_TEST_4.cc
+++ b/paludis/repositories/e/e_repository_TEST_4.cc
@@ -138,7 +138,8 @@ namespace test_cases
PretendAction pretend_action(make_named_values<PretendActionOptions>(
n::destination() = installed_repo,
- n::make_output_manager() = &make_standard_output_manager
+ n::make_output_manager() = &make_standard_output_manager,
+ n::replacing() = std::make_shared<PackageIDSequence>()
));
{
diff --git a/paludis/repositories/e/ebuild.cc b/paludis/repositories/e/ebuild.cc
index 7b3f525..e60bf69 100644
--- a/paludis/repositories/e/ebuild.cc
+++ b/paludis/repositories/e/ebuild.cc
@@ -1092,6 +1092,27 @@ EbuildPretendCommand::extend_command(Process & process)
process.setenv(params.package_id()->eapi()->supported()->ebuild_environment_variables()->env_use_expand_hidden(),
pretend_params.use_expand_hidden());
+ if (! params.package_id()->eapi()->supported()->ebuild_environment_variables()->env_replacing_ids().empty())
+ process.setenv(params.package_id()->eapi()->supported()->ebuild_environment_variables()->env_replacing_ids(),
+ join(indirect_iterator(pretend_params.replacing_ids()->begin()),
+ indirect_iterator(pretend_params.replacing_ids()->end()), " "));
+
+ if (! params.package_id()->eapi()->supported()->ebuild_environment_variables()->env_replacing_versions().empty())
+ {
+ std::string s;
+ for (PackageIDSequence::ConstIterator i(pretend_params.replacing_ids()->begin()),
+ i_end(pretend_params.replacing_ids()->end()) ;
+ i != i_end ; ++i)
+ if ((*i)->name() == params.package_id()->name())
+ {
+ if (! s.empty())
+ s.append(" ");
+ s.append(stringify((*i)->version()));
+ }
+
+ process.setenv(params.package_id()->eapi()->supported()->ebuild_environment_variables()->env_replacing_versions(), s);
+ }
+
for (Map<std::string, std::string>::ConstIterator
i(pretend_params.expand_vars()->begin()),
j(pretend_params.expand_vars()->end()) ; i != j ; ++i)
diff --git a/paludis/repositories/e/ebuild.hh b/paludis/repositories/e/ebuild.hh
index 3a98f11..b98fca2 100644
--- a/paludis/repositories/e/ebuild.hh
+++ b/paludis/repositories/e/ebuild.hh
@@ -202,6 +202,7 @@ namespace paludis
NamedValue<n::expand_vars, std::shared_ptr<const Map<std::string, std::string> > > expand_vars;
NamedValue<n::profiles, std::shared_ptr<const FSPathSequence> > profiles;
NamedValue<n::profiles_with_parents, std::shared_ptr<const FSPathSequence> > profiles_with_parents;
+ NamedValue<n::replacing_ids, std::shared_ptr<const PackageIDSequence> > replacing_ids;
NamedValue<n::use, std::string> use;
NamedValue<n::use_expand, std::string> use_expand;
NamedValue<n::use_expand_hidden, std::string> use_expand_hidden;
diff --git a/python/action.cc b/python/action.cc
index e3b0a98..a220bb7 100644
--- a/python/action.cc
+++ b/python/action.cc
@@ -116,7 +116,8 @@ namespace
{
return new PretendActionOptions(make_named_values<PretendActionOptions>(
n::destination() = r,
- n::make_output_manager() = &make_standard_output_manager
+ n::make_output_manager() = &make_standard_output_manager,
+ n::replacing() = std::make_shared<PackageIDSequence>()
));
}
diff --git a/ruby/action.cc b/ruby/action.cc
index 42dd664..5d525f2 100644
--- a/ruby/action.cc
+++ b/ruby/action.cc
@@ -592,7 +592,8 @@ namespace
ptr = new PretendActionOptions(make_named_values<PretendActionOptions>(
n::destination() = v_destination,
- n::make_output_manager() = &make_standard_output_manager
+ n::make_output_manager() = &make_standard_output_manager,
+ n::replacing() = std::make_shared<PackageIDSequence>()
));
VALUE tdata(Data_Wrap_Struct(self, 0, &Common<PretendActionOptions>::free, ptr));
diff --git a/src/clients/cave/cmd_perform.cc b/src/clients/cave/cmd_perform.cc
index 5105778..f8228d9 100644
--- a/src/clients/cave/cmd_perform.cc
+++ b/src/clients/cave/cmd_perform.cc
@@ -146,7 +146,7 @@ namespace
"be backgrounded or run in parallel with installs", true),
g_install_action_options(main_options_section(), "Install Action Options",
- "Options for if the action is 'install' or (for --destination) 'pretend'"),
+ "Options for if the action is 'install' or (for --destination and --replacing) 'pretend'"),
a_destination(&g_install_action_options, "destination", '\0',
"The name of the repository to which the install should take place"),
a_replacing(&g_install_action_options, "replacing", '\0',
@@ -171,7 +171,7 @@ namespace
" [ --ignore-unfetched ] spec");
add_usage_line("info spec");
add_usage_line("install --destination repo [ --replacing spec ... ] spec");
- add_usage_line("pretend --destination repo spec");
+ add_usage_line("pretend --destination repo [ --replacing spec ... ] spec");
add_usage_line("pretend-fetch spec");
add_usage_line("uninstall [ --config-protect values ] spec");
}
@@ -423,6 +423,21 @@ PerformCommand::run(
if (cmdline.a_fetch_unneeded.specified())
parts += fp_unneeded;
+ const std::shared_ptr<PackageIDSequence> replacing(std::make_shared<PackageIDSequence>());
+ for (args::StringSetArg::ConstIterator p(cmdline.a_replacing.begin_args()),
+ p_end(cmdline.a_replacing.end_args()) ;
+ p != p_end ; ++p)
+ {
+ PackageDepSpec rspec(parse_user_package_dep_spec(*p, env.get(), { }));
+ const std::shared_ptr<const PackageIDSequence> rids((*env)[selection::AllVersionsUnsorted(generator::Matches(rspec, { }))]);
+ if (rids->empty())
+ nothing_matching_error(env.get(), *p, filter::All());
+ else if (1 != std::distance(rids->begin(), rids->end()))
+ throw BeMoreSpecific(rspec, rids);
+ else
+ replacing->push_back(*rids->begin());
+ }
+
if (action == "config")
{
if (cmdline.a_if_supported.specified() && ! id->supports_action(SupportsActionTest<ConfigAction>()))
@@ -525,21 +540,6 @@ PerformCommand::run(
const std::shared_ptr<Repository> destination(env->package_database()->fetch_repository(
RepositoryName(cmdline.a_destination.argument())));
- const std::shared_ptr<PackageIDSequence> replacing(std::make_shared<PackageIDSequence>());
- for (args::StringSetArg::ConstIterator p(cmdline.a_replacing.begin_args()),
- p_end(cmdline.a_replacing.end_args()) ;
- p != p_end ; ++p)
- {
- PackageDepSpec rspec(parse_user_package_dep_spec(*p, env.get(), { }));
- const std::shared_ptr<const PackageIDSequence> rids((*env)[selection::AllVersionsUnsorted(generator::Matches(rspec, { }))]);
- if (rids->empty())
- nothing_matching_error(env.get(), *p, filter::All());
- else if (1 != std::distance(rids->begin(), rids->end()))
- throw BeMoreSpecific(rspec, rids);
- else
- replacing->push_back(*rids->begin());
- }
-
OutputManagerFromIPCOrEnvironment output_manager_holder(env.get(), cmdline, id);
WantInstallPhase want_phase(cmdline, output_manager_holder);
InstallActionOptions options(make_named_values<InstallActionOptions>(
@@ -569,7 +569,8 @@ PerformCommand::run(
OutputManagerFromIPCOrEnvironment output_manager_holder(env.get(), cmdline, id);
PretendActionOptions options(make_named_values<PretendActionOptions>(
n::destination() = destination,
- n::make_output_manager() = std::ref(output_manager_holder)
+ n::make_output_manager() = std::ref(output_manager_holder),
+ n::replacing() = replacing
));
PretendAction pretend_action(options);
execute(env, cmdline, id, action, pretend_action, output_manager_holder);