aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-12-24 16:17:13 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-12-24 16:17:13 +0000
commitc1e7676ecf2018847646b1e34c2198e099fb8fcf (patch)
tree4d55e12e13e24834def34283f1b2196eb8b581fa
parentd06f14a79104f509aabb31c51658d8051083fc19 (diff)
downloadpaludis-c1e7676ecf2018847646b1e34c2198e099fb8fcf.tar.gz
paludis-c1e7676ecf2018847646b1e34c2198e099fb8fcf.tar.xz
Add --show-use-descriptions option for --install
-rw-r--r--src/Makefile.am10
-rw-r--r--src/console_install_task.cc152
-rw-r--r--src/console_install_task.hh31
-rw-r--r--src/console_install_task.sr15
-rw-r--r--src/contrarius/install.cc20
-rw-r--r--src/paludis/command_line.cc7
-rw-r--r--src/paludis/command_line.hh3
-rw-r--r--src/paludis/install.cc23
-rw-r--r--src/use_flag_pretty_printer.cc44
-rw-r--r--src/use_flag_pretty_printer.hh8
10 files changed, 305 insertions, 8 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 0bdbad1..1bdf792 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,7 +1,10 @@
SUBDIRS = . paludis gtkpaludis qualudis adjutrix contrarius
CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda
+DISTCLEANFILES = console_install_task-sr.hh console_install_task-sr.cc
MAINTAINERCLEANFILES = Makefile.in
+EXTRA_DIST = console_install_task.sr console_install_task-sr.hh console_install_task-sr.cc
+BUILT_SOURCES = console_install_task-sr.hh console_install_task-sr.cc
noinst_LIBRARIES = liboutput.a
liboutput_a_SOURCES = \
@@ -15,3 +18,10 @@ AM_CXXFLAGS = -I$(top_srcdir) -I$(top_srcdir)/src @PALUDIS_CXXFLAGS@
built-sources : $(BUILT_SOURCES)
for s in `echo $(SUBDIRS) | tr -d .` ; do $(MAKE) -C $$s built-sources || exit 1 ; done
+console_install_task-sr.hh : console_install_task.sr $(top_srcdir)/misc/make_sr.bash
+ $(top_srcdir)/misc/make_sr.bash --header $(srcdir)/console_install_task.sr > $@
+
+console_install_task-sr.cc : console_install_task.sr $(top_srcdir)/misc/make_sr.bash
+ $(top_srcdir)/misc/make_sr.bash --source $(srcdir)/console_install_task.sr > $@
+
+
diff --git a/src/console_install_task.cc b/src/console_install_task.cc
index 20858e8..1d5bc7c 100644
--- a/src/console_install_task.cc
+++ b/src/console_install_task.cc
@@ -23,17 +23,23 @@
#include <paludis/util/log.hh>
#include <paludis/util/collection_concrete.hh>
+#include <paludis/util/compare.hh>
+#include <paludis/util/sr.hh>
#include <algorithm>
#include <set>
#include <iostream>
+#include <iomanip>
using namespace paludis;
+#include <src/console_install_task-sr.cc>
+
ConsoleInstallTask::ConsoleInstallTask(Environment * const env,
const DepListOptions & options) :
InstallTask(env, options),
- _all_tags(new SortedCollection<DepTagEntry>::Concrete)
+ _all_tags(new SortedCollection<DepTagEntry>::Concrete),
+ _all_use_descriptions(new SortedCollection<UseDescription>::Concrete)
{
std::fill_n(_counts, static_cast<int>(last_count), 0);
}
@@ -114,6 +120,7 @@ ConsoleInstallTask::on_display_merge_list_post()
output_endl();
display_merge_list_post_counts();
display_merge_list_post_tags();
+ display_merge_list_post_use_descriptions();
}
void
@@ -339,6 +346,110 @@ ConsoleInstallTask::display_merge_list_post_tags()
}
void
+ConsoleInstallTask::display_merge_list_post_use_descriptions()
+{
+ if (! want_use_summary())
+ return;
+
+ bool started(false);
+ UseFlagName old_flag("OFTEN_NOT_BEEN_ON_BOATS");
+
+ SortedCollection<UseDescription>::Pointer group(new SortedCollection<UseDescription>::Concrete);
+ for (SortedCollection<UseDescription>::Iterator i(all_use_descriptions()->begin()),
+ i_end(all_use_descriptions()->end()) ; i != i_end ; ++i)
+ {
+ switch (i->state)
+ {
+ case uds_new:
+ if (! want_new_use_flags())
+ continue;
+ break;
+
+ case uds_unchanged:
+ if (! want_unchanged_use_flags())
+ continue;
+ break;
+
+ case uds_changed:
+ if (! want_changed_use_flags())
+ continue;
+ break;
+ }
+
+ if (! started)
+ {
+ display_use_summary_start();
+ started = true;
+ }
+
+ if (old_flag != i->flag)
+ {
+ if (! group->empty())
+ display_use_summary_flag(group->begin(), group->end());
+ old_flag = i->flag;
+ group.assign(new SortedCollection<UseDescription>::Concrete);
+ }
+
+ group->insert(*i);
+ }
+
+ if (! group->empty())
+ display_use_summary_flag(group->begin(), group->end());
+
+ if (started)
+ display_use_summary_end();
+}
+
+void
+ConsoleInstallTask::display_use_summary_start()
+{
+ output_heading("Use flags:");
+}
+
+void
+ConsoleInstallTask::display_use_summary_flag(SortedCollection<UseDescription>::Iterator i,
+ SortedCollection<UseDescription>::Iterator i_end)
+{
+ if (next(i) == i_end)
+ {
+ std::ostringstream s;
+ s << std::left << std::setw(30) << (render_as_tag(stringify(i->flag)) + ": ");
+ s << i->description;
+ output_starred_item(s.str());
+ }
+ else
+ {
+ bool all_same(true);
+ for (SortedCollection<UseDescription>::Iterator j(next(i)) ; all_same && j != i_end ; ++j)
+ if (j->description != i->description)
+ all_same = false;
+
+ if (all_same)
+ {
+ std::ostringstream s;
+ s << std::left << std::setw(30) << (render_as_tag(stringify(i->flag)) + ": ");
+ s << i->description;
+ output_starred_item(s.str());
+ }
+ else
+ {
+ output_starred_item(render_as_tag(stringify(i->flag)) + ":");
+ for ( ; i != i_end ; ++i)
+ {
+ std::ostringstream s;
+ s << i->description << " (for " << render_as_package_name(stringify(i->package)) << ")";
+ output_starred_item(s.str(), 1);
+ }
+ }
+ }
+}
+
+void
+ConsoleInstallTask::display_use_summary_end()
+{
+}
+
+void
ConsoleInstallTask::display_tag_summary_start()
{
}
@@ -402,11 +513,11 @@ DepTagSummaryDisplayer::visit(const GeneralSetDepTag * const tag)
{
std::string desc;
if (tag->short_text() == "world")
- desc = ": Packages that have been explicitly installed";
+ desc = ": Packages that have been explicitly installed";
else if (tag->short_text() == "everything")
- desc = ": All installed packages";
+ desc = ": All installed packages";
else if (tag->short_text() == "system")
- desc = ": Packages that are part of the base system";
+ desc = ": Packages that are part of the base system";
task()->output_starred_item(task()->render_as_tag(tag->short_text()) + desc);
}
@@ -492,6 +603,28 @@ ConsoleInstallTask::display_merge_list_entry_status_and_update_counts(const DepL
}
void
+ConsoleInstallTask::_add_descriptions(UseFlagNameCollection::ConstPointer c,
+ const PackageDatabaseEntry & p, UseDescriptionState s)
+{
+ for (UseFlagNameCollection::Iterator f(c->begin()), f_end(c->end()) ;
+ f != f_end ; ++f)
+ {
+ std::string d;
+ const RepositoryUseInterface * const i(environment()->package_database()->
+ fetch_repository(p.repository)->use_interface);
+
+ if (i)
+ d = i->describe_use_flag(*f, &p);
+
+ _all_use_descriptions->insert(UseDescription::create()
+ .flag(*f)
+ .state(s)
+ .package(p)
+ .description(d));
+ }
+}
+
+void
ConsoleInstallTask::display_merge_list_entry_use(const DepListEntry & d,
PackageDatabaseEntryCollection::ConstPointer existing,
PackageDatabaseEntryCollection::ConstPointer)
@@ -502,6 +635,10 @@ ConsoleInstallTask::display_merge_list_entry_use(const DepListEntry & d,
output_no_endl(" ");
UseFlagPrettyPrinter::Pointer printer(make_use_flag_pretty_printer());
printer->print_package_flags(d.package, existing->empty() ? 0 : &*existing->last());
+
+ _add_descriptions(printer->new_flags(), d.package, uds_new);
+ _add_descriptions(printer->changed_flags(), d.package, uds_changed);
+ _add_descriptions(printer->unchanged_flags(), d.package, uds_unchanged);
}
void
@@ -603,9 +740,12 @@ ConsoleInstallTask::output_xterm_title(const std::string & s) const
}
void
-ConsoleInstallTask::output_starred_item(const std::string & s) const
+ConsoleInstallTask::output_starred_item(const std::string & s, const unsigned indent) const
{
- output_stream() << "* " << s << std::endl;
+ if (0 != indent)
+ output_stream() << std::string(2 * indent, ' ') << "* " << s << std::endl;
+ else
+ output_stream() << "* " << s << std::endl;
}
void
diff --git a/src/console_install_task.hh b/src/console_install_task.hh
index 64682df..8ce3ff1 100644
--- a/src/console_install_task.hh
+++ b/src/console_install_task.hh
@@ -29,6 +29,15 @@ namespace paludis
{
class ConsoleInstallTask;
+ enum UseDescriptionState
+ {
+ uds_unchanged,
+ uds_changed,
+ uds_new
+ };
+
+#include <src/console_install_task-sr.hh>
+
class PALUDIS_VISIBLE DepTagSummaryDisplayer :
public DepTagVisitorTypes::ConstVisitor,
public InternalCounted<DepTagSummaryDisplayer>
@@ -90,6 +99,10 @@ namespace paludis
private:
int _counts[last_count];
SortedCollection<DepTagEntry>::Pointer _all_tags;
+ SortedCollection<UseDescription>::Pointer _all_use_descriptions;
+
+ void _add_descriptions(UseFlagNameCollection::ConstPointer,
+ const PackageDatabaseEntry &, UseDescriptionState);
protected:
ConsoleInstallTask(Environment * const env, const DepListOptions & options);
@@ -141,7 +154,7 @@ namespace paludis
virtual void output_activity_end_message() const;
virtual void output_heading(const std::string &) const;
virtual void output_xterm_title(const std::string &) const;
- virtual void output_starred_item(const std::string &) const;
+ virtual void output_starred_item(const std::string &, const unsigned indent = 0) const;
virtual void output_starred_item_no_endl(const std::string &) const;
virtual void output_unstarred_item(const std::string &) const;
virtual void output_no_endl(const std::string &) const;
@@ -195,6 +208,12 @@ namespace paludis
virtual void display_tag_summary_tag_post_text(const DepTagCategory &);
virtual void display_tag_summary_end();
+ virtual void display_merge_list_post_use_descriptions();
+ virtual void display_use_summary_start();
+ virtual void display_use_summary_flag(SortedCollection<UseDescription>::Iterator,
+ SortedCollection<UseDescription>::Iterator);
+ virtual void display_use_summary_end();
+
///\}
///\name Data
@@ -217,6 +236,11 @@ namespace paludis
return _all_tags;
}
+ SortedCollection<UseDescription>::Pointer all_use_descriptions()
+ {
+ return _all_use_descriptions;
+ }
+
///\}
///\name Options
@@ -226,6 +250,11 @@ namespace paludis
virtual bool want_install_reasons() const = 0;
virtual bool want_tags_summary() const = 0;
+ virtual bool want_use_summary() const = 0;
+ virtual bool want_unchanged_use_flags() const = 0;
+ virtual bool want_changed_use_flags() const = 0;
+ virtual bool want_new_use_flags() const = 0;
+
///\}
///\name Makers
diff --git a/src/console_install_task.sr b/src/console_install_task.sr
new file mode 100644
index 0000000..433aef2
--- /dev/null
+++ b/src/console_install_task.sr
@@ -0,0 +1,15 @@
+#!/bin/bash
+# vim: set sw=4 sts=4 et :
+
+make_class_UseDescription()
+{
+ key flag UseFlagName
+ key package PackageDatabaseEntry
+ key state UseDescriptionState
+ key description std::string
+
+ comparison_operators all flag package
+
+ allow_named_args
+}
+
diff --git a/src/contrarius/install.cc b/src/contrarius/install.cc
index 4daaeff..c916ceb 100644
--- a/src/contrarius/install.cc
+++ b/src/contrarius/install.cc
@@ -72,6 +72,26 @@ namespace
return "full" == CommandLine::get_instance()->a_show_install_reasons.argument() ||
"summary" == CommandLine::get_instance()->a_show_install_reasons.argument();
}
+
+ virtual bool want_unchanged_use_flags() const
+ {
+ return false;
+ }
+
+ virtual bool want_changed_use_flags() const
+ {
+ return false;
+ }
+
+ virtual bool want_new_use_flags() const
+ {
+ return false;
+ }
+
+ virtual bool want_use_summary() const
+ {
+ return false;
+ }
};
void show_resume_command(const InstallTask & task)
diff --git a/src/paludis/command_line.cc b/src/paludis/command_line.cc
index f058571..fb6f383 100644
--- a/src/paludis/command_line.cc
+++ b/src/paludis/command_line.cc
@@ -95,6 +95,13 @@ CommandLine::CommandLine() :
("summary", "Show a summary")
("full", "Show full output (can be very verbose)"),
"none"),
+ a_show_use_descriptions(&install_args, "show-use-descriptions", '\0', "Show descriptions of USE flags",
+ paludis::args::EnumArg::EnumArgOptions
+ ("none", "Don't show any descriptions")
+ ("new", "Show for new use flags")
+ ("changed", "Show for new and changed flags")
+ ("all", "Show for all flags"),
+ "none"),
a_with_unused_dependencies(&install_args, "with-unused-dependencies", '\0',
"Also uninstall any dependencies of the target that are no longer used"),
a_with_dependencies(&install_args, "with-dependencies", '\0',
diff --git a/src/paludis/command_line.hh b/src/paludis/command_line.hh
index a60abc9..f2cddac 100644
--- a/src/paludis/command_line.hh
+++ b/src/paludis/command_line.hh
@@ -200,6 +200,9 @@ class CommandLine :
/// --show-install-reasons
paludis::args::EnumArg a_show_install_reasons;
+ /// --show-use-descriptions
+ paludis::args::EnumArg a_show_use_descriptions;
+
/// --with-unused-dependencies
paludis::args::SwitchArg a_with_unused_dependencies;
diff --git a/src/paludis/install.cc b/src/paludis/install.cc
index da80594..e685f05 100644
--- a/src/paludis/install.cc
+++ b/src/paludis/install.cc
@@ -74,6 +74,29 @@ namespace
return "full" == CommandLine::get_instance()->a_show_install_reasons.argument() ||
"summary" == CommandLine::get_instance()->a_show_install_reasons.argument();
}
+
+ virtual bool want_unchanged_use_flags() const
+ {
+ return "none" != CommandLine::get_instance()->a_show_use_descriptions.argument() &&
+ "new" != CommandLine::get_instance()->a_show_use_descriptions.argument() &&
+ "changed" != CommandLine::get_instance()->a_show_use_descriptions.argument();
+ }
+
+ virtual bool want_changed_use_flags() const
+ {
+ return "none" != CommandLine::get_instance()->a_show_use_descriptions.argument() &&
+ "new" != CommandLine::get_instance()->a_show_use_descriptions.argument();
+ }
+
+ virtual bool want_new_use_flags() const
+ {
+ return "none" != CommandLine::get_instance()->a_show_use_descriptions.argument();
+ }
+
+ virtual bool want_use_summary() const
+ {
+ return "none" != CommandLine::get_instance()->a_show_use_descriptions.argument();
+ }
};
void show_resume_command(const InstallTask & task)
diff --git a/src/use_flag_pretty_printer.cc b/src/use_flag_pretty_printer.cc
index f1db730..afb5df3 100644
--- a/src/use_flag_pretty_printer.cc
+++ b/src/use_flag_pretty_printer.cc
@@ -21,6 +21,7 @@
#include <paludis/version_metadata.hh>
#include <paludis/environment.hh>
#include <paludis/util/tokeniser.hh>
+#include <paludis/util/collection_concrete.hh>
#include "colour.hh"
#include <iostream>
#include <set>
@@ -29,7 +30,10 @@ using namespace paludis;
UseFlagPrettyPrinter::UseFlagPrettyPrinter(const Environment * const e) :
_env(e),
- _need_space(false)
+ _need_space(false),
+ _new_flags(new UseFlagNameCollection::Concrete),
+ _changed_flags(new UseFlagNameCollection::Concrete),
+ _unchanged_flags(new UseFlagNameCollection::Concrete)
{
}
@@ -102,11 +106,21 @@ UseFlagPrettyPrinter::print_package_flags(const PackageDatabaseEntry & pkg,
if (old_iuse.end() != old_iuse.find(*flag))
{
if (environment()->query_use(*flag, &pkg) != environment()->query_use(*flag, old_pkg))
+ {
+ _changed_flags->insert(*flag);
output_flag_changed_mark();
+ }
+ else
+ _unchanged_flags->insert(*flag);
}
else
+ {
+ _new_flags->insert(*flag);
output_flag_is_new_mark();
+ }
}
+ else
+ _new_flags->insert(*flag);
}
/* second pass: only expand flags */
@@ -153,11 +167,21 @@ UseFlagPrettyPrinter::print_package_flags(const PackageDatabaseEntry & pkg,
if (old_iuse.end() != old_iuse.find(*flag))
{
if (environment()->query_use(*flag, &pkg) != environment()->query_use(*flag, old_pkg))
+ {
+ _changed_flags->insert(*flag);
output_flag_changed_mark();
+ }
+ else
+ _unchanged_flags->insert(*flag);
}
else
+ {
+ _new_flags->insert(*flag);
output_flag_is_new_mark();
+ }
}
+ else
+ _new_flags->insert(*flag);
}
}
@@ -237,3 +261,21 @@ UseFlagPrettyPrinter::environment() const
return _env;
}
+UseFlagNameCollection::ConstPointer
+UseFlagPrettyPrinter::new_flags() const
+{
+ return _new_flags;
+}
+
+UseFlagNameCollection::ConstPointer
+UseFlagPrettyPrinter::changed_flags() const
+{
+ return _changed_flags;
+}
+
+UseFlagNameCollection::ConstPointer
+UseFlagPrettyPrinter::unchanged_flags() const
+{
+ return _unchanged_flags;
+}
+
diff --git a/src/use_flag_pretty_printer.hh b/src/use_flag_pretty_printer.hh
index f802b7f..ab6472a 100644
--- a/src/use_flag_pretty_printer.hh
+++ b/src/use_flag_pretty_printer.hh
@@ -36,6 +36,10 @@ namespace paludis
const Environment * const _env;
bool _need_space;
+ UseFlagNameCollection::Pointer _new_flags;
+ UseFlagNameCollection::Pointer _changed_flags;
+ UseFlagNameCollection::Pointer _unchanged_flags;
+
protected:
std::string::size_type use_expand_delim_pos(const UseFlagName & u,
const UseFlagNameCollection::ConstPointer c) const;
@@ -61,6 +65,10 @@ namespace paludis
const Environment * environment() const;
bool need_space() const;
+
+ UseFlagNameCollection::ConstPointer new_flags() const;
+ UseFlagNameCollection::ConstPointer changed_flags() const;
+ UseFlagNameCollection::ConstPointer unchanged_flags() const;
};
}