aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-02-05 12:25:42 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-02-05 01:33:54 +0000
commita0a35b8d0dd4ca00c91350e3d3acf1bc6208cad1 (patch)
tree83a8c5994577da21ed70242add8e4cf041ee554c
parent23d144895a2c80a2f3ff6cd7aa9d94705394ca04 (diff)
downloadpaludis-a0a35b8d0dd4ca00c91350e3d3acf1bc6208cad1.tar.gz
paludis-a0a35b8d0dd4ca00c91350e3d3acf1bc6208cad1.tar.xz
Make slot a metadata key.
Fixes: ticket:450
-rw-r--r--doc/api/cplusplus/examples/example_metadata_key.cc6
-rw-r--r--doc/api/cplusplus/examples/example_package_id.cc1
-rw-r--r--paludis/dep_list.cc36
-rw-r--r--paludis/filter.cc78
-rw-r--r--paludis/filter.hh6
-rw-r--r--paludis/find_unused_packages_task.cc18
-rw-r--r--paludis/install_task.cc28
-rw-r--r--paludis/literal_metadata_key.cc11
-rw-r--r--paludis/literal_metadata_key.hh5
-rw-r--r--paludis/match_package.cc12
-rw-r--r--paludis/metadata_key.cc1
-rw-r--r--paludis/metadata_key.hh1
-rw-r--r--paludis/ndbam_merger.cc5
-rw-r--r--paludis/ndbam_unmerger.cc7
-rw-r--r--paludis/package_id.hh14
-rw-r--r--paludis/repositories/accounts/accounts_id.cc25
-rw-r--r--paludis/repositories/accounts/accounts_id.hh2
-rw-r--r--paludis/repositories/accounts/installed_accounts_id.cc25
-rw-r--r--paludis/repositories/accounts/installed_accounts_id.hh2
-rw-r--r--paludis/repositories/cran/cran_package_id.cc18
-rw-r--r--paludis/repositories/cran/cran_package_id.hh4
-rw-r--r--paludis/repositories/e/e_installed_repository_id.cc43
-rw-r--r--paludis/repositories/e/e_installed_repository_id.hh4
-rw-r--r--paludis/repositories/e/e_key.cc51
-rw-r--r--paludis/repositories/e/e_key.hh17
-rw-r--r--paludis/repositories/e/e_repository_sets.cc11
-rw-r--r--paludis/repositories/e/ebuild.cc6
-rw-r--r--paludis/repositories/e/ebuild.hh4
-rw-r--r--paludis/repositories/e/ebuild_entries.cc2
-rw-r--r--paludis/repositories/e/ebuild_flat_metadata_cache.cc11
-rw-r--r--paludis/repositories/e/ebuild_flat_metadata_cache_TEST.cc2
-rw-r--r--paludis/repositories/e/ebuild_id.cc42
-rw-r--r--paludis/repositories/e/ebuild_id.hh4
-rw-r--r--paludis/repositories/e/exndbam_repository.cc17
-rw-r--r--paludis/repositories/e/fix_locked_dependencies.cc10
-rw-r--r--paludis/repositories/e/qa/metadata_keys.cc5
-rw-r--r--paludis/repositories/e/qa/spec_keys.cc4
-rw-r--r--paludis/repositories/e/vdb_merger.cc5
-rw-r--r--paludis/repositories/e/vdb_repository.cc14
-rw-r--r--paludis/repositories/e/vdb_repository_TEST.cc20
-rw-r--r--paludis/repositories/e/vdb_unmerger.cc7
-rw-r--r--paludis/repositories/fake/fake_package_id.cc29
-rw-r--r--paludis/repositories/fake/fake_package_id.hh2
-rw-r--r--paludis/repositories/gems/gem_specification.cc15
-rw-r--r--paludis/repositories/gems/gem_specification.hh4
-rw-r--r--paludis/repositories/unavailable/unavailable_id.cc33
-rw-r--r--paludis/repositories/unavailable/unavailable_id.hh4
-rw-r--r--paludis/repositories/unpackaged/installed_id.cc25
-rw-r--r--paludis/repositories/unpackaged/installed_id.hh4
-rw-r--r--paludis/repositories/unpackaged/installed_repository.cc13
-rw-r--r--paludis/repositories/unpackaged/installed_repository_TEST.cc4
-rw-r--r--paludis/repositories/unpackaged/unpackaged_id.cc25
-rw-r--r--paludis/repositories/unpackaged/unpackaged_id.hh4
-rw-r--r--paludis/repositories/unpackaged/unpackaged_repository_TEST.cc2
-rw-r--r--paludis/repositories/unwritten/unwritten_id.cc29
-rw-r--r--paludis/repositories/unwritten/unwritten_id.hh9
-rw-r--r--paludis/repositories/unwritten/unwritten_repository_file.cc4
-rw-r--r--paludis/repositories/unwritten/unwritten_repository_file.hh4
-rw-r--r--paludis/repositories/virtuals/package_id.cc15
-rw-r--r--paludis/repositories/virtuals/package_id.hh2
-rw-r--r--paludis/selection.cc23
-rw-r--r--paludis/util/files.m41
-rw-r--r--paludis/util/make_shared_copy-fwd.hh45
-rw-r--r--paludis/util/make_shared_copy.hh47
-rw-r--r--python/metadata_key.cc75
-rw-r--r--python/package_id.cc8
-rwxr-xr-xpython/package_id_TEST.py12
-rw-r--r--ruby/metadata_key.cc36
-rw-r--r--ruby/package_id.cc23
-rw-r--r--ruby/package_id_TEST.rb12
-rw-r--r--src/clients/adjutrix/downgrade_check.cc46
-rw-r--r--src/clients/adjutrix/find_dropped_keywords.cc26
-rw-r--r--src/clients/adjutrix/find_stable_candidates.cc26
-rw-r--r--src/clients/adjutrix/keywords_graph.cc28
-rw-r--r--src/clients/cave/cmd_show.cc18
-rw-r--r--src/clients/cave/format_plain_metadata_key.cc7
-rw-r--r--src/clients/inquisitio/key_extractor.cc7
-rw-r--r--src/clients/instruo/instruo.cc5
-rw-r--r--src/clients/paludis/applets.cc7
-rw-r--r--src/clients/paludis/info.cc7
-rw-r--r--src/clients/qualudis/qualudis.cc7
-rw-r--r--src/clients/reconcilio/fix_linkage.cc21
-rw-r--r--src/output/console_install_task.cc29
-rw-r--r--src/output/console_query_task.cc30
-rw-r--r--src/output/mask_displayer.cc8
85 files changed, 916 insertions, 449 deletions
diff --git a/doc/api/cplusplus/examples/example_metadata_key.cc b/doc/api/cplusplus/examples/example_metadata_key.cc
index fcda0fa..63a1b52 100644
--- a/doc/api/cplusplus/examples/example_metadata_key.cc
+++ b/doc/api/cplusplus/examples/example_metadata_key.cc
@@ -57,6 +57,12 @@ namespace
cout << indent << left << setw(30) << " Value:" << " " << key.value() << endl;
}
+ void visit(const MetadataValueKey<SlotName> & key)
+ {
+ cout << indent << left << setw(30) << " Class:" << " " << "MetadataValueKey<SlotName>" << endl;
+ cout << indent << left << setw(30) << " Value:" << " " << key.value() << endl;
+ }
+
void visit(const MetadataValueKey<long> & key)
{
cout << indent << left << setw(30) << " Class:" << " " << "MetadataValueKey<long>" << endl;
diff --git a/doc/api/cplusplus/examples/example_package_id.cc b/doc/api/cplusplus/examples/example_package_id.cc
index d9b813e..8066870 100644
--- a/doc/api/cplusplus/examples/example_package_id.cc
+++ b/doc/api/cplusplus/examples/example_package_id.cc
@@ -59,7 +59,6 @@ int main(int argc, char * argv[])
/* Start by outputting some basic properties: */
cout << left << setw(30) << " Name:" << " " << (*i)->name() << endl;
cout << left << setw(30) << " Version:" << " " << (*i)->version() << endl;
- cout << left << setw(30) << " Slot:" << " " << (*i)->slot() << endl;
cout << left << setw(30) << " Repository Name:" << " " << (*i)->repository()->name() << endl;
/* The PackageID::canonical_form method should be used when
diff --git a/paludis/dep_list.cc b/paludis/dep_list.cc
index 3197673..ff068fd 100644
--- a/paludis/dep_list.cc
+++ b/paludis/dep_list.cc
@@ -345,6 +345,24 @@ namespace
{
}
};
+
+ bool slot_is_same(
+ const PackageID & a,
+ const PackageID & b)
+ {
+ if (a.slot_key())
+ return b.slot_key() && a.slot_key()->value() == b.slot_key()->value();
+ else
+ return ! b.slot_key();
+ }
+
+ std::string slot_as_human_string(const std::tr1::shared_ptr<const PackageID> & id)
+ {
+ if (! id->slot_key())
+ return "(no slot)";
+ else
+ return stringify(id->slot_key()->value());
+ }
}
void
@@ -551,7 +569,7 @@ DepList::AddVisitor::visit(const DependencySpecTree::NodeType<PackageDepSpec>::T
std::tr1::shared_ptr<PackageIDSequence> already_installed_in_same_slot(new PackageIDSequence);
for (PackageIDSequence::ConstIterator aa(already_installed->begin()),
aa_end(already_installed->end()) ; aa != aa_end ; ++aa)
- if ((*aa)->slot() == best_visible_candidate->slot())
+ if (slot_is_same(**aa, *best_visible_candidate))
already_installed_in_same_slot->push_back(*aa);
/* no need to sort already_installed_in_same_slot here, although if the above is
* changed then check that this still holds... */
@@ -590,8 +608,8 @@ DepList::AddVisitor::visit(const DependencySpecTree::NodeType<PackageDepSpec>::T
*best_visible_candidate << "' (in different slot)";
}
else
- Log::get_instance()->message("dep_list.no_installed", ll_debug, lc_context) << "No installed packages in SLOT '"
- << best_visible_candidate->slot() << "', taking uninstalled package '"
+ Log::get_instance()->message("dep_list.no_installed", ll_debug, lc_context) << "No installed packages in SLOT "
+ << slot_as_human_string(best_visible_candidate) << ", taking uninstalled package '"
<< *best_visible_candidate << "'";
/* if this is a downgrade, make sure that that's ok */
@@ -605,11 +623,9 @@ DepList::AddVisitor::visit(const DependencySpecTree::NodeType<PackageDepSpec>::T
{
std::tr1::shared_ptr<const PackageIDSequence> are_we_downgrading(
(*d->_imp->env)[selection::AllVersionsSorted(
- generator::Matches(make_package_dep_spec()
- .package(best_visible_candidate->name())
- .slot_requirement(make_shared_ptr(new UserSlotExactRequirement(best_visible_candidate->slot()))),
- d->_imp->opts->match_package_options()) |
- filter::SupportsAction<InstalledAction>())]);
+ generator::Package(best_visible_candidate->name()) |
+ filter::SupportsAction<InstalledAction>() |
+ filter::SameSlot(best_visible_candidate))]);
if (are_we_downgrading->empty())
break;
@@ -848,7 +864,7 @@ DepList::AddVisitor::visit(const DependencySpecTree::NodeType<BlockDepSpec>::Typ
bool replaced(false);
for (std::list<MergeList::const_iterator>::const_iterator r(will_be_installed.begin()),
r_end(will_be_installed.end()) ; r != r_end && ! replaced ; ++r)
- if ((*r)->package_id()->slot() == (*aa)->slot())
+ if (slot_is_same(*(*r)->package_id(), **aa))
{
/* if it's a virtual, it only replaces if it's the same package. */
if ((*r)->package_id()->virtual_for_key())
@@ -1643,7 +1659,7 @@ DepList::replaced(const PackageID & m) const
while (p.second != ((p.first = std::find_if(p.first, p.second,
MatchDepListEntryAgainstPackageDepSpec(_imp->env, spec, _imp->opts->match_package_options())))))
{
- if (p.first->second->package_id()->slot() != m.slot())
+ if (! slot_is_same(*p.first->second->package_id(), m))
p.first = next(p.first);
else
return true;
diff --git a/paludis/filter.cc b/paludis/filter.cc
index b6c3c8d..07bbd84 100644
--- a/paludis/filter.cc
+++ b/paludis/filter.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -235,36 +235,6 @@ namespace
}
};
- struct SlotFilterHandler :
- AllFilterHandlerBase
- {
- const SlotName n;
-
- SlotFilterHandler(const SlotName & nn) :
- n(nn)
- {
- }
-
- virtual std::tr1::shared_ptr<const PackageIDSet> ids(
- const Environment * const,
- const std::tr1::shared_ptr<const PackageIDSet> & id) const
- {
- std::tr1::shared_ptr<PackageIDSet> result(new PackageIDSet);
-
- for (PackageIDSet::ConstIterator i(id->begin()), i_end(id->end()) ;
- i != i_end ; ++i)
- if ((*i)->slot() == n)
- result->insert(*i);
-
- return result;
- }
-
- virtual std::string as_string() const
- {
- return "slot is '" + stringify(n) + "'";
- }
- };
-
struct AndFilterHandler :
FilterHandler
{
@@ -312,6 +282,44 @@ namespace
return stringify(f1) + " filtered through " + stringify(f2);
}
};
+
+ struct SameSlotHandler :
+ AllFilterHandlerBase
+ {
+ const std::tr1::shared_ptr<const PackageID> as_id;
+
+ SameSlotHandler(const std::tr1::shared_ptr<const PackageID> & i) :
+ as_id(i)
+ {
+ }
+
+ virtual std::tr1::shared_ptr<const PackageIDSet> ids(
+ const Environment * const,
+ const std::tr1::shared_ptr<const PackageIDSet> & id) const
+ {
+ std::tr1::shared_ptr<PackageIDSet> result(new PackageIDSet);
+
+ for (PackageIDSet::ConstIterator i(id->begin()), i_end(id->end()) ;
+ i != i_end ; ++i)
+ if (as_id->slot_key())
+ {
+ if ((*i)->slot_key() && (*i)->slot_key()->value() == as_id->slot_key()->value())
+ result->insert(*i);
+ }
+ else
+ {
+ if (! (*i)->slot_key())
+ result->insert(*i);
+ }
+
+ return result;
+ }
+
+ virtual std::string as_string() const
+ {
+ return "not masked";
+ }
+ };
}
filter::All::All() :
@@ -335,13 +343,13 @@ filter::InstalledAtRoot::InstalledAtRoot(const FSEntry & r) :
{
}
-filter::Slot::Slot(const SlotName & n) :
- Filter(make_shared_ptr(new SlotFilterHandler(n)))
+filter::And::And(const Filter & f1, const Filter & f2) :
+ Filter(make_shared_ptr(new AndFilterHandler(f1, f2)))
{
}
-filter::And::And(const Filter & f1, const Filter & f2) :
- Filter(make_shared_ptr(new AndFilterHandler(f1, f2)))
+filter::SameSlot::SameSlot(const std::tr1::shared_ptr<const PackageID> & i) :
+ Filter(make_shared_ptr(new SameSlotHandler(i)))
{
}
diff --git a/paludis/filter.hh b/paludis/filter.hh
index 361565e..7f826cf 100644
--- a/paludis/filter.hh
+++ b/paludis/filter.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -108,11 +108,11 @@ namespace paludis
And(const Filter &, const Filter &);
};
- class PALUDIS_VISIBLE Slot :
+ class PALUDIS_VISIBLE SameSlot :
public Filter
{
public:
- Slot(const SlotName &);
+ SameSlot(const std::tr1::shared_ptr<const PackageID> &);
};
}
diff --git a/paludis/find_unused_packages_task.cc b/paludis/find_unused_packages_task.cc
index 9c91594..be0178a 100644
--- a/paludis/find_unused_packages_task.cc
+++ b/paludis/find_unused_packages_task.cc
@@ -36,6 +36,17 @@
using namespace paludis;
+namespace
+{
+ std::string slot_as_string(const std::tr1::shared_ptr<const PackageID> & id)
+ {
+ if (id->slot_key())
+ return stringify(id->slot_key()->value());
+ else
+ return "(none)";
+ }
+}
+
FindUnusedPackagesTask::~FindUnusedPackagesTask()
{
}
@@ -49,7 +60,7 @@ FindUnusedPackagesTask::execute(const QualifiedPackageName & package)
generator::Package(package)
)]);
- SlotName old_slot("I_am_a_slot");
+ std::string old_slot("I am not a slot");
std::set<KeywordName> keywords;
for (PackageIDSequence::ReverseConstIterator p(packages->rbegin()), p_end(packages->rend()) ;
p != p_end ; ++p)
@@ -57,10 +68,10 @@ FindUnusedPackagesTask::execute(const QualifiedPackageName & package)
if (! (*p)->keywords_key())
continue;
- if ((*p)->slot() != old_slot)
+ if (slot_as_string(*p) != old_slot)
{
keywords.clear();
- old_slot = (*p)->slot();
+ old_slot = slot_as_string(*p);
}
std::tr1::shared_ptr<const KeywordNameSet> current_keywords((*p)->keywords_key()->value());
@@ -90,3 +101,4 @@ FindUnusedPackagesTask::execute(const QualifiedPackageName & package)
return result;
}
+
diff --git a/paludis/install_task.cc b/paludis/install_task.cc
index 3e42dc2..5fadd75 100644
--- a/paludis/install_task.cc
+++ b/paludis/install_task.cc
@@ -44,6 +44,7 @@
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/destringify.hh>
#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/make_shared_copy.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/indirect_iterator-impl.hh>
@@ -525,14 +526,17 @@ InstallTask::_add_package_id(const std::tr1::shared_ptr<const PackageID> & targe
if (! _imp->override_target_type)
_imp->dep_list.options()->target_type() = dl_target_package;
- std::tr1::shared_ptr<PackageDepSpec> spec(new PackageDepSpec(make_package_dep_spec()
- .package(target->name())
- .version_requirement(make_named_values<VersionRequirement>(
- value_for<n::version_operator>(vo_equal),
- value_for<n::version_spec>(target->version())))
- .slot_requirement(make_shared_ptr(new UserSlotExactRequirement(target->slot())))
- .in_repository(target->repository()->name())));
+ PartiallyMadePackageDepSpec part_spec;
+ part_spec.package(target->name());
+ part_spec.in_repository(target->repository()->name());
+ part_spec.version_requirement(make_named_values<VersionRequirement>(
+ value_for<n::version_operator>(vo_equal),
+ value_for<n::version_spec>(target->version())));
+ if (target->slot_key())
+ part_spec.slot_requirement(make_shared_ptr(new UserSlotExactRequirement(target->slot_key()->value())));
+
+ std::tr1::shared_ptr<PackageDepSpec> spec(make_shared_copy(PackageDepSpec(part_spec)));
spec->set_tag(std::tr1::shared_ptr<const DepTag>(new TargetDepTag));
_imp->targets->root()->append(spec);
@@ -831,12 +835,10 @@ InstallTask::_one(const DepList::Iterator dep, const int x, const int y, const i
if (dep->destination())
collision_list = (*_imp->env)[selection::AllVersionsSorted(
- generator::Matches(make_package_dep_spec()
- .package(dep->package_id()->name())
- .slot_requirement(make_shared_ptr(new UserSlotExactRequirement(dep->package_id()->slot())))
- .in_repository(dep->destination()->name()),
- MatchPackageOptions()) |
- filter::SupportsAction<UninstallAction>())];
+ generator::Package(dep->package_id()->name()) &
+ generator::InRepository(dep->destination()->name()) |
+ filter::SupportsAction<UninstallAction>() |
+ filter::SameSlot(dep->package_id()))];
// don't clean the thing we just installed
PackageIDSequence clean_list;
diff --git a/paludis/literal_metadata_key.cc b/paludis/literal_metadata_key.cc
index 95c134b..4fcb044 100644
--- a/paludis/literal_metadata_key.cc
+++ b/paludis/literal_metadata_key.cc
@@ -26,6 +26,7 @@
#include <paludis/formatter.hh>
#include <paludis/package_id.hh>
#include <paludis/action.hh>
+#include <paludis/name.hh>
#include <tr1/functional>
using namespace paludis;
@@ -95,7 +96,7 @@ namespace paludis
const std::string raw_name;
const std::string human_name;
const MetadataKeyType type;
- const T_ value;
+ T_ value;
Implementation(const std::string & r, const std::string & h, const MetadataKeyType t, const T_ & v) :
raw_name(r),
@@ -264,6 +265,13 @@ LiteralMetadataValueKey<T_>::raw_name() const
}
template <typename T_>
+void
+LiteralMetadataValueKey<T_>::change_value(const T_ & v)
+{
+ _imp->value = v;
+}
+
+template <typename T_>
MetadataKeyType
LiteralMetadataValueKey<T_>::type() const
{
@@ -335,6 +343,7 @@ LiteralMetadataValueKey<T_>::value() const
template class LiteralMetadataValueKey<FSEntry>;
template class LiteralMetadataValueKey<std::string>;
+template class LiteralMetadataValueKey<SlotName>;
template class LiteralMetadataValueKey<bool>;
template class LiteralMetadataValueKey<long>;
template class LiteralMetadataValueKey<std::tr1::shared_ptr<const PackageID> >;
diff --git a/paludis/literal_metadata_key.hh b/paludis/literal_metadata_key.hh
index 070398c..f1dea9d 100644
--- a/paludis/literal_metadata_key.hh
+++ b/paludis/literal_metadata_key.hh
@@ -132,6 +132,11 @@ namespace paludis
virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ /**
+ * \since 0.36
+ */
+ void change_value(const T_ &);
};
/**
diff --git a/paludis/match_package.cc b/paludis/match_package.cc
index d236bb6..15ebb4b 100644
--- a/paludis/match_package.cc
+++ b/paludis/match_package.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -47,18 +47,18 @@ namespace
{
struct SlotRequirementChecker
{
- const SlotName actual;
+ const PackageID & id;
bool result;
- SlotRequirementChecker(const SlotName & a) :
- actual(a),
+ SlotRequirementChecker(const PackageID & i) :
+ id(i),
result(true)
{
}
void visit(const SlotExactRequirement & s)
{
- result = (actual == s.slot());
+ result = id.slot_key() && id.slot_key()->value() == s.slot();
}
void visit(const SlotAnyLockedRequirement &)
@@ -190,7 +190,7 @@ paludis::match_package(
if (spec.slot_requirement_ptr())
{
- SlotRequirementChecker v(entry.slot());
+ SlotRequirementChecker v(entry);
spec.slot_requirement_ptr()->accept(v);
if (! v.result)
return false;
diff --git a/paludis/metadata_key.cc b/paludis/metadata_key.cc
index 1e9cddf..334358c 100644
--- a/paludis/metadata_key.cc
+++ b/paludis/metadata_key.cc
@@ -117,6 +117,7 @@ template class MetadataValueKey<std::string>;
template class MetadataValueKey<long>;
template class MetadataValueKey<bool>;
template class MetadataValueKey<FSEntry>;
+template class MetadataValueKey<SlotName>;
template class MetadataValueKey<std::tr1::shared_ptr<const PackageID> >;
template class MetadataValueKey<std::tr1::shared_ptr<const Contents> >;
template class MetadataValueKey<std::tr1::shared_ptr<const RepositoryMaskInfo> >;
diff --git a/paludis/metadata_key.hh b/paludis/metadata_key.hh
index 6d30a81..79d3c90 100644
--- a/paludis/metadata_key.hh
+++ b/paludis/metadata_key.hh
@@ -100,6 +100,7 @@ namespace paludis
MetadataValueKey<long>,
MetadataValueKey<bool>,
MetadataValueKey<FSEntry>,
+ MetadataValueKey<SlotName>,
MetadataValueKey<std::tr1::shared_ptr<const PackageID> >,
MetadataValueKey<std::tr1::shared_ptr<const Contents> >,
MetadataValueKey<std::tr1::shared_ptr<const RepositoryMaskInfo> >,
diff --git a/paludis/ndbam_merger.cc b/paludis/ndbam_merger.cc
index 9807f4e..c7e3b7b 100644
--- a/paludis/ndbam_merger.cc
+++ b/paludis/ndbam_merger.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -34,6 +34,7 @@
#include <paludis/environment.hh>
#include <paludis/package_database.hh>
#include <paludis/ndbam_merger.hh>
+#include <paludis/metadata_key.hh>
#include <fstream>
#include <iostream>
#include <iomanip>
@@ -93,7 +94,7 @@ NDBAMMerger::extend_hook(const Hook & h)
std::string pn(stringify(_imp->params.package_id()->name().package()));
std::string pvr(stringify(_imp->params.package_id()->version()));
std::string pv(stringify(_imp->params.package_id()->version().remove_revision()));
- std::string slot(stringify(_imp->params.package_id()->slot()));
+ std::string slot(_imp->params.package_id()->slot_key() ? stringify(_imp->params.package_id()->slot_key()->value()) : "");
return Merger::extend_hook(h)
("P", pn + "-" + pv)
diff --git a/paludis/ndbam_unmerger.cc b/paludis/ndbam_unmerger.cc
index d0fd485..03d4439 100644
--- a/paludis/ndbam_unmerger.cc
+++ b/paludis/ndbam_unmerger.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
* Copyright (c) 2007 Piotr Jaroszyński
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -37,6 +37,7 @@
#include <paludis/util/strip.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/metadata_key.hh>
#include <tr1/functional>
#include <list>
#include <map>
@@ -131,6 +132,7 @@ NDBAMUnmerger::extend_hook(const Hook & h) const
std::string pn(stringify(_imp->options.package_id()->name().package()));
std::string pvr(stringify(_imp->options.package_id()->version()));
std::string pv(stringify(_imp->options.package_id()->version().remove_revision()));
+ std::string slot(_imp->options.package_id()->slot_key() ? stringify(_imp->options.package_id()->slot_key()->value()) : "");
return result
("P", pn + "-" + pv)
@@ -142,7 +144,8 @@ NDBAMUnmerger::extend_hook(const Hook & h) const
("PVR", pvr)
("PF", pn + "-" + pvr)
("PNVR", pn + "-" + pvr)
- ("SLOT", stringify(_imp->options.package_id()->slot()));
+ ("SLOT", slot)
+ ;
}
return result;
diff --git a/paludis/package_id.hh b/paludis/package_id.hh
index 29e2fa6..3eab37a 100644
--- a/paludis/package_id.hh
+++ b/paludis/package_id.hh
@@ -67,7 +67,6 @@ namespace paludis
*
* - A name
* - A version
- * - A slot (which will be '0' if slots aren't used)
* - An owning repository
*
* It should be noted that the above together are not sufficient to uniquely
@@ -154,11 +153,6 @@ namespace paludis
virtual const VersionSpec version() const = 0;
/**
- * What is our package's slot?
- */
- virtual const SlotName slot() const = 0;
-
- /**
* What is our owning repository?
*/
virtual const std::tr1::shared_ptr<const Repository> repository() const = 0;
@@ -167,6 +161,14 @@ namespace paludis
///\{
/**
+ * The slot, if specified, controls whether the package can be
+ * installed in parallel with other versions of the same package.
+ *
+ * \since 0.36
+ */
+ virtual const std::tr1::shared_ptr<const MetadataValueKey<SlotName> > slot_key() const = 0;
+
+ /**
* The virtual_for_key, if non-zero, indicates that we are an
* (old-style) virtual for another package. This affects dependency
* resolution.
diff --git a/paludis/repositories/accounts/accounts_id.cc b/paludis/repositories/accounts/accounts_id.cc
index aea9691..2f4b6a8 100644
--- a/paludis/repositories/accounts/accounts_id.cc
+++ b/paludis/repositories/accounts/accounts_id.cc
@@ -48,7 +48,6 @@ namespace paludis
const QualifiedPackageName name;
const VersionSpec version;
- const SlotName slot;
const std::tr1::shared_ptr<const Repository> repository;
const std::tr1::shared_ptr<const LiteralMetadataValueKey<FSEntry> > fs_location_key;
@@ -79,7 +78,6 @@ namespace paludis
env(e),
name(q),
version("0"),
- slot("0"),
repository(r),
fs_location_key(new LiteralMetadataValueKey<FSEntry>("location", "Location", mkt_internal, l)),
from_repositories_key(f),
@@ -243,12 +241,6 @@ AccountsID::version() const
return _imp->version;
}
-const SlotName
-AccountsID::slot() const
-{
- return _imp->slot;
-}
-
const std::tr1::shared_ptr<const Repository>
AccountsID::repository() const
{
@@ -261,10 +253,10 @@ AccountsID::canonical_form(const PackageIDCanonicalForm f) const
switch (f)
{
case idcf_full:
- return stringify(name()) + "-" + stringify(version()) + ":" + stringify(slot()) + "::" + stringify(repository()->name());
+ return stringify(name()) + "-" + stringify(version()) + "::" + stringify(repository()->name());
case idcf_no_version:
- return stringify(name()) + ":" + stringify(slot()) + "::" + stringify(repository()->name());
+ return stringify(name()) + "::" + stringify(repository()->name());
case idcf_version:
return stringify(version());
@@ -398,6 +390,12 @@ AccountsID::choices_key() const
return make_null_shared_ptr();
}
+const std::tr1::shared_ptr<const MetadataValueKey<SlotName> >
+AccountsID::slot_key() const
+{
+ return make_null_shared_ptr();
+}
+
std::tr1::shared_ptr<const Set<std::string> >
AccountsID::breaks_portage() const
{
@@ -405,18 +403,15 @@ AccountsID::breaks_portage() const
}
bool
-AccountsID::arbitrary_less_than_comparison(const PackageID & other) const
+AccountsID::arbitrary_less_than_comparison(const PackageID &) const
{
- if (slot() < other.slot())
- return true;
-
return false;
}
std::size_t
AccountsID::extra_hash_value() const
{
- return Hash<SlotName>()(slot());
+ return 0;
}
bool
diff --git a/paludis/repositories/accounts/accounts_id.hh b/paludis/repositories/accounts/accounts_id.hh
index 557294c..a2df466 100644
--- a/paludis/repositories/accounts/accounts_id.hh
+++ b/paludis/repositories/accounts/accounts_id.hh
@@ -56,12 +56,12 @@ namespace paludis
virtual const QualifiedPackageName name() const;
virtual const VersionSpec version() const;
- virtual const SlotName slot() const;
virtual const std::tr1::shared_ptr<const Repository> repository() const;
///\name Specific metadata keys
///\{
+ virtual const std::tr1::shared_ptr<const MetadataValueKey<SlotName> > slot_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<std::tr1::shared_ptr<const PackageID> > > virtual_for_key() const;
virtual const std::tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> > keywords_key() const;
virtual const std::tr1::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> > provide_key() const;
diff --git a/paludis/repositories/accounts/installed_accounts_id.cc b/paludis/repositories/accounts/installed_accounts_id.cc
index 67eaa15..ab613a1 100644
--- a/paludis/repositories/accounts/installed_accounts_id.cc
+++ b/paludis/repositories/accounts/installed_accounts_id.cc
@@ -45,7 +45,6 @@ namespace paludis
const QualifiedPackageName name;
const VersionSpec version;
- const SlotName slot;
const std::tr1::shared_ptr<const Repository> repository;
const std::tr1::shared_ptr<const LiteralMetadataValueKey<bool> > transient_key;
@@ -58,7 +57,6 @@ namespace paludis
env(e),
name(q),
version("0"),
- slot("0"),
repository(r),
transient_key(new LiteralMetadataValueKey<bool>("transient", "Transient", mkt_internal, true)),
is_user(u)
@@ -106,12 +104,6 @@ InstalledAccountsID::version() const
return _imp->version;
}
-const SlotName
-InstalledAccountsID::slot() const
-{
- return _imp->slot;
-}
-
const std::tr1::shared_ptr<const Repository>
InstalledAccountsID::repository() const
{
@@ -124,10 +116,10 @@ InstalledAccountsID::canonical_form(const PackageIDCanonicalForm f) const
switch (f)
{
case idcf_full:
- return stringify(name()) + "-" + stringify(version()) + ":" + stringify(slot()) + "::" + stringify(repository()->name());
+ return stringify(name()) + "-" + stringify(version()) + "::" + stringify(repository()->name());
case idcf_no_version:
- return stringify(name()) + ":" + stringify(slot()) + "::" + stringify(repository()->name());
+ return stringify(name()) + "::" + stringify(repository()->name());
case idcf_version:
return stringify(version());
@@ -253,6 +245,12 @@ InstalledAccountsID::choices_key() const
return make_null_shared_ptr();
}
+const std::tr1::shared_ptr<const MetadataValueKey<SlotName> >
+InstalledAccountsID::slot_key() const
+{
+ return make_null_shared_ptr();
+}
+
std::tr1::shared_ptr<const Set<std::string> >
InstalledAccountsID::breaks_portage() const
{
@@ -260,18 +258,15 @@ InstalledAccountsID::breaks_portage() const
}
bool
-InstalledAccountsID::arbitrary_less_than_comparison(const PackageID & other) const
+InstalledAccountsID::arbitrary_less_than_comparison(const PackageID &) const
{
- if (slot() < other.slot())
- return true;
-
return false;
}
std::size_t
InstalledAccountsID::extra_hash_value() const
{
- return Hash<SlotName>()(slot());
+ return 0;
}
bool
diff --git a/paludis/repositories/accounts/installed_accounts_id.hh b/paludis/repositories/accounts/installed_accounts_id.hh
index 436dc2f..c6280b5 100644
--- a/paludis/repositories/accounts/installed_accounts_id.hh
+++ b/paludis/repositories/accounts/installed_accounts_id.hh
@@ -54,12 +54,12 @@ namespace paludis
virtual const QualifiedPackageName name() const;
virtual const VersionSpec version() const;
- virtual const SlotName slot() const;
virtual const std::tr1::shared_ptr<const Repository> repository() const;
///\name Specific metadata keys
///\{
+ virtual const std::tr1::shared_ptr<const MetadataValueKey<SlotName> > slot_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<std::tr1::shared_ptr<const PackageID> > > virtual_for_key() const;
virtual const std::tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> > keywords_key() const;
virtual const std::tr1::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> > provide_key() const;
diff --git a/paludis/repositories/cran/cran_package_id.cc b/paludis/repositories/cran/cran_package_id.cc
index 60c71f7..685d05d 100644
--- a/paludis/repositories/cran/cran_package_id.cc
+++ b/paludis/repositories/cran/cran_package_id.cc
@@ -2,7 +2,7 @@
/*
* Copyright (c) 2006, 2007 Danny van Dyk
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -312,12 +312,6 @@ CRANPackageID::version() const
return _imp->version;
}
-const SlotName
-CRANPackageID::slot() const
-{
- return SlotName("0");
-}
-
const std::tr1::shared_ptr<const Repository>
CRANPackageID::repository() const
{
@@ -408,6 +402,12 @@ CRANPackageID::from_repositories_key() const
return std::tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > >();
}
+const std::tr1::shared_ptr<const MetadataValueKey<SlotName> >
+CRANPackageID::slot_key() const
+{
+ return make_null_shared_ptr();
+}
+
std::size_t
CRANPackageID::extra_hash_value() const
{
@@ -434,13 +434,13 @@ CRANPackageID::canonical_form(const PackageIDCanonicalForm f) const
switch (f)
{
case idcf_full:
- return stringify(_imp->name) + "-" + stringify(_imp->version) + ":" + stringify(slot()) + "::" + stringify(_imp->repository->name());
+ return stringify(_imp->name) + "-" + stringify(_imp->version) + "::" + stringify(_imp->repository->name());
case idcf_version:
return stringify(_imp->version);
case idcf_no_version:
- return stringify(_imp->name) + ":" + stringify(slot()) + "::" + stringify(_imp->repository->name());
+ return stringify(_imp->name) + "::" + stringify(_imp->repository->name());
case last_idcf:
break;
diff --git a/paludis/repositories/cran/cran_package_id.hh b/paludis/repositories/cran/cran_package_id.hh
index cff80a0..1b63c0f 100644
--- a/paludis/repositories/cran/cran_package_id.hh
+++ b/paludis/repositories/cran/cran_package_id.hh
@@ -2,7 +2,7 @@
/*
* Copyright (c) 2006 Danny van Dyk
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -54,9 +54,9 @@ namespace paludis
virtual const QualifiedPackageName name() const;
virtual const VersionSpec version() const;
- virtual const SlotName slot() const;
virtual const std::tr1::shared_ptr<const Repository> repository() const;
+ virtual const std::tr1::shared_ptr<const MetadataValueKey<SlotName> > slot_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<std::tr1::shared_ptr<const PackageID> > > virtual_for_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<std::tr1::shared_ptr<const Choices> > > choices_key() const;
virtual const std::tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> > keywords_key() const;
diff --git a/paludis/repositories/e/e_installed_repository_id.cc b/paludis/repositories/e/e_installed_repository_id.cc
index 6c3791d..c4f1e85 100644
--- a/paludis/repositories/e/e_installed_repository_id.cc
+++ b/paludis/repositories/e/e_installed_repository_id.cc
@@ -75,9 +75,9 @@ namespace paludis
const FSEntry dir;
mutable bool has_keys;
- std::tr1::shared_ptr<const SlotName> slot;
std::tr1::shared_ptr<const EAPI> eapi;
+ std::tr1::shared_ptr<const MetadataValueKey<SlotName> > slot;
std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > fs_location;
std::tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > > raw_use;
std::tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > > inherited;
@@ -193,6 +193,14 @@ EInstalledRepositoryID::need_keys_added() const
add_metadata_key(_imp->raw_use);
}
+ if (! vars->slot()->name().empty())
+ if ((_imp->dir / vars->slot()->name()).exists())
+ {
+ _imp->slot.reset(new LiteralMetadataValueKey<SlotName>(vars->slot()->name(), vars->slot()->description(),
+ mkt_internal, SlotName(file_contents(_imp->dir / vars->slot()->name()))));
+ add_metadata_key(_imp->slot);
+ }
+
if (! vars->inherited()->name().empty())
if ((_imp->dir / vars->inherited()->name()).exists())
{
@@ -534,14 +542,14 @@ EInstalledRepositoryID::canonical_form(const PackageIDCanonicalForm f) const
{
case idcf_full:
if (_imp->slot)
- return stringify(name()) + "-" + stringify(version()) + ":" + stringify(slot()) + "::" +
+ return stringify(name()) + "-" + stringify(version()) + ":" + stringify(_imp->slot->value()) + "::" +
stringify(repository()->name());
return stringify(name()) + "-" + stringify(version()) + "::" + stringify(repository()->name());
case idcf_no_version:
if (_imp->slot)
- return stringify(name()) + ":" + stringify(slot()) + "::" +
+ return stringify(name()) + ":" + stringify(_imp->slot->value()) + "::" +
stringify(repository()->name());
return stringify(name()) + "::" + stringify(repository()->name());
@@ -568,28 +576,6 @@ EInstalledRepositoryID::version() const
return _imp->version;
}
-const SlotName
-EInstalledRepositoryID::slot() const
-{
- Lock l(_imp->mutex);
-
- if (_imp->slot)
- return *_imp->slot;
-
- Context context("When finding SLOT for '" + stringify(name()) + "-" + stringify(version()) + "::"
- + stringify(repository()->name()) + "':");
-
- if ((_imp->dir / "SLOT").exists())
- _imp->slot.reset(new SlotName(file_contents(_imp->dir / "SLOT")));
- else
- {
- Log::get_instance()->message("e.no_slot", ll_warning, lc_context) << "No SLOT entry in '" << _imp->dir << "', pretending '0'";
- _imp->slot.reset(new SlotName("0"));
- }
-
- return *_imp->slot;
-}
-
const std::tr1::shared_ptr<const Repository>
EInstalledRepositoryID::repository() const
{
@@ -955,6 +941,13 @@ EInstalledRepositoryID::contained_in_key() const
return std::tr1::shared_ptr<const MetadataValueKey<std::tr1::shared_ptr<const PackageID> > >();
}
+const std::tr1::shared_ptr<const MetadataValueKey<SlotName> >
+EInstalledRepositoryID::slot_key() const
+{
+ need_keys_added();
+ return _imp->slot;
+}
+
std::tr1::shared_ptr<ChoiceValue>
EInstalledRepositoryID::make_choice_value(const std::tr1::shared_ptr<const Choice> & c, const UnprefixedChoiceName & v,
const Tribool, const bool explicitly_listed, const std::string & override_description, const bool) const
diff --git a/paludis/repositories/e/e_installed_repository_id.hh b/paludis/repositories/e/e_installed_repository_id.hh
index 24a5c1e..7d7be40 100644
--- a/paludis/repositories/e/e_installed_repository_id.hh
+++ b/paludis/repositories/e/e_installed_repository_id.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -54,10 +54,10 @@ namespace paludis
virtual const QualifiedPackageName name() const;
virtual const VersionSpec version() const;
- virtual const SlotName slot() const;
virtual const std::tr1::shared_ptr<const Repository> repository() const;
virtual const std::tr1::shared_ptr<const EAPI> eapi() const;
+ virtual const std::tr1::shared_ptr<const MetadataValueKey<SlotName> > slot_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<std::tr1::shared_ptr<const PackageID> > > virtual_for_key() const;
virtual const std::tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> > keywords_key() const;
virtual const std::tr1::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> > provide_key() const;
diff --git a/paludis/repositories/e/e_key.cc b/paludis/repositories/e/e_key.cc
index 613607e..d284c63 100644
--- a/paludis/repositories/e/e_key.cc
+++ b/paludis/repositories/e/e_key.cc
@@ -1120,3 +1120,54 @@ EMTimeKey::type() const
return _imp->type;
}
+namespace paludis
+{
+ template <>
+ struct Implementation<ESlotKey>
+ {
+ const SlotName value;
+ const std::tr1::shared_ptr<const EAPIMetadataVariable> variable;
+ const MetadataKeyType type;
+
+ Implementation(const SlotName & v, const std::tr1::shared_ptr<const EAPIMetadataVariable> & m, const MetadataKeyType t) :
+ value(v),
+ variable(m),
+ type(t)
+ {
+ }
+ };
+}
+
+ESlotKey::ESlotKey(const std::tr1::shared_ptr<const EAPIMetadataVariable> & m, const std::string & v, const MetadataKeyType t) :
+ PrivateImplementationPattern<ESlotKey>(new Implementation<ESlotKey>(SlotName(v), m, t))
+{
+}
+
+ESlotKey::~ESlotKey()
+{
+}
+
+const SlotName
+ESlotKey::value() const
+{
+ return _imp->value;
+}
+
+const std::string
+ESlotKey::raw_name() const
+{
+ return _imp->variable->name();
+}
+
+const std::string
+ESlotKey::human_name() const
+{
+ return _imp->variable->description();
+}
+
+MetadataKeyType
+ESlotKey::type() const
+{
+ return _imp->type;
+}
+
diff --git a/paludis/repositories/e/e_key.hh b/paludis/repositories/e/e_key.hh
index 0cb4409..03c7b1e 100644
--- a/paludis/repositories/e/e_key.hh
+++ b/paludis/repositories/e/e_key.hh
@@ -316,6 +316,23 @@ namespace paludis
virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
+
+ class ESlotKey :
+ public MetadataValueKey<SlotName>,
+ private PrivateImplementationPattern<ESlotKey>
+ {
+ public:
+ ESlotKey(
+ const std::tr1::shared_ptr<const EAPIMetadataVariable> &,
+ const std::string &, const MetadataKeyType);
+ ~ESlotKey();
+
+ virtual const SlotName value() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
}
}
diff --git a/paludis/repositories/e/e_repository_sets.cc b/paludis/repositories/e/e_repository_sets.cc
index d94cca6..65610b8 100644
--- a/paludis/repositories/e/e_repository_sets.cc
+++ b/paludis/repositories/e/e_repository_sets.cc
@@ -50,6 +50,7 @@
#include <paludis/filter.hh>
#include <paludis/filtered_generator.hh>
#include <paludis/action-fwd.hh>
+#include <paludis/metadata_key.hh>
#include <tr1/functional>
#include <algorithm>
#include <list>
@@ -181,7 +182,7 @@ namespace
{
try
{
- if (e.slot() != SlotName(r.slot()))
+ if ((! e.slot_key()) || (e.slot_key()->value() != SlotName(r.slot())))
return false;
}
catch (const SlotNameError &)
@@ -310,17 +311,15 @@ ERepositorySets::security_set(bool insecurity) const
else
{
Context local_local_local_context("When finding upgrade for '" + stringify(glsa_pkg->name()) + ":"
- + stringify((*c)->slot()) + "'");
+ + ((*c)->slot_key() ? stringify((*c)->slot_key()->value()) : "(none)") + "'");
/* we need to find the best not vulnerable installable package that isn't masked
* that's in the same slot as our vulnerable installed package. */
bool ok(false);
std::tr1::shared_ptr<const PackageIDSequence> available(
(*_imp->environment)[selection::AllVersionsSorted(
- generator::Matches(make_package_dep_spec()
- .package(glsa_pkg->name())
- .slot_requirement(make_shared_ptr(new ELikeSlotExactRequirement((*c)->slot(), false))),
- MatchPackageOptions()) |
+ generator::Package(glsa_pkg->name()) |
+ filter::SameSlot(*c) |
filter::SupportsAction<InstallAction>() |
filter::NotMasked())]);
diff --git a/paludis/repositories/e/ebuild.cc b/paludis/repositories/e/ebuild.cc
index 3406b89..245232a 100644
--- a/paludis/repositories/e/ebuild.cc
+++ b/paludis/repositories/e/ebuild.cc
@@ -397,7 +397,6 @@ EbuildMetadataCommand::load(const std::tr1::shared_ptr<const EbuildID> & id)
{
Log::get_instance()->message("e.ebuild.preload_eapi.unsupported", ll_debug, lc_context)
<< "ID pre-load EAPI '" << id->eapi()->name() << "' not supported";
- id->set_slot(SlotName("UNKNOWN"));
if (! captured_stderr.empty())
id->load_captured_stderr("STDERR", "Captured stderr", mkt_normal, captured_stderr);
@@ -418,7 +417,6 @@ EbuildMetadataCommand::load(const std::tr1::shared_ptr<const EbuildID> & id)
{
Log::get_instance()->message("e.ebuild.postload_eapi.unsupported", ll_debug, lc_context)
<< "ID post-load EAPI '" << id->eapi()->name() << "' not supported";
- id->set_slot(SlotName("UNKNOWN"));
if (! captured_stderr.empty())
id->load_captured_stderr("STDERR", "Captured stderr", mkt_normal, captured_stderr);
return;
@@ -474,7 +472,7 @@ EbuildMetadataCommand::load(const std::tr1::shared_ptr<const EbuildID> & id)
<< "Package '" << *id << "' set SLOT=\"\", using SLOT=\"0\" instead";
slot = "0";
}
- id->set_slot(SlotName(slot));
+ id->load_slot(m.slot(), slot);
}
catch (const InternalError &)
{
@@ -485,7 +483,7 @@ EbuildMetadataCommand::load(const std::tr1::shared_ptr<const EbuildID> & id)
Log::get_instance()->message("e.ebuild.bad_slot", ll_warning, lc_context)
<< "Setting SLOT for '" << *id << "' failed due to exception '"
<< e.message() << "' (" << e.what() << ")";
- id->set_slot(SlotName("0"));
+ id->load_slot(m.slot(), "0");
}
}
diff --git a/paludis/repositories/e/ebuild.hh b/paludis/repositories/e/ebuild.hh
index 289c4b8..2e4613b 100644
--- a/paludis/repositories/e/ebuild.hh
+++ b/paludis/repositories/e/ebuild.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -149,7 +149,7 @@ namespace paludis
NamedValue<n::loadsaveenv_dir, FSEntry> loadsaveenv_dir;
NamedValue<n::profiles, std::tr1::shared_ptr<const FSEntrySequence> > profiles;
NamedValue<n::root, std::string> root;
- NamedValue<n::slot, SlotName> slot;
+ NamedValue<n::slot, std::string> slot;
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/paludis/repositories/e/ebuild_entries.cc b/paludis/repositories/e/ebuild_entries.cc
index c40b020..3b6bd4a 100644
--- a/paludis/repositories/e/ebuild_entries.cc
+++ b/paludis/repositories/e/ebuild_entries.cc
@@ -752,7 +752,7 @@ EbuildEntries::install(const std::tr1::shared_ptr<const ERepositoryID> & id,
value_for<n::loadsaveenv_dir>(_imp->params.builddir() / (stringify(id->name().category()) + "-" + stringify(id->name().package()) + "-" + stringify(id->version())) / "temp"),
value_for<n::profiles>(_imp->params.profiles()),
value_for<n::root>(o.destination()->installed_root_key() ? stringify(o.destination()->installed_root_key()->value()) : "/"),
- value_for<n::slot>(SlotName(id->slot())),
+ value_for<n::slot>(id->slot_key() ? stringify(id->slot_key()->value()) : ""),
value_for<n::use>(use),
value_for<n::use_expand>(join(p->use_expand()->begin(), p->use_expand()->end(), " ")),
value_for<n::use_expand_hidden>(join(p->use_expand_hidden()->begin(), p->use_expand_hidden()->end(), " "))
diff --git a/paludis/repositories/e/ebuild_flat_metadata_cache.cc b/paludis/repositories/e/ebuild_flat_metadata_cache.cc
index 8e6f83f..e8376cc 100644
--- a/paludis/repositories/e/ebuild_flat_metadata_cache.cc
+++ b/paludis/repositories/e/ebuild_flat_metadata_cache.cc
@@ -175,7 +175,7 @@ namespace
if (-1 != m.run_depend()->flat_list_index() && ! m.run_depend()->name().empty())
id->load_run_depend(m.run_depend()->name(), m.run_depend()->description(), lines.at(m.run_depend()->flat_list_index()));
- id->set_slot(SlotName(lines.at(m.slot()->flat_list_index())));
+ id->load_slot(m.slot(), lines.at(m.slot()->flat_list_index()));
if (-1 != m.src_uri()->flat_list_index() && ! m.src_uri()->name().empty())
id->load_src_uri(m.src_uri(), lines.at(m.src_uri()->flat_list_index()));
@@ -269,8 +269,6 @@ namespace
id->load_remote_ids(m.remote_ids(), value);
}
}
- else
- id->set_slot(SlotName("UNKNOWN"));
Log::get_instance()->message("e.cache.success", ll_debug, lc_context) << "Successfully loaded cache file";
return true;
@@ -491,7 +489,7 @@ EbuildFlatMetadataCache::load(const std::tr1::shared_ptr<const EbuildID> & id)
if (! m.run_depend()->name().empty())
id->load_run_depend(m.run_depend()->name(), m.run_depend()->description(), keys[m.run_depend()->name()]);
- id->set_slot(SlotName(keys[m.slot()->name()]));
+ id->load_slot(m.slot(), keys[m.slot()->name()]);
if (! m.src_uri()->name().empty())
id->load_src_uri(m.src_uri(), keys[m.src_uri()->name()]);
@@ -584,8 +582,6 @@ EbuildFlatMetadataCache::load(const std::tr1::shared_ptr<const EbuildID> & id)
id->load_remote_ids(m.remote_ids(), value);
}
}
- else
- id->set_slot(SlotName("UNKNOWN"));
Log::get_instance()->message("e.cache.success", ll_debug, lc_context) << "Successfully loaded cache file";
return true;
@@ -722,7 +718,8 @@ EbuildFlatMetadataCache::save(const std::tr1::shared_ptr<const EbuildID> & id)
if (! m.run_depend()->name().empty() && id->run_dependencies_key())
write_kv(cache, m.run_depend()->name(), flatten(id->run_dependencies_key()->value()));
- write_kv(cache, m.slot()->name(), normalise(id->slot()));
+ if (! m.slot()->name().empty() && id->slot_key())
+ write_kv(cache, m.slot()->name(), normalise(id->slot_key()->value()));
if (! m.src_uri()->name().empty() && id->fetches_key())
write_kv(cache, m.src_uri()->name(), flatten(id->fetches_key()->value()));
diff --git a/paludis/repositories/e/ebuild_flat_metadata_cache_TEST.cc b/paludis/repositories/e/ebuild_flat_metadata_cache_TEST.cc
index aa60697..53441c7 100644
--- a/paludis/repositories/e/ebuild_flat_metadata_cache_TEST.cc
+++ b/paludis/repositories/e/ebuild_flat_metadata_cache_TEST.cc
@@ -305,7 +305,7 @@ namespace test_cases
TEST_CHECK(id->short_description_key());
TEST_CHECK_EQUAL(id->short_description_key()->value(), "");
- TEST_CHECK_STRINGIFY_EQUAL(id->slot(), "the-slot");
+ TEST_CHECK_STRINGIFY_EQUAL(id->slot_key()->value(), "the-slot");
}
} test_metadata_flat_hash_empty_value;
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index db3bbef..bec57ed 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -70,7 +70,6 @@ namespace paludis
const Environment * const environment;
const std::tr1::shared_ptr<const ERepository> repository;
const FSEntry ebuild;
- std::tr1::shared_ptr<const SlotName> slot;
mutable std::tr1::shared_ptr<const EAPI> eapi;
const std::string guessed_eapi;
const time_t master_mtime;
@@ -78,6 +77,7 @@ namespace paludis
mutable bool has_keys;
mutable bool has_masks;
+ mutable std::tr1::shared_ptr<const ESlotKey> slot;
mutable std::tr1::shared_ptr<const LiteralMetadataValueKey<FSEntry> > fs_location;
mutable std::tr1::shared_ptr<const LiteralMetadataValueKey<std::string> > short_description;
mutable std::tr1::shared_ptr<const LiteralMetadataValueKey<std::string> > long_description;
@@ -508,14 +508,14 @@ EbuildID::canonical_form(const PackageIDCanonicalForm f) const
{
case idcf_full:
if (_imp->slot)
- return stringify(name()) + "-" + stringify(version()) + ":" + stringify(*_imp->slot) +
+ return stringify(name()) + "-" + stringify(version()) + ":" + stringify(_imp->slot->value()) +
"::" + stringify(repository()->name());
return stringify(name()) + "-" + stringify(version()) + "::" + stringify(repository()->name());
case idcf_no_version:
if (_imp->slot)
- return stringify(name()) + ":" + stringify(*_imp->slot) +
+ return stringify(name()) + ":" + stringify(_imp->slot->value()) +
"::" + stringify(repository()->name());
return stringify(name()) + "::" + stringify(repository()->name());
@@ -542,20 +542,6 @@ EbuildID::version() const
return _imp->version;
}
-const SlotName
-EbuildID::slot() const
-{
- if (_imp->slot)
- return *_imp->slot;
-
- need_keys_added();
-
- if (! _imp->slot)
- throw InternalError(PALUDIS_HERE, "_imp->slot still not set");
-
- return *_imp->slot;
-}
-
const std::tr1::shared_ptr<const Repository>
EbuildID::repository() const
{
@@ -777,13 +763,6 @@ EbuildID::set_eapi(const std::string & s) const
_imp->eapi = EAPIData::get_instance()->eapi_from_string(s);
}
-void
-EbuildID::set_slot(const SlotName & s) const
-{
- Lock l(_imp->mutex);
- _imp->slot.reset(new SlotName(s));
-}
-
std::tr1::shared_ptr<const ERepository>
EbuildID::e_repository() const
{
@@ -980,6 +959,14 @@ EbuildID::load_remote_ids(const std::tr1::shared_ptr<const EAPIMetadataVariable>
add_metadata_key(_imp->remote_ids);
}
+void
+EbuildID::load_slot(const std::tr1::shared_ptr<const EAPIMetadataVariable> & m, const std::string & v) const
+{
+ Lock l(_imp->mutex);
+ _imp->slot.reset(new ESlotKey(m, v, mkt_internal));
+ add_metadata_key(_imp->slot);
+}
+
namespace
{
struct SupportsActionQuery
@@ -1168,6 +1155,13 @@ EbuildID::choices_key() const
return _imp->choices;
}
+const std::tr1::shared_ptr<const MetadataValueKey<SlotName> >
+EbuildID::slot_key() const
+{
+ need_keys_added();
+ return _imp->slot;
+}
+
std::tr1::shared_ptr<ChoiceValue>
EbuildID::make_choice_value(
const std::tr1::shared_ptr<const Choice> & choice,
diff --git a/paludis/repositories/e/ebuild_id.hh b/paludis/repositories/e/ebuild_id.hh
index 3694ceb..943aec0 100644
--- a/paludis/repositories/e/ebuild_id.hh
+++ b/paludis/repositories/e/ebuild_id.hh
@@ -60,9 +60,9 @@ namespace paludis
virtual const QualifiedPackageName name() const;
virtual const VersionSpec version() const;
- virtual const SlotName slot() const;
virtual const std::tr1::shared_ptr<const Repository> repository() const;
+ virtual const std::tr1::shared_ptr<const MetadataValueKey<SlotName> > slot_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<std::tr1::shared_ptr<const PackageID> > > virtual_for_key() const;
virtual const std::tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> > keywords_key() const;
virtual const std::tr1::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> > provide_key() const;
@@ -111,7 +111,6 @@ namespace paludis
virtual std::tr1::shared_ptr<const ERepository> e_repository() const;
void set_eapi(const std::string &) const;
- void set_slot(const SlotName &) const;
void load_short_description(const std::string &, const std::string &, const std::string &) const;
void load_captured_stderr(const std::string &, const std::string &, const MetadataKeyType, const std::string &) const;
@@ -136,6 +135,7 @@ namespace paludis
void load_bugs_to(const std::tr1::shared_ptr<const EAPIMetadataVariable> &, const std::string &) const;
void load_remote_ids(const std::tr1::shared_ptr<const EAPIMetadataVariable> &, const std::string &) const;
void load_defined_phases(const std::string &, const std::string &, const std::string &) const;
+ void load_slot(const std::tr1::shared_ptr<const EAPIMetadataVariable> &, const std::string &) const;
virtual bool supports_action(const SupportsActionTestBase &) const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void perform_action(Action &) const;
diff --git a/paludis/repositories/e/exndbam_repository.cc b/paludis/repositories/e/exndbam_repository.cc
index 15d045e..89d47b0 100644
--- a/paludis/repositories/e/exndbam_repository.cc
+++ b/paludis/repositories/e/exndbam_repository.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -287,6 +287,15 @@ namespace
return std::make_pair(uid, gid);
}
+
+ bool slot_is_same(const std::tr1::shared_ptr<const PackageID> & a,
+ const std::tr1::shared_ptr<const PackageID> & b)
+ {
+ if (a->slot_key())
+ return b->slot_key() && a->slot_key()->value() == b->slot_key()->value();
+ else
+ return ! b->slot_key();
+ }
}
void
@@ -305,7 +314,7 @@ ExndbamRepository::merge(const MergeParams & m)
v != v_end ; ++v)
{
if_same_name_id = *v;
- if ((*v)->version() == m.package_id()->version() && (*v)->slot() == m.package_id()->slot())
+ if ((*v)->version() == m.package_id()->version() && slot_is_same(*v, m.package_id()))
{
if_overwritten_id = *v;
break;
@@ -326,7 +335,7 @@ ExndbamRepository::merge(const MergeParams & m)
}
FSEntry target_ver_dir(uid_dir);
- target_ver_dir /= (stringify(m.package_id()->version()) + ":" + stringify(m.package_id()->slot()) + ":" + cookie());
+ target_ver_dir /= (stringify(m.package_id()->version()) + ":" + stringify(m.package_id()->slot_key()->value()) + ":" + cookie());
if (target_ver_dir.exists())
throw InstallActionError("Temporary merge directory '" + stringify(target_ver_dir) + "' already exists, probably "
@@ -394,7 +403,7 @@ ExndbamRepository::merge(const MergeParams & m)
it_end(replace_candidates->end()); it_end != it; ++it)
{
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())
+ if (candidate != if_overwritten_id && slot_is_same(candidate, m.package_id()))
perform_uninstall(candidate, false, "");
}
}
diff --git a/paludis/repositories/e/fix_locked_dependencies.cc b/paludis/repositories/e/fix_locked_dependencies.cc
index dcff496..5fc969d 100644
--- a/paludis/repositories/e/fix_locked_dependencies.cc
+++ b/paludis/repositories/e/fix_locked_dependencies.cc
@@ -34,6 +34,7 @@
#include <paludis/generator.hh>
#include <paludis/filter.hh>
#include <paludis/filtered_generator.hh>
+#include <paludis/metadata_key.hh>
#include <tr1/functional>
#include <algorithm>
#include <list>
@@ -110,9 +111,12 @@ namespace
if (matches->empty())
break;
- PackageDepSpec new_s(PartiallyMadePackageDepSpec(*node.spec()).slot_requirement(
- make_shared_ptr(new ELikeSlotExactRequirement((*matches->last())->slot(), true))));
- c.reset(new PackageDepSpec(new_s));
+ if ((*matches->last())->slot_key())
+ {
+ PackageDepSpec new_s(PartiallyMadePackageDepSpec(*node.spec()).slot_requirement(
+ make_shared_ptr(new ELikeSlotExactRequirement((*matches->last())->slot_key()->value(), true))));
+ c.reset(new PackageDepSpec(new_s));
+ }
} while (false);
if (! c)
diff --git a/paludis/repositories/e/qa/metadata_keys.cc b/paludis/repositories/e/qa/metadata_keys.cc
index 7080621..c48f38a 100644
--- a/paludis/repositories/e/qa/metadata_keys.cc
+++ b/paludis/repositories/e/qa/metadata_keys.cc
@@ -39,6 +39,11 @@ namespace
const std::string & PALUDIS_ATTRIBUTE((unused)) s(k.value());
}
+ void visit(const MetadataValueKey<SlotName> & k)
+ {
+ const SlotName & PALUDIS_ATTRIBUTE((unused)) s(k.value());
+ }
+
void visit(const MetadataValueKey<long> & k)
{
long PALUDIS_ATTRIBUTE((unused)) t(k.value());
diff --git a/paludis/repositories/e/qa/spec_keys.cc b/paludis/repositories/e/qa/spec_keys.cc
index 717331d..8a1d58e 100644
--- a/paludis/repositories/e/qa/spec_keys.cc
+++ b/paludis/repositories/e/qa/spec_keys.cc
@@ -311,6 +311,10 @@ namespace
{
}
+ void visit(const MetadataValueKey<SlotName> &)
+ {
+ }
+
void visit(const MetadataValueKey<long> &)
{
}
diff --git a/paludis/repositories/e/vdb_merger.cc b/paludis/repositories/e/vdb_merger.cc
index bf0c17f..8cfbb54 100644
--- a/paludis/repositories/e/vdb_merger.cc
+++ b/paludis/repositories/e/vdb_merger.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -34,6 +34,7 @@
#include <paludis/util/md5.hh>
#include <paludis/environment.hh>
#include <paludis/package_database.hh>
+#include <paludis/metadata_key.hh>
#include <fstream>
#include <iostream>
#include <iomanip>
@@ -105,7 +106,7 @@ VDBMerger::extend_hook(const Hook & h)
std::string pn(stringify(_imp->params.package_id()->name().package()));
std::string pvr(stringify(_imp->params.package_id()->version()));
std::string pv(stringify(_imp->params.package_id()->version().remove_revision()));
- std::string slot(stringify(_imp->params.package_id()->slot()));
+ std::string slot(_imp->params.package_id()->slot_key() ? stringify(_imp->params.package_id()->slot_key()->value()) : "");
return Merger::extend_hook(h)
("P", pn + "-" + pv)
diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc
index da1fbf3..c6963b0 100644
--- a/paludis/repositories/e/vdb_repository.cc
+++ b/paludis/repositories/e/vdb_repository.cc
@@ -779,6 +779,18 @@ VDBRepository::category_names_containing_package(const PackageNamePart & p) cons
return result ? result : Repository::category_names_containing_package(p);
}
+namespace
+{
+ bool slot_is_same(const std::tr1::shared_ptr<const PackageID> & a,
+ const std::tr1::shared_ptr<const PackageID> & b)
+ {
+ if (a->slot_key())
+ return b->slot_key() && a->slot_key()->value() == b->slot_key()->value();
+ else
+ return ! b->slot_key();
+ }
+}
+
void
VDBRepository::merge(const MergeParams & m)
{
@@ -873,7 +885,7 @@ VDBRepository::merge(const MergeParams & m)
it_end(replace_candidates->end()); it_end != it; ++it)
{
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())
+ if (candidate != is_replace && slot_is_same(candidate, m.package_id()))
perform_uninstall(candidate, false, "");
}
}
diff --git a/paludis/repositories/e/vdb_repository_TEST.cc b/paludis/repositories/e/vdb_repository_TEST.cc
index a0c8e9c..cedad9c 100644
--- a/paludis/repositories/e/vdb_repository_TEST.cc
+++ b/paludis/repositories/e/vdb_repository_TEST.cc
@@ -867,15 +867,15 @@ namespace test_cases
RepositoryProvidesInterface::ProvidesSequence::ConstIterator it(seq->begin());
TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/foo");
- TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg1-1::installed");
+ TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg1-1:1::installed");
TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/foo");
- TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg1-2::installed");
+ TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg1-2:2::installed");
TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/foo");
- TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg2-1::installed");
+ TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg2-1:1::installed");
TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/bar");
- TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg2-1::installed");
+ TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg2-1:1::installed");
TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/bar");
- TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg2-2::installed");
+ TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg2-2:2::installed");
}
vdb_repo->regenerate_cache();
@@ -888,15 +888,15 @@ namespace test_cases
RepositoryProvidesInterface::ProvidesSequence::ConstIterator it(seq->begin());
TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/foo");
- TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg1-1::installed");
+ TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg1-1:1::installed");
TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/foo");
- TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg1-2::installed");
+ TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg1-2:2::installed");
TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/foo");
- TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg2-1::installed");
+ TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg2-1:1::installed");
TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/bar");
- TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg2-1::installed");
+ TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg2-1:1::installed");
TEST_CHECK_STRINGIFY_EQUAL(it->virtual_name(), "virtual/bar");
- TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg2-2::installed");
+ TEST_CHECK_STRINGIFY_EQUAL(*(*it++).provided_by(), "cat1/pkg2-2:2::installed");
}
}
diff --git a/paludis/repositories/e/vdb_unmerger.cc b/paludis/repositories/e/vdb_unmerger.cc
index f05a7ee..9103dfe 100644
--- a/paludis/repositories/e/vdb_unmerger.cc
+++ b/paludis/repositories/e/vdb_unmerger.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
* Copyright (c) 2007 Piotr Jaroszyński
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -29,6 +29,7 @@ using namespace paludis;
#include <paludis/hook.hh>
#include <paludis/package_database.hh>
#include <paludis/package_id.hh>
+#include <paludis/metadata_key.hh>
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/join.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
@@ -146,6 +147,7 @@ VDBUnmerger::extend_hook(const Hook & h) const
std::string pn(stringify(_imp->options.package_id()->name().package()));
std::string pvr(stringify(_imp->options.package_id()->version()));
std::string pv(stringify(_imp->options.package_id()->version().remove_revision()));
+ std::string slot(_imp->options.package_id()->slot_key() ? stringify(_imp->options.package_id()->slot_key()->value()) : "");
return result
("P", pn + "-" + pv)
@@ -157,7 +159,8 @@ VDBUnmerger::extend_hook(const Hook & h) const
("PVR", pvr)
("PF", pn + "-" + pvr)
("PNVR", pn + "-" + pvr)
- ("SLOT", stringify(_imp->options.package_id()->slot()));
+ ("SLOT", slot)
+ ;
}
return result;
diff --git a/paludis/repositories/fake/fake_package_id.cc b/paludis/repositories/fake/fake_package_id.cc
index f4eddcb..fc3ff88 100644
--- a/paludis/repositories/fake/fake_package_id.cc
+++ b/paludis/repositories/fake/fake_package_id.cc
@@ -606,13 +606,13 @@ namespace paludis
const std::tr1::shared_ptr<const FakeRepositoryBase> repository;
const QualifiedPackageName name;
const VersionSpec version;
- SlotName slot;
mutable std::tr1::shared_ptr<DependencyLabelSequence> build_dependencies_labels;
mutable std::tr1::shared_ptr<DependencyLabelSequence> run_dependencies_labels;
mutable std::tr1::shared_ptr<DependencyLabelSequence> post_dependencies_labels;
mutable std::tr1::shared_ptr<DependencyLabelSequence> suggested_dependencies_labels;
+ std::tr1::shared_ptr<LiteralMetadataValueKey<SlotName> > slot;
std::tr1::shared_ptr<LiteralMetadataValueKey<std::tr1::shared_ptr<const PackageID> > > package_id;
std::tr1::shared_ptr<LiteralMetadataValueKey<std::tr1::shared_ptr<const PackageID> > > virtual_for;
std::tr1::shared_ptr<FakeMetadataKeywordSetKey> keywords;
@@ -636,11 +636,11 @@ namespace paludis
repository(r),
name(q),
version(v),
- slot("0"),
build_dependencies_labels(new DependencyLabelSequence),
run_dependencies_labels(new DependencyLabelSequence),
post_dependencies_labels(new DependencyLabelSequence),
suggested_dependencies_labels(new DependencyLabelSequence),
+ slot(new LiteralMetadataValueKey<SlotName>("SLOT", "Slot", mkt_internal, SlotName("0"))),
keywords(new FakeMetadataKeywordSetKey("KEYWORDS", "Keywords", "test", mkt_normal, id, env)),
has_masks(false)
{
@@ -671,13 +671,14 @@ FakePackageID::canonical_form(const PackageIDCanonicalForm f) const
switch (f)
{
case idcf_full:
- return stringify(_imp->name) + "-" + stringify(_imp->version) + ":" + stringify(slot()) + "::" + stringify(_imp->repository->name());
+ return stringify(_imp->name) + "-" + stringify(_imp->version) + ":" + stringify(_imp->slot->value())
+ + "::" + stringify(_imp->repository->name());
case idcf_version:
return stringify(_imp->version);
case idcf_no_version:
- return stringify(_imp->name) + ":" + stringify(slot()) + "::" + stringify(_imp->repository->name());
+ return stringify(_imp->name) + ":" + stringify(_imp->slot->value()) + "::" + stringify(_imp->repository->name());
case last_idcf:
break;
@@ -698,12 +699,6 @@ FakePackageID::version() const
return _imp->version;
}
-const SlotName
-FakePackageID::slot() const
-{
- return _imp->slot;
-}
-
const std::tr1::shared_ptr<const Repository>
FakePackageID::repository() const
{
@@ -874,13 +869,13 @@ FakePackageID::from_repositories_key() const
void
FakePackageID::set_slot(const SlotName & s)
{
- _imp->slot = s;
+ _imp->slot->change_value(s);
}
bool
FakePackageID::arbitrary_less_than_comparison(const PackageID & other) const
{
- return slot().data() < other.slot().data();
+ return slot_key()->value().data() < (other.slot_key() ? stringify(other.slot_key()->value()) : "");
}
void
@@ -930,6 +925,7 @@ FakePackageID::need_keys_added() const
_imp->choices.reset(new FakeMetadataChoicesKey(_imp->env, shared_from_this()));
+ add_metadata_key(_imp->slot);
add_metadata_key(_imp->build_dependencies);
add_metadata_key(_imp->run_dependencies);
add_metadata_key(_imp->post_dependencies);
@@ -945,7 +941,7 @@ FakePackageID::need_keys_added() const
std::size_t
FakePackageID::extra_hash_value() const
{
- return Hash<SlotName>()(slot());
+ return Hash<SlotName>()(slot_key()->value());
}
bool
@@ -1239,6 +1235,13 @@ FakePackageID::choices_key()
return _imp->choices;
}
+const std::tr1::shared_ptr<const MetadataValueKey<SlotName> >
+FakePackageID::slot_key() const
+{
+ need_keys_added();
+ return _imp->slot;
+}
+
template class FakeMetadataSpecTreeKey<LicenseSpecTree>;
template class FakeMetadataSpecTreeKey<ProvideSpecTree>;
template class FakeMetadataSpecTreeKey<PlainTextSpecTree>;
diff --git a/paludis/repositories/fake/fake_package_id.hh b/paludis/repositories/fake/fake_package_id.hh
index 7f43ee9..1b71aa6 100644
--- a/paludis/repositories/fake/fake_package_id.hh
+++ b/paludis/repositories/fake/fake_package_id.hh
@@ -241,9 +241,9 @@ namespace paludis
virtual const QualifiedPackageName name() const;
virtual const VersionSpec version() const;
- virtual const SlotName slot() const;
virtual const std::tr1::shared_ptr<const Repository> repository() const;
+ virtual const std::tr1::shared_ptr<const MetadataValueKey<SlotName> > slot_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<std::tr1::shared_ptr<const PackageID> > > virtual_for_key() const;
virtual const std::tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> > keywords_key() const;
virtual const std::tr1::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> > provide_key() const;
diff --git a/paludis/repositories/gems/gem_specification.cc b/paludis/repositories/gems/gem_specification.cc
index 86c08b0..84b127b 100644
--- a/paludis/repositories/gems/gem_specification.cc
+++ b/paludis/repositories/gems/gem_specification.cc
@@ -54,6 +54,7 @@ namespace paludis
std::tr1::shared_ptr<LiteralMetadataValueKey<std::string> > authors_key;
std::tr1::shared_ptr<LiteralMetadataValueKey<std::string> > rubyforge_project_key;
std::tr1::shared_ptr<LiteralMetadataValueKey<FSEntry> > fs_location_key;
+ std::tr1::shared_ptr<LiteralMetadataValueKey<SlotName> > slot_key;
std::tr1::shared_ptr<const FSEntry> load_from_file;
@@ -272,6 +273,8 @@ GemSpecification::GemSpecification(const Environment * const e, const std::tr1::
_imp->load_from_file.reset(new FSEntry(f));
_imp->fs_location_key.reset(new LiteralMetadataValueKey<FSEntry> ("GEM", "Gem Location", mkt_internal, f));
add_metadata_key(_imp->fs_location_key);
+ _imp->slot_key.reset(new LiteralMetadataValueKey<SlotName>("SLOT", "Slot", mkt_internal, SlotName(stringify(v))));
+ add_metadata_key(_imp->slot_key);
}
GemSpecification::~GemSpecification()
@@ -316,12 +319,6 @@ GemSpecification::version() const
return VersionSpec(_imp->version);
}
-const SlotName
-GemSpecification::slot() const
-{
- return SlotName(_imp->version);
-}
-
const std::tr1::shared_ptr<const Repository>
GemSpecification::repository() const
{
@@ -436,6 +433,12 @@ GemSpecification::transient_key() const
return std::tr1::shared_ptr<const MetadataValueKey<bool> >();
}
+const std::tr1::shared_ptr<const MetadataValueKey<SlotName> >
+GemSpecification::slot_key() const
+{
+ return _imp->slot_key;
+}
+
bool
GemSpecification::arbitrary_less_than_comparison(const PackageID &) const
{
diff --git a/paludis/repositories/gems/gem_specification.hh b/paludis/repositories/gems/gem_specification.hh
index ccd8198..5691dfa 100644
--- a/paludis/repositories/gems/gem_specification.hh
+++ b/paludis/repositories/gems/gem_specification.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -87,9 +87,9 @@ namespace paludis
virtual const QualifiedPackageName name() const;
virtual const VersionSpec version() const;
- virtual const SlotName slot() const;
virtual const std::tr1::shared_ptr<const Repository> repository() const;
+ virtual const std::tr1::shared_ptr<const MetadataValueKey<SlotName> > slot_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<std::tr1::shared_ptr<const PackageID> > > virtual_for_key() const;
virtual const std::tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> > keywords_key() const;
virtual const std::tr1::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> > provide_key() const;
diff --git a/paludis/repositories/unavailable/unavailable_id.cc b/paludis/repositories/unavailable/unavailable_id.cc
index dd9bc12..5682a49 100644
--- a/paludis/repositories/unavailable/unavailable_id.cc
+++ b/paludis/repositories/unavailable/unavailable_id.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -29,6 +29,7 @@
#include <paludis/name.hh>
#include <paludis/version_spec.hh>
#include <paludis/metadata_key.hh>
+#include <paludis/literal_metadata_key.hh>
#include <paludis/action.hh>
#include <paludis/unchoices_key.hh>
@@ -42,9 +43,9 @@ namespace paludis
{
const QualifiedPackageName name;
const VersionSpec version;
- const SlotName slot;
const UnavailableRepository * const repo;
+ const std::tr1::shared_ptr<const MetadataValueKey<SlotName> > slot_key;
const std::tr1::shared_ptr<const MetadataValueKey<std::string> > description_key;
const std::tr1::shared_ptr<const MetadataValueKey<std::string> > repository_homepage_key, repository_description_key;
const std::tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > > from_repositories_key;
@@ -55,8 +56,8 @@ namespace paludis
const UnavailableIDParams & e) :
name(e.name()),
version(e.version()),
- slot(e.slot()),
repo(e.repository()),
+ slot_key(new LiteralMetadataValueKey<SlotName>("SLOT", "Slot", mkt_internal, e.slot())),
description_key(e.description()),
repository_homepage_key(e.repository_homepage()),
repository_description_key(e.repository_description()),
@@ -72,6 +73,7 @@ UnavailableID::UnavailableID(const UnavailableIDParams & entry) :
PrivateImplementationPattern<UnavailableID>(new Implementation<UnavailableID>(entry)),
_imp(PrivateImplementationPattern<UnavailableID>::_imp)
{
+ add_metadata_key(_imp->slot_key);
add_metadata_key(_imp->description_key);
add_metadata_key(_imp->from_repositories_key);
if (_imp->repository_homepage_key)
@@ -102,11 +104,11 @@ UnavailableID::canonical_form(const PackageIDCanonicalForm f) const
{
case idcf_full:
return stringify(_imp->name) + "-" + stringify(_imp->version) +
- ":" + stringify(_imp->slot) + "::" + stringify(_imp->repo->name()) +
+ ":" + stringify(_imp->slot_key->value()) + "::" + stringify(_imp->repo->name()) +
" (in ::" + *_imp->from_repositories_key->value()->begin() + ")";
case idcf_no_version:
- return stringify(_imp->name) + ":" + stringify(_imp->slot) +
+ return stringify(_imp->name) + ":" + stringify(_imp->slot_key->value()) +
"::" + stringify(_imp->repo->name()) +
" (in ::" + *_imp->from_repositories_key->value()->begin() + ")";
@@ -133,12 +135,6 @@ UnavailableID::version() const
return _imp->version;
}
-const SlotName
-UnavailableID::slot() const
-{
- return _imp->slot;
-}
-
const std::tr1::shared_ptr<const Repository>
UnavailableID::repository() const
{
@@ -166,9 +162,12 @@ UnavailableID::breaks_portage() const
bool
UnavailableID::arbitrary_less_than_comparison(const PackageID & other) const
{
- if (slot() < other.slot())
+ if (! other.slot_key())
+ return false;
+
+ if (slot_key()->value() < other.slot_key()->value())
return true;
- if (slot() > other.slot())
+ if (slot_key()->value() > other.slot_key()->value())
return false;
std::tr1::shared_ptr<const MetadataCollectionKey<Set<std::string > > > k(other.from_repositories_key());
@@ -184,7 +183,7 @@ std::size_t
UnavailableID::extra_hash_value() const
{
return Hash<std::pair<SlotName, std::string> >()(std::make_pair(
- slot(), *_imp->from_repositories_key->value()->begin()));
+ slot_key()->value(), *_imp->from_repositories_key->value()->begin()));
}
const std::tr1::shared_ptr<const MetadataCollectionKey<PackageIDSequence> >
@@ -301,5 +300,11 @@ UnavailableID::choices_key() const
return _imp->choices_key;
}
+const std::tr1::shared_ptr<const MetadataValueKey<SlotName> >
+UnavailableID::slot_key() const
+{
+ return _imp->slot_key;
+}
+
template class PrivateImplementationPattern<UnavailableID>;
diff --git a/paludis/repositories/unavailable/unavailable_id.hh b/paludis/repositories/unavailable/unavailable_id.hh
index a97280a..49596ed 100644
--- a/paludis/repositories/unavailable/unavailable_id.hh
+++ b/paludis/repositories/unavailable/unavailable_id.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -73,9 +73,9 @@ namespace paludis
const std::string canonical_form(const PackageIDCanonicalForm) const;
const QualifiedPackageName name() const;
const VersionSpec version() const;
- const SlotName slot() const;
const std::tr1::shared_ptr<const Repository> repository() const;
+ const std::tr1::shared_ptr<const MetadataValueKey<SlotName> > slot_key() const;
const std::tr1::shared_ptr<const MetadataValueKey<std::tr1::shared_ptr<const PackageID> > >
virtual_for_key() const;
const std::tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> > keywords_key() const;
diff --git a/paludis/repositories/unpackaged/installed_id.cc b/paludis/repositories/unpackaged/installed_id.cc
index 33cafdc..a54f62b 100644
--- a/paludis/repositories/unpackaged/installed_id.cc
+++ b/paludis/repositories/unpackaged/installed_id.cc
@@ -395,7 +395,6 @@ namespace paludis
const Environment * const env;
const QualifiedPackageName name;
const VersionSpec version;
- const SlotName slot;
const RepositoryName repository_name;
const FSEntry root;
const NDBAM * const ndbam;
@@ -403,6 +402,7 @@ namespace paludis
std::tr1::shared_ptr<DependencyLabelSequence> build_dependencies_labels;
std::tr1::shared_ptr<DependencyLabelSequence> run_dependencies_labels;
+ std::tr1::shared_ptr<LiteralMetadataValueKey<SlotName> > slot_key;
std::tr1::shared_ptr<InstalledUnpackagedFSEntryKey> fs_location_key;
std::tr1::shared_ptr<InstalledUnpackagedContentsKey> contents_key;
std::tr1::shared_ptr<InstalledUnpackagedTimeKey> installed_time_key;
@@ -424,12 +424,12 @@ namespace paludis
env(e),
name(q),
version(v),
- slot(s),
repository_name(r),
root(ro),
ndbam(d),
build_dependencies_labels(new DependencyLabelSequence),
run_dependencies_labels(new DependencyLabelSequence),
+ slot_key(new LiteralMetadataValueKey<SlotName> ("slot", "Slot", mkt_internal, s)),
fs_location_key(new InstalledUnpackagedFSEntryKey(l))
{
build_dependencies_labels->push_back(make_shared_ptr(new DependencyBuildLabel("build_dependencies")));
@@ -471,6 +471,7 @@ InstalledUnpackagedID::InstalledUnpackagedID(const Environment * const e, const
_imp(PrivateImplementationPattern<InstalledUnpackagedID>::_imp)
{
add_metadata_key(_imp->fs_location_key);
+ add_metadata_key(_imp->slot_key);
if (_imp->contents_key)
add_metadata_key(_imp->contents_key);
if (_imp->installed_time_key)
@@ -506,13 +507,13 @@ InstalledUnpackagedID::canonical_form(const PackageIDCanonicalForm f) const
{
case idcf_full:
return stringify(_imp->name) + "-" + stringify(_imp->version) + ":" +
- stringify(slot()) + "::" + stringify(_imp->repository_name);
+ stringify(slot_key()->value()) + "::" + stringify(_imp->repository_name);
case idcf_version:
return stringify(_imp->version);
case idcf_no_version:
- return stringify(_imp->name) + ":" + stringify(slot()) + "::" +
+ return stringify(_imp->name) + ":" + stringify(slot_key()->value()) + "::" +
stringify(_imp->repository_name);
case last_idcf:
@@ -534,12 +535,6 @@ InstalledUnpackagedID::version() const
return _imp->version;
}
-const SlotName
-InstalledUnpackagedID::slot() const
-{
- return _imp->slot;
-}
-
const std::tr1::shared_ptr<const Repository>
InstalledUnpackagedID::repository() const
{
@@ -648,6 +643,12 @@ InstalledUnpackagedID::fs_location_key() const
return _imp->fs_location_key;
}
+const std::tr1::shared_ptr<const MetadataValueKey<SlotName> >
+InstalledUnpackagedID::slot_key() const
+{
+ return _imp->slot_key;
+}
+
namespace paludis
{
class InstalledUnpackagedTransientKey :
@@ -808,13 +809,13 @@ InstalledUnpackagedID::breaks_portage() const
bool
InstalledUnpackagedID::arbitrary_less_than_comparison(const PackageID & other) const
{
- return slot().data() < other.slot().data();
+ return slot_key()->value().data() < (other.slot_key() ? stringify(other.slot_key()->value()) : "");
}
std::size_t
InstalledUnpackagedID::extra_hash_value() const
{
- return Hash<SlotName>()(slot());
+ return Hash<SlotName>()(slot_key()->value());
}
void
diff --git a/paludis/repositories/unpackaged/installed_id.hh b/paludis/repositories/unpackaged/installed_id.hh
index e1a5f8d..a62bcdd 100644
--- a/paludis/repositories/unpackaged/installed_id.hh
+++ b/paludis/repositories/unpackaged/installed_id.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -54,9 +54,9 @@ namespace paludis
virtual const std::string canonical_form(const PackageIDCanonicalForm) const;
virtual const QualifiedPackageName name() const;
virtual const VersionSpec version() const;
- virtual const SlotName slot() const;
virtual const std::tr1::shared_ptr<const Repository> repository() const;
+ virtual const std::tr1::shared_ptr<const MetadataValueKey<SlotName> > slot_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<std::tr1::shared_ptr<const PackageID> > > virtual_for_key() const;
virtual const std::tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> > keywords_key() const;
virtual const std::tr1::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> > provide_key() const;
diff --git a/paludis/repositories/unpackaged/installed_repository.cc b/paludis/repositories/unpackaged/installed_repository.cc
index 5f435bd..488ab85 100644
--- a/paludis/repositories/unpackaged/installed_repository.cc
+++ b/paludis/repositories/unpackaged/installed_repository.cc
@@ -241,6 +241,15 @@ namespace
return std::make_pair(uid, gid);
}
+
+ bool slot_is_same(const std::tr1::shared_ptr<const PackageID> & a,
+ const std::tr1::shared_ptr<const PackageID> & b)
+ {
+ if (a->slot_key())
+ return b->slot_key() && a->slot_key()->value() == b->slot_key()->value();
+ else
+ return ! b->slot_key();
+ }
}
void
@@ -283,7 +292,7 @@ InstalledUnpackagedRepository::merge(const MergeParams & m)
v != v_end ; ++v)
{
if_same_name_id = *v;
- if ((*v)->version() == m.package_id()->version() && (*v)->slot() == m.package_id()->slot())
+ if ((*v)->version() == m.package_id()->version() && slot_is_same(*v, m.package_id()))
{
if_overwritten_id = *v;
break;
@@ -304,7 +313,7 @@ InstalledUnpackagedRepository::merge(const MergeParams & m)
}
FSEntry target_ver_dir(uid_dir);
- target_ver_dir /= (stringify(m.package_id()->version()) + ":" + stringify(m.package_id()->slot()) + ":" + cookie());
+ target_ver_dir /= (stringify(m.package_id()->version()) + ":" + stringify(m.package_id()->slot_key()->value()) + ":" + cookie());
if (target_ver_dir.exists())
throw InstallActionError("Temporary merge directory '" + stringify(target_ver_dir) + "' already exists, probably "
diff --git a/paludis/repositories/unpackaged/installed_repository_TEST.cc b/paludis/repositories/unpackaged/installed_repository_TEST.cc
index c3610a8..d98b450 100644
--- a/paludis/repositories/unpackaged/installed_repository_TEST.cc
+++ b/paludis/repositories/unpackaged/installed_repository_TEST.cc
@@ -134,7 +134,7 @@ namespace test_cases
&env, UserPackageDepSpecOptions()), MatchPackageOptions()))]->begin());
TEST_CHECK_EQUAL(id1->version(), VersionSpec("1"));
- TEST_CHECK_EQUAL(id1->slot(), SlotName("0"));
+ TEST_CHECK_EQUAL(id1->slot_key()->value(), SlotName("0"));
TEST_CHECK_EQUAL(id1->name(), QualifiedPackageName("cat-one/foo"));
TEST_CHECK_EQUAL(id1->repository()->name(), RepositoryName("installed-unpackaged"));
TEST_CHECK(id1->fs_location_key());
@@ -152,7 +152,7 @@ namespace test_cases
&env, UserPackageDepSpecOptions()), MatchPackageOptions()))]->begin());
TEST_CHECK_EQUAL(id2->version(), VersionSpec("2"));
- TEST_CHECK_EQUAL(id2->slot(), SlotName("1"));
+ TEST_CHECK_EQUAL(id2->slot_key()->value(), SlotName("1"));
TEST_CHECK_EQUAL(id2->name(), QualifiedPackageName("cat-one/foo"));
TEST_CHECK_EQUAL(id2->repository()->name(), RepositoryName("installed-unpackaged"));
TEST_CHECK(id2->fs_location_key());
diff --git a/paludis/repositories/unpackaged/unpackaged_id.cc b/paludis/repositories/unpackaged/unpackaged_id.cc
index 3a3e232..0564621 100644
--- a/paludis/repositories/unpackaged/unpackaged_id.cc
+++ b/paludis/repositories/unpackaged/unpackaged_id.cc
@@ -51,12 +51,12 @@ namespace paludis
const Environment * const env;
const QualifiedPackageName name;
const VersionSpec version;
- const SlotName slot;
const RepositoryName repository_name;
std::tr1::shared_ptr<DependencyLabelSequence> build_dependencies_labels;
std::tr1::shared_ptr<DependencyLabelSequence> run_dependencies_labels;
+ const std::tr1::shared_ptr<LiteralMetadataValueKey<SlotName> > slot_key;
const std::tr1::shared_ptr<LiteralMetadataValueKey<FSEntry> > fs_location_key;
const std::tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > build_dependencies_key;
const std::tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > run_dependencies_key;
@@ -76,10 +76,10 @@ namespace paludis
env(e),
name(q),
version(v),
- slot(s),
repository_name(n),
build_dependencies_labels(new DependencyLabelSequence),
run_dependencies_labels(new DependencyLabelSequence),
+ slot_key(new LiteralMetadataValueKey<SlotName> ("slot", "Slot", mkt_internal, s)),
fs_location_key(new LiteralMetadataValueKey<FSEntry> ("location", "Location", mkt_normal, l)),
build_dependencies_key(new UnpackagedDependencyKey(env, "build_dependencies", "Build dependencies", mkt_dependencies,
build_dependencies_labels, b)),
@@ -100,6 +100,7 @@ UnpackagedID::UnpackagedID(const Environment * const e, const QualifiedPackageNa
PrivateImplementationPattern<UnpackagedID>(new Implementation<UnpackagedID>(e, q, v, s, n, l, b, r, d, this)),
_imp(PrivateImplementationPattern<UnpackagedID>::_imp)
{
+ add_metadata_key(_imp->slot_key);
add_metadata_key(_imp->fs_location_key);
add_metadata_key(_imp->build_dependencies_key);
add_metadata_key(_imp->run_dependencies_key);
@@ -128,13 +129,13 @@ UnpackagedID::canonical_form(const PackageIDCanonicalForm f) const
{
case idcf_full:
return stringify(_imp->name) + "-" + stringify(_imp->version) + ":" +
- stringify(slot()) + "::" + stringify(_imp->repository_name);
+ stringify(slot_key()->value()) + "::" + stringify(_imp->repository_name);
case idcf_version:
return stringify(_imp->version);
case idcf_no_version:
- return stringify(_imp->name) + ":" + stringify(slot()) + "::" +
+ return stringify(_imp->name) + ":" + stringify(slot_key()->value()) + "::" +
stringify(_imp->repository_name);
case last_idcf:
@@ -156,12 +157,6 @@ UnpackagedID::version() const
return _imp->version;
}
-const SlotName
-UnpackagedID::slot() const
-{
- return _imp->slot;
-}
-
const std::tr1::shared_ptr<const Repository>
UnpackagedID::repository() const
{
@@ -270,6 +265,12 @@ UnpackagedID::fs_location_key() const
return _imp->fs_location_key;
}
+const std::tr1::shared_ptr<const MetadataValueKey<SlotName> >
+UnpackagedID::slot_key() const
+{
+ return _imp->slot_key;
+}
+
const std::tr1::shared_ptr<const MetadataValueKey<bool> >
UnpackagedID::transient_key() const
{
@@ -379,13 +380,13 @@ UnpackagedID::breaks_portage() const
bool
UnpackagedID::arbitrary_less_than_comparison(const PackageID & other) const
{
- return slot().data() < other.slot().data();
+ return slot_key()->value().data() < (other.slot_key() ? stringify(other.slot_key()->value()) : "");
}
std::size_t
UnpackagedID::extra_hash_value() const
{
- return Hash<SlotName>()(slot());
+ return Hash<SlotName>()(slot_key()->value());
}
const std::tr1::shared_ptr<const MetadataValueKey<std::tr1::shared_ptr<const Choices> > >
diff --git a/paludis/repositories/unpackaged/unpackaged_id.hh b/paludis/repositories/unpackaged/unpackaged_id.hh
index 7e987d2..7fe9159 100644
--- a/paludis/repositories/unpackaged/unpackaged_id.hh
+++ b/paludis/repositories/unpackaged/unpackaged_id.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -52,9 +52,9 @@ namespace paludis
virtual const std::string canonical_form(const PackageIDCanonicalForm) const;
virtual const QualifiedPackageName name() const;
virtual const VersionSpec version() const;
- virtual const SlotName slot() const;
virtual const std::tr1::shared_ptr<const Repository> repository() const;
+ virtual const std::tr1::shared_ptr<const MetadataValueKey<SlotName> > slot_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<std::tr1::shared_ptr<const PackageID> > > virtual_for_key() const;
virtual const std::tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> > keywords_key() const;
virtual const std::tr1::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> > provide_key() const;
diff --git a/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc b/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc
index 2d8e2b6..46913ab 100644
--- a/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc
+++ b/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc
@@ -110,7 +110,7 @@ namespace test_cases
*env[selection::RequireExactlyOne(generator::All())]->begin());
TEST_CHECK_EQUAL(id->version(), VersionSpec("1.0"));
- TEST_CHECK_EQUAL(id->slot(), SlotName("foo"));
+ TEST_CHECK_EQUAL(id->slot_key()->value(), SlotName("foo"));
TEST_CHECK_EQUAL(id->name(), QualifiedPackageName("cat/pkg"));
TEST_CHECK_EQUAL(id->repository()->name(), RepositoryName("unpackaged"));
TEST_CHECK(id->fs_location_key());
diff --git a/paludis/repositories/unwritten/unwritten_id.cc b/paludis/repositories/unwritten/unwritten_id.cc
index c0c7609..64bc478 100644
--- a/paludis/repositories/unwritten/unwritten_id.cc
+++ b/paludis/repositories/unwritten/unwritten_id.cc
@@ -41,9 +41,9 @@ namespace paludis
{
const QualifiedPackageName name;
const VersionSpec version;
- const SlotName slot;
const UnwrittenRepository * const repo;
+ const std::tr1::shared_ptr<const MetadataValueKey<SlotName> > slot_key;
const std::tr1::shared_ptr<const MetadataValueKey<std::string> > description_key;
const std::tr1::shared_ptr<const MetadataValueKey<std::string> > added_by_key;
const std::tr1::shared_ptr<const MetadataValueKey<std::string> > comment_key;
@@ -57,8 +57,8 @@ namespace paludis
const UnwrittenIDParams & e) :
name(e.name()),
version(e.version()),
- slot(e.slot()),
repo(e.repository()),
+ slot_key(e.slot()),
description_key(e.description()),
added_by_key(e.added_by()),
comment_key(e.comment()),
@@ -76,6 +76,8 @@ UnwrittenID::UnwrittenID(const UnwrittenIDParams & entry) :
PrivateImplementationPattern<UnwrittenID>(new Implementation<UnwrittenID>(entry)),
_imp(PrivateImplementationPattern<UnwrittenID>::_imp)
{
+ if (_imp->slot_key)
+ add_metadata_key(_imp->slot_key);
if (_imp->description_key)
add_metadata_key(_imp->description_key);
if (_imp->homepage_key)
@@ -112,10 +114,10 @@ UnwrittenID::canonical_form(const PackageIDCanonicalForm f) const
{
case idcf_full:
return stringify(_imp->name) + "-" + stringify(_imp->version) +
- ":" + stringify(_imp->slot) + "::" + stringify(_imp->repo->name());
+ ":" + stringify(slot_key()->value()) + "::" + stringify(_imp->repo->name());
case idcf_no_version:
- return stringify(_imp->name) + ":" + stringify(_imp->slot) +
+ return stringify(_imp->name) + ":" + stringify(slot_key()->value()) +
"::" + stringify(_imp->repo->name());
case idcf_version:
@@ -140,12 +142,6 @@ UnwrittenID::version() const
return _imp->version;
}
-const SlotName
-UnwrittenID::slot() const
-{
- return _imp->slot;
-}
-
const std::tr1::shared_ptr<const Repository>
UnwrittenID::repository() const
{
@@ -173,16 +169,13 @@ UnwrittenID::breaks_portage() const
bool
UnwrittenID::arbitrary_less_than_comparison(const PackageID & other) const
{
- if (slot() < other.slot())
- return true;
-
- return false;
+ return slot_key()->value().data() < (other.slot_key() ? stringify(other.slot_key()->value()) : "");
}
std::size_t
UnwrittenID::extra_hash_value() const
{
- return Hash<SlotName>()(slot());
+ return Hash<SlotName>()(slot_key()->value());
}
const std::tr1::shared_ptr<const MetadataCollectionKey<PackageIDSequence> >
@@ -251,6 +244,12 @@ UnwrittenID::suggested_dependencies_key() const
return std::tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >();
}
+const std::tr1::shared_ptr<const MetadataValueKey<SlotName> >
+UnwrittenID::slot_key() const
+{
+ return _imp->slot_key;
+}
+
const std::tr1::shared_ptr<const MetadataValueKey<std::string> >
UnwrittenID::short_description_key() const
{
diff --git a/paludis/repositories/unwritten/unwritten_id.hh b/paludis/repositories/unwritten/unwritten_id.hh
index 742b68d..9ced431 100644
--- a/paludis/repositories/unwritten/unwritten_id.hh
+++ b/paludis/repositories/unwritten/unwritten_id.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -57,7 +57,7 @@ namespace paludis
NamedValue<n::name, QualifiedPackageName> name;
NamedValue<n::remote_ids, std::tr1::shared_ptr<const MetadataCollectionKey<Sequence<std::string> > > > remote_ids;
NamedValue<n::repository, const UnwrittenRepository *> repository;
- NamedValue<n::slot, SlotName> slot;
+ NamedValue<n::slot, std::tr1::shared_ptr<const MetadataValueKey<SlotName> > > slot;
NamedValue<n::version, VersionSpec> version;
};
@@ -79,11 +79,10 @@ namespace paludis
const std::string canonical_form(const PackageIDCanonicalForm) const;
const QualifiedPackageName name() const;
const VersionSpec version() const;
- const SlotName slot() const;
const std::tr1::shared_ptr<const Repository> repository() const;
- const std::tr1::shared_ptr<const MetadataValueKey<std::tr1::shared_ptr<const PackageID> > >
- virtual_for_key() const;
+ const std::tr1::shared_ptr<const MetadataValueKey<SlotName> > slot_key() const;
+ const std::tr1::shared_ptr<const MetadataValueKey<std::tr1::shared_ptr<const PackageID> > > virtual_for_key() const;
const std::tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> > keywords_key() const;
const std::tr1::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> > provide_key() const;
const std::tr1::shared_ptr<const MetadataCollectionKey<PackageIDSequence> > contains_key() const;
diff --git a/paludis/repositories/unwritten/unwritten_repository_file.cc b/paludis/repositories/unwritten/unwritten_repository_file.cc
index d3fe389..d0e2860 100644
--- a/paludis/repositories/unwritten/unwritten_repository_file.cc
+++ b/paludis/repositories/unwritten/unwritten_repository_file.cc
@@ -195,7 +195,7 @@ UnwrittenRepositoryFile::_load(const FSEntry & f)
CategoryNamePart category("x");
PackageNamePart package("x");
- SlotName slot("x");
+ std::tr1::shared_ptr<MetadataValueKey<SlotName> > slot;
VersionSpec version("0");
std::tr1::shared_ptr<UnwrittenRepositoryFileEntry> entry;
while (std::getline(file, line))
@@ -242,7 +242,7 @@ UnwrittenRepositoryFile::_load(const FSEntry & f)
(+simple_parser::any_of(" \t"))
))
{
- slot = SlotName(token);
+ slot.reset(new LiteralMetadataValueKey<SlotName>("SLOT", "Slot", mkt_internal, SlotName(token)));
if (line_parser.consume(
(+simple_parser::any_except(" \t") >> token)
diff --git a/paludis/repositories/unwritten/unwritten_repository_file.hh b/paludis/repositories/unwritten/unwritten_repository_file.hh
index 89170c8..752a553 100644
--- a/paludis/repositories/unwritten/unwritten_repository_file.hh
+++ b/paludis/repositories/unwritten/unwritten_repository_file.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -57,7 +57,7 @@ namespace paludis
NamedValue<n::homepage, std::tr1::shared_ptr<const MetadataSpecTreeKey<SimpleURISpecTree> > > homepage;
NamedValue<n::name, QualifiedPackageName> name;
NamedValue<n::remote_ids, std::tr1::shared_ptr<const MetadataCollectionKey<Sequence<std::string> > > > remote_ids;
- NamedValue<n::slot, SlotName> slot;
+ NamedValue<n::slot, std::tr1::shared_ptr<const MetadataValueKey<SlotName> > > slot;
NamedValue<n::version, VersionSpec> version;
};
diff --git a/paludis/repositories/virtuals/package_id.cc b/paludis/repositories/virtuals/package_id.cc
index 99654af..e3334cc 100644
--- a/paludis/repositories/virtuals/package_id.cc
+++ b/paludis/repositories/virtuals/package_id.cc
@@ -72,7 +72,8 @@ namespace paludis
.version_requirement(make_named_values<VersionRequirement>(
value_for<n::version_operator>(vo_equal),
value_for<n::version_spec>(v->version())))
- .slot_requirement(make_shared_ptr(new UserSlotExactRequirement(v->slot())))
+ .slot_requirement(make_shared_ptr(new UserSlotExactRequirement(
+ v->slot_key() ? v->slot_key()->value() : SlotName("UNKNOWN"))))
.in_repository(v->repository()->name())))
:
make_shared_ptr(new PackageDepSpec(
@@ -249,12 +250,6 @@ VirtualsPackageID::version() const
return _imp->version;
}
-const SlotName
-VirtualsPackageID::slot() const
-{
- return _imp->virtual_for->value()->slot();
-}
-
const std::tr1::shared_ptr<const Repository>
VirtualsPackageID::repository() const
{
@@ -527,6 +522,12 @@ VirtualsPackageID::fs_location_key() const
return std::tr1::shared_ptr<const MetadataValueKey<FSEntry> >();
}
+const std::tr1::shared_ptr<const MetadataValueKey<SlotName> >
+VirtualsPackageID::slot_key() const
+{
+ return _imp->virtual_for->value()->slot_key();
+}
+
const std::tr1::shared_ptr<const MetadataValueKey<bool> >
VirtualsPackageID::transient_key() const
{
diff --git a/paludis/repositories/virtuals/package_id.hh b/paludis/repositories/virtuals/package_id.hh
index 95c2ee7..18ff6be 100644
--- a/paludis/repositories/virtuals/package_id.hh
+++ b/paludis/repositories/virtuals/package_id.hh
@@ -84,9 +84,9 @@ namespace paludis
virtual const QualifiedPackageName name() const;
virtual const VersionSpec version() const;
- virtual const SlotName slot() const;
virtual const std::tr1::shared_ptr<const Repository> repository() const;
+ virtual const std::tr1::shared_ptr<const MetadataValueKey<SlotName> > slot_key() const;
virtual const std::tr1::shared_ptr<const MetadataValueKey<std::tr1::shared_ptr<const PackageID> > > virtual_for_key() const;
virtual const std::tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> > keywords_key() const;
virtual const std::tr1::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> > provide_key() const;
diff --git a/paludis/selection.cc b/paludis/selection.cc
index 738622d..7d57078 100644
--- a/paludis/selection.cc
+++ b/paludis/selection.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -37,6 +37,7 @@
#include <paludis/filter.hh>
#include <paludis/filtered_generator.hh>
#include <paludis/environment.hh>
+#include <paludis/metadata_key.hh>
#include <algorithm>
#include <functional>
#include <tr1/functional>
@@ -101,6 +102,14 @@ Selection::as_string() const
namespace
{
+ std::string slot_as_string(const std::tr1::shared_ptr<const PackageID> & id)
+ {
+ if (id->slot_key())
+ return stringify(id->slot_key()->value());
+ else
+ return "(none)";
+ }
+
class SomeArbitraryVersionSelectionHandler :
public SelectionHandler
{
@@ -300,14 +309,14 @@ namespace
std::tr1::shared_ptr<const PackageIDSet> id(_fg.filter().ids(env, _fg.generator().ids(env, r, p)));
- typedef std::map<std::pair<QualifiedPackageName, SlotName>, std::tr1::shared_ptr<PackageIDSequence> > SlotMap;
+ typedef std::map<std::pair<QualifiedPackageName, std::string>, std::tr1::shared_ptr<PackageIDSequence> > SlotMap;
SlotMap by_slot;
for (PackageIDSet::ConstIterator i(id->begin()), i_end(id->end()) ;
i != i_end ; ++i)
{
- SlotMap::iterator m(by_slot.find(std::make_pair((*i)->name(), (*i)->slot())));
+ SlotMap::iterator m(by_slot.find(std::make_pair((*i)->name(), slot_as_string(*i))));
if (m == by_slot.end())
- m = by_slot.insert(std::make_pair(std::make_pair((*i)->name(), (*i)->slot()),
+ m = by_slot.insert(std::make_pair(std::make_pair((*i)->name(), slot_as_string(*i)),
make_shared_ptr(new PackageIDSequence))).first;
m->second->push_back(*i);
}
@@ -366,14 +375,14 @@ namespace
std::tr1::shared_ptr<const PackageIDSet> id(_fg.filter().ids(env, _fg.generator().ids(env, r, p)));
- typedef std::map<std::pair<QualifiedPackageName, SlotName>, std::tr1::shared_ptr<PackageIDSequence> > SlotMap;
+ typedef std::map<std::pair<QualifiedPackageName, std::string>, std::tr1::shared_ptr<PackageIDSequence> > SlotMap;
SlotMap by_slot;
for (PackageIDSet::ConstIterator i(id->begin()), i_end(id->end()) ;
i != i_end ; ++i)
{
- SlotMap::iterator m(by_slot.find(std::make_pair((*i)->name(), (*i)->slot())));
+ SlotMap::iterator m(by_slot.find(std::make_pair((*i)->name(), slot_as_string(*i))));
if (m == by_slot.end())
- m = by_slot.insert(std::make_pair(std::make_pair((*i)->name(), (*i)->slot()),
+ m = by_slot.insert(std::make_pair(std::make_pair((*i)->name(), slot_as_string(*i)),
make_shared_ptr(new PackageIDSequence))).first;
m->second->push_back(*i);
}
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index 0bb4849..45151d5 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -36,6 +36,7 @@ add(`is_file_with_extension', `hh', `cc', `se', `test', `testscript')
add(`join', `hh', `test')
add(`log', `hh', `cc', `se', `test')
add(`make_named_values', `hh', `cc')
+add(`make_shared_copy', `hh', `fwd')
add(`make_shared_ptr', `hh', `fwd')
add(`map', `hh', `fwd', `impl', `cc')
add(`member_iterator', `hh', `fwd', `impl', `test')
diff --git a/paludis/util/make_shared_copy-fwd.hh b/paludis/util/make_shared_copy-fwd.hh
new file mode 100644
index 0000000..993c2af
--- /dev/null
+++ b/paludis/util/make_shared_copy-fwd.hh
@@ -0,0 +1,45 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_UTIL_MAKE_SHARED_COPY_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_UTIL_MAKE_SHARED_COPY_FWD_HH 1
+
+#include <paludis/util/attributes.hh>
+#include <tr1/memory>
+
+/** \file
+ * Forward declarations for paludis/make_shared_copy.hh .
+ *
+ * \ingroup g_utils
+ */
+
+namespace paludis
+{
+ /**
+ * Like make_shared_ptr(new T_(t)).
+ *
+ * \ingroup g_utils
+ * \since 0.36
+ */
+ template <typename T_>
+ std::tr1::shared_ptr<T_>
+ make_shared_copy(const T_ & t) PALUDIS_ATTRIBUTE((warn_unused_result));
+}
+
+#endif
diff --git a/paludis/util/make_shared_copy.hh b/paludis/util/make_shared_copy.hh
new file mode 100644
index 0000000..d966e32
--- /dev/null
+++ b/paludis/util/make_shared_copy.hh
@@ -0,0 +1,47 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_UTIL_MAKE_SHARED_COPY_HH
+#define PALUDIS_GUARD_PALUDIS_UTIL_MAKE_SHARED_COPY_HH 1
+
+#include <paludis/util/make_shared_copy-fwd.hh>
+#include <paludis/util/make_shared_ptr.hh>
+
+/** \file
+ * Declarations for the make_shared_copy function.
+ *
+ * \ingroup g_utils
+ *
+ * \section Examples
+ *
+ * - None at this time.
+ */
+
+namespace paludis
+{
+ template <typename T_>
+ std::tr1::shared_ptr<T_>
+ make_shared_copy(const T_ & t)
+ {
+ return make_shared_ptr(new T_(t));
+ }
+}
+
+#endif
+
diff --git a/python/metadata_key.cc b/python/metadata_key.cc
index 8cdee84..c3c83bd 100644
--- a/python/metadata_key.cc
+++ b/python/metadata_key.cc
@@ -57,6 +57,11 @@ class MetadataKeySptrToPythonVisitor
obj = bp::object(std::tr1::static_pointer_cast<const MetadataValueKey<std::string> >(_m_ptr));
}
+ void visit(const MetadataValueKey<SlotName> & k)
+ {
+ obj = bp::object(std::tr1::static_pointer_cast<const MetadataValueKey<SlotName> >(_m_ptr));
+ }
+
void visit(const MetadataValueKey<long> & k)
{
obj = bp::object(std::tr1::static_pointer_cast<const MetadataValueKey<long> >(_m_ptr));
@@ -271,6 +276,52 @@ struct MetadataStringKeyWrapper :
}
};
+struct MetadataSlotNameKeyWrapper :
+ MetadataValueKey<SlotName> ,
+ bp::wrapper<MetadataValueKey<SlotName> >
+{
+ virtual const SlotName value() const
+ PALUDIS_ATTRIBUTE((warn_unused_result))
+ {
+ Lock l(get_mutex());
+
+ if (bp::override f = get_override("value"))
+ return f();
+ else
+ throw PythonMethodNotImplemented("MetadataSlotNameKey", "value");
+ }
+
+ virtual const std::string raw_name() const
+ {
+ Lock l(get_mutex());
+
+ if (bp::override f = get_override("raw_name"))
+ return f();
+ else
+ throw PythonMethodNotImplemented("MetadataSlotNameKey", "raw_name");
+ }
+
+ virtual const std::string human_name() const
+ {
+ Lock l(get_mutex());
+
+ if (bp::override f = get_override("human_name"))
+ return f();
+ else
+ throw PythonMethodNotImplemented("MetadataSlotNameKey", "human_name");
+ }
+
+ virtual MetadataKeyType type() const
+ {
+ Lock l(get_mutex());
+
+ if (bp::override f = get_override("type"))
+ return f();
+ else
+ throw PythonMethodNotImplemented("MetadataSlotNameKey", "type");
+ }
+};
+
struct MetadataSectionKeyWrapper :
MetadataSectionKey,
bp::wrapper<MetadataSectionKey>
@@ -1131,6 +1182,30 @@ void expose_metadata_key()
;
/**
+ * MetadataSlotNameKey
+ */
+ bp::register_ptr_to_python<std::tr1::shared_ptr<const MetadataValueKey<SlotName> > >();
+ bp::implicitly_convertible<std::tr1::shared_ptr<MetadataSlotNameKeyWrapper>,
+ std::tr1::shared_ptr<MetadataKey> >();
+ bp::class_<MetadataSlotNameKeyWrapper, std::tr1::shared_ptr<MetadataSlotNameKeyWrapper>,
+ bp::bases<MetadataKey>, boost::noncopyable>
+ (
+ "MetadataSlotNameKey",
+ "A MetadataStringKey is a MetadataKey that has a SlotName as its\n"
+ "value.\n\n"
+
+ "This class can be subclassed in Python.",
+ bp::init<>(
+ "__init__()"
+ )
+ )
+ .def("value", bp::pure_virtual(&MetadataValueKey<SlotName> ::value),
+ "value() -> SlotName\n"
+ "Fetch our value."
+ )
+ ;
+
+ /**
* MetadataSectionKey
*/
bp::register_ptr_to_python<std::tr1::shared_ptr<const MetadataSectionKey> >();
diff --git a/python/package_id.cc b/python/package_id.cc
index 9f21213..2bc5886 100644
--- a/python/package_id.cc
+++ b/python/package_id.cc
@@ -74,10 +74,6 @@ void expose_package_id()
"[ro] VersionSpec\n"
)
- .add_property("slot", &PackageID::slot,
- "[ro] SlotName\n"
- )
-
.add_property("repository", &PackageID::repository,
"[ro] Repository\n"
)
@@ -202,6 +198,10 @@ void expose_package_id()
"best describes the location of a PackageID."
)
+ .def("slot_key", &PackageID::slot_key,
+ "The slot_key, if not None, indicates the package's slot."
+ )
+
.def("__eq__", &py_eq<PackageID>)
.def("__ne__", &py_ne<PackageID>)
diff --git a/python/package_id_TEST.py b/python/package_id_TEST.py
index 16f73c9..1e243fa 100755
--- a/python/package_id_TEST.py
+++ b/python/package_id_TEST.py
@@ -50,8 +50,8 @@ class TestCase_01_PackageID(unittest.TestCase):
self.assertEquals(self.ipid.version, VersionSpec("1"))
def test_04_slot(self):
- self.assertEquals(str(self.ipid.slot), "test_slot")
- self.assertEquals(str(self.pid.slot), "0")
+ self.assertEquals(str(self.ipid.slot_key().value()), "test_slot")
+ self.assertEquals(str(self.pid.slot_key().value()), "0")
def test_05_repository(self):
self.assertEquals(str(self.pid.repository.name), "testrepo")
@@ -59,8 +59,8 @@ class TestCase_01_PackageID(unittest.TestCase):
def test_07_canonical_form(self):
# Load the metadata
- self.pid.slot
- self.ipid.slot
+ self.pid.slot_key().value
+ self.ipid.slot_key().value
self.assertEquals(self.pid.canonical_form(PackageIDCanonicalForm.FULL), "foo/bar-1.0:0::testrepo")
self.assertEquals(self.pid.canonical_form(PackageIDCanonicalForm.VERSION), "1.0")
@@ -74,8 +74,8 @@ class TestCase_01_PackageID(unittest.TestCase):
def test_08_str(self):
# Load the metadata
- self.pid.slot
- self.ipid.slot
+ self.pid.slot_key().value
+ self.ipid.slot_key().value
self.assertEquals(str(self.pid), "foo/bar-1.0:0::testrepo")
self.assertEquals(str(self.ipid), "cat-one/pkg-one-1:test_slot::installed")
diff --git a/ruby/metadata_key.cc b/ruby/metadata_key.cc
index 662e440..fe5d1c3 100644
--- a/ruby/metadata_key.cc
+++ b/ruby/metadata_key.cc
@@ -34,6 +34,7 @@ namespace
static VALUE c_metadata_key;
static VALUE c_metadata_package_id_key;
static VALUE c_metadata_string_key;
+ static VALUE c_metadata_slot_key;
static VALUE c_metadata_size_key;
static VALUE c_metadata_time_key;
static VALUE c_metadata_contents_key;
@@ -112,6 +113,12 @@ namespace
new std::tr1::shared_ptr<const MetadataKey>(mm));
}
+ void visit(const MetadataValueKey<SlotName> &)
+ {
+ value = Data_Wrap_Struct(c_metadata_slot_key, 0, &Common<std::tr1::shared_ptr<const MetadataKey> >::free,
+ new std::tr1::shared_ptr<const MetadataKey>(mm));
+ }
+
void visit(const MetadataValueKey<long> &)
{
value = Data_Wrap_Struct(c_metadata_size_key, 0, &Common<std::tr1::shared_ptr<const MetadataKey> >::free,
@@ -285,6 +292,27 @@ namespace
/*
* call-seq:
+ * value -> String
+ *
+ * Our Value.
+ * */
+ VALUE
+ metadata_slot_key_value(VALUE self)
+ {
+ try
+ {
+ std::tr1::shared_ptr<const MetadataKey> * self_ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<const MetadataKey>, self_ptr);
+ return rb_str_new2(stringify((std::tr1::static_pointer_cast<const MetadataValueKey<SlotName> >(*self_ptr))->value()).c_str());
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+
+ /*
+ * call-seq:
* value -> Numeric
*
* Our Value.
@@ -622,6 +650,14 @@ namespace
rb_define_method(c_metadata_string_key, "value", RUBY_FUNC_CAST(&metadata_string_key_value), 0);
/*
+ * Document-class: Paludis::MetadataSlotNameKey
+ *
+ * Metadata class for SlotNames.
+ */
+ c_metadata_slot_key = rb_define_class_under(paludis_module(), "MetadataSlotNameKey", c_metadata_key);
+ rb_define_method(c_metadata_slot_key, "value", RUBY_FUNC_CAST(&metadata_slot_key_value), 0);
+
+ /*
* Document-class: Paludis::MetadataSizeKey
*
* Metadata class for file sizes.
diff --git a/ruby/package_id.cc b/ruby/package_id.cc
index e8f89ee..010d40b 100644
--- a/ruby/package_id.cc
+++ b/ruby/package_id.cc
@@ -103,26 +103,6 @@ namespace
}
/*
- * Document-method: slot
- *
- * call-seq:
- * slot -> String
- *
- * Our slot
- */
- template <typename T_, typename S_, const T_ (S_::* m_) () const>
- struct BaseValue
- {
- static VALUE
- fetch(VALUE self)
- {
- std::tr1::shared_ptr<const S_> * self_ptr;
- Data_Get_Struct(self, std::tr1::shared_ptr<const S_>, self_ptr);
- return rb_str_new2(stringify(((**self_ptr).*m_)()).c_str());
- }
- };
-
- /*
* call-seq:
* version -> VersionSpec
*
@@ -410,7 +390,6 @@ namespace
rb_define_method(c_package_id, "canonical_form", RUBY_FUNC_CAST(&package_id_canonical_form), 1);
rb_define_method(c_package_id, "name", RUBY_FUNC_CAST(&package_id_name), 0);
rb_define_method(c_package_id, "version", RUBY_FUNC_CAST(&package_id_version), 0);
- rb_define_method(c_package_id, "slot", RUBY_FUNC_CAST((&BaseValue<SlotName,PackageID,&PackageID::slot>::fetch)), 0);
rb_define_method(c_package_id, "repository_name", RUBY_FUNC_CAST(&package_id_repository_name), 0);
rb_define_method(c_package_id, "==", RUBY_FUNC_CAST(&Common<std::tr1::shared_ptr<const PackageID> >::equal_via_ptr), 1);
rb_define_method(c_package_id, "[]", RUBY_FUNC_CAST(&package_id_subscript), 1);
@@ -455,6 +434,8 @@ namespace
&KeyValue<MetadataSpecTreeKey<FetchableURISpecTree>, &PackageID::fetches_key>::fetch)), 0);
rb_define_method(c_package_id, "choices_key", RUBY_FUNC_CAST((
&KeyValue<MetadataValueKey<std::tr1::shared_ptr<const Choices> >, &PackageID::choices_key>::fetch)), 0);
+ rb_define_method(c_package_id, "slot_key", RUBY_FUNC_CAST((
+ &KeyValue<MetadataValueKey<SlotName>, &PackageID::slot_key>::fetch)), 0);
/*
* Document-module: Paludis::PackageIDCanonicalForm
diff --git a/ruby/package_id_TEST.rb b/ruby/package_id_TEST.rb
index 8590315..4e3acd4 100644
--- a/ruby/package_id_TEST.rb
+++ b/ruby/package_id_TEST.rb
@@ -109,7 +109,7 @@ module Paludis
end
def test_members
- { :name => QualifiedPackageName, :version => VersionSpec, :slot => String, :repository_name => String,
+ { :name => QualifiedPackageName, :version => VersionSpec, :repository_name => String,
:keywords_key => MetadataKeywordNameSetKey, :choices_key => MetadataChoicesKey,
:short_description_key => MetadataStringKey, :long_description_key => MetadataStringKey,
:contents_key => MetadataContentsKey, :installed_time_key => MetadataTimeKey,
@@ -159,7 +159,7 @@ module Paludis
keys = { "DESCRIPTION" => 1, "INHERITED" => 1, "KEYWORDS" => 1, "EAPI" => 1, "repository_mask" => 1,
"profile_mask" => 1, "DEPEND" => 1, "RDEPEND" => 1, "PDEPEND" => 1, "LICENSE" => 1, "PROVIDE" => 1,
"RESTRICT" => 1, "SRC_URI" => 1, "HOMEPAGE" => 1, "EBUILD" => 1, "PROPERTIES" => 1, "IUSE" => 1,
- "PALUDIS_CHOICES" => 1, "DEFINED_PHASES" => 1 }
+ "PALUDIS_CHOICES" => 1, "DEFINED_PHASES" => 1, "SLOT" => 1 }
pid_testrepo.each_metadata do | key |
assert keys.has_key?(key.raw_name), "no key #{key.raw_name}"
keys.delete key.raw_name
@@ -215,8 +215,8 @@ module Paludis
end
def test_slot
- assert_kind_of String, pid_testrepo.slot
- assert_equal '0', pid_testrepo.slot
+ assert_kind_of String, pid_testrepo.slot_key.value
+ assert_equal '0', pid_testrepo.slot_key.value
end
def test_short_description
@@ -290,8 +290,8 @@ module Paludis
end
def test_slot
- assert_kind_of String, pid_installed.slot
- assert_equal 'test_slot', pid_installed.slot
+ assert_kind_of String, pid_installed.slot_key.value
+ assert_equal 'test_slot', pid_installed.slot_key.value
end
def test_short_description
diff --git a/src/clients/adjutrix/downgrade_check.cc b/src/clients/adjutrix/downgrade_check.cc
index a8219e0..fca21f9 100644
--- a/src/clients/adjutrix/downgrade_check.cc
+++ b/src/clients/adjutrix/downgrade_check.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -33,6 +33,7 @@
#include <paludis/filter.hh>
#include <paludis/filtered_generator.hh>
#include <paludis/selection.hh>
+#include <paludis/metadata_key.hh>
#include <fstream>
#include <iostream>
#include <vector>
@@ -42,23 +43,31 @@ using namespace paludis;
namespace
{
+ std::string slot_as_string(const PackageID & id)
+ {
+ if (id.slot_key())
+ return stringify(id.slot_key()->value());
+ else
+ return "(none)";
+ }
+
int
build_one_list(NoConfigEnvironment & env, std::ostream & f)
{
std::tr1::shared_ptr<const PackageIDSequence> matches(env[selection::AllVersionsGroupedBySlot(generator::All() | filter::NotMasked())]);
QualifiedPackageName old_package("dummy/dummy");
- SlotName old_slot("dummy");
+ std::string old_slot("dummy");
VersionSpec best_version("0");
for (IndirectIterator<PackageIDSequence::ConstIterator> m(matches->begin()), m_end(matches->end()) ;
m != m_end ; ++m)
{
- if (m->name() != old_package || m->slot() != old_slot)
+ if (m->name() != old_package || slot_as_string(*m) != old_slot)
{
f << old_package << " " << old_slot << " " << best_version << std::endl;
old_package = m->name();
- old_slot = m->slot();
+ old_slot = slot_as_string(*m);
best_version = m->version();
}
}
@@ -101,7 +110,7 @@ namespace
}
void
- load_list(std::map<std::pair<QualifiedPackageName, SlotName>, VersionSpec> & map, std::istream & f)
+ load_list(std::map<std::pair<QualifiedPackageName, std::string>, VersionSpec> & map, std::istream & f)
{
std::string s;
while (std::getline(f, s))
@@ -112,34 +121,35 @@ namespace
throw ConfigurationError("Bad line '" + s + "'");
map.insert(std::make_pair(make_pair(QualifiedPackageName(tokens.at(0)),
- SlotName(tokens.at(1))), VersionSpec(tokens.at(2))));
+ tokens.at(1)), VersionSpec(tokens.at(2))));
}
}
int
check_one_list(NoConfigEnvironment & env, std::istream & f1,
- std::istream & f2, std::multimap<std::pair<QualifiedPackageName, SlotName>, std::string> & results,
+ std::istream & f2, std::multimap<std::pair<QualifiedPackageName, std::string>, std::string> & results,
const std::string & desc)
{
int exit_status(0);
- std::map<std::pair<QualifiedPackageName, SlotName>, VersionSpec> before, after;
+ std::map<std::pair<QualifiedPackageName, std::string>, VersionSpec> before, after;
load_list(before, f1);
load_list(after, f2);
- for (std::map<std::pair<QualifiedPackageName, SlotName>, VersionSpec>::const_iterator
+ for (std::map<std::pair<QualifiedPackageName, std::string>, VersionSpec>::const_iterator
b(before.begin()), b_end(before.end()) ;
b != b_end ; ++b)
{
- std::map<std::pair<QualifiedPackageName, SlotName>, VersionSpec>::const_iterator
+ std::map<std::pair<QualifiedPackageName, std::string>, VersionSpec>::const_iterator
a(after.find(b->first));
if (after.end() == a)
{
- if (! env[selection::SomeArbitraryVersion(generator::Matches(make_package_dep_spec()
- .package(b->first.first)
- .slot_requirement(make_shared_ptr(new UserSlotExactRequirement(b->first.second))),
- MatchPackageOptions()))]->empty())
+ PartiallyMadePackageDepSpec part_spec;
+ part_spec.package(b->first.first);
+ if ("(none)" != b->first.second)
+ part_spec.slot_requirement(make_shared_ptr(new UserSlotExactRequirement(SlotName(b->first.second))));
+ if (! env[selection::SomeArbitraryVersion(generator::Matches(part_spec, MatchPackageOptions()))]->empty())
{
results.insert(std::make_pair(b->first, stringify(b->second) + " -> nothing on " + desc));
exit_status |= 2;
@@ -197,7 +207,7 @@ do_downgrade_check(NoConfigEnvironment & env)
if (! after_dir.is_directory())
throw ConfigurationError("Second input directory is not a directory");
- std::multimap<std::pair<QualifiedPackageName, SlotName>, std::string> results;
+ std::multimap<std::pair<QualifiedPackageName, std::string>, std::string> results;
for (RepositoryEInterface::ProfilesConstIterator
p((*env.main_repository()).e_interface()->begin_profiles()),
@@ -223,9 +233,9 @@ do_downgrade_check(NoConfigEnvironment & env)
}
}
- std::pair<QualifiedPackageName, SlotName> old_qpns(QualifiedPackageName("dummy/dummmy"),
- SlotName("dummy"));
- for (std::multimap<std::pair<QualifiedPackageName, SlotName>, std::string>::const_iterator
+ std::pair<QualifiedPackageName, std::string> old_qpns(QualifiedPackageName("dummy/dummmy"),
+ std::string("dummy"));
+ for (std::multimap<std::pair<QualifiedPackageName, std::string>, std::string>::const_iterator
r(results.begin()), r_end(results.end()) ;
r != r_end ; ++r)
{
diff --git a/src/clients/adjutrix/find_dropped_keywords.cc b/src/clients/adjutrix/find_dropped_keywords.cc
index 02414ed..761ad8e 100644
--- a/src/clients/adjutrix/find_dropped_keywords.cc
+++ b/src/clients/adjutrix/find_dropped_keywords.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -55,6 +55,14 @@ namespace paludis
namespace
{
+ std::string slot_as_string(const std::tr1::shared_ptr<const PackageID> & id)
+ {
+ if (id->slot_key())
+ return stringify(id->slot_key()->value());
+ else
+ return "(none)";
+ }
+
struct VersionsEntry
{
NamedValue<n::best_anywhere, VersionSpec> best_anywhere;
@@ -97,7 +105,7 @@ namespace
};
void
- write_package(const QualifiedPackageName & package, const SlotName & slot,
+ write_package(const QualifiedPackageName & package, const std::string & slot,
const VersionSpec & best_keyworded, const VersionSpec & best_anywhere)
{
static CategoryNamePart previous_category("not-on-a-boat");
@@ -108,7 +116,7 @@ namespace
}
std::string p(stringify(package.package()));
- if (SlotName("0") != slot)
+ if ("0" != slot)
p += ":" + stringify(slot);
cout << " " << std::setw(col_width_package - 2) << p;
@@ -130,7 +138,7 @@ namespace
bool is_interesting(false);
VersionSpec worst_keyworded("99999999");
- typedef std::map<SlotName, VersionsEntry> VersionsInSlots;
+ typedef std::map<std::string, VersionsEntry> VersionsInSlots;
VersionsInSlots versions_in_slots;
std::tr1::shared_ptr<const PackageIDSequence> versions(repo.package_ids(package));
@@ -141,7 +149,7 @@ namespace
continue;
/* ensure that there's an entry for this SLOT */
- versions_in_slots.insert(std::make_pair((*v)->slot(), VersionsEntry(
+ versions_in_slots.insert(std::make_pair(slot_as_string(*v), VersionsEntry(
make_named_values<VersionsEntry>(
value_for<n::best_anywhere>(VersionSpec("0")),
value_for<n::best_keyworded>(VersionSpec("0"))
@@ -151,15 +159,15 @@ namespace
(*v)->keywords_key()->value()->end() != (*v)->keywords_key()->value()->find(KeywordName("~" + stringify(keyword))))
{
is_interesting = true;
- versions_in_slots.find((*v)->slot())->second.best_keyworded() =
- std::max(versions_in_slots.find((*v)->slot())->second.best_keyworded(), (*v)->version());
+ versions_in_slots.find(slot_as_string(*v))->second.best_keyworded() =
+ std::max(versions_in_slots.find(slot_as_string(*v))->second.best_keyworded(), (*v)->version());
worst_keyworded = std::min(worst_keyworded, (*v)->version());
}
if ((*v)->keywords_key()->value()->end() != std::find_if((*v)->keywords_key()->value()->begin(),
(*v)->keywords_key()->value()->end(), IsStableOrUnstableKeyword()))
- versions_in_slots.find((*v)->slot())->second.best_anywhere() =
- std::max(versions_in_slots.find((*v)->slot())->second.best_anywhere(), (*v)->version());
+ versions_in_slots.find(slot_as_string(*v))->second.best_anywhere() =
+ std::max(versions_in_slots.find(slot_as_string(*v))->second.best_anywhere(), (*v)->version());
}
if (! is_interesting)
diff --git a/src/clients/adjutrix/find_stable_candidates.cc b/src/clients/adjutrix/find_stable_candidates.cc
index f18d80e..2afb3bf 100644
--- a/src/clients/adjutrix/find_stable_candidates.cc
+++ b/src/clients/adjutrix/find_stable_candidates.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -97,7 +97,7 @@ namespace
};
void
- write_package(const QualifiedPackageName & package, const SlotName & slot,
+ write_package(const QualifiedPackageName & package, const std::string & slot,
const VersionSpec & our_version, const VersionSpec & best_version)
{
static CategoryNamePart previous_category("not-on-a-boat");
@@ -108,7 +108,7 @@ namespace
}
std::string p(stringify(package.package()));
- if (SlotName("0") != slot)
+ if ("0" != slot)
p += ":" + stringify(slot);
cout << " " << std::setw(col_width_package - 2) << p;
@@ -120,6 +120,14 @@ namespace
cout << endl;
}
+ std::string slot_as_string(const std::tr1::shared_ptr<const PackageID> & id)
+ {
+ if (id->slot_key())
+ return stringify(id->slot_key()->value());
+ else
+ return "(none)";
+ }
+
void
check_one_package(const Environment &, const KeywordName & keyword,
const Repository & repo, const QualifiedPackageName & package)
@@ -129,7 +137,7 @@ namespace
* version for us, best stable version for anyone). */
bool is_interesting(false);
- typedef std::map<SlotName, SlotsEntry> SlotsToVersions;
+ typedef std::map<std::string, SlotsEntry> SlotsToVersions;
SlotsToVersions slots_to_versions;
std::tr1::shared_ptr<const PackageIDSequence> versions(repo.package_ids(package));
@@ -144,8 +152,8 @@ namespace
is_interesting = true;
/* replace the entry */
- slots_to_versions.erase((*v)->slot());
- slots_to_versions.insert(std::make_pair((*v)->slot(),
+ slots_to_versions.erase(slot_as_string(*v));
+ slots_to_versions.insert(std::make_pair(slot_as_string(*v),
make_named_values<SlotsEntry>(
value_for<n::best_version>(VersionSpec("0")),
value_for<n::our_version>((*v)->version())
@@ -156,7 +164,7 @@ namespace
(*v)->keywords_key()->value()->end(), IsStableKeyword()))
{
/* ensure that an entry exists */
- slots_to_versions.insert(std::make_pair((*v)->slot(),
+ slots_to_versions.insert(std::make_pair(slot_as_string(*v),
make_named_values<SlotsEntry>(
value_for<n::best_version>((*v)->version()),
value_for<n::our_version>(VersionSpec("0"))
@@ -164,8 +172,8 @@ namespace
/* update the entry to mark our current version as the best
* version */
- if (slots_to_versions.find((*v)->slot())->second.best_version() <= (*v)->version())
- slots_to_versions.find((*v)->slot())->second.best_version() = (*v)->version();
+ if (slots_to_versions.find(slot_as_string(*v))->second.best_version() <= (*v)->version())
+ slots_to_versions.find(slot_as_string(*v))->second.best_version() = (*v)->version();
}
}
diff --git a/src/clients/adjutrix/keywords_graph.cc b/src/clients/adjutrix/keywords_graph.cc
index f28ddfa..7a5ed90 100644
--- a/src/clients/adjutrix/keywords_graph.cc
+++ b/src/clients/adjutrix/keywords_graph.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -61,6 +61,14 @@ namespace
}
};
+ std::string slot_as_string(const PackageID & id)
+ {
+ if (id.slot_key())
+ return stringify(id.slot_key()->value());
+ else
+ return "(none)";
+ }
+
void
write_keywords_graph(const Environment & e, const Repository & repo,
const QualifiedPackageName & package)
@@ -107,10 +115,10 @@ namespace
return;
}
- std::set<SlotName> slots;
+ std::set<std::string> slots;
std::transform(indirect_iterator(packages->begin()), indirect_iterator(packages->end()),
std::inserter(slots, slots.begin()),
- std::tr1::mem_fn(&PackageID::slot));
+ std::tr1::bind(&slot_as_string, std::tr1::placeholders::_1));
unsigned version_specs_columns_width(std::max_element(indirect_iterator(packages->begin()),
indirect_iterator(packages->end()),
@@ -123,7 +131,7 @@ namespace
arch_flags.end(), CompareByStringLength<std::string>())).length(), static_cast<std::size_t>(6)));
unsigned longest_slot_name(stringify(*std::max_element(slots.begin(),
- slots.end(), CompareByStringLength<SlotName>())).length());
+ slots.end(), CompareByStringLength<std::string>())).length());
for (unsigned h = 0 ; h < tallest_arch_name ; ++h)
{
@@ -153,15 +161,15 @@ namespace
<< std::string(arch_flags.size() * 2 + 1, '-') << "+"
<< std::string(longest_slot_name + 3, '-') << endl;
- SlotName old_slot("first_slot");
+ std::string old_slot("the first slot");
for (IndirectIterator<PackageIDSequence::ConstIterator> p(packages->begin()), p_end(packages->end()) ;
p != p_end ; ++p)
{
if (! p->keywords_key())
continue;
- if (p->slot() != old_slot)
- if (old_slot != SlotName("first_slot"))
+ if (slot_as_string(*p) != old_slot)
+ if (old_slot != "the first slot")
cout << std::string(version_specs_columns_width, '-') << "+"
<< std::string(arch_flags.size() * 2 + 1, '-') << "+"
<< std::string(longest_slot_name + 3, '-') << endl;
@@ -188,10 +196,10 @@ namespace
cout << "| " << (indirect_iterator(unused->end()) !=
std::find(indirect_iterator(unused->begin()), indirect_iterator(unused->end()), *p) ? "* " : " ");
- if (p->slot() != old_slot)
+ if (slot_as_string(*p) != old_slot)
{
- cout << p->slot();
- old_slot = p->slot();
+ cout << slot_as_string(*p);
+ old_slot = slot_as_string(*p);
}
cout << endl;
diff --git a/src/clients/cave/cmd_show.cc b/src/clients/cave/cmd_show.cc
index ef7a6f1..86b7ed8 100644
--- a/src/clients/cave/cmd_show.cc
+++ b/src/clients/cave/cmd_show.cc
@@ -113,6 +113,14 @@ namespace
}
};
+ std::string slot_as_string(const std::tr1::shared_ptr<const PackageID> & id)
+ {
+ if (id->slot_key())
+ return stringify(id->slot_key()->value());
+ else
+ return "";
+ }
+
struct SetDisplayer
{
const std::tr1::shared_ptr<const Environment> env;
@@ -385,6 +393,12 @@ namespace
stringify(k.value()), indent, important);
}
+ void visit(const MetadataValueKey<SlotName> & k)
+ {
+ cout << format_general_rhvib(f::show_metadata_key_value(), k.raw_name(), k.human_name(),
+ stringify(k.value()), indent, important);
+ }
+
void visit(const MetadataValueKey<long> & k)
{
cout << format_general_rhvib(f::show_metadata_key_value(), k.raw_name(), k.human_name(),
@@ -708,11 +722,11 @@ namespace
if ((*i)->repository()->name() != *r)
continue;
- if (slot_name != stringify((*i)->slot()))
+ if (slot_name != slot_as_string(*i))
{
if (! slot_name.empty())
cout << format_general_s(f::show_package_slot(), slot_name);
- slot_name = stringify((*i)->slot());
+ slot_name = slot_as_string(*i);
}
if (need_space)
diff --git a/src/clients/cave/format_plain_metadata_key.cc b/src/clients/cave/format_plain_metadata_key.cc
index b01d877..a908cd7 100644
--- a/src/clients/cave/format_plain_metadata_key.cc
+++ b/src/clients/cave/format_plain_metadata_key.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -87,6 +87,11 @@ namespace
s << k.value();
}
+ void visit(const MetadataValueKey<SlotName> & k)
+ {
+ s << k.value();
+ }
+
void visit(const MetadataSpecTreeKey<DependencySpecTree> & k)
{
StringifyFormatter f;
diff --git a/src/clients/inquisitio/key_extractor.cc b/src/clients/inquisitio/key_extractor.cc
index f1e226f..2252d63 100644
--- a/src/clients/inquisitio/key_extractor.cc
+++ b/src/clients/inquisitio/key_extractor.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -209,6 +209,11 @@ namespace
result = _m(s.value());
}
+ void visit(const MetadataValueKey<SlotName> & s)
+ {
+ result = _m(stringify(s.value()));
+ }
+
void visit(const MetadataValueKey<long> & s)
{
result = _m(stringify(s.value()));
diff --git a/src/clients/instruo/instruo.cc b/src/clients/instruo/instruo.cc
index ab65bba..4bfa4e4 100644
--- a/src/clients/instruo/instruo.cc
+++ b/src/clients/instruo/instruo.cc
@@ -63,6 +63,11 @@ namespace
const std::string & PALUDIS_ATTRIBUTE((unused)) s(k.value());
}
+ void visit(const MetadataValueKey<SlotName> & k)
+ {
+ const SlotName & PALUDIS_ATTRIBUTE((unused)) s(k.value());
+ }
+
void visit(const MetadataValueKey<long> & k)
{
long PALUDIS_ATTRIBUTE((unused)) t(k.value());
diff --git a/src/clients/paludis/applets.cc b/src/clients/paludis/applets.cc
index 8d2db8f..542daf2 100644
--- a/src/clients/paludis/applets.cc
+++ b/src/clients/paludis/applets.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -55,6 +55,11 @@ namespace
std::cout << k.value() << std::endl;
}
+ void visit(const MetadataValueKey<SlotName> & k)
+ {
+ std::cout << k.value() << std::endl;
+ }
+
void visit(const MetadataValueKey<long> & k)
{
std::cout << k.value() << std::endl;
diff --git a/src/clients/paludis/info.cc b/src/clients/paludis/info.cc
index b3cffc9..1ad15ba 100644
--- a/src/clients/paludis/info.cc
+++ b/src/clients/paludis/info.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -88,6 +88,11 @@ namespace
cout << std::setw(30) << (indent + k.human_name() + ":") << " " << k.value() << endl;
}
+ void visit(const MetadataValueKey<SlotName> & k)
+ {
+ cout << std::setw(30) << (indent + k.human_name() + ":") << " " << k.value() << endl;
+ }
+
void visit(const MetadataValueKey<long> & k)
{
cout << std::setw(30) << (indent + k.human_name() + ":") << " " << k.value() << endl;
diff --git a/src/clients/qualudis/qualudis.cc b/src/clients/qualudis/qualudis.cc
index 5bbef7a..3ccfb5f 100644
--- a/src/clients/qualudis/qualudis.cc
+++ b/src/clients/qualudis/qualudis.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -141,6 +141,11 @@ namespace
stream << k.raw_name() << ": " << k.value() << "\n";
}
+ void visit(const MetadataValueKey<SlotName> & k)
+ {
+ stream << k.raw_name() << ": " << k.value() << "\n";
+ }
+
void visit(const MetadataValueKey<long> & k)
{
stream << k.raw_name() << ": " << k.value() << "\n";
diff --git a/src/clients/reconcilio/fix_linkage.cc b/src/clients/reconcilio/fix_linkage.cc
index 5ae9934..e46eb7c 100644
--- a/src/clients/reconcilio/fix_linkage.cc
+++ b/src/clients/reconcilio/fix_linkage.cc
@@ -36,6 +36,7 @@
#include <paludis/name.hh>
#include <paludis/package_id.hh>
#include <paludis/version_requirements.hh>
+#include <paludis/metadata_key.hh>
#include <src/output/colour.hh>
@@ -97,17 +98,17 @@ do_fix_linkage(const std::tr1::shared_ptr<Environment> & env)
std::cout << std::endl;
}
+ PartiallyMadePackageDepSpec part_spec;
+ part_spec.package((*pkg_it)->name());
+ if ((*pkg_it)->slot_key())
+ part_spec.slot_requirement(make_shared_ptr(new UserSlotExactRequirement((*pkg_it)->slot_key()->value())));
+
if (CommandLine::get_instance()->a_exact.specified())
- targets->push_back(stringify(make_package_dep_spec()
- .package((*pkg_it)->name())
- .version_requirement(make_named_values<VersionRequirement>(
- value_for<n::version_operator>(vo_equal),
- value_for<n::version_spec>((*pkg_it)->version())))
- .slot_requirement(make_shared_ptr(new UserSlotExactRequirement((*pkg_it)->slot())))));
- else
- targets->push_back(stringify(make_package_dep_spec()
- .package((*pkg_it)->name())
- .slot_requirement(make_shared_ptr(new UserSlotExactRequirement((*pkg_it)->slot())))));
+ part_spec.version_requirement(make_named_values<VersionRequirement>(
+ value_for<n::version_operator>(vo_equal),
+ value_for<n::version_spec>((*pkg_it)->version())));
+
+ targets->push_back(stringify(PackageDepSpec(part_spec)));
}
std::tr1::shared_ptr<const PackageID> orphans;
diff --git a/src/output/console_install_task.cc b/src/output/console_install_task.cc
index 08b2ce5..bf06943 100644
--- a/src/output/console_install_task.cc
+++ b/src/output/console_install_task.cc
@@ -436,14 +436,10 @@ ConsoleInstallTask::on_display_merge_list_entry(const DepListEntry & d)
std::tr1::shared_ptr<const PackageIDSequence> existing_slot_repo((*environment())[selection::AllVersionsSorted(
generator::Matches(repo ?
- make_package_dep_spec()
- .package(d.package_id()->name())
- .slot_requirement(make_shared_ptr(new UserSlotExactRequirement(d.package_id()->slot())))
- .in_repository(*repo) :
- make_package_dep_spec()
- .package(d.package_id()->name())
- .slot_requirement(make_shared_ptr(new UserSlotExactRequirement(d.package_id()->slot()))),
- MatchPackageOptions()))]);
+ make_package_dep_spec().package(d.package_id()->name()).in_repository(*repo) :
+ make_package_dep_spec().package(d.package_id()->name()),
+ MatchPackageOptions()) |
+ filter::SameSlot(d.package_id()))]);
display_merge_list_entry_start(d, m);
display_merge_list_entry_package_name(d, m);
@@ -911,10 +907,8 @@ ConsoleInstallTask::display_merge_list_entry_repository(const DepListEntry & d,
{
// XXX fix this once the new resolver's in
std::tr1::shared_ptr<const PackageIDSequence> inst((*environment())[selection::BestVersionOnly(
- generator::Matches(make_package_dep_spec()
- .package(d.package_id()->name())
- .slot_requirement(make_shared_ptr(new UserSlotExactRequirement(d.package_id()->slot()))),
- MatchPackageOptions()) |
+ generator::Package(d.package_id()->name()) |
+ filter::SameSlot(d.package_id()) |
filter::InstalledAtRoot(environment()->root()))]);
bool changed(normal_entry == m &&
! inst->empty() && (*inst->begin())->from_repositories_key() &&
@@ -932,22 +926,25 @@ ConsoleInstallTask::display_merge_list_entry_repository(const DepListEntry & d,
void
ConsoleInstallTask::display_merge_list_entry_slot(const DepListEntry & d, const DisplayMode m)
{
- if (d.package_id()->slot() == SlotName("0"))
+ if (! d.package_id()->slot_key())
+ return;
+
+ if (d.package_id()->slot_key()->value() == SlotName("0"))
return;
switch (m)
{
case normal_entry:
case suggested_entry:
- output_no_endl(render_as_slot_name(" :" + stringify(d.package_id()->slot())));
+ output_no_endl(render_as_slot_name(" :" + stringify(d.package_id()->slot_key()->value())));
break;
case unimportant_entry:
- output_no_endl(render_as_unimportant(" :" + stringify(d.package_id()->slot())));
+ output_no_endl(render_as_unimportant(" :" + stringify(d.package_id()->slot_key()->value())));
break;
case error_entry:
- output_no_endl(render_as_slot_name(" :" + stringify(d.package_id()->slot())));
+ output_no_endl(render_as_slot_name(" :" + stringify(d.package_id()->slot_key()->value())));
break;
}
}
diff --git a/src/output/console_query_task.cc b/src/output/console_query_task.cc
index 5e326fd..0dc7937 100644
--- a/src/output/console_query_task.cc
+++ b/src/output/console_query_task.cc
@@ -64,6 +64,17 @@ namespace paludis
};
}
+namespace
+{
+ std::string slot_as_string(const std::tr1::shared_ptr<const PackageID> & id)
+ {
+ if (id->slot_key())
+ return stringify(id->slot_key()->value());
+ else
+ return "(none)";
+ }
+}
+
ConsoleQueryTask::ConsoleQueryTask(const Environment * const e) :
PrivateImplementationPattern<ConsoleQueryTask>(new Implementation<ConsoleQueryTask>(e))
{
@@ -214,7 +225,7 @@ ConsoleQueryTask::display_versions_by_repository(const PackageDepSpec &,
if ((*e)->repository()->name() == *r)
{
/* show the slot, if we're about to move onto a new slot */
- std::string slot_name(stringify((*e)->slot()));
+ std::string slot_name(slot_as_string(*e));
if (old_slot.empty())
old_slot = slot_name;
else if (old_slot != slot_name)
@@ -560,6 +571,23 @@ namespace
}
}
+ void visit(const MetadataValueKey<SlotName> & k)
+ {
+ if (k.type() == type)
+ {
+ if (task->want_raw())
+ {
+ task->output_left_column(k.raw_name() + ":", in);
+ task->output_right_column(stringify(k.value()));
+ }
+ else
+ {
+ task->output_left_column(k.human_name() + ":", in);
+ task->output_right_column(stringify(k.value()));
+ }
+ }
+ }
+
void visit(const MetadataValueKey<long> & k)
{
if (k.type() == type)
diff --git a/src/output/mask_displayer.cc b/src/output/mask_displayer.cc
index f8562e4..461768c 100644
--- a/src/output/mask_displayer.cc
+++ b/src/output/mask_displayer.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -25,6 +25,7 @@
#include <paludis/util/sequence.hh>
#include <paludis/util/set.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/name.hh>
#include <paludis/metadata_key.hh>
#include <sstream>
@@ -67,6 +68,11 @@ namespace
s << k.value();
}
+ void visit(const MetadataValueKey<SlotName> & k)
+ {
+ s << k.value();
+ }
+
void visit(const MetadataValueKey<long> & k)
{
s << k.value();