aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-01 13:56:58 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-02-01 13:56:58 +0000
commit47d354c479ceb41b307390ce0a15c806a7280e83 (patch)
tree36c3d320efa58bccc56d76e4de7244cbcb519cf9
parentd7d14e20c49247a6f8d12c30732ffeb6409a553a (diff)
downloadpaludis-47d354c479ceb41b307390ce0a15c806a7280e83.tar.gz
paludis-47d354c479ceb41b307390ce0a15c806a7280e83.tar.xz
More work on metadata
-rw-r--r--ebuild/depend.bash5
-rwxr-xr-xebuild/ebuild.bash1
-rw-r--r--ebuild/eclass_functions.bash1
-rw-r--r--paludis/dep_atom_pretty_printer.cc84
-rw-r--r--paludis/dep_atom_pretty_printer.hh70
-rw-r--r--paludis/files.m41
-rw-r--r--paludis/portage_repository.cc2
-rw-r--r--src/command_line.cc3
-rw-r--r--src/command_line.hh3
-rw-r--r--src/query.cc31
10 files changed, 197 insertions, 4 deletions
diff --git a/ebuild/depend.bash b/ebuild/depend.bash
index 062f4e4..c96800b 100644
--- a/ebuild/depend.bash
+++ b/ebuild/depend.bash
@@ -32,7 +32,10 @@ ebuild_f_depend()
for key in DEPEND RDEPEND PDEPEND IUSE SLOT SRC_URI RESTRICT LICENSE \
KEYWORDS INHERITED PROVIDE EAPI HOMEPAGE DESCRIPTION ; do
- echo "${key}="${!key}
+ local k=${!key}
+ k=${k/\\/\\\\}
+ k=${k/\"/\\\"}
+ echo "${key}=\""${k}"\""
done
}
diff --git a/ebuild/ebuild.bash b/ebuild/ebuild.bash
index c50fd0f..17676bf 100755
--- a/ebuild/ebuild.bash
+++ b/ebuild/ebuild.bash
@@ -67,6 +67,7 @@ ebuild_load_ebuild()
{
[[ -f "${1}" ]] || die "Ebuild '${1}' is not a file"
source ${1} || die "Error sourcing ebuild '${1}'"
+ [[ ${RDEPEND-unset} == "unset" ]] && RDEPEND="${DEPEND}"
}
case ${1:x} in
diff --git a/ebuild/eclass_functions.bash b/ebuild/eclass_functions.bash
index 40eee81..0ce3424 100644
--- a/ebuild/eclass_functions.bash
+++ b/ebuild/eclass_functions.bash
@@ -44,7 +44,6 @@ inherit()
unset IUSE DEPEND RDEPEND PDEPEND
- echo "DEBUG: source eclass ${e}" 1>&2
source "${location}" || die "Error sourcing eclass ${e}"
hasq "${ECLASS}" ${INHERITED} || export INHERITED="${INHERITED} ${ECLASS}"
diff --git a/paludis/dep_atom_pretty_printer.cc b/paludis/dep_atom_pretty_printer.cc
new file mode 100644
index 0000000..a2777f5
--- /dev/null
+++ b/paludis/dep_atom_pretty_printer.cc
@@ -0,0 +1,84 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.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 "dep_atom_pretty_printer.hh"
+#include "dep_atom.hh"
+#include "any_dep_atom.hh"
+#include "all_dep_atom.hh"
+#include "use_dep_atom.hh"
+#include "package_dep_atom.hh"
+#include "block_dep_atom.hh"
+#include "save.hh"
+#include <algorithm>
+
+using namespace paludis;
+
+std::ostream &
+paludis::operator<< (std::ostream & s, const DepAtomPrettyPrinter & p)
+{
+ s << p._s.str();
+ return s;
+}
+
+void
+DepAtomPrettyPrinter::visit(const AllDepAtom * const a)
+{
+ _s << std::string(_indent, ' ') << "(" << std::endl;
+ {
+ Save<unsigned> old_indent(&_indent, _indent + 4);
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+ _s << std::string(_indent, ' ') << ")" << std::endl;
+}
+
+void
+DepAtomPrettyPrinter::visit(const AnyDepAtom * const a)
+{
+ _s << std::string(_indent, ' ') << "|| (" << std::endl;
+ {
+ Save<unsigned> old_indent(&_indent, _indent + 4);
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+ _s << std::string(_indent, ' ') << ")" << std::endl;
+}
+
+void
+DepAtomPrettyPrinter::visit(const UseDepAtom * const a)
+{
+ _s << std::string(_indent, ' ') << (a->inverse() ? "!" : "") <<
+ a->flag() << "? (" << std::endl;
+ {
+ Save<unsigned> old_indent(&_indent, _indent + 4);
+ std::for_each(a->begin(), a->end(), accept_visitor(this));
+ }
+ _s << std::string(_indent, ' ') << ")" << std::endl;
+}
+
+void
+DepAtomPrettyPrinter::visit(const PackageDepAtom * const p)
+{
+ _s << std::string(_indent, ' ') << *p << std::endl;
+}
+
+void
+DepAtomPrettyPrinter::visit(const BlockDepAtom * const b)
+{
+ _s << std::string(_indent, ' ') << "!" << *b->blocked_atom() << std::endl;
+}
+
diff --git a/paludis/dep_atom_pretty_printer.hh b/paludis/dep_atom_pretty_printer.hh
new file mode 100644
index 0000000..bd12749
--- /dev/null
+++ b/paludis/dep_atom_pretty_printer.hh
@@ -0,0 +1,70 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.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_PALUDIS_DEP_ATOM_PRETTY_PRINTER_HH
+#define PALUDIS_GUARD_PALUDIS_DEP_ATOM_PRETTY_PRINTER_HH 1
+
+#include <paludis/dep_atom_visitor.hh>
+#include <ostream>
+#include <sstream>
+
+namespace paludis
+{
+ /**
+ * Pretty print dependency atoms
+ */
+ class DepAtomPrettyPrinter :
+ public DepAtomVisitorTypes::ConstVisitor
+ {
+ friend std::ostream & operator<< (std::ostream &, const DepAtomPrettyPrinter &);
+
+ private:
+ std::stringstream _s;
+ unsigned _indent;
+
+ public:
+ /**
+ * Constructor.
+ */
+ DepAtomPrettyPrinter(unsigned initial_indent) :
+ _indent(initial_indent)
+ {
+ }
+
+ /// \name Visit functions
+ ///{
+ void visit(const AllDepAtom * const);
+
+ void visit(const AnyDepAtom * const);
+
+ void visit(const UseDepAtom * const);
+
+ void visit(const PackageDepAtom * const);
+
+ void visit(const BlockDepAtom * const);
+ ///}
+ };
+
+ /**
+ * Output a DepAtomPrettyPrinter to an ostream.
+ */
+ std::ostream & operator<< (std::ostream & s, const DepAtomPrettyPrinter & p);
+}
+
+#endif
diff --git a/paludis/files.m4 b/paludis/files.m4
index fdf1303..e6c265e 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -29,6 +29,7 @@ add(`dep_atom', `hh', `cc')
add(`dep_atom_dumper', `hh', `cc', `test')
add(`dep_atom_flattener', `hh', `cc')
add(`dep_atom_visitor', `hh', `cc')
+add(`dep_atom_pretty_printer', `hh', `cc')
add(`dep_lexer', `hh', `cc', `test')
add(`dep_list', `hh', `cc', `test')
add(`dep_parser', `hh', `cc', `test')
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index bddddc7..781771c 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -659,7 +659,7 @@ PortageRepository::make_portage_repository(
throw PortageRepositoryConfigurationError("Key 'profile' not specified or empty");
std::string cache;
- if (m.end() == m.find("cache") || ((profile = m.find("cache")->second)).empty())
+ if (m.end() == m.find("cache") || ((cache = m.find("cache")->second)).empty())
cache = location + "/metadata/cache";
return CountedPtr<Repository>(new PortageRepository(db, location, profile, cache));
diff --git a/src/command_line.cc b/src/command_line.cc
index 495da6d..357b506 100644
--- a/src/command_line.cc
+++ b/src/command_line.cc
@@ -38,7 +38,8 @@ CommandLine::CommandLine() :
a_show_slot(&query_args, "show-slot", 'S', "Show SLOTs"),
a_show_license(&query_args, "show-license", 'L', "Show licenses"),
a_show_licence(&a_show_license, "show-licence"),
- a_show_metadata(&query_args, "show-metadata", 'M', "Show full metadata"),
+ 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 options"),
a_pretend(&install_args, "pretend", 'p', "Pretend only"),
diff --git a/src/command_line.hh b/src/command_line.hh
index 4f20888..af5181f 100644
--- a/src/command_line.hh
+++ b/src/command_line.hh
@@ -99,6 +99,9 @@ class CommandLine :
/// --show-licence
paludis::args::AliasArg a_show_licence;
+ /// --show-deps
+ paludis::args::SwitchArg a_show_deps;
+
/// --show-metadata
paludis::args::SwitchArg a_show_metadata;
diff --git a/src/query.cc b/src/query.cc
index ea788d3..24c2869 100644
--- a/src/query.cc
+++ b/src/query.cc
@@ -149,16 +149,47 @@ void do_one_query(
if (! metadata->get(p::vmk_homepage).empty())
std::cout << " " << std::setw(22) << std::left << "Homepage:" << std::setw(0) <<
" " << metadata->get(p::vmk_homepage) << std::endl;
+
if (! metadata->get(p::vmk_description).empty())
std::cout << " " << std::setw(22) << std::left << "Description:" << std::setw(0) <<
" " << metadata->get(p::vmk_description) << std::endl;
+
if (CommandLine::get_instance()->a_show_license.specified())
if (! metadata->get(p::vmk_license).empty())
std::cout << " " << std::setw(22) << std::left << "License:" << std::setw(0) <<
" " << metadata->get(p::vmk_license) << std::endl;
+
+ if (CommandLine::get_instance()->a_show_deps.specified())
+ {
+ if (! metadata->get(p::vmk_depend).empty())
+ {
+ p::DepAtomPrettyPrinter p_depend(12);
+ p::DepParser::parse(metadata->get(p::vmk_depend))->accept(&p_depend);
+ std::cout << " " << std::setw(22) << std::left << "Build dependencies:" << std::setw(0)
+ << std::endl << p_depend;
+ }
+
+ if (! metadata->get(p::vmk_rdepend).empty())
+ {
+ p::DepAtomPrettyPrinter p_rdepend(12);
+ p::DepParser::parse(metadata->get(p::vmk_rdepend))->accept(&p_rdepend);
+ std::cout << " " << std::setw(22) << std::left << "Runtime dependencies:" << std::setw(0)
+ << std::endl << p_rdepend;
+ }
+
+ if (! metadata->get(p::vmk_pdepend).empty())
+ {
+ p::DepAtomPrettyPrinter p_pdepend(12);
+ p::DepParser::parse(metadata->get(p::vmk_pdepend))->accept(&p_pdepend);
+ std::cout << " " << std::setw(22) << std::left << "Post dependencies:" << std::setw(0)
+ << std::endl << p_pdepend;
+ }
+ }
+
if (! metadata->get(p::vmk_virtual).empty())
std::cout << " " << std::setw(22) << std::left << "Virtual for:" << std::setw(0) <<
" " << metadata->get(p::vmk_virtual) << std::endl;
+
if (! metadata->get(p::vmk_provide).empty())
std::cout << " " << std::setw(22) << std::left << "Provides:" << std::setw(0) <<
" " << metadata->get(p::vmk_provide) << std::endl;