aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-12 12:23:26 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-12 12:23:26 +0000
commitb7e7ad11a42ac8b99e2e5284528373693ddf6dab (patch)
treea9bb66c92369931cb22622c5ff66d1d749343514
parentaf016c31d4c835b541157e6f5619b58d366c0efe (diff)
downloadpaludis-b7e7ad11a42ac8b99e2e5284528373693ddf6dab.tar.gz
paludis-b7e7ad11a42ac8b99e2e5284528373693ddf6dab.tar.xz
Implement adjutrix --what-needs-keywording
-rw-r--r--src/clients/adjutrix/Makefile.am1
-rw-r--r--src/clients/adjutrix/adjutrix.cc14
-rw-r--r--src/clients/adjutrix/command_line.cc2
-rw-r--r--src/clients/adjutrix/command_line.hh1
-rw-r--r--src/clients/adjutrix/what_needs_keywording.cc100
-rw-r--r--src/clients/adjutrix/what_needs_keywording.hh27
6 files changed, 144 insertions, 1 deletions
diff --git a/src/clients/adjutrix/Makefile.am b/src/clients/adjutrix/Makefile.am
index e8548a2..e6039f6 100644
--- a/src/clients/adjutrix/Makefile.am
+++ b/src/clients/adjutrix/Makefile.am
@@ -36,6 +36,7 @@ adjutrix_SOURCES = \
keywords_graph.hh keywords_graph.cc \
display_profiles_use.hh display_profiles_use.cc \
display_default_system_resolution.hh display_default_system_resolution.cc \
+ what_needs_keywording.hh what_needs_keywording.cc \
adjutrix.cc
adjutrix_LDADD = \
diff --git a/src/clients/adjutrix/adjutrix.cc b/src/clients/adjutrix/adjutrix.cc
index 2cb3a8f..7a929fa 100644
--- a/src/clients/adjutrix/adjutrix.cc
+++ b/src/clients/adjutrix/adjutrix.cc
@@ -26,6 +26,7 @@
#include "keywords_graph.hh"
#include "display_profiles_use.hh"
#include "display_default_system_resolution.hh"
+#include "what_needs_keywording.hh"
#include <paludis/about.hh>
#include <paludis/util/join.hh>
@@ -133,7 +134,8 @@ main(int argc, char *argv[])
CommandLine::get_instance()->a_keywords_graph.specified() +
CommandLine::get_instance()->a_reverse_deps.specified() +
CommandLine::get_instance()->a_display_profiles_use.specified() +
- CommandLine::get_instance()->a_display_default_system_resolution.specified()
+ CommandLine::get_instance()->a_display_default_system_resolution.specified() +
+ CommandLine::get_instance()->a_what_needs_keywording.specified()
))
throw DoHelp("you should specify exactly one action");
@@ -217,6 +219,16 @@ main(int argc, char *argv[])
return do_display_default_system_resolution(env);
}
+ if (CommandLine::get_instance()->a_what_needs_keywording.specified())
+ {
+ if (2 != std::distance(CommandLine::get_instance()->begin_parameters(),
+ CommandLine::get_instance()->end_parameters()))
+ throw DoHelp("what-needs-keywording action takes exactly two parameters "
+ "(the target keyword and the target package)");
+
+ return do_what_needs_keywording(env);
+ }
+
throw InternalError(__PRETTY_FUNCTION__, "no action?");
}
catch (const DoVersion &)
diff --git a/src/clients/adjutrix/command_line.cc b/src/clients/adjutrix/command_line.cc
index 5a4dd68..8024e4a 100644
--- a/src/clients/adjutrix/command_line.cc
+++ b/src/clients/adjutrix/command_line.cc
@@ -36,6 +36,8 @@ CommandLine::CommandLine() :
"keyword-graph", 'k', "Display keywords graphically"),
a_reverse_deps(&tree_action_args,
"reverse-deps", 'r', "Find all package that depend on a given dep atom"),
+ a_what_needs_keywording(&tree_action_args,
+ "what-needs-keywording", 'w', "Display what needs to be done to keyword a target"),
profile_action_args(this, "Profile-Oriented Actions",
"Selects which basic profile-oriented action to perform. Exactly one action should "
diff --git a/src/clients/adjutrix/command_line.hh b/src/clients/adjutrix/command_line.hh
index 4e6a0b5..81053c4 100644
--- a/src/clients/adjutrix/command_line.hh
+++ b/src/clients/adjutrix/command_line.hh
@@ -65,6 +65,7 @@ class CommandLine :
paludis::args::SwitchArg a_find_insecure_packages;
paludis::args::SwitchArg a_keywords_graph;
paludis::args::SwitchArg a_reverse_deps;
+ paludis::args::SwitchArg a_what_needs_keywording;
paludis::args::ArgsGroup profile_action_args;
paludis::args::SwitchArg a_display_profiles_use;
diff --git a/src/clients/adjutrix/what_needs_keywording.cc b/src/clients/adjutrix/what_needs_keywording.cc
new file mode 100644
index 0000000..e969160
--- /dev/null
+++ b/src/clients/adjutrix/what_needs_keywording.cc
@@ -0,0 +1,100 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 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 version 2, as published by the Free Software Foundation.
+ *
+ * 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
+ */
+
+#include "what_needs_keywording.hh"
+#include "command_line.hh"
+
+#include <paludis/util/tokeniser.hh>
+#include <paludis/util/compare.hh>
+#include <paludis/util/strip.hh>
+#include <paludis/repositories/portage/portage_repository.hh>
+#include <paludis/dep_list/exceptions.hh>
+#include <paludis/dep_list/dep_list.hh>
+
+#include <set>
+#include <map>
+#include <list>
+#include <iostream>
+#include <iomanip>
+
+using namespace paludis;
+using std::cout;
+using std::cerr;
+using std::endl;
+
+int do_what_needs_keywording(NoConfigEnvironment & env)
+{
+ int return_code(0);
+
+ Context context("When performing what-needs-keywording action:");
+
+ KeywordName target_keyword(*CommandLine::get_instance()->begin_parameters());
+ UseFlagName target_arch(strip_leading_string(
+ *CommandLine::get_instance()->begin_parameters(), "~"));
+
+ env.portage_repository()->set_profile_by_arch(target_arch);
+ env.set_accept_unstable('~' == stringify(target_keyword).at(0));
+
+ DepListOptions d_options;
+ d_options.circular = dl_circular_discard;
+ d_options.override_mask_reasons.set(mr_keyword);
+
+ DepList d(&env, d_options);
+
+ cout << std::setw(30) << std::left << "Package";
+ cout << std::setw(20) << std::left << "Version";
+ cout << std::setw(20) << std::left << "Current Keywords";
+ cout << endl;
+
+ cout << std::string(29, '=') << " " << std::string(19, '=') << " "
+ << std::string(19, '=') << endl;
+
+ for (CommandLine::ParametersIterator p(next(CommandLine::get_instance()->begin_parameters())),
+ p_end(CommandLine::get_instance()->end_parameters()) ; p != p_end ; ++p)
+ d.add(PackageDepAtom::Pointer(new PackageDepAtom(*p)));
+
+ for (DepList::Iterator p(d.begin()), p_end(d.end()) ; p != p_end ; ++p)
+ if (dlk_masked == p->kind)
+ {
+ cout << std::setw(30) << std::left << stringify(p->package.name);
+ cout << std::setw(20) << std::left << stringify(p->package.version);
+
+ VersionMetadata::ConstPointer m(env.package_database()->fetch_repository(
+ p->package.repository)->version_metadata(p->package.name,
+ p->package.version));
+ if (m->get_ebuild_interface())
+ {
+ std::set<std::string> keywords;
+ WhitespaceTokeniser::get_instance()->tokenise(m->get_ebuild_interface()->keywords,
+ std::inserter(keywords, keywords.end()));
+ for (std::set<std::string>::const_iterator k(keywords.begin()), k_end(keywords.end()) ;
+ k != k_end ; ++k)
+ if (*k == "-*"
+ || *k == stringify(target_keyword)
+ || k->substr(1) == stringify(target_arch))
+ cout << *k << " ";
+ }
+
+ cout << endl;
+ }
+
+ return return_code;
+}
+
+
diff --git a/src/clients/adjutrix/what_needs_keywording.hh b/src/clients/adjutrix/what_needs_keywording.hh
new file mode 100644
index 0000000..77f8e8a
--- /dev/null
+++ b/src/clients/adjutrix/what_needs_keywording.hh
@@ -0,0 +1,27 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 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 version 2, as published by the Free Software Foundation.
+ *
+ * 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
+ */
+
+#ifndef PALUDIS_GUARD_SRC_CLIENTS_ADJUTRIX_WHAT_NEEDS_KEYWORDING_HH
+#define PALUDIS_GUARD_SRC_CLIENTS_ADJUTRIX_WHAT_NEEDS_KEYWORDING_HH 1
+
+#include <paludis/environment/no_config/no_config_environment.hh>
+
+int do_what_needs_keywording(paludis::NoConfigEnvironment & env);
+
+#endif