aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-09-12 01:44:55 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-09-12 01:44:55 +0000
commit86d64baa4ffff0ea3eb9c5d0ed0fc6c5c02e34df (patch)
treef20ca703b25a4bca8c2f726eb96f5b982c1761e6
parent6b16ddcfcd07f583d4d27b60cdefafeefdc6511d (diff)
downloadpaludis-86d64baa4ffff0ea3eb9c5d0ed0fc6c5c02e34df.tar.gz
paludis-86d64baa4ffff0ea3eb9c5d0ed0fc6c5c02e34df.tar.xz
Add a --display-default-system-resolution action to adjutrix
-rw-r--r--src/adjutrix/Makefile.am14
-rw-r--r--src/adjutrix/adjutrix.cc16
-rw-r--r--src/adjutrix/adjutrix_environment.cc21
-rw-r--r--src/adjutrix/adjutrix_environment.hh2
-rw-r--r--src/adjutrix/command_line.cc7
-rw-r--r--src/adjutrix/command_line.hh1
-rw-r--r--src/adjutrix/display_default_system_resolution.cc151
-rw-r--r--src/adjutrix/display_default_system_resolution.hh27
-rw-r--r--src/adjutrix/find_dropped_keywords.cc3
-rw-r--r--src/adjutrix/find_stable_candidates.cc3
-rw-r--r--src/adjutrix/keywords_graph.cc3
11 files changed, 235 insertions, 13 deletions
diff --git a/src/adjutrix/Makefile.am b/src/adjutrix/Makefile.am
index 04a63ee..f38109c 100644
--- a/src/adjutrix/Makefile.am
+++ b/src/adjutrix/Makefile.am
@@ -27,12 +27,13 @@ man_adjutrix_LDADD = \
$(DYNAMIC_LD_LIBS)
adjutrix_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 \
- adjutrix_environment.hh adjutrix_environment.cc \
- display_profiles_use.hh display_profiles_use.cc \
+ 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 \
+ adjutrix_environment.hh adjutrix_environment.cc \
+ display_profiles_use.hh display_profiles_use.cc \
+ display_default_system_resolution.hh display_default_system_resolution.cc \
adjutrix.cc
adjutrix_LDADD = \
@@ -40,6 +41,7 @@ adjutrix_LDADD = \
$(top_builddir)/paludis/libpaludis.la \
$(top_builddir)/paludis/args/libpaludisargs.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
+ $(top_builddir)/paludis/repositories/portage/libpaludisportagerepository.la \
$(top_builddir)/src/libcolour.a \
$(DYNAMIC_LD_LIBS)
diff --git a/src/adjutrix/adjutrix.cc b/src/adjutrix/adjutrix.cc
index dbe4069..e4e8294 100644
--- a/src/adjutrix/adjutrix.cc
+++ b/src/adjutrix/adjutrix.cc
@@ -23,6 +23,7 @@
#include "find_dropped_keywords.hh"
#include "keywords_graph.hh"
#include "display_profiles_use.hh"
+#include "display_default_system_resolution.hh"
#include "adjutrix_environment.hh"
#include <paludis/about.hh>
@@ -63,7 +64,7 @@ namespace
return FSEntry::cwd().dirname().dirname();
}
- throw ConfigurationError("Cannot find tree location (try specifying --repository-directory)");
+ throw ConfigurationError("Cannot find tree location (try specifying --repository-dir)");
}
void display_version()
@@ -135,7 +136,9 @@ main(int argc, char *argv[])
CommandLine::get_instance()->a_find_stable_candidates.specified() +
CommandLine::get_instance()->a_find_dropped_keywords.specified() +
CommandLine::get_instance()->a_keywords_graph.specified() +
- CommandLine::get_instance()->a_display_profiles_use.specified()))
+ CommandLine::get_instance()->a_display_profiles_use.specified() +
+ CommandLine::get_instance()->a_display_default_system_resolution.specified()
+ ))
throw DoHelp("you should specify exactly one action");
AdjutrixEnvironment env(get_location_and_add_filters());
@@ -180,6 +183,15 @@ main(int argc, char *argv[])
return EXIT_SUCCESS;
}
+ if (CommandLine::get_instance()->a_display_default_system_resolution.specified())
+ {
+ if (CommandLine::get_instance()->begin_parameters() !=
+ CommandLine::get_instance()->end_parameters())
+ throw DoHelp("display-default-system-resolution action takes no parameters");
+
+ return do_display_default_system_resolution(env);
+ }
+
throw InternalError(__PRETTY_FUNCTION__, "no action?");
}
catch (const DoVersion &)
diff --git a/src/adjutrix/adjutrix_environment.cc b/src/adjutrix/adjutrix_environment.cc
index a8816ef..e0a48b2 100644
--- a/src/adjutrix/adjutrix_environment.cc
+++ b/src/adjutrix/adjutrix_environment.cc
@@ -19,6 +19,7 @@
#include "adjutrix_environment.hh"
#include <paludis/util/collection_concrete.hh>
+#include <paludis/repositories/portage/portage_repository.hh>
using namespace paludis;
@@ -30,10 +31,12 @@ namespace paludis
{
const FSEntry top_level_dir;
PackageDatabase::Pointer db;
+ KeywordName accepted_keyword;
Implementation(Environment * const env, const FSEntry & d) :
top_level_dir(d),
- db(new PackageDatabase(env))
+ db(new PackageDatabase(env)),
+ accepted_keyword("fnord")
{
}
};
@@ -54,6 +57,9 @@ AdjutrixEnvironment::AdjutrixEnvironment(const FSEntry & dir) :
_imp->db->add_repository(
RepositoryMaker::get_instance()->find_maker("portage")(this,
_imp->db.raw_pointer(), keys));
+
+ _imp->db->add_repository(RepositoryMaker::get_instance()->find_maker("virtuals")(this,
+ _imp->db.raw_pointer(), AssociativeCollection<std::string, std::string>::Pointer(0)));
}
AdjutrixEnvironment::~AdjutrixEnvironment()
@@ -84,10 +90,19 @@ AdjutrixEnvironment::set_profile(const FSEntry & location)
keys->insert("location", stringify(_imp->top_level_dir));
keys->insert("profiles", stringify(location));
- db->add_repository(
- RepositoryMaker::get_instance()->find_maker("portage")(this,
+ PortageRepository::Pointer p(RepositoryMaker::get_instance()->find_maker("portage")(this,
_imp->db.raw_pointer(), keys));
+ _imp->accepted_keyword = KeywordName(p->profile_variable("ARCH"));
+ db->add_repository(RepositoryMaker::get_instance()->find_maker("virtuals")(this,
+ db.raw_pointer(), AssociativeCollection<std::string, std::string>::Pointer(0)));
+ db->add_repository(p);
change_package_database(db);
}
+bool
+AdjutrixEnvironment::accept_keyword(const KeywordName & k, const PackageDatabaseEntry * const) const
+{
+ return (k.data() == "*") || (k == _imp->accepted_keyword);
+}
+
diff --git a/src/adjutrix/adjutrix_environment.hh b/src/adjutrix/adjutrix_environment.hh
index 00a40ec..edb4cea 100644
--- a/src/adjutrix/adjutrix_environment.hh
+++ b/src/adjutrix/adjutrix_environment.hh
@@ -40,6 +40,8 @@ namespace paludis
FSEntry main_repository_dir() const;
void set_profile(const FSEntry & location);
+
+ virtual bool accept_keyword(const KeywordName &, const PackageDatabaseEntry * const) const;
};
}
diff --git a/src/adjutrix/command_line.cc b/src/adjutrix/command_line.cc
index 963a7ba..2712558 100644
--- a/src/adjutrix/command_line.cc
+++ b/src/adjutrix/command_line.cc
@@ -39,6 +39,9 @@ CommandLine::CommandLine() :
a_display_profiles_use(&profile_action_args,
"display-profiles-use", 'u', "Display USE information for all profiles"),
+ a_display_default_system_resolution(&profile_action_args,
+ "display-default-system-resolution", 'S', "Display package names and versions that are included in "
+ "the default resolution of the system set"),
general_action_args(this, "General Actions",
"Selects which basic general action to perform. Exactly one action should "
@@ -65,9 +68,9 @@ CommandLine::CommandLine() :
tree_args(this, "Tree action options",
"Options which are relevant for tree actions."),
- a_category(&general_args, "category", 'C',
+ a_category(&tree_args, "category", 'C',
"Matches with this category name only (may be specified multiple times)"),
- a_package(&general_args, "package", 'P',
+ a_package(&tree_args, "package", 'P',
"Matches with this package name only (may be specified multiple times)"),
profile_args(this, "Profile action options",
diff --git a/src/adjutrix/command_line.hh b/src/adjutrix/command_line.hh
index 279ae33..7845a27 100644
--- a/src/adjutrix/command_line.hh
+++ b/src/adjutrix/command_line.hh
@@ -65,6 +65,7 @@ class CommandLine :
paludis::args::ArgsGroup profile_action_args;
paludis::args::SwitchArg a_display_profiles_use;
+ paludis::args::SwitchArg a_display_default_system_resolution;
paludis::args::ArgsGroup general_action_args;
paludis::args::SwitchArg a_version;
diff --git a/src/adjutrix/display_default_system_resolution.cc b/src/adjutrix/display_default_system_resolution.cc
new file mode 100644
index 0000000..2bf4690
--- /dev/null
+++ b/src/adjutrix/display_default_system_resolution.cc
@@ -0,0 +1,151 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 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 "display_default_system_resolution.hh"
+#include "command_line.hh"
+#include "colour.hh"
+#include <paludis/config_file.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/tokeniser.hh>
+#include <paludis/util/dir_iterator.hh>
+#include <paludis/util/is_file_with_extension.hh>
+#include <paludis/util/strip.hh>
+#include <paludis/dep_list.hh>
+
+#include <iostream>
+#include <iomanip>
+#include <vector>
+#include <cstdlib>
+#include <set>
+#include <map>
+
+using namespace paludis;
+using std::cout;
+using std::cerr;
+using std::endl;
+
+using namespace paludis;
+
+namespace
+{
+ int
+ display_default_system_resolution(const AdjutrixEnvironment & env, const std::string & desc,
+ const FSEntry & profile)
+ {
+ int return_code(0);
+
+ Context context("When displaying system resolution for '" + stringify(desc) + "' at '"
+ + stringify(profile) + "':");
+
+ std::string display_profile(stringify(profile)), display_profile_chop(
+ stringify(env.main_repository_dir() / "profiles"));
+ if (0 == display_profile.compare(0, display_profile_chop.length(), display_profile_chop))
+ {
+ display_profile.erase(0, display_profile_chop.length());
+ if (0 == display_profile.compare(0, 1, "/"))
+ display_profile.erase(0, 1);
+ if (display_profile.empty())
+ display_profile = "/";
+ }
+
+ cout << std::left << std::setw(20) << (desc + ":") << display_profile << endl;
+
+ DepList d(&env);
+ d.set_reinstall(false);
+ d.set_drop_circular(true);
+
+ try
+ {
+ d.add(env.package_set("system"));
+
+ for (DepList::Iterator e(d.begin()), e_end(d.end()) ; e != e_end ; ++e)
+ cout << " " << e->name << "-" << e->version << ":" << e->metadata->slot << "::"
+ << e->repository << endl;
+ }
+ catch (const NoSuchPackageError & e)
+ {
+ cout << endl;
+ cerr << "Query error:" << endl;
+ cerr << " * " << e.backtrace("\n * ");
+ cerr << "No such package '" << e.name() << "'" << endl;
+
+ return_code |= 1;
+ }
+ catch (const DepListError & e)
+ {
+ cout << endl;
+ cerr << "Dependency error:" << endl;
+ cerr << " * " << e.backtrace("\n * ") << e.message() << " ("
+ << e.what() << ")" << endl;
+ cerr << endl;
+
+ return_code |= 1;
+ }
+
+ cout << endl;
+
+ return return_code;
+ }
+}
+
+int do_display_default_system_resolution(AdjutrixEnvironment & env)
+{
+ int return_code(0);
+
+ Context context("When performing display-default-system-resolution action:");
+
+ if (CommandLine::get_instance()->a_profile.args_begin() ==
+ CommandLine::get_instance()->a_profile.args_end())
+ {
+ LineConfigFile profiles_desc(env.main_repository_dir() / "profiles" / "profiles.desc");
+ {
+ for (LineConfigFile::Iterator line(profiles_desc.begin()), line_end(profiles_desc.end()) ;
+ line != line_end ; ++line)
+ {
+ std::vector<std::string> tokens;
+ WhitespaceTokeniser::get_instance()->tokenise(*line, std::back_inserter(tokens));
+
+ if (tokens.size() != 3)
+ {
+ Log::get_instance()->message(ll_warning, lc_context, "Skipping invalid line '"
+ + *line + "'");
+ continue;
+ }
+
+ env.set_profile(env.main_repository_dir() / "profiles" / tokens.at(1));
+ return_code |= display_default_system_resolution(env, tokens.at(0) + "." + tokens.at(2), env.main_repository_dir() /
+ "profiles" / tokens.at(1));
+ }
+ }
+ }
+ else
+ {
+ for (args::StringSetArg::Iterator i(CommandLine::get_instance()->a_profile.args_begin()),
+ i_end(CommandLine::get_instance()->a_profile.args_end()) ; i != i_end ; ++i)
+ {
+ env.set_profile(env.main_repository_dir() / "profiles" / (*i));
+ return_code |= display_default_system_resolution(env, *i, env.main_repository_dir() / "profiles" / *i);
+ }
+ }
+
+ return return_code;
+}
+
+
+
diff --git a/src/adjutrix/display_default_system_resolution.hh b/src/adjutrix/display_default_system_resolution.hh
new file mode 100644
index 0000000..f645e2a
--- /dev/null
+++ b/src/adjutrix/display_default_system_resolution.hh
@@ -0,0 +1,27 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 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_ADJUTRIX_DISPLAY_DEFAULT_SYSTEM_RESOLUTION_HH
+#define PALUDIS_GUARD_SRC_ADJUTRIX_DISPLAY_DEFAULT_SYSTEM_RESOLUTION_HH 1
+
+#include <adjutrix_environment.hh>
+
+int do_display_default_system_resolution(paludis::AdjutrixEnvironment & env);
+
+#endif
diff --git a/src/adjutrix/find_dropped_keywords.cc b/src/adjutrix/find_dropped_keywords.cc
index c32b573..e8e2643 100644
--- a/src/adjutrix/find_dropped_keywords.cc
+++ b/src/adjutrix/find_dropped_keywords.cc
@@ -172,6 +172,9 @@ void do_find_dropped_keywords(const Environment & env)
r(env.package_database()->begin_repositories()),
r_end(env.package_database()->end_repositories()) ; r != r_end ; ++r)
{
+ if (r->name() == RepositoryName("virtuals"))
+ continue;
+
write_repository_header(keyword, r->name());
CategoryNamePartCollection::ConstPointer cat_names(r->category_names());
diff --git a/src/adjutrix/find_stable_candidates.cc b/src/adjutrix/find_stable_candidates.cc
index 32034b6..9d26c7d 100644
--- a/src/adjutrix/find_stable_candidates.cc
+++ b/src/adjutrix/find_stable_candidates.cc
@@ -175,6 +175,9 @@ void do_find_stable_candidates(const Environment & env)
r(env.package_database()->begin_repositories()),
r_end(env.package_database()->end_repositories()) ; r != r_end ; ++r)
{
+ if (r->name() == RepositoryName("virtuals"))
+ continue;
+
write_repository_header(keyword, r->name());
CategoryNamePartCollection::ConstPointer cat_names(r->category_names());
diff --git a/src/adjutrix/keywords_graph.cc b/src/adjutrix/keywords_graph.cc
index 23cdcb1..35b1133 100644
--- a/src/adjutrix/keywords_graph.cc
+++ b/src/adjutrix/keywords_graph.cc
@@ -136,6 +136,9 @@ void do_keywords_graph(const Environment & env)
r(env.package_database()->begin_repositories()),
r_end(env.package_database()->end_repositories()) ; r != r_end ; ++r)
{
+ if (r->name() == RepositoryName("virtuals"))
+ continue;
+
CategoryNamePartCollection::ConstPointer cat_names(r->category_names());
for (CategoryNamePartCollection::Iterator c(cat_names->begin()), c_end(cat_names->end()) ;
c != c_end ; ++c)