aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2007-10-15 00:34:32 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2007-10-15 00:34:32 +0000
commitf7cc99de8df62d6459c03a46e268251b00dd8fa3 (patch)
tree611e9c41baccd8a582cc780a40397b91d4cb7618
parentf86df49454c19c43ed6233517c67e1ceb0d3d644 (diff)
downloadpaludis-f7cc99de8df62d6459c03a46e268251b00dd8fa3.tar.gz
paludis-f7cc99de8df62d6459c03a46e268251b00dd8fa3.tar.xz
Move private methods to the Implementations.
-rw-r--r--src/clients/reconcilio/broken_linkage_finder/broken_linkage_finder.cc62
-rw-r--r--src/clients/reconcilio/broken_linkage_finder/broken_linkage_finder.hh10
-rw-r--r--src/clients/reconcilio/broken_linkage_finder/configuration.cc62
-rw-r--r--src/clients/reconcilio/broken_linkage_finder/configuration.hh7
-rw-r--r--src/clients/reconcilio/broken_linkage_finder/elf_linkage_checker.cc29
-rw-r--r--src/clients/reconcilio/broken_linkage_finder/elf_linkage_checker.hh6
6 files changed, 84 insertions, 92 deletions
diff --git a/src/clients/reconcilio/broken_linkage_finder/broken_linkage_finder.cc b/src/clients/reconcilio/broken_linkage_finder/broken_linkage_finder.cc
index 95b83e9..81191af 100644
--- a/src/clients/reconcilio/broken_linkage_finder/broken_linkage_finder.cc
+++ b/src/clients/reconcilio/broken_linkage_finder/broken_linkage_finder.cc
@@ -76,6 +76,14 @@ namespace paludis
Breakage breakage;
PackageBreakage orphan_breakage;
+ void search_directory(const FSEntry &);
+
+ void walk_directory(const FSEntry &);
+ void check_file(const FSEntry &);
+
+ void add_breakage(const FSEntry &, const std::string &);
+ void gather_package(const tr1::shared_ptr<const PackageID> &);
+
Implementation(const Environment * the_env, const std::string & the_library) :
env(the_env),
config(the_env->root()),
@@ -137,10 +145,10 @@ BrokenLinkageFinder::BrokenLinkageFinder(const Environment * env, const std::str
join(search_dirs_pruned.begin(), search_dirs_pruned.end(), " ") + "\"");
parallel_for_each(search_dirs_pruned.begin(), search_dirs_pruned.end(),
- tr1::bind(&BrokenLinkageFinder::search_directory, this, _1));
+ tr1::bind(&Implementation<BrokenLinkageFinder>::search_directory, _imp.get(), _1));
tr1::function<void (const FSEntry &, const std::string &)> callback(
- tr1::bind(&BrokenLinkageFinder::add_breakage, this, _1, _2));
+ tr1::bind(&Implementation<BrokenLinkageFinder>::add_breakage, _imp.get(), _1, _2));
std::for_each(_imp->checkers.begin(), _imp->checkers.end(),
tr1::bind(&LinkageChecker::need_breakage_added, _1, callback));
@@ -152,13 +160,13 @@ BrokenLinkageFinder::~BrokenLinkageFinder()
}
void
-BrokenLinkageFinder::search_directory(const FSEntry & directory)
+Implementation<BrokenLinkageFinder>::search_directory(const FSEntry & directory)
{
FSEntry dir(directory);
do
{
dir = dir.dirname();
- if (_imp->config.dir_is_masked(dir))
+ if (config.dir_is_masked(dir))
{
Log::get_instance()->message(ll_debug, lc_context, "Skipping '" + stringify(directory) + "' because '" + stringify(dir) + "' is search-masked");
return;
@@ -166,7 +174,7 @@ BrokenLinkageFinder::search_directory(const FSEntry & directory)
}
while (FSEntry("/") != dir);
- FSEntry with_root(_imp->env->root() / directory);
+ FSEntry with_root(env->root() / directory);
if (with_root.is_directory())
walk_directory(with_root);
else
@@ -174,11 +182,11 @@ BrokenLinkageFinder::search_directory(const FSEntry & directory)
}
void
-BrokenLinkageFinder::walk_directory(const FSEntry & directory)
+Implementation<BrokenLinkageFinder>::walk_directory(const FSEntry & directory)
{
using namespace tr1::placeholders;
- if (_imp->config.dir_is_masked(directory.strip_leading(_imp->env->root())))
+ if (config.dir_is_masked(directory.strip_leading(env->root())))
{
Log::get_instance()->message(ll_debug, lc_context, "'" + stringify(directory) + "' is search-masked");
return;
@@ -188,7 +196,7 @@ BrokenLinkageFinder::walk_directory(const FSEntry & directory)
try
{
parallel_for_each(DirIterator(directory, false), DirIterator(),
- tr1::bind(&BrokenLinkageFinder::check_file, this, _1));
+ tr1::bind(&Implementation<BrokenLinkageFinder>::check_file, this, _1));
}
catch (const FSError & ex)
{
@@ -197,7 +205,7 @@ BrokenLinkageFinder::walk_directory(const FSEntry & directory)
}
void
-BrokenLinkageFinder::check_file(const FSEntry & file)
+Implementation<BrokenLinkageFinder>::check_file(const FSEntry & file)
{
using namespace tr1::placeholders;
@@ -205,9 +213,9 @@ BrokenLinkageFinder::check_file(const FSEntry & file)
{
if (file.is_symbolic_link())
{
- FSEntry target(dereference_with_root(file, _imp->env->root()));
+ FSEntry target(dereference_with_root(file, env->root()));
if (target.is_regular_file())
- std::for_each(_imp->checkers.begin(), _imp->checkers.end(),
+ std::for_each(checkers.begin(), checkers.end(),
tr1::bind(&LinkageChecker::note_symlink, _1, file, target));
}
@@ -215,8 +223,8 @@ BrokenLinkageFinder::check_file(const FSEntry & file)
walk_directory(file);
else if (file.is_regular_file())
- if (_imp->checkers.end() ==
- std::find_if(_imp->checkers.begin(), _imp->checkers.end(),
+ if (checkers.end() ==
+ std::find_if(checkers.begin(), checkers.end(),
tr1::bind(&LinkageChecker::check_file, _1, file)))
Log::get_instance()->message(ll_debug, lc_context, "'" + stringify(file) + "' is not a recognised file type");
}
@@ -227,41 +235,41 @@ BrokenLinkageFinder::check_file(const FSEntry & file)
}
void
-BrokenLinkageFinder::add_breakage(const FSEntry & file, const std::string & req)
+Implementation<BrokenLinkageFinder>::add_breakage(const FSEntry & file, const std::string & req)
{
using namespace tr1::placeholders;
- if (_imp->library.empty() && _imp->config.lib_is_masked(req))
+ if (library.empty() && config.lib_is_masked(req))
return;
- if (! _imp->has_files)
+ if (! has_files)
{
- _imp->has_files = true;
+ has_files = true;
Context ctx("When building map from files to packages:");
- tr1::shared_ptr<const PackageDatabase> db(_imp->env->package_database());
+ tr1::shared_ptr<const PackageDatabase> db(env->package_database());
tr1::shared_ptr<const PackageIDSequence> pkgs(
- db->query(query::InstalledAtRoot(_imp->env->root()), qo_whatever));
+ db->query(query::InstalledAtRoot(env->root()), qo_whatever));
parallel_for_each(pkgs->begin(), pkgs->end(),
- tr1::bind(&BrokenLinkageFinder::gather_package, this, _1));
+ tr1::bind(&Implementation<BrokenLinkageFinder>::gather_package, this, _1));
}
- FSEntry without_root(file.strip_leading(_imp->env->root()));
- std::pair<Files::const_iterator, Files::const_iterator> range(_imp->files.equal_range(without_root));
+ FSEntry without_root(file.strip_leading(env->root()));
+ std::pair<Files::const_iterator, Files::const_iterator> range(files.equal_range(without_root));
if (range.first == range.second)
- _imp->orphan_breakage[without_root].insert(req);
+ orphan_breakage[without_root].insert(req);
else
while (range.first != range.second)
{
- _imp->breakage[range.first->second][without_root].insert(req);
+ breakage[range.first->second][without_root].insert(req);
++range.first;
}
}
void
-BrokenLinkageFinder::gather_package(const tr1::shared_ptr<const PackageID> & pkg)
+Implementation<BrokenLinkageFinder>::gather_package(const tr1::shared_ptr<const PackageID> & pkg)
{
using namespace tr1::placeholders;
@@ -280,8 +288,8 @@ BrokenLinkageFinder::gather_package(const tr1::shared_ptr<const PackageID> & pkg
const ContentsFileEntry * file(visitor_cast<const ContentsFileEntry>(**it));
if (0 != file)
{
- Lock l(_imp->mutex);
- _imp->files.insert(std::make_pair(file->name(), pkg));
+ Lock l(mutex);
+ files.insert(std::make_pair(file->name(), pkg));
}
}
}
diff --git a/src/clients/reconcilio/broken_linkage_finder/broken_linkage_finder.hh b/src/clients/reconcilio/broken_linkage_finder/broken_linkage_finder.hh
index 5f1af22..78718e5 100644
--- a/src/clients/reconcilio/broken_linkage_finder/broken_linkage_finder.hh
+++ b/src/clients/reconcilio/broken_linkage_finder/broken_linkage_finder.hh
@@ -62,16 +62,6 @@ class BrokenLinkageFinder :
MissingRequirementConstIterator end_missing_requirements(
const paludis::tr1::shared_ptr<const paludis::PackageID> &, const paludis::FSEntry &)
const PALUDIS_ATTRIBUTE((warn_unused_result));
-
- private:
- void search_directory(const paludis::FSEntry &);
-
- void walk_directory(const paludis::FSEntry &);
- void check_file(const paludis::FSEntry &);
-
- void gather_package(const paludis::tr1::shared_ptr<const paludis::PackageID> &);
-
- void add_breakage(const paludis::FSEntry &, const std::string &);
};
#endif
diff --git a/src/clients/reconcilio/broken_linkage_finder/configuration.cc b/src/clients/reconcilio/broken_linkage_finder/configuration.cc
index 9c2ac52..aa4485c 100644
--- a/src/clients/reconcilio/broken_linkage_finder/configuration.cc
+++ b/src/clients/reconcilio/broken_linkage_finder/configuration.cc
@@ -51,6 +51,12 @@ namespace paludis
std::vector<std::string> ld_library_mask;
std::vector<FSEntry> search_dirs;
std::vector<FSEntry> search_dirs_mask;
+
+ void load_from_environment();
+ void load_from_etc_revdep_rebuild(const FSEntry &);
+ void load_from_etc_profile_env(const FSEntry &);
+ void load_from_etc_ld_so_conf(const FSEntry &);
+ void add_defaults();
};
}
@@ -127,11 +133,11 @@ Configuration::Configuration(const FSEntry & root) :
{
Context ctx("When loading broken linkage checker configuration for '" + stringify(root) + "':");
- load_from_environment();
- load_from_etc_revdep_rebuild(root);
- load_from_etc_profile_env(root);
- load_from_etc_ld_so_conf(root);
- add_defaults();
+ _imp->load_from_environment();
+ _imp->load_from_etc_revdep_rebuild(root);
+ _imp->load_from_etc_profile_env(root);
+ _imp->load_from_etc_ld_so_conf(root);
+ _imp->add_defaults();
cleanup("LD_LIBRARY_MASK", _imp->ld_library_mask, root);
cleanup("SEARCH_DIRS", _imp->search_dirs, root);
@@ -143,7 +149,7 @@ Configuration::~Configuration()
}
void
-Configuration::load_from_environment()
+Implementation<Configuration>::load_from_environment()
{
using namespace tr1::placeholders;
@@ -152,13 +158,13 @@ Configuration::load_from_environment()
tr1::function<std::string (const std::string &)> fromenv(
tr1::bind(getenv_with_default, _1, ""));
- from_string(fromenv, "LD_LIBRARY_MASK", _imp->ld_library_mask);
- from_string(fromenv, "SEARCH_DIRS", _imp->search_dirs);
- from_string(fromenv, "SEARCH_DIRS_MASK", _imp->search_dirs_mask);
+ from_string(fromenv, "LD_LIBRARY_MASK", ld_library_mask);
+ from_string(fromenv, "SEARCH_DIRS", search_dirs);
+ from_string(fromenv, "SEARCH_DIRS_MASK", search_dirs_mask);
}
void
-Configuration::load_from_etc_revdep_rebuild(const FSEntry & root)
+Implementation<Configuration>::load_from_etc_revdep_rebuild(const FSEntry & root)
{
using namespace tr1::placeholders;
@@ -190,9 +196,9 @@ Configuration::load_from_etc_revdep_rebuild(const FSEntry & root)
tr1::function<std::string (const std::string &)> fromfile(
tr1::bind(&KeyValueConfigFile::get, tr1::cref(kvs), _1));
- from_string(fromfile, "LD_LIBRARY_MASK", _imp->ld_library_mask);
- from_string(fromfile, "SEARCH_DIRS", _imp->search_dirs);
- from_string(fromfile, "SEARCH_DIRS_MASK", _imp->search_dirs_mask);
+ from_string(fromfile, "LD_LIBRARY_MASK", ld_library_mask);
+ from_string(fromfile, "SEARCH_DIRS", search_dirs);
+ from_string(fromfile, "SEARCH_DIRS_MASK", search_dirs_mask);
}
else
Log::get_instance()->message(ll_warning, lc_context, "'" + stringify(*it) + "' is not a regular file");
@@ -203,7 +209,7 @@ Configuration::load_from_etc_revdep_rebuild(const FSEntry & root)
}
void
-Configuration::load_from_etc_profile_env(const FSEntry & root)
+Implementation<Configuration>::load_from_etc_profile_env(const FSEntry & root)
{
using namespace tr1::placeholders;
@@ -223,15 +229,15 @@ Configuration::load_from_etc_profile_env(const FSEntry & root)
tr1::function<std::string (const std::string &)> fromfile(
tr1::bind(&KeyValueConfigFile::get, tr1::cref(kvs), _1));
- from_string(fromfile, "PATH", _imp->search_dirs, tokeniser);
- from_string(fromfile, "ROOTPATH", _imp->search_dirs, tokeniser);
+ from_string(fromfile, "PATH", search_dirs, tokeniser);
+ from_string(fromfile, "ROOTPATH", search_dirs, tokeniser);
}
else if (etc_profile_env.exists())
Log::get_instance()->message(ll_warning, lc_context, "'" + stringify(etc_profile_env) + "' exists but is not a regular file");
}
void
-Configuration::load_from_etc_ld_so_conf(const FSEntry & root)
+Implementation<Configuration>::load_from_etc_ld_so_conf(const FSEntry & root)
{
FSEntry etc_ld_so_conf(root / "etc" / "ld.so.conf");
Context ctx("When reading '" + stringify(etc_ld_so_conf) + "':");
@@ -245,7 +251,7 @@ Configuration::load_from_etc_ld_so_conf(const FSEntry & root)
if (lines.begin() != lines.end())
{
Log::get_instance()->message(ll_debug, lc_context, "Got " + join(lines.begin(), lines.end(), " "));
- std::copy(lines.begin(), lines.end(), std::back_inserter(_imp->search_dirs));
+ std::copy(lines.begin(), lines.end(), std::back_inserter(search_dirs));
}
}
else if (etc_ld_so_conf.exists())
@@ -253,28 +259,28 @@ Configuration::load_from_etc_ld_so_conf(const FSEntry & root)
}
void
-Configuration::add_defaults()
+Implementation<Configuration>::add_defaults()
{
Context ctx("When adding default settings:");
- static const std::string ld_library_mask(
+ static const std::string default_ld_library_mask(
"libodbcinst.so libodbc.so libjava.so libjvm.so");
- static const std::string search_dirs(
+ static const std::string default_search_dirs(
"/bin /sbin /usr/bin /usr/sbin /lib* /usr/lib*");
- static const std::string search_dirs_mask(
+ static const std::string default_search_dirs_mask(
"/opt/OpenOffice /usr/lib*/openoffice /lib*/modules");
- Log::get_instance()->message(ll_debug, lc_context, "Got LD_LIBRARY_MASK=\"" + ld_library_mask + "\"");
+ Log::get_instance()->message(ll_debug, lc_context, "Got LD_LIBRARY_MASK=\"" + default_ld_library_mask + "\"");
WhitespaceTokeniser::get_instance()->tokenise(
- ld_library_mask, std::back_inserter(_imp->ld_library_mask));
+ default_ld_library_mask, std::back_inserter(ld_library_mask));
- Log::get_instance()->message(ll_debug, lc_context, "Got SEARCH_DIRS=\"" + search_dirs + "\"");
+ Log::get_instance()->message(ll_debug, lc_context, "Got SEARCH_DIRS=\"" + default_search_dirs + "\"");
WhitespaceTokeniser::get_instance()->tokenise(
- search_dirs, std::back_inserter(_imp->search_dirs));
+ default_search_dirs, std::back_inserter(search_dirs));
- Log::get_instance()->message(ll_debug, lc_context, "Got SEARCH_DIRS_MASK=\"" + search_dirs_mask + "\"");
+ Log::get_instance()->message(ll_debug, lc_context, "Got SEARCH_DIRS_MASK=\"" + default_search_dirs_mask + "\"");
WhitespaceTokeniser::get_instance()->tokenise(
- search_dirs_mask, std::back_inserter(_imp->search_dirs_mask));
+ default_search_dirs_mask, std::back_inserter(search_dirs_mask));
}
Configuration::DirsIterator
diff --git a/src/clients/reconcilio/broken_linkage_finder/configuration.hh b/src/clients/reconcilio/broken_linkage_finder/configuration.hh
index 2039f03..d876787 100644
--- a/src/clients/reconcilio/broken_linkage_finder/configuration.hh
+++ b/src/clients/reconcilio/broken_linkage_finder/configuration.hh
@@ -45,13 +45,6 @@ namespace broken_linkage_finder
bool dir_is_masked(const paludis::FSEntry &) const PALUDIS_ATTRIBUTE((warn_unused_result));
bool lib_is_masked(const std::string &) const PALUDIS_ATTRIBUTE((warn_unused_result));
-
- private:
- void load_from_environment();
- void load_from_etc_revdep_rebuild(const paludis::FSEntry &);
- void load_from_etc_profile_env(const paludis::FSEntry &);
- void load_from_etc_ld_so_conf(const paludis::FSEntry &);
- void add_defaults();
};
}
diff --git a/src/clients/reconcilio/broken_linkage_finder/elf_linkage_checker.cc b/src/clients/reconcilio/broken_linkage_finder/elf_linkage_checker.cc
index a812936..863445c 100644
--- a/src/clients/reconcilio/broken_linkage_finder/elf_linkage_checker.cc
+++ b/src/clients/reconcilio/broken_linkage_finder/elf_linkage_checker.cc
@@ -42,12 +42,10 @@
#include <set>
#include <vector>
-#define tr1 paludis::tr1 // XXX
-
using namespace paludis;
using namespace broken_linkage_finder;
-namespace broken_linkage_finder
+namespace
{
struct ElfArchitecture
{
@@ -116,6 +114,9 @@ namespace paludis
std::map<ElfArchitecture, std::vector<std::string> > libraries;
Needed needed;
+ template <typename> bool check_elf(const FSEntry &, std::ifstream &);
+ void handle_library(const FSEntry &, const ElfArchitecture &);
+
Implementation(const std::string & the_library) :
library(the_library)
{
@@ -145,12 +146,12 @@ ElfLinkageChecker::check_file(const FSEntry & file)
if (! stream)
throw FSError("Error opening file '" + stringify(file) + "': " + strerror(errno));
- return check_elf<Elf32Type>(file, stream) || check_elf<Elf64Type>(file, stream);
+ return _imp->check_elf<Elf32Type>(file, stream) || _imp->check_elf<Elf64Type>(file, stream);
}
template <typename ElfType_>
bool
-ElfLinkageChecker::check_elf(const FSEntry & file, std::ifstream & stream)
+Implementation<ElfLinkageChecker>::check_elf(const FSEntry & file, std::ifstream & stream)
{
if (! ElfObject<ElfType_>::is_valid_elf(stream))
return false;
@@ -169,9 +170,9 @@ ElfLinkageChecker::check_elf(const FSEntry & file, std::ifstream & stream)
ElfArchitecture arch(elf);
elf.resolve_all_strings();
- Lock l(_imp->mutex);
+ Lock l(mutex);
- if (_imp->library.empty() && ET_DYN == elf.get_type())
+ if (library.empty() && ET_DYN == elf.get_type())
handle_library(file, arch);
for (typename ElfObject<ElfType_>::SectionIterator sec_it(elf.section_begin()),
@@ -188,10 +189,10 @@ ElfLinkageChecker::check_elf(const FSEntry & file, std::ifstream & stream)
if (0 != ent_str && "NEEDED" == ent_str->tag_name())
{
const std::string & req((*ent_str)());
- if (_imp->library.empty() || _imp->library == req)
+ if (library.empty() || library == req)
{
Log::get_instance()->message(ll_debug, lc_context, "File depends on " + req);
- _imp->needed[arch][req].push_back(file);
+ needed[arch][req].push_back(file);
}
}
}
@@ -206,11 +207,11 @@ ElfLinkageChecker::check_elf(const FSEntry & file, std::ifstream & stream)
}
void
-ElfLinkageChecker::handle_library(const FSEntry & file, const ElfArchitecture & arch)
+Implementation<ElfLinkageChecker>::handle_library(const FSEntry & file, const ElfArchitecture & arch)
{
- _imp->seen.insert(std::make_pair(file, arch));
- std::pair<Symlinks::const_iterator, Symlinks::const_iterator> range(_imp->symlinks.equal_range(file));
- _imp->libraries[arch].push_back(file.basename());
+ seen.insert(std::make_pair(file, arch));
+ std::pair<Symlinks::const_iterator, Symlinks::const_iterator> range(symlinks.equal_range(file));
+ libraries[arch].push_back(file.basename());
if (range.first != range.second)
{
@@ -218,7 +219,7 @@ ElfLinkageChecker::handle_library(const FSEntry & file, const ElfArchitecture &
ll_debug, lc_context, "Known symlinks are " +
join(second_iterator(range.first), second_iterator(range.second), " "));
std::transform(second_iterator(range.first), second_iterator(range.second),
- std::back_inserter(_imp->libraries[arch]), tr1::mem_fn(&FSEntry::basename));
+ std::back_inserter(libraries[arch]), tr1::mem_fn(&FSEntry::basename));
}
}
diff --git a/src/clients/reconcilio/broken_linkage_finder/elf_linkage_checker.hh b/src/clients/reconcilio/broken_linkage_finder/elf_linkage_checker.hh
index ba79cc2..22d5a93 100644
--- a/src/clients/reconcilio/broken_linkage_finder/elf_linkage_checker.hh
+++ b/src/clients/reconcilio/broken_linkage_finder/elf_linkage_checker.hh
@@ -29,8 +29,6 @@
namespace broken_linkage_finder
{
- class ElfArchitecture;
-
class ElfLinkageChecker :
public LinkageChecker,
private paludis::PrivateImplementationPattern<ElfLinkageChecker>
@@ -44,10 +42,6 @@ namespace broken_linkage_finder
virtual void need_breakage_added(
const paludis::tr1::function<void (const paludis::FSEntry &, const std::string &)> &);
-
- private:
- template <typename> bool check_elf(const paludis::FSEntry &, std::ifstream &);
- void handle_library(const paludis::FSEntry &, const ElfArchitecture &);
};
}