aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-01-01 23:27:27 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-01-01 23:27:27 +0000
commit10b3fba18f5ee11e04dcefedb53dc15cbf7d6964 (patch)
treeacfc2d5ac305ea0748d571589a9ec6274e844118
parente88e16d3a9172ba5e613f59104b73938da318023 (diff)
downloadpaludis-10b3fba18f5ee11e04dcefedb53dc15cbf7d6964.tar.gz
paludis-10b3fba18f5ee11e04dcefedb53dc15cbf7d6964.tar.xz
Hack in basic DEPENDENCIES support for now
-rw-r--r--paludis/repositories/e/Makefile.am2
-rw-r--r--paludis/repositories/e/dependencies_rewriter.cc223
-rw-r--r--paludis/repositories/e/dependencies_rewriter.hh65
-rw-r--r--paludis/repositories/e/eapi.cc4
-rw-r--r--paludis/repositories/e/eapi.sr2
-rw-r--r--paludis/repositories/e/eapis/exheres-0.conf1
-rw-r--r--paludis/repositories/e/ebuild.cc27
-rw-r--r--paludis/repositories/e/vdb_id.cc64
8 files changed, 360 insertions, 28 deletions
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index 38cd590..ec36387 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -42,6 +42,7 @@ paludis_repositories_e_include_HEADERS = \
dep_parser-se.hh \
dep_parser-fwd.hh \
dep_spec_pretty_printer.hh \
+ dependencies_rewriter.hh \
e_key.hh \
e_mask.hh \
e_repository.hh \
@@ -99,6 +100,7 @@ libpaludiserepository_la_SOURCES = \
check_fetched_files_visitor.cc \
dep_parser.cc \
dep_spec_pretty_printer.cc \
+ dependencies_rewriter.cc \
e_key.cc \
e_mask.cc \
e_repository.cc \
diff --git a/paludis/repositories/e/dependencies_rewriter.cc b/paludis/repositories/e/dependencies_rewriter.cc
new file mode 100644
index 0000000..73ed45f
--- /dev/null
+++ b/paludis/repositories/e/dependencies_rewriter.cc
@@ -0,0 +1,223 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2008 Ciaran McCreesh
+ *
+ * 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 <paludis/repositories/e/dependencies_rewriter.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/save.hh>
+#include <paludis/util/indirect_iterator-impl.hh>
+#include <list>
+
+using namespace paludis;
+using namespace paludis::erepository;
+
+typedef std::list<tr1::shared_ptr<ActiveDependencyLabels> > LabelsStack;
+
+namespace paludis
+{
+ template <>
+ struct Implementation<DependenciesRewriter>
+ {
+ std::string depend;
+ std::string rdepend;
+ std::string pdepend;
+
+ tr1::shared_ptr<DependencyLabelSequence> default_labels;
+ LabelsStack labels;
+
+ Implementation() :
+ default_labels(new DependencyLabelSequence)
+ {
+ default_labels->push_back(make_shared_ptr(new DependencyBuildLabel("build")));
+ default_labels->push_back(make_shared_ptr(new DependencyRunLabel("run")));
+ labels.push_front(make_shared_ptr(new ActiveDependencyLabels(*default_labels)));
+ }
+ };
+}
+
+DependenciesRewriter::DependenciesRewriter() :
+ PrivateImplementationPattern<DependenciesRewriter>(new Implementation<DependenciesRewriter>)
+{
+}
+
+DependenciesRewriter::~DependenciesRewriter()
+{
+}
+
+const std::string
+DependenciesRewriter::depend() const
+{
+ return _imp->depend;
+}
+
+const std::string
+DependenciesRewriter::rdepend() const
+{
+ return _imp->rdepend;
+}
+
+const std::string
+DependenciesRewriter::pdepend() const
+{
+ return _imp->pdepend;
+}
+
+void
+DependenciesRewriter::visit_leaf(const PackageDepSpec & spec)
+{
+ _add_where_necessary(stringify(spec));
+}
+
+void
+DependenciesRewriter::visit_leaf(const NamedSetDepSpec & spec)
+{
+ _add_where_necessary(stringify(spec));
+}
+
+void
+DependenciesRewriter::visit_leaf(const BlockDepSpec & spec)
+{
+ _add_where_necessary(stringify(spec));
+}
+
+void
+DependenciesRewriter::visit_leaf(const DependencyLabelsDepSpec & spec)
+{
+ _imp->depend.append(" " + stringify(spec));
+ _imp->rdepend.append(" " + stringify(spec));
+ _imp->pdepend.append(" " + stringify(spec));
+
+ _imp->labels.begin()->reset(new ActiveDependencyLabels(**_imp->labels.begin(), spec));
+}
+
+void
+DependenciesRewriter::visit_sequence(const AllDepSpec &,
+ DependencySpecTree::ConstSequenceIterator cur,
+ DependencySpecTree::ConstSequenceIterator end)
+{
+ _imp->labels.push_front(make_shared_ptr(new ActiveDependencyLabels(**_imp->labels.begin())));
+ RunOnDestruction restore_labels(tr1::bind(tr1::mem_fn(&LabelsStack::pop_front), &_imp->labels));
+
+ std::string d(_imp->depend), r(_imp->rdepend), p(_imp->pdepend);
+ _imp->depend.clear();
+ _imp->rdepend.clear();
+ _imp->pdepend.clear();
+
+ std::for_each(cur, end, accept_visitor(*this));
+
+ _imp->depend = d + " ( " + _imp->depend + " )";
+ _imp->rdepend = r + " ( " + _imp->rdepend + " )";
+ _imp->pdepend = p + " ( " + _imp->pdepend + " )";
+}
+
+void
+DependenciesRewriter::visit_sequence(const AnyDepSpec &,
+ DependencySpecTree::ConstSequenceIterator cur,
+ DependencySpecTree::ConstSequenceIterator end)
+{
+ _imp->labels.push_front(make_shared_ptr(new ActiveDependencyLabels(**_imp->labels.begin())));
+ RunOnDestruction restore_labels(tr1::bind(tr1::mem_fn(&LabelsStack::pop_front), &_imp->labels));
+
+ std::string d(_imp->depend), r(_imp->rdepend), p(_imp->pdepend);
+ _imp->depend.clear();
+ _imp->rdepend.clear();
+ _imp->pdepend.clear();
+
+ std::for_each(cur, end, accept_visitor(*this));
+
+ _imp->depend = d + " || ( " + _imp->depend + " )";
+ _imp->rdepend = r + " || ( " + _imp->rdepend + " )";
+ _imp->pdepend = p + " || ( " + _imp->pdepend + " )";
+}
+
+void
+DependenciesRewriter::visit_sequence(const UseDepSpec & spec,
+ DependencySpecTree::ConstSequenceIterator cur,
+ DependencySpecTree::ConstSequenceIterator end)
+{
+ _imp->labels.push_front(make_shared_ptr(new ActiveDependencyLabels(**_imp->labels.begin())));
+ RunOnDestruction restore_labels(tr1::bind(tr1::mem_fn(&LabelsStack::pop_front), &_imp->labels));
+
+ std::string d(_imp->depend), r(_imp->rdepend), p(_imp->pdepend);
+ _imp->depend.clear();
+ _imp->rdepend.clear();
+ _imp->pdepend.clear();
+
+ std::for_each(cur, end, accept_visitor(*this));
+
+ _imp->depend = d + stringify(spec) + " ( " + _imp->depend + " )";
+ _imp->rdepend = r + stringify(spec) + " ( " + _imp->rdepend + " )";
+ _imp->pdepend = p + stringify(spec) + " ( " + _imp->pdepend + " )";
+}
+
+namespace
+{
+ struct AddWhereNecessary :
+ ConstVisitor<DependencyTypeLabelVisitorTypes>
+ {
+ std::string & d, & r, & p;
+ const std::string & s;
+
+ AddWhereNecessary(std::string & dd, std::string & rr, std::string & pp, const std::string & ss) :
+ d(dd),
+ r(rr),
+ p(pp),
+ s(ss)
+ {
+ }
+
+ void visit(const DependencyRunLabel &)
+ {
+ r.append(" " + s);
+ }
+
+ void visit(const DependencyPostLabel &)
+ {
+ p.append(" " + s);
+ }
+
+ void visit(const DependencyBuildLabel &)
+ {
+ d.append(" " + s);
+ }
+
+ void visit(const DependencyCompileLabel &)
+ {
+ r.append(" " + s);
+ }
+
+ void visit(const DependencyInstallLabel &)
+ {
+ d.append(" " + s);
+ }
+ };
+}
+
+void
+DependenciesRewriter::_add_where_necessary(const std::string & s)
+{
+ AddWhereNecessary v(_imp->depend, _imp->rdepend, _imp->pdepend, s);
+ std::for_each(
+ indirect_iterator((*_imp->labels.begin())->type_labels()->begin()),
+ indirect_iterator((*_imp->labels.begin())->type_labels()->end()),
+ accept_visitor(v));
+}
+
diff --git a/paludis/repositories/e/dependencies_rewriter.hh b/paludis/repositories/e/dependencies_rewriter.hh
new file mode 100644
index 0000000..333d941
--- /dev/null
+++ b/paludis/repositories/e/dependencies_rewriter.hh
@@ -0,0 +1,65 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2008 Ciaran McCreesh
+ *
+ * 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_REPOSITORIES_E_DEPENDENCIES_REWRITER_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_DEPENDENCIES_REWRITER_HH 1
+
+#include <paludis/dep_spec.hh>
+#include <paludis/dep_tree.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ class DependenciesRewriter :
+ public ConstVisitor<DependencySpecTree>,
+ private PrivateImplementationPattern<DependenciesRewriter>
+ {
+ public:
+ DependenciesRewriter();
+ ~DependenciesRewriter();
+
+ void _add_where_necessary(const std::string &);
+
+ void visit_leaf(const PackageDepSpec &);
+ void visit_leaf(const NamedSetDepSpec &);
+ void visit_leaf(const BlockDepSpec &);
+ void visit_leaf(const DependencyLabelsDepSpec &);
+
+ void visit_sequence(const AnyDepSpec &,
+ DependencySpecTree::ConstSequenceIterator,
+ DependencySpecTree::ConstSequenceIterator);
+
+ void visit_sequence(const AllDepSpec &,
+ DependencySpecTree::ConstSequenceIterator,
+ DependencySpecTree::ConstSequenceIterator);
+
+ void visit_sequence(const UseDepSpec &,
+ DependencySpecTree::ConstSequenceIterator,
+ DependencySpecTree::ConstSequenceIterator);
+
+ const std::string depend() const;
+ const std::string rdepend() const;
+ const std::string pdepend() const;
+ };
+ }
+}
+
+#endif
diff --git a/paludis/repositories/e/eapi.cc b/paludis/repositories/e/eapi.cc
index c0ed107..85eb2fc 100644
--- a/paludis/repositories/e/eapi.cc
+++ b/paludis/repositories/e/eapi.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 2008 Ciaran McCreesh
*
* 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
@@ -155,6 +155,7 @@ namespace paludis
.metadata_pdepend(k.get("metadata_pdepend"))
.metadata_provide(k.get("metadata_provide"))
.metadata_eapi(k.get("metadata_eapi"))
+ .metadata_dependencies(k.get("metadata_dependencies"))
.description_build_depend(k.get("description_build_depend"))
.description_run_depend(k.get("description_run_depend"))
.description_slot(k.get("description_slot"))
@@ -170,6 +171,7 @@ namespace paludis
.description_pdepend(k.get("description_pdepend"))
.description_provide(k.get("description_provide"))
.description_eapi(k.get("description_eapi"))
+ .description_dependencies(k.get("description_dependencies"))
)))
.ebuild_environment_variables(make_shared_ptr(new EAPIEbuildEnvironmentVariables(
diff --git a/paludis/repositories/e/eapi.sr b/paludis/repositories/e/eapi.sr
index 44f3a29..5f676c7 100644
--- a/paludis/repositories/e/eapi.sr
+++ b/paludis/repositories/e/eapi.sr
@@ -46,6 +46,7 @@ make_class_EAPIEbuildMetadataVariables()
key metadata_pdepend std::string
key metadata_provide std::string
key metadata_eapi std::string
+ key metadata_dependencies std::string
key description_build_depend std::string
key description_run_depend std::string
@@ -62,6 +63,7 @@ make_class_EAPIEbuildMetadataVariables()
key description_pdepend std::string
key description_provide std::string
key description_eapi std::string
+ key description_dependencies std::string
doxygen_comment << "END"
/**
diff --git a/paludis/repositories/e/eapis/exheres-0.conf b/paludis/repositories/e/eapis/exheres-0.conf
index 5db485a..0cc6fdb 100644
--- a/paludis/repositories/e/eapis/exheres-0.conf
+++ b/paludis/repositories/e/eapis/exheres-0.conf
@@ -136,6 +136,7 @@ description_run_depend =
description_slot = Slot
description_src_uri = Source URI
description_use = Selected option flags
+description_dependencies = Dependencies
env_use = OPTIONS
env_use_expand = SUBOPTIONS
diff --git a/paludis/repositories/e/ebuild.cc b/paludis/repositories/e/ebuild.cc
index 74bc6ca..5102272 100644
--- a/paludis/repositories/e/ebuild.cc
+++ b/paludis/repositories/e/ebuild.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
*
* 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
@@ -24,6 +24,7 @@
#include <paludis/repositories/e/dep_parser.hh>
#include <paludis/repositories/e/package_dep_spec.hh>
#include <paludis/repositories/e/pipe_command_handler.hh>
+#include <paludis/repositories/e/dependencies_rewriter.hh>
#include <paludis/util/system.hh>
#include <paludis/util/strip.hh>
@@ -361,14 +362,26 @@ EbuildMetadataCommand::load(const tr1::shared_ptr<const EbuildID> & id)
if (! m.metadata_description.empty())
id->load_short_description(m.metadata_description, m.description_description, get(keys, m.metadata_description));
- if (! m.metadata_build_depend.empty())
- id->load_build_depend(m.metadata_build_depend, m.description_build_depend, get(keys, m.metadata_build_depend));
- if (! m.metadata_run_depend.empty())
- id->load_run_depend(m.metadata_run_depend, m.description_run_depend, get(keys, m.metadata_run_depend));
+ if (! m.metadata_dependencies.empty())
+ {
+ DependenciesRewriter rewriter;
+ parse_depend(get(keys, m.metadata_dependencies), *id->eapi(), id)->accept(rewriter);
+ id->load_build_depend(m.metadata_dependencies + ".DEPEND", m.description_dependencies + " (build)", rewriter.depend());
+ id->load_build_depend(m.metadata_dependencies + ".RDEPEND", m.description_dependencies + " (run)", rewriter.rdepend());
+ id->load_build_depend(m.metadata_dependencies + ".PDEPEND", m.description_dependencies + " (post)", rewriter.pdepend());
+ }
+ else
+ {
+ if (! m.metadata_build_depend.empty())
+ id->load_build_depend(m.metadata_build_depend, m.description_build_depend, get(keys, m.metadata_build_depend));
+
+ if (! m.metadata_run_depend.empty())
+ id->load_run_depend(m.metadata_run_depend, m.description_run_depend, get(keys, m.metadata_run_depend));
- if (! m.metadata_pdepend.empty())
- id->load_post_depend(m.metadata_pdepend, m.description_pdepend, get(keys, m.metadata_pdepend));
+ if (! m.metadata_pdepend.empty())
+ id->load_post_depend(m.metadata_pdepend, m.description_pdepend, get(keys, m.metadata_pdepend));
+ }
if (! m.metadata_slot.empty())
{
diff --git a/paludis/repositories/e/vdb_id.cc b/paludis/repositories/e/vdb_id.cc
index d4371f0..312e5fd 100644
--- a/paludis/repositories/e/vdb_id.cc
+++ b/paludis/repositories/e/vdb_id.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007 Ciaran McCreesh
+ * Copyright (c) 2007, 2008 Ciaran McCreesh
*
* 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
@@ -22,6 +22,7 @@
#include <paludis/repositories/e/vdb_repository.hh>
#include <paludis/repositories/e/eapi.hh>
#include <paludis/repositories/e/dep_parser.hh>
+#include <paludis/repositories/e/dependencies_rewriter.hh>
#include <paludis/name.hh>
#include <paludis/version_spec.hh>
@@ -214,32 +215,55 @@ VDBID::need_keys_added() const
add_metadata_key(_imp->provide);
}
- if (! vars->metadata_build_depend.empty())
- if ((_imp->dir / vars->metadata_build_depend).exists())
+ if (! vars->metadata_dependencies.empty())
+ {
+ if ((_imp->dir / vars->metadata_dependencies).exists())
{
- _imp->build_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), vars->metadata_build_depend,
- vars->description_build_depend, file_contents(_imp->dir / vars->metadata_build_depend),
- _imp->build_dependencies_labels, mkt_dependencies));
+ DependenciesRewriter rewriter;
+ parse_depend(file_contents(_imp->dir / vars->metadata_dependencies), *eapi(), shared_from_this())->accept(rewriter);
+
+ _imp->build_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), vars->metadata_dependencies + ".DEPEND",
+ vars->description_dependencies + " (build)", rewriter.depend(), _imp->build_dependencies_labels, mkt_dependencies));
add_metadata_key(_imp->build_dependencies);
- }
- if (! vars->metadata_run_depend.empty())
- if ((_imp->dir / vars->metadata_run_depend).exists())
- {
- _imp->run_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), vars->metadata_run_depend,
- vars->description_run_depend, file_contents(_imp->dir / vars->metadata_run_depend),
- _imp->run_dependencies_labels, mkt_dependencies));
+ _imp->build_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), vars->metadata_dependencies + ".RDEPEND",
+ vars->description_dependencies + " (run)", rewriter.rdepend(), _imp->build_dependencies_labels, mkt_dependencies));
add_metadata_key(_imp->run_dependencies);
- }
- if (! vars->metadata_pdepend.empty())
- if ((_imp->dir / vars->metadata_pdepend).exists())
- {
- _imp->post_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), vars->metadata_pdepend,
- vars->description_pdepend, file_contents(_imp->dir / vars->metadata_pdepend),
- _imp->post_dependencies_labels, mkt_dependencies));
+ _imp->build_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), vars->metadata_dependencies + ".PDEPEND",
+ vars->description_dependencies + " (post)", rewriter.pdepend(), _imp->build_dependencies_labels, mkt_dependencies));
add_metadata_key(_imp->post_dependencies);
}
+ }
+ else
+ {
+ if (! vars->metadata_build_depend.empty())
+ if ((_imp->dir / vars->metadata_build_depend).exists())
+ {
+ _imp->build_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), vars->metadata_build_depend,
+ vars->description_build_depend, file_contents(_imp->dir / vars->metadata_build_depend),
+ _imp->build_dependencies_labels, mkt_dependencies));
+ add_metadata_key(_imp->build_dependencies);
+ }
+
+ if (! vars->metadata_run_depend.empty())
+ if ((_imp->dir / vars->metadata_run_depend).exists())
+ {
+ _imp->run_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), vars->metadata_run_depend,
+ vars->description_run_depend, file_contents(_imp->dir / vars->metadata_run_depend),
+ _imp->run_dependencies_labels, mkt_dependencies));
+ add_metadata_key(_imp->run_dependencies);
+ }
+
+ if (! vars->metadata_pdepend.empty())
+ if ((_imp->dir / vars->metadata_pdepend).exists())
+ {
+ _imp->post_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), vars->metadata_pdepend,
+ vars->description_pdepend, file_contents(_imp->dir / vars->metadata_pdepend),
+ _imp->post_dependencies_labels, mkt_dependencies));
+ add_metadata_key(_imp->post_dependencies);
+ }
+ }
if (! vars->metadata_restrict.empty())
if ((_imp->dir / vars->metadata_restrict).exists())