diff options
35 files changed, 1 insertions, 3975 deletions
diff --git a/.gitignore b/.gitignore index 58cb2eded..d09dba3c6 100644 --- a/.gitignore +++ b/.gitignore @@ -356,11 +356,6 @@ paludis-*.*.*.tar.bz2 /paludis/repositories/fake/dep_parser_TEST /paludis/repositories/fake/fake_installed_repository_TEST /paludis/repositories/fake/fake_repository_TEST -/paludis/repositories/gems/gem_specification_TEST -/paludis/repositories/gems/gem_specifications_TEST -/paludis/repositories/gems/gems_repository_TEST -/paludis/repositories/gems/installed_gems_repository_TEST -/paludis/repositories/gems/yaml_TEST /paludis/repositories/unavailable/unavailable_repository_TEST /paludis/repositories/unpackaged/installed_repository_TEST /paludis/repositories/unpackaged/unpackaged_repository_TEST diff --git a/configure.ac b/configure.ac index 7958807e6..30cd6da74 100644 --- a/configure.ac +++ b/configure.ac @@ -89,8 +89,6 @@ dnl }}} need_xml_check= need_pcrecpp_check= -need_syck_check= -need_gem_check= need_libarchive_check= need_resolver= need_sqlite3_check= @@ -1320,7 +1318,7 @@ AC_SUBST([VIM_INSTALL_DIR]) dnl }}} dnl {{{ repositories -m4_define(ALL_REPOSITORIES_m4, [accounts,cran,e,fake,gems,repository,unavailable,unpackaged,unwritten,virtuals]) +m4_define(ALL_REPOSITORIES_m4, [accounts,cran,e,fake,repository,unavailable,unpackaged,unwritten,virtuals]) ALL_REPOSITORIES=`echo ALL_REPOSITORIES_m4 | tr , ' '` DEFAULT_REPOSITORIES="e fake repository unavailable unpackaged unwritten virtuals" AC_MSG_CHECKING([which repositories to build...]) @@ -1334,7 +1332,6 @@ AC_ARG_WITH([repositories], cran The Comprehensive R Archive Network (unusable) e Ebuild, Ebin, Exheres, VDB etc fake A fake repository for test cases and adjutrix - gems Ruby gems (unusable) repository Automatic repository config generation (via 'unavailable') unavailable Unavailable unpackaged Unpackaged (for importare) @@ -1565,28 +1562,6 @@ int main(int, char **) fi dnl }}} -dnl {{{ syck check -if test "x$need_syck_check" = "xyes" ; then - AC_MSG_CHECKING([for syck]) - AC_PREPROC_IFELSE([ -#include <syck.h> -], - [AC_MSG_RESULT([yes])], - [AC_MSG_ERROR([syck is required for gems repositories])]) -fi -dnl }}} - -dnl {{{ gem check -if test "x$need_gem_check" = "xyes" ; then - AC_MSG_CHECKING([for gem]) - if gem -v 1>/dev/null 2>/dev/null ; then - AC_MSG_RESULT([yes]) - else - AC_MSG_ERROR([gem (http://rubygems.org/) is required for gems repositories]) - fi -fi -dnl }}} - dnl {{{ sqlite3 check NEED_SQLITE3=$need_sqlite3_check if test "x$need_sqlite3_check" = "xyes" ; then @@ -1725,7 +1700,6 @@ AC_OUTPUT( paludis/repositories/e/ebuild/utils/4/Makefile paludis/repositories/e/ebuild/utils/exheres-0/Makefile paludis/repositories/fake/Makefile - paludis/repositories/gems/Makefile paludis/repositories/repository/Makefile paludis/repositories/unavailable/Makefile paludis/repositories/unpackaged/Makefile diff --git a/paludis/Makefile.am.m4 b/paludis/Makefile.am.m4 index 1aed2a0d5..524cc9550 100644 --- a/paludis/Makefile.am.m4 +++ b/paludis/Makefile.am.m4 @@ -100,7 +100,6 @@ condrepo(cran) condrepo(dummy) condrepo(e) condrepo(fake) -condrepo(gems) condrepo(repository) condrepo(unavailable) condrepo(unpackaged) diff --git a/paludis/repositories/gems/Makefile.am b/paludis/repositories/gems/Makefile.am deleted file mode 100644 index c432311ba..000000000 --- a/paludis/repositories/gems/Makefile.am +++ /dev/null @@ -1,106 +0,0 @@ -include $(top_srcdir)/misc/common-makefile.am - -SUBDIRS = . - -AM_CXXFLAGS = -I$(top_srcdir) -I$(top_builddir) @PALUDIS_CXXFLAGS@ @PALUDIS_CXXFLAGS_VISIBILITY@ -DEFS = \ - -DSYSCONFDIR=\"$(sysconfdir)\" \ - -DLIBEXECDIR=\"$(libexecdir)\" \ - -DDATADIR=\"$(datadir)\" \ - -DLIBDIR=\"$(libdir)\" - -paludis_gems_libexecdir = $(libexecdir)/paludis/gems - -noinst_LTLIBRARIES = libpaludisgemsrepository.la - -noinst_HEADERS = \ - gems_repository.hh \ - installed_gems_repository.hh \ - exceptions.hh \ - yaml.hh yaml-fwd.hh \ - gem_specification.hh gem_specification-fwd.hh \ - gem_specifications.hh \ - params-fwd.hh params.hh \ - extra_distribution_data.hh - -libpaludisgemsrepository_la_SOURCES = \ - gems_repository.cc \ - installed_gems_repository.cc \ - params.cc \ - exceptions.cc \ - yaml.cc \ - gem_specification.cc \ - gem_specifications.cc \ - extra_distribution_data.cc \ - registration.cc \ - $(noinst_HEADERS) - -libpaludisgemsrepository_la_LIBADD = \ - -lsyck - -gems_repository_TEST_SOURCES = gems_repository_TEST.cc -installed_gems_repository_TEST_SOURCES = gems_repository_TEST.cc -yaml_TEST_SOURCES = yaml_TEST.cc -gem_specification_TEST_SOURCES = gem_specification_TEST.cc -gem_specifications_TEST_SOURCES = gem_specifications_TEST.cc - -gems_repository_TEST_LDADD = \ - $(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \ - $(top_builddir)/paludis/util/test_extras.o \ - $(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \ - $(top_builddir)/test/libtest.a \ - -lsyck - -installed_gems_repository_TEST_LDADD = \ - $(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \ - $(top_builddir)/paludis/util/test_extras.o \ - $(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \ - $(top_builddir)/test/libtest.a \ - -lsyck - -yaml_TEST_LDADD = \ - $(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \ - $(top_builddir)/paludis/util/test_extras.o \ - $(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \ - $(top_builddir)/test/libtest.a \ - -lsyck - -gem_specification_TEST_LDADD = \ - $(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \ - $(top_builddir)/paludis/util/test_extras.o \ - $(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \ - $(top_builddir)/test/libtest.a \ - -lsyck - -gem_specifications_TEST_LDADD = \ - $(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \ - $(top_builddir)/paludis/util/test_extras.o \ - $(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \ - $(top_builddir)/test/libtest.a \ - -lsyck - -gems_repository_TEST_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_CXXFLAGS_NO_DEBUGGING@ -installed_gems_repository_TEST_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_CXXFLAGS_NO_DEBUGGING@ -yaml_TEST_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_CXXFLAGS_NO_DEBUGGING@ -gem_specification_TEST_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_CXXFLAGS_NO_DEBUGGING@ -gem_specifications_TEST_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_CXXFLAGS_NO_DEBUGGING@ - -EXTRA_DIST = \ - installed_gems_repository_TEST.cc \ - installed_gems_repository_TEST_setup.sh \ - installed_gems_repository_TEST_cleanup.sh \ - gems_repository_TEST.cc \ - gems_repository_TEST_setup.sh \ - gems_repository_TEST_cleanup.sh \ - yaml_TEST.cc \ - gem_specification_TEST.cc \ - gem_specifications_TEST.cc - -check_SCRIPTS = \ - gems_repository_TEST_setup.sh gems_repository_TEST_cleanup.sh - -paludis_gems_libexec_SCRIPTS = gems.bash - -TESTS = gems_repository_TEST installed_gems_repository_TEST yaml_TEST gem_specification_TEST gem_specifications_TEST -check_PROGRAMS = $(TESTS) - diff --git a/paludis/repositories/gems/exceptions.cc b/paludis/repositories/gems/exceptions.cc deleted file mode 100644 index eb106fddd..000000000 --- a/paludis/repositories/gems/exceptions.cc +++ /dev/null @@ -1,29 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007 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 "exceptions.hh" - -using namespace paludis; -using namespace paludis::gems; - -RepositoryConfigurationError::RepositoryConfigurationError(const std::string & s) throw () : - ConfigurationError(s) -{ -} - diff --git a/paludis/repositories/gems/exceptions.hh b/paludis/repositories/gems/exceptions.hh deleted file mode 100644 index ebb47b580..000000000 --- a/paludis/repositories/gems/exceptions.hh +++ /dev/null @@ -1,50 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007 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_GEMS_EXCEPTIONS_HH -#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_GEMS_EXCEPTIONS_HH 1 - -#include <paludis/util/exception.hh> - -namespace paludis -{ - namespace gems - { - /** - * Thrown if a Gems repository is misconfigured. - * - * \ingroup grpexceptions - * \ingroup grpgemsrepository - * \nosubgrouping - */ - class PALUDIS_VISIBLE RepositoryConfigurationError : - public ConfigurationError - { - public: - ///\name Basic operations - ///\{ - - RepositoryConfigurationError(const std::string &) throw (); - - ///\} - }; - } -} - -#endif diff --git a/paludis/repositories/gems/extra_distribution_data.cc b/paludis/repositories/gems/extra_distribution_data.cc deleted file mode 100644 index 031e1ed81..000000000 --- a/paludis/repositories/gems/extra_distribution_data.cc +++ /dev/null @@ -1,49 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2008, 2010 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/gems/extra_distribution_data.hh> -#include <paludis/util/make_named_values.hh> -#include <paludis/util/singleton-impl.hh> -#include <paludis/distribution-impl.hh> - -using namespace paludis; -using namespace paludis::gems; - -namespace paludis -{ - template <> - struct ExtraDistributionDataData<GemsDistribution> - { - static std::string config_file_name() - { - return "gems.conf"; - } - - static std::shared_ptr<GemsDistribution> make_data(const std::shared_ptr<const KeyValueConfigFile> & k) - { - return std::make_shared<GemsDistribution>(make_named_values<GemsDistribution>( - n::default_buildroot() = k->get("default_buildroot") - )); - } - }; -} - -template class ExtraDistributionData<GemsDistribution>; -template class Singleton<ExtraDistributionData<GemsDistribution>>; - diff --git a/paludis/repositories/gems/extra_distribution_data.hh b/paludis/repositories/gems/extra_distribution_data.hh deleted file mode 100644 index 990758d06..000000000 --- a/paludis/repositories/gems/extra_distribution_data.hh +++ /dev/null @@ -1,45 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2008, 2010 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_GEMS_EXTRA_DISTRIBUTION_DATA_HH -#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_GEMS_EXTRA_DISTRIBUTION_DATA_HH 1 - -#include <paludis/distribution-fwd.hh> -#include <paludis/util/named_value.hh> -#include <string> - -namespace paludis -{ - namespace n - { - typedef Name<struct default_buildroot_name> default_buildroot; - } - - namespace gems - { - struct GemsDistribution - { - NamedValue<n::default_buildroot, std::string> default_buildroot; - }; - - typedef ExtraDistributionData<GemsDistribution> GemsExtraDistributionData; - } -} - -#endif diff --git a/paludis/repositories/gems/gem_specification-fwd.hh b/paludis/repositories/gems/gem_specification-fwd.hh deleted file mode 100644 index 44a8c189e..000000000 --- a/paludis/repositories/gems/gem_specification-fwd.hh +++ /dev/null @@ -1,32 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007 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_GEMS_GEM_SPECIFICATION_FWD_HH -#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_GEMS_GEM_SPECIFICATION_FWD_HH 1 - -namespace paludis -{ - namespace gems - { - class BadSpecificationError; - class GemSpecification; - } -} - -#endif diff --git a/paludis/repositories/gems/gem_specification.cc b/paludis/repositories/gems/gem_specification.cc deleted file mode 100644 index 52ef46d74..000000000 --- a/paludis/repositories/gems/gem_specification.cc +++ /dev/null @@ -1,649 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2008, 2009, 2010 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/gems/gem_specification.hh> -#include <paludis/repositories/gems/yaml.hh> -#include <paludis/util/pimp-impl.hh> -#include <paludis/util/mutex.hh> -#include <paludis/util/stringify.hh> -#include <paludis/util/make_named_values.hh> -#include <paludis/util/make_null_shared_ptr.hh> -#include <paludis/name.hh> -#include <paludis/version_spec.hh> -#include <paludis/repository.hh> -#include <paludis/metadata_key.hh> -#include <paludis/action.hh> -#include <paludis/environment.hh> -#include <paludis/literal_metadata_key.hh> -#include <paludis/mask.hh> -#include <paludis/user_dep_spec.hh> -#include <functional> - -using namespace paludis; -using namespace paludis::gems; - -namespace paludis -{ - template <> - struct Imp<GemSpecification> - { - mutable Mutex mutex; - - std::string name_part; - std::string version; - std::string date; - std::string platform; - std::string homepage; - - std::shared_ptr<LiteralMetadataValueKey<std::string> > description_key; - std::shared_ptr<LiteralMetadataValueKey<std::string> > summary_key; - std::shared_ptr<LiteralMetadataValueKey<std::string> > authors_key; - std::shared_ptr<LiteralMetadataValueKey<std::string> > rubyforge_project_key; - std::shared_ptr<LiteralMetadataValueKey<FSPath> > fs_location_key; - std::shared_ptr<LiteralMetadataValueKey<SlotName> > slot_key; - - std::shared_ptr<const FSPath> load_from_file; - - const Environment * const environment; - const std::shared_ptr<const Repository> repository; - - mutable bool has_masks; - - Imp(const Environment * const e, const std::shared_ptr<const Repository> & r) : - environment(e), - repository(r), - has_masks(false) - { - } - }; -} - -namespace -{ - std::string extract_text_only(const yaml::Node & n, const std::string & extra); - - struct VersionVisitor - { - std::string text; - - void visit(const yaml::StringNode & n) PALUDIS_ATTRIBUTE((noreturn)); - void visit(const yaml::SequenceNode & n) PALUDIS_ATTRIBUTE((noreturn)); - - void visit(const yaml::MapNode & n) - { - yaml::MapNode::ConstIterator i(n.find("version")); - if (i == n.end()) - throw BadSpecificationError("Version has no version: key"); - text = extract_text_only(*i->second, "for Version version: key"); - } - }; - - void VersionVisitor::visit(const yaml::StringNode &) - { - throw BadSpecificationError("Version child node is string, not map"); - } - - void VersionVisitor::visit(const yaml::SequenceNode &) - { - throw BadSpecificationError("Version child node is sequence, not map"); - } - - struct ExtractTextVisitor - { - const std::string extra; - const bool accept_sequence; - std::string result; - - ExtractTextVisitor(const std::string & s, const bool b) : - extra(s), - accept_sequence(b) - { - } - - void visit(const yaml::StringNode & n) - { - result = n.text(); - } - - void visit(const yaml::SequenceNode & s) - { - if (! accept_sequence) - throw BadSpecificationError("Found sequence rather than text " + extra); - - bool w(false); - for (yaml::SequenceNode::ConstIterator i(s.begin()), i_end(s.end()) ; i != i_end ; ++i) - { - if (w) - result.append(", "); - result.append(extract_text_only(**i, extra)); - w = true; - } - } - - void visit(const yaml::MapNode &) PALUDIS_ATTRIBUTE((noreturn)); - }; - - void ExtractTextVisitor::visit(const yaml::MapNode &) - { - throw BadSpecificationError("Found map rather than text " + extra); - } - - std::string extract_text_only(const yaml::Node & n, const std::string & extra) - { - ExtractTextVisitor v(extra, false); - n.accept(v); - return v.result; - } - - std::string extract_text_sequence(const yaml::Node & n, const std::string & extra) - { - ExtractTextVisitor v(extra, true); - n.accept(v); - return v.result; - } - - std::string required_text_only_key(const yaml::MapNode & n, const std::string & k) - { - yaml::MapNode::ConstIterator i(n.find(k)); - if (i == n.end()) - throw BadSpecificationError("Key '" + k + "' not defined"); - return extract_text_only(*i->second, "for key '" + k + "'"); - } - - std::string optional_text_sequence_key(const yaml::MapNode & n, const std::string & k) - { - yaml::MapNode::ConstIterator i(n.find(k)); - if (i == n.end()) - return ""; - return extract_text_sequence(*i->second, "for key '" + k + "'"); - } - - std::string optional_text_only_key(const yaml::MapNode & n, const std::string & k) - { - yaml::MapNode::ConstIterator i(n.find(k)); - if (i == n.end()) - return ""; - return extract_text_only(*i->second, "for key '" + k + "'"); - } - - std::string required_version(const yaml::MapNode & n, const std::string & k) - { - yaml::MapNode::ConstIterator i(n.find(k)); - if (i == n.end()) - throw BadSpecificationError("Key '" + k + "' not defined"); - - VersionVisitor v; - i->second->accept(v); - return v.text; - } - - struct TopVisitor - { - Imp<GemSpecification> * const _imp; - - TopVisitor(Imp<GemSpecification> * const i) : - _imp(i) - { - } - - void visit(const yaml::MapNode & n) - { - std::string summary(required_text_only_key(n, "summary")); - if (! summary.empty()) - _imp->summary_key = std::make_shared<LiteralMetadataValueKey<std::string> >("summary", "Summary", mkt_significant, summary); - - std::string description(optional_text_only_key(n, "description")); - if (! description.empty()) - _imp->description_key = std::make_shared<LiteralMetadataValueKey<std::string> >("description", "Description", mkt_normal, description); - - std::string authors(optional_text_sequence_key(n, "authors")); - if (! authors.empty()) - _imp->authors_key = std::make_shared<LiteralMetadataValueKey<std::string> >("authors", "Authors", mkt_normal, authors); - - std::string rubyforge_project(optional_text_sequence_key(n, "rubyforge_project")); - if (! rubyforge_project.empty()) - _imp->rubyforge_project_key = std::make_shared<LiteralMetadataValueKey<std::string> >("rubyforge_project", "Rubyforge Project", - mkt_normal, rubyforge_project); - - _imp->date = required_text_only_key(n, "date"); - _imp->platform = required_text_only_key(n, "platform"); - _imp->name_part = required_text_only_key(n, "name"); - _imp->version = required_version(n, "version"); - } - - void visit(const yaml::SequenceNode & n) PALUDIS_ATTRIBUTE((noreturn)); - - void visit(const yaml::StringNode & n) PALUDIS_ATTRIBUTE((noreturn)); - }; - - void TopVisitor::visit(const yaml::SequenceNode &) - { - throw BadSpecificationError("Top level node is sequence, not map"); - } - - void TopVisitor::visit(const yaml::StringNode & n) - { - throw BadSpecificationError("Top level node is text '" + n.text() + "', not map"); - } -} - -GemSpecification::GemSpecification(const Environment * const e, - const std::shared_ptr<const Repository> & r, const yaml::Node & node) : - Pimp<GemSpecification>(e, r), - _imp(Pimp<GemSpecification>::_imp) -{ - TopVisitor v(_imp.get()); - node.accept(v); - - if (_imp->summary_key) - add_metadata_key(_imp->summary_key); - - if (_imp->description_key) - add_metadata_key(_imp->description_key); - - if (_imp->authors_key) - add_metadata_key(_imp->authors_key); - - if (_imp->rubyforge_project_key) - add_metadata_key(_imp->rubyforge_project_key); -} - - -GemSpecification::GemSpecification(const Environment * const e, const std::shared_ptr<const Repository> & r, - const PackageNamePart & q, const VersionSpec & v, const FSPath & f) : - Pimp<GemSpecification>(e, r), - _imp(Pimp<GemSpecification>::_imp) -{ - _imp->name_part = stringify(q); - _imp->version = stringify(v); - _imp->load_from_file = std::make_shared<FSPath>(f); - _imp->fs_location_key = std::make_shared<LiteralMetadataValueKey<FSPath> >("GEM", "Gem Location", mkt_internal, f); - add_metadata_key(_imp->fs_location_key); - _imp->slot_key = std::make_shared<LiteralMetadataValueKey<SlotName>>("SLOT", "Slot", mkt_internal, SlotName(stringify(v))); - add_metadata_key(_imp->slot_key); -} - -GemSpecification::~GemSpecification() -{ -} - -BadSpecificationError::BadSpecificationError(const std::string & s) throw () : - Exception("Bad gem specification: " + s) -{ -} - -const std::string -GemSpecification::canonical_form(const PackageIDCanonicalForm f) const -{ - switch (f) - { - case idcf_full: - return stringify(name()) + "-" + stringify(version()) + "::" + stringify(repository()->name()); - - case idcf_version: - return stringify(version()); - - case idcf_no_version: - return stringify(name()) + "::" + stringify(_imp->repository->name()); - - case idcf_no_name: - return stringify(version()) + "::" + stringify(repository()->name()); - - case last_idcf: - break; - } - - throw InternalError(PALUDIS_HERE, "Bad PackageIDCanonicalForm"); -} - -PackageDepSpec -GemSpecification::uniquely_identifying_spec() const -{ - return parse_user_package_dep_spec("=" + stringify(name()) + "-" + stringify(version()) + "::" + stringify(repository()->name()), - _imp->environment, { }); -} - -const QualifiedPackageName -GemSpecification::name() const -{ - return QualifiedPackageName(CategoryNamePart("gems") + PackageNamePart(_imp->name_part)); -} - -const VersionSpec -GemSpecification::version() const -{ - return VersionSpec(_imp->version, { }); -} - -const std::shared_ptr<const Repository> -GemSpecification::repository() const -{ - return _imp->repository; -} - -const std::shared_ptr<const MetadataValueKey<std::shared_ptr<const PackageID> > > -GemSpecification::virtual_for_key() const -{ - return std::shared_ptr<const MetadataValueKey<std::shared_ptr<const PackageID> > >(); -} - -const std::shared_ptr<const MetadataCollectionKey<KeywordNameSet> > -GemSpecification::keywords_key() const -{ - return std::shared_ptr<const MetadataCollectionKey<KeywordNameSet> >(); -} - -const std::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> > -GemSpecification::provide_key() const -{ - return std::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> >(); -} - -const std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > -GemSpecification::dependencies_key() const -{ - return std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >(); -} - -const std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > -GemSpecification::build_dependencies_key() const -{ - return std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >(); -} - -const std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > -GemSpecification::run_dependencies_key() const -{ - return std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >(); -} - -const std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > -GemSpecification::post_dependencies_key() const -{ - return std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >(); -} - -const std::shared_ptr<const MetadataSpecTreeKey<FetchableURISpecTree> > -GemSpecification::fetches_key() const -{ - return std::shared_ptr<const MetadataSpecTreeKey<FetchableURISpecTree> >(); -} - -const std::shared_ptr<const MetadataSpecTreeKey<SimpleURISpecTree> > -GemSpecification::homepage_key() const -{ - return std::shared_ptr<const MetadataSpecTreeKey<SimpleURISpecTree> >(); -} - -const std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > -GemSpecification::suggested_dependencies_key() const -{ - return std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >(); -} - -const std::shared_ptr<const MetadataValueKey<std::string> > -GemSpecification::short_description_key() const -{ - return _imp->summary_key; -} - -const std::shared_ptr<const MetadataValueKey<std::string> > -GemSpecification::long_description_key() const -{ - return _imp->description_key; -} - -const std::shared_ptr<const MetadataValueKey<FSPath> > -GemSpecification::fs_location_key() const -{ - return _imp->fs_location_key; -} - -const std::shared_ptr<const MetadataValueKey<std::shared_ptr<const Contents> > > -GemSpecification::contents_key() const -{ - return std::shared_ptr<const MetadataValueKey<std::shared_ptr<const Contents> > >(); -} - -const std::shared_ptr<const MetadataTimeKey> -GemSpecification::installed_time_key() const -{ - return std::shared_ptr<const MetadataTimeKey>(); -} - -const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > -GemSpecification::from_repositories_key() const -{ - return std::shared_ptr<const MetadataCollectionKey<Set<std::string> > >(); -} - -const std::shared_ptr<const MetadataCollectionKey<PackageIDSequence> > -GemSpecification::contains_key() const -{ - return std::shared_ptr<const MetadataCollectionKey<PackageIDSequence> >(); -} - -const std::shared_ptr<const MetadataValueKey<std::shared_ptr<const PackageID> > > -GemSpecification::contained_in_key() const -{ - return std::shared_ptr<const MetadataValueKey<std::shared_ptr<const PackageID> > >(); -} - -const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > -GemSpecification::behaviours_key() const -{ - return make_null_shared_ptr(); -} - -const std::shared_ptr<const MetadataValueKey<SlotName> > -GemSpecification::slot_key() const -{ - return _imp->slot_key; -} - -bool -GemSpecification::arbitrary_less_than_comparison(const PackageID &) const -{ - return false; -} - -std::size_t -GemSpecification::extra_hash_value() const -{ - return 0; -} - -void -GemSpecification::need_keys_added() const -{ - if (_imp->load_from_file) - throw InternalError(PALUDIS_HERE, "Got to do the load from file thing"); -} - -#if 0 -InstalledGemsRepository::need_version_metadata(const QualifiedPackageName & q, const VersionSpec & v) const -{ - MetadataMap::const_iterator i(_imp->metadata.find(std::make_pair(q, v))); - if (i != _imp->metadata.end()) - return; - - Context c("When loading version metadata for '" + stringify(PackageDatabaseEntry(q, v, name())) + "':"); - - std::shared_ptr<gems::InstalledGemMetadata> m(std::make_shared<gems::InstalledGemMetadata>(v)); - _imp->metadata.insert(std::make_pair(std::make_pair(q, v), m)); - - Command cmd(getenv_with_default("PALUDIS_GEMS_DIR", LIBEXECDIR "/paludis") + - "/gems/gems.bash specification '" + stringify(q.package) + "' '" + stringify(v) + "'"); - cmd.with_stderr_prefix(stringify(q) + "-" + stringify(v) + "::" + stringify(name()) + "> "); - cmd.with_sandbox(); - cmd.with_uid_gid(_imp->params.environment->reduced_uid(), _imp->params.environment->reduced_gid()); - - PStream p(cmd); - std::string output((std::istreambuf_iterator<char>(p)), std::istreambuf_iterator<char>()); - - if (0 != p.exit_status()) - { - Log::get_instance()->message(ll_warning, lc_context) << "Version metadata extraction returned non-zero"; - return; - } - - yaml::Document spec_doc(output); - gems::GemSpecification spec(*spec_doc.top()); - m->populate_from_specification(spec); - m->eapi = EAPIData::get_instance()->eapi_from_string("gems-1"); -} -#endif - -bool -GemSpecification::supports_action(const SupportsActionTestBase & b) const -{ - return repository()->some_ids_might_support_action(b); -} - -namespace -{ - struct PerformAction - { - const PackageID * const id; - - PerformAction(const PackageID * const i) : - id(i) - { - } - - void visit(const InstallAction & a) - { - SupportsActionTest<InstallAction> t; - if (! id->repository()->some_ids_might_support_action(t)) - throw ActionFailedError("Unsupported action '" + a.simple_name() + "'"); - } - - void visit(const UninstallAction & a) - { - SupportsActionTest<UninstallAction> t; - if (! id->repository()->some_ids_might_support_action(t)) - throw ActionFailedError("Unsupported action '" + a.simple_name() + "'"); - } - - void visit(const ConfigAction & a) - { - SupportsActionTest<ConfigAction> t; - if (! id->repository()->some_ids_might_support_action(t)) - throw ActionFailedError("Unsupported action '" + a.simple_name() + "'"); - } - - void visit(const FetchAction & a) - { - SupportsActionTest<FetchAction> t; - if (! id->repository()->some_ids_might_support_action(t)) - throw ActionFailedError("Unsupported action '" + a.simple_name() + "'"); - } - - void visit(const InfoAction & a) - { - SupportsActionTest<InfoAction> t; - if (! id->repository()->some_ids_might_support_action(t)) - throw ActionFailedError("Unsupported action '" + a.simple_name() + "'"); - } - - void visit(const PretendAction & a) - { - SupportsActionTest<PretendAction> t; - if (! id->repository()->some_ids_might_support_action(t)) - throw ActionFailedError("Unsupported action '" + a.simple_name() + "'"); - } - - void visit(const PretendFetchAction & a) - { - SupportsActionTest<PretendFetchAction> t; - if (! id->repository()->some_ids_might_support_action(t)) - throw ActionFailedError("Unsupported action '" + a.simple_name() + "'"); - } - }; -} - -void -GemSpecification::perform_action(Action & a) const -{ - PerformAction b(this); - a.accept(b); -} - -void -GemSpecification::need_masks_added() const -{ - Lock l(_imp->mutex); - - if (_imp->has_masks) - return; - - _imp->has_masks = true; - - Context context("When generating masks for ID '" + canonical_form(idcf_full) + "':"); - - if (! _imp->environment->unmasked_by_user(*this)) - { - /* user */ - std::shared_ptr<const Mask> user_mask(_imp->environment->mask_for_user(*this, false)); - if (user_mask) - add_mask(user_mask); - } - else - { - std::shared_ptr<const Mask> user_mask(_imp->environment->mask_for_user(*this, true)); - if (user_mask) - add_overridden_mask(std::make_shared<OverriddenMask>( - make_named_values<OverriddenMask>( - n::mask() = user_mask, - n::override_reason() = mro_overridden_by_user - ))); - } - - /* break portage */ - std::shared_ptr<const Mask> breaks_mask(_imp->environment->mask_for_breakage(*this)); - if (breaks_mask) - add_mask(breaks_mask); -} - -void -GemSpecification::invalidate_masks() const -{ - Lock l(_imp->mutex); - - if (! _imp->has_masks) - return; - - _imp->has_masks = false; - PackageID::invalidate_masks(); -} - -std::shared_ptr<const Set<std::string> > -GemSpecification::breaks_portage() const -{ - std::shared_ptr<Set<std::string> > why(std::make_shared<Set<std::string>>()); - why->insert("format"); - return why; -} - -const std::shared_ptr<const MetadataValueKey<std::shared_ptr<const Choices> > > -GemSpecification::choices_key() const -{ - return std::shared_ptr<const MetadataValueKey<std::shared_ptr<const Choices> > >(); -} - diff --git a/paludis/repositories/gems/gem_specification.hh b/paludis/repositories/gems/gem_specification.hh deleted file mode 100644 index a487ec5c8..000000000 --- a/paludis/repositories/gems/gem_specification.hh +++ /dev/null @@ -1,129 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2008, 2009, 2010 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_GEMS_GEM_SPECIFICATION_HH -#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_GEMS_GEM_SPECIFICATION_HH 1 - -#include <paludis/repositories/gems/gem_specification-fwd.hh> -#include <paludis/repositories/gems/yaml-fwd.hh> -#include <paludis/package_id.hh> -#include <paludis/name-fwd.hh> -#include <paludis/util/attributes.hh> -#include <paludis/util/pimp.hh> -#include <paludis/util/exception.hh> -#include <string> - -namespace paludis -{ - namespace gems - { - /** - * Thrown if a bad Gem specification is encountered. - * - * \ingroup grpexceptions - * \ingroup grpgemsrepository - * \nosubgrouping - */ - class PALUDIS_VISIBLE BadSpecificationError : - public Exception - { - public: - ///\name Basic operations - ///\{ - - BadSpecificationError(const std::string &) throw (); - - ///\} - }; - - /** - * Represents a Gem specification. - * - * \ingroup grpgemsrepository - * \nosubgrouping - */ - class PALUDIS_VISIBLE GemSpecification : - private Pimp<GemSpecification>, - public PackageID - { - private: - Pimp<GemSpecification>::ImpPtr & _imp; - - protected: - void need_keys_added() const; - virtual void need_masks_added() const; - - public: - ///\name Basic operations - ///\{ - - GemSpecification(const Environment * const e, const std::shared_ptr<const Repository> &, const yaml::Node &); - GemSpecification(const Environment * const e, const std::shared_ptr<const Repository> &, const PackageNamePart &, - const VersionSpec &, const FSPath &); - - ~GemSpecification(); - - ///\} - - /* PackageID */ - virtual const std::string canonical_form(const PackageIDCanonicalForm) const; - - virtual const QualifiedPackageName name() const; - virtual const VersionSpec version() const; - virtual const std::shared_ptr<const Repository> repository() const; - virtual PackageDepSpec uniquely_identifying_spec() const; - - virtual const std::shared_ptr<const MetadataValueKey<SlotName> > slot_key() const; - virtual const std::shared_ptr<const MetadataValueKey<std::shared_ptr<const PackageID> > > virtual_for_key() const; - virtual const std::shared_ptr<const MetadataCollectionKey<KeywordNameSet> > keywords_key() const; - virtual const std::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> > provide_key() const; - virtual const std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > dependencies_key() const; - virtual const std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > build_dependencies_key() const; - virtual const std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > run_dependencies_key() const; - virtual const std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > post_dependencies_key() const; - virtual const std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > suggested_dependencies_key() const; - virtual const std::shared_ptr<const MetadataSpecTreeKey<FetchableURISpecTree> > fetches_key() const; - virtual const std::shared_ptr<const MetadataSpecTreeKey<SimpleURISpecTree> > homepage_key() const; - virtual const std::shared_ptr<const MetadataValueKey<std::string> > short_description_key() const; - virtual const std::shared_ptr<const MetadataValueKey<std::string> > long_description_key() const; - virtual const std::shared_ptr<const MetadataCollectionKey<PackageIDSequence> > contains_key() const; - virtual const std::shared_ptr<const MetadataValueKey<std::shared_ptr<const PackageID> > > contained_in_key() const; - - virtual const std::shared_ptr<const MetadataValueKey<FSPath> > fs_location_key() const; - virtual const std::shared_ptr<const MetadataValueKey<std::shared_ptr<const Contents> > > contents_key() const; - virtual const std::shared_ptr<const MetadataTimeKey> installed_time_key() const; - virtual const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > from_repositories_key() const; - virtual const std::shared_ptr<const MetadataValueKey<std::shared_ptr<const Choices> > > choices_key() const; - - virtual const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > behaviours_key() const; - - virtual bool supports_action(const SupportsActionTestBase &) const PALUDIS_ATTRIBUTE((warn_unused_result)); - virtual void perform_action(Action &) const; - - virtual bool arbitrary_less_than_comparison(const PackageID &) const; - virtual std::size_t extra_hash_value() const; - - virtual std::shared_ptr<const Set<std::string> > breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual void invalidate_masks() const; - }; - } -} - -#endif diff --git a/paludis/repositories/gems/gem_specification_TEST.cc b/paludis/repositories/gems/gem_specification_TEST.cc deleted file mode 100644 index b839ff419..000000000 --- a/paludis/repositories/gems/gem_specification_TEST.cc +++ /dev/null @@ -1,84 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2008, 2009, 2010 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 <test/test_runner.hh> -#include <test/test_framework.hh> -#include <paludis/repositories/gems/gem_specification.hh> -#include <paludis/repositories/gems/yaml.hh> -#include <paludis/environments/test/test_environment.hh> -#include <paludis/util/simple_visitor_cast.hh> -#include <paludis/util/set.hh> -#include <paludis/util/options.hh> -#include <paludis/name.hh> -#include <paludis/metadata_key.hh> -#include <paludis/version_spec.hh> - -using namespace test; -using namespace paludis; -using namespace paludis::gems; - -namespace test_cases -{ - struct SpecificationTest : TestCase - { - SpecificationTest() : TestCase("gem specification") { } - - void run() - { - std::string spec_text( - "--- !ruby/object:Gem::Specification\n" - "name: demo\n" - "version: !ruby/object:Gem::Version\n" - " version: 1.2.3\n" - "summary: This is the summary\n" - "homepage:\n" - "rubyforge_project:\n" - "description: A longer description\n" - "platform: ruby\n" - "date: 1234\n" - "authors: [ Fred , Barney ]\n" - ); - - yaml::Document spec_doc(spec_text); - TEST_CHECK(spec_doc.top()); - - TestEnvironment env; - GemSpecification spec(&env, std::shared_ptr<Repository>(), *spec_doc.top()); - - TEST_CHECK(bool(spec.short_description_key())); - TEST_CHECK_EQUAL(spec.short_description_key()->value(), "This is the summary"); - TEST_CHECK_EQUAL(spec.name(), QualifiedPackageName("gems/demo")); - TEST_CHECK_EQUAL(spec.version(), VersionSpec("1.2.3", { })); - TEST_CHECK(spec.find_metadata("rubyforge_project") == spec.end_metadata()); - TEST_CHECK(bool(spec.long_description_key())); - TEST_CHECK_EQUAL(spec.long_description_key()->value(), "A longer description"); - - TEST_CHECK(spec.find_metadata("authors") != spec.end_metadata()); - TEST_CHECK(simple_visitor_cast<const MetadataValueKey<std::string> >(**spec.find_metadata("authors"))); - TEST_CHECK_EQUAL(simple_visitor_cast<const MetadataValueKey<std::string> >(**spec.find_metadata("authors"))->value(), "Fred, Barney"); - -#if 0 - TEST_CHECK_EQUAL(spec.homepage(), ""); - TEST_CHECK_EQUAL(spec.rubyforge_project(), ""); - TEST_CHECK_EQUAL(spec.date(), "1234"); -#endif - } - } test_specification; -} - diff --git a/paludis/repositories/gems/gem_specifications.cc b/paludis/repositories/gems/gem_specifications.cc deleted file mode 100644 index f1b22eaf8..000000000 --- a/paludis/repositories/gems/gem_specifications.cc +++ /dev/null @@ -1,224 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2008, 2009, 2010 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/gems/gem_specifications.hh> -#include <paludis/repositories/gems/gem_specification.hh> -#include <paludis/repositories/gems/yaml.hh> -#include <paludis/name.hh> -#include <paludis/version_spec.hh> -#include <paludis/util/pimp-impl.hh> -#include <paludis/util/log.hh> -#include <paludis/util/stringify.hh> -#include <paludis/util/wrapped_forward_iterator-impl.hh> -#include <paludis/util/hashes.hh> -#include <unordered_map> - -using namespace paludis; -using namespace paludis::gems; - -typedef std::unordered_map<std::pair<QualifiedPackageName, VersionSpec>, std::shared_ptr<const GemSpecification>, - Hash<std::pair<QualifiedPackageName, VersionSpec> > > Specs; - -namespace paludis -{ - template <> - struct Imp<GemSpecifications> - { - Specs specs; - }; - - template <> - struct WrappedForwardIteratorTraits<GemSpecifications::ConstIteratorTag> - { - typedef Specs::const_iterator UnderlyingIterator; - }; -} - -namespace -{ - std::string extract_text_only(const yaml::Node & n, const std::string & extra); - - struct ExtractTextVisitor - { - const std::string extra; - const bool accept_sequence; - std::string result; - - ExtractTextVisitor(const std::string & s, const bool b) : - extra(s), - accept_sequence(b) - { - } - - void visit(const yaml::StringNode & n) - { - result = n.text(); - } - - void visit(const yaml::SequenceNode & s) - { - if (! accept_sequence) - throw BadSpecificationError("Found sequence rather than text " + extra); - - bool w(false); - for (yaml::SequenceNode::ConstIterator i(s.begin()), i_end(s.end()) ; i != i_end ; ++i) - { - if (w) - result.append(", "); - result.append(extract_text_only(**i, extra)); - w = true; - } - } - - void visit(const yaml::MapNode &) PALUDIS_ATTRIBUTE((noreturn)); - }; - - void ExtractTextVisitor::visit(const yaml::MapNode &) - { - throw BadSpecificationError("Found map rather than text " + extra); - } - - std::string extract_text_only(const yaml::Node & n, const std::string & extra) - { - ExtractTextVisitor v(extra, false); - n.accept(v); - return v.result; - } - - struct GemsVisitor - { - Imp<GemSpecifications> * const _imp; - const Environment * const environment; - const std::shared_ptr<const Repository> repository; - - GemsVisitor(const Environment * const e, - const std::shared_ptr<const Repository> & r, Imp<GemSpecifications> * const i) : - _imp(i), - environment(e), - repository(r) - { - } - - void visit(const yaml::MapNode & n) - { - for (yaml::MapNode::ConstIterator i(n.begin()), i_end(n.end()) ; i != i_end ; ++i) - { - std::string pv(extract_text_only(*i->first, " as key for gem")); - Context c_item("When handling Gem entry '" + pv + "':"); - - try - { - std::shared_ptr<GemSpecification> spec(std::make_shared<GemSpecification>(environment, repository, *i->second)); - _imp->specs.insert(std::make_pair(std::make_pair(spec->name(), spec->version()), spec)); - } - catch (const InternalError &) - { - throw; - } - catch (const Exception & e) - { - Log::get_instance()->message("gems.id.failure", ll_qa, lc_context) << "Skipping entry '" - << pv << "' due to exception '" << e.message() << "' (" << e.what() << ")"; - } - } - } - - void visit(const yaml::SequenceNode & n) PALUDIS_ATTRIBUTE((noreturn)); - - void visit(const yaml::StringNode & n) PALUDIS_ATTRIBUTE((noreturn)); - }; - - void GemsVisitor::visit(const yaml::SequenceNode &) - { - throw BadSpecificationError("Top level 'gems' right hand node is sequence, not map"); - } - - void GemsVisitor::visit(const yaml::StringNode & n) - { - throw BadSpecificationError("Top level 'gems' right hand node is text '" + n.text() + "', not map"); - } - - struct TopVisitor - { - Imp<GemSpecifications> * const _imp; - const Environment * const environment; - const std::shared_ptr<const Repository> repository; - - TopVisitor(const Environment * const e, - const std::shared_ptr<const Repository> & r, Imp<GemSpecifications> * const i) : - _imp(i), - environment(e), - repository(r) - { - } - - void visit(const yaml::MapNode & n) - { - yaml::MapNode::ConstIterator i(n.find("gems")); - if (n.end() == i) - throw BadSpecificationError("Top level map does not contain 'gems' node"); - - GemsVisitor g(environment, repository, _imp); - i->second->accept(g); - } - - void visit(const yaml::SequenceNode & n) PALUDIS_ATTRIBUTE((noreturn)); - - void visit(const yaml::StringNode & n) PALUDIS_ATTRIBUTE((noreturn)); - }; - - void TopVisitor::visit(const yaml::SequenceNode &) - { - throw BadSpecificationError("Top level node is sequence, not map"); - } - - void TopVisitor::visit(const yaml::StringNode & n) - { - throw BadSpecificationError("Top level node is text '" + n.text() + "', not map"); - } -} - -GemSpecifications::GemSpecifications(const Environment * const e, - const std::shared_ptr<const Repository> & r, const yaml::Node & n) : - Pimp<GemSpecifications>() -{ - TopVisitor v(e, r, _imp.get()); - n.accept(v); -} - -GemSpecifications::~GemSpecifications() -{ -} - -GemSpecifications::ConstIterator -GemSpecifications::begin() const -{ - return ConstIterator(_imp->specs.begin()); -} - -GemSpecifications::ConstIterator -GemSpecifications::end() const -{ - return ConstIterator(_imp->specs.end()); -} - -template class WrappedForwardIterator<GemSpecifications::ConstIteratorTag, - const std::pair<const std::pair<QualifiedPackageName, VersionSpec>, std::shared_ptr<const GemSpecification> > >; - - diff --git a/paludis/repositories/gems/gem_specifications.hh b/paludis/repositories/gems/gem_specifications.hh deleted file mode 100644 index c767d69ac..000000000 --- a/paludis/repositories/gems/gem_specifications.hh +++ /dev/null @@ -1,74 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * 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 - * 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_GEMS_GEM_SPECIFICATIONS_HH -#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_GEMS_GEM_SPECIFICATIONS_HH 1 - -#include <paludis/repositories/gems/gem_specification-fwd.hh> -#include <paludis/repositories/gems/yaml-fwd.hh> -#include <paludis/util/attributes.hh> -#include <paludis/util/pimp.hh> -#include <paludis/util/exception.hh> -#include <paludis/util/wrapped_forward_iterator-fwd.hh> -#include <paludis/name-fwd.hh> -#include <paludis/version_spec-fwd.hh> -#include <paludis/repository-fwd.hh> -#include <memory> -#include <string> - -namespace paludis -{ - namespace gems - { - /** - * Represents a collection of Gem specifications held in a master yaml - * file. - * - * \ingroup grpgemsrepository - * \nosubgrouping - */ - class PALUDIS_VISIBLE GemSpecifications : - private Pimp<GemSpecifications> - { - public: - ///\name Basic operations - ///\{ - - GemSpecifications(const Environment * const, const std::shared_ptr<const Repository> &, const yaml::Node &); - ~GemSpecifications(); - - ///\} - - ///\name Iterate over our specifications - ///\{ - - struct ConstIteratorTag; - typedef WrappedForwardIterator<ConstIteratorTag, - const std::pair<const std::pair<QualifiedPackageName, VersionSpec>, std::shared_ptr<const GemSpecification> > > - ConstIterator; - ConstIterator begin() const PALUDIS_ATTRIBUTE((warn_unused_result)); - ConstIterator end() const PALUDIS_ATTRIBUTE((warn_unused_result)); - - ///\} - }; - } -} - -#endif - diff --git a/paludis/repositories/gems/gem_specifications_TEST.cc b/paludis/repositories/gems/gem_specifications_TEST.cc deleted file mode 100644 index 7c3571d7d..000000000 --- a/paludis/repositories/gems/gem_specifications_TEST.cc +++ /dev/null @@ -1,41 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007 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 <test/test_runner.hh> -#include <test/test_framework.hh> -#include <paludis/repositories/gems/gem_specification.hh> -#include <paludis/repositories/gems/yaml.hh> - -using namespace test; -using namespace paludis; -using namespace paludis::gems; - -namespace test_cases -{ - struct SpecificationsTest : TestCase - { - SpecificationsTest() : TestCase("gem specifications") { } - - void run() - { - } - } test_specifications; -} - - diff --git a/paludis/repositories/gems/gems.bash b/paludis/repositories/gems/gems.bash deleted file mode 100755 index 51d18b321..000000000 --- a/paludis/repositories/gems/gems.bash +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env bash -# vim: set sw=4 sts=4 et : - -# Copyright (c) 2007 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 - -unalias -a -set +C -unset GZIP BZIP BZIP2 CDPATH GREP_OPTIONS GREP_COLOR GLOBIGNORE -eval unset LANG ${!LC_*} - -if [[ -z "${PALUDIS_DO_NOTHING_SANDBOXY}" ]] ; then - export SANDBOX_WRITE="${SANDBOX_WRITE}/dev/shm:/dev/stdout:/dev/stderr:/dev/null:/dev/tty:/dev/pts" - export SANDBOX_WRITE="${SANDBOX_WRITE}:/proc/self/attr:/proc/self/task:/selinux/context" - export SANDBOX_ON="1" - export SANDBOX_BASHRC="/dev/null" - unset BASH_ENV -fi - -shopt -s expand_aliases -shopt -s extglob - -case "${1}" in - specification) - gem specification "${2}" -v "${3}" - exit $? - ;; - - install) - gem install "${2}" -v "${3}" - exit $? - ;; - - uninstall) - gem uninstall "${2}" -v "${3}" -i -x - exit $? - ;; - - *) - echo "Unknown action ${1}" 1>&2 - exit 1 - ;; -esac diff --git a/paludis/repositories/gems/gems_repository.cc b/paludis/repositories/gems/gems_repository.cc deleted file mode 100644 index 7940957bc..000000000 --- a/paludis/repositories/gems/gems_repository.cc +++ /dev/null @@ -1,439 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2008, 2009, 2010 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/gems/gems_repository.hh> -#include <paludis/repositories/gems/params.hh> -#include <paludis/repositories/gems/yaml.hh> -#include <paludis/repositories/gems/gem_specification.hh> -#include <paludis/repositories/gems/gem_specifications.hh> -#include <paludis/repositories/gems/exceptions.hh> -#include <paludis/repositories/gems/extra_distribution_data.hh> -#include <paludis/util/stringify.hh> -#include <paludis/util/pimp-impl.hh> -#include <paludis/util/system.hh> -#include <paludis/util/set.hh> -#include <paludis/util/sequence.hh> -#include <paludis/util/mutex.hh> -#include <paludis/util/hashes.hh> -#include <paludis/util/make_named_values.hh> -#include <paludis/util/safe_ifstream.hh> -#include <paludis/util/make_null_shared_ptr.hh> -#include <paludis/action.hh> -#include <paludis/metadata_key.hh> -#include <paludis/literal_metadata_key.hh> -#include <paludis/distribution.hh> -#include <paludis/environment.hh> -#include <paludis/hook.hh> -#include <unordered_map> - -using namespace paludis; - -namespace paludis -{ - template <> - struct Imp<GemsRepository> - { - const gems::RepositoryParams params; - - const std::shared_ptr<Mutex> big_nasty_mutex; - - mutable std::shared_ptr<const CategoryNamePartSet> category_names; - mutable std::unordered_map<CategoryNamePart, std::shared_ptr<const QualifiedPackageNameSet>, Hash<CategoryNamePart> > package_names; - mutable std::unordered_map<QualifiedPackageName, std::shared_ptr<PackageIDSequence>, Hash<QualifiedPackageName> > ids; - - mutable bool has_category_names; - mutable bool has_ids; - - std::shared_ptr<const MetadataValueKey<FSPath> > location_key; - std::shared_ptr<const MetadataValueKey<FSPath> > install_dir_key; - std::shared_ptr<const MetadataValueKey<FSPath> > builddir_key; - std::shared_ptr<const MetadataValueKey<std::string> > sync_key; - std::shared_ptr<const MetadataValueKey<std::string> > sync_options_key; - std::shared_ptr<const MetadataValueKey<std::string> > format_key; - - Imp(const gems::RepositoryParams p, std::shared_ptr<Mutex> m = std::make_shared<Mutex>()) : - params(p), - big_nasty_mutex(m), - has_category_names(false), - has_ids(false), - location_key(std::make_shared<LiteralMetadataValueKey<FSPath> >("location", "location", - mkt_significant, params.location())), - install_dir_key(std::make_shared<LiteralMetadataValueKey<FSPath> >("install_dir", "install_dir", - mkt_normal, params.install_dir())), - builddir_key(std::make_shared<LiteralMetadataValueKey<FSPath> >("builddir", "builddir", - mkt_normal, params.builddir())), - sync_key(std::make_shared<LiteralMetadataValueKey<std::string> >("sync", "sync", - mkt_normal, params.sync())), - sync_options_key(std::make_shared<LiteralMetadataValueKey<std::string> >( - "sync_options", "sync_options", mkt_normal, params.sync_options())), - format_key(std::make_shared<LiteralMetadataValueKey<std::string> >("format", "format", - mkt_significant, "gems")) - { - } - }; -} - -GemsRepository::GemsRepository(const gems::RepositoryParams & params) : - Repository(params.environment(), RepositoryName("gems"), - make_named_values<RepositoryCapabilities>( - n::destination_interface() = static_cast<RepositoryDestinationInterface *>(0), - n::environment_variable_interface() = static_cast<RepositoryEnvironmentVariableInterface *>(0), - n::make_virtuals_interface() = static_cast<RepositoryMakeVirtualsInterface *>(0), - n::manifest_interface() = static_cast<RepositoryManifestInterface *>(0), - n::provides_interface() = static_cast<RepositoryProvidesInterface *>(0), - n::virtuals_interface() = static_cast<RepositoryVirtualsInterface *>(0) - )), - Pimp<GemsRepository>(params), - _imp(Pimp<GemsRepository>::_imp) -{ - _add_metadata_keys(); -} - -GemsRepository::~GemsRepository() -{ -} - -void -GemsRepository::_add_metadata_keys() const -{ - clear_metadata_keys(); - add_metadata_key(_imp->location_key); - add_metadata_key(_imp->install_dir_key); - add_metadata_key(_imp->builddir_key); - add_metadata_key(_imp->sync_key); - add_metadata_key(_imp->sync_options_key); - add_metadata_key(_imp->format_key); -} - -void -GemsRepository::invalidate() -{ - Lock l(*_imp->big_nasty_mutex); - - _imp.reset(new Imp<GemsRepository>(_imp->params, _imp->big_nasty_mutex)); - _add_metadata_keys(); -} - -void -GemsRepository::invalidate_masks() -{ - Lock l(*_imp->big_nasty_mutex); - - for (std::unordered_map<QualifiedPackageName, std::shared_ptr<PackageIDSequence>, Hash<QualifiedPackageName> >::iterator - it(_imp->ids.begin()), it_end(_imp->ids.end()); - it_end != it; ++it) - for (PackageIDSequence::ConstIterator it2(it->second->begin()), it2_end(it->second->end()); - it2_end != it2; ++it2) - (*it2)->invalidate_masks(); -} - -bool -GemsRepository::has_category_named(const CategoryNamePart & c) const -{ - Lock l(*_imp->big_nasty_mutex); - - need_category_names(); - return _imp->category_names->end() != _imp->category_names->find(c); -} - -bool -GemsRepository::has_package_named(const QualifiedPackageName & q) const -{ - Lock l(*_imp->big_nasty_mutex); - - if (! has_category_named(q.category())) - return false; - - need_ids(); - return _imp->package_names.find(q.category())->second->end() != _imp->package_names.find(q.category())->second->find(q); -} - -std::shared_ptr<const CategoryNamePartSet> -GemsRepository::category_names() const -{ - Lock l(*_imp->big_nasty_mutex); - - need_category_names(); - return _imp->category_names; -} - -std::shared_ptr<const QualifiedPackageNameSet> -GemsRepository::package_names(const CategoryNamePart & c) const -{ - Lock l(*_imp->big_nasty_mutex); - - if (! has_category_named(c)) - return std::make_shared<QualifiedPackageNameSet>(); - - need_ids(); - - std::unordered_map<CategoryNamePart, std::shared_ptr<const QualifiedPackageNameSet>, Hash<CategoryNamePart> >::const_iterator i( - _imp->package_names.find(c)); - if (i == _imp->package_names.end()) - return std::make_shared<QualifiedPackageNameSet>(); - return i->second; -} - -std::shared_ptr<const PackageIDSequence> -GemsRepository::package_ids(const QualifiedPackageName & q) const -{ - Lock l(*_imp->big_nasty_mutex); - - if (! has_package_named(q)) - return std::make_shared<PackageIDSequence>(); - - need_ids(); - - std::unordered_map<QualifiedPackageName, std::shared_ptr<PackageIDSequence>, Hash<QualifiedPackageName> >::const_iterator i( - _imp->ids.find(q)); - if (i == _imp->ids.end()) - return std::make_shared<PackageIDSequence>(); - - return i->second; -} - -void -GemsRepository::need_category_names() const -{ - Lock l(*_imp->big_nasty_mutex); - - if (_imp->has_category_names) - return; - - std::shared_ptr<CategoryNamePartSet> cat(std::make_shared<CategoryNamePartSet>()); - _imp->category_names = cat; - - cat->insert(CategoryNamePart("gems")); - _imp->has_category_names = true; -} - -void -GemsRepository::need_ids() const -{ - Lock l(*_imp->big_nasty_mutex); - - if (_imp->has_ids) - return; - - need_category_names(); - - std::shared_ptr<QualifiedPackageNameSet> pkgs(std::make_shared<QualifiedPackageNameSet>()); - _imp->package_names.insert(std::make_pair(CategoryNamePart("gems"), pkgs)); - - Context context("When loading gems yaml file:"); - - SafeIFStream yaml_file(_imp->params.location() / "yaml"); - - std::string output((std::istreambuf_iterator<char>(yaml_file)), std::istreambuf_iterator<char>()); - yaml::Document master_doc(output); - gems::GemSpecifications specs(_imp->params.environment(), shared_from_this(), *master_doc.top()); - - for (gems::GemSpecifications::ConstIterator i(specs.begin()), i_end(specs.end()) ; - i != i_end ; ++i) - { - pkgs->insert(i->first.first); - - std::unordered_map<QualifiedPackageName, std::shared_ptr<PackageIDSequence>, Hash<QualifiedPackageName> >::iterator - v(_imp->ids.find(i->first.first)); - if (_imp->ids.end() == v) - v = _imp->ids.insert(std::make_pair(i->first.first, std::make_shared<PackageIDSequence>())).first; - - v->second->push_back(i->second); - } - - _imp->has_ids = true; -} - -#if 0 -void -GemsRepository::do_install(const std::shared_ptr<const PackageID> & id, const InstallOptions & o) const -{ - if (o.fetch_only) - return; - - Command cmd(getenv_with_default("PALUDIS_GEMS_DIR", LIBEXECDIR "/paludis") + - "/gems/gems.bash install '" + stringify(id->name().package()) + "' '" + stringify(id->version()) + "'"); - cmd.with_stderr_prefix(stringify(*id) + "> "); - cmd.with_setenv("GEMCACHE", stringify(_imp->params.location / "yaml")); - - if (0 != run_command(cmd)) - throw PackageInstallActionError("Install of '" + stringify(*id) + "' failed"); -} -#endif - -namespace -{ - struct SupportsActionQuery - { - bool visit(const SupportsActionTest<InstallAction> &) const - { - return true; - } - - bool visit(const SupportsActionTest<FetchAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<PretendFetchAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<ConfigAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<PretendAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<InfoAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<UninstallAction> &) const - { - return false; - } - }; -} - -bool -GemsRepository::some_ids_might_support_action(const SupportsActionTestBase & a) const -{ - SupportsActionQuery q; - return a.accept_returning<bool>(q); -} - -bool -GemsRepository::some_ids_might_not_be_masked() const -{ - return true; -} - -const bool -GemsRepository::is_unimportant() const -{ - return false; -} - -void -GemsRepository::need_keys_added() const -{ -} - -const std::shared_ptr<const MetadataValueKey<std::string> > -GemsRepository::format_key() const -{ - return _imp->format_key; -} - -const std::shared_ptr<const MetadataValueKey<FSPath> > -GemsRepository::location_key() const -{ - return _imp->location_key; -} - -const std::shared_ptr<const MetadataValueKey<FSPath> > -GemsRepository::installed_root_key() const -{ - return std::shared_ptr<const MetadataValueKey<FSPath> >(); -} - -std::shared_ptr<Repository> -GemsRepository::repository_factory_create( - Environment * const env, - const std::function<std::string (const std::string &)> & f) -{ - std::string location(f("location")); - if (location.empty()) - throw gems::RepositoryConfigurationError("Key 'location' not specified or empty"); - - std::string install_dir(f("install_dir")); - if (install_dir.empty()) - throw gems::RepositoryConfigurationError("Key 'install_dir' not specified or empty"); - - std::string sync(f("sync")); - - std::string sync_options(f("sync_options")); - - std::string builddir(f("builddir")); - if (builddir.empty()) - builddir = gems::GemsExtraDistributionData::get_instance()->data_from_distribution( - *DistributionData::get_instance()->distribution_from_string(env->distribution()))->default_buildroot(); - - return std::make_shared<GemsRepository>(make_named_values<gems::RepositoryParams>( - n::builddir() = builddir, - n::environment() = env, - n::install_dir() = install_dir, - n::location() = location, - n::sync() = sync, - n::sync_options() = sync_options - )); -} - -RepositoryName -GemsRepository::repository_factory_name( - const Environment * const, - const std::function<std::string (const std::string &)> &) -{ - return RepositoryName("gems"); -} - -std::shared_ptr<const RepositoryNameSet> -GemsRepository::repository_factory_dependencies( - const Environment * const, - const std::function<std::string (const std::string &)> &) -{ - return std::make_shared<RepositoryNameSet>(); -} - -void -GemsRepository::populate_sets() const -{ -} - -HookResult -GemsRepository::perform_hook(const Hook &, const std::shared_ptr<OutputManager> &) -{ - return make_named_values<HookResult>(n::max_exit_status() = 0, n::output() = ""); -} - -bool -GemsRepository::sync(const std::shared_ptr<OutputManager> &) const -{ - return false; -} - -const std::shared_ptr<const MetadataValueKey<std::string> > -GemsRepository::accept_keywords_key() const -{ - return make_null_shared_ptr(); -} - -const std::shared_ptr<const MetadataValueKey<std::string> > -GemsRepository::sync_host_key() const -{ - return make_null_shared_ptr(); -} - diff --git a/paludis/repositories/gems/gems_repository.hh b/paludis/repositories/gems/gems_repository.hh deleted file mode 100644 index c387690c1..000000000 --- a/paludis/repositories/gems/gems_repository.hh +++ /dev/null @@ -1,129 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2008, 2009, 2010 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_GEMS_GEMS_REPOSITORY_HH -#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_GEMS_GEMS_REPOSITORY_HH 1 - -#include <paludis/repository.hh> -#include <paludis/repositories/gems/params-fwd.hh> -#include <paludis/util/pimp.hh> -#include <memory> - -namespace paludis -{ - /** - * Repository for Gem packages. - * - * \ingroup grpgemsrepository - * \nosubgrouping - */ - class PALUDIS_VISIBLE GemsRepository : - public Repository, - private Pimp<GemsRepository>, - public std::enable_shared_from_this<GemsRepository> - { - private: - Pimp<GemsRepository>::ImpPtr & _imp; - void _add_metadata_keys() const; - - void need_category_names() const; - void need_ids() const; - - protected: - virtual void need_keys_added() const; - - public: - /** - * Constructor. - */ - GemsRepository(const gems::RepositoryParams &); - - /** - * Destructor. - */ - ~GemsRepository(); - - virtual void invalidate(); - - virtual void invalidate_masks(); - - /* Repository */ - - virtual std::shared_ptr<const PackageIDSequence> package_ids( - const QualifiedPackageName &) const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual std::shared_ptr<const QualifiedPackageNameSet> package_names( - const CategoryNamePart &) const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual std::shared_ptr<const CategoryNamePartSet> category_names() const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual bool has_package_named(const QualifiedPackageName &) const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual bool has_category_named(const CategoryNamePart &) const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual bool some_ids_might_support_action(const SupportsActionTestBase &) const; - - virtual bool some_ids_might_not_be_masked() const; - - virtual const bool is_unimportant() const; - - virtual bool sync(const std::shared_ptr<OutputManager> &) const; - - /* Keys */ - - virtual const std::shared_ptr<const MetadataValueKey<std::string> > format_key() const; - virtual const std::shared_ptr<const MetadataValueKey<FSPath> > location_key() const; - virtual const std::shared_ptr<const MetadataValueKey<FSPath> > installed_root_key() const; - virtual const std::shared_ptr<const MetadataValueKey<std::string> > accept_keywords_key() const; - virtual const std::shared_ptr<const MetadataValueKey<std::string> > sync_host_key() const; - - ///\name RepositoryFactory functions - ///\{ - - static RepositoryName repository_factory_name( - const Environment * const env, - const std::function<std::string (const std::string &)> &); - - static std::shared_ptr<Repository> repository_factory_create( - Environment * const env, - const std::function<std::string (const std::string &)> &); - - static std::shared_ptr<const RepositoryNameSet> repository_factory_dependencies( - const Environment * const env, - const std::function<std::string (const std::string &)> &); - - ///\} - - ///\name Set methods - ///\{ - - virtual void populate_sets() const; - - ///\} - - virtual HookResult perform_hook(const Hook & hook, const std::shared_ptr<OutputManager> &); - }; -} - -#endif diff --git a/paludis/repositories/gems/gems_repository_TEST.cc b/paludis/repositories/gems/gems_repository_TEST.cc deleted file mode 100644 index 06b2c8416..000000000 --- a/paludis/repositories/gems/gems_repository_TEST.cc +++ /dev/null @@ -1,52 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2008, 2010 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/environments/test/test_environment.hh> -#include <paludis/repositories/gems/gems_repository.hh> -#include <paludis/repositories/gems/params.hh> -#include <paludis/package_database.hh> -#include <paludis/util/make_named_values.hh> -#include <test/test_framework.hh> -#include <test/test_runner.hh> - -using namespace test; -using namespace paludis; - -namespace test_cases -{ - struct CreationTest : TestCase - { - CreationTest() : TestCase("creation") { } - - void run() - { - TestEnvironment env; - env.package_database()->add_repository(1, std::make_shared<GemsRepository>( - make_named_values<gems::RepositoryParams>( - n::builddir() = FSPath("gems_repository_TEST_dir/build"), - n::environment() = &env, - n::install_dir() = FSPath("gems_repository_TEST_dir/install"), - n::location() = FSPath("gems_repository_TEST_dir/repo"), - n::sync() = "", - n::sync_options() = "" - ))); - } - } test_creation; -} - diff --git a/paludis/repositories/gems/gems_repository_TEST_cleanup.sh b/paludis/repositories/gems/gems_repository_TEST_cleanup.sh deleted file mode 100755 index 925666ca6..000000000 --- a/paludis/repositories/gems/gems_repository_TEST_cleanup.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -# vim: set ft=sh sw=4 sts=4 et : - -if [ -d gems_repository_TEST_dir ] ; then - rm -fr gems_repository_TEST_dir -else - true -fi - diff --git a/paludis/repositories/gems/gems_repository_TEST_setup.sh b/paludis/repositories/gems/gems_repository_TEST_setup.sh deleted file mode 100755 index b309e871a..000000000 --- a/paludis/repositories/gems/gems_repository_TEST_setup.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -# vim: set ft=sh sw=4 sts=4 et : - -mkdir gems_repository_TEST_dir || exit 1 -cd gems_repository_TEST_dir || exit 1 - diff --git a/paludis/repositories/gems/installed_gems_repository.cc b/paludis/repositories/gems/installed_gems_repository.cc deleted file mode 100644 index 350f87b54..000000000 --- a/paludis/repositories/gems/installed_gems_repository.cc +++ /dev/null @@ -1,457 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2008, 2009, 2010 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/gems/installed_gems_repository.hh> -#include <paludis/repositories/gems/params.hh> -#include <paludis/repositories/gems/gem_specification.hh> -#include <paludis/repositories/gems/yaml.hh> -#include <paludis/repositories/gems/exceptions.hh> -#include <paludis/repositories/gems/extra_distribution_data.hh> -#include <paludis/package_database.hh> -#include <paludis/environment.hh> -#include <paludis/util/stringify.hh> -#include <paludis/util/pimp-impl.hh> -#include <paludis/util/set.hh> -#include <paludis/util/sequence.hh> -#include <paludis/util/is_file_with_extension.hh> -#include <paludis/util/system.hh> -#include <paludis/util/mutex.hh> -#include <paludis/util/log.hh> -#include <paludis/util/strip.hh> -#include <paludis/util/hashes.hh> -#include <paludis/util/make_named_values.hh> -#include <paludis/util/make_null_shared_ptr.hh> -#include <paludis/util/fs_iterator.hh> -#include <paludis/literal_metadata_key.hh> -#include <paludis/distribution.hh> -#include <paludis/action.hh> -#include <paludis/generator.hh> -#include <paludis/filter.hh> -#include <paludis/filtered_generator.hh> -#include <paludis/selection.hh> -#include <paludis/hook.hh> -#include <paludis/common_sets.hh> -#include <unordered_map> - -using namespace paludis; - -typedef std::unordered_map<QualifiedPackageName, std::shared_ptr<PackageIDSequence>, Hash<QualifiedPackageName> > IDMap; - -namespace paludis -{ - template <> - struct Imp<InstalledGemsRepository> - { - const std::shared_ptr<Mutex> big_nasty_mutex; - - const gems::InstalledRepositoryParams params; - - mutable std::shared_ptr<const CategoryNamePartSet> category_names; - mutable std::unordered_map<CategoryNamePart, std::shared_ptr<const QualifiedPackageNameSet>, Hash<CategoryNamePart> > package_names; - mutable IDMap ids; - - mutable bool has_category_names; - mutable bool has_ids; - - std::shared_ptr<const MetadataValueKey<FSPath> > install_dir_key; - std::shared_ptr<const MetadataValueKey<FSPath> > builddir_key; - std::shared_ptr<const MetadataValueKey<FSPath> > root_key; - std::shared_ptr<const MetadataValueKey<std::string> > format_key; - - Imp(const gems::InstalledRepositoryParams p, - std::shared_ptr<Mutex> m = std::make_shared<Mutex>()) : - big_nasty_mutex(m), - params(p), - has_category_names(false), - has_ids(false), - install_dir_key(std::make_shared<LiteralMetadataValueKey<FSPath> >("install_dir", "install_dir", - mkt_normal, params.install_dir())), - builddir_key(std::make_shared<LiteralMetadataValueKey<FSPath> >("builddir", "builddir", - mkt_normal, params.builddir())), - root_key(std::make_shared<LiteralMetadataValueKey<FSPath> >( - "root", "root", mkt_normal, params.root())), - format_key(std::make_shared<LiteralMetadataValueKey<std::string> >("format", "format", - mkt_significant, "gems")) - { - } - }; -} - -InstalledGemsRepository::InstalledGemsRepository(const gems::InstalledRepositoryParams & params) : - Repository(params.environment(), - RepositoryName("installed-gems"), - make_named_values<RepositoryCapabilities>( - n::destination_interface() = this, - n::environment_variable_interface() = static_cast<RepositoryEnvironmentVariableInterface *>(0), - n::make_virtuals_interface() = static_cast<RepositoryMakeVirtualsInterface *>(0), - n::manifest_interface() = static_cast<RepositoryManifestInterface *>(0), - n::provides_interface() = static_cast<RepositoryProvidesInterface *>(0), - n::virtuals_interface() = static_cast<RepositoryVirtualsInterface *>(0) - )), - Pimp<InstalledGemsRepository>(params), - _imp(Pimp<InstalledGemsRepository>::_imp) -{ - _add_metadata_keys(); -} - -InstalledGemsRepository::~InstalledGemsRepository() -{ -} - -void -InstalledGemsRepository::_add_metadata_keys() const -{ - clear_metadata_keys(); - add_metadata_key(_imp->install_dir_key); - add_metadata_key(_imp->builddir_key); - add_metadata_key(_imp->format_key); - add_metadata_key(_imp->root_key); -} - -void -InstalledGemsRepository::invalidate() -{ - Lock l(*_imp->big_nasty_mutex); - _imp.reset(new Imp<InstalledGemsRepository>(_imp->params, _imp->big_nasty_mutex)); - _add_metadata_keys(); -} - -void -InstalledGemsRepository::invalidate_masks() -{ -} - -bool -InstalledGemsRepository::has_category_named(const CategoryNamePart & c) const -{ - Lock l(*_imp->big_nasty_mutex); - - need_category_names(); - return _imp->category_names->end() != _imp->category_names->find(c); -} - -bool -InstalledGemsRepository::has_package_named(const QualifiedPackageName & q) const -{ - Lock l(*_imp->big_nasty_mutex); - - if (! has_category_named(q.category())) - return false; - - need_ids(); - return _imp->package_names.find(q.category())->second->end() != _imp->package_names.find(q.category())->second->find(q); -} - -std::shared_ptr<const CategoryNamePartSet> -InstalledGemsRepository::category_names() const -{ - Lock l(*_imp->big_nasty_mutex); - - need_category_names(); - return _imp->category_names; -} - -std::shared_ptr<const QualifiedPackageNameSet> -InstalledGemsRepository::package_names(const CategoryNamePart & c) const -{ - Lock l(*_imp->big_nasty_mutex); - - if (! has_category_named(c)) - return std::make_shared<QualifiedPackageNameSet>(); - - need_ids(); - - std::unordered_map<CategoryNamePart, std::shared_ptr<const QualifiedPackageNameSet>, Hash<CategoryNamePart> >::const_iterator i( - _imp->package_names.find(c)); - if (i == _imp->package_names.end()) - return std::make_shared<QualifiedPackageNameSet>(); - return i->second; -} - -std::shared_ptr<const PackageIDSequence> -InstalledGemsRepository::package_ids(const QualifiedPackageName & q) const -{ - Lock l(*_imp->big_nasty_mutex); - - if (! has_package_named(q)) - return std::make_shared<PackageIDSequence>(); - - need_ids(); - - IDMap::const_iterator i(_imp->ids.find(q)); - if (i == _imp->ids.end()) - return std::make_shared<PackageIDSequence>(); - - return i->second; -} - -void -InstalledGemsRepository::need_category_names() const -{ - Lock l(*_imp->big_nasty_mutex); - - if (_imp->has_category_names) - return; - - std::shared_ptr<CategoryNamePartSet> cat(std::make_shared<CategoryNamePartSet>()); - _imp->category_names = cat; - - cat->insert(CategoryNamePart("gems")); - _imp->has_category_names = true; -} - -void -InstalledGemsRepository::need_ids() const -{ - Lock l(*_imp->big_nasty_mutex); - - if (_imp->has_ids) - return; - - static CategoryNamePart gems("gems"); - - Context c("When loading entries for repository '" + stringify(name()) + "':"); - - need_category_names(); - - std::shared_ptr<QualifiedPackageNameSet> pkgs(std::make_shared<QualifiedPackageNameSet>()); - _imp->package_names.insert(std::make_pair(gems, pkgs)); - - for (FSIterator d(_imp->params.install_dir() / "specifications", { }), d_end ; d != d_end ; ++d) - { - if (! is_file_with_extension(*d, ".gemspec", { })) - continue; - - std::string s(strip_trailing_string(d->basename(), ".gemspec")); - std::string::size_type h(s.rfind('-')); - if (std::string::npos == h) - { - Log::get_instance()->message("gems.id.unrecognised", ll_qa, lc_context) << "Unrecognised file name format '" - << *d << "' (no hyphen)"; - continue; - } - - VersionSpec v(s.substr(h + 1), { }); - PackageNamePart p(s.substr(0, h)); - pkgs->insert(gems + p); - - if (_imp->ids.end() == _imp->ids.find(gems + p)) - _imp->ids.insert(std::make_pair(gems + p, std::make_shared<PackageIDSequence>())); - _imp->ids.find(gems + p)->second->push_back(std::make_shared<gems::GemSpecification>( - _imp->params.environment(), shared_from_this(), p, v, *d)); - } -} - -bool -InstalledGemsRepository::is_suitable_destination_for(const PackageID & e) const -{ - Lock l(*_imp->big_nasty_mutex); - - std::string f(e.repository()->format_key() ? e.repository()->format_key()->value() : ""); - return f == "gems"; -} - -bool -InstalledGemsRepository::is_default_destination() const -{ - return true; -} - -bool -InstalledGemsRepository::want_pre_post_phases() const -{ - return true; -} - -void -InstalledGemsRepository::merge(const MergeParams &) -{ - throw InternalError(PALUDIS_HERE, "Invalid target for merge"); -} - -#if 0 -void -InstalledGemsRepository::do_uninstall(const std::shared_ptr<const PackageID> & id, - const UninstallOptions &) const -{ - Command cmd(getenv_with_default("PALUDIS_GEMS_DIR", LIBEXECDIR "/paludis") + - "/gems/gems.bash uninstall '" + stringify(id->name().package()) + "' '" + stringify(id->version()) + "'"); - cmd.with_stderr_prefix(stringify(*id) + "> "); - cmd.with_setenv("GEM_HOME", stringify(_imp->params.install_dir)); - - if (0 != run_command(cmd)) - throw PackageInstallActionError("Uninstall of '" + stringify(*id) + "' failed"); -} -#endif - -namespace -{ - struct SupportsActionQuery - { - bool visit(const SupportsActionTest<InstallAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<ConfigAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<PretendAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<FetchAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<PretendFetchAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<InfoAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<UninstallAction> &) const - { - return true; - } - }; -} - -bool -InstalledGemsRepository::some_ids_might_support_action(const SupportsActionTestBase & a) const -{ - SupportsActionQuery q; - return a.accept_returning<bool>(q); -} - -bool -InstalledGemsRepository::some_ids_might_not_be_masked() const -{ - return true; -} - -const bool -InstalledGemsRepository::is_unimportant() const -{ - return false; -} - -void -InstalledGemsRepository::need_keys_added() const -{ -} - -const std::shared_ptr<const MetadataValueKey<std::string> > -InstalledGemsRepository::format_key() const -{ - return _imp->format_key; -} - -const std::shared_ptr<const MetadataValueKey<FSPath> > -InstalledGemsRepository::location_key() const -{ - return _imp->install_dir_key; -} - -const std::shared_ptr<const MetadataValueKey<FSPath> > -InstalledGemsRepository::installed_root_key() const -{ - return _imp->root_key; -} - -RepositoryName -InstalledGemsRepository::repository_factory_name( - const Environment * const, - const std::function<std::string (const std::string &)> &) -{ - return RepositoryName("installed-gems"); -} - -std::shared_ptr<const RepositoryNameSet> -InstalledGemsRepository::repository_factory_dependencies( - const Environment * const, - const std::function<std::string (const std::string &)> &) -{ - return std::make_shared<RepositoryNameSet>(); -} - -std::shared_ptr<Repository> -InstalledGemsRepository::repository_factory_create( - Environment * const env, - const std::function<std::string (const std::string &)> & f) -{ - std::string install_dir(f("install_dir")); - if (install_dir.empty()) - throw gems::RepositoryConfigurationError("Key 'install_dir' not specified or empty"); - - std::string builddir(f("builddir")); - if (builddir.empty()) - builddir = gems::GemsExtraDistributionData::get_instance()->data_from_distribution( - *DistributionData::get_instance()->distribution_from_string(env->distribution()))->default_buildroot(); - - std::string root(f("root")); - if (root.empty()) - root = "/"; - - return std::make_shared<InstalledGemsRepository>(make_named_values<gems::InstalledRepositoryParams>( - n::builddir() = builddir, - n::environment() = env, - n::install_dir() = install_dir, - n::root() = root - )); -} - -void -InstalledGemsRepository::populate_sets() const -{ - add_common_sets_for_installed_repo(_imp->params.environment(), *this); -} - -HookResult -InstalledGemsRepository::perform_hook(const Hook &, const std::shared_ptr<OutputManager> &) -{ - return make_named_values<HookResult>(n::max_exit_status() = 0, n::output() = ""); -} - -bool -InstalledGemsRepository::sync(const std::shared_ptr<OutputManager> &) const -{ - return false; -} - -const std::shared_ptr<const MetadataValueKey<std::string> > -InstalledGemsRepository::accept_keywords_key() const -{ - return make_null_shared_ptr(); -} - -const std::shared_ptr<const MetadataValueKey<std::string> > -InstalledGemsRepository::sync_host_key() const -{ - return make_null_shared_ptr(); -} - diff --git a/paludis/repositories/gems/installed_gems_repository.hh b/paludis/repositories/gems/installed_gems_repository.hh deleted file mode 100644 index 48999885e..000000000 --- a/paludis/repositories/gems/installed_gems_repository.hh +++ /dev/null @@ -1,146 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2008, 2009, 2010 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_GEMS_INSTALLED_GEMS_REPOSITORY_HH -#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_GEMS_INSTALLED_GEMS_REPOSITORY_HH 1 - -#include <paludis/repository.hh> -#include <paludis/repositories/gems/params-fwd.hh> -#include <paludis/util/pimp.hh> -#include <memory> - -namespace paludis -{ - /** - * Repository for installed Gem packages. - * - * \ingroup grpgemsrepository - * \nosubgrouping - */ - class PALUDIS_VISIBLE InstalledGemsRepository : - public Repository, - public RepositoryDestinationInterface, - public std::enable_shared_from_this<InstalledGemsRepository>, - private Pimp<InstalledGemsRepository> - { - private: - Pimp<InstalledGemsRepository>::ImpPtr & _imp; - void _add_metadata_keys() const; - - void need_category_names() const; - void need_ids() const; - - protected: - virtual void need_keys_added() const; - - public: - /** - * Constructor. - */ - InstalledGemsRepository(const gems::InstalledRepositoryParams &); - - /** - * Destructor. - */ - ~InstalledGemsRepository(); - - virtual void invalidate(); - - virtual void invalidate_masks(); - - /* RepositoryDestinationInterface */ - - virtual bool is_suitable_destination_for(const PackageID &) const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual bool is_default_destination() const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual bool want_pre_post_phases() const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual void merge(const MergeParams &) PALUDIS_ATTRIBUTE((noreturn)); - - public: - /* Repository */ - - virtual std::shared_ptr<const PackageIDSequence> package_ids( - const QualifiedPackageName &) const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual std::shared_ptr<const QualifiedPackageNameSet> package_names( - const CategoryNamePart &) const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual std::shared_ptr<const CategoryNamePartSet> category_names() const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual bool has_package_named(const QualifiedPackageName &) const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual bool has_category_named(const CategoryNamePart &) const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual bool some_ids_might_support_action(const SupportsActionTestBase &) const; - - virtual bool some_ids_might_not_be_masked() const; - - virtual const bool is_unimportant() const; - - virtual bool sync(const std::shared_ptr<OutputManager> &) const; - - /* Keys */ - - virtual const std::shared_ptr<const MetadataValueKey<std::string> > format_key() const; - virtual const std::shared_ptr<const MetadataValueKey<FSPath> > location_key() const; - virtual const std::shared_ptr<const MetadataValueKey<FSPath> > installed_root_key() const; - virtual const std::shared_ptr<const MetadataValueKey<std::string> > accept_keywords_key() const; - virtual const std::shared_ptr<const MetadataValueKey<std::string> > sync_host_key() const; - - ///\name RepositoryFactory functions - ///\{ - - static RepositoryName repository_factory_name( - const Environment * const env, - const std::function<std::string (const std::string &)> &); - - static std::shared_ptr<Repository> repository_factory_create( - Environment * const env, - const std::function<std::string (const std::string &)> &); - - static std::shared_ptr<const RepositoryNameSet> repository_factory_dependencies( - const Environment * const env, - const std::function<std::string (const std::string &)> &); - - ///\} - - ///\name Set methods - ///\{ - - virtual void populate_sets() const; - - ///\} - - virtual HookResult perform_hook(const Hook & hook, const std::shared_ptr<OutputManager> &) - PALUDIS_ATTRIBUTE((warn_unused_result)); - }; -} - - -#endif diff --git a/paludis/repositories/gems/installed_gems_repository_TEST.cc b/paludis/repositories/gems/installed_gems_repository_TEST.cc deleted file mode 100644 index 0e81a2158..000000000 --- a/paludis/repositories/gems/installed_gems_repository_TEST.cc +++ /dev/null @@ -1,50 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2010 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/environments/test/test_environment.hh> -#include <paludis/repositories/gems/gems_repository.hh> -#include <paludis/repositories/gems/params.hh> -#include <paludis/package_database.hh> -#include <paludis/util/make_shared_ptr.hh> -#include <test/test_framework.hh> -#include <test/test_runner.hh> - -using namespace test; -using namespace paludis; - -namespace test_cases -{ - struct CreationTest : TestCase - { - CreationTest() : TestCase("creation") { } - - void run() - { - TestEnvironment env; - env.package_database()->add_repository(1, make_shared_ptr(std::make_shared<InstalledGemsRepository>( - gems::InstalledRepositoryParams::create() - .location(FSEntry("gems_repository_TEST_dir/installed-repo")) - .environment(&env) - .builddir(FSEntry("gems_repository_TEST_dir/build")) - .install_dir(FSEntry("gems_repository_TEST_dir/install_dir")) - ))); - } - } test_creation; -} - diff --git a/paludis/repositories/gems/installed_gems_repository_TEST_cleanup.sh b/paludis/repositories/gems/installed_gems_repository_TEST_cleanup.sh deleted file mode 100755 index 8b7590043..000000000 --- a/paludis/repositories/gems/installed_gems_repository_TEST_cleanup.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -# vim: set ft=sh sw=4 sts=4 et : - -if [ -d installed_gems_repository_TEST_dir ] ; then - rm -fr installed_gems_repository_TEST_dir -else - true -fi - diff --git a/paludis/repositories/gems/installed_gems_repository_TEST_setup.sh b/paludis/repositories/gems/installed_gems_repository_TEST_setup.sh deleted file mode 100755 index a99ca927f..000000000 --- a/paludis/repositories/gems/installed_gems_repository_TEST_setup.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -# vim: set ft=sh sw=4 sts=4 et : - -mkdir installed_gems_repository_TEST_dir || exit 1 -cd installed_gems_repository_TEST_dir || exit 1 - -mkdir -p installed-repo/installed_dir/specifications -cat <<END > installed-repo/yaml -END - diff --git a/paludis/repositories/gems/params-fwd.hh b/paludis/repositories/gems/params-fwd.hh deleted file mode 100644 index 4ee302671..000000000 --- a/paludis/repositories/gems/params-fwd.hh +++ /dev/null @@ -1,32 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007 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_GEMS_PARAMS_FWD_HH -#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_GEMS_PARAMS_FWD_HH 1 - -namespace paludis -{ - namespace gems - { - class RepositoryParams; - class InstalledRepositoryParams; - } -} - -#endif diff --git a/paludis/repositories/gems/params.cc b/paludis/repositories/gems/params.cc deleted file mode 100644 index df89864ff..000000000 --- a/paludis/repositories/gems/params.cc +++ /dev/null @@ -1,24 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * 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 - * 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 "params.hh" - -using namespace paludis; -using namespace paludis::gems; - diff --git a/paludis/repositories/gems/params.hh b/paludis/repositories/gems/params.hh deleted file mode 100644 index fb49f79b3..000000000 --- a/paludis/repositories/gems/params.hh +++ /dev/null @@ -1,66 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2008, 2010 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_GEMS_PARAMS_HH -#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_GEMS_PARAMS_HH 1 - -#include <paludis/repositories/gems/params-fwd.hh> -#include <paludis/util/attributes.hh> -#include <paludis/util/fs_path.hh> -#include <paludis/util/named_value.hh> -#include <string> - -namespace paludis -{ - class Environment; - - namespace n - { - typedef Name<struct builddir_name> builddir; - typedef Name<struct environment_name> environment; - typedef Name<struct install_dir_name> install_dir; - typedef Name<struct location_name> location; - typedef Name<struct root_name> root; - typedef Name<struct sync_name> sync; - typedef Name<struct sync_options_name> sync_options; - } - - namespace gems - { - struct RepositoryParams - { - NamedValue<n::builddir, FSPath> builddir; - NamedValue<n::environment, Environment *> environment; - NamedValue<n::install_dir, FSPath> install_dir; - NamedValue<n::location, FSPath> location; - NamedValue<n::sync, std::string> sync; - NamedValue<n::sync_options, std::string> sync_options; - }; - - struct InstalledRepositoryParams - { - NamedValue<n::builddir, FSPath> builddir; - NamedValue<n::environment, Environment *> environment; - NamedValue<n::install_dir, FSPath> install_dir; - NamedValue<n::root, FSPath> root; - }; - } -} - -#endif diff --git a/paludis/repositories/gems/registration.cc b/paludis/repositories/gems/registration.cc deleted file mode 100644 index d502d46b0..000000000 --- a/paludis/repositories/gems/registration.cc +++ /dev/null @@ -1,80 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2008, 2009, 2010 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/repository_factory.hh> -#include <paludis/repositories/gems/gems_repository.hh> -#include <paludis/repositories/gems/installed_gems_repository.hh> -#include <paludis/repositories/gems/params.hh> -#include <paludis/repositories/gems/exceptions.hh> -#include <paludis/util/set.hh> -#include <paludis/util/wrapped_forward_iterator.hh> -#include <paludis/util/destringify.hh> -#include <paludis/distribution.hh> -#include <paludis/environment.hh> -#include "config.h" - -using namespace paludis; - -namespace -{ - int generic_importance(const Environment * const, const std::function<std::string (const std::string &)> & f) - { - if (! f("importance").empty()) - return destringify<int>(f("importance")); - else - return 1; - } -} - -namespace paludis -{ - namespace repository_groups - { - REPOSITORY_GROUPS_DECLS; - } - - template <> - void register_repositories<repository_groups::gems>(const repository_groups::gems * const, - RepositoryFactory * const factory) - { - std::shared_ptr<Set<std::string> > gems_formats(std::make_shared<Set<std::string>>()); - gems_formats->insert("gems"); - - factory->add_repository_format( - gems_formats, - GemsRepository::repository_factory_name, - &generic_importance, - GemsRepository::repository_factory_create, - GemsRepository::repository_factory_dependencies - ); - - std::shared_ptr<Set<std::string> > installed_gems_formats(std::make_shared<Set<std::string>>()); - installed_gems_formats->insert("installed_gems"); - installed_gems_formats->insert("installed-gems"); - - factory->add_repository_format( - installed_gems_formats, - InstalledGemsRepository::repository_factory_name, - &generic_importance, - InstalledGemsRepository::repository_factory_create, - InstalledGemsRepository::repository_factory_dependencies - ); - } -} - diff --git a/paludis/repositories/gems/yaml-fwd.hh b/paludis/repositories/gems/yaml-fwd.hh deleted file mode 100644 index b55c56637..000000000 --- a/paludis/repositories/gems/yaml-fwd.hh +++ /dev/null @@ -1,37 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * 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 - * 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_GEMS_YAML_FWD_HH -#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_GEMS_YAML_FWD_HH 1 - -namespace paludis -{ - namespace yaml - { - class Node; - class StringNode; - class SequenceNode; - class MapNode; - class Document; - class NodeManager; - class ParseError; - } -} - -#endif diff --git a/paludis/repositories/gems/yaml.cc b/paludis/repositories/gems/yaml.cc deleted file mode 100644 index d4f28271a..000000000 --- a/paludis/repositories/gems/yaml.cc +++ /dev/null @@ -1,404 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2008, 2009, 2010 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 "yaml.hh" -#include <paludis/util/pimp-impl.hh> -#include <paludis/util/singleton-impl.hh> -#include <paludis/util/wrapped_forward_iterator-impl.hh> -#include <functional> -#include <syck.h> -#include <cstring> -#include <algorithm> -#include <map> -#include <list> - -using namespace paludis; -using namespace paludis::yaml; - -Node::~Node() -{ -} - -namespace paludis -{ - template <> - struct Imp<StringNode> - { - const std::string text; - - Imp(const std::string & t) : - text(t) - { - } - }; - - template <> - struct WrappedForwardIteratorTraits<MapNode::ConstIteratorTag> - { - typedef std::list<std::pair<const Node *, const Node *> >::const_iterator UnderlyingIterator; - }; - - template <> - struct WrappedForwardIteratorTraits<SequenceNode::ConstIteratorTag> - { - typedef std::list<const Node *>::const_iterator UnderlyingIterator; - }; -} - -StringNode::StringNode(const std::string & t) : - Pimp<StringNode>(t) -{ -} - -StringNode::~StringNode() -{ -} - -std::string -StringNode::text() const -{ - return _imp->text; -} - -namespace paludis -{ - template <> - struct Imp<SequenceNode> - { - std::list<const Node *> nodes; - }; -} - -SequenceNode::SequenceNode() : - Pimp<SequenceNode>() -{ -} - -SequenceNode::~SequenceNode() -{ -} - -void -SequenceNode::push_back(const Node * const n) -{ - _imp->nodes.push_back(n); -} - -SequenceNode::ConstIterator -SequenceNode::begin() const -{ - return ConstIterator(_imp->nodes.begin()); -} - -SequenceNode::ConstIterator -SequenceNode::end() const -{ - return ConstIterator(_imp->nodes.end()); -} - -namespace paludis -{ - template <> - struct Imp<MapNode> - { - std::list<std::pair<const Node *, const Node *> > nodes; - }; -} - -MapNode::MapNode() : - Pimp<MapNode>() -{ -} - -MapNode::~MapNode() -{ -} - -void -MapNode::push_back(const std::pair<const Node *, const Node *> & p) -{ - _imp->nodes.push_back(p); -} - -MapNode::ConstIterator -MapNode::begin() const -{ - return ConstIterator(_imp->nodes.begin()); -} - -MapNode::ConstIterator -MapNode::end() const -{ - return ConstIterator(_imp->nodes.end()); -} - -namespace -{ - struct MatchStringVisitor - { - bool found; - const std::string target; - - MatchStringVisitor(const std::string & s) : - found(false), - target(s) - { - } - - void visit(const StringNode & n) - { - found = n.text() == target; - } - - void visit(const MapNode &) - { - } - - void visit(const SequenceNode &) - { - } - }; - - bool match_string_node(const std::string & s, const Node * const n) - { - MatchStringVisitor v(s); - n->accept(v); - return v.found; - } -} - -MapNode::ConstIterator -MapNode::find(const std::string & s) const -{ - using namespace std::placeholders; - return std::find_if(begin(), end(), - std::bind(match_string_node, s, std::bind<const Node *>(std::mem_fn(&std::pair<const Node *, const Node *>::first), _1))); -} - -namespace -{ - static Mutex document_error_table_mutex; - static std::map<void *, std::string> document_error_table; - - template <typename R_, typename T_> - struct CallUnlessNull - { - R_ (* function) (T_ *); - - CallUnlessNull(R_ (*f) (T_ *)) : - function(f) - { - } - - void operator() (T_ * const t) const - { - if (t) - function(t); - } - }; - - template <typename R_, typename T_> - CallUnlessNull<R_, T_> - call_unless_null(R_ (* f) (T_ *)) - { - return CallUnlessNull<R_, T_>(f); - } - - SYMID node_handler(SyckParser * p, SyckNode * n) - { - Node * node(0); - - switch (n->kind) - { - case syck_str_kind: - { - node = new StringNode(std::string(n->data.str->ptr, n->data.str->len)); - NodeManager::get_instance()->manage_node(p, node); - } - break; - - case syck_seq_kind: - { - SequenceNode * s(new SequenceNode); - NodeManager::get_instance()->manage_node(p, s); - for (int i = 0 ; i < n->data.list->idx ; ++i) - { - SYMID v_id(syck_seq_read(n, i)); - char * v(0); - syck_lookup_sym(p, v_id, &v); - s->push_back(reinterpret_cast<Node *>(v)); - } - node = s; - } - break; - - case syck_map_kind: - { - MapNode * m(new MapNode); - NodeManager::get_instance()->manage_node(p, m); - for (int i = 0 ; i < n->data.pairs->idx ; ++i) - { - SYMID k_id(syck_map_read(n, map_key, i)), v_id(syck_map_read(n, map_value, i)); - char * k(0), * v(0); - syck_lookup_sym(p, k_id, &k); - syck_lookup_sym(p, v_id, &v); - m->push_back(std::make_pair(reinterpret_cast<Node *>(k), reinterpret_cast<Node *>(v))); - } - node = m; - } - break; - } - - return syck_add_sym(p, reinterpret_cast<char *>(node)); - } - - void error_handler(SyckParser * p, char * s) - { - Lock l(document_error_table_mutex); - document_error_table[p] = s; - } -} - -namespace paludis -{ - template <> - struct Imp<Document> - { - struct Register - { - Imp<Document> * _imp; - - Register(Imp<Document> * imp) : - _imp(imp) - { - NodeManager::get_instance()->register_document(_imp->parser.get()); - } - - ~Register() - { - NodeManager::get_instance()->deregister_document(_imp->parser.get()); - } - }; - - Node * top; - std::shared_ptr<SyckParser> parser; - std::shared_ptr<char> data; - unsigned data_length; - - Register reg; - - Imp(const std::string & s) : - top(0), - parser(syck_new_parser(), call_unless_null(syck_free_parser)), - data(strdup(s.c_str()), call_unless_null(std::free)), - data_length(s.length()), - reg(this) - { - } - }; -} - -Document::Document(const std::string & s) : - Pimp<Document>(s) -{ - Context c("When parsing yaml document:"); - - syck_parser_str(_imp->parser.get(), _imp->data.get(), _imp->data_length, 0); - syck_parser_handler(_imp->parser.get(), node_handler); - syck_parser_error_handler(_imp->parser.get(), error_handler); - - SYMID root_id(syck_parse(_imp->parser.get())); - - { - Lock l(document_error_table_mutex); - if (document_error_table.end() != document_error_table.find(_imp->parser.get())) - { - std::string e(document_error_table.find(_imp->parser.get())->second); - document_error_table.erase(_imp->parser.get()); - throw ParseError(e); - } - } - - char * root_uncasted(0); - syck_lookup_sym(_imp->parser.get(), root_id, &root_uncasted); - _imp->top = reinterpret_cast<Node *>(root_uncasted); -} - -Document::~Document() -{ -} - -const Node * -Document::top() const -{ - return _imp->top; -} - -namespace paludis -{ - template <> - struct Imp<NodeManager> - { - std::map<const void *, std::list<std::shared_ptr<const Node> > > store; - }; -} - -NodeManager::NodeManager() : - Pimp<NodeManager>() -{ -} - -NodeManager::~NodeManager() -{ -} - -void -NodeManager::register_document(const void * const d) -{ - if (! _imp->store.insert(std::make_pair(d, std::list<std::shared_ptr<const Node> >())).second) - throw InternalError(PALUDIS_HERE, "duplicate document"); -} - -void -NodeManager::deregister_document(const void * const d) -{ - if (0 == _imp->store.erase(d)) - throw InternalError(PALUDIS_HERE, "no such document"); -} - -void -NodeManager::manage_node(const void * const d, const Node * const n) -{ - std::map<const void *, std::list<std::shared_ptr<const Node> > >::iterator i(_imp->store.find(d)); - if (i == _imp->store.end()) - throw InternalError(PALUDIS_HERE, "no such document"); - i->second.push_back(std::shared_ptr<const Node>(n)); -} - -ParseError::ParseError(const std::string & s) throw () : - Exception(s) -{ -} - -template class Singleton<NodeManager>; - -template class WrappedForwardIterator<MapNode::ConstIteratorTag, const std::pair<const Node *, const Node *> >; -template class WrappedForwardIterator<SequenceNode::ConstIteratorTag, const Node * const>; - - diff --git a/paludis/repositories/gems/yaml.hh b/paludis/repositories/gems/yaml.hh deleted file mode 100644 index c36f6b9ef..000000000 --- a/paludis/repositories/gems/yaml.hh +++ /dev/null @@ -1,242 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2008, 2009, 2010 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_GEMS_YAML_HH -#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_GEMS_YAML_HH 1 - -#include <paludis/repositories/gems/yaml-fwd.hh> -#include <paludis/util/simple_visitor.hh> -#include <paludis/util/attributes.hh> -#include <paludis/util/singleton.hh> -#include <paludis/util/pimp.hh> -#include <paludis/util/exception.hh> -#include <paludis/util/type_list.hh> -#include <paludis/util/wrapped_forward_iterator.hh> - -namespace paludis -{ - namespace yaml - { - class Node; - class StringNode; - class SequenceNode; - class MapNode; - - /** - * A node in a yaml document. - * - * \ingroup grpgemsrepository - * \nosubgrouping - */ - class PALUDIS_VISIBLE Node : - public virtual DeclareAbstractAcceptMethods<Node, MakeTypeList< - StringNode, SequenceNode, MapNode>::Type> - { - public: - ///\name Basic operations - ///\{ - - virtual ~Node() = 0; - - ///\} - }; - - /** - * A string node in a yaml document. - * - * \ingroup grpgemsrepository - * \nosubgrouping - */ - class PALUDIS_VISIBLE StringNode : - public Node, - public ImplementAcceptMethods<Node, StringNode>, - private Pimp<StringNode> - { - public: - ///\name Basic operations - ///\{ - - StringNode(const std::string &); - ~StringNode(); - - ///\} - - /** - * The node's raw text. - */ - std::string text() const PALUDIS_ATTRIBUTE((warn_unused_result)); - }; - - /** - * A sequence node in a yaml document. - * - * \ingroup grpgemsrepository - * \nosubgrouping - */ - class PALUDIS_VISIBLE SequenceNode : - public Node, - public ImplementAcceptMethods<Node, SequenceNode>, - private Pimp<SequenceNode> - { - public: - ///\name Basic operations - ///\{ - - SequenceNode(); - ~SequenceNode(); - - ///\} - - /** - * Add a child node. - */ - void push_back(const Node * const); - - ///\name Iterate over our child nodes. - ///\{ - - struct ConstIteratorTag; - typedef WrappedForwardIterator<ConstIteratorTag, const Node * const> ConstIterator; - ConstIterator begin() const PALUDIS_ATTRIBUTE((warn_unused_result)); - ConstIterator end() const PALUDIS_ATTRIBUTE((warn_unused_result)); - - ///\} - }; - - /** - * A mapping node in a yaml document. - * - * \ingroup grpgemsrepository - * \nosubgrouping - */ - class PALUDIS_VISIBLE MapNode : - public Node, - public ImplementAcceptMethods<Node, MapNode>, - private Pimp<MapNode> - { - public: - ///\name Basic operations - ///\{ - - MapNode(); - ~MapNode(); - - ///\} - - /** - * Add a child node pair. - */ - void push_back(const std::pair<const Node *, const Node *> &); - - ///\name Iterate over and find our child nodes. - ///\{ - - struct ConstIteratorTag; - typedef WrappedForwardIterator<ConstIteratorTag, const std::pair<const Node *, const Node *> > ConstIterator; - ConstIterator begin() const PALUDIS_ATTRIBUTE((warn_unused_result)); - ConstIterator end() const PALUDIS_ATTRIBUTE((warn_unused_result)); - ConstIterator find(const std::string &) const PALUDIS_ATTRIBUTE((warn_unused_result)); - - ///\} - }; - - /** - * A yaml document. - * - * \ingroup grpgemsrepository - * \nosubgrouping - */ - class PALUDIS_VISIBLE Document : - private Pimp<Document> - { - public: - ///\name Basic operations - ///\{ - - Document(const std::string &); - ~Document(); - - ///\} - - /** - * The top node in our document. - */ - const Node * top() const PALUDIS_ATTRIBUTE((warn_unused_result)); - }; - - /** - * Handles memory management for yaml nodes, since syck assumes garbage - * collection. - * - * \ingroup grpgemsrepository - * \nosubgrouping - */ - class PALUDIS_VISIBLE NodeManager : - private Pimp<NodeManager>, - public Singleton<NodeManager> - { - friend class Singleton<NodeManager>; - - private: - ///\name Basic operations - ///\{ - - NodeManager(); - ~NodeManager(); - - ///\} - - public: - ///\name Memory management operations - ///\{ - - void register_document(const void * const); - void deregister_document(const void * const); - - void manage_node(const void * const, const Node * const); - - ///\} - }; - - /** - * Thrown if a yaml document cannot be parsed. - * - * \ingroup grpgemsrepository - * \ingroup grpexceptions - * \nosubgrouping - */ - class PALUDIS_VISIBLE ParseError : - public Exception - { - public: - ///\name Basic operations - ///\{ - - ParseError(const std::string &) throw (); - - ///\} - }; - } - - extern template class WrappedForwardIterator<yaml::MapNode::ConstIteratorTag, const std::pair<const yaml::Node *, const yaml::Node *> >; - extern template class WrappedForwardIterator<yaml::SequenceNode::ConstIteratorTag, const yaml::Node * const>; - -} - -#endif diff --git a/paludis/repositories/gems/yaml_TEST.cc b/paludis/repositories/gems/yaml_TEST.cc deleted file mode 100644 index 25c98ce73..000000000 --- a/paludis/repositories/gems/yaml_TEST.cc +++ /dev/null @@ -1,182 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2008, 2009 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 <test/test_runner.hh> -#include <test/test_framework.hh> -#include <paludis/repositories/gems/yaml.hh> -#include <algorithm> -#include <sstream> - -using namespace test; -using namespace paludis; -using namespace paludis::yaml; - -namespace -{ - struct CountedStringNode : - StringNode - { - static unsigned alloc_count; - - void * operator new (const std::size_t sz) throw (std::bad_alloc) - { - ++alloc_count; - return ::operator new (sz); - } - - void operator delete (void * n) throw () - { - --alloc_count; - ::operator delete (n); - } - - CountedStringNode() : - StringNode("x") - { - } - }; - - unsigned CountedStringNode::alloc_count(0); - - struct FakeDocument - { - FakeDocument() - { - NodeManager::get_instance()->register_document(this); - } - - ~FakeDocument() - { - NodeManager::get_instance()->deregister_document(this); - } - }; - - struct Dumper - { - std::stringstream s; - - void visit(const StringNode & n) - { - s << "str(" << n.text() << ")"; - } - - void visit(const MapNode & n) - { - s << "map("; - bool w(false); - for (MapNode::ConstIterator i(n.begin()), i_end(n.end()) ; i != i_end ; ++i) - { - if (w) - s << ", "; - - i->first->accept(*this); - s << " -> "; - i->second->accept(*this); - w = true; - } - s << ")"; - } - - void visit(const SequenceNode & n) - { - s << "seq("; - bool w(false); - for (SequenceNode::ConstIterator i(n.begin()), i_end(n.end()) ; i != i_end ; ++i) - { - if (w) - s << ", "; - (*i)->accept(*this); - w = true; - } - s << ")"; - } - }; -} - -namespace test_cases -{ - struct ManagementTest : TestCase - { - ManagementTest() : TestCase("management") { } - - void run() - { - TEST_CHECK_EQUAL(CountedStringNode::alloc_count, 0u); - { - FakeDocument d; - NodeManager::get_instance()->manage_node(&d, new CountedStringNode); - NodeManager::get_instance()->manage_node(&d, new CountedStringNode); - NodeManager::get_instance()->manage_node(&d, new CountedStringNode); - TEST_CHECK_EQUAL(CountedStringNode::alloc_count, 3u); - } - TEST_CHECK_EQUAL(CountedStringNode::alloc_count, 0u); - } - } test_management; - - struct ParseTest : TestCase - { - ParseTest() : TestCase("parse") { } - - void run() - { - Document doc("foo: [ bar, baz ]"); - TEST_CHECK(doc.top()); - - Dumper dumper; - doc.top()->accept(dumper); - TEST_CHECK_EQUAL(dumper.s.str(), "map(str(foo) -> seq(str(bar), str(baz)))"); - } - } test_parse; - - struct ParseErrorTest : TestCase - { - ParseErrorTest() : TestCase("parse error") { } - - void run() - { - TEST_CHECK_THROWS(Document("foo: [ bar, baz"), ParseError); - } - } test_parse_error; - - struct MapFindTest : TestCase - { - MapFindTest() : TestCase("map find") { } - - void run() - { - Document doc("{ foo: bar, bar: baz, monkey: pants }"); - TEST_CHECK(doc.top()); - - Dumper dumper; - doc.top()->accept(dumper); - TEST_CHECK_EQUAL(dumper.s.str(), "map(str(foo) -> str(bar), str(bar) -> str(baz), str(monkey) -> str(pants))"); - - const MapNode * m(static_cast<const MapNode *>(doc.top())); - TEST_CHECK(m->find("foo") != m->end()); - TEST_CHECK(m->find("bar") != m->end()); - TEST_CHECK(m->find("monkey") != m->end()); - TEST_CHECK(m->find("baz") == m->end()); - - TEST_CHECK_EQUAL(static_cast<const StringNode *>(m->find("foo")->second)->text(), "bar"); - TEST_CHECK_EQUAL(static_cast<const StringNode *>(m->find("bar")->second)->text(), "baz"); - TEST_CHECK_EQUAL(static_cast<const StringNode *>(m->find("monkey")->second)->text(), "pants"); - } - } test_map_find; -} - diff --git a/paludis/repository_factory.cc b/paludis/repository_factory.cc index eb8017cb4..483066dc1 100644 --- a/paludis/repository_factory.cc +++ b/paludis/repository_factory.cc @@ -119,7 +119,6 @@ RepositoryFactory::RepositoryFactory() : register_repositories(static_cast<const TypeOrNoType<REPOSITORY_GROUP_IF_cran>::Type *>(0), this); register_repositories(static_cast<const TypeOrNoType<REPOSITORY_GROUP_IF_dummy>::Type *>(0), this); register_repositories(static_cast<const TypeOrNoType<REPOSITORY_GROUP_IF_e>::Type *>(0), this); - register_repositories(static_cast<const TypeOrNoType<REPOSITORY_GROUP_IF_gems>::Type *>(0), this); register_repositories(static_cast<const TypeOrNoType<REPOSITORY_GROUP_IF_fake>::Type *>(0), this); register_repositories(static_cast<const TypeOrNoType<REPOSITORY_GROUP_IF_repository>::Type *>(0), this); register_repositories(static_cast<const TypeOrNoType<REPOSITORY_GROUP_IF_unavailable>::Type *>(0), this); |