aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-03-31 19:16:19 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-03-31 19:16:19 +0100
commit90f88326dbc6d58e2a8e97d8d2ba06dbe60df083 (patch)
tree40ad7ff3b5d228a9e7380e831c752ec05862e4a5
parentf07f179e9bc57b1af665563f6554c55de3b8d893 (diff)
downloadpaludis-90f88326dbc6d58e2a8e97d8d2ba06dbe60df083.tar.gz
paludis-90f88326dbc6d58e2a8e97d8d2ba06dbe60df083.tar.xz
Notifiers for linkage steps
Fixes: ticket:867
-rw-r--r--paludis/broken_linkage_finder.cc5
-rw-r--r--paludis/notifier_callback-fwd.hh3
-rw-r--r--paludis/notifier_callback.cc13
-rw-r--r--paludis/notifier_callback.hh19
-rw-r--r--src/clients/cave/cmd_fix_linkage.cc41
-rw-r--r--src/clients/cave/cmd_resolve_display_callback.cc24
-rw-r--r--src/clients/cave/cmd_resolve_display_callback.hh6
-rw-r--r--src/clients/cave/cmd_search.cc4
-rw-r--r--src/clients/cave/resolve_common.cc2
-rw-r--r--src/clients/inquisitio/do_search.cc6
-rw-r--r--src/output/console_install_task.cc4
11 files changed, 94 insertions, 33 deletions
diff --git a/paludis/broken_linkage_finder.cc b/paludis/broken_linkage_finder.cc
index 613efc0..6026ed8 100644
--- a/paludis/broken_linkage_finder.cc
+++ b/paludis/broken_linkage_finder.cc
@@ -45,6 +45,7 @@
#include <paludis/filter.hh>
#include <paludis/filtered_generator.hh>
#include <paludis/selection.hh>
+#include <paludis/notifier_callback.hh>
#include <tr1/functional>
#include <algorithm>
@@ -197,6 +198,8 @@ void
Implementation<BrokenLinkageFinder>::search_directory(const FSEntry & directory)
{
FSEntry dir(directory);
+ env->trigger_notifier_callback(NotifierCallbackLinkageStepEvent(dir));
+
do
{
dir = dir.dirname();
@@ -270,6 +273,8 @@ Implementation<BrokenLinkageFinder>::check_file(const FSEntry & file)
else if (file.is_regular_file())
{
+ env->trigger_notifier_callback(NotifierCallbackLinkageStepEvent(file));
+
if (indirect_iterator(checkers.end()) ==
std::find_if(indirect_iterator(checkers.begin()), indirect_iterator(checkers.end()),
std::tr1::bind(&LinkageChecker::check_file, _1, file)))
diff --git a/paludis/notifier_callback-fwd.hh b/paludis/notifier_callback-fwd.hh
index dd97d83..0a9194a 100644
--- a/paludis/notifier_callback-fwd.hh
+++ b/paludis/notifier_callback-fwd.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2008, 2009, 2010 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
@@ -28,6 +28,7 @@ namespace paludis
struct NotifierCallbackGeneratingMetadataEvent;
struct NotifierCallbackResolverStepEvent;
struct NotifierCallbackResolverStageEvent;
+ struct NotifierCallbackLinkageStepEvent;
typedef std::tr1::function<void (const NotifierCallbackEvent &) > NotifierCallbackFunction;
diff --git a/paludis/notifier_callback.cc b/paludis/notifier_callback.cc
index 4ebc466..888eafb 100644
--- a/paludis/notifier_callback.cc
+++ b/paludis/notifier_callback.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 2010 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
@@ -46,6 +46,17 @@ NotifierCallbackResolverStageEvent::stage() const
return _stage;
}
+NotifierCallbackLinkageStepEvent::NotifierCallbackLinkageStepEvent(const FSEntry & r) :
+ _location(r)
+{
+}
+
+const FSEntry
+NotifierCallbackLinkageStepEvent::location() const
+{
+ return _location;
+}
+
namespace paludis
{
template <>
diff --git a/paludis/notifier_callback.hh b/paludis/notifier_callback.hh
index 2a28e90..83d30fb 100644
--- a/paludis/notifier_callback.hh
+++ b/paludis/notifier_callback.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 2010 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
@@ -24,6 +24,7 @@
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/simple_visitor.hh>
#include <paludis/util/type_list.hh>
+#include <paludis/util/fs_entry.hh>
#include <paludis/name.hh>
#include <paludis/environment-fwd.hh>
@@ -33,7 +34,8 @@ namespace paludis
public virtual DeclareAbstractAcceptMethods<NotifierCallbackEvent, MakeTypeList<
NotifierCallbackGeneratingMetadataEvent,
NotifierCallbackResolverStepEvent,
- NotifierCallbackResolverStageEvent>::Type>
+ NotifierCallbackResolverStageEvent,
+ NotifierCallbackLinkageStepEvent>::Type>
{
};
@@ -69,6 +71,19 @@ namespace paludis
const std::string stage() const PALUDIS_ATTRIBUTE((warn_unused_result));
};
+ class PALUDIS_VISIBLE NotifierCallbackLinkageStepEvent :
+ public NotifierCallbackEvent,
+ public ImplementAcceptMethods<NotifierCallbackEvent, NotifierCallbackLinkageStepEvent>
+ {
+ private:
+ const FSEntry _location;
+
+ public:
+ NotifierCallbackLinkageStepEvent(const FSEntry &);
+
+ const FSEntry location() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
class PALUDIS_VISIBLE ScopedNotifierCallback :
private PrivateImplementationPattern<ScopedNotifierCallback>
{
diff --git a/src/clients/cave/cmd_fix_linkage.cc b/src/clients/cave/cmd_fix_linkage.cc
index 3969254..18f1171 100644
--- a/src/clients/cave/cmd_fix_linkage.cc
+++ b/src/clients/cave/cmd_fix_linkage.cc
@@ -19,6 +19,7 @@
#include "cmd_fix_linkage.hh"
#include "cmd_resolve_cmdline.hh"
+#include "cmd_resolve_display_callback.hh"
#include "resolve_common.hh"
#include <paludis/args/do_help.hh>
@@ -32,6 +33,7 @@
#include <paludis/dep_spec.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/metadata_key.hh>
+#include <paludis/notifier_callback.hh>
#include <paludis/version_operator.hh>
#include <paludis/version_requirements.hh>
@@ -158,16 +160,15 @@ FixLinkageCommand::run(
resolve_cmdline.resolution_options.a_execute.set_specified(true);
std::string library(cmdline.a_library.argument());
- if (library.empty())
- cout << "Searching for broken packages... " << std::flush;
- else
- cout << "Searching for packages that depend on " << library << "... " << std::flush;
-
- BrokenLinkageFinder finder(env.get(), cmdline.a_library.argument());
-
- cout << endl;
+ std::tr1::shared_ptr<BrokenLinkageFinder> finder;
+ {
+ DisplayCallback display_callback("Searching: ");
+ ScopedNotifierCallback display_callback_holder(env.get(),
+ NotifierCallbackFunction(std::tr1::cref(display_callback)));
+ finder.reset(new BrokenLinkageFinder(env.get(), cmdline.a_library.argument()));
+ }
- if (finder.begin_broken_packages() == finder.end_broken_packages())
+ if (finder->begin_broken_packages() == finder->end_broken_packages())
{
if (library.empty())
cout << "No broken packages found" << endl;
@@ -179,21 +180,21 @@ FixLinkageCommand::run(
std::tr1::shared_ptr<Sequence<std::string> > targets(new Sequence<std::string>);
- for (BrokenLinkageFinder::BrokenPackageConstIterator pkg_it(finder.begin_broken_packages()),
- pkg_it_end(finder.end_broken_packages()); pkg_it_end != pkg_it; ++pkg_it)
+ for (BrokenLinkageFinder::BrokenPackageConstIterator pkg_it(finder->begin_broken_packages()),
+ pkg_it_end(finder->end_broken_packages()); pkg_it_end != pkg_it; ++pkg_it)
{
cout << endl;
cout << "* " << **pkg_it << endl;
- for (BrokenLinkageFinder::BrokenFileConstIterator file_it(finder.begin_broken_files(*pkg_it)),
- file_it_end(finder.end_broken_files(*pkg_it)); file_it_end != file_it; ++file_it)
+ for (BrokenLinkageFinder::BrokenFileConstIterator file_it(finder->begin_broken_files(*pkg_it)),
+ file_it_end(finder->end_broken_files(*pkg_it)); file_it_end != file_it; ++file_it)
{
cout << " " << *file_it;
if (library.empty())
cout << " (requires "
- << join(finder.begin_missing_requirements(*pkg_it, *file_it),
- finder.end_missing_requirements(*pkg_it, *file_it),
+ << join(finder->begin_missing_requirements(*pkg_it, *file_it),
+ finder->end_missing_requirements(*pkg_it, *file_it),
" ") << ")";
cout << endl;
}
@@ -212,21 +213,21 @@ FixLinkageCommand::run(
}
std::tr1::shared_ptr<const PackageID> orphans;
- if (finder.begin_broken_files(orphans) != finder.end_broken_files(orphans))
+ if (finder->begin_broken_files(orphans) != finder->end_broken_files(orphans))
{
if (library.empty())
cout << endl << "The following broken files are not owned by any installed package:" << endl;
else
cout << endl << "The following files that depend on " << library << " are not owned by any installed package:" << endl;
- for (BrokenLinkageFinder::BrokenFileConstIterator file_it(finder.begin_broken_files(orphans)),
- file_it_end(finder.end_broken_files(orphans)); file_it_end != file_it; ++file_it)
+ for (BrokenLinkageFinder::BrokenFileConstIterator file_it(finder->begin_broken_files(orphans)),
+ file_it_end(finder->end_broken_files(orphans)); file_it_end != file_it; ++file_it)
{
cout << " " << *file_it;
if (library.empty())
cout << " (requires "
- << join(finder.begin_missing_requirements(orphans, *file_it),
- finder.end_missing_requirements(orphans, *file_it),
+ << join(finder->begin_missing_requirements(orphans, *file_it),
+ finder->end_missing_requirements(orphans, *file_it),
" ") << ")";
cout << endl;
}
diff --git a/src/clients/cave/cmd_resolve_display_callback.cc b/src/clients/cave/cmd_resolve_display_callback.cc
index a49f8ee..697d927 100644
--- a/src/clients/cave/cmd_resolve_display_callback.cc
+++ b/src/clients/cave/cmd_resolve_display_callback.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 2010 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
@@ -40,8 +40,8 @@ namespace paludis
bool output;
- Implementation() :
- stage("Resolving: "),
+ Implementation(const std::string & s) :
+ stage(s),
width(stage.length()),
output(::isatty(1))
{
@@ -50,8 +50,8 @@ namespace paludis
}
-DisplayCallback::DisplayCallback() :
- PrivateImplementationPattern<DisplayCallback>(new Implementation<DisplayCallback>)
+DisplayCallback::DisplayCallback(const std::string & s) :
+ PrivateImplementationPattern<DisplayCallback>(new Implementation<DisplayCallback>(s))
{
if (_imp->output)
std::cout << _imp->stage << std::flush;
@@ -117,6 +117,20 @@ DisplayCallback::visit(const NotifierCallbackResolverStepEvent &) const
}
void
+DisplayCallback::visit(const NotifierCallbackLinkageStepEvent & e) const
+{
+ if (! _imp->output)
+ return;
+
+ Lock lock(_imp->mutex);
+ if (e.location().is_directory_or_symlink_to_directory())
+ ++_imp->steps.insert(std::make_pair("directories", 0)).first->second;
+ else
+ ++_imp->steps.insert(std::make_pair("files", 0)).first->second;
+ update();
+}
+
+void
DisplayCallback::update() const
{
if (! _imp->output)
diff --git a/src/clients/cave/cmd_resolve_display_callback.hh b/src/clients/cave/cmd_resolve_display_callback.hh
index e71b4ae..ecfa5ae 100644
--- a/src/clients/cave/cmd_resolve_display_callback.hh
+++ b/src/clients/cave/cmd_resolve_display_callback.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 2010 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
@@ -39,7 +39,7 @@ namespace paludis
void update() const;
public:
- DisplayCallback();
+ DisplayCallback(const std::string & initial_stage);
~DisplayCallback();
void operator() (const NotifierCallbackEvent & event) const;
@@ -51,6 +51,8 @@ namespace paludis
void visit(const NotifierCallbackResolverStepEvent &) const;
void visit(const NotifierCallbackResolverStageEvent &) const;
+
+ void visit(const NotifierCallbackLinkageStepEvent &) const;
};
}
}
diff --git a/src/clients/cave/cmd_search.cc b/src/clients/cave/cmd_search.cc
index 68da483..d12fdd9 100644
--- a/src/clients/cave/cmd_search.cc
+++ b/src/clients/cave/cmd_search.cc
@@ -233,6 +233,10 @@ namespace
void visit(const NotifierCallbackResolverStageEvent &) const
{
}
+
+ void visit(const NotifierCallbackLinkageStepEvent &) const
+ {
+ }
};
void step(DisplayCallback & display_callback, const std::string & s)
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 20e1d1f..29605a8 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -1588,7 +1588,7 @@ paludis::cave::resolve_common(
try
{
{
- DisplayCallback display_callback;
+ DisplayCallback display_callback("Resolving");
ScopedNotifierCallback display_callback_holder(env.get(),
NotifierCallbackFunction(std::tr1::cref(display_callback)));
diff --git a/src/clients/inquisitio/do_search.cc b/src/clients/inquisitio/do_search.cc
index 101ec13..3f17905 100644
--- a/src/clients/inquisitio/do_search.cc
+++ b/src/clients/inquisitio/do_search.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009, 2010 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
@@ -81,6 +81,10 @@ namespace
{
}
+ void visit(const NotifierCallbackLinkageStepEvent &) const
+ {
+ }
+
void visit(const NotifierCallbackResolverStepEvent &) const
{
Lock lock(mutex);
diff --git a/src/output/console_install_task.cc b/src/output/console_install_task.cc
index ce93409..e9dacaa 100644
--- a/src/output/console_install_task.cc
+++ b/src/output/console_install_task.cc
@@ -233,6 +233,10 @@ struct ConsoleInstallTask::CallbackDisplayer
{
}
+ void visit(const NotifierCallbackLinkageStepEvent &)
+ {
+ }
+
void update()
{
std::string s;