aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-09-02 14:37:50 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-09-02 14:37:50 +0000
commitaacf415f9ebb785f313f66a7dcf09192580adc58 (patch)
treeb84e63521f6b7d66a086783daacc8576f890af03
parentb36f8a4bc2fd8e8471332700f1b2a0f53606cb04 (diff)
downloadpaludis-aacf415f9ebb785f313f66a7dcf09192580adc58.tar.gz
paludis-aacf415f9ebb785f313f66a7dcf09192580adc58.tar.xz
Add instruo, a metadata generation client
-rw-r--r--Makefile.am3
-rw-r--r--configure.ac4
-rw-r--r--doc/Makefile.am12
-rw-r--r--doc/index.html.skel17
-rw-r--r--paludis/repositories/e/e_repository.cc1
-rw-r--r--paludis/repositories/e/e_repository_params.sr1
-rw-r--r--paludis/repositories/e/ebuild_id.cc3
-rw-r--r--paludis/repositories/e/make_ebin_repository.cc1
-rw-r--r--paludis/repositories/e/make_ebuild_repository.cc8
-rw-r--r--src/clients/instruo/Makefile.am83
-rw-r--r--src/clients/instruo/command_line.cc77
-rw-r--r--src/clients/instruo/command_line.hh62
-rwxr-xr-xsrc/clients/instruo/help_TEST5
-rw-r--r--src/clients/instruo/instruo.cc351
-rw-r--r--src/clients/instruo/man_instruo.cc80
-rwxr-xr-xsrc/clients/instruo/version_TEST4
16 files changed, 702 insertions, 10 deletions
diff --git a/Makefile.am b/Makefile.am
index 75dceef..7312973 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -10,7 +10,7 @@ DISTCHECK_CONFIGURE_FLAGS = --enable-qa --enable-ruby --enable-glsa --enable-vim
--with-ruby-install-dir='$${DESTDIR}$${prefix}/ruby_dir' \
--with-repositories=default \
--with-environments=default,portage \
- --with-clients=default,accerso,contrarius,inquisitio \
+ --with-clients=default,accerso,contrarius,inquisitio,instruo \
--with-default-distribution=giant-space-monkey
automake-deps-built-hack.tmp : built-sources-subdirs
@@ -30,6 +30,7 @@ automake-deps-dist-hack.tmp : built-sources-subdirs
$(MAKE) -C src/clients/adjutrix adjutrix.1 adjutrix.html
$(MAKE) -C src/clients/inquisitio inquisitio.1 inquisitio.html
$(MAKE) -C src/clients/accerso accerso.1 accerso.html
+ $(MAKE) -C src/clients/instruo instruo.1 instruo.html
touch $@
dist-hook :
diff --git a/configure.ac b/configure.ac
index 50b878e..0c96fff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -983,7 +983,7 @@ AC_DEFINE_UNQUOTED([DEFAULT_DISTRIBUTION], "$DEFAULT_DISTRIBUTION", [Default dis
dnl }}}
dnl {{{ clients
-ALL_CLIENTS="accerso adjutrix contrarius gtkpaludis inquisitio paludis qualudis"
+ALL_CLIENTS="accerso adjutrix contrarius gtkpaludis inquisitio instruo paludis qualudis"
DEFAULT_CLIENTS="adjutrix paludis"
if test x"$ENABLE_QA" = "xyes" ; then
DEFAULT_CLIENTS="$DEFAULT_CLIENTS qualudis"
@@ -1001,6 +1001,7 @@ AC_ARG_WITH([clients],
contrarius The cross toolchain creator
gtkpaludis GUI client (experimental)
inquisitio A search client
+ instruo A metadata generation client
paludis The Paludis console client
qualudis The QA console client],
[clients="`echo $with_clients | tr ',' ' '`"],
@@ -1280,6 +1281,7 @@ AC_OUTPUT(
src/clients/gtkpaludis/vtemm/converts/Makefile
src/clients/gtkpaludis/vtemm/defs/Makefile
src/clients/inquisitio/Makefile
+ src/clients/instruo/Makefile
src/clients/paludis/Makefile
src/clients/qualudis/Makefile
src/common_args/Makefile
diff --git a/doc/Makefile.am b/doc/Makefile.am
index a656c24..f0cf546 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -34,6 +34,7 @@ htmlfiles = \
man-contrarius.html \
man-adjutrix.html \
man-accerso.html \
+ man-instruo.html \
man-inquisitio.html
EXTRA_DIST = doxygen.conf.in header.html footer.html paludis.css epydoc.css \
@@ -46,7 +47,7 @@ EXTRA_DIST = doxygen.conf.in header.html footer.html paludis.css epydoc.css \
CLEANFILES = *~ news.html index.html changelog.html licence.html authors.html faq.html \
migration.html cachefiles.html configuration.html portagedifferences.html programmingwithpaludis.html \
sets.html hooks.html man-paludis.html man-qualudis.html man-contrarius.html man-adjutrix.html man-inquisitio.html \
- man-accerso.html \
+ man-accerso.html man-instruo.html \
cleannews cleanrecentnews cleanchangelog cleanauthors cleanfaqtoc cleanbasiccppapp cleanbasicrubyapp
MAINTAINERCLEANFILES = Makefile.in $(tagfiles)
@@ -280,6 +281,15 @@ man-accerso.html : $(top_builddir)/src/clients/accerso/accerso.html man.html.ske
-e '/@MAN@/d' \
< $(srcdir)/man.html.skel > man-accerso.html
+man-instruo.html : $(top_builddir)/src/clients/instruo/instruo.html man.html.skel
+ sed -e '/@HEADER@/r htmlheader.html' \
+ -e '/@HEADER@/d' \
+ -e '/@FOOTER@/r htmlfooter.html' \
+ -e '/@FOOTER@/d' \
+ -e '/@MAN@/r $(top_builddir)/src/clients/instruo/instruo.html' \
+ -e '/@MAN@/d' \
+ < $(srcdir)/man.html.skel > man-instruo.html
+
man-inquisitio.html : $(top_builddir)/src/clients/inquisitio/inquisitio.html man.html.skel
sed -e '/@HEADER@/r htmlheader.html' \
-e '/@HEADER@/d' \
diff --git a/doc/index.html.skel b/doc/index.html.skel
index 36b0492..d0d9b8e 100644
--- a/doc/index.html.skel
+++ b/doc/index.html.skel
@@ -54,12 +54,17 @@
<li>Manual pages:
<ul>
- <li><a href="man-accerso.html">accerso</a></li>
- <li><a href="man-adjutrix.html">adjutrix</a></li>
- <li><a href="man-contrarius.html">contrarius</a></li>
- <li><a href="man-inquisitio.html">inquisitio</a></li>
- <li><a href="man-paludis.html">paludis</a></li>
- <li><a href="man-qualudis.html">qualudis</a></li>
+ <li><a href="man-accerso.html">accerso</a>, the mirror client</li>
+ <li><a href="man-adjutrix.html">adjutrix</a>, the developer tools
+ client</li>
+ <li><a href="man-contrarius.html">contrarius</a>, the
+ cross-toolchain generation client</li>
+ <li><a href="man-inquisitio.html">inquisitio</a>, the search client</li>
+ <li><a href="man-instruo.html">instruo</a>, the metadata generation
+ client</li>
+ <li><a href="man-paludis.html">paludis</a>, the console package
+ management client</li>
+ <li><a href="man-qualudis.html">qualudis</a>, the QA client</li>
</ul>
</li>
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index 3c6cc63..57a726d 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -329,6 +329,7 @@ ERepository::ERepository(const ERepositoryParams & p) :
_imp->params.profiles->end(), " "));
config_info->add_kv("cache", stringify(_imp->params.cache));
config_info->add_kv("write_cache", stringify(_imp->params.write_cache));
+ config_info->add_kv("append_repository_name_to_write_cache", stringify(_imp->params.append_repository_name_to_write_cache));
config_info->add_kv("names_cache", stringify(_imp->params.names_cache));
config_info->add_kv("distdir", stringify(_imp->params.distdir));
config_info->add_kv("eclassdirs", join(_imp->params.eclassdirs->begin(),
diff --git a/paludis/repositories/e/e_repository_params.sr b/paludis/repositories/e/e_repository_params.sr
index 5c862f7..7d254c1 100644
--- a/paludis/repositories/e/e_repository_params.sr
+++ b/paludis/repositories/e/e_repository_params.sr
@@ -12,6 +12,7 @@ make_class_ERepositoryParams()
key profiles "tr1::shared_ptr<const FSEntrySequence>"
key cache FSEntry
key write_cache FSEntry
+ key append_repository_name_to_write_cache bool
key names_cache FSEntry
key distdir FSEntry
key eclassdirs "tr1::shared_ptr<const FSEntrySequence>"
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index 43107aa..dd162cf 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -152,7 +152,8 @@ EbuildID::need_keys_added() const
cache_file /= stringify(name().package) + "-" + stringify(version());
FSEntry write_cache_file(_imp->repository->params().write_cache);
- write_cache_file /= stringify(repository()->name());
+ if (_imp->repository->params().append_repository_name_to_write_cache)
+ write_cache_file /= stringify(repository()->name());
write_cache_file /= stringify(name().category);
write_cache_file /= stringify(name().package) + "-" + stringify(version());
diff --git a/paludis/repositories/e/make_ebin_repository.cc b/paludis/repositories/e/make_ebin_repository.cc
index 9573a76..022df06 100644
--- a/paludis/repositories/e/make_ebin_repository.cc
+++ b/paludis/repositories/e/make_ebin_repository.cc
@@ -198,6 +198,7 @@ paludis::make_ebin_repository(
.eapi_when_unknown(eapi_when_unknown)
.profile_eapi(profile_eapi)
.use_manifest(use_manifest)
+ .append_repository_name_to_write_cache(true)
.buildroot(buildroot)));
}
diff --git a/paludis/repositories/e/make_ebuild_repository.cc b/paludis/repositories/e/make_ebuild_repository.cc
index 041bebd..8ff28d3 100644
--- a/paludis/repositories/e/make_ebuild_repository.cc
+++ b/paludis/repositories/e/make_ebuild_repository.cc
@@ -139,6 +139,13 @@ paludis::make_ebuild_repository(
write_cache = DistributionData::get_instance()->distribution_from_string(
env->default_distribution())->default_ebuild_write_cache;
+ bool append_repository_name_to_write_cache(true);
+ if (m->end() != m->find("append_repository_name_to_write_cache") && ! m->find("append_repository_name_to_write_cache")->second.empty())
+ {
+ Context item_context("When handling append_repository_name_to_write_cache key:");
+ append_repository_name_to_write_cache = destringify<bool>(m->find("append_repository_name_to_write_cache")->second);
+ }
+
std::string eapi_when_unknown;
if (m->end() == m->find("eapi_when_unknown") || ((eapi_when_unknown = m->find("eapi_when_unknown")->second)).empty())
eapi_when_unknown = DistributionData::get_instance()->distribution_from_string(
@@ -225,6 +232,7 @@ paludis::make_ebuild_repository(
.eapi_when_unspecified(eapi_when_unspecified)
.profile_eapi(profile_eapi)
.use_manifest(use_manifest)
+ .append_repository_name_to_write_cache(append_repository_name_to_write_cache)
.buildroot(buildroot)));
}
diff --git a/src/clients/instruo/Makefile.am b/src/clients/instruo/Makefile.am
new file mode 100644
index 0000000..a5fdfee
--- /dev/null
+++ b/src/clients/instruo/Makefile.am
@@ -0,0 +1,83 @@
+AM_CXXFLAGS = -I$(top_srcdir) -I$(top_srcdir)/src \
+ @PALUDIS_CXXFLAGS@ @PALUDIS_CXXFLAGS_VISIBILITY@
+DEFS= \
+ -DSYSCONFDIR=\"$(sysconfdir)\" \
+ -DDATADIR=\"$(datadir)\" \
+ -DLIBEXECDIR=\"$(libexecdir)\" \
+ -DLIBDIR=\"$(libdir)\"
+
+SUBDIRS = .
+
+bin_PROGRAMS = instruo
+noinst_PROGRAMS = man-instruo
+noinst_DATA = instruo.html
+man_MANS = instruo.1
+
+instruo.1 : man-instruo
+ ./man-instruo > $@
+
+instruo.html : man-instruo
+ ./man-instruo --html > $@
+
+man_instruo_SOURCES = \
+ man_instruo.cc \
+ command_line.hh \
+ command_line.cc
+
+man_instruo_LDADD = \
+ $(top_builddir)/paludis/args/libpaludisargs.la \
+ $(top_builddir)/paludis/args/libpaludisman.a \
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(top_builddir)/paludis/libpaludismanpagethings.la \
+ $(top_builddir)/src/common_args/libcommonargs.a \
+ $(top_builddir)/src/output/liboutput.a \
+ $(DYNAMIC_LD_LIBS)
+
+instruo_SOURCES = \
+ command_line.hh command_line.cc \
+ instruo.cc
+
+instruo_LDADD = \
+ $(top_builddir)/paludis/tasks/libpaludistasks.la \
+ $(top_builddir)/paludis/libpaludis.la \
+ $(top_builddir)/paludis/args/libpaludisargs.la \
+ $(top_builddir)/paludis/util/libpaludisutil.la \
+ $(top_builddir)/paludis/environments/no_config/libpaludisnoconfigenvironment.la \
+ $(top_builddir)/src/output/liboutput.a \
+ $(top_builddir)/src/common_args/libcommonargs.a \
+ $(DYNAMIC_LD_LIBS)
+
+TESTS_ENVIRONMENT = env \
+ TEST_SCRIPT_DIR="$(srcdir)/" \
+ PALUDIS_NO_GLOBAL_HOOKS="yes" \
+ PALUDIS_NO_XTERM_TITLES="yes" \
+ PALUDIS_OPTIONS="" \
+ PALUDIS_EBUILD_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_srcdir)/paludis/repositories/e/ebuild/`" \
+ PALUDIS_EBUILD_DIR_FALLBACK="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories/e/ebuild/`" \
+ PALUDIS_EAPIS_DIR="$(top_srcdir)/paludis/repositories/e/eapis/" \
+ PALUDIS_DISTRIBUTIONS_DIR="$(top_srcdir)/paludis/distributions/" \
+ PALUDIS_DISTRIBUTION="gentoo" \
+ PALUDIS_REPOSITORY_SO_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories`" \
+ PALUDIS_ENVIRONMENT_SO_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/environments`" \
+ PALUDIS_NO_CHOWN="yupyup" \
+ PALUDIS_REDUCED_USERNAME="`id -un`" \
+ PALUDIS_OUTPUTWRAPPER_DIR="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/util/`" \
+ TEST_OUTPUT_WRAPPER="`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/util/outputwrapper`" \
+ SYSCONFDIR="$(sysconfdir)" \
+ bash $(top_srcdir)/test/run_test.sh bash
+
+TESTS = version_TEST \
+ help_TEST
+
+EXTRA_DIST = \
+ $(man_MANS) \
+ $(TESTS)
+
+CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda
+DISTCLEANFILES = $(man_MANS) $(noinst_DATA)
+MAINTAINERCLEANFILES = Makefile.in
+
+built-sources : $(BUILT_SOURCES)
+ for s in `echo $(SUBDIRS) | tr -d .` ; do $(MAKE) -C $$s built-sources || exit 1 ; done
+
+
diff --git a/src/clients/instruo/command_line.cc b/src/clients/instruo/command_line.cc
new file mode 100644
index 0000000..e5ea902
--- /dev/null
+++ b/src/clients/instruo/command_line.cc
@@ -0,0 +1,77 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "command_line.hh"
+#include <paludis/util/instantiation_policy-impl.hh>
+
+using namespace paludis;
+
+template class paludis::InstantiationPolicy<CommandLine, paludis::instantiation_method::SingletonTag>;
+
+CommandLine::CommandLine() :
+ ArgsHandler(),
+
+ action_args(this, "Actions",
+ "Selects which basic action to perform. Exactly one action should "
+ "be specified."),
+ a_generate_cache(&action_args, "generate-cache", 'g', "Generate cache"),
+ a_version(&action_args, "version", 'V', "Display program version"),
+ a_help(&action_args, "help", 'h', "Display program help"),
+
+ general_args(this, "General options",
+ "Options which are relevant for most or all actions."),
+ a_log_level(&general_args, "log-level", '\0'),
+ a_no_colour(&general_args, "no-colour", '\0', "Do not use colour"),
+ a_no_color(&a_no_colour, "no-color"),
+ a_repository_directory(&general_args, "repository-dir", 'D',
+ "Where to find the repository (default: current directory)"),
+ a_output_directory(&general_args, "output-dir", 'o',
+ "Where to place generated metadata (default: current directory)"),
+ a_master_repository_dir(&general_args, "master-repository-dir", '\0',
+ "Use the specified location for the master repository"),
+ a_report_file(&general_args, "report-file", 'r',
+ "Write report to the specified file, rather than stdout")
+{
+ add_usage_line("--generate-cache");
+}
+
+std::string
+CommandLine::app_name() const
+{
+ return "instruo [ at least one of --repository-dir /dir or --output-dir /dir ]";
+}
+
+std::string
+CommandLine::app_synopsis() const
+{
+ return "Metadata generation client for Paludis";
+}
+
+std::string
+CommandLine::app_description() const
+{
+ return
+ "instruo is a metadata generation client for Paludis. It generates metadata cache for every ID in a "
+ "given repository and produces a report of any failures.";
+}
+
+CommandLine::~CommandLine()
+{
+}
+
diff --git a/src/clients/instruo/command_line.hh b/src/clients/instruo/command_line.hh
new file mode 100644
index 0000000..873794c
--- /dev/null
+++ b/src/clients/instruo/command_line.hh
@@ -0,0 +1,62 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_SRC_CLIENTS_INSTRUO_COMMAND_LINE_HH
+#define PALUDIS_GUARD_SRC_CLIENTS_INSTRUO_COMMAND_LINE_HH 1
+
+#include <paludis/args/args.hh>
+#include <paludis/util/instantiation_policy.hh>
+#include <src/common_args/debug_build_arg.hh>
+#include <src/common_args/checks_arg.hh>
+#include <src/common_args/log_level_arg.hh>
+#include <src/common_args/deps_option_arg.hh>
+
+class CommandLine :
+ public paludis::args::ArgsHandler,
+ public paludis::InstantiationPolicy<CommandLine, paludis::instantiation_method::SingletonTag>
+{
+ friend class paludis::InstantiationPolicy<CommandLine, paludis::instantiation_method::SingletonTag>;
+
+ private:
+ CommandLine();
+ ~CommandLine();
+
+ public:
+ virtual std::string app_name() const;
+ virtual std::string app_synopsis() const;
+ virtual std::string app_description() const;
+
+ paludis::args::ArgsGroup action_args;
+
+ paludis::args::SwitchArg a_generate_cache;
+ paludis::args::SwitchArg a_version;
+ paludis::args::SwitchArg a_help;
+
+ paludis::args::ArgsGroup general_args;
+
+ paludis::args::LogLevelArg a_log_level;
+ paludis::args::SwitchArg a_no_colour;
+ paludis::args::AliasArg a_no_color;
+ paludis::args::StringArg a_repository_directory;
+ paludis::args::StringArg a_output_directory;
+ paludis::args::StringArg a_master_repository_dir;
+ paludis::args::StringArg a_report_file;
+};
+
+#endif
diff --git a/src/clients/instruo/help_TEST b/src/clients/instruo/help_TEST
new file mode 100755
index 0000000..8329f80
--- /dev/null
+++ b/src/clients/instruo/help_TEST
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+./instruo --help
+
+
diff --git a/src/clients/instruo/instruo.cc b/src/clients/instruo/instruo.cc
new file mode 100644
index 0000000..2c0fafc
--- /dev/null
+++ b/src/clients/instruo/instruo.cc
@@ -0,0 +1,351 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <output/colour.hh>
+#include <src/common_args/do_help.hh>
+#include "command_line.hh"
+#include <paludis/about.hh>
+#include <paludis/action.hh>
+#include <paludis/util/join.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/fs_entry.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/util/map.hh>
+#include <paludis/util/tr1_functional.hh>
+#include <paludis/util/visitor-impl.hh>
+#include <paludis/environments/no_config/no_config_environment.hh>
+#include <paludis/package_database.hh>
+#include <paludis/query.hh>
+#include <paludis/metadata_key.hh>
+#include <iostream>
+#include <fstream>
+#include <map>
+
+using namespace paludis;
+using std::cout;
+using std::cerr;
+using std::endl;
+
+namespace
+{
+ struct EAPIFinder :
+ ConstVisitor<MetadataKeyVisitorTypes>
+ {
+ bool ok;
+ std::string s;
+
+ EAPIFinder() :
+ ok(false)
+ {
+ }
+
+ void visit(const MetadataStringKey & k)
+ {
+ s = k.value();
+ ok = true;
+ }
+
+ void visit(const MetadataPackageIDKey &)
+ {
+ }
+
+ void visit(const MetadataTimeKey &)
+ {
+ }
+
+ void visit(const MetadataContentsKey &)
+ {
+ }
+
+ void visit(const MetadataRepositoryMaskInfoKey &)
+ {
+ }
+
+ void visit(const MetadataSpecTreeKey<RestrictSpecTree> &)
+ {
+ }
+
+ void visit(const MetadataSpecTreeKey<ProvideSpecTree> &)
+ {
+ }
+
+ void visit(const MetadataSpecTreeKey<URISpecTree> &)
+ {
+ }
+
+ void visit(const MetadataSpecTreeKey<LicenseSpecTree> &)
+ {
+ }
+
+ void visit(const MetadataSpecTreeKey<DependencySpecTree> &)
+ {
+ }
+
+ void visit(const MetadataSetKey<PackageIDSequence> &)
+ {
+ }
+
+ void visit(const MetadataSetKey<InheritedSet> &)
+ {
+ }
+
+ void visit(const MetadataSetKey<KeywordNameSet> &)
+ {
+ }
+
+ void visit(const MetadataSetKey<IUseFlagSet> &)
+ {
+ }
+
+ void visit(const MetadataSetKey<UseFlagNameSet> &)
+ {
+ }
+ };
+}
+
+int
+main(int argc, char *argv[])
+{
+ Context context("In program " + join(argv, argv + argc, " ") + ":");
+
+ try
+ {
+ CommandLine::get_instance()->run(argc, argv, "instruo", "INSTRUO_OPTIONS", "INSTRUO_CMDLINE");
+ set_use_colour(
+ (! CommandLine::get_instance()->a_no_color.specified()) &&
+ (! CommandLine::get_instance()->a_report_file.specified()));
+
+ if (CommandLine::get_instance()->a_help.specified())
+ throw args::DoHelp();
+
+ if (CommandLine::get_instance()->a_log_level.specified())
+ Log::get_instance()->set_log_level(CommandLine::get_instance()->a_log_level.option());
+ else
+ Log::get_instance()->set_log_level(ll_qa);
+
+ if (1 < (
+ CommandLine::get_instance()->a_generate_cache.specified() +
+ CommandLine::get_instance()->a_version.specified()
+ ))
+ throw args::DoHelp("you should specify exactly one action");
+
+ if (! CommandLine::get_instance()->a_repository_directory.specified())
+ CommandLine::get_instance()->a_repository_directory.set_argument(stringify(FSEntry::cwd()));
+
+ if (CommandLine::get_instance()->a_version.specified())
+ {
+ cout << "instruo " << 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 << 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;
+ }
+
+ if ((
+ CommandLine::get_instance()->a_repository_directory.specified() +
+ CommandLine::get_instance()->a_output_directory.specified()
+ ) < 1)
+ throw args::DoHelp("at least one of '--" + CommandLine::get_instance()->a_repository_directory.long_name() + "' or '--"
+ + CommandLine::get_instance()->a_output_directory.long_name() + "' must be specified");
+
+ if (! CommandLine::get_instance()->a_master_repository_dir.specified())
+ CommandLine::get_instance()->a_master_repository_dir.set_argument("/var/empty");
+
+ if (! CommandLine::get_instance()->a_output_directory.specified())
+ CommandLine::get_instance()->a_output_directory.set_argument(stringify(FSEntry::cwd()));
+
+ tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("append_repository_name_to_write_cache", "false");
+ NoConfigEnvironment env(no_config_environment::Params::create()
+ .repository_dir(CommandLine::get_instance()->a_repository_directory.argument())
+ .write_cache(CommandLine::get_instance()->a_output_directory.argument())
+ .accept_unstable(true)
+ .repository_type(no_config_environment::ncer_ebuild)
+ .disable_metadata_cache(true)
+ .extra_params(keys)
+ .master_repository_dir(FSEntry(CommandLine::get_instance()->a_master_repository_dir.argument())));
+
+ tr1::shared_ptr<const PackageIDSequence> ids(
+ env.package_database()->query(query::Repository(env.main_repository()->name()), qo_order_by_version));
+ PackageIDComparator comparator(env.package_database().get());
+ std::multimap<tr1::shared_ptr<const PackageID>, std::string, tr1::reference_wrapper<const PackageIDComparator> >
+ results(tr1::cref(comparator));
+ unsigned success(0), total(0);
+
+ CategoryNamePart old_cat("OLDCAT");
+ for (PackageIDSequence::Iterator i(ids->begin()), i_end(ids->end()) ;
+ i != i_end ; ++i)
+ {
+ Context i_context("When fetching ID '" + stringify(**i) + "':");
+
+ if ((*i)->name().category != old_cat)
+ {
+ cout << "Processing " << colour(cl_package_name, stringify((*i)->name().category)) << "..." << endl;
+ old_cat = (*i)->name().category;
+ }
+
+ ++total;
+
+ try
+ {
+ PackageID::MetadataIterator eapi_i((*i)->find_metadata("EAPI"));
+ if ((*i)->end_metadata() == eapi_i)
+ {
+ results.insert(std::make_pair(*i, "No EAPI metadata key"));
+ continue;
+ }
+
+ EAPIFinder f;
+ (*eapi_i)->accept(f);
+ if (! f.ok)
+ {
+ results.insert(std::make_pair(*i, "EAPI metadata key is not a string key"));
+ continue;
+ }
+
+ if (f.s == "UNKNOWN")
+ {
+ results.insert(std::make_pair(*i, "EAPI is '" + f.s + "'"));
+ continue;
+ }
+
+ ++success;
+ }
+ catch (const Exception & e)
+ {
+ results.insert(std::make_pair(*i, "Uncaught exception '" + e.message() + "' (" + e.what() + ")"));
+ }
+ }
+
+ std::cout << std::endl;
+
+ tr1::shared_ptr<std::ofstream> outf;
+ if (CommandLine::get_instance()->a_report_file.specified())
+ {
+ outf.reset(new std::ofstream(CommandLine::get_instance()->a_report_file.argument().c_str()));
+ if (! *outf)
+ {
+ std::cerr << "Cannot write to " << CommandLine::get_instance()->a_report_file.argument() << std::endl;
+ return EXIT_FAILURE;
+ }
+ }
+
+ std::ostream & out(outf ? *outf : cout);
+
+ char t[255];
+ time_t tt(time(0));
+ if (0 == strftime(t, 255, "%c", gmtime(&tt)))
+ throw InternalError(PALUDIS_HERE, "strftime failed");
+
+ out << colour(cl_heading, "Instruo results for ") << colour(cl_repository_name, env.main_repository()->name())
+ << colour(cl_heading, " on " + stringify(t) + ":") << endl << endl
+ << total << " IDs, " << success << " successes, " << (total - success) << " failures" << endl << endl;
+
+ int exit_status(0);
+ tr1::shared_ptr<const PackageID> old_id;
+ for (std::multimap<tr1::shared_ptr<const PackageID>, std::string, tr1::reference_wrapper<const PackageIDComparator> >::const_iterator
+ r(results.begin()), r_end(results.end()) ; r != r_end ; ++r)
+ {
+ exit_status |= 1;
+ if ((! old_id) || (*old_id != *r->first))
+ {
+ out << colour(cl_package_name, stringify(*r->first)) << ":" << endl;
+ old_id = r->first;
+ }
+ out << " " << r->second << endl;
+ }
+ out << endl;
+
+ return exit_status;
+ }
+ catch (const paludis::args::ArgsError & e)
+ {
+ cerr << "Usage error: " << e.message() << endl;
+ cerr << "Try " << argv[0] << " --help" << endl;
+ return EXIT_FAILURE;
+ }
+ catch (const args::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 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/src/clients/instruo/man_instruo.cc b/src/clients/instruo/man_instruo.cc
new file mode 100644
index 0000000..453b991
--- /dev/null
+++ b/src/clients/instruo/man_instruo.cc
@@ -0,0 +1,80 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "command_line.hh"
+#include <paludis/args/man.hh>
+
+#include <iostream>
+#include <cstdlib>
+
+using std::cout;
+using std::endl;
+
+namespace
+{
+ struct ManCommandLine :
+ paludis::args::ArgsHandler
+ {
+ paludis::args::ArgsGroup group;
+ paludis::args::SwitchArg a_html;
+
+ ManCommandLine() :
+ group(this, "", ""),
+ a_html(&group, "html", '\0', "")
+ {
+ }
+
+ virtual std::string app_name() const
+ {
+ return "";
+ }
+
+ virtual std::string app_description() const
+ {
+ return "";
+ }
+
+ virtual std::string app_synopsis() const
+ {
+ return "";
+ }
+ };
+}
+
+int
+main(int argc, char * argv[])
+{
+ ManCommandLine cmdline;
+ cmdline.run(argc, argv, "", "", "");
+
+ if (cmdline.a_html.specified())
+ {
+ paludis::args::HtmlWriter hw(cout);
+ paludis::args::generate_doc(hw, CommandLine::get_instance());
+ }
+ else
+ {
+ paludis::args::ManWriter mw(cout);
+ paludis::args::generate_doc(mw, CommandLine::get_instance());
+ }
+
+ return EXIT_SUCCESS;
+}
+
+
diff --git a/src/clients/instruo/version_TEST b/src/clients/instruo/version_TEST
new file mode 100755
index 0000000..a207175
--- /dev/null
+++ b/src/clients/instruo/version_TEST
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+./instruo --version
+