aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2009-04-22 21:28:35 +0100
committerAvatar David Leverton <levertond@googlemail.com> 2009-04-22 21:28:35 +0100
commit6e0588bd0ba3bbdda96412ea8f3d91191e681b20 (patch)
tree05c45844e91d246be5185446a38d2c80a94fc28f
parentffa3e75ce4d5cf786e4fda77f039cb73f8de3738 (diff)
downloadpaludis-6e0588bd0ba3bbdda96412ea8f3d91191e681b20.tar.gz
paludis-6e0588bd0ba3bbdda96412ea8f3d91191e681b20.tar.xz
Update caches with the newly added/removed IDs
We need this because, since 977328d782f70c7b3bc4fb52903fa937d037d778, the invalidate() gets called too late for some things that need to know about the new state.
-rw-r--r--paludis/ndbam.cc78
-rw-r--r--paludis/ndbam.hh3
-rw-r--r--paludis/repositories/e/exndbam_repository.cc8
-rwxr-xr-xpaludis/repositories/e/exndbam_repository_TEST_setup.sh3
-rw-r--r--paludis/repositories/e/vdb_repository.cc32
-rwxr-xr-xpaludis/repositories/e/vdb_repository_TEST_setup.sh5
6 files changed, 121 insertions, 8 deletions
diff --git a/paludis/ndbam.cc b/paludis/ndbam.cc
index 6297ad6..4a97b49 100644
--- a/paludis/ndbam.cc
+++ b/paludis/ndbam.cc
@@ -359,6 +359,84 @@ NDBAM::entries(const QualifiedPackageName & q)
}
void
+NDBAM::add_entry(const QualifiedPackageName & q, const FSEntry & d)
+{
+ Lock l(_imp->category_names_mutex);
+ CategoryContentsMap::iterator cc_i(_imp->category_contents_map.find(q.category()));
+ if (_imp->category_contents_map.end() == cc_i || ! cc_i->second)
+ return;
+ CategoryContents & cc(*cc_i->second);
+ l.acquire_then_release_old(cc.mutex);
+
+ PackageContentsMap::iterator pc_i(cc.package_contents_map.find(q));
+ if (cc.package_contents_map.end() == pc_i || ! pc_i->second)
+ return;
+ PackageContents & pc(*pc_i->second);
+ l.acquire_then_release_old(pc.mutex);
+
+ if (pc.entries)
+ {
+ std::vector<std::string> tokens;
+ tokenise<delim_kind::AnyOfTag, delim_mode::DelimiterTag>(d.basename(), ":", "", std::back_inserter(tokens));
+
+ VersionSpec v(tokens[0], _imp->version_options);
+ SlotName s(tokens[1]);
+ std::string m(tokens[2]);
+ pc.entries->push_back(make_shared_ptr(new NDBAMEntry(NDBAMEntry(make_named_values<NDBAMEntry>(
+ value_for<n::fs_location>(d.realpath()),
+ value_for<n::magic>(m),
+ value_for<n::mutex>(make_shared_ptr(new Mutex)),
+ value_for<n::name>(q),
+ value_for<n::package_id>(std::tr1::shared_ptr<PackageID>()),
+ value_for<n::slot>(s),
+ value_for<n::version>(v)
+ )))));
+ }
+}
+
+namespace
+{
+ struct FSLocationIs
+ {
+ FSEntry _d;
+
+ FSLocationIs(const FSEntry & d) :
+ _d(d)
+ {
+ }
+
+ bool operator() (const std::tr1::shared_ptr<const NDBAMEntry> & e) const
+ {
+ return e->fs_location() == _d;
+ }
+ };
+}
+
+void
+NDBAM::remove_entry(const QualifiedPackageName & q, const FSEntry & d)
+{
+ Lock l(_imp->category_names_mutex);
+ CategoryContentsMap::iterator cc_i(_imp->category_contents_map.find(q.category()));
+ if (_imp->category_contents_map.end() == cc_i || ! cc_i->second)
+ return;
+ CategoryContents & cc(*cc_i->second);
+ l.acquire_then_release_old(cc.mutex);
+
+ PackageContentsMap::iterator pc_i(cc.package_contents_map.find(q));
+ if (cc.package_contents_map.end() == pc_i || ! pc_i->second)
+ return;
+ PackageContents & pc(*pc_i->second);
+ l.acquire_then_release_old(pc.mutex);
+
+ if (pc.entries)
+ {
+ std::tr1::shared_ptr<NDBAMEntrySequence> new_entries(new NDBAMEntrySequence);
+ std::remove_copy_if(pc.entries->begin(), pc.entries->end(), new_entries->back_inserter(), FSLocationIs(d));
+ pc.entries = new_entries;
+ }
+}
+
+void
NDBAM::parse_contents(const PackageID & id,
const std::tr1::function<void (const std::tr1::shared_ptr<const ContentsEntry> &)> & on_file,
const std::tr1::function<void (const std::tr1::shared_ptr<const ContentsEntry> &)> & on_dir,
diff --git a/paludis/ndbam.hh b/paludis/ndbam.hh
index 2d64f6f..3abd57f 100644
--- a/paludis/ndbam.hh
+++ b/paludis/ndbam.hh
@@ -108,6 +108,9 @@ namespace paludis
std::tr1::shared_ptr<NDBAMEntrySequence> entries(const QualifiedPackageName &)
PALUDIS_ATTRIBUTE((warn_unused_result));
+ void add_entry(const QualifiedPackageName &, const FSEntry &);
+ void remove_entry(const QualifiedPackageName &, const FSEntry &);
+
///\}
/**
diff --git a/paludis/repositories/e/exndbam_repository.cc b/paludis/repositories/e/exndbam_repository.cc
index a2022cc..f9be764 100644
--- a/paludis/repositories/e/exndbam_repository.cc
+++ b/paludis/repositories/e/exndbam_repository.cc
@@ -371,6 +371,8 @@ ExndbamRepository::merge(const MergeParams & m)
write_vdb_entry_command();
+ _imp->ndbam.add_entry(m.package_id()->name(), target_ver_dir);
+
/* load CONFIG_PROTECT, CONFIG_PROTECT_MASK back */
std::string config_protect, config_protect_mask;
try
@@ -440,7 +442,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 && slot_is_same(candidate, m.package_id()))
+ if (candidate != if_overwritten_id && candidate->fs_location_key()->value() != target_ver_dir && slot_is_same(candidate, m.package_id()))
{
UninstallActionOptions uo(make_named_values<UninstallActionOptions>(
value_for<n::config_protect>(config_protect),
@@ -474,7 +476,7 @@ ExndbamRepository::perform_uninstall(
std::tr1::shared_ptr<OutputManager> output_manager(a.options.make_output_manager()(a));
- FSEntry ver_dir(id->fs_location_key()->value());
+ FSEntry ver_dir(id->fs_location_key()->value().realpath());
std::tr1::shared_ptr<FSEntry> load_env(new FSEntry(ver_dir / "environment.bz2"));
std::tr1::shared_ptr<FSEntrySequence> eclassdirs(new FSEntrySequence);
@@ -573,6 +575,8 @@ ExndbamRepository::perform_uninstall(
FSEntry(*d).unlink();
ver_dir.rmdir();
+ _imp->ndbam.remove_entry(id->name(), ver_dir);
+
FSEntry pkg_dir(ver_dir.dirname());
if (DirIterator() == DirIterator(pkg_dir, DirIteratorOptions() + dio_include_dotfiles + dio_inode_sort + dio_first_only))
{
diff --git a/paludis/repositories/e/exndbam_repository_TEST_setup.sh b/paludis/repositories/e/exndbam_repository_TEST_setup.sh
index 4ce00c8..8264040 100755
--- a/paludis/repositories/e/exndbam_repository_TEST_setup.sh
+++ b/paludis/repositories/e/exndbam_repository_TEST_setup.sh
@@ -49,8 +49,7 @@ pkg_postinst() {
\${COMMAND} "\${ROOT}"/\${OTHER##*/} || die
}
pkg_postrm() {
- if has_version "=\${CATEGORY}/\${PN}-0*:\${SLOT}" &&
- ( has_version "<\${CATEGORY}/\${PF}:\${SLOT}" || has_version ">\${CATEGORY}/\${PF}:\${SLOT}" ); then
+ if has_version "\${CATEGORY}/\${PN}:\${SLOT}[<\${PVR}&=0*]" || has_version "\${CATEGORY}/\${PN}:\${SLOT}[>\${PVR}&=0*]"; then
rmdir "\${ROOT}"/\${PF} || die
else
mkdir "\${ROOT}"/\${PF} || die
diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc
index 034ae12..42b25f7 100644
--- a/paludis/repositories/e/vdb_repository.cc
+++ b/paludis/repositories/e/vdb_repository.cc
@@ -496,6 +496,20 @@ VDBRepository::perform_uninstall(
FSEntry(*d).unlink();
pkg_dir.rmdir();
+ {
+ CategoryMap::iterator it(_imp->categories.find(id->name().category()));
+ if (_imp->categories.end() != it && it->second)
+ {
+ IDMap::iterator it2(_imp->ids.find(id->name()));
+ if (_imp->ids.end() != it2)
+ {
+ std::tr1::shared_ptr<PackageIDSequence> ids(new PackageIDSequence);
+ std::remove_copy(it2->second->begin(), it2->second->end(), ids->back_inserter(), id);
+ it2->second = ids;
+ }
+ }
+ }
+
if (! a.options.is_overwrite())
{
std::tr1::shared_ptr<const PackageIDSequence> ids(package_ids(id->name()));
@@ -925,6 +939,22 @@ VDBRepository::merge(const MergeParams & m)
tmp_vdb_dir.rename(vdb_dir);
+ std::tr1::shared_ptr<const PackageID> new_id;
+ {
+ CategoryMap::iterator it(_imp->categories.find(m.package_id()->name().category()));
+ if (_imp->categories.end() != it && it->second)
+ {
+ it->second->insert(m.package_id()->name());
+ IDMap::iterator it2(_imp->ids.find(m.package_id()->name()));
+ if (_imp->ids.end() == it2)
+ {
+ std::tr1::shared_ptr<PackageIDSequence> ids(new PackageIDSequence);
+ it2 = _imp->ids.insert(std::make_pair(m.package_id()->name(), ids)).first;
+ }
+ it2->second->push_back(new_id = make_id(m.package_id()->name(), m.package_id()->version(), vdb_dir));
+ }
+ }
+
merger.merge();
if (is_replace)
@@ -946,7 +976,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 && slot_is_same(candidate, m.package_id()))
+ if (candidate != is_replace && candidate != new_id && slot_is_same(candidate, m.package_id()))
{
UninstallActionOptions uo(make_named_values<UninstallActionOptions>(
value_for<n::config_protect>(config_protect),
diff --git a/paludis/repositories/e/vdb_repository_TEST_setup.sh b/paludis/repositories/e/vdb_repository_TEST_setup.sh
index 06e204e..868f46c 100755
--- a/paludis/repositories/e/vdb_repository_TEST_setup.sh
+++ b/paludis/repositories/e/vdb_repository_TEST_setup.sh
@@ -487,7 +487,7 @@ echo cat >postinsttest_src1/profiles/categories
cat <<END >postinsttest_src1/cat/pkg/pkg-0.ebuild
if [[ \${PV} == 0* ]]; then
- EAPI=1
+ EAPI=kdebuild-1
else
EAPI=paludis-1
fi
@@ -513,8 +513,7 @@ pkg_postinst() {
\${COMMAND} "\${ROOT}"/\${OTHER##*/} || die
}
pkg_postrm() {
- if has_version "=\${CATEGORY}/\${PN}-0*:\${SLOT}" &&
- ( has_version "<\${CATEGORY}/\${PF}:\${SLOT}" || has_version ">\${CATEGORY}/\${PF}:\${SLOT}" ); then
+ if has_version "\${CATEGORY}/\${PN}:\${SLOT}[<\${PVR}&=0*]" || has_version "\${CATEGORY}/\${PN}:\${SLOT}[>\${PVR}&=0*]"; then
rmdir "\${ROOT}"/\${PF} || die
else
mkdir "\${ROOT}"/\${PF} || die