aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-08-24 18:15:18 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-08-24 18:15:18 +0000
commitf2f23009c69428d0905eff1de037424ac9c21364 (patch)
treea4f21e3126b84ead1e283c99e94aa1abc427d7e1
parent03635e3cb4929139788051802baf44b646fe576f (diff)
downloadpaludis-f2f23009c69428d0905eff1de037424ac9c21364.tar.gz
paludis-f2f23009c69428d0905eff1de037424ac9c21364.tar.xz
Add --find-dropped-keywords action to archtool
-rw-r--r--src/archtool/Makefile.am13
-rw-r--r--src/archtool/archtool.cc12
-rw-r--r--src/archtool/command_line.cc12
-rw-r--r--src/archtool/command_line.hh1
-rw-r--r--src/archtool/find_dropped_keywords.cc200
-rw-r--r--src/archtool/find_dropped_keywords.hh28
-rw-r--r--src/archtool/find_dropped_keywords.sr13
7 files changed, 274 insertions, 5 deletions
diff --git a/src/archtool/Makefile.am b/src/archtool/Makefile.am
index 886545b..55d4c66 100644
--- a/src/archtool/Makefile.am
+++ b/src/archtool/Makefile.am
@@ -28,6 +28,7 @@ man_archtool_LDADD = \
archtool_SOURCES = \
command_line.hh command_line.cc \
find_stable_candidates.hh find_stable_candidates.cc \
+ find_dropped_keywords.hh find_dropped_keywords.cc \
keywords_graph.hh keywords_graph.cc \
archtool_environment.hh archtool_environment.cc \
archtool.cc
@@ -54,12 +55,15 @@ EXTRA_DIST = \
$(man_MANS) \
$(TESTS) \
find_stable_candidates-sr.hh find_stable_candidates-sr.cc \
+ find_dropped_keywords-sr.hh find_dropped_keywords-sr.cc \
find_stable_candidates_TEST_setup.sh find_stable_candidates_TEST_cleanup.sh
CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda
DISTCLEANFILES = $(man_MANS) find_stable_candidates-sr.hh find_stable_candidates-sr.cc
MAINTAINERCLEANFILES = Makefile.in
-BUILT_SOURCES = find_stable_candidates-sr.hh find_stable_candidates-sr.cc
+BUILT_SOURCES = \
+ find_stable_candidates-sr.hh find_stable_candidates-sr.cc \
+ find_dropped_keywords-sr.hh find_dropped_keywords-sr.cc
find_stable_candidates-sr.hh : find_stable_candidates.sr $(top_srcdir)/misc/make_sr.bash
$(top_srcdir)/misc/make_sr.bash --header $(srcdir)/find_stable_candidates.sr > $@
@@ -67,3 +71,10 @@ find_stable_candidates-sr.hh : find_stable_candidates.sr $(top_srcdir)/misc/make
find_stable_candidates-sr.cc : find_stable_candidates.sr $(top_srcdir)/misc/make_sr.bash
$(top_srcdir)/misc/make_sr.bash --source $(srcdir)/find_stable_candidates.sr > $@
+find_dropped_keywords-sr.hh : find_dropped_keywords.sr $(top_srcdir)/misc/make_sr.bash
+ $(top_srcdir)/misc/make_sr.bash --header $(srcdir)/find_dropped_keywords.sr > $@
+
+find_dropped_keywords-sr.cc : find_dropped_keywords.sr $(top_srcdir)/misc/make_sr.bash
+ $(top_srcdir)/misc/make_sr.bash --source $(srcdir)/find_dropped_keywords.sr > $@
+
+
diff --git a/src/archtool/archtool.cc b/src/archtool/archtool.cc
index dcd146a..9a691c6 100644
--- a/src/archtool/archtool.cc
+++ b/src/archtool/archtool.cc
@@ -19,6 +19,7 @@
#include "command_line.hh"
#include "find_stable_candidates.hh"
+#include "find_dropped_keywords.hh"
#include "keywords_graph.hh"
#include "archtool_environment.hh"
@@ -129,6 +130,7 @@ main(int argc, char *argv[])
if (1 != (
CommandLine::get_instance()->a_find_stable_candidates.specified() +
+ CommandLine::get_instance()->a_find_dropped_keywords.specified() +
CommandLine::get_instance()->a_keywords_graph.specified()))
throw DoHelp("you should specify exactly one action");
@@ -144,6 +146,16 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
+ if (CommandLine::get_instance()->a_find_dropped_keywords.specified())
+ {
+ if (1 != std::distance(CommandLine::get_instance()->begin_parameters(),
+ CommandLine::get_instance()->end_parameters()))
+ throw DoHelp("find-dropped-keywords action takes exactly one parameter (the target arch)");
+
+ do_find_dropped_keywords(env);
+ return EXIT_SUCCESS;
+ }
+
if (CommandLine::get_instance()->a_keywords_graph.specified())
{
if (CommandLine::get_instance()->begin_parameters() !=
diff --git a/src/archtool/command_line.cc b/src/archtool/command_line.cc
index 75e611d..e0118a0 100644
--- a/src/archtool/command_line.cc
+++ b/src/archtool/command_line.cc
@@ -28,8 +28,10 @@ CommandLine::CommandLine() :
a_find_stable_candidates(&action_args,
"find-stable-candidates", 's', "Search for stable package candidates"),
+ a_find_dropped_keywords(&action_args,
+ "find-dropped-keywords", 'd', "Search for packages where keywords have been dropped"),
a_keywords_graph(&action_args,
- "keyword-graph", 'k', "Display KEYWORDS graphically"),
+ "keyword-graph", 'k', "Display keywords graphically"),
a_version(&action_args,
"version", 'V', "Display program version"),
a_help(&action_args,
@@ -50,10 +52,12 @@ CommandLine::CommandLine() :
a_package(&general_args, "package", 'P',
"Matches with this package name only")
{
- add_usage_line("--find-stable-candidates [ --repository-dir /path ] "
+ add_usage_line("--find-stable-candidates arch [ --repository-dir /path ] "
"[ --category app-misc --category sys-apps ... ] "
- "[ --package foo --package fnord ... ] "
- "arch");
+ "[ --package foo --package fnord ... ] ");
+ add_usage_line("--find-dropped-keywords arch [ --repository-dir /path ] "
+ "[ --category app-misc --category sys-apps ... ] "
+ "[ --package foo --package fnord ... ] ");
add_usage_line("--keywords-graph [ --repository-dir /path ] "
"[ --category app-misc --category sys-apps ... ] "
"[ --package foo --package fnord ... ]"),
diff --git a/src/archtool/command_line.hh b/src/archtool/command_line.hh
index a2ebed5..7df9bd2 100644
--- a/src/archtool/command_line.hh
+++ b/src/archtool/command_line.hh
@@ -60,6 +60,7 @@ class CommandLine :
paludis::args::ArgsGroup action_args;
paludis::args::SwitchArg a_find_stable_candidates;
+ paludis::args::SwitchArg a_find_dropped_keywords;
paludis::args::SwitchArg a_keywords_graph;
paludis::args::SwitchArg a_version;
diff --git a/src/archtool/find_dropped_keywords.cc b/src/archtool/find_dropped_keywords.cc
new file mode 100644
index 0000000..fb52d83
--- /dev/null
+++ b/src/archtool/find_dropped_keywords.cc
@@ -0,0 +1,200 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk>
+ *
+ * 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 "find_dropped_keywords.hh"
+#include "command_line.hh"
+
+#include <paludis/util/tokeniser.hh>
+#include <paludis/util/compare.hh>
+
+#include <set>
+#include <map>
+#include <iostream>
+#include <iomanip>
+#include <algorithm>
+
+using namespace paludis;
+using std::cout;
+using std::cerr;
+using std::endl;
+
+namespace
+{
+
+#include "find_dropped_keywords-sr.hh"
+#include "find_dropped_keywords-sr.cc"
+
+ static const int col_width_package = 30;
+ static const int col_width_best_keyworded = 20;
+ static const int col_width_best_anywhere = 20;
+
+ void
+ write_repository_header(const KeywordName & keyword, const RepositoryName & repo)
+ {
+ std::string s("Dropped keywords for '" + stringify(repo) + "' on '"
+ + stringify(keyword) + "'");
+ cout << std::string(s.length(), '=') << endl;
+ cout << s << endl;
+ cout << std::string(s.length(), '=') << endl;
+ cout << endl;
+
+ cout << std::left
+ << std::setw(col_width_package) << "category/package (:slot)"
+ << std::setw(col_width_best_keyworded) << "best keyworded"
+ << std::setw(col_width_best_anywhere) << "best anywhere"
+ << endl;
+
+ cout
+ << std::string(col_width_package - 1, '-') << " "
+ << std::string(col_width_best_keyworded - 1, '-') << " "
+ << std::string(col_width_best_anywhere - 1, '-') << " "
+ << endl;
+ }
+
+ struct IsStableOrUnstableKeyword
+ {
+ bool operator() (const KeywordName & k) const
+ {
+ return stringify(k).at(0) != '-';
+ }
+ };
+
+ void
+ write_package(const QualifiedPackageName & package, const SlotName & slot,
+ const VersionSpec & best_keyworded, const VersionSpec & best_anywhere)
+ {
+ static CategoryNamePart previous_category("not-on-a-boat");
+ if (package.category != previous_category)
+ {
+ cout << std::setw(col_width_package) << (stringify(package.category) + "/") << endl;
+ previous_category = package.category;
+ }
+
+ std::string p(stringify(package.package));
+ if (SlotName("0") != slot)
+ p += ":" + stringify(slot);
+ cout << " " << std::setw(col_width_package - 2) << p;
+
+ if (best_keyworded != VersionSpec("0"))
+ cout << std::setw(col_width_best_keyworded) << best_keyworded;
+ else
+ cout << std::setw(col_width_best_keyworded) << " ";
+ cout << std::setw(col_width_best_anywhere) << best_anywhere;
+ cout << endl;
+ }
+
+ void
+ check_one_package(const Environment &, const KeywordName & keyword,
+ const Repository & repo, const QualifiedPackageName & package)
+ {
+ /* determine whether we have any interesting versions, and pick out
+ * slots where we do. for slots, we map slot to a pair (best stable
+ * version for us, best stable version for anyone). */
+
+ bool is_interesting(false);
+ typedef std::map<SlotName, VersionsEntry> VersionsInSlots;
+ VersionsInSlots versions_in_slots;
+
+ VersionSpecCollection::ConstPointer versions(repo.version_specs(package));
+ for (VersionSpecCollection::Iterator v(versions->begin()), v_end(versions->end()) ;
+ v != v_end ; ++v)
+ {
+ VersionMetadata::ConstPointer metadata(repo.version_metadata(package, *v));
+ if (! metadata->get_ebuild_interface())
+ continue;
+
+ std::set<KeywordName> keywords;
+ WhitespaceTokeniser::get_instance()->tokenise(metadata->get_ebuild_interface()->keywords,
+ create_inserter<KeywordName>(std::inserter(keywords, keywords.end())));
+
+ /* ensure that there's an entry for this SLOT */
+ versions_in_slots.insert(std::make_pair(metadata->slot, VersionsEntry(
+ VersionsEntry::create()
+ .best_keyworded(VersionSpec("0"))
+ .best_anywhere(VersionSpec("0")))));
+
+ if (keywords.end() != keywords.find(keyword) ||
+ keywords.end() != keywords.find(KeywordName("~" + stringify(keyword))))
+ {
+ is_interesting = true;
+ versions_in_slots.find(metadata->slot)->second.best_keyworded =
+ std::max(versions_in_slots.find(metadata->slot)->second.best_keyworded, *v);
+ }
+
+ if (keywords.end() != std::find_if(keywords.begin(), keywords.end(), IsStableOrUnstableKeyword()))
+ versions_in_slots.find(metadata->slot)->second.best_anywhere =
+ std::max(versions_in_slots.find(metadata->slot)->second.best_anywhere, *v);
+ }
+
+ if (! is_interesting)
+ return;
+
+ /* for each slot, if there's a higher version on another arch, flag it */
+ for (VersionsInSlots::const_iterator s(versions_in_slots.begin()),
+ s_end(versions_in_slots.end()) ; s != s_end ; ++s)
+ {
+ if (s->second.best_keyworded >= s->second.best_anywhere)
+ continue;
+
+ write_package(package, s->first, s->second.best_keyworded, s->second.best_anywhere);
+ }
+ }
+}
+
+void do_find_dropped_keywords(const Environment & env)
+{
+ Context context("When performing find-dropped-keywords action:");
+
+ KeywordName keyword(*CommandLine::get_instance()->begin_parameters());
+
+ for (IndirectIterator<PackageDatabase::RepositoryIterator, const Repository>
+ r(env.package_database()->begin_repositories()),
+ r_end(env.package_database()->end_repositories()) ; r != r_end ; ++r)
+ {
+ write_repository_header(keyword, r->name());
+
+ CategoryNamePartCollection::ConstPointer cat_names(r->category_names());
+ for (CategoryNamePartCollection::Iterator c(cat_names->begin()), c_end(cat_names->end()) ;
+ c != c_end ; ++c)
+ {
+ if (CommandLine::get_instance()->a_category.specified())
+ if (CommandLine::get_instance()->a_category.args_end() == std::find(
+ CommandLine::get_instance()->a_category.args_begin(),
+ CommandLine::get_instance()->a_category.args_end(),
+ stringify(*c)))
+ continue;
+
+ QualifiedPackageNameCollection::ConstPointer pkg_names(r->package_names(*c));
+ for (QualifiedPackageNameCollection::Iterator p(pkg_names->begin()), p_end(pkg_names->end()) ;
+ p != p_end ; ++p)
+ {
+ if (CommandLine::get_instance()->a_package.specified())
+ if (CommandLine::get_instance()->a_package.args_end() == std::find(
+ CommandLine::get_instance()->a_package.args_begin(),
+ CommandLine::get_instance()->a_package.args_end(),
+ stringify(p->package)))
+ continue;
+
+ check_one_package(env, keyword, *r, *p);
+ }
+ }
+ }
+}
+
+
diff --git a/src/archtool/find_dropped_keywords.hh b/src/archtool/find_dropped_keywords.hh
new file mode 100644
index 0000000..d3e4791
--- /dev/null
+++ b/src/archtool/find_dropped_keywords.hh
@@ -0,0 +1,28 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk>
+ *
+ * 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_ARCHTOOL_FIND_DROPPED_KEYWORDS_HH
+#define PALUDIS_GUARD_SRC_ARCHTOOL_FIND_DROPPED_KEYWORDS_HH 1
+
+#include <paludis/environment.hh>
+
+void do_find_dropped_keywords(const paludis::Environment & env);
+
+#endif
+
diff --git a/src/archtool/find_dropped_keywords.sr b/src/archtool/find_dropped_keywords.sr
new file mode 100644
index 0000000..b197b2a
--- /dev/null
+++ b/src/archtool/find_dropped_keywords.sr
@@ -0,0 +1,13 @@
+#!/bin/bash
+# vim: set sw=4 sts=4 et :
+
+make_class_VersionsEntry()
+{
+ key best_keyworded VersionSpec
+ key best_anywhere VersionSpec
+
+ allow_named_args
+}
+
+
+