aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-11-30 20:33:44 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-11-30 20:33:44 +0000
commit81de25bf6a4a4eaa33d08edb5f9e32a0bdb9ace3 (patch)
treebe40759321069c6f426d505dc7de2747035b9d01
parent410957de97c3f8c4d91326683f9b8783f46538c2 (diff)
downloadpaludis-81de25bf6a4a4eaa33d08edb5f9e32a0bdb9ace3.tar.gz
paludis-81de25bf6a4a4eaa33d08edb5f9e32a0bdb9ace3.tar.xz
Add experimental vdb provides cache option, framework for repository caches
-rw-r--r--hooks/Makefile.am.m47
-rwxr-xr-xhooks/installable_cache_regen.bash29
-rwxr-xr-xhooks/installed_cache_regen.bash29
-rw-r--r--paludis/repositories/vdb/vdb_repository.cc222
-rw-r--r--paludis/repositories/vdb/vdb_repository.hh6
-rw-r--r--paludis/repositories/vdb/vdb_repository.sr1
-rw-r--r--paludis/repository.cc5
-rw-r--r--paludis/repository.hh7
-rw-r--r--src/paludis/applets.cc18
-rw-r--r--src/paludis/applets.hh3
-rw-r--r--src/paludis/command_line.cc4
-rw-r--r--src/paludis/command_line.hh6
-rw-r--r--src/paludis/paludis.cc11
13 files changed, 298 insertions, 50 deletions
diff --git a/hooks/Makefile.am.m4 b/hooks/Makefile.am.m4
index aa51108..829a1ac 100644
--- a/hooks/Makefile.am.m4
+++ b/hooks/Makefile.am.m4
@@ -18,7 +18,9 @@ installhookcommonprog_SCRIPTS = \
gnu_info_index.bash \
eselect_env_update.bash \
log.bash \
- news.bash
+ news.bash \
+ installable_cache_regen.bash \
+ installed_cache_regen.bash
installhookinstallallpost_SCRIPTS = \
find_config_updates.bash
@@ -195,6 +197,9 @@ install-data-local :
ln -sf ../common/news.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/sync_all_post/
ln -sf ../common/news.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/install_all_post/
ln -sf ../common/news.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/install_pretend_post/
+ ln -sf ../common/installable_cache_regen.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/sync_all_post/
+ ln -sf ../common/installed_cache_regen.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/install_post/
+ ln -sf ../common/installed_cache_regen.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/uninstall_post/
uninstall-local :
rm $(DESTDIR)/$(libexecdir)/paludis/hooks/*/gnu_info_index.bash
diff --git a/hooks/installable_cache_regen.bash b/hooks/installable_cache_regen.bash
new file mode 100755
index 0000000..a739f83
--- /dev/null
+++ b/hooks/installable_cache_regen.bash
@@ -0,0 +1,29 @@
+#!/bin/bash
+# vim: set et sw=4 sts=4 :
+
+# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+#
+# 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 as published by the Free Software Foundation; either version
+# 2 of the License, or (at your option) any later version.
+#
+# 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
+
+export PATH="$(${PALUDIS_EBUILD_DIR}/utils/canonicalise ${PALUDIS_EBUILD_DIR}/utils/ ):${PATH}"
+source ${PALUDIS_EBUILD_DIR}/echo_functions.bash
+
+echo
+einfo "Regenerating cache for installable repositories..."
+${PALUDIS_COMMAND} --regenerate-installable-cache
+einfo "Done regenerating cache for installable repositories"
+
+true
+
diff --git a/hooks/installed_cache_regen.bash b/hooks/installed_cache_regen.bash
new file mode 100755
index 0000000..940c5ff
--- /dev/null
+++ b/hooks/installed_cache_regen.bash
@@ -0,0 +1,29 @@
+#!/bin/bash
+# vim: set et sw=4 sts=4 :
+
+# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+#
+# 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 as published by the Free Software Foundation; either version
+# 2 of the License, or (at your option) any later version.
+#
+# 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
+
+export PATH="$(${PALUDIS_EBUILD_DIR}/utils/canonicalise ${PALUDIS_EBUILD_DIR}/utils/ ):${PATH}"
+source ${PALUDIS_EBUILD_DIR}/echo_functions.bash
+
+echo
+einfo "Regenerating cache for installed repositories..."
+${PALUDIS_COMMAND} --regenerate-installed-cache
+einfo "Done regenerating cache for installed repositories"
+
+true
+
diff --git a/paludis/repositories/vdb/vdb_repository.cc b/paludis/repositories/vdb/vdb_repository.cc
index 44c9e21..21a029d 100644
--- a/paludis/repositories/vdb/vdb_repository.cc
+++ b/paludis/repositories/vdb/vdb_repository.cc
@@ -317,6 +317,9 @@ namespace paludis
/// World file
FSEntry world_file;
+ /// Provides cache
+ FSEntry provides_cache;
+
/// Do we have entries loaded?
mutable bool entries_valid;
@@ -329,6 +332,9 @@ namespace paludis
/// Load metadata for one entry.
void load_entry(std::vector<VDBEntry>::iterator) const;
+ /// Provieds data
+ mutable RepositoryProvidesInterface::ProvidesCollection::Pointer provides;
+
/// Constructor.
Implementation(const VDBRepositoryParams &);
@@ -346,7 +352,9 @@ namespace paludis
root(p.root),
buildroot(p.buildroot),
world_file(p.world),
- entries_valid(false)
+ provides_cache(p.provides_cache),
+ entries_valid(false),
+ provides(0)
{
}
@@ -775,8 +783,8 @@ VDBRepository::make_vdb_repository(
const PackageDatabase * const db,
AssociativeCollection<std::string, std::string>::ConstPointer m)
{
- Context context("When making VDB repository from repo_file '" +
- (m->end() == m->find("repo_file") ? std::string("?") : m->find("repo_file")->second) + "':");
+ std::string repo_file(m->end() == m->find("repo_file") ? std::string("?") : m->find("repo_file")->second);
+ Context context("When making VDB repository from repo_file '" + repo_file + "':");
std::string location;
if (m->end() == m->find("location") || ((location = m->find("location")->second)).empty())
@@ -790,6 +798,15 @@ VDBRepository::make_vdb_repository(
if (m->end() == m->find("world") || ((world = m->find("world")->second)).empty())
world = location + "/world";
+ std::string provides_cache;
+ if (m->end() == m->find("provides_cache") || ((provides_cache = m->find("provides_cache")->second)).empty())
+ {
+ Log::get_instance()->message(ll_warning, lc_no_context, "The provides_cache key is not set in '"
+ + repo_file + "'. You should read http://paludis.berlios.de/CacheFiles.html and select an "
+ "appropriate value.");
+ provides_cache = "/var/empty";
+ }
+
std::string buildroot;
if (m->end() == m->find("buildroot") || ((buildroot = m->find("buildroot")->second)).empty())
buildroot = "/var/tmp/paludis";
@@ -800,7 +817,8 @@ VDBRepository::make_vdb_repository(
.location(location)
.root(root)
.world(world)
- .buildroot(buildroot)));
+ .buildroot(buildroot)
+ .provides_cache(provides_cache)));
}
VDBRepositoryConfigurationError::VDBRepositoryConfigurationError(
@@ -1095,7 +1113,126 @@ VDBRepository::get_environment_variable(
RepositoryProvidesInterface::ProvidesCollection::ConstPointer
VDBRepository::provided_packages() const
{
- Context context("When loading VDB PROVIDEs map:");
+ if (_imp->provides)
+ return _imp->provides;
+
+ if (! load_provided_using_cache())
+ load_provided_the_slow_way();
+
+ return _imp->provides;
+}
+
+VersionMetadata::ConstPointer
+VDBRepository::provided_package_version_metadata(const RepositoryProvidesEntry & p) const
+{
+ VersionMetadata::ConstPointer m(version_metadata(p.provided_by_name, p.version));
+ VersionMetadata::Virtual::Pointer result(new VersionMetadata::Virtual(
+ PortageDepParser::parse_depend, PackageDatabaseEntry(p.provided_by_name,
+ p.version, name())));
+
+ result->slot = m->slot;
+ result->license_string = m->license_string;
+ result->eapi = m->eapi;
+ result->deps = VersionMetadataDeps(&PortageDepParser::parse_depend,
+ stringify(p.provided_by_name), stringify(p.provided_by_name), "");
+
+ return result;
+}
+
+UseFlagNameCollection::ConstPointer
+VDBRepository::do_arch_flags() const
+{
+ return UseFlagNameCollection::ConstPointer(new UseFlagNameCollection::Concrete);
+}
+
+UseFlagNameCollection::ConstPointer
+VDBRepository::do_use_expand_flags() const
+{
+ return UseFlagNameCollection::ConstPointer(new UseFlagNameCollection::Concrete);
+}
+
+UseFlagNameCollection::ConstPointer
+VDBRepository::do_use_expand_prefixes() const
+{
+ return UseFlagNameCollection::ConstPointer(new UseFlagNameCollection::Concrete);
+}
+
+UseFlagNameCollection::ConstPointer
+VDBRepository::do_use_expand_hidden_prefixes() const
+{
+ return UseFlagNameCollection::ConstPointer(new UseFlagNameCollection::Concrete);
+}
+
+UseFlagName
+VDBRepository::do_use_expand_name(const UseFlagName & u) const
+{
+ return u;
+}
+
+UseFlagName
+VDBRepository::do_use_expand_value(const UseFlagName & u) const
+{
+ return u;
+}
+
+bool
+VDBRepository::load_provided_using_cache() const
+{
+ if (_imp->provides_cache == FSEntry("/var/empty"))
+ return false;
+
+ Context context("When loading VDB PROVIDEs map using '" + stringify(_imp->provides_cache) + "':");
+
+ ProvidesCollection::Pointer result(new ProvidesCollection::Concrete);
+
+ if (! _imp->provides_cache.is_regular_file())
+ {
+ Log::get_instance()->message(ll_warning, lc_no_context, "Provides cache at '"
+ + stringify(_imp->provides_cache) + "' is not a regular file.");
+ return false;
+ }
+
+ LineConfigFile provides_cache(_imp->provides_cache);
+ LineConfigFile::Iterator line(provides_cache.begin()), line_end(provides_cache.end());
+
+ std::string version;
+ if (line != line_end)
+ version = *line++;
+
+ if (version != "paludis-1")
+ {
+ Log::get_instance()->message(ll_warning, lc_no_context, "Can't use provides cache at '"
+ + stringify(_imp->provides_cache) + "' because format '" + version + "' is not 'paludis-1'");
+ return false;
+ }
+
+ while (line != line_end)
+ {
+ std::vector<std::string> tokens;
+ WhitespaceTokeniser::get_instance()->tokenise(*line++, std::back_inserter(tokens));
+ if (tokens.size() < 3)
+ continue;
+
+ PackageDatabaseEntry dbe(QualifiedPackageName(tokens.at(0)), VersionSpec(tokens.at(1)), name());
+ DepAtomFlattener f(_imp->env, &dbe, PortageDepParser::parse(
+ join(next(next(tokens.begin())), tokens.end(), " "),
+ PortageDepParserPolicy<PackageDepAtom, false>::get_instance()));
+
+ for (DepAtomFlattener::Iterator p(f.begin()), p_end(f.end()) ; p != p_end ; ++p)
+ result->insert(RepositoryProvidesEntry::create()
+ .virtual_name((*p)->text())
+ .version(dbe.version)
+ .provided_by_name(dbe.name));
+ }
+
+ _imp->provides = result;
+ return true;
+}
+
+void
+VDBRepository::load_provided_the_slow_way() const
+{
+ Context context("When loading VDB PROVIDEs map the slow way:");
Log::get_instance()->message(ll_debug, lc_no_context, "Starting VDB PROVIDEs map creation");
@@ -1158,60 +1295,49 @@ VDBRepository::provided_packages() const
Log::get_instance()->message(ll_debug, lc_no_context, "Done VDB PROVIDEs map creation");
- return result;
+ _imp->provides = result;
}
-VersionMetadata::ConstPointer
-VDBRepository::provided_package_version_metadata(const RepositoryProvidesEntry & p) const
+void
+VDBRepository::regenerate_cache() const
{
- VersionMetadata::ConstPointer m(version_metadata(p.provided_by_name, p.version));
- VersionMetadata::Virtual::Pointer result(new VersionMetadata::Virtual(
- PortageDepParser::parse_depend, PackageDatabaseEntry(p.provided_by_name,
- p.version, name())));
+ if (_imp->provides_cache == FSEntry("/var/empty"))
+ return;
- result->slot = m->slot;
- result->license_string = m->license_string;
- result->eapi = m->eapi;
- result->deps = VersionMetadataDeps(&PortageDepParser::parse_depend,
- stringify(p.provided_by_name), stringify(p.provided_by_name), "");
+ Context context("When generating VDB repository provides cache at '"
+ + stringify(_imp->provides_cache) + "':");
- return result;
-}
+ FSEntry(_imp->provides_cache).unlink();
+ _imp->provides_cache.dirname().mkdir();
-UseFlagNameCollection::ConstPointer
-VDBRepository::do_arch_flags() const
-{
- return UseFlagNameCollection::ConstPointer(new UseFlagNameCollection::Concrete);
-}
+ if (! _imp->entries_valid)
+ _imp->load_entries();
-UseFlagNameCollection::ConstPointer
-VDBRepository::do_use_expand_flags() const
-{
- return UseFlagNameCollection::ConstPointer(new UseFlagNameCollection::Concrete);
-}
+ std::ofstream f(stringify(_imp->provides_cache).c_str());
+ if (! f)
+ {
+ Log::get_instance()->message(ll_warning, lc_context, "Cannot write to '"
+ + stringify(_imp->provides_cache) + "'");
+ return;
+ }
-UseFlagNameCollection::ConstPointer
-VDBRepository::do_use_expand_prefixes() const
-{
- return UseFlagNameCollection::ConstPointer(new UseFlagNameCollection::Concrete);
-}
+ f << "paludis-1" << std::endl;
-UseFlagNameCollection::ConstPointer
-VDBRepository::do_use_expand_hidden_prefixes() const
-{
- return UseFlagNameCollection::ConstPointer(new UseFlagNameCollection::Concrete);
-}
+ for (std::vector<VDBEntry>::const_iterator c(_imp->entries.begin()), c_end(_imp->entries.end()) ;
+ c != c_end ; ++c)
+ {
+ std::string provide_str;
+ if (c->metadata)
+ provide_str = c->metadata->get_ebuild_interface()->provide_string;
+ else
+ provide_str = file_contents(_imp->location, c->name, c->version, "PROVIDE");
-UseFlagName
-VDBRepository::do_use_expand_name(const UseFlagName & u) const
-{
- return u;
-}
+ provide_str = strip_leading(strip_trailing(provide_str, " \t\r\n"), " \t\r\n");
+ if (provide_str.empty())
+ continue;
-UseFlagName
-VDBRepository::do_use_expand_value(const UseFlagName & u) const
-{
- return u;
+ f << c->name << " " << c->version << " " << provide_str << std::endl;
+ }
}
#ifdef PALUDIS_ENABLE_VISIBILITY
diff --git a/paludis/repositories/vdb/vdb_repository.hh b/paludis/repositories/vdb/vdb_repository.hh
index 1745694..8ff5e8b 100644
--- a/paludis/repositories/vdb/vdb_repository.hh
+++ b/paludis/repositories/vdb/vdb_repository.hh
@@ -55,6 +55,10 @@ namespace paludis
public RepositoryProvidesInterface,
public PrivateImplementationPattern<VDBRepository>
{
+ private:
+ bool load_provided_using_cache() const;
+ void load_provided_the_slow_way() const;
+
protected:
virtual bool do_has_category_named(const CategoryNamePart &) const;
@@ -124,6 +128,8 @@ namespace paludis
virtual void invalidate() const;
+ virtual void regenerate_cache() const;
+
virtual void add_to_world(const QualifiedPackageName &) const;
virtual void remove_from_world(const QualifiedPackageName &) const;
diff --git a/paludis/repositories/vdb/vdb_repository.sr b/paludis/repositories/vdb/vdb_repository.sr
index ebdb633..04928d9 100644
--- a/paludis/repositories/vdb/vdb_repository.sr
+++ b/paludis/repositories/vdb/vdb_repository.sr
@@ -8,6 +8,7 @@ make_class_VDBRepositoryParams()
key location FSEntry
key root FSEntry
key world FSEntry
+ key provides_cache FSEntry
key buildroot FSEntry
doxygen_comment << "END"
diff --git a/paludis/repository.cc b/paludis/repository.cc
index c1aa807..eb3f56f 100644
--- a/paludis/repository.cc
+++ b/paludis/repository.cc
@@ -193,3 +193,8 @@ Repository::do_category_names_containing_package(const PackageNamePart & p) cons
return result;
}
+void
+Repository::regenerate_cache() const
+{
+}
+
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 127ba83..876c023 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -337,11 +337,16 @@ namespace paludis
}
/**
- * Invalidate any cache.
+ * Invalidate any in memory cache.
*/
virtual void invalidate() const = 0;
/**
+ * Regenerate any on disk cache.
+ */
+ virtual void regenerate_cache() const;
+
+ /**
* Are we allowed to be favourite repository?
*/
virtual bool can_be_favourite_repository() const
diff --git a/src/paludis/applets.cc b/src/paludis/applets.cc
index 4720b86..a11120d 100644
--- a/src/paludis/applets.cc
+++ b/src/paludis/applets.cc
@@ -218,3 +218,21 @@ int do_list_dep_tag_categories()
return return_code;
}
+int do_regenerate_cache(bool installed)
+{
+ Context context("When performing cache regeneration action from command line:");
+ Environment * const env(DefaultEnvironment::get_instance());
+
+ for (PackageDatabase::RepositoryIterator r(env->package_database()->begin_repositories()),
+ r_end(env->package_database()->end_repositories()) ; r != r_end ; ++r)
+ {
+ if (installed != (0 != (*r)->installed_interface))
+ continue;
+
+ std::cout << "Regenerating cache for " << (*r)->name() << "..." << std::endl;
+ (*r)->regenerate_cache();
+ }
+
+ return 0;
+}
+
diff --git a/src/paludis/applets.hh b/src/paludis/applets.hh
index 108b962..607b667 100644
--- a/src/paludis/applets.hh
+++ b/src/paludis/applets.hh
@@ -47,5 +47,8 @@ int do_list_sync_protocols();
/// Handle --list-dep-tag-categories
int do_list_dep_tag_categories();
+/// Handle cache regeneration
+int do_regenerate_cache(bool installed);
+
#endif
diff --git a/src/paludis/command_line.cc b/src/paludis/command_line.cc
index a913224..7158155 100644
--- a/src/paludis/command_line.cc
+++ b/src/paludis/command_line.cc
@@ -54,6 +54,10 @@ CommandLine::CommandLine() :
"List available repository formats"),
a_list_dep_tag_categories(&action_args_internal, "list-dep-tag-categories", '\0', "List known dep tag categories"),
a_update_news(&action_args_internal, "update-news", '\0', "Regenerate news.unread files"),
+ a_regenerate_installed_cache(&action_args_internal, "regenerate-installed-cache", '\0',
+ "Regenerate (non-metadata) cache for installed repositories"),
+ a_regenerate_installable_cache(&action_args_internal, "regenerate-installable-cache", '\0',
+ "Regenerate (non-metadata) cache for installable repositories"),
general_args(this, "General options",
"Options which are relevant for most or all actions."),
diff --git a/src/paludis/command_line.hh b/src/paludis/command_line.hh
index 5df2387..a60abc9 100644
--- a/src/paludis/command_line.hh
+++ b/src/paludis/command_line.hh
@@ -131,6 +131,12 @@ class CommandLine :
/// --update-news
paludis::args::SwitchArg a_update_news;
+ /// --regenerate-installed-cache
+ paludis::args::SwitchArg a_regenerate_installed_cache;
+
+ /// --regenerate-installable-cache
+ paludis::args::SwitchArg a_regenerate_installable_cache;
+
///}
/// \name General arguments
diff --git a/src/paludis/paludis.cc b/src/paludis/paludis.cc
index 1ef1e5d..c9f8178 100644
--- a/src/paludis/paludis.cc
+++ b/src/paludis/paludis.cc
@@ -207,6 +207,8 @@ main(int argc, char *argv[])
CommandLine::get_instance()->a_owner.specified() +
CommandLine::get_instance()->a_has_version.specified() +
CommandLine::get_instance()->a_update_news.specified() +
+ CommandLine::get_instance()->a_regenerate_installed_cache.specified() +
+ CommandLine::get_instance()->a_regenerate_installable_cache.specified() +
CommandLine::get_instance()->a_environment_variable.specified() +
CommandLine::get_instance()->a_configuration_variable.specified() +
CommandLine::get_instance()->a_info.specified() +
@@ -438,6 +440,15 @@ main(int argc, char *argv[])
return do_update_news();
}
+ if (CommandLine::get_instance()->a_regenerate_installed_cache.specified() ||
+ CommandLine::get_instance()->a_regenerate_installable_cache.specified())
+ {
+ if (! CommandLine::get_instance()->empty())
+ throw DoHelp("regenerate cache actions takes no parameters");
+
+ return do_regenerate_cache(CommandLine::get_instance()->a_regenerate_installed_cache.specified());
+ }
+
throw InternalError(__PRETTY_FUNCTION__, "no action?");
}
catch (const DoVersion &)