aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-08 14:26:40 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-08 14:26:40 +0000
commit12e32a6f768f35fcf3d82fdd512a2ce031038f84 (patch)
tree50e35dbd2f2186211f26b66af8d210d633eb27f5
parenta2c1a3146931b3a52d18f98e32c99278a1ab0382 (diff)
downloadpaludis-12e32a6f768f35fcf3d82fdd512a2ce031038f84.tar.gz
paludis-12e32a6f768f35fcf3d82fdd512a2ce031038f84.tar.xz
Add --show-install-reasons paludis option
-rw-r--r--paludis/dep_list.cc18
-rw-r--r--paludis/dep_list.sr2
-rw-r--r--paludis/dep_tag.cc52
-rw-r--r--paludis/dep_tag.hh40
-rw-r--r--paludis/tasks/install_task.cc3
-rw-r--r--src/colour.hh2
-rw-r--r--src/paludis/command_line.cc6
-rw-r--r--src/paludis/command_line.hh3
-rw-r--r--src/paludis/install.cc79
9 files changed, 190 insertions, 15 deletions
diff --git a/paludis/dep_list.cc b/paludis/dep_list.cc
index 661d38e..8b0c6ab 100644
--- a/paludis/dep_list.cc
+++ b/paludis/dep_list.cc
@@ -74,7 +74,8 @@ DepListOptions::DepListOptions() :
uninstalled_deps_pre(dl_deps_pre),
uninstalled_deps_runtime(dl_deps_pre_or_post),
uninstalled_deps_post(dl_deps_post),
- circular(dl_circular_error)
+ circular(dl_circular_error),
+ dependency_tags(false)
{
/* when changing the above, also see src/paludis/command_line.cc. */
}
@@ -370,6 +371,11 @@ DepList::AddVisitor::visit(const PackageDepAtom * const a)
.tag(a->tag())
.generation(d->_imp->merge_list_generation));
+ if (d->_imp->opts.dependency_tags && d->_imp->current_pde())
+ existing_merge_list_entry->tags->insert(DepTagEntry::create()
+ .tag(DepTag::Pointer(new DependencyDepTag(*d->_imp->current_pde())))
+ .generation(d->_imp->merge_list_generation));
+
/* have our deps been merged already, or is this a circular dep? */
if (dle_no_deps == existing_merge_list_entry->state)
{
@@ -612,6 +618,11 @@ DepList::add_package(const PackageDatabaseEntry & p, DepTag::ConstPointer tag)
.generation(_imp->merge_list_generation)
.tag(tag));
+ if (_imp->opts.dependency_tags && _imp->current_pde())
+ our_merge_entry_position->tags->insert(DepTagEntry::create()
+ .tag(DepTag::Pointer(new DependencyDepTag(*_imp->current_pde())))
+ .generation(_imp->merge_list_generation));
+
Save<MergeList::const_iterator> save_current_merge_list_entry(&_imp->current_merge_list_entry,
our_merge_entry_position);
@@ -733,6 +744,11 @@ DepList::add_already_installed_package(const PackageDatabaseEntry & p, DepTag::C
.generation(_imp->merge_list_generation)
.tag(tag));
+ if (_imp->opts.dependency_tags && _imp->current_pde())
+ our_merge_entry->tags->insert(DepTagEntry::create()
+ .tag(DepTag::Pointer(new DependencyDepTag(*_imp->current_pde())))
+ .generation(_imp->merge_list_generation));
+
Save<MergeList::const_iterator> save_current_merge_list_entry(&_imp->current_merge_list_entry,
our_merge_entry);
diff --git a/paludis/dep_list.sr b/paludis/dep_list.sr
index 090ceae..abc6c94 100644
--- a/paludis/dep_list.sr
+++ b/paludis/dep_list.sr
@@ -17,6 +17,8 @@ make_class_DepListOptions()
key circular DepListCircularOption
+ key dependency_tags bool
+
extra_constructors <<END
DepListOptions();
END
diff --git a/paludis/dep_tag.cc b/paludis/dep_tag.cc
index 1d76e4b..caf2418 100644
--- a/paludis/dep_tag.cc
+++ b/paludis/dep_tag.cc
@@ -43,6 +43,7 @@ namespace
make_glsa_dep_tag()
{
return DepTagCategory::ConstPointer(new DepTagCategory(
+ true,
"glsa",
"Security advisories",
"Your system is potentially affected by these security issues:",
@@ -58,7 +59,7 @@ namespace
&make_glsa_dep_tag);
/**
- * Create the DepTagCategory for seneral sets.
+ * Create the DepTagCategory for general sets.
*
* \see register_general_set_dep_tag
*
@@ -68,6 +69,7 @@ namespace
make_general_set_dep_tag()
{
return DepTagCategory::ConstPointer(new DepTagCategory(
+ true,
"general",
"General sets",
"",
@@ -81,11 +83,40 @@ namespace
*/
static const DepTagCategoryMaker::RegisterMaker register_general_set_dep_tag("general",
&make_general_set_dep_tag);
+
+ /**
+ * Create the DepTagCategory for dependency sets.
+ *
+ * \see register_dependency_set_dep_tag
+ *
+ * \ingroup grpdeptag
+ */
+ DepTagCategory::ConstPointer
+ make_dependency_set_dep_tag()
+ {
+ return DepTagCategory::ConstPointer(new DepTagCategory(
+ false,
+ "dependency",
+ "Dependencies",
+ "",
+ ""));
+ }
+
+ /**
+ * Register the general set dep tag category instance.
+ *
+ * \ingroup grpdeptag
+ */
+ static const DepTagCategoryMaker::RegisterMaker register_dependency_set_dep_tag("dependency",
+ &make_dependency_set_dep_tag);
}
-DepTagCategory::DepTagCategory(const std::string & our_id,
+DepTagCategory::DepTagCategory(
+ bool vis,
+ const std::string & our_id,
const std::string & t, const std::string & pre,
const std::string & post) :
+ _visible(vis),
_id(our_id),
_title(t),
_pre_text(pre),
@@ -149,3 +180,20 @@ GeneralSetDepTag::category() const
return "general";
}
+DependencyDepTag::DependencyDepTag(const PackageDatabaseEntry & pde) :
+ _dbe(pde)
+{
+}
+
+std::string
+DependencyDepTag::short_text() const
+{
+ return stringify(_dbe);
+}
+
+std::string
+DependencyDepTag::category() const
+{
+ return "dependency";
+}
+
diff --git a/paludis/dep_tag.hh b/paludis/dep_tag.hh
index a91692c..d897e8d 100644
--- a/paludis/dep_tag.hh
+++ b/paludis/dep_tag.hh
@@ -27,6 +27,7 @@
*/
#include <string>
+#include <paludis/package_database_entry.hh>
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/visitor.hh>
#include <paludis/util/counted_ptr.hh>
@@ -53,6 +54,7 @@ namespace paludis
public InternalCounted<DepTagCategory>
{
private:
+ bool _visible;
const std::string _id;
const std::string _title;
const std::string _pre_text;
@@ -62,12 +64,22 @@ namespace paludis
/**
* Constructor.
*/
- DepTagCategory(const std::string & id,
+ DepTagCategory(
+ bool visible,
+ const std::string & id,
const std::string & t,
const std::string & pre,
const std::string & post);
/**
+ * Should we be displayed in a tag category summary?
+ */
+ bool visible() const
+ {
+ return _visible;
+ }
+
+ /**
* Fetch our short ID (for example, 'GLSA').
*/
std::string id() const
@@ -128,13 +140,14 @@ namespace paludis
class DepTag;
class GLSADepTag;
class GeneralSetDepTag;
+ class DependencyDepTag;
/**
* Visitor class for visiting the different DepTag subclasses.
*
* \ingroup grpdeptag
*/
- typedef VisitorTypes<GLSADepTag *, GeneralSetDepTag *> DepTagVisitorTypes;
+ typedef VisitorTypes<GLSADepTag *, GeneralSetDepTag *, DependencyDepTag *> DepTagVisitorTypes;
/**
* A DepTag can be associated with a PackageDepAtom, and is transferred
@@ -234,6 +247,29 @@ namespace paludis
virtual std::string category() const;
};
+ /**
+ * DepTag subclass for dependencies.
+ *
+ * \ingroup grpdeptag
+ */
+ class DependencyDepTag :
+ public DepTag,
+ public Visitable<DependencyDepTag, DepTagVisitorTypes>
+ {
+ private:
+ const PackageDatabaseEntry _dbe;
+
+ public:
+ /**
+ * Constructor.
+ */
+ DependencyDepTag(const PackageDatabaseEntry & dbe);
+
+ virtual std::string short_text() const;
+
+ virtual std::string category() const;
+ };
+
#include <paludis/dep_tag-sr.hh>
typedef SortedCollection<DepTagEntry> DepListEntryTags;
diff --git a/paludis/tasks/install_task.cc b/paludis/tasks/install_task.cc
index 942797d..e5a2d98 100644
--- a/paludis/tasks/install_task.cc
+++ b/paludis/tasks/install_task.cc
@@ -164,8 +164,7 @@ InstallTask::execute()
dep != dep_end ; ++dep)
{
_imp->current_dep_list_entry = dep;
- if (! dep->already_installed)
- on_display_merge_list_entry(*dep);
+ on_display_merge_list_entry(*dep);
}
/* we're done displaying our task list */
diff --git a/src/colour.hh b/src/colour.hh
index 924526a..1e42b0b 100644
--- a/src/colour.hh
+++ b/src/colour.hh
@@ -32,6 +32,7 @@ enum Colour
cl_yellow = 33,
cl_blue = 34,
cl_pink = 35,
+ cl_grey = 38,
cl_bold_red = cl_red + 100,
cl_bold_green = cl_green + 100,
@@ -67,6 +68,7 @@ enum Colour
cl_key_name = cl_blue,
#endif
+ cl_unimportant = cl_grey,
cl_error = cl_bold_red,
cl_file = cl_none,
diff --git a/src/paludis/command_line.cc b/src/paludis/command_line.cc
index b836569..54c8c54 100644
--- a/src/paludis/command_line.cc
+++ b/src/paludis/command_line.cc
@@ -78,6 +78,12 @@ CommandLine::CommandLine() :
a_preserve_world(&install_args, "preserve-world", '1', "Don't modify the world file"),
a_no_config_protection(&install_args, "no-config-protection", '\0', "Disable config file protection (dangerous)"),
a_fetch(&install_args, "fetch", 'f', "Only fetch sources; don't install anything"),
+ a_show_install_reasons(&install_args, "show-install-reasons", '\0', "Show why packages are being installed",
+ paludis::args::EnumArg::EnumArgOptions
+ ("none", "Don't show any information")
+ ("summary", "Show a summary")
+ ("full", "Show full output (can be very verbose)"),
+ "none"),
dl_args(this, "DepList behaviour",
"Modify dependency list generation behaviour. Use with caution."),
diff --git a/src/paludis/command_line.hh b/src/paludis/command_line.hh
index 0f3440b..fb508da 100644
--- a/src/paludis/command_line.hh
+++ b/src/paludis/command_line.hh
@@ -185,6 +185,9 @@ class CommandLine :
/// --fetch
paludis::args::SwitchArg a_fetch;
+ /// --show-install-reasons
+ paludis::args::EnumArg a_show_install_reasons;
+
/// }
/// \name DepList behaviour arguments
diff --git a/src/paludis/install.cc b/src/paludis/install.cc
index fd1c538..bb04f80 100644
--- a/src/paludis/install.cc
+++ b/src/paludis/install.cc
@@ -23,6 +23,7 @@
#include "use.hh"
#include <iostream>
+#include <limits>
#include <set>
#include <signal.h>
@@ -55,6 +56,10 @@ namespace
<< tag->glsa_title() << endl;
}
+ void visit(const DependencyDepTag * const)
+ {
+ }
+
void visit(const GeneralSetDepTag * const tag)
{
cout << "* " << colour(cl_tag, tag->short_text());
@@ -355,6 +360,9 @@ namespace
DepTagCategory::ConstPointer c(DepTagCategoryMaker::get_instance()->
find_maker(*cat)());
+ if (! c->visible())
+ continue;
+
if (! c->title().empty())
cout << colour(cl_heading, c->title()) << ":" << endl << endl;
if (! c->pre_text().empty())
@@ -378,9 +386,13 @@ namespace
void
OurInstallTask::on_display_merge_list_entry(const DepListEntry & d)
{
+ if (d.already_installed && CommandLine::get_instance()->a_show_install_reasons.argument() != "full")
+ return;
+
Context context("When displaying entry '" + stringify(d.package) + "':");
- cout << "* " << colour(cl_package_name, d.package.name);
+ cout << "* " << colour(d.already_installed ? cl_unimportant : cl_package_name,
+ d.package.name);
/* display version, unless it's 0 and our category is "virtual" */
if ((VersionSpec("0") != d.package.version) ||
@@ -394,15 +406,18 @@ namespace
/* display slot name, unless it's 0 */
if (SlotName("0") != d.metadata->slot)
- cout << colour(cl_slot, " {:" + stringify(d.metadata->slot) + "}");
+ cout << colour(d.already_installed ? cl_unimportant : cl_slot,
+ " {:" + stringify(d.metadata->slot) + "}");
- /* indicate [U], [S] or [N]. display existing version, if we're
+ /* indicate [U], [S], [N] or [-]. display existing version, if we're
* already installed */
PackageDatabaseEntryCollection::Pointer existing(DefaultEnvironment::get_instance()->package_database()->
query(PackageDepAtom::Pointer(new PackageDepAtom(stringify(
d.package.name))), is_installed_only));
- if (existing->empty())
+ if (d.already_installed)
+ cout << colour(cl_unimportant, " [-]");
+ else if (existing->empty())
{
cout << colour(cl_updatemode, " [N]");
if (d.metadata->get_virtual_interface())
@@ -487,7 +502,8 @@ namespace
PackageDatabaseEntry p(d.package);
/* display USE flags */
- std::cout << make_pretty_use_flags_string(DefaultEnvironment::get_instance(), p, d.metadata);
+ if (! d.already_installed)
+ std::cout << make_pretty_use_flags_string(DefaultEnvironment::get_instance(), p, d.metadata);
/* display tag, add tag to our post display list */
if (! d.tags->empty())
@@ -498,12 +514,55 @@ namespace
tag_end(d.tags->end()) ;
tag != tag_end ; ++tag)
{
+ if (tag->tag->category() == "dependency")
+ continue;
+
_all_tags.insert(*tag);
tag_titles.append(tag->tag->short_text());
- tag_titles.append(",");
+ tag_titles.append(", ");
+ }
+ if (! tag_titles.empty())
+ {
+ tag_titles.erase(tag_titles.length() - 2);
+ cout << " " << colour(d.already_installed ? cl_unimportant : cl_tag,
+ "<" + tag_titles + ">");
+ }
+
+ /* display dependency tags */
+ if ((CommandLine::get_instance()->a_show_install_reasons.argument() == "summary") ||
+ (CommandLine::get_instance()->a_show_install_reasons.argument() == "full"))
+ {
+ std::string deps;
+ unsigned count(0), max_count;
+ if (CommandLine::get_instance()->a_show_install_reasons.argument() == "summary")
+ max_count = 3;
+ else
+ max_count = std::numeric_limits<long>::max();
+
+ for (SortedCollection<DepTagEntry>::Iterator
+ tag(d.tags->begin()),
+ tag_end(d.tags->end()) ;
+ tag != tag_end ; ++tag)
+ {
+ if (tag->tag->category() != "dependency")
+ continue;
+
+ if (++count < max_count)
+ {
+ deps.append(tag->tag->short_text());
+ deps.append(", ");
+ }
+ }
+ if (! deps.empty())
+ {
+ if (count >= max_count)
+ deps.append(stringify(count - max_count + 1) + " more, ");
+
+ deps.erase(deps.length() - 2);
+ cout << " " << colour(d.already_installed ? cl_unimportant : cl_tag,
+ "<" + deps + ">");
+ }
}
- tag_titles.erase(tag_titles.length() - 1);
- cout << " " << colour(cl_tag, "<" + tag_titles + ">");
}
cout << endl;
@@ -644,6 +703,10 @@ do_install()
options.uninstalled_deps_post = enum_arg_to_dep_list_deps_option(
CommandLine::get_instance()->dl_uninstalled_deps_post);
+ if ((CommandLine::get_instance()->a_show_install_reasons.argument() == "summary") ||
+ (CommandLine::get_instance()->a_show_install_reasons.argument() == "full"))
+ options.dependency_tags = true;
+
OurInstallTask task(options);
task.set_no_config_protect(CommandLine::get_instance()->a_no_config_protection.specified());
task.set_fetch_only(CommandLine::get_instance()->a_fetch.specified());