aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-28 18:11:28 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-28 18:11:28 +0100
commit5b7b5149b750b53d35516c57725fec1fde2236e3 (patch)
treee13964eb7309fc6a09868eb50906d3005d2c2d76
parent0d7c7cc2f8dc683c0b845a7da7380799aed0e965 (diff)
downloadpaludis-5b7b5149b750b53d35516c57725fec1fde2236e3.tar.gz
paludis-5b7b5149b750b53d35516c57725fec1fde2236e3.tar.xz
Change world spec handling
Fixes: ticket:890 Fixes: ticket:894
-rw-r--r--src/clients/cave/cmd_execute_resolution.cc18
-rw-r--r--src/clients/cave/cmd_fix_linkage.cc2
-rw-r--r--src/clients/cave/cmd_import.cc2
-rw-r--r--src/clients/cave/cmd_purge.cc2
-rw-r--r--src/clients/cave/cmd_resolve.cc2
-rw-r--r--src/clients/cave/cmd_uninstall.cc6
-rw-r--r--src/clients/cave/resolve_common.cc27
-rw-r--r--src/clients/cave/resolve_common.hh1
-rw-r--r--src/clients/cave/resume_data.cc11
-rw-r--r--src/clients/cave/resume_data.hh2
10 files changed, 56 insertions, 17 deletions
diff --git a/src/clients/cave/cmd_execute_resolution.cc b/src/clients/cave/cmd_execute_resolution.cc
index e7bc0fb..1d3f66c 100644
--- a/src/clients/cave/cmd_execute_resolution.cc
+++ b/src/clients/cave/cmd_execute_resolution.cc
@@ -98,6 +98,7 @@ namespace
args::ArgsGroup g_general_options;
args::SwitchArg a_pretend;
args::SwitchArg a_set;
+ args::StringSetArg a_world_specs;
ResolveCommandLineExecutionOptions execution_options;
ResolveCommandLineProgramOptions program_options;
@@ -107,6 +108,7 @@ namespace
g_general_options(main_options_section(), "General Options", "General options."),
a_pretend(&g_general_options, "pretend", '\0', "Only carry out the pretend action", false),
a_set(&g_general_options, "set", '\0', "Our target is a set rather than package specs", false),
+ a_world_specs(&g_general_options, "world-specs", '\0', "Use the specified spec or set name for updating world"),
execution_options(this),
program_options(this),
import_options(this)
@@ -510,8 +512,8 @@ namespace
return;
command.append(" --set");
- for (args::ArgsHandler::ParametersConstIterator a(cmdline.begin_parameters()),
- a_end(cmdline.end_parameters()) ;
+ for (args::StringSetArg::ConstIterator a(cmdline.a_world_specs.begin_args()),
+ a_end(cmdline.a_world_specs.end_args()) ;
a != a_end ; ++a)
{
if (*a == "world" || *a == "system" || *a == "security"
@@ -528,8 +530,8 @@ namespace
}
else
{
- for (args::ArgsHandler::ParametersConstIterator a(cmdline.begin_parameters()),
- a_end(cmdline.end_parameters()) ;
+ for (args::StringSetArg::ConstIterator a(cmdline.a_world_specs.begin_args()),
+ a_end(cmdline.a_world_specs.end_args()) ;
a != a_end ; ++a)
{
std::string aa(*a);
@@ -548,7 +550,7 @@ namespace
continue;
}
- PackageDepSpec spec(parse_user_package_dep_spec(aa, env.get(), UserPackageDepSpecOptions()));
+ PackageDepSpec spec(parse_user_package_dep_spec(aa, env.get(), UserPackageDepSpecOptions() + updso_no_disambiguation));
if (package_dep_spec_has_properties(spec, make_named_values<PackageDepSpecProperties>(
n::has_additional_requirements() = false,
n::has_category_name_part() = false,
@@ -1144,11 +1146,15 @@ namespace
std::tr1::shared_ptr<Sequence<std::string> > targets(new Sequence<std::string>);
std::copy(cmdline.begin_parameters(), cmdline.end_parameters(), targets->back_inserter());
+ std::tr1::shared_ptr<Sequence<std::string> > world_specs(new Sequence<std::string>);
+ std::copy(cmdline.a_world_specs.begin_args(), cmdline.a_world_specs.end_args(), world_specs->back_inserter());
+
ResumeData resume_data(make_named_values<ResumeData>(
n::job_lists() = lists,
n::preserve_world() = cmdline.execution_options.a_preserve_world.specified(),
n::target_set() = cmdline.a_set.specified(),
- n::targets() = targets
+ n::targets() = targets,
+ n::world_specs() = world_specs
));
cout << endl << "Writing resume information to " << resume_file << "..." << endl;
diff --git a/src/clients/cave/cmd_fix_linkage.cc b/src/clients/cave/cmd_fix_linkage.cc
index af403e9..565523b 100644
--- a/src/clients/cave/cmd_fix_linkage.cc
+++ b/src/clients/cave/cmd_fix_linkage.cc
@@ -242,7 +242,7 @@ FixLinkageCommand::run(
resolve_cmdline.execution_options,
resolve_cmdline.display_options,
resolve_cmdline.program_options,
- make_null_shared_ptr(), targets, false);
+ make_null_shared_ptr(), targets, make_null_shared_ptr(), false);
}
std::tr1::shared_ptr<args::ArgsHandler>
diff --git a/src/clients/cave/cmd_import.cc b/src/clients/cave/cmd_import.cc
index 6b41632..98bddac 100644
--- a/src/clients/cave/cmd_import.cc
+++ b/src/clients/cave/cmd_import.cc
@@ -280,7 +280,7 @@ ImportCommand::run(
resolve_cmdline.execution_options,
resolve_cmdline.display_options,
resolve_cmdline.program_options,
- keys, targets, false);
+ keys, targets, targets, false);
}
std::tr1::shared_ptr<args::ArgsHandler>
diff --git a/src/clients/cave/cmd_purge.cc b/src/clients/cave/cmd_purge.cc
index fc58a70..f7118b6 100644
--- a/src/clients/cave/cmd_purge.cc
+++ b/src/clients/cave/cmd_purge.cc
@@ -108,7 +108,7 @@ PurgeCommand::run(
cmdline.resolution_options->a_purge.add_argument("*/*");
return resolve_common(env, *cmdline.resolution_options, *cmdline.execution_options, *cmdline.display_options,
- *cmdline.program_options, make_null_shared_ptr(), make_null_shared_ptr(), true);
+ *cmdline.program_options, make_null_shared_ptr(), make_null_shared_ptr(), make_null_shared_ptr(), true);
}
std::tr1::shared_ptr<args::ArgsHandler>
diff --git a/src/clients/cave/cmd_resolve.cc b/src/clients/cave/cmd_resolve.cc
index aee1947..1b057a6 100644
--- a/src/clients/cave/cmd_resolve.cc
+++ b/src/clients/cave/cmd_resolve.cc
@@ -103,7 +103,7 @@ ResolveCommand::run(
targets->push_back(*p);
return resolve_common(env, cmdline.resolution_options, cmdline.execution_options, cmdline.display_options,
- cmdline.program_options, make_null_shared_ptr(), targets, false);
+ cmdline.program_options, make_null_shared_ptr(), targets, make_null_shared_ptr(), false);
}
std::tr1::shared_ptr<args::ArgsHandler>
diff --git a/src/clients/cave/cmd_uninstall.cc b/src/clients/cave/cmd_uninstall.cc
index 5632351..bf20839 100644
--- a/src/clients/cave/cmd_uninstall.cc
+++ b/src/clients/cave/cmd_uninstall.cc
@@ -111,7 +111,7 @@ UninstallCommand::run(
cmdline.resolution_options->apply_shortcuts();
cmdline.resolution_options->verify(env);
- std::tr1::shared_ptr<Sequence<std::string> > targets(new Sequence<std::string>);
+ std::tr1::shared_ptr<Sequence<std::string> > targets(new Sequence<std::string>), targets_cleaned_up(new Sequence<std::string>);
for (UninstallCommandLine::ParametersConstIterator p(cmdline.begin_parameters()), p_end(cmdline.end_parameters()) ;
p != p_end ; ++p)
{
@@ -132,11 +132,13 @@ UninstallCommand::run(
target.append(":" + stringify((*i)->slot_key()->value()));
targets->push_back(target);
}
+
+ targets_cleaned_up->push_back("!" + stringify((*ids->begin())->name()));
}
}
return resolve_common(env, *cmdline.resolution_options, *cmdline.execution_options, *cmdline.display_options,
- *cmdline.program_options, make_null_shared_ptr(), targets, false);
+ *cmdline.program_options, make_null_shared_ptr(), targets, targets_cleaned_up, false);
}
std::tr1::shared_ptr<args::ArgsHandler>
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 97ec221..62f6319 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -355,7 +355,7 @@ namespace
throw InternalError(PALUDIS_HERE, stringify(r.destination_type()));
}
- void add_resolver_targets(
+ const std::tr1::shared_ptr<const Sequence<std::string> > add_resolver_targets(
const std::tr1::shared_ptr<Environment> & env,
const std::tr1::shared_ptr<Resolver> & resolver,
const ResolveCommandLineResolutionOptions &,
@@ -367,6 +367,7 @@ namespace
if (targets->empty())
throw args::DoHelp("Must specify at least one target");
+ const std::tr1::shared_ptr<Sequence<std::string> > result(new Sequence<std::string>);
bool seen_sets(false), seen_packages(false);
for (Sequence<std::string>::ConstIterator p(targets->begin()), p_end(targets->end()) ;
p != p_end ; ++p)
@@ -380,12 +381,16 @@ namespace
{
seen_packages = true;
PackageDepSpec s(parse_user_package_dep_spec(p->substr(1), env.get(), UserPackageDepSpecOptions()));
- resolver->add_target(BlockDepSpec(*p, s, false));
+ BlockDepSpec bs("!" + stringify(s), s, false);
+ result->push_back(stringify(bs));
+ resolver->add_target(bs);
}
else
{
- resolver->add_target(parse_user_package_dep_spec(*p, env.get(),
+ PackageDepSpec s(parse_user_package_dep_spec(*p, env.get(),
UserPackageDepSpecOptions() + updso_throw_if_set));
+ result->push_back(stringify(s));
+ resolver->add_target(s);
seen_packages = true;
}
}
@@ -395,6 +400,7 @@ namespace
throw args::DoHelp("Cannot specify multiple set targets");
resolver->add_target(SetName(*p));
+ result->push_back(*p);
seen_sets = true;
}
}
@@ -404,6 +410,8 @@ namespace
if (seen_sets)
is_set = true;
+
+ return result;
}
UseExisting use_existing_from_cmdline(const args::EnumArg & a, const bool is_set)
@@ -1409,6 +1417,7 @@ namespace
const ResolveCommandLineProgramOptions & program_options,
const std::tr1::shared_ptr<const Map<std::string, std::string> > & keys_if_import,
const std::tr1::shared_ptr<const Sequence<std::string> > & targets,
+ const std::tr1::shared_ptr<const Sequence<std::string> > & world_specs,
const bool is_set)
{
Context context("When performing chosen resolution:");
@@ -1445,6 +1454,13 @@ namespace
if (! resolution_options.a_execute.specified())
args->push_back("--pretend");
+ for (Sequence<std::string>::ConstIterator p(world_specs->begin()), p_end(world_specs->end()) ;
+ p != p_end ; ++p)
+ {
+ args->push_back("--world-specs");
+ args->push_back(*p);
+ }
+
for (Sequence<std::string>::ConstIterator p(targets->begin()), p_end(targets->end()) ;
p != p_end ; ++p)
args->push_back(*p);
@@ -1611,6 +1627,7 @@ paludis::cave::resolve_common(
const ResolveCommandLineProgramOptions & program_options,
const std::tr1::shared_ptr<const Map<std::string, std::string> > & keys_if_import,
const std::tr1::shared_ptr<const Sequence<std::string> > & targets_if_not_purge,
+ const std::tr1::shared_ptr<const Sequence<std::string> > & world_specs_if_not_auto,
const bool purge)
{
int retcode(0);
@@ -1822,6 +1839,7 @@ paludis::cave::resolve_common(
ScopedSelectionCache selection_cache(env.get());
std::tr1::shared_ptr<Resolver> resolver(new Resolver(env.get(), resolver_functions));
bool is_set(false);
+ std::tr1::shared_ptr<const Sequence<std::string> > targets_cleaned_up;
std::list<SuggestRestart> restarts;
try
@@ -1838,7 +1856,7 @@ paludis::cave::resolve_common(
if (purge)
resolver->purge();
else
- add_resolver_targets(env, resolver, resolution_options, targets_if_not_purge, is_set);
+ targets_cleaned_up = add_resolver_targets(env, resolver, resolution_options, targets_if_not_purge, is_set);
resolver->resolve();
break;
}
@@ -1881,6 +1899,7 @@ paludis::cave::resolve_common(
return perform_resolution(env, resolver->resolved(), resolution_options,
execution_options, program_options, keys_if_import,
purge ? make_shared_ptr(new const Sequence<std::string>) : targets_if_not_purge,
+ world_specs_if_not_auto ? world_specs_if_not_auto : targets_cleaned_up,
is_set);
}
catch (...)
diff --git a/src/clients/cave/resolve_common.hh b/src/clients/cave/resolve_common.hh
index 132e5da..ea0ef71 100644
--- a/src/clients/cave/resolve_common.hh
+++ b/src/clients/cave/resolve_common.hh
@@ -38,6 +38,7 @@ namespace paludis
const ResolveCommandLineProgramOptions & program_options,
const std::tr1::shared_ptr<const Map<std::string, std::string> > & keys_if_import,
const std::tr1::shared_ptr<const Sequence<std::string> > & targets_if_not_purge,
+ const std::tr1::shared_ptr<const Sequence<std::string> > & world_specs_if_not_auto,
const bool purge
) PALUDIS_ATTRIBUTE((warn_unused_result));
}
diff --git a/src/clients/cave/resume_data.cc b/src/clients/cave/resume_data.cc
index 2c9a9aa..c7358e9 100644
--- a/src/clients/cave/resume_data.cc
+++ b/src/clients/cave/resume_data.cc
@@ -47,11 +47,19 @@ ResumeData::deserialise(Deserialisation & d)
targets->push_back(vv.member<std::string>(stringify(n)));
}
+ std::tr1::shared_ptr<Sequence<std::string> > world_specs(new Sequence<std::string>);
+ {
+ Deserialisator vv(*v.find_remove_member("world_specs"), "c");
+ for (int n(1), n_end(vv.member<int>("count") + 1) ; n != n_end ; ++n)
+ world_specs->push_back(vv.member<std::string>(stringify(n)));
+ }
+
return make_shared_copy(make_named_values<ResumeData>(
n::job_lists() = v.member<std::tr1::shared_ptr<JobLists> >("job_lists"),
n::preserve_world() = v.member<bool>("preserve_world"),
n::target_set() = v.member<bool>("target_set"),
- n::targets() = targets
+ n::targets() = targets,
+ n::world_specs() = world_specs
));
}
@@ -63,6 +71,7 @@ ResumeData::serialise(Serialiser & s) const
.member(SerialiserFlags<>(), "preserve_world", preserve_world())
.member(SerialiserFlags<>(), "target_set", target_set())
.member(SerialiserFlags<serialise::might_be_null, serialise::container>(), "targets", targets())
+ .member(SerialiserFlags<serialise::might_be_null, serialise::container>(), "world_specs", world_specs())
;
}
diff --git a/src/clients/cave/resume_data.hh b/src/clients/cave/resume_data.hh
index d7a0319..2f3e5ea 100644
--- a/src/clients/cave/resume_data.hh
+++ b/src/clients/cave/resume_data.hh
@@ -34,6 +34,7 @@ namespace paludis
typedef Name<struct preserve_world_name> preserve_world;
typedef Name<struct target_set_name> target_set;
typedef Name<struct targets_name> targets;
+ typedef Name<struct world_specs_name> world_specs;
}
namespace cave
@@ -44,6 +45,7 @@ namespace paludis
NamedValue<n::preserve_world, bool> preserve_world;
NamedValue<n::target_set, bool> target_set;
NamedValue<n::targets, std::tr1::shared_ptr<Sequence<std::string> > > targets;
+ NamedValue<n::world_specs, std::tr1::shared_ptr<Sequence<std::string> > > world_specs;
void serialise(Serialiser &) const;
static const std::tr1::shared_ptr<ResumeData> deserialise(