aboutsummaryrefslogtreecommitdiff
path: root/0.8.0/src/paludis
diff options
context:
space:
mode:
Diffstat (limited to '0.8.0/src/paludis')
-rw-r--r--0.8.0/src/paludis/Makefile.am76
-rw-r--r--0.8.0/src/paludis/applets.cc197
-rw-r--r--0.8.0/src/paludis/applets.hh51
-rw-r--r--0.8.0/src/paludis/command_line.cc227
-rw-r--r--0.8.0/src/paludis/command_line.hh256
-rw-r--r--0.8.0/src/paludis/contents.cc155
-rw-r--r--0.8.0/src/paludis/contents.hh30
-rwxr-xr-x0.8.0/src/paludis/exception_TEST6
-rwxr-xr-x0.8.0/src/paludis/help_TEST3
-rw-r--r--0.8.0/src/paludis/install.cc915
-rw-r--r--0.8.0/src/paludis/install.hh32
-rwxr-xr-x0.8.0/src/paludis/install_TEST5
-rwxr-xr-x0.8.0/src/paludis/install_TEST_cleanup.sh11
-rwxr-xr-x0.8.0/src/paludis/install_TEST_setup.sh121
-rw-r--r--0.8.0/src/paludis/licence.cc66
-rw-r--r--0.8.0/src/paludis/licence.hh67
-rw-r--r--0.8.0/src/paludis/list.cc338
-rw-r--r--0.8.0/src/paludis/list.hh39
-rwxr-xr-x0.8.0/src/paludis/list_dep_tag_categories_TEST3
-rwxr-xr-x0.8.0/src/paludis/list_repository_formats_TEST3
-rwxr-xr-x0.8.0/src/paludis/list_sync_formats_TEST3
-rw-r--r--0.8.0/src/paludis/man_paludis.cc35
-rw-r--r--0.8.0/src/paludis/news.cc52
-rw-r--r--0.8.0/src/paludis/news.hh34
-rw-r--r--0.8.0/src/paludis/owner.cc133
-rw-r--r--0.8.0/src/paludis/owner.hh30
-rw-r--r--0.8.0/src/paludis/paludis.cc443
-rw-r--r--0.8.0/src/paludis/query.cc418
-rw-r--r--0.8.0/src/paludis/query.hh32
-rw-r--r--0.8.0/src/paludis/sync.cc129
-rw-r--r--0.8.0/src/paludis/sync.hh33
-rw-r--r--0.8.0/src/paludis/uninstall.cc185
-rw-r--r--0.8.0/src/paludis/uninstall.hh33
-rwxr-xr-x0.8.0/src/paludis/upgrade_TEST17
-rwxr-xr-x0.8.0/src/paludis/upgrade_TEST_cleanup.sh11
-rwxr-xr-x0.8.0/src/paludis/upgrade_TEST_setup.sh153
-rw-r--r--0.8.0/src/paludis/use.cc125
-rw-r--r--0.8.0/src/paludis/use.hh36
-rwxr-xr-x0.8.0/src/paludis/version_TEST3
39 files changed, 4506 insertions, 0 deletions
diff --git a/0.8.0/src/paludis/Makefile.am b/0.8.0/src/paludis/Makefile.am
new file mode 100644
index 0000000..4185f88
--- /dev/null
+++ b/0.8.0/src/paludis/Makefile.am
@@ -0,0 +1,76 @@
+AM_CXXFLAGS = -I$(top_srcdir) -I$(top_srcdir)/src @PALUDIS_CXXFLAGS@
+DEFS= \
+ -DSYSCONFDIR=\"$(sysconfdir)\" \
+ -DDATADIR=\"$(datadir)\" \
+ -DLIBEXECDIR=\"$(libexecdir)\" \
+ -DLIBDIR=\"$(libdir)\"
+
+SUBDIRS = .
+
+bin_PROGRAMS = paludis
+noinst_PROGRAMS = man-paludis
+
+man_MANS = paludis.1
+
+paludis.1 : man-paludis
+ ./man-paludis | tee $@ | sed -e 's/^/ /'
+
+man_paludis_SOURCES = \
+ man_paludis.cc \
+ command_line.hh \
+ command_line.cc
+
+man_paludis_LDADD = \
+ $(top_builddir)/paludis/args/libpaludisargs.la \
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(top_builddir)/src/libcolour.a \
+ $(DYNAMIC_LD_LIBS)
+
+paludis_SOURCES = \
+ applets.hh applets.cc \
+ command_line.hh command_line.cc \
+ install.hh install.cc \
+ uninstall.hh uninstall.cc \
+ list.hh list.cc \
+ query.hh query.cc \
+ sync.hh sync.cc \
+ licence.hh licence.cc \
+ use.hh use.cc \
+ contents.hh contents.cc \
+ owner.hh owner.cc \
+ news.hh news.cc \
+ paludis.cc
+
+paludis_LDADD = \
+ $(top_builddir)/paludis/tasks/libpaludistasks.a \
+ $(top_builddir)/paludis/libpaludis.la \
+ $(top_builddir)/paludis/args/libpaludisargs.la \
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(top_builddir)/paludis/environment/default/libpaludisdefaultenvironment.la \
+ $(top_builddir)/src/libcolour.a \
+ $(DYNAMIC_LD_LIBS)
+
+TESTS_ENVIRONMENT = env \
+ TEST_SCRIPT_DIR="$(srcdir)/" \
+ PALUDIS_NO_GLOBAL_HOOKS="yes" \
+ PALUDIS_NO_XTERM_TITLES="yes" \
+ PALUDIS_EBUILD_DIR="`$(top_srcdir)/ebuild/utils/canonicalise $(top_srcdir)/ebuild/`" \
+ PALUDIS_EBUILD_DIR_FALLBACK="`$(top_srcdir)/ebuild/utils/canonicalise $(top_builddir)/ebuild/`" \
+ PALUDIS_REPOSITORY_SO_DIR="`$(top_srcdir)/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories`" \
+ SYSCONFDIR="$(sysconfdir)" \
+ bash $(top_srcdir)/test/run_test.sh bash
+
+TESTS = version_TEST help_TEST list_sync_formats_TEST \
+ list_repository_formats_TEST list_dep_tag_categories_TEST \
+ exception_TEST install_TEST upgrade_TEST
+
+EXTRA_DIST = \
+ $(man_MANS) \
+ $(TESTS) \
+ install_TEST_setup.sh install_TEST_cleanup.sh \
+ upgrade_TEST_setup.sh upgrade_TEST_cleanup.sh
+
+CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda
+DISTCLEANFILES = $(man_MANS)
+MAINTAINERCLEANFILES = Makefile.in
+
diff --git a/0.8.0/src/paludis/applets.cc b/0.8.0/src/paludis/applets.cc
new file mode 100644
index 0000000..43d8f00
--- /dev/null
+++ b/0.8.0/src/paludis/applets.cc
@@ -0,0 +1,197 @@
+/* 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 "applets.hh"
+#include "colour.hh"
+#include <functional>
+#include <iomanip>
+#include <iostream>
+#include <paludis/paludis.hh>
+#include <paludis/environment/default/default_environment.hh>
+#include <string>
+#include <set>
+
+/** \file
+ * Handle the --has-version, --best-version and various --list actions for the
+ * main paludis program.
+ */
+
+namespace p = paludis;
+
+int do_has_version()
+{
+ int return_code(0);
+
+ p::Context context("When performing has-version action from command line:");
+ p::Environment * const env(p::DefaultEnvironment::get_instance());
+
+ std::string query(*CommandLine::get_instance()->begin_parameters());
+ p::PackageDepAtom::Pointer atom(new p::PackageDepAtom(query));
+ p::PackageDatabaseEntryCollection::ConstPointer entries(env->package_database()->query(
+ atom, p::is_installed_only));
+ if (entries->empty())
+ return_code = 1;
+
+ return return_code;
+}
+
+int do_best_version()
+{
+ int return_code(0);
+
+ p::Context context("When performing best-version action from command line:");
+ p::Environment * const env(p::DefaultEnvironment::get_instance());
+
+ std::string query(*CommandLine::get_instance()->begin_parameters());
+ p::PackageDepAtom::Pointer atom(new p::PackageDepAtom(query));
+ p::PackageDatabaseEntryCollection::ConstPointer entries(env->package_database()->query(
+ atom, p::is_installed_only));
+ if (entries->empty())
+ return_code = 1;
+ else
+ {
+ // don't include repo, it breaks built_with_use and the like.
+ std::string entry(
+ stringify(entries->last()->name) + "-" +
+ stringify(entries->last()->version));
+ std::cout << entry << std::endl;
+ }
+
+ return return_code;
+}
+
+int do_environment_variable()
+{
+ int return_code(0);
+
+ p::Context context("When performing environment-variable action from command line:");
+ p::Environment * const env(p::DefaultEnvironment::get_instance());
+
+ std::string atom_str(*CommandLine::get_instance()->begin_parameters());
+ std::string var_str(* p::next(CommandLine::get_instance()->begin_parameters()));
+ p::PackageDepAtom::Pointer atom(new p::PackageDepAtom(atom_str));
+
+ p::PackageDatabaseEntryCollection::ConstPointer entries(env->package_database()->query(
+ atom, p::is_installed_only));
+
+ if (entries->empty())
+ entries = env->package_database()->query(atom, p::is_uninstalled_only);
+
+ if (entries->empty())
+ throw p::NoSuchPackageError(atom_str);
+
+ p::Repository::ConstPointer repo(env->package_database()->fetch_repository(
+ entries->begin()->repository));
+ p::RepositoryEnvironmentVariableInterface * env_if(
+ repo->environment_variable_interface);
+
+ if (! env_if)
+ {
+ std::cerr << "Repository '" << repo->name() <<
+ "' cannot be queried for environment variables" << std::endl;
+ return_code |= 1;
+ }
+ else
+ std::cout << env_if->get_environment_variable(*entries->begin(), var_str) << std::endl;
+
+ return return_code;
+}
+
+int do_configuration_variable()
+{
+ int return_code(0);
+
+ p::Context context("When performing configuration-variable action from command line:");
+ p::Environment * const env(p::DefaultEnvironment::get_instance());
+
+ std::string repo_str(*CommandLine::get_instance()->begin_parameters());
+ std::string var_str(* p::next(CommandLine::get_instance()->begin_parameters()));
+
+ p::RepositoryInfo::ConstPointer info(env->package_database()->fetch_repository(
+ p::RepositoryName(repo_str))->info(false));
+
+ return_code = 1;
+ for (p::RepositoryInfo::SectionIterator s(info->begin_sections()),
+ s_end(info->end_sections()) ; s != s_end ; ++s)
+ for (p::RepositoryInfoSection::KeyValueIterator k((*s)->begin_kvs()),
+ k_end((*s)->end_kvs()) ; k != k_end ; ++k)
+ if (var_str == k->first)
+ {
+ std::cout << k->second << std::endl;
+ return_code = 0;
+ break;
+ }
+
+ return return_code;
+}
+
+int do_list_repository_formats()
+{
+ int return_code(1);
+
+ std::set<std::string> keys;
+ p::RepositoryMaker::get_instance()->copy_keys(std::inserter(keys, keys.begin()));
+
+ if (! keys.empty())
+ {
+ return_code = 0;
+ for (std::set<std::string>::const_iterator k(keys.begin()), k_end(keys.end()) ;
+ k != k_end ; ++k)
+ std::cout << "* " << colour(cl_key_name, *k) << std::endl;
+ }
+
+ return return_code;
+}
+
+int do_list_sync_protocols()
+{
+ int return_code(1);
+
+ std::set<std::string> keys;
+ p::SyncerMaker::get_instance()->copy_keys(std::inserter(keys, keys.begin()));
+
+ if (! keys.empty())
+ {
+ return_code = 0;
+ for (std::set<std::string>::const_iterator k(keys.begin()), k_end(keys.end()) ;
+ k != k_end ; ++k)
+ std::cout << "* " << colour(cl_key_name, *k) << std::endl;
+ }
+
+ return return_code;
+}
+
+int do_list_dep_tag_categories()
+{
+ int return_code(1);
+
+ std::set<std::string> keys;
+ p::DepTagCategoryMaker::get_instance()->copy_keys(std::inserter(keys, keys.begin()));
+
+ if (! keys.empty())
+ {
+ return_code = 0;
+ for (std::set<std::string>::const_iterator k(keys.begin()), k_end(keys.end()) ;
+ k != k_end ; ++k)
+ std::cout << "* " << colour(cl_key_name, *k) << std::endl;
+ }
+
+ return return_code;
+}
+
diff --git a/0.8.0/src/paludis/applets.hh b/0.8.0/src/paludis/applets.hh
new file mode 100644
index 0000000..108b962
--- /dev/null
+++ b/0.8.0/src/paludis/applets.hh
@@ -0,0 +1,51 @@
+/* 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_APPLETS_HH
+#define PALUDIS_GUARD_SRC_APPLETS_HH 1
+
+#include "command_line.hh"
+
+/** \file
+ * Declaration for small do_* functions.
+ */
+
+/// Handle --has-version.
+int do_has_version();
+
+/// Handle --best-version.
+int do_best_version();
+
+/// Handle --environment-variable.
+int do_environment_variable();
+
+/// Handle --configuration-variable.
+int do_configuration_variable();
+
+/// Handle --list-repository-formats
+int do_list_repository_formats();
+
+/// Handle --list-sync-protocols
+int do_list_sync_protocols();
+
+/// Handle --list-dep-tag-categories
+int do_list_dep_tag_categories();
+
+#endif
+
diff --git a/0.8.0/src/paludis/command_line.cc b/0.8.0/src/paludis/command_line.cc
new file mode 100644
index 0000000..a3b10c0
--- /dev/null
+++ b/0.8.0/src/paludis/command_line.cc
@@ -0,0 +1,227 @@
+/* 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 "command_line.hh"
+
+CommandLine::CommandLine() :
+ ArgsHandler(),
+
+ action_args(this, "Actions",
+ "Selects which basic action to perform. Exactly one action should "
+ "be specified."),
+ a_query(&action_args, "query", 'q', "Query for package information"),
+ a_install(&action_args, "install", 'i', "Install one or more packages"),
+ a_uninstall(&action_args, "uninstall", 'u', "Uninstall one or more packages"),
+ a_sync(&action_args, "sync", 's', "Sync all or specified repositories"),
+ a_contents(&action_args, "contents", 'k', "Display contents of a package"),
+ a_owner(&action_args, "owner", 'o', "Display the owner of a file"),
+ a_version(&action_args, "version", 'V', "Display program version"),
+ a_info(&action_args, "info", 'I', "Display program version and system information"),
+ a_help(&action_args, "help", 'h', "Display program help"),
+
+ action_args_internal(this, "More actions",
+ "Additional actions, mostly for script and internal use."),
+ a_has_version(&action_args_internal, "has-version", '\0', "Check whether the specified atom is installed"),
+ a_best_version(&action_args_internal, "best-version", '\0', "Display the best version of the specified atom"),
+ a_environment_variable(&action_args_internal, "environment-variable", '\0', "Display the value of an environment "
+ "variable for a particular package"),
+ a_configuration_variable(&action_args_internal, "configuration-variable", '\0', "Display the value of a "
+ "configuration variable for a particular repository"),
+ a_list_repositories(&action_args_internal, "list-repositories", '\0', "List available repositories"),
+ a_list_categories(&action_args_internal, "list-categories", '\0', "List available categories"),
+ a_list_packages(&action_args_internal, "list-packages", '\0', "List available packages"),
+ a_list_sets(&action_args_internal, "list-sets", '\0', "List available package sets"),
+ a_list_sync_protocols(&action_args_internal, "list-sync-protocols", '\0', "List available sync protocols"),
+ a_list_repository_formats(&action_args_internal, "list-repository-formats", '\0',
+ "List available repository formats"),
+ a_list_dep_tag_categories(&action_args_internal, "list-dep-tag-categories", '\0', "List known dep tag categories"),
+ a_update_news(&action_args_internal, "update-news", '\0', "Regenerate news.unread files"),
+
+ general_args(this, "General options",
+ "Options which are relevant for most or all actions."),
+ a_log_level(&general_args, "log-level", '\0', "Specify the log level",
+ paludis::args::EnumArg::EnumArgOptions("debug", "Show debug output (noisy)")
+ ("qa", "Show QA messages and warnings only")
+ ("warning", "Show warnings only")
+ ("silent", "Suppress all log messages"),
+ "qa"),
+ a_no_colour(&general_args, "no-colour", '\0', "Do not use colour"),
+ a_no_color(&a_no_colour, "no-color"),
+ a_config_suffix(&general_args, "config-suffix", 'c', "Config directory suffix"),
+
+ query_args(this, "Query options",
+ "Options which are relevant for --query."),
+ a_show_slot(&query_args, "show-slot", 'S', "Show SLOTs"),
+ a_show_deps(&query_args, "show-deps", 'D', "Show dependencies"),
+ a_show_metadata(&query_args, "show-metadata", 'M', "Show raw metadata"),
+
+ install_args(this, "Install, Uninstall options",
+ "Options which are relevant for --install or --uninstall."),
+ a_pretend(&install_args, "pretend", 'p', "Pretend only"),
+ 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."),
+
+ dl_reinstall(&dl_args, "dl-reinstall", '\0', "When to reinstall packages",
+ paludis::args::EnumArg::EnumArgOptions
+ ("never", "Never")
+ ("always", "Always")
+ ("if-use-changed", "If USE flags have changed"),
+ "never"),
+ dl_upgrade(&dl_args, "dl-upgrade", '\0', "When to upgrade packages",
+ paludis::args::EnumArg::EnumArgOptions
+ ("always", "Always")
+ ("as-needed", "As needed"),
+ "always"),
+
+ dl_installed_deps_pre(&dl_args, "dl-installed-deps-pre", '\0', "How to handle pre dependencies for installed packages",
+ paludis::args::EnumArg::EnumArgOptions
+ ("pre", "As pre dependencies")
+ ("pre-or-post", "As pre dependencies, or post depenencies where needed")
+ ("post", "As post dependencies")
+ ("try-post", "As post dependencies, with no error for failures")
+ ("discard", "Discard"),
+ "discard"),
+ dl_installed_deps_runtime(&dl_args, "dl-installed-deps-runtime", '\0', "How to handle runtime dependencies for installed packages",
+ paludis::args::EnumArg::EnumArgOptions
+ ("pre", "As pre dependencies")
+ ("pre-or-post", "As pre dependencies, or post depenencies where needed")
+ ("post", "As post dependencies")
+ ("try-post", "As post dependencies, with no error for failures")
+ ("discard", "Discard"),
+ "try-post"),
+ dl_installed_deps_post(&dl_args, "dl-installed-deps-post", '\0', "How to handle post dependencies for installed packages",
+ paludis::args::EnumArg::EnumArgOptions
+ ("pre", "As pre dependencies")
+ ("pre-or-post", "As pre dependencies, or post depenencies where needed")
+ ("post", "As post dependencies")
+ ("try-post", "As post dependencies, with no error for failures")
+ ("discard", "Discard"),
+ "try-post"),
+
+ dl_uninstalled_deps_pre(&dl_args, "dl-uninstalled-deps-pre", '\0', "How to handle pre dependencies for uninstalled packages",
+ paludis::args::EnumArg::EnumArgOptions
+ ("pre", "As pre dependencies")
+ ("pre-or-post", "As pre dependencies, or post depenencies where needed")
+ ("post", "As post dependencies")
+ ("try-post", "As post dependencies, with no error for failures")
+ ("discard", "Discard"),
+ "pre"),
+ dl_uninstalled_deps_runtime(&dl_args, "dl-uninstalled-deps-runtime", '\0', "How to handle runtime dependencies for uninstalled packages",
+ paludis::args::EnumArg::EnumArgOptions
+ ("pre", "As pre dependencies")
+ ("pre-or-post", "As pre dependencies, or post depenencies where needed")
+ ("post", "As post dependencies")
+ ("try-post", "As post dependencies, with no error for failures")
+ ("discard", "Discard"),
+ "pre-or-post"),
+ dl_uninstalled_deps_post(&dl_args, "dl-uninstalled-deps-post", '\0', "How to handle post dependencies for uninstalled packages",
+ paludis::args::EnumArg::EnumArgOptions
+ ("pre", "As pre dependencies")
+ ("pre-or-post", "As pre dependencies, or post depenencies where needed")
+ ("post", "As post dependencies")
+ ("try-post", "As post dependencies, with no error for failures")
+ ("discard", "Discard"),
+ "post"),
+
+ dl_circular(&dl_args, "dl-circular", '\0', "How to handle circular dependencies",
+ paludis::args::EnumArg::EnumArgOptions
+ ("error", "Raise an error")
+ ("discard", "Discard"),
+ "error"),
+
+ list_args(this, "List options",
+ "Options relevant for one or more of the --list actions."),
+ a_repository(&list_args, "repository", '\0', "Matches with this repository name only"),
+ a_category(&list_args, "category", '\0', "Matches with this category name only"),
+ a_package(&list_args, "package", '\0', "Matches with this package name only"),
+ a_set(&list_args, "set", '\0', "Matches with this package set name only"),
+
+ owner_args(this, "Owner options",
+ "Options relevant for the --owner actions."),
+ a_full_match(&owner_args, "full-match", '\0', "Match whole filename")
+{
+ add_usage_line("--query [query options] target ...");
+ add_usage_line("--install [install options] target ...");
+ add_usage_line("--sync [target (leave blank for all)]");
+ add_usage_line("--contents target ...");
+ add_usage_line("--owner [owner options] files ...");
+ add_usage_line("--version");
+ add_usage_line("--info");
+ add_usage_line("--help");
+
+ add_usage_line("--has-version atom");
+ add_usage_line("--best-version atom");
+ add_usage_line("--environment-variable atom variable");
+ add_usage_line("--configuration-variable repository variable");
+ add_usage_line("--list-repositories [--repository repo1 --repository repo2 ...]");
+ add_usage_line("--list-categories [--repository repo1 ... --category cat1 --category cat2 ...]");
+ add_usage_line("--list-packages [--repository repo1 ... --category cat1 ... --package pkg1 --package pkg2 ...]");
+ add_usage_line("--list-sets [--repository repo1 ... --set set1 ...]");
+ add_usage_line("--list-sync-protocols");
+ add_usage_line("--list-repository-formats");
+ add_usage_line("--list-dep-tag-categories");
+ add_usage_line("--update-news");
+
+ add_enviromnent_variable("PALUDIS_HOME", "Overrides the home directory used when searching "
+ "for configuration files etc.");
+ add_enviromnent_variable("PALUDIS_NO_GLOBAL_HOOKS", "Don't use global hooks. Mostly for "
+ "internal and test case use.");
+ add_enviromnent_variable("PALUDIS_SKIP_CONFIG", "Don't load configuration. Mostly for "
+ "internal and test case use.");
+ add_enviromnent_variable("PALUDIS_EBUILD_DIR", "Where to look for ebuild.bash and related "
+ "utilities.");
+ add_enviromnent_variable("PALUDIS_REPOSITORY_SO_DIR", "Where to look for repository .so "
+ "files.");
+}
+
+std::string
+CommandLine::app_name() const
+{
+ return "paludis";
+}
+
+std::string
+CommandLine::app_synopsis() const
+{
+ return "The other package mangler";
+}
+
+std::string
+CommandLine::app_description() const
+{
+ return
+ "paludis is the command line interface used to handle packages. It can query and "
+ "install packages, update repositories and display information about packages "
+ "already installed on a system.";
+}
+
+CommandLine::~CommandLine()
+{
+}
+
diff --git a/0.8.0/src/paludis/command_line.hh b/0.8.0/src/paludis/command_line.hh
new file mode 100644
index 0000000..bd60b6c
--- /dev/null
+++ b/0.8.0/src/paludis/command_line.hh
@@ -0,0 +1,256 @@
+/* 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_COMMAND_LINE_HH
+#define PALUDIS_GUARD_SRC_COMMAND_LINE_HH 1
+
+#include <paludis/args/args.hh>
+#include <paludis/util/instantiation_policy.hh>
+
+/** \file
+ * Declarations for the CommandLine class.
+ */
+
+/**
+ * Our command line.
+ */
+class CommandLine :
+ public paludis::args::ArgsHandler,
+ public paludis::InstantiationPolicy<CommandLine, paludis::instantiation_method::SingletonAsNeededTag>
+{
+ friend class paludis::InstantiationPolicy<CommandLine, paludis::instantiation_method::SingletonAsNeededTag>;
+
+ private:
+ /// Constructor.
+ CommandLine();
+
+ /// Destructor.
+ ~CommandLine();
+
+ public:
+ ///\name Program information
+ ///\{
+
+ virtual std::string app_name() const;
+ virtual std::string app_synopsis() const;
+ virtual std::string app_description() const;
+
+ ///\}
+
+ /// \name Action arguments
+ ///{
+
+ /// Action arguments.
+ paludis::args::ArgsGroup action_args;
+
+ /// --query
+ paludis::args::SwitchArg a_query;
+
+ /// --install
+ paludis::args::SwitchArg a_install;
+
+ /// --uninstall
+ paludis::args::SwitchArg a_uninstall;
+
+ /// --sync
+ paludis::args::SwitchArg a_sync;
+
+ /// --contents
+ paludis::args::SwitchArg a_contents;
+
+ /// --owner
+ paludis::args::SwitchArg a_owner;
+
+ /// --version
+ paludis::args::SwitchArg a_version;
+
+ /// --info
+ paludis::args::SwitchArg a_info;
+
+ /// --help
+ paludis::args::SwitchArg a_help;
+
+ /// Action arguments (internal).
+ paludis::args::ArgsGroup action_args_internal;
+
+ /// --has-version
+ paludis::args::SwitchArg a_has_version;
+
+ /// --best-version
+ paludis::args::SwitchArg a_best_version;
+
+ /// --environment-variable
+ paludis::args::SwitchArg a_environment_variable;
+
+ /// --configuration-variable
+ paludis::args::SwitchArg a_configuration_variable;
+
+ /// --list-repositories
+ paludis::args::SwitchArg a_list_repositories;
+
+ /// --list-categories
+ paludis::args::SwitchArg a_list_categories;
+
+ /// --list-packages
+ paludis::args::SwitchArg a_list_packages;
+
+ /// --list-sets
+ paludis::args::SwitchArg a_list_sets;
+
+ /// --list-sync-protocols
+ paludis::args::SwitchArg a_list_sync_protocols;
+
+ /// --list-repository-formats
+ paludis::args::SwitchArg a_list_repository_formats;
+
+ /// --list-dep-tag-categories
+ paludis::args::SwitchArg a_list_dep_tag_categories;
+
+ /// --update-news
+ paludis::args::SwitchArg a_update_news;
+
+ ///}
+
+ /// \name General arguments
+ ///{
+
+ /// General arguments.
+ paludis::args::ArgsGroup general_args;
+
+ /// --log-level
+ paludis::args::EnumArg a_log_level;
+
+ /// --no-colour
+ paludis::args::SwitchArg a_no_colour;
+
+ /// --no-color
+ paludis::args::AliasArg a_no_color;
+
+ /// --config-suffix
+ paludis::args::StringArg a_config_suffix;
+
+ ///}
+
+ /// \name Query arguments
+ ///{
+
+ /// Query arguments.
+ paludis::args::ArgsGroup query_args;
+
+ /// --show-slot
+ paludis::args::SwitchArg a_show_slot;
+
+ /// --show-deps
+ paludis::args::SwitchArg a_show_deps;
+
+ /// --show-metadata
+ paludis::args::SwitchArg a_show_metadata;
+
+ /// }
+
+ /// \name (Un)Install arguments
+ /// {
+
+ /// Install arguments.
+ paludis::args::ArgsGroup install_args;
+
+ /// --pretend
+ paludis::args::SwitchArg a_pretend;
+
+ /// --preserve-world
+ paludis::args::SwitchArg a_preserve_world;
+
+ /// --no-config-protection
+ paludis::args::SwitchArg a_no_config_protection;
+
+ /// --fetch
+ paludis::args::SwitchArg a_fetch;
+
+ /// --show-install-reasons
+ paludis::args::EnumArg a_show_install_reasons;
+
+ /// }
+
+ /// \name DepList behaviour arguments
+ /// {
+
+ /// DepList behaviour arguments.
+ paludis::args::ArgsGroup dl_args;
+
+ paludis::args::EnumArg dl_reinstall;
+ paludis::args::EnumArg dl_upgrade;
+
+ paludis::args::EnumArg dl_installed_deps_pre;
+ paludis::args::EnumArg dl_installed_deps_runtime;
+ paludis::args::EnumArg dl_installed_deps_post;
+
+ paludis::args::EnumArg dl_uninstalled_deps_pre;
+ paludis::args::EnumArg dl_uninstalled_deps_runtime;
+ paludis::args::EnumArg dl_uninstalled_deps_post;
+
+ paludis::args::EnumArg dl_circular;
+
+ /// }
+
+ /// \name List arguments
+ /// {
+
+ /// List arguments.
+ paludis::args::ArgsGroup list_args;
+
+ /// --repository
+ paludis::args::StringSetArg a_repository;
+
+ /// --category
+ paludis::args::StringSetArg a_category;
+
+ /// --package
+ paludis::args::StringSetArg a_package;
+
+ /// --set
+ paludis::args::StringSetArg a_set;
+
+ /// }
+
+ /// \name Owner arguments
+ /// {
+
+ /// Owner arguments.
+ paludis::args::ArgsGroup owner_args;
+
+ /// --full-match
+ paludis::args::SwitchArg a_full_match;
+
+ /// }
+};
+
+/**
+ * Show the help message.
+ */
+struct DoHelp
+{
+ const std::string message;
+
+ DoHelp(const std::string & m = "") :
+ message(m)
+ {
+ }
+};
+
+#endif
diff --git a/0.8.0/src/paludis/contents.cc b/0.8.0/src/paludis/contents.cc
new file mode 100644
index 0000000..ca9efc0
--- /dev/null
+++ b/0.8.0/src/paludis/contents.cc
@@ -0,0 +1,155 @@
+/* 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 "contents.hh"
+#include "colour.hh"
+#include "command_line.hh"
+#include <paludis/paludis.hh>
+#include <paludis/environment/default/default_environment.hh>
+#include <iostream>
+#include <algorithm>
+
+namespace p = paludis;
+using std::cout;
+using std::cerr;
+using std::endl;
+
+namespace
+{
+ struct ContentsDisplayer :
+ p::ContentsVisitorTypes::ConstVisitor
+ {
+ void visit(const p::ContentsFileEntry * const e)
+ {
+ cout << " " << colour(cl_file, e->name()) << endl;
+ }
+
+ void visit(const p::ContentsDirEntry * const e)
+ {
+ cout << " " << colour(cl_dir, e->name()) << endl;
+ }
+
+ void visit(const p::ContentsSymEntry * const e)
+ {
+ cout << " " << colour(cl_sym, e->name()) << " -> " << e->target() << endl;
+ }
+
+ void visit(const p::ContentsMiscEntry * const e)
+ {
+ cout << " " << colour(cl_misc, e->name()) << endl;
+ }
+ };
+}
+
+void
+do_one_contents_entry(
+ const p::Environment * const env,
+ const p::PackageDatabaseEntry & e)
+{
+ cout << "* " << colour(cl_package_name, e) << endl;
+
+ const p::RepositoryInstalledInterface * const installed_interface(
+ env->package_database()->fetch_repository(e.repository)->
+ installed_interface);
+ if (installed_interface)
+ {
+ p::Contents::ConstPointer contents(installed_interface->contents(
+ e.name, e.version));
+ ContentsDisplayer d;
+ std::for_each(contents->begin(), contents->end(), accept_visitor(&d));
+ }
+ else
+ cout << " " << colour(cl_error, "(unknown)") << endl;
+
+ cout << endl;
+}
+
+void
+do_one_contents(
+ const p::Environment * const env,
+ const std::string & q)
+{
+ p::Context local_context("When handling query '" + q + "':");
+
+ /* we might have a dep atom, but we might just have a simple package name
+ * without a category. either should work. */
+ p::PackageDepAtom::Pointer atom(std::string::npos == q.find('/') ?
+ new p::PackageDepAtom(env->package_database()->fetch_unique_qualified_package_name(
+ p::PackageNamePart(q))) :
+ new p::PackageDepAtom(q));
+
+ p::PackageDatabaseEntryCollection::ConstPointer
+ entries(env->package_database()->query(atom, p::is_installed_only));
+
+ if (entries->empty())
+ throw p::NoSuchPackageError(q);
+
+ for (p::PackageDatabaseEntryCollection::Iterator i(entries->begin()),
+ i_end(entries->end()) ; i != i_end ; ++i)
+ do_one_contents_entry(env, *i);
+}
+
+int
+do_contents()
+{
+ int return_code(0);
+
+ p::Context context("When performing contents action from command line:");
+ p::Environment * const env(p::DefaultEnvironment::get_instance());
+
+ CommandLine::ParametersIterator q(CommandLine::get_instance()->begin_parameters()),
+ q_end(CommandLine::get_instance()->end_parameters());
+ for ( ; q != q_end ; ++q)
+ {
+ try
+ {
+ do_one_contents(env, *q);
+ }
+ catch (const p::AmbiguousPackageNameError & e)
+ {
+ cout << endl;
+ cerr << "Query error:" << endl;
+ cerr << " * " << e.backtrace("\n * ");
+ cerr << "Ambiguous package name '" << e.name() << "'. Did you mean:" << endl;
+ for (p::AmbiguousPackageNameError::OptionsIterator o(e.begin_options()),
+ o_end(e.end_options()) ; o != o_end ; ++o)
+ cerr << " * " << colour(cl_package_name, *o) << endl;
+ cerr << endl;
+ }
+ catch (const p::NameError & e)
+ {
+ return_code |= 1;
+ cout << endl;
+ cerr << "Query error:" << endl;
+ cerr << " * " << e.backtrace("\n * ") << e.message() << endl;
+ cerr << endl;
+ }
+ catch (const p::PackageDatabaseLookupError & e)
+ {
+ return_code |= 1;
+ cout << endl;
+ cerr << "Query error:" << endl;
+ cerr << " * " << e.backtrace("\n * ") << e.message() << endl;
+ cerr << endl;
+ }
+ }
+
+ return return_code;
+}
+
diff --git a/0.8.0/src/paludis/contents.hh b/0.8.0/src/paludis/contents.hh
new file mode 100644
index 0000000..5cf38e3
--- /dev/null
+++ b/0.8.0/src/paludis/contents.hh
@@ -0,0 +1,30 @@
+/* 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_CONTENTS_HH
+#define PALUDIS_GUARD_SRC_CONTENTS_HH 1
+
+/** \file
+ * Declaration for the do_contents function.
+ */
+
+/// Handle --contents.
+int do_contents();
+
+#endif
diff --git a/0.8.0/src/paludis/exception_TEST b/0.8.0/src/paludis/exception_TEST
new file mode 100755
index 0000000..a3daaaf
--- /dev/null
+++ b/0.8.0/src/paludis/exception_TEST
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+PALUDIS_HOME=./ \
+ ./paludis --config-suffix paludis-build-test -pi asdf 2>&1 \
+ | grep 'Default configuration error' >/dev/null
+
diff --git a/0.8.0/src/paludis/help_TEST b/0.8.0/src/paludis/help_TEST
new file mode 100755
index 0000000..3a0f5fb
--- /dev/null
+++ b/0.8.0/src/paludis/help_TEST
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+PALUDIS_SKIP_CONFIG=yes ./paludis --help
diff --git a/0.8.0/src/paludis/install.cc b/0.8.0/src/paludis/install.cc
new file mode 100644
index 0000000..5de8260
--- /dev/null
+++ b/0.8.0/src/paludis/install.cc
@@ -0,0 +1,915 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 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 "colour.hh"
+#include "install.hh"
+#include "licence.hh"
+#include "use.hh"
+
+#include <iostream>
+#include <limits>
+#include <set>
+
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include <paludis/tasks/install_task.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/tokeniser.hh>
+#include <paludis/environment/default/default_environment.hh>
+
+/** \file
+ * Handle the --install action for the main paludis program.
+ */
+
+using namespace paludis;
+
+using std::cerr;
+using std::cout;
+using std::endl;
+
+namespace
+{
+ struct TagDisplayer :
+ DepTagVisitorTypes::ConstVisitor
+ {
+ void visit(const GLSADepTag * const tag)
+ {
+ cout << "* " << colour(cl_tag, tag->short_text()) << ": "
+ << tag->glsa_title() << endl;
+ }
+
+ void visit(const DependencyDepTag * const)
+ {
+ }
+
+ void visit(const GeneralSetDepTag * const tag)
+ {
+ cout << "* " << colour(cl_tag, tag->short_text());
+ if (tag->short_text() == "world")
+ cout << ": " << "Packages that have been explicitly installed";
+ else if (tag->short_text() == "everything")
+ cout << ": " << "All installed packages";
+ else if (tag->short_text() == "system")
+ cout << ": " << "Packages that are part of the base system";
+ cout << endl;
+ }
+ };
+
+ class OurInstallTask :
+ public InstallTask
+ {
+ private:
+ int _current_count, _max_count, _new_count, _upgrade_count,
+ _downgrade_count, _new_slot_count, _rebuild_count,
+ _current_virtual_count, _max_virtual_count, _new_virtual_count,
+ _upgrade_virtual_count, _downgrade_virtual_count,
+ _new_slot_virtual_count, _rebuild_virtual_count;
+
+ std::set<DepTagEntry> _all_tags;
+
+ public:
+ OurInstallTask(const DepListOptions & options) :
+ InstallTask(DefaultEnvironment::get_instance(), options),
+ _current_count(0),
+ _max_count(0),
+ _new_count(0),
+ _upgrade_count(0),
+ _downgrade_count(0),
+ _new_slot_count(0),
+ _rebuild_count(0),
+ _current_virtual_count(0),
+ _max_virtual_count(0),
+ _new_virtual_count(0),
+ _upgrade_virtual_count(0),
+ _downgrade_virtual_count(0),
+ _new_slot_virtual_count(0),
+ _rebuild_virtual_count(0)
+ {
+ }
+
+ void on_build_deplist_pre()
+ {
+ cout << "Building dependency list... " << std::flush;
+ }
+
+ virtual void on_build_deplist_post()
+ {
+ cout << "done" << endl;
+ }
+
+ virtual void on_build_cleanlist_pre(const DepListEntry & d)
+ {
+ cout << endl << colour(cl_heading, "Cleaning stale versions after installing " +
+ stringify(d.package.name) + "-" + stringify(d.package.version) +
+ "::" + stringify(d.package.repository)) << endl << endl;
+ }
+
+ virtual void on_build_cleanlist_post(const DepListEntry &)
+ {
+ }
+
+ virtual void on_clean_all_pre(const DepListEntry &,
+ const PackageDatabaseEntryCollection & c)
+ {
+ if (c.empty())
+ cout << "* No cleaning required" << endl;
+ else
+ {
+ for (PackageDatabaseEntryCollection::Iterator cc(c.begin()),
+ cc_end(c.end()) ; cc != cc_end ; ++cc)
+ cout << "* " << colour(cl_package_name, *cc) << endl;
+ }
+ cout << endl;
+ }
+
+ virtual void on_clean_pre(const DepListEntry &,
+ const PackageDatabaseEntry & c)
+ {
+ cout << colour(cl_heading, "Cleaning " + stringify(c)) << endl << endl;
+
+ cerr << xterm_title("(" + stringify(_current_count) + " of " +
+ stringify(_max_count + _max_virtual_count) + ") Cleaning " + stringify(c));
+ }
+
+ virtual void on_clean_post(const DepListEntry &,
+ const PackageDatabaseEntry &)
+ {
+ }
+
+ virtual void on_clean_all_post(const DepListEntry &,
+ const PackageDatabaseEntryCollection &)
+ {
+ }
+
+ virtual void on_display_merge_list_pre()
+ {
+ cout << endl << colour(cl_heading, "These packages will be installed:")
+ << endl << endl;
+ }
+
+ virtual void on_display_merge_list_post();
+ virtual void on_display_merge_list_entry(const DepListEntry &);
+
+ virtual void on_fetch_all_pre()
+ {
+ }
+
+ virtual void on_fetch_pre(const DepListEntry & d)
+ {
+ cout << colour(cl_heading, "Fetching " +
+ stringify(d.package.name) + "-" + stringify(d.package.version) +
+ "::" + stringify(d.package.repository)) << endl << endl;
+
+ cerr << xterm_title("(" + stringify(++_current_count) + " of " +
+ stringify(_max_count + _max_virtual_count) + ") Fetching " +
+ stringify(d.package.name) + "-" + stringify(d.package.version) +
+ "::" + stringify(d.package.repository));
+ }
+
+ virtual void on_fetch_post(const DepListEntry &)
+ {
+ }
+
+ virtual void on_fetch_all_post()
+ {
+ }
+
+ virtual void on_install_all_pre()
+ {
+ }
+
+ virtual void on_install_pre(const DepListEntry & d)
+ {
+ cout << endl << colour(cl_heading, "Installing " +
+ stringify(d.package.name) + "-" + stringify(d.package.version) +
+ "::" + stringify(d.package.repository)) << endl << endl;
+
+ cerr << xterm_title("(" + stringify(++_current_count) + " of " +
+ stringify(_max_count + _max_virtual_count) + ") Installing " +
+ stringify(d.package.name) + "-" + stringify(d.package.version) +
+ "::" + stringify(d.package.repository));
+ }
+
+ virtual void on_install_post(const DepListEntry &)
+ {
+ }
+
+ virtual void on_install_all_post()
+ {
+ }
+
+ virtual void on_update_world_pre()
+ {
+ cout << endl << colour(cl_heading, "Updating world file") << endl << endl;
+ }
+
+ virtual void on_update_world(const PackageDepAtom & a)
+ {
+ cout << "* adding " << colour(cl_package_name, a.package()) << endl;
+ }
+
+ virtual void on_update_world_skip(const PackageDepAtom & a, const std::string & s)
+ {
+ cout << "* skipping " << colour(cl_package_name, a.package()) << " ("
+ << s << ")" << endl;
+ }
+
+ virtual void on_update_world_post()
+ {
+ cout << endl;
+ }
+
+ virtual void on_preserve_world()
+ {
+ cout << endl << colour(cl_heading, "Updating world file") << endl << endl;
+ cout << "* --preserve-world was specified, skipping world changes" << endl;
+ cout << endl;
+ }
+ };
+
+ void
+ OurInstallTask::on_display_merge_list_post()
+ {
+ if (_max_count != _new_count + _upgrade_count + _downgrade_count + _new_slot_count +
+ _rebuild_count)
+ Log::get_instance()->message(ll_warning, lc_no_context,
+ "Max count doesn't add up. This is a bug!");
+
+ if (_max_virtual_count != _new_virtual_count + _upgrade_virtual_count +
+ _downgrade_virtual_count + _new_slot_virtual_count + _rebuild_virtual_count)
+ Log::get_instance()->message(ll_warning, lc_no_context,
+ "Max virtuals count doesn't add up. This is a bug!");
+
+ cout << endl << "Total: " << _max_count << (_max_count == 1 ? " package" : " packages");
+ if (_max_count)
+ {
+ bool need_comma(false);
+ cout << " (";
+ if (_new_count)
+ {
+ cout << _new_count << " new";
+ need_comma = true;
+ }
+ if (_upgrade_count)
+ {
+ if (need_comma)
+ cout << ", ";
+ cout << _upgrade_count << (_upgrade_count == 1 ? " upgrade" : " upgrades");
+ need_comma = true;
+ }
+ if (_downgrade_count)
+ {
+ if (need_comma)
+ cout << ", ";
+ cout << _downgrade_count << (_downgrade_count == 1 ? " downgrade" : " downgrades");
+ need_comma = true;
+ }
+ if (_new_slot_count)
+ {
+ if (need_comma)
+ cout << ", ";
+ cout << _new_slot_count << (_new_slot_count == 1 ? " in new slot" : " in new slots");
+ need_comma = true;
+ }
+ if (_rebuild_count)
+ {
+ if (need_comma)
+ cout << ", ";
+ cout << _rebuild_count << (_rebuild_count == 1 ? " rebuild" : " rebuilds");
+ need_comma = true;
+ }
+ cout << ")";
+ }
+
+ if (_max_virtual_count)
+ {
+ cout << " and " << _max_virtual_count << (_max_virtual_count == 1
+ ? " virtual" : " virtuals");
+ bool need_comma(false);
+ cout << " (";
+ if (_new_virtual_count)
+ {
+ cout << _new_virtual_count << " new";
+ need_comma = true;
+ }
+ if (_upgrade_virtual_count)
+ {
+ if (need_comma)
+ cout << ", ";
+ cout << _upgrade_virtual_count << (_upgrade_virtual_count == 1 ? " upgrade" : " upgrades");
+ need_comma = true;
+ }
+ if (_downgrade_virtual_count)
+ {
+ if (need_comma)
+ cout << ", ";
+ cout << _downgrade_virtual_count << (_downgrade_virtual_count == 1 ?
+ " downgrade" : " downgrades");
+ need_comma = true;
+ }
+ if (_new_slot_virtual_count)
+ {
+ if (need_comma)
+ cout << ", ";
+ cout << _new_slot_virtual_count << (_new_slot_virtual_count == 1 ?
+ " in new slot" : " in new slots");
+ need_comma = true;
+ }
+ if (_rebuild_virtual_count)
+ {
+ if (need_comma)
+ cout << ", ";
+ cout << _rebuild_virtual_count << (_rebuild_virtual_count == 1 ?
+ " rebuild" : " rebuilds");
+ need_comma = true;
+ }
+ cout << ")";
+ }
+ cout << endl << endl;
+
+ if (CommandLine::get_instance()->a_pretend.specified() && ! _all_tags.empty())
+ {
+ TagDisplayer tag_displayer;
+
+ std::set<std::string> tag_categories;
+ for (std::set<DepTagEntry>::const_iterator a(_all_tags.begin()),
+ a_end(_all_tags.end()) ; a != a_end ; ++a)
+ tag_categories.insert(a->tag->category());
+
+ for (std::set<std::string>::iterator cat(tag_categories.begin()),
+ cat_end(tag_categories.end()) ; cat != cat_end ; ++cat)
+ {
+ 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())
+ cout << c->pre_text() << endl << endl;
+
+ for (std::set<DepTagEntry>::const_iterator t(_all_tags.begin()), t_end(_all_tags.end()) ;
+ t != t_end ; ++t)
+ {
+ if (t->tag->category() != *cat)
+ continue;
+ t->tag->accept(&tag_displayer);
+ }
+ cout << endl;
+
+ if (! c->post_text().empty())
+ cout << c->post_text() << endl << endl;
+ }
+ }
+ }
+
+ 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(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) ||
+ CategoryNamePart("virtual") != d.package.name.category)
+ cout << "-" << d.package.version;
+
+ /* display repository, unless it's our main repository */
+ if (DefaultEnvironment::get_instance()->package_database()->favourite_repository() !=
+ d.package.repository)
+ cout << "::" << d.package.repository;
+
+ /* display slot name, unless it's 0 */
+ if (SlotName("0") != d.metadata->slot)
+ cout << colour(d.already_installed ? cl_unimportant : cl_slot,
+ " {:" + stringify(d.metadata->slot) + "}");
+
+ /* 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 (d.already_installed)
+ cout << colour(cl_unimportant, " [-]");
+ else if (existing->empty())
+ {
+ cout << colour(cl_updatemode, " [N]");
+ if (d.metadata->get_virtual_interface())
+ {
+ ++_new_virtual_count;
+ ++_max_virtual_count;
+ }
+ else
+ {
+ ++_new_count;
+ ++_max_count;
+ }
+ }
+ else
+ {
+ existing = DefaultEnvironment::get_instance()->package_database()->query(PackageDepAtom::Pointer(
+ new PackageDepAtom(stringify(d.package.name) + ":" +
+ stringify(d.metadata->slot))),
+ is_installed_only);
+ if (existing->empty())
+ {
+ cout << colour(cl_updatemode, " [S]");
+ if (d.metadata->get_virtual_interface())
+ {
+ ++_new_slot_virtual_count;
+ ++_max_virtual_count;
+ }
+ else
+ {
+ ++_new_slot_count;
+ ++_max_count;
+ }
+ }
+ else if (existing->last()->version < d.package.version)
+ {
+ cout << colour(cl_updatemode, " [U " + stringify(
+ existing->last()->version) + "]");
+ if (d.metadata->get_virtual_interface())
+ {
+ ++_upgrade_virtual_count;
+ ++_max_virtual_count;
+ }
+ else
+ {
+ ++_upgrade_count;
+ ++_max_count;
+ }
+ }
+ else if (existing->last()->version > d.package.version)
+ {
+ cout << colour(cl_updatemode, " [D " + stringify(
+ existing->last()->version) + "]");
+ if (d.metadata->get_virtual_interface())
+ {
+ ++_downgrade_virtual_count;
+ ++_max_virtual_count;
+ }
+ else
+ {
+ ++_downgrade_count;
+ ++_max_count;
+ }
+
+ }
+ else
+ {
+ cout << colour(cl_updatemode, " [R]");
+ if (d.metadata->get_virtual_interface())
+ {
+ ++_rebuild_virtual_count;
+ ++_max_virtual_count;
+ }
+ else
+ {
+ ++_rebuild_count;
+ ++_max_count;
+ }
+ }
+ }
+
+ /* fetch db entry */
+ PackageDatabaseEntry p(d.package);
+
+ /* display USE flags */
+ if (! d.already_installed)
+ std::cout << make_pretty_use_flags_string(DefaultEnvironment::get_instance(), p, d.metadata,
+ (existing->empty() ? 0 : &*existing->last()));
+
+ /* display tag, add tag to our post display list */
+ if (! d.tags->empty())
+ {
+ std::string tag_titles;
+ for (SortedCollection<DepTagEntry>::Iterator
+ tag(d.tags->begin()),
+ 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(", ");
+ }
+ 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 + ">");
+ }
+ }
+ }
+
+ cout << endl;
+ }
+
+ void show_resume_command(const InstallTask & task)
+ {
+ if (CommandLine::get_instance()->a_fetch.specified() ||
+ CommandLine::get_instance()->a_pretend.specified())
+ return;
+
+ if (task.current_dep_list_entry() != task.dep_list().end())
+ {
+ cerr << "Resume command: " << DefaultEnvironment::get_instance()->paludis_command() << " "
+ "--dl-installed-deps-pre discard "
+ "--dl-installed-deps-runtime discard "
+ "--dl-installed-deps-post discard "
+ "--dl-uninstalled-deps-pre discard "
+ "--dl-uninstalled-deps-runtime discard "
+ "--dl-uninstalled-deps-post discard "
+ "--install --preserve-world";
+ for (DepList::Iterator i(task.current_dep_list_entry()), i_end(task.dep_list().end()) ;
+ i != i_end ; ++i)
+ if (! i->already_installed)
+ cerr << " =" << i->package.name << "-" << i->package.version << "::" << i->package.repository;
+ cerr << endl;
+ }
+ }
+
+ class InstallKilledCatcher
+ {
+ private:
+ static const InstallTask * _task;
+
+ static void _signal_handler(int sig) PALUDIS_ATTRIBUTE((noreturn));
+
+ sig_t _old;
+
+ public:
+ InstallKilledCatcher(const InstallTask & task) :
+ _old(signal(SIGINT, &InstallKilledCatcher::_signal_handler))
+ {
+ _task = &task;
+ }
+
+ ~InstallKilledCatcher()
+ {
+ signal(SIGINT, _old);
+ _task = 0;
+ }
+ };
+
+ const InstallTask * InstallKilledCatcher::_task(0);
+
+ void
+ InstallKilledCatcher::_signal_handler(int sig)
+ {
+ cout << endl;
+ cerr << "Caught signal " << sig << endl;
+ cerr << "Waiting for children..." << endl;
+ while (-1 != wait(0))
+ ;
+ cerr << endl;
+ if (_task)
+ show_resume_command(*_task);
+ cerr << endl;
+ cerr << "Exiting with failure" << endl;
+ exit(EXIT_FAILURE);
+ }
+
+ DepListDepsOption
+ enum_arg_to_dep_list_deps_option(const args::EnumArg & arg)
+ {
+ if (arg.argument() == "pre")
+ return dl_deps_pre;
+ else if (arg.argument() == "pre-or-post")
+ return dl_deps_pre_or_post;
+ else if (arg.argument() == "post")
+ return dl_deps_post;
+ else if (arg.argument() == "try-post")
+ return dl_deps_try_post;
+ else if (arg.argument() == "discard")
+ return dl_deps_discard;
+ else
+ throw DoHelp("bad value for --" + arg.long_name());
+ }
+}
+
+int
+do_install()
+{
+ int return_code(0);
+
+ Context context("When performing install action from command line:");
+
+ DepListOptions options;
+
+ if (CommandLine::get_instance()->dl_reinstall.specified())
+ {
+ if (CommandLine::get_instance()->dl_reinstall.argument() == "never")
+ options.reinstall = dl_reinstall_never;
+ else if (CommandLine::get_instance()->dl_reinstall.argument() == "always")
+ options.reinstall = dl_reinstall_always;
+ else if (CommandLine::get_instance()->dl_reinstall.argument() == "if-use-changed")
+ options.reinstall = dl_reinstall_if_use_changed;
+ else
+ throw DoHelp("bad value for --dl-reinstall");
+ }
+
+ if (CommandLine::get_instance()->dl_upgrade.specified())
+ {
+ if (CommandLine::get_instance()->dl_upgrade.argument() == "as-needed")
+ options.upgrade = dl_upgrade_as_needed;
+ else if (CommandLine::get_instance()->dl_upgrade.argument() == "always")
+ options.upgrade = dl_upgrade_always;
+ else
+ throw DoHelp("bad value for --dl-upgrade");
+ }
+
+ if (CommandLine::get_instance()->dl_circular.specified())
+ {
+ if (CommandLine::get_instance()->dl_circular.argument() == "discard")
+ options.circular = dl_circular_discard;
+ else if (CommandLine::get_instance()->dl_circular.argument() == "error")
+ options.circular = dl_circular_error;
+ else
+ throw DoHelp("bad value for --dl-circular");
+ }
+
+ if (CommandLine::get_instance()->dl_installed_deps_pre.specified())
+ options.installed_deps_pre = enum_arg_to_dep_list_deps_option(
+ CommandLine::get_instance()->dl_installed_deps_pre);
+ if (CommandLine::get_instance()->dl_installed_deps_runtime.specified())
+ options.installed_deps_runtime = enum_arg_to_dep_list_deps_option(
+ CommandLine::get_instance()->dl_installed_deps_runtime);
+ if (CommandLine::get_instance()->dl_installed_deps_post.specified())
+ options.installed_deps_post = enum_arg_to_dep_list_deps_option(
+ CommandLine::get_instance()->dl_installed_deps_post);
+
+ if (CommandLine::get_instance()->dl_uninstalled_deps_pre.specified())
+ options.uninstalled_deps_pre = enum_arg_to_dep_list_deps_option(
+ CommandLine::get_instance()->dl_uninstalled_deps_pre);
+ if (CommandLine::get_instance()->dl_uninstalled_deps_runtime.specified())
+ options.uninstalled_deps_runtime = enum_arg_to_dep_list_deps_option(
+ CommandLine::get_instance()->dl_uninstalled_deps_runtime);
+ if (CommandLine::get_instance()->dl_uninstalled_deps_post.specified())
+ 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());
+ task.set_pretend(CommandLine::get_instance()->a_pretend.specified());
+ task.set_preserve_world(CommandLine::get_instance()->a_preserve_world.specified());
+
+ InstallKilledCatcher install_killed_catcher(task);
+
+ try
+ {
+ for (CommandLine::ParametersIterator q(CommandLine::get_instance()->begin_parameters()),
+ q_end(CommandLine::get_instance()->end_parameters()) ; q != q_end ; ++q)
+ task.add_target(*q);
+
+ task.execute();
+
+ cout << endl;
+ }
+ catch (const AmbiguousPackageNameError & e)
+ {
+ cout << endl;
+ cerr << "Query error:" << endl;
+ cerr << " * " << e.backtrace("\n * ");
+ cerr << "Ambiguous package name '" << e.name() << "'. Did you mean:" << endl;
+ for (AmbiguousPackageNameError::OptionsIterator o(e.begin_options()),
+ o_end(e.end_options()) ; o != o_end ; ++o)
+ cerr << " * " << colour(cl_package_name, *o) << endl;
+ cerr << endl;
+ return 1;
+ }
+ catch (const PackageInstallActionError & e)
+ {
+ cout << endl;
+ cerr << "Install error:" << endl;
+ cerr << " * " << e.backtrace("\n * ");
+ cerr << e.message() << endl;
+ cerr << endl;
+ show_resume_command(task);
+ cerr << endl;
+
+ return_code |= 1;
+ }
+ catch (const PackageFetchActionError & e)
+ {
+ cout << endl;
+ cerr << "Fetch error:" << endl;
+ cerr << " * " << e.backtrace("\n * ");
+ cerr << e.message() << endl;
+ cerr << endl;
+ show_resume_command(task);
+ cerr << endl;
+
+ return_code |= 1;
+ }
+ catch (const NoSuchPackageError & e)
+ {
+ cout << endl;
+ cerr << "Query error:" << endl;
+ cerr << " * " << e.backtrace("\n * ");
+ cerr << "No such package '" << e.name() << "'" << endl;
+ return 1;
+ }
+ catch (const AllMaskedError & e)
+ {
+ try
+ {
+ PackageDatabaseEntryCollection::ConstPointer p(
+ DefaultEnvironment::get_instance()->package_database()->query(
+ PackageDepAtom::ConstPointer(new PackageDepAtom(e.query())),
+ is_uninstalled_only));
+ if (p->empty())
+ {
+ cout << endl;
+ cerr << "Query error:" << endl;
+ cerr << " * " << e.backtrace("\n * ");
+ cerr << "All versions of '" << e.query() << "' are masked" << endl;
+ }
+ else
+ {
+ cout << endl;
+ cerr << "Query error:" << endl;
+ cerr << " * " << e.backtrace("\n * ");
+ cerr << "All versions of '" << e.query() << "' are masked. Candidates are:" << endl;
+ for (PackageDatabaseEntryCollection::Iterator pp(p->begin()), pp_end(p->end()) ;
+ pp != pp_end ; ++pp)
+ {
+ cerr << " * " << colour(cl_package_name, *pp) << ": Masked by ";
+
+ bool need_comma(false);
+ MaskReasons m(DefaultEnvironment::get_instance()->mask_reasons(*pp));
+ for (unsigned mm = 0 ; mm < m.size() ; ++mm)
+ if (m[mm])
+ {
+ if (need_comma)
+ cerr << ", ";
+ cerr << MaskReason(mm);
+
+ if (mr_eapi == mm)
+ {
+ std::string eapi_str(DefaultEnvironment::get_instance()->
+ package_database()->fetch_repository(
+ pp->repository)->version_metadata(
+ pp->name, pp->version)->eapi);
+
+ cerr << " ( " << colour(cl_masked, eapi_str) << " )";
+ }
+ else if (mr_license == mm)
+ {
+ cerr << " ";
+
+ LicenceDisplayer ld(cerr, DefaultEnvironment::get_instance(), &*pp);
+ DefaultEnvironment::get_instance()->package_database()->fetch_repository(
+ pp->repository)->version_metadata(
+ pp->name, pp->version)->license()->
+ accept(&ld);
+ }
+ else if (mr_keyword == mm)
+ {
+ VersionMetadata::ConstPointer meta(DefaultEnvironment::get_instance()->
+ package_database()->fetch_repository(
+ pp->repository)->version_metadata(
+ pp->name, pp->version));
+ if (meta->get_ebuild_interface())
+ {
+ std::set<KeywordName> keywords;
+ WhitespaceTokeniser::get_instance()->tokenise(
+ meta->get_ebuild_interface()->keywords,
+ create_inserter<KeywordName>(
+ std::inserter(keywords, keywords.end())));
+
+ cerr << " ( " << colour(cl_masked, join(keywords.begin(),
+ keywords.end(), " ")) << " )";
+ }
+ }
+
+ need_comma = true;
+ }
+ cerr << endl;
+ }
+ }
+ }
+ catch (...)
+ {
+ throw e;
+ }
+
+ return 1;
+ }
+ catch (const UseRequirementsNotMetError & e)
+ {
+ cout << endl;
+ cerr << "DepList USE requirements not met error:" << endl;
+ cerr << " * " << e.backtrace("\n * ") << e.message() << endl;
+ cerr << endl;
+ cerr << "This error usually indicates that one of the packages you are trying to" << endl;
+ cerr << "install requires that another package be built with particular USE flags" << endl;
+ cerr << "enabled or disabled. You may be able to work around this restriction by" << endl;
+ cerr << "adjusting your use.conf." << endl;
+ cerr << 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;
+ }
+ catch (const HadBothPackageAndSetTargets &)
+ {
+ cout << endl;
+ cerr << "Error: both package sets and packages were specified." << endl;
+ cerr << endl;
+ cerr << "Package sets (like 'system' and 'world') cannot be installed at the same time" << endl;
+ cerr << "as ordinary packages." << endl;
+
+ return_code |= 1;
+ }
+ catch (const MultipleSetTargetsSpecified &)
+ {
+ cout << endl;
+ cerr << "Error: multiple package sets were specified." << endl;
+ cerr << endl;
+ cerr << "Package sets (like 'system' and 'world') must be installed individually," << endl;
+ cerr << "without any other sets or packages." << endl;
+
+ return_code |= 1;
+ }
+
+ return return_code;
+}
+
diff --git a/0.8.0/src/paludis/install.hh b/0.8.0/src/paludis/install.hh
new file mode 100644
index 0000000..693931b
--- /dev/null
+++ b/0.8.0/src/paludis/install.hh
@@ -0,0 +1,32 @@
+/* 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_DEPGRAPH_HH
+#define PALUDIS_GUARD_SRC_DEPGRAPH_HH 1
+
+#include "command_line.hh"
+
+/** \file
+ * Declaration for the do_install function.
+ */
+
+/// Handle --install.
+int do_install();
+
+#endif
diff --git a/0.8.0/src/paludis/install_TEST b/0.8.0/src/paludis/install_TEST
new file mode 100755
index 0000000..eab20a9
--- /dev/null
+++ b/0.8.0/src/paludis/install_TEST
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --config-suffix install-test --install target || exit 1
+./install_TEST_dir/root/usr/bin/testbin | grep success >/dev/null
+
diff --git a/0.8.0/src/paludis/install_TEST_cleanup.sh b/0.8.0/src/paludis/install_TEST_cleanup.sh
new file mode 100755
index 0000000..92bb92a
--- /dev/null
+++ b/0.8.0/src/paludis/install_TEST_cleanup.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+if [ -d install_TEST_dir ] ; then
+ rm -fr install_TEST_dir
+else
+ true
+fi
+
+
+
diff --git a/0.8.0/src/paludis/install_TEST_setup.sh b/0.8.0/src/paludis/install_TEST_setup.sh
new file mode 100755
index 0000000..b511e8e
--- /dev/null
+++ b/0.8.0/src/paludis/install_TEST_setup.sh
@@ -0,0 +1,121 @@
+#!/bin/bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+mkdir install_TEST_dir || exit 1
+cd install_TEST_dir || exit 1
+
+mkdir -p config/.paludis-install-test
+cat <<END > config/.paludis-install-test/specpath
+root = `pwd`/root
+config-suffix =
+END
+
+mkdir -p root/${SYSCONFDIR}/paludis/repositories
+cat <<END > root/${SYSCONFDIR}/paludis/use.conf
+* foo
+END
+
+cat <<END > root/${SYSCONFDIR}/paludis/licenses.conf
+* *
+END
+
+cat <<END > root/${SYSCONFDIR}/paludis/keywords.conf
+* test
+END
+
+cat <<END > root/${SYSCONFDIR}/paludis/bashrc
+export CHOST="my-chost"
+export USER_BASHRC_WAS_USED=yes
+END
+
+cat <<END > root/${SYSCONFDIR}/paludis/repositories/repo1.conf
+location = `pwd`/repo1
+cache = /var/empty
+format = portage
+profiles = \${location}/profiles/testprofile \${location}/profiles/anothertestprofile
+buildroot = `pwd`/build
+END
+
+mkdir -p root/tmp
+touch root/${SYSCONFDIR}/ld.so.conf
+
+mkdir -p repo1/{eclass,distfiles,profiles/{testprofile,anothertestprofile},test-category/target/files} || exit 1
+
+mkdir -p src/target-2
+cat <<"END" > src/target-2/testbin
+#!/bin/bash
+echo "Test was a success"
+END
+chmod +x src/target-2/testbin
+cd src
+tar zcf target-2.tar.gz target-2/
+mv target-2.tar.gz ../repo1/distfiles/
+cd ..
+rm -fr src
+
+cd repo1 || exit 1
+echo "test-repo-1" > profiles/repo_name || exit 1
+cat <<END > profiles/categories || exit 1
+test-category
+END
+cat <<END > profiles/testprofile/make.defaults
+ARCH=test
+USERLAND=test
+KERNEL=test
+TESTPROFILE_WAS_SOURCED=yes
+PROFILE_ORDERING=1
+END
+cat <<END > profiles/anothertestprofile/make.defaults
+ARCH=test
+USERLAND=test
+KERNEL=test
+ANOTHERTESTPROFILE_WAS_SOURCED=yes
+PROFILE_ORDERING=2
+END
+
+cat <<"END" > eclass/foo.eclass
+inherit_was_ok() {
+ true
+}
+END
+
+cat <<"END" > test-category/target/target-2.ebuild || exit 1
+inherit foo
+
+DESCRIPTION="Test target"
+HOMEPAGE="http://paludis.berlios.de/"
+SRC_URI="http://invalid.domain/${P}.tar.gz oink? ( http://example.com/foo.tar.gz )"
+SLOT="0"
+IUSE="oink"
+LICENSE="GPL-2"
+KEYWORDS="test"
+
+pkg_setup() {
+ [[ -z "${USER_BASHRC_WAS_USED}" ]] && die "bad env"
+ [[ -z "${TESTPROFILE_WAS_SOURCED}" ]] && die "testprofile not sourced"
+ [[ -z "${ANOTHERTESTPROFILE_WAS_SOURCED}" ]] && die "anothertestprofile not sourced"
+ [[ ${PROFILE_ORDERING:-0} != 2 ]] && die "bad profile source ordering"
+}
+
+src_unpack() {
+ hasq "${P}.tar.gz" ${A} || die
+ hasq "${P}.tar.gz" ${AA} || die
+ hasq "foo.tar.gz" ${A} && die
+ hasq "foo.tar.gz" ${AA} || die
+ unpack ${A}
+}
+
+src_compile() {
+ inherit_was_ok || die "inherit didn't work"
+}
+
+src_test() {
+ ./testbin | grep success || die "failure"
+}
+
+src_install() {
+ dobin testbin
+}
+END
+cd ..
+
diff --git a/0.8.0/src/paludis/licence.cc b/0.8.0/src/paludis/licence.cc
new file mode 100644
index 0000000..a460a97
--- /dev/null
+++ b/0.8.0/src/paludis/licence.cc
@@ -0,0 +1,66 @@
+/* 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 "licence.hh"
+#include "colour.hh"
+#include <ostream>
+
+void
+LicenceDisplayer::visit(const paludis::AllDepAtom * atom)
+{
+ stream << "( ";
+ std::for_each(atom->begin(), atom->end(), paludis::accept_visitor(this));
+ stream << ") ";
+}
+
+void
+LicenceDisplayer::visit(const paludis::AnyDepAtom * atom)
+{
+ stream << "|| ( ";
+ std::for_each(atom->begin(), atom->end(), paludis::accept_visitor(this));
+ stream << ") ";
+}
+
+void
+LicenceDisplayer::visit(const paludis::UseDepAtom * atom)
+{
+ stream << atom->flag() << "? ( ";
+ std::for_each(atom->begin(), atom->end(), paludis::accept_visitor(this));
+ stream << ") ";
+}
+
+void
+LicenceDisplayer::visit(const paludis::PlainTextDepAtom * atom)
+{
+ if (env->accept_license(atom->text(), db_entry))
+ stream << colour(cl_not_masked, atom->text());
+ else
+ stream << colour(cl_masked, "(" + atom->text() + ")!");
+ stream << " ";
+}
+
+LicenceDisplayer::LicenceDisplayer(
+ std::ostream & s,
+ const paludis::Environment * const e,
+ const paludis::PackageDatabaseEntry * const d) :
+ stream(s),
+ env(e),
+ db_entry(d)
+{
+}
diff --git a/0.8.0/src/paludis/licence.hh b/0.8.0/src/paludis/licence.hh
new file mode 100644
index 0000000..38d902e
--- /dev/null
+++ b/0.8.0/src/paludis/licence.hh
@@ -0,0 +1,67 @@
+/* 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_LICENCE_HH
+#define PALUDIS_GUARD_SRC_LICENCE_HH 1
+
+#include <paludis/paludis.hh>
+#include <iosfwd>
+
+/**
+ * Display licences.
+ */
+struct LicenceDisplayer :
+ paludis::DepAtomVisitorTypes::ConstVisitor
+{
+ /// Our stream.
+ std::ostream & stream;
+
+ /// Our environment.
+ const paludis::Environment * const env;
+
+ /// Our db entry.
+ const paludis::PackageDatabaseEntry * const db_entry;
+
+ /// Constructor.
+ LicenceDisplayer(
+ std::ostream & stream,
+ const paludis::Environment * const e,
+ const paludis::PackageDatabaseEntry * const d);
+
+ ///\name Visit methods
+ ///{
+ void visit(const paludis::AllDepAtom * atom);
+
+ void visit(const paludis::AnyDepAtom * atom);
+
+ void visit(const paludis::UseDepAtom * atom);
+
+ void visit(const paludis::PlainTextDepAtom * atom);
+
+ void visit(const paludis::PackageDepAtom *)
+ {
+ }
+
+ void visit(const paludis::BlockDepAtom *)
+ {
+ }
+ ///}
+};
+
+#endif
diff --git a/0.8.0/src/paludis/list.cc b/0.8.0/src/paludis/list.cc
new file mode 100644
index 0000000..5b93fc1
--- /dev/null
+++ b/0.8.0/src/paludis/list.cc
@@ -0,0 +1,338 @@
+/* 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 "colour.hh"
+#include "command_line.hh"
+#include "list.hh"
+#include <iomanip>
+#include <iostream>
+#include <list>
+#include <map>
+#include <paludis/paludis.hh>
+#include <paludis/environment/default/default_environment.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/visitor.hh>
+
+namespace p = paludis;
+
+int
+do_list_repositories()
+{
+ int ret_code(1);
+
+ p::Context context("When performing list-repositories action from command line:");
+ p::Environment * const env(p::DefaultEnvironment::get_instance());
+
+ for (p::IndirectIterator<p::PackageDatabase::RepositoryIterator, const p::Repository>
+ r(env->package_database()->begin_repositories()), r_end(env->package_database()->end_repositories()) ;
+ r != r_end ; ++r)
+ {
+ if (CommandLine::get_instance()->a_repository.specified())
+ if (CommandLine::get_instance()->a_repository.args_end() == std::find(
+ CommandLine::get_instance()->a_repository.args_begin(),
+ CommandLine::get_instance()->a_repository.args_end(),
+ stringify(r->name())))
+ continue;
+
+ ret_code = 0;
+
+ std::cout << "* " << colour(cl_repository_name, r->name()) << std::endl;
+
+ p::RepositoryInfo::ConstPointer ii(r->info(false));
+ for (p::RepositoryInfo::SectionIterator i(ii->begin_sections()),
+ i_end(ii->end_sections()) ; i != i_end ; ++i)
+ {
+ std::cout << " " << colour(cl_heading, (*i)->heading() + ":") << std::endl;
+ for (p::RepositoryInfoSection::KeyValueIterator k((*i)->begin_kvs()),
+ k_end((*i)->end_kvs()) ; k != k_end ; ++k)
+ std::cout << " " << std::setw(22) << std::left << (p::stringify(k->first) + ":")
+ << std::setw(0) << " " << k->second << std::endl;
+ std::cout << std::endl;
+ }
+ }
+
+ return ret_code;
+}
+
+int
+do_list_categories()
+{
+ int ret_code(1);
+
+ p::Context context("When performing list-categories action from command line:");
+ p::Environment * const env(p::DefaultEnvironment::get_instance());
+
+ std::map<p::CategoryNamePart, std::list<p::RepositoryName> > cats;
+
+ for (p::IndirectIterator<p::PackageDatabase::RepositoryIterator, const p::Repository>
+ r(env->package_database()->begin_repositories()), r_end(env->package_database()->end_repositories()) ;
+ r != r_end ; ++r)
+ {
+ if (CommandLine::get_instance()->a_repository.specified())
+ if (CommandLine::get_instance()->a_repository.args_end() == std::find(
+ CommandLine::get_instance()->a_repository.args_begin(),
+ CommandLine::get_instance()->a_repository.args_end(),
+ stringify(r->name())))
+ continue;
+
+ p::CategoryNamePartCollection::ConstPointer cat_names(r->category_names());
+ for (p::CategoryNamePartCollection::Iterator c(cat_names->begin()), c_end(cat_names->end()) ;
+ c != c_end ; ++c)
+ cats[*c].push_back(r->name());
+ }
+
+ for (std::map<p::CategoryNamePart, std::list<p::RepositoryName > >::const_iterator
+ c(cats.begin()), c_end(cats.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->first)))
+ continue;
+
+ ret_code = 0;
+
+ std::cout << "* " << colour(cl_package_name, c->first) << std::endl;
+ std::cout << " " << std::setw(22) << std::left << "found in:" <<
+ std::setw(0) << " " << p::join(c->second.begin(), c->second.end(), ", ") << std::endl;
+ std::cout << std::endl;
+ }
+
+ return ret_code;
+}
+
+int
+do_list_packages()
+{
+ int ret_code(1);
+
+ p::Context context("When performing list-packages action from command line:");
+ p::Environment * const env(p::DefaultEnvironment::get_instance());
+
+ std::map<p::QualifiedPackageName, std::list<p::RepositoryName> > pkgs;
+
+ for (p::IndirectIterator<p::PackageDatabase::RepositoryIterator, const p::Repository>
+ r(env->package_database()->begin_repositories()), r_end(env->package_database()->end_repositories()) ;
+ r != r_end ; ++r)
+ {
+ if (CommandLine::get_instance()->a_repository.specified())
+ if (CommandLine::get_instance()->a_repository.args_end() == std::find(
+ CommandLine::get_instance()->a_repository.args_begin(),
+ CommandLine::get_instance()->a_repository.args_end(),
+ stringify(r->name())))
+ continue;
+
+ p::CategoryNamePartCollection::ConstPointer cat_names(r->category_names());
+ for (p::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;
+
+ p::QualifiedPackageNameCollection::ConstPointer pkg_names(r->package_names(*c));
+ for (p::QualifiedPackageNameCollection::Iterator p(pkg_names->begin()), p_end(pkg_names->end()) ;
+ p != p_end ; ++p)
+ pkgs[*p].push_back(r->name());
+ }
+ }
+
+ for (std::map<p::QualifiedPackageName, std::list<p::RepositoryName > >::const_iterator
+ p(pkgs.begin()), p_end(pkgs.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->first.package)))
+ continue;
+
+ ret_code = 0;
+
+ std::cout << "* " << colour(cl_package_name, p->first) << std::endl;
+ std::cout << " " << std::setw(22) << std::left << "found in:" <<
+ std::setw(0) << " " << p::join(p->second.begin(), p->second.end(), ", ") << std::endl;
+ std::cout << std::endl;
+ }
+
+ return ret_code;
+}
+
+int
+do_list_sets()
+{
+ int ret_code(1);
+
+ p::Context context("While performing list-sets action from command line:");
+ p::Environment * const env(p::DefaultEnvironment::get_instance());
+
+ std::map<std::string, std::list<p::RepositoryName> > sets;
+
+ for (p::IndirectIterator<p::PackageDatabase::RepositoryIterator, const p::Repository>
+ r(env->package_database()->begin_repositories()), r_end(env->package_database()->end_repositories()) ;
+ r != r_end ; ++r)
+ {
+ if (r->sets_interface == 0)
+ continue;
+
+ if (CommandLine::get_instance()->a_repository.specified())
+ if (CommandLine::get_instance()->a_repository.args_end() == std::find(
+ CommandLine::get_instance()->a_repository.args_begin(),
+ CommandLine::get_instance()->a_repository.args_end(),
+ stringify(r->name())))
+ continue;
+
+ p::SetsCollection::ConstPointer set_names(r->sets_interface->sets_list());
+ for (p::SetsCollection::Iterator s(set_names->begin()), s_end(set_names->end()) ;
+ s != s_end ; ++s)
+ sets[*s].push_back(r->name());
+ }
+
+ for (std::map<std::string, std::list<p::RepositoryName > >::const_iterator
+ s(sets.begin()), s_end(sets.end()) ; s != s_end ; ++s)
+ {
+ if (CommandLine::get_instance()->a_set.specified())
+ if (CommandLine::get_instance()->a_set.args_end() == std::find(
+ CommandLine::get_instance()->a_set.args_begin(),
+ CommandLine::get_instance()->a_set.args_end(),
+ s->first))
+ continue;
+
+ ret_code = 0;
+
+ std::cout << "* " << colour(cl_package_name, s->first) << std::endl;
+ std::cout << " " << std::setw(22) << std::left << "found in:" <<
+ std::setw(0) << " " << p::join(s->second.begin(), s->second.end(), ", ") << std::endl;
+ std::cout << std::endl;
+ }
+
+ return ret_code;
+}
+
+namespace
+{
+ /**
+ * Print dependency atoms as returned by do_package_set("security").
+ *
+ * \ingroup grpvulnerabilitiesprinter
+ */
+ class VulnerabilitiesPrinter :
+ public p::DepAtomVisitorTypes::ConstVisitor
+ {
+ private:
+ unsigned _size;
+
+ public:
+ /**
+ * Constructor.
+ */
+ VulnerabilitiesPrinter() :
+ _size(0)
+ {
+ }
+
+ /// \name Visit functions
+ ///{
+ void visit(const p::AllDepAtom * const);
+
+ void visit(const p::AnyDepAtom * const);
+
+ void visit(const p::UseDepAtom * const);
+
+ void visit(const p::PackageDepAtom * const);
+
+ void visit(const p::PlainTextDepAtom * const);
+
+ void visit(const p::BlockDepAtom * const);
+ ///}
+
+ /**
+ * Return number of visited atoms.
+ */
+ unsigned size() const
+ {
+ return _size;
+ }
+ };
+
+ void
+ VulnerabilitiesPrinter::visit(const p::AllDepAtom * const a)
+ {
+ std::for_each(a->begin(), a->end(), p::accept_visitor(this));
+ }
+
+ void
+ VulnerabilitiesPrinter::visit(const p::AnyDepAtom * const a)
+ {
+ std::for_each(a->begin(), a->end(), p::accept_visitor(this));
+ }
+
+ void
+ VulnerabilitiesPrinter::visit(const p::UseDepAtom * const a)
+ {
+ p::Log::get_instance()->message(p::ll_warning, p::lc_no_context,
+ "UseDepAtom encounter in do_package_set(\"security\").");
+ std::for_each(a->begin(), a->end(), p::accept_visitor(this));
+ }
+
+ void
+ VulnerabilitiesPrinter::visit(const p::PackageDepAtom * const a)
+ {
+ p::QualifiedPackageName q(a->package());
+
+ std::string c(p::stringify(q.category));
+ 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(),
+ c))
+ return;
+
+ std::string p(p::stringify(q.package));
+ 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(),
+ p))
+ return;
+
+ std::cout << "* " << colour(cl_package_name, p::stringify(q));
+ if (0 != a->tag())
+ std::cout << "-" << p::stringify(*a->version_spec_ptr());
+ if (0 != a->tag())
+ std::cout << " " << colour(cl_tag, "<" + a->tag()->short_text() + ">");
+ std::cout << std::endl;
+ ++_size;
+ }
+
+ void
+ VulnerabilitiesPrinter::visit(const p::PlainTextDepAtom * const)
+ {
+ }
+
+ void
+ VulnerabilitiesPrinter::visit(const p::BlockDepAtom * const)
+ {
+ }
+}
+
diff --git a/0.8.0/src/paludis/list.hh b/0.8.0/src/paludis/list.hh
new file mode 100644
index 0000000..204af50
--- /dev/null
+++ b/0.8.0/src/paludis/list.hh
@@ -0,0 +1,39 @@
+/* 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_LIST_REPOSITORIES_HH
+#define PALUDIS_GUARD_SRC_LIST_REPOSITORIES_HH 1
+
+/** \file
+ * Declaration for the do_list_repositories and do_list_categories functions.
+ */
+
+/// Handle --list-repositories.
+int do_list_repositories();
+
+/// Handle --list-categories.
+int do_list_categories();
+
+/// Handle --list-packages.
+int do_list_packages();
+
+/// Handle --list-sets.
+int do_list_sets();
+
+#endif
diff --git a/0.8.0/src/paludis/list_dep_tag_categories_TEST b/0.8.0/src/paludis/list_dep_tag_categories_TEST
new file mode 100755
index 0000000..40fa15c
--- /dev/null
+++ b/0.8.0/src/paludis/list_dep_tag_categories_TEST
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+PALUDIS_SKIP_CONFIG=yes ./paludis --list-dep-tag-categories
diff --git a/0.8.0/src/paludis/list_repository_formats_TEST b/0.8.0/src/paludis/list_repository_formats_TEST
new file mode 100755
index 0000000..487513c
--- /dev/null
+++ b/0.8.0/src/paludis/list_repository_formats_TEST
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+PALUDIS_SKIP_CONFIG=yes ./paludis --list-repository-formats
diff --git a/0.8.0/src/paludis/list_sync_formats_TEST b/0.8.0/src/paludis/list_sync_formats_TEST
new file mode 100755
index 0000000..f638b22
--- /dev/null
+++ b/0.8.0/src/paludis/list_sync_formats_TEST
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+PALUDIS_SKIP_CONFIG=yes ./paludis --list-sync-protocols
diff --git a/0.8.0/src/paludis/man_paludis.cc b/0.8.0/src/paludis/man_paludis.cc
new file mode 100644
index 0000000..9cab7e5
--- /dev/null
+++ b/0.8.0/src/paludis/man_paludis.cc
@@ -0,0 +1,35 @@
+/* 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 "command_line.hh"
+#include <paludis/args/man.hh>
+
+#include <iostream>
+#include <cstdlib>
+
+using std::cout;
+using std::endl;
+
+int
+main(int, char *[])
+{
+ paludis::args::generate_man(cout, CommandLine::get_instance());
+ return EXIT_SUCCESS;
+}
+
diff --git a/0.8.0/src/paludis/news.cc b/0.8.0/src/paludis/news.cc
new file mode 100644
index 0000000..17df87a
--- /dev/null
+++ b/0.8.0/src/paludis/news.cc
@@ -0,0 +1,52 @@
+/* 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 "colour.hh"
+#include "news.hh"
+#include <functional>
+#include <iomanip>
+#include <iostream>
+#include <paludis/paludis.hh>
+#include <paludis/environment/default/default_environment.hh>
+#include <string>
+
+/** \file
+ * Handle the --update-news action for the main paludis program.
+ */
+
+namespace p = paludis;
+
+int
+do_update_news()
+{
+ int return_code(0);
+
+ p::Context context("When performing update-news action from command line:");
+ p::Environment * const env(p::DefaultEnvironment::get_instance());
+
+ for (p::PackageDatabase::RepositoryIterator r(env->package_database()->begin_repositories()),
+ r_end(env->package_database()->end_repositories()) ; r != r_end ; ++r)
+ if ((*r)->news_interface)
+ (*r)->news_interface->update_news();
+
+ return return_code;
+}
+
+
+
diff --git a/0.8.0/src/paludis/news.hh b/0.8.0/src/paludis/news.hh
new file mode 100644
index 0000000..1e3e06d
--- /dev/null
+++ b/0.8.0/src/paludis/news.hh
@@ -0,0 +1,34 @@
+/* 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_NEWS_HH
+#define PALUDIS_GUARD_SRC_NEWS_HH 1
+
+#include "command_line.hh"
+
+/** \file
+ * Declaration for the do_update_news function.
+ */
+
+/// Handle --update-news.
+int do_update_news();
+
+#endif
+
+
diff --git a/0.8.0/src/paludis/owner.cc b/0.8.0/src/paludis/owner.cc
new file mode 100644
index 0000000..4d63bf1
--- /dev/null
+++ b/0.8.0/src/paludis/owner.cc
@@ -0,0 +1,133 @@
+/* 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 "owner.hh"
+#include "colour.hh"
+#include "command_line.hh"
+#include <paludis/paludis.hh>
+#include <paludis/environment/default/default_environment.hh>
+#include <iostream>
+
+namespace p = paludis;
+using std::cout;
+using std::cerr;
+using std::endl;
+
+namespace
+{
+ struct ContentsFinder :
+ p::ContentsVisitorTypes::ConstVisitor
+ {
+ bool found;
+ const std::string query;
+ const bool full;
+
+ ContentsFinder(const std::string & q, bool f) :
+ found(false),
+ query(q),
+ full(f)
+ {
+ }
+
+ void handle(const std::string & e)
+ {
+ if (full)
+ found |= (e == query);
+ else
+ found |= (std::string::npos != e.find(query));
+ }
+
+ void visit(const p::ContentsFileEntry * const e)
+ {
+ handle(e->name());
+ }
+
+ void visit(const p::ContentsDirEntry * const e)
+ {
+ handle(e->name());
+ }
+
+ void visit(const p::ContentsSymEntry * const e)
+ {
+ handle(e->name());
+ }
+
+ void visit(const p::ContentsMiscEntry * const e)
+ {
+ handle(e->name());
+ }
+ };
+}
+
+void
+do_one_owner(
+ const p::Environment * const env,
+ const std::string & query)
+{
+ cout << "* " << colour(cl_package_name, query) << endl;
+
+ for (p::PackageDatabase::RepositoryIterator r(env->package_database()->begin_repositories()),
+ r_end(env->package_database()->end_repositories()) ; r != r_end ; ++r)
+ {
+ if (! (*r)->installed_interface)
+ continue;
+
+ p::CategoryNamePartCollection::ConstPointer cats((*r)->category_names());
+ for (p::CategoryNamePartCollection::Iterator c(cats->begin()),
+ c_end(cats->end()) ; c != c_end ; ++c)
+ {
+ p::QualifiedPackageNameCollection::ConstPointer pkgs((*r)->package_names(*c));
+ for (p::QualifiedPackageNameCollection::Iterator p(pkgs->begin()),
+ p_end(pkgs->end()) ; p != p_end ; ++p)
+ {
+ p::VersionSpecCollection::ConstPointer vers((*r)->version_specs(*p));
+ for (p::VersionSpecCollection::Iterator v(vers->begin()),
+ v_end(vers->end()) ; v != v_end ; ++v)
+ {
+ p::PackageDatabaseEntry e(*p, *v, (*r)->name());
+ p::Contents::ConstPointer contents((*r)->installed_interface->
+ contents(*p, *v));
+ ContentsFinder d(query, CommandLine::get_instance()->a_full_match.specified());
+ std::for_each(contents->begin(), contents->end(), accept_visitor(&d));
+ if (d.found)
+ cout << " " << e << endl;
+ }
+ }
+ }
+ }
+
+ cout << endl;
+}
+
+
+int
+do_owner()
+{
+ int return_code(0);
+ p::Context context("When performing owner action from command line:");
+ p::Environment * const env(p::DefaultEnvironment::get_instance());
+
+ CommandLine::ParametersIterator q(CommandLine::get_instance()->begin_parameters()),
+ q_end(CommandLine::get_instance()->end_parameters());
+ for ( ; q != q_end ; ++q)
+ do_one_owner(env, *q);
+
+ return return_code;
+}
+
diff --git a/0.8.0/src/paludis/owner.hh b/0.8.0/src/paludis/owner.hh
new file mode 100644
index 0000000..ce9efba
--- /dev/null
+++ b/0.8.0/src/paludis/owner.hh
@@ -0,0 +1,30 @@
+/* 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_OWNER_HH
+#define PALUDIS_GUARD_SRC_OWNER_HH 1
+
+/** \file
+ * Declaration for the do_owner function.
+ */
+
+/// Handle --owner.
+int do_owner();
+
+#endif
diff --git a/0.8.0/src/paludis/paludis.cc b/0.8.0/src/paludis/paludis.cc
new file mode 100644
index 0000000..e44e791
--- /dev/null
+++ b/0.8.0/src/paludis/paludis.cc
@@ -0,0 +1,443 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 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 "applets.hh"
+#include "colour.hh"
+#include "command_line.hh"
+#include "contents.hh"
+#include "install.hh"
+#include "list.hh"
+#include "news.hh"
+#include "owner.hh"
+#include "query.hh"
+#include "sync.hh"
+#include "uninstall.hh"
+#include "config.h"
+
+#include <paludis/paludis.hh>
+#include <paludis/util/util.hh>
+#include <paludis/environment/default/default_environment.hh>
+#include <paludis/environment/default/default_config.hh>
+
+#include <libebt/libebt.hh>
+#include <libwrapiter/libwrapiter.hh>
+
+#include <iostream>
+#include <iomanip>
+#include <string>
+#include <cstdlib>
+
+/** \file
+ * Main paludis program.
+ */
+
+namespace p = paludis;
+
+using std::cout;
+using std::cerr;
+using std::endl;
+
+#ifndef DOXYGEN
+struct DoVersion
+{
+};
+#endif
+
+namespace
+{
+ void display_version()
+ {
+ cout << PALUDIS_PACKAGE << " " << PALUDIS_VERSION_MAJOR << "."
+ << PALUDIS_VERSION_MINOR << "." << PALUDIS_VERSION_MICRO;
+ if (! std::string(PALUDIS_SUBVERSION_REVISION).empty())
+ cout << " svn " << PALUDIS_SUBVERSION_REVISION;
+ cout << endl << endl;
+ cout << "Built by " << PALUDIS_BUILD_USER << "@" << PALUDIS_BUILD_HOST
+ << " on " << PALUDIS_BUILD_DATE << endl;
+ cout << "CXX: " << PALUDIS_BUILD_CXX
+#if defined(__ICC)
+ << " " << __ICC
+#elif defined(__VERSION__)
+ << " " << __VERSION__
+#endif
+ << endl;
+ cout << "CXXFLAGS: " << PALUDIS_BUILD_CXXFLAGS << endl;
+ cout << "LDFLAGS: " << PALUDIS_BUILD_LDFLAGS << endl;
+ cout << "DATADIR: " << DATADIR << endl;
+ cout << "LIBDIR: " << LIBDIR << endl;
+ cout << "LIBEXECDIR: " << LIBEXECDIR << endl;
+ cout << "SYSCONFDIR: " << SYSCONFDIR << endl;
+ cout << "stdlib: "
+#if defined(__GLIBCXX__)
+# define XSTRINGIFY(x) #x
+# define STRINGIFY(x) XSTRINGIFY(x)
+ << "GNU libstdc++ " << STRINGIFY(__GLIBCXX__)
+#endif
+ << endl;
+
+ cout << "libebt: " << LIBEBT_VERSION_MAJOR << "." << LIBEBT_VERSION_MINOR
+ << "." << LIBEBT_VERSION_MICRO << endl;
+ cout << "libwrapiter: " << LIBWRAPITER_VERSION_MAJOR << "." << LIBWRAPITER_VERSION_MINOR
+ << "." << LIBWRAPITER_VERSION_MICRO << endl;
+#if HAVE_SANDBOX
+ cout << "sandbox: enabled" << endl;
+#else
+ cout << "sandbox: disabled" << endl;
+#endif
+ }
+
+ void display_info()
+ {
+ p::Environment * const env(p::DefaultEnvironment::get_instance());
+
+ for (p::IndirectIterator<p::PackageDatabase::RepositoryIterator, const p::Repository>
+ r(env->package_database()->begin_repositories()), r_end(env->package_database()->end_repositories()) ;
+ r != r_end ; ++r)
+ {
+ cout << "Repository " << colour(cl_repository_name, r->name()) << ":" << endl;
+
+ p::RepositoryInfo::ConstPointer ii(r->info(true));
+ for (p::RepositoryInfo::SectionIterator i(ii->begin_sections()),
+ i_end(ii->end_sections()) ; i != i_end ; ++i)
+ {
+ cout << " " << colour(cl_heading, (*i)->heading() + ":") << endl;
+ for (p::RepositoryInfoSection::KeyValueIterator k((*i)->begin_kvs()),
+ k_end((*i)->end_kvs()) ; k != k_end ; ++k)
+ cout << " " << std::setw(22) << std::left << (p::stringify(k->first) + ":")
+ << std::setw(0) << " " << k->second << endl;
+ cout << endl;
+ }
+ }
+
+ }
+}
+
+int
+main(int argc, char *argv[])
+{
+ p::Context context("In program " + p::join(argv, argv + argc, " ") + ":");
+
+ try
+ {
+ CommandLine::get_instance()->run(argc, argv);
+ set_use_colour(! CommandLine::get_instance()->a_no_color.specified());
+
+ if (CommandLine::get_instance()->a_help.specified())
+ throw DoHelp();
+
+ if (CommandLine::get_instance()->a_version.specified())
+ throw DoVersion();
+
+ if (! CommandLine::get_instance()->a_log_level.specified())
+ p::Log::get_instance()->set_log_level(p::ll_qa);
+ else if (CommandLine::get_instance()->a_log_level.argument() == "debug")
+ p::Log::get_instance()->set_log_level(p::ll_debug);
+ else if (CommandLine::get_instance()->a_log_level.argument() == "qa")
+ p::Log::get_instance()->set_log_level(p::ll_qa);
+ else if (CommandLine::get_instance()->a_log_level.argument() == "warning")
+ p::Log::get_instance()->set_log_level(p::ll_warning);
+ else if (CommandLine::get_instance()->a_log_level.argument() == "silent")
+ p::Log::get_instance()->set_log_level(p::ll_silent);
+ else
+ throw DoHelp("bad value for --log-level");
+
+ p::Log::get_instance()->set_program_name(argv[0]);
+
+ if (1 != (CommandLine::get_instance()->a_query.specified() +
+ CommandLine::get_instance()->a_version.specified() +
+ CommandLine::get_instance()->a_install.specified() +
+ CommandLine::get_instance()->a_uninstall.specified() +
+ CommandLine::get_instance()->a_sync.specified() +
+ CommandLine::get_instance()->a_list_repositories.specified() +
+ CommandLine::get_instance()->a_list_categories.specified() +
+ CommandLine::get_instance()->a_list_packages.specified() +
+ CommandLine::get_instance()->a_list_sets.specified() +
+ CommandLine::get_instance()->a_list_sync_protocols.specified() +
+ CommandLine::get_instance()->a_list_repository_formats.specified() +
+ CommandLine::get_instance()->a_list_dep_tag_categories.specified() +
+ CommandLine::get_instance()->a_contents.specified() +
+ CommandLine::get_instance()->a_owner.specified() +
+ CommandLine::get_instance()->a_has_version.specified() +
+ CommandLine::get_instance()->a_update_news.specified() +
+ CommandLine::get_instance()->a_environment_variable.specified() +
+ CommandLine::get_instance()->a_configuration_variable.specified() +
+ CommandLine::get_instance()->a_info.specified() +
+ CommandLine::get_instance()->a_best_version.specified()))
+ {
+ if ((1 == std::distance(CommandLine::get_instance()->begin_parameters(),
+ CommandLine::get_instance()->end_parameters())) &&
+ ("moo" == *CommandLine::get_instance()->begin_parameters()))
+ {
+ cout << endl;
+ cout << " ______________________________" << endl;
+ cout << "( Ugh. Another Portage user... )" << endl;
+ cout << " ------------------------------ " << endl;
+ cout << " o" << endl;
+ cout << " o" << endl;
+ cout << " ^__^ /" << endl;
+ cout << " (" << colour(cl_bold_pink, "oo") << ")\\_______/ _________" << endl;
+ cout << " (__)\\ )=( ____|_ \\_____" << endl;
+ cout << " ||----w | \\ \\ \\_____ |" << endl;
+ cout << " || || || ||" << endl;
+ cout << endl;
+ return EXIT_SUCCESS;
+ }
+ else
+ throw DoHelp("you should specify exactly one action");
+ }
+
+ /* these actions don't need DefaultConfig */
+
+ if (CommandLine::get_instance()->a_list_sync_protocols.specified())
+ {
+ if (! CommandLine::get_instance()->empty())
+ throw DoHelp("list-sync-protocols action takes no parameters");
+
+ return do_list_sync_protocols();
+ }
+
+ if (CommandLine::get_instance()->a_list_repository_formats.specified())
+ {
+ if (! CommandLine::get_instance()->empty())
+ throw DoHelp("list-repository-formats action takes no parameters");
+
+ return do_list_repository_formats();
+ }
+
+ if (CommandLine::get_instance()->a_list_dep_tag_categories.specified())
+ {
+ if (! CommandLine::get_instance()->empty())
+ throw DoHelp("list-dep-tag-categories action takes no parameters");
+
+ return do_list_dep_tag_categories();
+ }
+
+ /* these actions do need DefaultConfig */
+
+ try
+ {
+ std::string paludis_command(argv[0]);
+ if (CommandLine::get_instance()->a_config_suffix.specified())
+ {
+ p::DefaultConfig::set_config_suffix(CommandLine::get_instance()->a_config_suffix.argument());
+ paludis_command.append(" --config-suffix " +
+ CommandLine::get_instance()->a_config_suffix.argument());
+ }
+ paludis_command.append(" --log-level " + CommandLine::get_instance()->a_log_level.argument());
+ p::DefaultConfig::get_instance()->set_paludis_command(paludis_command);
+ }
+ catch (const p::DefaultConfigError & e)
+ {
+ if (CommandLine::get_instance()->a_info.specified())
+ {
+ display_version();
+ cout << endl;
+ cout << "Cannot complete --info output due to configuration exception" << endl;
+ }
+ throw;
+ }
+
+ if (CommandLine::get_instance()->a_info.specified())
+ {
+ display_version();
+ cout << endl;
+ display_info();
+ cout << endl;
+ return EXIT_SUCCESS;
+ }
+
+ if (CommandLine::get_instance()->a_query.specified())
+ {
+ if (CommandLine::get_instance()->empty())
+ throw DoHelp("query action requires at least one parameter");
+
+ return do_query();
+ }
+
+ if (CommandLine::get_instance()->a_install.specified())
+ {
+ if (CommandLine::get_instance()->empty())
+ throw DoHelp("install action requires at least one parameter");
+
+ return do_install();
+ }
+
+ if (CommandLine::get_instance()->a_uninstall.specified())
+ {
+ if (CommandLine::get_instance()->empty())
+ throw DoHelp("uninstall action requires at least one parameter");
+
+ return do_uninstall();
+ }
+
+ if (CommandLine::get_instance()->a_sync.specified())
+ {
+ return do_sync();
+ }
+
+ if (CommandLine::get_instance()->a_list_repositories.specified())
+ {
+ if (! CommandLine::get_instance()->empty())
+ throw DoHelp("list-repositories action takes no parameters");
+
+ return do_list_repositories();
+ }
+
+ if (CommandLine::get_instance()->a_list_categories.specified())
+ {
+ if (! CommandLine::get_instance()->empty())
+ throw DoHelp("list-categories action takes no parameters");
+
+ return do_list_categories();
+ }
+
+ if (CommandLine::get_instance()->a_list_packages.specified())
+ {
+ if (! CommandLine::get_instance()->empty())
+ throw DoHelp("list-packages action takes no parameters");
+
+ return do_list_packages();
+ }
+
+ if (CommandLine::get_instance()->a_list_sets.specified())
+ {
+ if (! CommandLine::get_instance()->empty())
+ throw DoHelp("list-sets action takes no parameters");
+
+ return do_list_sets();
+ }
+
+ if (CommandLine::get_instance()->a_contents.specified())
+ {
+ if (CommandLine::get_instance()->empty())
+ throw DoHelp("contents action requires at least one parameter");
+
+ return do_contents();
+ }
+
+ if (CommandLine::get_instance()->a_owner.specified())
+ {
+ if (CommandLine::get_instance()->empty())
+ throw DoHelp("owner action requires at least one parameter");
+
+ return do_owner();
+ }
+
+ if (CommandLine::get_instance()->a_has_version.specified())
+ {
+ if (1 != std::distance(CommandLine::get_instance()->begin_parameters(),
+ CommandLine::get_instance()->end_parameters()))
+ throw DoHelp("has-version action takes exactly one parameter");
+
+ return do_has_version();
+ }
+
+ if (CommandLine::get_instance()->a_best_version.specified())
+ {
+ if (1 != std::distance(CommandLine::get_instance()->begin_parameters(),
+ CommandLine::get_instance()->end_parameters()))
+ throw DoHelp("best-version action takes exactly one parameter");
+
+ return do_best_version();
+ }
+
+ if (CommandLine::get_instance()->a_environment_variable.specified())
+ {
+ if (2 != std::distance(CommandLine::get_instance()->begin_parameters(),
+ CommandLine::get_instance()->end_parameters()))
+ throw DoHelp("environment-variable action takes exactly two parameters (depatom var)");
+
+ return do_environment_variable();
+ }
+
+ if (CommandLine::get_instance()->a_configuration_variable.specified())
+ {
+ if (2 != std::distance(CommandLine::get_instance()->begin_parameters(),
+ CommandLine::get_instance()->end_parameters()))
+ throw DoHelp("configuration-variable action takes exactly two parameters (repository var)");
+
+ return do_configuration_variable();
+ }
+
+ if (CommandLine::get_instance()->a_update_news.specified())
+ {
+ if (! CommandLine::get_instance()->empty())
+ throw DoHelp("update-news action takes no parameters");
+
+ return do_update_news();
+ }
+
+ throw p::InternalError(__PRETTY_FUNCTION__, "no action?");
+ }
+ catch (const DoVersion &)
+ {
+ display_version();
+ cout << endl;
+ cout << "Paludis comes with ABSOLUTELY NO WARRANTY. Paludis is free software, and you" << endl;
+ cout << "are welcome to redistribute it under the terms of the GNU General Public" << endl;
+ cout << "License, version 2." << endl;
+
+ return EXIT_SUCCESS;
+ }
+ catch (const paludis::args::ArgsError & e)
+ {
+ cerr << "Usage error: " << e.message() << endl;
+ cerr << "Try " << argv[0] << " --help" << endl;
+ return EXIT_FAILURE;
+ }
+ catch (const DoHelp & h)
+ {
+ if (h.message.empty())
+ {
+ cout << "Usage: " << argv[0] << " [options]" << endl;
+ cout << endl;
+ cout << *CommandLine::get_instance();
+ return EXIT_SUCCESS;
+ }
+ else
+ {
+ cerr << "Usage error: " << h.message << endl;
+ cerr << "Try " << argv[0] << " --help" << endl;
+ return EXIT_FAILURE;
+ }
+ }
+ catch (const p::Exception & e)
+ {
+ cout << endl;
+ cerr << "Unhandled exception:" << endl
+ << " * " << e.backtrace("\n * ")
+ << e.message() << " (" << e.what() << ")" << endl;
+ return EXIT_FAILURE;
+ }
+ catch (const std::exception & e)
+ {
+ cout << endl;
+ cerr << "Unhandled exception:" << endl
+ << " * " << e.what() << endl;
+ return EXIT_FAILURE;
+ }
+ catch (...)
+ {
+ cout << endl;
+ cerr << "Unhandled exception:" << endl
+ << " * Unknown exception type. Ouch..." << endl;
+ return EXIT_FAILURE;
+ }
+}
+
diff --git a/0.8.0/src/paludis/query.cc b/0.8.0/src/paludis/query.cc
new file mode 100644
index 0000000..09b1725
--- /dev/null
+++ b/0.8.0/src/paludis/query.cc
@@ -0,0 +1,418 @@
+/* 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 "colour.hh"
+#include "query.hh"
+#include "licence.hh"
+#include "use.hh"
+#include <functional>
+#include <iomanip>
+#include <iostream>
+#include <paludis/paludis.hh>
+#include <paludis/util/collection_concrete.hh>
+#include <paludis/environment/default/default_environment.hh>
+#include <string>
+
+/** \file
+ * Handle the --query action for the main paludis program.
+ */
+
+using namespace paludis;
+using std::cout;
+using std::cerr;
+using std::endl;
+
+void do_one_package_query(
+ const Environment * const env,
+ const std::string & q,
+ MaskReasons & mask_reasons_to_explain,
+ PackageDepAtom::Pointer atom)
+{
+ /* prefer the best installed version, then the best visible version, then
+ * the best version */
+ PackageDatabaseEntryCollection::ConstPointer
+ entries(env->package_database()->query(atom, is_either)),
+ preferred_entries(env->package_database()->query(atom, is_installed_only));
+ if (entries->empty())
+ throw NoSuchPackageError(q);
+ if (preferred_entries->empty())
+ preferred_entries = entries;
+
+ PackageDatabaseEntry display_entry(*preferred_entries->last());
+ for (PackageDatabaseEntryCollection::Iterator i(preferred_entries->begin()),
+ i_end(preferred_entries->end()) ; i != i_end ; ++i)
+ if (! env->mask_reasons(*i).any())
+ display_entry = *i;
+
+ /* match! display it. */
+ cout << "* " << colour(cl_package_name, entries->begin()->name);
+ if (atom->version_spec_ptr())
+ cout << " (" << atom->version_operator() << *atom->version_spec_ptr() << ")";
+ if (atom->slot_ptr())
+ cout << " (:" << *atom->slot_ptr() << ")";
+ if (atom->repository_ptr())
+ cout << " (::" << *atom->repository_ptr() << ")";
+ cout << endl;
+
+ /* find all repository names. */
+ RepositoryNameCollection::Concrete repo_names;
+ PackageDatabaseEntryCollection::Iterator e(entries->begin()), e_end(entries->end());
+ for ( ; e != e_end ; ++e)
+ repo_names.append(e->repository);
+
+ /* display versions, by repository. */
+ RepositoryNameCollection::Iterator r(repo_names.begin()), r_end(repo_names.end());
+ for ( ; r != r_end ; ++r)
+ {
+ cout << " " << std::setw(22) << std::left <<
+ (stringify(*r) + ":") << std::setw(0) << " ";
+
+ std::string old_slot;
+ for (e = entries->begin() ; e != e_end ; ++e)
+ {
+ Context context("When displaying entry '" + stringify(*e) + "':'");
+
+ if (e->repository == *r)
+ {
+ VersionMetadata::ConstPointer metadata(env->package_database()->fetch_repository(
+ e->repository)->version_metadata(e->name,
+ e->version));
+ if (CommandLine::get_instance()->a_show_slot.specified())
+ {
+ /* show the slot, if we're about to move onto a new slot */
+ std::string slot_name(stringify(metadata->slot));
+ if (old_slot.empty())
+ old_slot = slot_name;
+ else if (old_slot != slot_name)
+ cout << colour(cl_slot, "{:" + old_slot + "} ");
+ old_slot = slot_name;
+ }
+
+ const MaskReasons masks(env->mask_reasons(*e));
+
+ if (masks.none())
+ cout << colour(cl_visible, e->version);
+ else
+ {
+ std::string reasons;
+ for (MaskReason m(MaskReason(0)) ; m < last_mr ;
+ m = MaskReason(static_cast<int>(m) + 1))
+ {
+ if (! masks.test(m))
+ continue;
+
+ switch (m)
+ {
+ case mr_keyword:
+ reasons.append("K");
+ break;
+ case mr_user_mask:
+ reasons.append("U");
+ break;
+ case mr_profile_mask:
+ reasons.append("P");
+ break;
+ case mr_repository_mask:
+ reasons.append("R");
+ break;
+ case mr_eapi:
+ reasons.append("E");
+ break;
+ case mr_license:
+ reasons.append("L");
+ break;
+ case mr_by_association:
+ reasons.append("A");
+ break;
+ case last_mr:
+ break;
+ }
+ }
+ mask_reasons_to_explain |= masks;
+ cout << colour(cl_masked, "(" + stringify(e->version) + ")" + reasons);
+ }
+
+ if (*e == display_entry)
+ cout << "*";
+ cout << " ";
+ }
+ }
+
+ /* still need to show the slot for the last item */
+ if (CommandLine::get_instance()->a_show_slot.specified())
+ cout << colour(cl_slot, "{:" + old_slot + "} ");
+
+ cout << endl;
+ }
+
+ /* display metadata */
+ VersionMetadata::ConstPointer metadata(env->package_database()->fetch_repository(
+ display_entry.repository)->version_metadata(
+ display_entry.name, display_entry.version));
+
+ if (CommandLine::get_instance()->a_show_metadata.specified())
+ {
+ cout << " " << std::setw(22) << std::left << "DESCRIPTION:" << std::setw(0) <<
+ " " << metadata->description << endl;
+ cout << " " << std::setw(22) << std::left << "HOMEPAGE:" << std::setw(0) <<
+ " " << metadata->homepage << endl;
+ cout << " " << std::setw(22) << std::left << "LICENSE:" << std::setw(0) <<
+ " " << metadata->license_string << endl;
+
+ cout << " " << std::setw(22) << std::left << "DEPEND:" << std::setw(0) <<
+ " " << metadata->deps.build_depend_string << endl;
+ cout << " " << std::setw(22) << std::left << "RDEPEND:" << std::setw(0) <<
+ " " << metadata->deps.run_depend_string << endl;
+ cout << " " << std::setw(22) << std::left << "PDEPEND:" << std::setw(0) <<
+ " " << metadata->deps.post_depend_string << endl;
+
+ if (metadata->get_cran_interface())
+ {
+ cout << " " << std::setw(22) << std::left << "KEYWORDS:" << std::setw(0) <<
+ " " << metadata->get_cran_interface()->keywords << endl;
+ cout << " " << std::setw(22) << std::left << "PACKAGE:" << std::setw(0) <<
+ " " << metadata->get_cran_interface()->package << endl;
+ cout << " " << std::setw(22) << std::left << "VERSION:" << std::setw(0) <<
+ " " << metadata->get_cran_interface()->version << endl;
+ cout << " " << std::setw(22) << std::left << "IS_BUNDLE:" << std::setw(0) <<
+ " " << std::boolalpha << metadata->get_cran_interface()->is_bundle << endl;
+ }
+
+ if (metadata->get_ebuild_interface())
+ {
+ cout << " " << std::setw(22) << std::left << "IUSE:" << std::setw(0) <<
+ " " << metadata->get_ebuild_interface()->iuse << endl;
+ cout << " " << std::setw(22) << std::left << "KEYWORDS:" << std::setw(0) <<
+ " " << metadata->get_ebuild_interface()->keywords << endl;
+ cout << " " << std::setw(22) << std::left << "PROVIDE:" << std::setw(0) <<
+ " " << metadata->get_ebuild_interface()->provide_string << endl;
+ cout << " " << std::setw(22) << std::left << "RESTRICT:" << std::setw(0) <<
+ " " << metadata->get_ebuild_interface()->restrict_string << endl;
+ cout << " " << std::setw(22) << std::left << "SRC_URI:" << std::setw(0) <<
+ " " << metadata->get_ebuild_interface()->src_uri << endl;
+ }
+
+ if (metadata->get_ebin_interface())
+ {
+ cout << " " << std::setw(22) << std::left << "BIN_URI:" << std::setw(0) <<
+ " " << metadata->get_ebin_interface()->bin_uri << endl;
+ cout << " " << std::setw(22) << std::left << "SRC_REPOSITORY:" << std::setw(0) <<
+ " " << metadata->get_ebin_interface()->src_repository << endl;
+ }
+ }
+ else
+ {
+ if (! metadata->homepage.empty())
+ cout << " " << std::setw(22) << std::left << "Homepage:" << std::setw(0) <<
+ " " << metadata->homepage << endl;
+
+ if (! metadata->description.empty())
+ cout << " " << std::setw(22) << std::left << "Description:" << std::setw(0) <<
+ " " << metadata->description << endl;
+
+ if (! metadata->license_string.empty())
+ {
+ cout << " " << std::setw(22) << std::left << "License:" << std::setw(0) << " ";
+ LicenceDisplayer d(cout, env, &display_entry);
+ metadata->license()->accept(&d);
+ cout << endl;
+ }
+
+ if (CommandLine::get_instance()->a_show_deps.specified())
+ {
+ if (! metadata->deps.build_depend_string.empty())
+ {
+ DepAtomPrettyPrinter p_depend(12);
+ metadata->deps.build_depend()->accept(&p_depend);
+ cout << " " << std::setw(22) << std::left << "Build dependencies:" << std::setw(0)
+ << endl << p_depend;
+ }
+
+ if (! metadata->deps.run_depend_string.empty())
+ {
+ DepAtomPrettyPrinter p_depend(12);
+ metadata->deps.run_depend()->accept(&p_depend);
+ cout << " " << std::setw(22) << std::left << "Runtime dependencies:" << std::setw(0)
+ << endl << p_depend;
+ }
+
+ if (! metadata->deps.post_depend_string.empty())
+ {
+ DepAtomPrettyPrinter p_depend(12);
+ metadata->deps.post_depend()->accept(&p_depend);
+ cout << " " << std::setw(22) << std::left << "Post dependencies:" << std::setw(0)
+ << endl << p_depend;
+ }
+ }
+
+ if (metadata->get_ebuild_interface())
+ {
+ if (! metadata->get_ebuild_interface()->provide_string.empty())
+ cout << " " << std::setw(22) << std::left << "Provides:" << std::setw(0) <<
+ " " << metadata->get_ebuild_interface()->provide_string << endl;
+
+ if (! metadata->get_ebuild_interface()->iuse.empty())
+ cout << " " << std::setw(22) << std::left << "Use flags:" << std::setw(0) <<
+ " " << make_pretty_use_flags_string(DefaultEnvironment::get_instance(),
+ display_entry, metadata) << endl;
+ }
+
+ if (metadata->get_virtual_interface())
+ cout << " " << std::setw(22) << std::left << "Virtual for:" << std::setw(0) <<
+ " " << metadata->get_virtual_interface()->virtual_for << endl;
+ }
+
+
+ /* blank line */
+ cout << endl;
+}
+
+void do_one_set_query(
+ const Environment * const,
+ const std::string & q,
+ MaskReasons &,
+ DepAtom::Pointer set)
+{
+ cout << "* " << colour(cl_package_name, q) << endl;
+ DepAtomPrettyPrinter packages(12);
+ set->accept(&packages);
+ cout << " " << std::setw(22) << std::left << "Packages:" << std::setw(0)
+ << endl << packages << endl;
+}
+
+void do_one_query(
+ const Environment * const env,
+ const std::string & q,
+ MaskReasons & mask_reasons_to_explain)
+{
+ Context local_context("When handling query '" + q + "':");
+
+ /* we might have a dep atom, but we might just have a simple package name
+ * without a category. or it might be a set... all should work. */
+ PackageDepAtom::Pointer atom(0);
+ DepAtom::Pointer set(0);
+ if (std::string::npos == q.find('/'))
+ {
+ if (0 == ((set = env->package_set(q))))
+ atom.assign(new PackageDepAtom(env->package_database()->fetch_unique_qualified_package_name(
+ PackageNamePart(q))));
+ }
+ else
+ atom.assign(new PackageDepAtom(q));
+
+ if (atom)
+ do_one_package_query(env, q, mask_reasons_to_explain, atom);
+ else
+ do_one_set_query(env, q, mask_reasons_to_explain, set);
+}
+
+int do_query()
+{
+ int return_code(0);
+
+ Context context("When performing query action from command line:");
+ Environment * const env(DefaultEnvironment::get_instance());
+
+ MaskReasons mask_reasons_to_explain;
+
+ CommandLine::ParametersIterator q(CommandLine::get_instance()->begin_parameters()),
+ q_end(CommandLine::get_instance()->end_parameters());
+ for ( ; q != q_end ; ++q)
+ {
+ try
+ {
+ do_one_query(env, *q, mask_reasons_to_explain);
+ }
+ catch (const AmbiguousPackageNameError & e)
+ {
+ cout << endl;
+ cerr << "Query error:" << endl;
+ cerr << " * " << e.backtrace("\n * ");
+ cerr << "Ambiguous package name '" << e.name() << "'. Did you mean:" << endl;
+ for (AmbiguousPackageNameError::OptionsIterator o(e.begin_options()),
+ o_end(e.end_options()) ; o != o_end ; ++o)
+ cerr << " * " << colour(cl_package_name, *o) << endl;
+ cerr << endl;
+ }
+ catch (const NameError & e)
+ {
+ return_code |= 1;
+ cout << endl;
+ cerr << "Query error:" << endl;
+ cerr << " * " << e.backtrace("\n * ") << e.message() << endl;
+ cerr << endl;
+ }
+ catch (const PackageDatabaseLookupError & e)
+ {
+ return_code |= 1;
+ cout << endl;
+ cerr << "Query error:" << endl;
+ cerr << " * " << e.backtrace("\n * ") << e.message() << endl;
+ cerr << endl;
+ }
+ }
+
+ if (mask_reasons_to_explain.any())
+ {
+ cout << colour(cl_heading, "Key to mask reasons:") << endl << endl;
+
+ /* use for/case to get compiler warnings when new mr_ are added */
+ for (MaskReason m(MaskReason(0)) ; m < last_mr ;
+ m = MaskReason(static_cast<int>(m) + 1))
+ {
+ if (! mask_reasons_to_explain.test(m))
+ continue;
+
+ switch (m)
+ {
+ case mr_keyword:
+ cout << "* " << colour(cl_masked, "K") << ": keyword";
+ break;
+ case mr_user_mask:
+ cout << "* " << colour(cl_masked, "U") << ": user mask";
+ break;
+ case mr_profile_mask:
+ cout << "* " << colour(cl_masked, "P") << ": profile mask";
+ break;
+ case mr_repository_mask:
+ cout << "* " << colour(cl_masked, "R") << ": repository mask";
+ break;
+ case mr_eapi:
+ cout << "* " << colour(cl_masked, "E") << ": EAPI";
+ break;
+ case mr_license:
+ cout << "* " << colour(cl_masked, "L") << ": licence";
+ break;
+ case mr_by_association:
+ cout << "* " << colour(cl_masked, "A") << ": by association";
+ break;
+
+ case last_mr:
+ break;
+ }
+
+ cout << endl;
+ }
+
+ cout << endl;
+ }
+
+ return return_code;
+}
+
diff --git a/0.8.0/src/paludis/query.hh b/0.8.0/src/paludis/query.hh
new file mode 100644
index 0000000..62e7e02
--- /dev/null
+++ b/0.8.0/src/paludis/query.hh
@@ -0,0 +1,32 @@
+/* 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_QUERY_HH
+#define PALUDIS_GUARD_SRC_QUERY_HH 1
+
+#include "command_line.hh"
+
+/** \file
+ * Declaration for the do_query function.
+ */
+
+/// Handle --query.
+int do_query();
+
+#endif
diff --git a/0.8.0/src/paludis/sync.cc b/0.8.0/src/paludis/sync.cc
new file mode 100644
index 0000000..89f08eb
--- /dev/null
+++ b/0.8.0/src/paludis/sync.cc
@@ -0,0 +1,129 @@
+/* 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 "colour.hh"
+#include "sync.hh"
+#include <paludis/tasks/sync_task.hh>
+#include <paludis/environment/default/default_environment.hh>
+#include <paludis/syncer.hh>
+#include <iomanip>
+#include <iostream>
+#include <string>
+
+/** \file
+ * Handle the --sync action for the main paludis program.
+ */
+
+using namespace paludis;
+using std::cerr;
+using std::cout;
+using std::endl;
+
+namespace
+{
+ class OurSyncTask :
+ public SyncTask
+ {
+ private:
+ int _return_code;
+
+ public:
+ OurSyncTask() :
+ SyncTask(DefaultEnvironment::get_instance()),
+ _return_code(0)
+ {
+ }
+
+ virtual void on_sync_all_pre();
+ virtual void on_sync_pre(const RepositoryName &);
+ virtual void on_sync_post(const RepositoryName &);
+ virtual void on_sync_skip(const RepositoryName &);
+ virtual void on_sync_fail(const RepositoryName &, const SyncFailedError &);
+ virtual void on_sync_succeed(const RepositoryName &);
+ virtual void on_sync_all_post();
+
+ int return_code() const
+ {
+ return _return_code;
+ }
+ };
+
+ void
+ OurSyncTask::on_sync_all_pre()
+ {
+ }
+
+ void
+ OurSyncTask::on_sync_pre(const RepositoryName & r)
+ {
+ cout << colour(cl_heading, "Sync " + stringify(r)) << endl;
+ cerr << xterm_title("Syncing " + stringify(r));
+ }
+
+ void
+ OurSyncTask::on_sync_post(const RepositoryName &)
+ {
+ }
+
+ void
+ OurSyncTask::on_sync_skip(const RepositoryName & r)
+ {
+ cout << "Sync " << r << " skipped" << endl;
+ }
+
+ void
+ OurSyncTask::on_sync_succeed(const RepositoryName & r)
+ {
+ cout << "Sync " << r << " completed" << endl;
+ }
+
+ void
+ OurSyncTask::on_sync_fail(const RepositoryName & r, const SyncFailedError & e)
+ {
+ _return_code |= 1;
+ cout << endl;
+ cerr << "Sync error:" << endl;
+ cerr << " * " << e.backtrace("\n * ") << e.message() << endl;
+ cerr << endl;
+ cout << "Sync " << r << " failed" << endl;
+ }
+
+ void
+ OurSyncTask::on_sync_all_post()
+ {
+ cout << endl;
+ }
+}
+
+int do_sync()
+{
+ Context context("When performing sync action from command line:");
+
+ OurSyncTask task;
+
+ for (CommandLine::ParametersIterator q(CommandLine::get_instance()->begin_parameters()),
+ q_end(CommandLine::get_instance()->end_parameters()) ; q != q_end ; ++q)
+ task.add_target(*q);
+
+ task.execute();
+
+ return task.return_code();
+}
+
+
diff --git a/0.8.0/src/paludis/sync.hh b/0.8.0/src/paludis/sync.hh
new file mode 100644
index 0000000..92c518c
--- /dev/null
+++ b/0.8.0/src/paludis/sync.hh
@@ -0,0 +1,33 @@
+/* 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_SYNC_HH
+#define PALUDIS_GUARD_SRC_SYNC_HH 1
+
+#include "command_line.hh"
+
+/** \file
+ * Declaration for the do_sync function.
+ */
+
+/// Handle --sync.
+int do_sync();
+
+#endif
+
diff --git a/0.8.0/src/paludis/uninstall.cc b/0.8.0/src/paludis/uninstall.cc
new file mode 100644
index 0000000..b34268a
--- /dev/null
+++ b/0.8.0/src/paludis/uninstall.cc
@@ -0,0 +1,185 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 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 "colour.hh"
+#include "uninstall.hh"
+
+#include <paludis/environment/default/default_environment.hh>
+#include <paludis/tasks/uninstall_task.hh>
+
+#include <iostream>
+
+/** \file
+ * Handle the --uninstall action for the main paludis program.
+ */
+
+using namespace paludis;
+
+using std::cerr;
+using std::cout;
+using std::endl;
+
+namespace
+{
+ class OurUninstallTask :
+ public UninstallTask
+ {
+ private:
+ int _count, _current_count;
+
+ public:
+ OurUninstallTask() :
+ UninstallTask(DefaultEnvironment::get_instance()),
+ _count(0),
+ _current_count(0)
+ {
+ };
+
+ virtual void on_build_unmergelist_pre()
+ {
+ cout << "Building unmerge list... " << std::flush;
+ }
+
+ virtual void on_build_unmergelist_post()
+ {
+ cout << "done" << endl;
+ }
+
+ virtual void on_display_unmerge_list_pre()
+ {
+ cout << endl << colour(cl_heading, "These packages will be uninstalled:")
+ << endl << endl;
+ }
+
+ virtual void on_display_unmerge_list_post()
+ {
+ cout << endl << endl <<
+ "Total: " << _count << (_count == 1 ? " package" : " packages") << endl;
+ }
+
+ virtual void on_display_unmerge_list_entry(const PackageDatabaseEntry & d)
+ {
+ cout << "* " << colour(cl_package_name, stringify(d)) << endl;
+ ++_count;
+ }
+
+ virtual void on_uninstall_all_pre()
+ {
+ }
+
+ virtual void on_uninstall_pre(const PackageDatabaseEntry & d)
+ {
+ cout << endl << colour(cl_heading, "Uninstalling " +
+ stringify(d.name) + "-" + stringify(d.version) +
+ "::" + stringify(d.repository)) << endl << endl;
+
+ cerr << xterm_title("(" + stringify(++_current_count) + " of " +
+ stringify(_count) + ") Uninstalling " +
+ stringify(d.name) + "-" + stringify(d.version) +
+ "::" + stringify(d.repository));
+ }
+
+ virtual void on_uninstall_post(const PackageDatabaseEntry &)
+ {
+ }
+
+ virtual void on_uninstall_all_post()
+ {
+ }
+
+ virtual void on_update_world_pre()
+ {
+ cout << endl << colour(cl_heading, "Updating world file") << endl << endl;
+ }
+
+ virtual void on_update_world(const PackageDepAtom & a)
+ {
+ cout << "* removing " << colour(cl_package_name, a.package()) << endl;
+ }
+
+ virtual void on_update_world_post()
+ {
+ cout << endl;
+ }
+
+ virtual void on_preserve_world()
+ {
+ cout << endl << colour(cl_heading, "Updating world file") << endl << endl;
+ cout << "* --preserve-world was specified, skipping world changes" << endl;
+ cout << endl;
+ }
+ };
+}
+
+int
+do_uninstall()
+{
+ int return_code(0);
+
+ Context context("When performing uninstall action from command line:");
+
+ OurUninstallTask task;
+
+ task.set_pretend(CommandLine::get_instance()->a_pretend.specified());
+ task.set_no_config_protect(CommandLine::get_instance()->a_no_config_protection.specified());
+ task.set_preserve_world(CommandLine::get_instance()->a_preserve_world.specified());
+
+ try
+ {
+ for (CommandLine::ParametersIterator q(CommandLine::get_instance()->begin_parameters()),
+ q_end(CommandLine::get_instance()->end_parameters()) ; q != q_end ; ++q)
+ task.add_target(*q);
+
+ task.execute();
+
+ cout << endl;
+ }
+ catch (const AmbiguousUnmergeTargetError & e)
+ {
+ cout << endl;
+ cerr << "Query error:" << endl;
+ cerr << " * " << e.backtrace("\n * ");
+ cerr << "Ambiguous unmerge target '" << e.target() << "'. Did you mean:" << endl;
+ for (AmbiguousUnmergeTargetError::Iterator o(e.begin()),
+ o_end(e.end()) ; o != o_end ; ++o)
+ cerr << " * =" << colour(cl_package_name, *o) << endl;
+ cerr << endl;
+ return 1;
+ }
+ catch (const PackageUninstallActionError & e)
+ {
+ cout << endl;
+ cerr << "Uninstall error:" << endl;
+ cerr << " * " << e.backtrace("\n * ");
+ cerr << e.message() << endl;
+
+ return_code |= 1;
+ }
+ catch (const NoSuchPackageError & e)
+ {
+ cout << endl;
+ cerr << "Query error:" << endl;
+ cerr << " * " << e.backtrace("\n * ");
+ cerr << "No such package '" << e.name() << "'" << endl;
+ return 1;
+ }
+
+ return return_code;
+}
+
diff --git a/0.8.0/src/paludis/uninstall.hh b/0.8.0/src/paludis/uninstall.hh
new file mode 100644
index 0000000..a2a49ff
--- /dev/null
+++ b/0.8.0/src/paludis/uninstall.hh
@@ -0,0 +1,33 @@
+/* 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_UNINSTALL_HH
+#define PALUDIS_GUARD_SRC_UNINSTALL_HH 1
+
+#include "command_line.hh"
+
+/** \file
+ * Declaration for the do_uninstall function.
+ */
+
+/// Handle --uninstall.
+int do_uninstall();
+
+#endif
+
diff --git a/0.8.0/src/paludis/upgrade_TEST b/0.8.0/src/paludis/upgrade_TEST
new file mode 100755
index 0000000..48b315f
--- /dev/null
+++ b/0.8.0/src/paludis/upgrade_TEST
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+PALUDIS_HOME=./upgrade_TEST_dir/config/ \
+ ./paludis --config-suffix upgrade-test --install =test-category/target-1 || exit 1
+
+./upgrade_TEST_dir/root/usr/bin/testbin | grep testbin-1 >/dev/null || exit 1
+./upgrade_TEST_dir/root/usr/bin/testbin1 | grep testbin1 >/dev/null || exit 1
+./upgrade_TEST_dir/root/usr/bin/testbin2 && exit 1
+
+
+PALUDIS_HOME=./upgrade_TEST_dir/config/ \
+ ./paludis --config-suffix upgrade-test --install target || exit 1
+
+./upgrade_TEST_dir/root/usr/bin/testbin | grep testbin-2 >/dev/null || exit 1
+./upgrade_TEST_dir/root/usr/bin/testbin1 && exit 1
+./upgrade_TEST_dir/root/usr/bin/testbin2 | grep testbin2 >/dev/null || exit 1
+
diff --git a/0.8.0/src/paludis/upgrade_TEST_cleanup.sh b/0.8.0/src/paludis/upgrade_TEST_cleanup.sh
new file mode 100755
index 0000000..bc42e78
--- /dev/null
+++ b/0.8.0/src/paludis/upgrade_TEST_cleanup.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+if [ -d upgrade_TEST_dir ] ; then
+ rm -fr upgrade_TEST_dir
+else
+ true
+fi
+
+
+
diff --git a/0.8.0/src/paludis/upgrade_TEST_setup.sh b/0.8.0/src/paludis/upgrade_TEST_setup.sh
new file mode 100755
index 0000000..52e6958
--- /dev/null
+++ b/0.8.0/src/paludis/upgrade_TEST_setup.sh
@@ -0,0 +1,153 @@
+#!/bin/bash
+# vim: set ft=sh sw=4 sts=4 et :
+
+mkdir upgrade_TEST_dir || exit 1
+cd upgrade_TEST_dir || exit 1
+
+mkdir -p config/.paludis-upgrade-test
+cat <<END > config/.paludis-upgrade-test/specpath
+root = `pwd`/root
+config-suffix =
+END
+
+mkdir -p root/${SYSCONFDIR}/paludis/repositories
+cat <<END > root/${SYSCONFDIR}/paludis/use.conf
+* foo
+END
+
+cat <<END > root/${SYSCONFDIR}/paludis/licenses.conf
+* *
+END
+
+cat <<END > root/${SYSCONFDIR}/paludis/keywords.conf
+* test
+END
+
+cat <<END > root/${SYSCONFDIR}/paludis/bashrc
+export CHOST="my-chost"
+export USER_BASHRC_WAS_USED=yes
+END
+
+cat <<END > root/${SYSCONFDIR}/paludis/repositories/repo1.conf
+location = `pwd`/repo1
+cache = /var/empty
+format = portage
+profiles = \${location}/profiles/testprofile
+buildroot = `pwd`/build
+END
+
+cat <<END > root/${SYSCONFDIR}/paludis/repositories/installed.conf
+location = \${ROOT}/var/db/pkg
+format = vdb
+buildroot = `pwd`/build
+END
+
+mkdir -p root/tmp
+touch root/${SYSCONFDIR}/ld.so.conf
+mkdir -p root/var/db/pkg
+
+mkdir -p repo1/{eclass,distfiles,profiles/testprofile,test-category/target/files} || exit 1
+
+mkdir -p src/target-1
+cat <<"END" > src/target-1/testbin
+#!/bin/bash
+echo "This is testbin-1"
+END
+chmod +x src/target-1/testbin
+cat <<"END" > src/target-1/testbin1
+#!/bin/bash
+echo "This is testbin1"
+END
+chmod +x src/target-1/testbin1
+cd src
+tar zcf target-1.tar.gz target-1/
+mv target-1.tar.gz ../repo1/distfiles/
+cd ..
+rm -fr src
+
+mkdir -p src/target-2
+cat <<"END" > src/target-2/testbin
+#!/bin/bash
+echo "This is testbin-2"
+END
+chmod +x src/target-2/testbin
+cat <<"END" > src/target-2/testbin2
+#!/bin/bash
+echo "This is testbin2"
+END
+chmod +x src/target-2/testbin2
+cd src
+tar zcf target-2.tar.gz target-2/
+mv target-2.tar.gz ../repo1/distfiles/
+cd ..
+rm -fr src
+
+cd repo1 || exit 1
+echo "test-repo-1" > profiles/repo_name || exit 1
+cat <<END > profiles/categories || exit 1
+test-category
+END
+cat <<END > profiles/testprofile/make.defaults
+ARCH=test
+USERLAND=test
+KERNEL=test
+END
+
+cat <<"END" > eclass/myeclass.eclass || exit 1
+the_eclass_works()
+{
+ true
+}
+END
+
+cat <<"END" > test-category/target/target-1.ebuild || exit 1
+inherit myeclass
+
+DESCRIPTION="Test target"
+HOMEPAGE="http://paludis.berlios.de/"
+SRC_URI="http://invalid.domain/${P}.tar.gz"
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+
+pkg_setup() {
+ export VAR1=yes
+ VAR2=yes
+ local VAR3=yes
+}
+
+src_install() {
+ [[ "${VAR1}" == yes ]] || die
+ [[ "${VAR2}" == yes ]] || die
+ [[ "${VAR3}" == yes ]] && die
+
+ dobin testbin
+ dobin testbin${PV}
+}
+
+pkg_prerm() {
+ [[ "${VAR1}" == yes ]] || die
+ [[ "${VAR2}" == yes ]] || die
+ [[ "${VAR3}" == yes ]] && die
+
+ the_eclass_works || die
+}
+END
+
+cat <<"END" > test-category/target/target-2.ebuild || exit 1
+DESCRIPTION="Test target"
+HOMEPAGE="http://paludis.berlios.de/"
+SRC_URI="http://invalid.domain/${P}.tar.gz"
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+
+src_install() {
+ dobin testbin
+ dobin testbin${PV}
+}
+END
+cd ..
+
diff --git a/0.8.0/src/paludis/use.cc b/0.8.0/src/paludis/use.cc
new file mode 100644
index 0000000..f598e48
--- /dev/null
+++ b/0.8.0/src/paludis/use.cc
@@ -0,0 +1,125 @@
+/* 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 "use.hh"
+#include "colour.hh"
+#include <paludis/util/tokeniser.hh>
+#include <sstream>
+#include <set>
+
+using namespace paludis;
+
+namespace
+{
+ std::string::size_type
+ use_expand_delim_pos(const UseFlagName & u, const UseFlagNameCollection::ConstPointer c)
+ {
+ for (UseFlagNameCollection::Iterator i(c->begin()), i_end(c->end()) ; i != i_end ; ++i)
+ if (0 == u.data().compare(0, i->data().length(), i->data(), 0, i->data().length()))
+ return i->data().length();
+ return std::string::npos;
+ }
+}
+
+std::string
+make_pretty_use_flags_string(const Environment * const env, const PackageDatabaseEntry & p,
+ VersionMetadata::ConstPointer metadata, const PackageDatabaseEntry * const other_p)
+{
+ std::ostringstream c;
+
+ if (metadata->get_ebuild_interface())
+ {
+ const RepositoryUseInterface * const use_interface(
+ env->package_database()->
+ fetch_repository(p.repository)->use_interface);
+ std::set<UseFlagName> iuse;
+ WhitespaceTokeniser::get_instance()->tokenise(
+ metadata->get_ebuild_interface()->iuse,
+ create_inserter<UseFlagName>(std::inserter(iuse, iuse.end())));
+
+ /* display normal use flags first */
+ for (std::set<UseFlagName>::const_iterator i(iuse.begin()), i_end(iuse.end()) ;
+ i != i_end ; ++i)
+ {
+ if (std::string::npos != use_expand_delim_pos(*i, use_interface->use_expand_prefixes()))
+ continue;
+
+ if (env->query_use(*i, &p))
+ {
+ if (use_interface && use_interface->query_use_force(*i, &p))
+ c << " " << colour(cl_flag_on, "(" + stringify(*i) + ")");
+ else
+ c << " " << colour(cl_flag_on, *i);
+ }
+ else
+ {
+ if (use_interface && use_interface->query_use_mask(*i, &p))
+ c << " " << colour(cl_flag_off, "(-" + stringify(*i) + ")");
+ else
+ c << " " << colour(cl_flag_off, "-" + stringify(*i));
+ }
+
+ if (other_p)
+ if (env->query_use(*i, &p) != env->query_use(*i, other_p))
+ c << "*";
+ }
+
+ /* now display expand flags */
+ UseFlagName old_expand_name("OFTEN_NOT_BEEN_ON_BOATS");
+ for (std::set<UseFlagName>::const_iterator i(iuse.begin()), i_end(iuse.end()) ;
+ i != i_end ; ++i)
+ {
+ std::string::size_type delim_pos;
+ if (std::string::npos == ((delim_pos = use_expand_delim_pos(*i, use_interface->use_expand_prefixes()))))
+ continue;
+ if (use_interface->use_expand_hidden_prefixes()->count(UseFlagName(i->data().substr(0, delim_pos))))
+ continue;
+
+ UseFlagName expand_name(i->data().substr(0, delim_pos)), expand_value(i->data().substr(delim_pos + 1));
+
+ if (expand_name != old_expand_name)
+ {
+ c << " " << expand_name << ":";
+ old_expand_name = expand_name;
+ }
+
+ if (env->query_use(*i, &p))
+ {
+ if (use_interface && use_interface->query_use_force(*i, &p))
+ c << " " << colour(cl_flag_on, "(" + stringify(expand_value) + ")");
+ else
+ c << " " << colour(cl_flag_on, expand_value);
+ }
+ else
+ {
+ if (use_interface && use_interface->query_use_mask(*i, &p))
+ c << " " << colour(cl_flag_off, "(-" + stringify(expand_value) + ")");
+ else
+ c << " " << colour(cl_flag_off, "-" + stringify(expand_value));
+ }
+
+ if (other_p)
+ if (env->query_use(*i, &p) != env->query_use(*i, other_p))
+ c << "*";
+ }
+ }
+
+ return c.str();
+}
+
diff --git a/0.8.0/src/paludis/use.hh b/0.8.0/src/paludis/use.hh
new file mode 100644
index 0000000..ed7e846
--- /dev/null
+++ b/0.8.0/src/paludis/use.hh
@@ -0,0 +1,36 @@
+/* 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_PALUDIS_USE_HH
+#define PALUDIS_GUARD_SRC_PALUDIS_USE_HH 1
+
+#include <paludis/name.hh>
+#include <paludis/environment.hh>
+#include <paludis/package_database_entry.hh>
+#include <paludis/version_metadata.hh>
+
+/**
+ * Make a nice string for outputting USE flags.
+ */
+std::string
+make_pretty_use_flags_string(const paludis::Environment * const env, const paludis::PackageDatabaseEntry & p,
+ paludis::VersionMetadata::ConstPointer metadata, const paludis::PackageDatabaseEntry * const other_p = 0)
+ PALUDIS_ATTRIBUTE((nonnull(1)));
+
+#endif
diff --git a/0.8.0/src/paludis/version_TEST b/0.8.0/src/paludis/version_TEST
new file mode 100755
index 0000000..02513f0
--- /dev/null
+++ b/0.8.0/src/paludis/version_TEST
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+PALUDIS_SKIP_CONFIG=yes ./paludis --version