diff options
author | 2011-02-27 22:09:52 +0000 | |
---|---|---|
committer | 2011-02-28 15:31:18 +0000 | |
commit | 7ca9f93d962864f1b2a018abf1b4deda3b9b821a (patch) | |
tree | d25e8fe0bf16a7424a728e226cfd3c5167ae3f1a | |
parent | bf9e33c1c76c2c2387ada7ae7294efa21a1c2f2f (diff) | |
download | paludis-7ca9f93d962864f1b2a018abf1b4deda3b9b821a.tar.gz paludis-7ca9f93d962864f1b2a018abf1b4deda3b9b821a.tar.xz |
CRAN is dead
38 files changed, 2 insertions, 4191 deletions
diff --git a/.gitignore b/.gitignore index d5ded1cd9..6ca15f813 100644 --- a/.gitignore +++ b/.gitignore @@ -266,10 +266,6 @@ paludis-*.*.*.tar.bz2 /paludis/package_database_TEST /paludis/paludis.hh /paludis/repositories/accounts/accounts_repository_TEST -/paludis/repositories/cran/cran_dep_parser_TEST -/paludis/repositories/cran/cran_installed_repository_TEST -/paludis/repositories/cran/cran_repository_TEST -/paludis/repositories/cran/description_file_TEST /paludis/repositories/e/aa_visitor_TEST /paludis/repositories/e/dep_parser_TEST /paludis/repositories/e/dep_spec_pretty_printer_TEST diff --git a/configure.ac b/configure.ac index d83c75766..1ab1b0f82 100644 --- a/configure.ac +++ b/configure.ac @@ -1398,7 +1398,7 @@ AC_SUBST([VIM_INSTALL_DIR]) dnl }}} dnl {{{ repositories -m4_define(ALL_REPOSITORIES_m4, [accounts,cran,e,fake,gemcutter,repository,unavailable,unpackaged,unwritten,virtuals]) +m4_define(ALL_REPOSITORIES_m4, [accounts,e,fake,gemcutter,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...]) @@ -1409,7 +1409,6 @@ AC_ARG_WITH([repositories], default Equivalent to e,fake,unavailable,unpackaged,unwritten,virtuals accounts Account management (requires distribution support) - cran The Comprehensive R Archive Network (unusable) e Ebuild, Ebin, Exheres, VDB etc fake A fake repository for test cases gemcutter Gemcutter for Ruby @@ -1773,8 +1772,6 @@ AC_CONFIG_FILES([ paludis/fetchers/demos/Makefile paludis/repositories/Makefile paludis/repositories/accounts/Makefile - paludis/repositories/cran/Makefile - paludis/repositories/cran/cran/Makefile paludis/repositories/e/Makefile paludis/repositories/e/eapis/Makefile paludis/repositories/e/ebuild/0/Makefile diff --git a/doc/configuration/licenses.html.part.in b/doc/configuration/licenses.html.part.in index b6eb79fdf..42ef347ae 100644 --- a/doc/configuration/licenses.html.part.in +++ b/doc/configuration/licenses.html.part.in @@ -37,8 +37,7 @@ any of:</p> <li><code>*</code>, which accepts all licenses.</li> </ul> -<p>Any token may be quoted using either single or double quotes. Note that CRAN repository entries can use spaces in -license names, so quoting would be required to explicitly accept those licenses.</p> +<p>Any token may be quoted using either single or double quotes.</p> <p>License settings are cumulative. To <em>only</em> accept listed licenses for a given spec, include <code>-*</code> in the symbols list.</p> diff --git a/misc/common-makefile.am b/misc/common-makefile.am index 5d63e51ea..e5c6eb2a6 100644 --- a/misc/common-makefile.am +++ b/misc/common-makefile.am @@ -47,7 +47,6 @@ LOG_COMPILER = \ CAVE_SYNC_OPTIONS="" \ CAVE_UNINSTALL_OPTIONS="" \ CAVE_UPDATE_WORLD_OPTIONS="" \ - CRAN_BASH_DIR="$(top_srcdir)/paludis/repositories/cran/cran/" \ INQUISITIO_OPTIONS="" \ LD_LIBRARY_PATH="`echo $$LD_LIBRARY_PATH: | sed -e 's,^:,,'`` \ $(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/.libs/ \ diff --git a/paludis/Makefile.am.m4 b/paludis/Makefile.am.m4 index 03c10b49f..a27da865b 100644 --- a/paludis/Makefile.am.m4 +++ b/paludis/Makefile.am.m4 @@ -96,7 +96,6 @@ endif ') condrepo(accounts) -condrepo(cran) condrepo(dummy) condrepo(e) condrepo(fake) diff --git a/paludis/repositories/cran/Makefile.am b/paludis/repositories/cran/Makefile.am deleted file mode 100644 index f525c150d..000000000 --- a/paludis/repositories/cran/Makefile.am +++ /dev/null @@ -1,102 +0,0 @@ -include $(top_srcdir)/misc/common-makefile.am - -SUBDIRS = cran . -AM_CXXFLAGS = -I$(top_srcdir) @PALUDIS_CXXFLAGS@ @PALUDIS_CXXFLAGS_VISIBILITY@ -DEFS= \ - -DSYSCONFDIR=\"$(sysconfdir)\" \ - -DLIBEXECDIR=\"$(libexecdir)\" \ - -DDATADIR=\"$(datadir)\" \ - -DLIBDIR=\"$(libdir)\" - -paludis_repositories_libdir = $(libdir)/paludis/repositories - -noinst_LTLIBRARIES = libpaludiscranrepository.la - -noinst_HEADERS = \ - cran_package_id.hh \ - cran_dep_parser.hh \ - cran_repository.hh \ - cran_installed_repository.hh \ - description_file.hh \ - masks.hh \ - keys.hh \ - normalise.hh \ - spec_tree_pretty_printer.hh \ - package_dep_spec.hh - -libpaludiscranrepository_la_SOURCES = \ - cran_package_id.cc \ - cran_dep_parser.cc \ - cran_repository.cc \ - cran_installed_repository.cc \ - description_file.cc \ - registration.cc \ - normalise.cc \ - masks.cc \ - keys.cc \ - spec_tree_pretty_printer.cc \ - package_dep_spec.cc \ - $(paludis_repositories_cran_include_HEADERS) - -TESTS = \ - cran_dep_parser_TEST \ - cran_repository_TEST \ - cran_installed_repository_TEST \ - description_file_TEST - -cran_dep_parser_TEST_SOURCES = cran_dep_parser_TEST.cc - -cran_dep_parser_TEST_LDADD = \ - $(top_builddir)/paludis/util/test_extras.o \ - $(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \ - $(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \ - $(top_builddir)/test/libtest.a - -cran_dep_parser_TEST_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@ - -cran_installed_repository_TEST_SOURCES = cran_installed_repository_TEST.cc - -cran_installed_repository_TEST_LDADD = \ - $(top_builddir)/paludis/util/test_extras.o \ - $(top_builddir)/test/libtest.a \ - $(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \ - $(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \ - $(DYNAMIC_LD_LIBS) - -cran_installed_repository_TEST_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@ - -cran_repository_TEST_SOURCES = cran_repository_TEST.cc - -cran_repository_TEST_LDADD = \ - $(top_builddir)/paludis/util/test_extras.o \ - $(top_builddir)/test/libtest.a \ - $(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \ - $(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \ - $(DYNAMIC_LD_LIBS) - -cran_repository_TEST_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@ - -description_file_TEST_SOURCES = description_file_TEST.cc - -description_file_TEST_LDADD = \ - $(top_builddir)/paludis/util/test_extras.o \ - $(top_builddir)/test/libtest.a \ - $(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \ - $(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \ - $(DYNAMIC_LD_LIBS) - -description_file_TEST_CXXFLAGS = $(AM_CXXFLAGS) @PALUDIS_CXXFLAGS_NO_DEBUGGING@ - -EXTRA_DIST = \ - cran_repository_TEST.cc \ - cran_repository_TEST_setup.sh \ - cran_repository_TEST_cleanup.sh \ - cran_installed_repository_TEST.cc \ - cran_installed_repository_TEST_setup.sh \ - cran_installed_repository_TEST_cleanup.sh - -check_PROGRAMS = $(TESTS) -check_SCRIPTS = \ - cran_repository_TEST_setup.sh cran_repository_TEST_cleanup.sh \ - cran_installed_repository_TEST_setup.sh cran_installed_repository_TEST_cleanup.sh - diff --git a/paludis/repositories/cran/cran/Makefile.am b/paludis/repositories/cran/cran/Makefile.am deleted file mode 100644 index 3d0f5c339..000000000 --- a/paludis/repositories/cran/cran/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ -MAINTAINERCLEANFILES = Makefile.in -CLEANFILES = *~ *.epicfail -SUBDIRS = . - -AUTOMAKE_OPTIONS = 1.11 parallel-tests - -libexecprogdir = $(libexecdir)/paludis/ - -libexecprog_SCRIPTS = \ - cran.bash - -EXTRA_DIST = $(libexecprog_SCRIPTS) - -built-sources : $(BUILT_SOURCES) - for s in `echo $(SUBDIRS) | tr -d .` ; do $(MAKE) -C $$s built-sources || exit 1 ; done - diff --git a/paludis/repositories/cran/cran/cran.bash b/paludis/repositories/cran/cran/cran.bash deleted file mode 100644 index ba70ffcb7..000000000 --- a/paludis/repositories/cran/cran/cran.bash +++ /dev/null @@ -1,151 +0,0 @@ -#!/usr/bin/env bash -# vim: set sw=4 sts=4 et : - -# Copyright (c) 2006,2007 Danny van Dyk -# -# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005 -# Gentoo Foundation and distributed under the terms of the GNU General -# Public License v2. -# -# 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 - -. ${PALUDIS_EBUILD_DIR}/echo_functions.bash - -shopt -s expand_aliases - -CRAN_KILL_PID=$$ -alias die='diefunc "$FUNCNAME" "$LINENO"' -trap 'echo "die trap: exiting with error." 1>&2 ; exit 250' 15 - -for f in ${PALUDIS_BASHRC_FILES} ; do - if [[ -f ${f} ]] ; then - ebuild_notice "debug" "Loading bashrc file ${f}" - source ${f} - else - ebuild_notice "debug" "Skipping bashrc file ${f}" - fi -done - -diefunc() -{ - local func="$1" line="$2" - shift 2 - echo 1>&2 - echo "!!! ERROR in cran/${PN:-?}:" 1>&2 - echo "!!! In ${func:-?} at line ${line:-?}" 1>&2 - echo "!!! ${*:-(no message provided)}" 1>&2 - echo 1>&2 - - echo "!!! Call stack:" 1>&2 - for (( n = 1 ; n < ${#FUNCNAME[@]} ; ++n )) ; do - funcname=${FUNCNAME[${n}]} - sourcefile=${BASH_SOURCE[${n}]} - lineno=${BASH_LINENO[$(( n - 1 ))]} - echo "!!! * ${funcname} (${sourcefile}:${lineno})" 1>&2 - done - echo 1>&2 - - kill ${CRAN_KILL_PID} - exit 249 -} - -cran_command() { - local ret=1 command=${1} - shift - - ebuild_section "Starting ${command}" - - if type cran_do_${command} &> /dev/null ; then - cran_do_${command} || die "Failed to run command: ${command}" - else - die "Unknown command: ${command}" - fi - - ebuild_section "Done ${command}" -} - -cran_do_clean() { - [[ -e ${WORKDIR} ]] && rm -rf ${WORKDIR} - [[ -e ${IMAGE} ]] && rm -rf ${IMAGE} - return 0 -} - -cran_do_fetch() { - local mirror ret=0 - shift - - for mirror in ${PALUDIS_CRAN_MIRRORS[@]} ; do - mkdir -p ${DISTDIR} - cd ${DISTDIR} - - if [[ -e ${DISTFILE} ]] ; then - echo "Already fetched: $(basename ${DISTFILE})" - return 0 - fi - - local dofetch="${PALUDIS_EBUILD_DIR}/fetchers/do$(echo ${mirror%%://*})" - local a="${mirror}/src/contrib/${DISTFILE}" - if [[ -f "${dofetch}" ]] ; then - ${dofetch} "${a}" "${DISTFILE}" - ret=$? - else - eerror "Don't know how to fetch '${a}'" - ret=1 - fi - if [[ ${ret} == 0 ]] ; then - break - else - echo "Failed to run \"${command}\" for mirror ${mirror}." - fi - done - if [[ ${ret} != 0 ]] ; then - echo "Finally failed to run \"${command}\"." - fi -} - -cran_do_install() { - if [[ -e "${WORKDIR}" ]] ; then - rm -Rf "${WORKDIR}" || die "Could not remove existing WORKDIR: ${WORKDIR}" - fi - mkdir -p "${WORKDIR}" - cd "${WORKDIR}" || die "Could not cd to WORKDIR: ${WORKDIR}" - - local dounpack="${PALUDIS_EBUILD_DIR}/utils/dounpack" - ${dounpack} "${DISTFILE}" - - # \todo Sandbox this? - R CMD INSTALL -l "${IMAGE}/${PALUDIS_CRAN_LIBRARY##${ROOT}}" ${PN} - - if [[ ${IS_BUNDLE} == "yes" ]] ; then - mkdir -p "${IMAGE}/${PALUDIS_CRAN_LIBRARY##${ROOT}}/paludis/bundles/" - cp "${PN}/DESCRIPTION" "${IMAGE}/${PALUDIS_CRAN_LIBRARY##${ROOT}}/paludis/bundles/${PN}.DESCRIPTION" - fi -} - -cran_do_merge() { - [[ -e "${IMAGE}/${INSTALL_TO##${ROOT}}/R.css" ]] \ - && rm -f "${IMAGE}/${PALUDIS_CRAN_LIBRARY##${ROOT}}/R.css" - mkdir -p "${PALUDIS_CRAN_LIBRARY}/paludis/${PN}" - ${PALUDIS_EBUILD_DIR}/merge "${IMAGE}" "${ROOT}" "${PALUDIS_CRAN_LIBRARY}/paludis/${PN}/CONTENTS" - echo ${REPOSITORY} > "${PALUDIS_CRAN_LIBRARY}/paludis/${PN}/REPOSITORY" -} - -cran_do_unmerge() { - [[ -e "${PALUDIS_CRAN_LIBRARY}/paludis/${PN}/CONTENTS" ]] || die "CONTENTS file is missing for package ${PN}" - ${PALUDIS_EBUILD_DIR}/unmerge "${ROOT}" "${PALUDIS_CRAN_LIBRARY}/paludis/${PN}/CONTENTS" -} - -for cmd in $* ; do - cran_command ${cmd} -done diff --git a/paludis/repositories/cran/cran_dep_parser.cc b/paludis/repositories/cran/cran_dep_parser.cc deleted file mode 100644 index 2ae206b09..000000000 --- a/paludis/repositories/cran/cran_dep_parser.cc +++ /dev/null @@ -1,76 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 Danny van Dyk - * - * 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/dep_spec.hh> -#include <paludis/spec_tree.hh> -#include <paludis/repositories/cran/cran_dep_parser.hh> -#include <paludis/repositories/cran/normalise.hh> -#include <paludis/repositories/cran/package_dep_spec.hh> -#include <paludis/util/strip.hh> -#include <paludis/util/stringify.hh> -#include <paludis/util/tokeniser.hh> - -#include <string> -#include <list> - -using namespace paludis; - -std::shared_ptr<DependencySpecTree> -cranrepository::parse_depends(const std::string & s) -{ - Context context("When parsing CRAN 'Depends:' string: '" + s + "':"); - - std::shared_ptr<DependencySpecTree> result(std::make_shared<DependencySpecTree>(std::make_shared<AllDepSpec>())); - - std::list<std::string> specs; - - std::string::size_type p(0), s_p(0); - while (p < s.length()) - { - if (s[p] == ',') - { - specs.push_back(s.substr(s_p, p - s_p)); - s_p = ++p; - } - else if (s[p] == '(') - { - p = s.find(')', p); - if (std::string::npos == p) - p = s.length(); - } - else - ++p; - } - - if (s_p < s.length()) - specs.push_back(s.substr(s_p)); - - std::list<std::string>::const_iterator a(specs.begin()), a_end(specs.end()); - for ( ; a != a_end ; ++a) - { - Context local_context("When processing token '" + *a + "':"); - - std::shared_ptr<PackageDepSpec> spec(std::make_shared<PackageDepSpec>(cranrepository::parse_cran_package_dep_spec( - strip_leading(strip_trailing(*a, " \r\n\t"), " \r\n\t")))); - result->top()->append(spec); - } - - return result; -} - diff --git a/paludis/repositories/cran/cran_dep_parser.hh b/paludis/repositories/cran/cran_dep_parser.hh deleted file mode 100644 index 019b07883..000000000 --- a/paludis/repositories/cran/cran_dep_parser.hh +++ /dev/null @@ -1,36 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006 Danny van Dyk - * 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_CRAN_DEP_PARSER_HH -#define PALUDIS_GUARD_PALUDIS_CRAN_DEP_PARSER_HH 1 - -#include <paludis/dep_spec.hh> -#include <paludis/spec_tree-fwd.hh> -#include <string> - -namespace paludis -{ - namespace cranrepository - { - std::shared_ptr<DependencySpecTree> parse_depends(const std::string & s) PALUDIS_VISIBLE; - } -} - -#endif diff --git a/paludis/repositories/cran/cran_dep_parser_TEST.cc b/paludis/repositories/cran/cran_dep_parser_TEST.cc deleted file mode 100644 index fe5726129..000000000 --- a/paludis/repositories/cran/cran_dep_parser_TEST.cc +++ /dev/null @@ -1,74 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006 Danny van Dyk - * - * 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/dep_spec.hh> -#include <paludis/dep_spec_flattener.hh> -#include <paludis/repositories/cran/cran_dep_parser.hh> -#include <paludis/repositories/cran/spec_tree_pretty_printer.hh> -#include <paludis/environments/test/test_environment.hh> -#include <paludis/util/system.hh> -#include <paludis/unformatted_pretty_printer.hh> -#include <test/test_framework.hh> -#include <test/test_runner.hh> - -using namespace test; -using namespace paludis; - -namespace test_cases -{ - struct CRANDepParserTest : TestCase - { - CRANDepParserTest() : TestCase("DepParser") { } - - void run() - { - UnformattedPrettyPrinter ff; - cranrepository::SpecTreePrettyPrinter d1(ff, { }), d2(ff, { }), d3(ff, { }), - d4(ff, { }), d5(ff, { }), d6(ff, { }); - - // test R dependency - std::string dep1("R (>= 2.0.0)"); - cranrepository::parse_depends(dep1)->top()->accept(d1); - TEST_CHECK_EQUAL(stringify(d1), "R (>= 2.0.0)"); - - // test varying whitespaces - std::string dep2("testpackage1 \t(<1.9)"); - cranrepository::parse_depends(dep2)->top()->accept(d2); - TEST_CHECK_EQUAL(stringify(d2), "testpackage1 (< 1.9)"); - - // test for package-name and version normalisation - std::string dep3("R.matlab (>= 2.3-1)"); - cranrepository::parse_depends(dep3)->top()->accept(d3); - TEST_CHECK_EQUAL(stringify(d3), "R.matlab (>= 2.3.1)"); - - std::string dep4("foo (>= 2, <3)"); - cranrepository::parse_depends(dep4)->top()->accept(d4); - TEST_CHECK_EQUAL(stringify(d4), "foo (>= 2, < 3)"); - - std::string dep5("foo (>= 2), bar (<=3)"); - cranrepository::parse_depends(dep5)->top()->accept(d5); - TEST_CHECK_EQUAL(stringify(d5), "foo (>= 2), bar (<= 3)"); - - std::string dep6("foo (>= 2, <= 4), bar (<=3)"); - cranrepository::parse_depends(dep6)->top()->accept(d6); - TEST_CHECK_EQUAL(stringify(d6), "foo (>= 2, <= 4), bar (<= 3)"); - } - } test_cran_dep_parser; -} - diff --git a/paludis/repositories/cran/cran_installed_repository.cc b/paludis/repositories/cran/cran_installed_repository.cc deleted file mode 100644 index e764df7cb..000000000 --- a/paludis/repositories/cran/cran_installed_repository.cc +++ /dev/null @@ -1,606 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 Danny van Dyk - * Copyright (c) 2007, 2008, 2009, 2010, 2011 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/environment.hh> -#include <paludis/util/pimp-impl.hh> -#include <paludis/dep_spec.hh> -#include <paludis/util/config_file.hh> -#include <paludis/set_file.hh> -#include <paludis/action.hh> -#include <paludis/literal_metadata_key.hh> -#include <paludis/user_dep_spec.hh> -#include <paludis/generator.hh> -#include <paludis/filtered_generator.hh> -#include <paludis/filter.hh> -#include <paludis/selection.hh> -#include <paludis/hook.hh> -#include <paludis/common_sets.hh> -#include <paludis/package_database.hh> -#include <paludis/repositories/cran/cran_package_id.hh> -#include <paludis/repositories/cran/cran_dep_parser.hh> -#include <paludis/repositories/cran/cran_installed_repository.hh> -#include <paludis/repositories/cran/package_dep_spec.hh> -#include <paludis/util/sequence.hh> -#include <paludis/util/system.hh> -#include <paludis/util/log.hh> -#include <paludis/util/map.hh> -#include <paludis/util/set.hh> -#include <paludis/util/stringify.hh> -#include <paludis/util/strip.hh> -#include <paludis/util/tokeniser.hh> -#include <paludis/util/hashes.hh> -#include <paludis/util/make_named_values.hh> -#include <paludis/util/wrapped_output_iterator.hh> -#include <paludis/util/make_null_shared_ptr.hh> -#include <unordered_map> -#include <functional> -#include <algorithm> - -using namespace paludis; - -typedef std::unordered_map< - QualifiedPackageName, - std::shared_ptr<const cranrepository::CRANPackageID>, - Hash<QualifiedPackageName> > IDMap; - -namespace paludis -{ - template <> - struct Imp<CRANInstalledRepository> - { - CRANInstalledRepositoryParams params; - - mutable bool has_ids; - mutable IDMap ids; - - Imp(const CRANInstalledRepositoryParams &); - ~Imp(); - - std::shared_ptr<const MetadataValueKey<FSPath> > location_key; - std::shared_ptr<const MetadataValueKey<FSPath> > installed_root_key; - std::shared_ptr<const MetadataValueKey<std::string> > format_key; - }; -} - -Imp<CRANInstalledRepository>::Imp(const CRANInstalledRepositoryParams & p) : - params(p), - has_ids(false), - location_key(std::make_shared<LiteralMetadataValueKey<FSPath> >("location", "location", mkt_significant, params.location())), - installed_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, "installed_cran")) -{ -} - -Imp<CRANInstalledRepository>::~Imp() -{ -} - -#if 0 -void -Imp<CRANInstalledRepository>::need_ids() const -{ - Context context("When loading CRANInstalledRepository IDs from '" + stringify(location) + "':"); - - entries_valid = true; - try - { - for (DirIterator d(location), d_end ; d != d_end ; ++d) - { - Context local_context("When parsing directoryy '" + stringify(*d) + "':"); - if (! d->is_directory()) - continue; - - FSPath f(FSPath(stringify(*d)) / "DESCRIPTION"); - if (! f.is_regular_file()) - continue; - - std::string n(d->basename()); - CRANDescription::normalise_name(n); - - CRANDescription desc(n, f, true); - entries.push_back(desc); - - QualifiedPackageName q("cran/" + n); - metadata.insert(std::make_pair(std::make_pair(q, VersionSpec(desc.version)), desc.metadata)); - } - - if (! FSPath(location / "paludis" / "bundles").is_directory()) - return; - - // Load Bundle Metadata - for (DirIterator f(location / "paludis" / "bundles"), f_end ; f != f_end ; ++f) - { - Context local_context("When parsing file '" + stringify(*f) + "'."); - - if (! f->is_regular_file()) - { - continue; - } - - std::string n(f->basename()); - std::string::size_type pos(n.find_last_of(".")); - if (std::string::npos != pos) - n.erase(pos); - CRANDescription::normalise_name(n); - - CRANDescription desc(n, *f, true); - entries.push_back(desc); - - QualifiedPackageName q("cran/" + n); - metadata.insert(std::make_pair(std::make_pair(q, VersionSpec(desc.version)), desc.metadata)); - } - - } - catch (...) - { - entries_valid = false; - throw; - } -} -#endif - -CRANInstalledRepository::CRANInstalledRepository(const CRANInstalledRepositoryParams & p) : - Repository( - p.environment(), - RepositoryName("installed-cran"), - 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) - )), - _imp(p) -{ - _add_metadata_keys(); -} - -CRANInstalledRepository::~CRANInstalledRepository() -{ -} - -void -CRANInstalledRepository::_add_metadata_keys() const -{ - clear_metadata_keys(); - add_metadata_key(_imp->location_key); - add_metadata_key(_imp->installed_root_key); - add_metadata_key(_imp->format_key); -} - -bool -CRANInstalledRepository::has_category_named(const CategoryNamePart & c, const RepositoryContentMayExcludes &) const -{ - return (CategoryNamePart("cran") == c); -} - -const bool -CRANInstalledRepository::is_unimportant() const -{ - return false; -} - -bool -CRANInstalledRepository::has_package_named(const QualifiedPackageName & q, const RepositoryContentMayExcludes & x) const -{ - Context context("When checking for package '" + stringify(q) + "' in " + stringify(name()) + ":"); - - if (! has_category_named(q.category(), x)) - return false; - - need_ids(); - - return _imp->ids.end() != _imp->ids.find(q); -} - -std::shared_ptr<const CategoryNamePartSet> -CRANInstalledRepository::category_names(const RepositoryContentMayExcludes &) const -{ - std::shared_ptr<CategoryNamePartSet> result(std::make_shared<CategoryNamePartSet>()); - result->insert(CategoryNamePart("cran")); - return result; -} - -std::shared_ptr<const QualifiedPackageNameSet> -CRANInstalledRepository::package_names(const CategoryNamePart & c, const RepositoryContentMayExcludes & x) const -{ - Context context("When fetching package names in category '" + stringify(c) - + "' in " + stringify(name()) + ":"); - - std::shared_ptr<QualifiedPackageNameSet> result(std::make_shared<QualifiedPackageNameSet>()); - if (! has_category_named(c, x)) - return result; - - need_ids(); - - std::transform(_imp->ids.begin(), _imp->ids.end(), result->inserter(), - std::mem_fn(&std::pair<const QualifiedPackageName, std::shared_ptr<const cranrepository::CRANPackageID> >::first)); - - return result; -} - -std::shared_ptr<const PackageIDSequence> -CRANInstalledRepository::package_ids(const QualifiedPackageName & n, const RepositoryContentMayExcludes & x) const -{ - Context context("When fetching versions of '" + stringify(n) + "' in " - + stringify(name()) + ":"); - - std::shared_ptr<PackageIDSequence> result(std::make_shared<PackageIDSequence>()); - if (! has_package_named(n, x)) - return result; - - need_ids(); - - IDMap::const_iterator i(_imp->ids.find(n)); - if (i != _imp->ids.end()) - result->push_back(i->second); - return result; -} - -#if 0 -std::shared_ptr<const Contents> -CRANInstalledRepository::do_contents(const Package ID & id) const -{ - Context context("When fetching contents for " + stringify(id) + ":"); - - std::shared_ptr<Contents> result(std::make_shared<Contents>()); - - if (! _imp->entries_valid) - _imp->load_entries(); - - if (! has_version(q, v)) - return result; - - std::string pn = stringify(q.package()); - CRANDescription::normalise_name(pn); - FSPath f(_imp->location / "paludis" / pn / "CONTENTS"); - if (! f.is_regular_file()) - { - Log::get_instance()->message(ll_warning, lc_no_context, "CONTENTS lookup failed for request for' " + - stringify(q) + "-" + stringify(v) + "' in CRANInstalled '" + - stringify(_imp->location) + "'"); - return result; - } - - SafeIFStream ff(f); - if (! ff) - throw ConfigurationError("Could not read '" + stringify(f) + "'"); - - std::string line; - unsigned line_number(0); - while (std::getline(ff, line)) - { - ++line_number; - - std::vector<std::string> tokens; - WhitespaceTokeniser::tokenise(line, std::back_inserter(tokens)); - if (tokens.empty()) - continue; - - if (tokens.size() < 2) - { - Log::get_instance()->message(ll_warning, lc_no_context, "CONTENTS for '" + - stringify(q) + "-" + stringify(v) + "' in vdb '" + - stringify(_imp->location) + "' has broken line " + - stringify(line_number) + ", skipping"); - continue; - } - - if ("obj" == tokens.at(0)) - result->add(std::shared_ptr<ContentsEntry>(std::make_shared<ContentsFileEntry>(tokens.at(1)))); - else if ("dir" == tokens.at(0)) - result->add(std::shared_ptr<ContentsEntry>(std::make_shared<ContentsDirEntry>(tokens.at(1)))); - else if ("misc" == tokens.at(0)) - result->add(std::shared_ptr<ContentsEntry>(std::make_shared<ContentsMiscEntry>(tokens.at(1)))); - else if ("sym" == tokens.at(0)) - { - if (tokens.size() < 4) - { - Log::get_instance()->message(ll_warning, lc_no_context, "CONTENTS for '" + - stringify(q) + "-" + stringify(v) + "' in vdb '" + - stringify(_imp->location) + "' has broken sym line " + - stringify(line_number) + ", skipping"); - continue; - } - - result->add(std::shared_ptr<ContentsEntry>(std::make_shared<ContentsSymEntry>( - tokens.at(1), tokens.at(3)))); - } - } - - return result; -} - -time_t -CRANInstalledRepository::do_installed_time(const QualifiedPackageName & q, - const VersionSpec & v) const -{ - Context context("When finding installed time for '" + stringify(q) + - "-" + stringify(v) + "':"); - - if (! _imp->entries_valid) - _imp->load_entries(); - - std::vector<CRANDescription>::iterator r(_imp->entries.begin()), r_end(_imp->entries.end()); - for ( ; r != r_end ; ++r) - { - if (q == r->name) - break; - } - - if (r == r_end) - throw NoSuchPackageError(stringify(PackageDatabaseEntry(q, v, name()))); - else - { - if (0 == r->installed_time) - { - std::string pn(stringify(q.package())); - CRANDescription::normalise_name(pn); - FSPath f(_imp->location / "paludis" / pn / "CONTENTS"); - try - { - r->installed_time = f.mtime(); - } - catch (const FSError & e) - { - Log::get_instance()->message(ll_warning, lc_no_context, "Can't get mtime of '" - + stringify(f) + "' due to exception '" + e.message() + "' (" + e.what() - + ")"); - r->installed_time = 1; - } - } - return r->installed_time; - } -} -#endif - -std::shared_ptr<Repository> -CRANInstalledRepository::repository_factory_create( - Environment * const env, - const std::function<std::string (const std::string &)> & f) -{ - Context context("When making CRAN installed repository from repo_file '" + f("repo_file") + "':"); - - std::string location(f("location")); - if (location.empty()) - throw CRANInstalledRepositoryConfigurationError("Key 'location' not specified or empty"); - - std::string root(f("root")); - if (root.empty()) - root = stringify(env->preferred_root_key()->value()); - - if (! f("world").empty()) - throw CRANInstalledRepositoryConfigurationError("Key 'world' is no longer supported."); - - return std::make_shared<CRANInstalledRepository>(make_named_values<CRANInstalledRepositoryParams>( - n::environment() = env, - n::location() = location, - n::root() = root - )); -} - -RepositoryName -CRANInstalledRepository::repository_factory_name( - const Environment * const, - const std::function<std::string (const std::string &)> &) -{ - return RepositoryName("installed-cran"); -} - -std::shared_ptr<const RepositoryNameSet> -CRANInstalledRepository::repository_factory_dependencies( - const Environment * const, - const std::function<std::string (const std::string &)> &) -{ - return std::make_shared<RepositoryNameSet>(); -} - -CRANInstalledRepositoryConfigurationError::CRANInstalledRepositoryConfigurationError( - const std::string & msg) throw () : - ConfigurationError("CRAN installed repository configuration error: " + msg) -{ -} - -#if 0 -void -CRANInstalledRepository::do_uninstall(const QualifiedPackageName & q, const VersionSpec & v, - const UninstallOptions &) const -{ - Context context("When uninstalling '" + stringify(q) + "-" + stringify(v) + - "' from '" + stringify(name()) + "':"); - - if (! _imp->location.is_directory()) - throw PackageInstallActionError("Couldn't uninstall '" + stringify(q) + "-" + - stringify(v) + "' because its location ('" + stringify(_imp->location) + "') is not a directory"); - - std::shared_ptr<const VersionMetadata> vm(do_version_metadata(q, v)); - std::shared_ptr<const FSPath> bashrc_files(_imp->env->bashrc_files()); - - Command cmd(Command(LIBEXECDIR "/paludis/cran.bash unmerge") - .with_setenv("PN", vm->cran_interface->package()) - .with_setenv("PV", stringify(v)) - .with_setenv("PALUDIS_CRAN_LIBRARY", stringify(_imp->location)) - .with_setenv("PALUDIS_EBUILD_DIR", std::string(LIBEXECDIR "/paludis/")) - .with_setenv("PALUDIS_BASHRC_FILES", join(bashrc_files->begin(), bashrc_files->end(), " "))); - - if (0 != run_command(cmd)) - throw PackageUninstallActionError("Couldn't unmerge '" + stringify(q) + "-" + stringify(v) + "'"); -} -#endif - -void -CRANInstalledRepository::invalidate() -{ - _imp.reset(new Imp<CRANInstalledRepository>(_imp->params)); - _add_metadata_keys(); -} - -void -CRANInstalledRepository::invalidate_masks() -{ -} - -bool -CRANInstalledRepository::is_suitable_destination_for(const std::shared_ptr<const PackageID> & id) const -{ - auto repo(_imp->params.environment()->package_database()->fetch_repository(id->repository_name())); - std::string f(repo->format_key() ? repo->format_key()->value() : ""); - return f == "cran"; -} -bool -CRANInstalledRepository::is_default_destination() const -{ - return _imp->params.environment()->preferred_root_key()->value() == installed_root_key()->value(); -} - -bool -CRANInstalledRepository::want_pre_post_phases() const -{ - return true; -} - -void -CRANInstalledRepository::merge(const MergeParams & m) -{ - Context context("When merging '" + stringify(*m.package_id()) + "' at '" + stringify(m.image_dir()) - + "' to repository '" + stringify(name()) + "':"); - - if (! is_suitable_destination_for(m.package_id())) - throw ActionFailedError("Not a suitable destination for '" + stringify(*m.package_id()) + "'"); - -} - -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<UninstallAction> &) const - { - return true; - } - - bool visit(const SupportsActionTest<InfoAction> &) const - { - return false; - } - }; -} - -bool -CRANInstalledRepository::some_ids_might_support_action(const SupportsActionTestBase & a) const -{ - SupportsActionQuery q; - return a.accept_returning<bool>(q); -} - -bool -CRANInstalledRepository::some_ids_might_not_be_masked() const -{ - return true; -} - -void -CRANInstalledRepository::need_ids() const -{ -} - -void -CRANInstalledRepository::need_keys_added() const -{ -} - -const std::shared_ptr<const MetadataValueKey<std::string> > -CRANInstalledRepository::format_key() const -{ - return _imp->format_key; -} - -const std::shared_ptr<const MetadataValueKey<FSPath> > -CRANInstalledRepository::location_key() const -{ - return _imp->location_key; -} - -const std::shared_ptr<const MetadataValueKey<FSPath> > -CRANInstalledRepository::installed_root_key() const -{ - return _imp->installed_root_key; -} - -const std::shared_ptr<const MetadataCollectionKey<Map<std::string, std::string> > > -CRANInstalledRepository::sync_host_key() const -{ - return make_null_shared_ptr(); -} - -void -CRANInstalledRepository::populate_sets() const -{ - add_common_sets_for_installed_repo(_imp->params.environment(), *this); -} - -HookResult -CRANInstalledRepository::perform_hook( - const Hook &, - const std::shared_ptr<OutputManager> &) -{ - return make_named_values<HookResult>(n::max_exit_status() = 0, n::output() = ""); -} - -bool -CRANInstalledRepository::sync( - const std::string &, - const std::shared_ptr<OutputManager> &) const -{ - return false; -} - -const std::shared_ptr<const MetadataValueKey<std::string> > -CRANInstalledRepository::accept_keywords_key() const -{ - return make_null_shared_ptr(); -} - diff --git a/paludis/repositories/cran/cran_installed_repository.hh b/paludis/repositories/cran/cran_installed_repository.hh deleted file mode 100644 index f5c3b7535..000000000 --- a/paludis/repositories/cran/cran_installed_repository.hh +++ /dev/null @@ -1,186 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006 Danny van Dyk - * Copyright (c) 2007, 2008, 2009, 2010, 2011 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_CRAN_INSTALLED_REPOSITORY_HH -#define PALUDIS_GUARD_PALUDIS_CRAN_INSTALLED_REPOSITORY_HH 1 - -#include <paludis/repository.hh> -#include <paludis/util/attributes.hh> -#include <paludis/util/pimp.hh> -#include <paludis/util/map-fwd.hh> - -/** \file - * Declarations for CRANInstalledRepository. - * - * \ingroup grpcraninstrepository - */ - -namespace paludis -{ - namespace n - { - typedef Name<struct name_environment> environment; - typedef Name<struct name_location> location; - typedef Name<struct name_root> root; - } - - /** - * Parameters used to create a CRANInstalledRepository - * - * \see CRANInstalledRepository - * \ingroup grpcraninstrepository - * \nosubgrouping - */ - struct CRANInstalledRepositoryParams - { - NamedValue<n::environment, const Environment *> environment; - NamedValue<n::location, FSPath> location; - NamedValue<n::root, FSPath> root; - }; - - /** - * A CRANInstalledRepository represents the database used for - * installed CRAN packages. - * - * \ingroup grpcraninstrepository - */ - class PALUDIS_VISIBLE CRANInstalledRepository : - public Repository, - public RepositoryDestinationInterface - { - private: - Pimp<CRANInstalledRepository> _imp; - - void _add_metadata_keys() const; - - void need_ids() const; - - protected: - virtual void need_keys_added() const; - - public: - /** - * Constructor. - */ - CRANInstalledRepository(const CRANInstalledRepositoryParams &); - - ///\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 &)> &); - - ///\} - - /** - * Destructor. - */ - ~CRANInstalledRepository(); - - virtual void invalidate(); - virtual void invalidate_masks(); - virtual HookResult perform_hook( - const Hook & hook, - const std::shared_ptr<OutputManager> &); - - /* RepositoryDestinationInterface */ - - virtual bool is_suitable_destination_for(const std::shared_ptr<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 &); - - /* Repository */ - - virtual std::shared_ptr<const PackageIDSequence> package_ids( - const QualifiedPackageName &, const RepositoryContentMayExcludes &) const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual std::shared_ptr<const QualifiedPackageNameSet> package_names( - const CategoryNamePart &, const RepositoryContentMayExcludes &) const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual std::shared_ptr<const CategoryNamePartSet> category_names(const RepositoryContentMayExcludes &) const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual bool has_package_named(const QualifiedPackageName &, const RepositoryContentMayExcludes &) const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual bool has_category_named(const CategoryNamePart &, const RepositoryContentMayExcludes &) const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual const bool is_unimportant() const; - - virtual bool some_ids_might_support_action(const SupportsActionTestBase &) const; - - virtual bool some_ids_might_not_be_masked() const; - - virtual bool sync(const std::string &, 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 MetadataCollectionKey<Map<std::string, std::string> > > sync_host_key() const; - - ///\name Set methods - ///\{ - - virtual void populate_sets() const; - - ///\} - }; - - /** - * Thrown if invalid parameters are provided for - * CRANInstalledRepositoryConfigurationError::make_cran_installed_repository. - * - * \ingroup grpcraninstrepository - * \ingroup grpexceptions - */ - class PALUDIS_VISIBLE CRANInstalledRepositoryConfigurationError : - public ConfigurationError - { - public: - /** - * Constructor. - */ - CRANInstalledRepositoryConfigurationError(const std::string & msg) throw (); - }; -} - -#endif diff --git a/paludis/repositories/cran/cran_installed_repository_TEST.cc b/paludis/repositories/cran/cran_installed_repository_TEST.cc deleted file mode 100644 index d7e4dd8d9..000000000 --- a/paludis/repositories/cran/cran_installed_repository_TEST.cc +++ /dev/null @@ -1,68 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2008, 2010, 2011 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/dep_spec.hh> -#include <paludis/dep_spec_flattener.hh> -#include <paludis/repositories/cran/cran_dep_parser.hh> -#include <paludis/repositories/cran/cran_package_id.hh> -#include <paludis/repositories/cran/cran_installed_repository.hh> -#include <paludis/environments/test/test_environment.hh> -#include <paludis/util/system.hh> -#include <paludis/util/map.hh> -#include <paludis/util/wrapped_forward_iterator.hh> -#include <test/test_framework.hh> -#include <test/test_runner.hh> - -using namespace test; -using namespace paludis; - -namespace -{ - std::string from_keys(const std::shared_ptr<const Map<std::string, std::string> > & m, - const std::string & k) - { - Map<std::string, std::string>::ConstIterator mm(m->find(k)); - if (m->end() == mm) - return ""; - else - return mm->second; - } -} - -namespace test_cases -{ - struct CRANInstalledRepositoryPackagesTest : TestCase - { - CRANInstalledRepositoryPackagesTest() : TestCase("PACKAGES") { } - - void run() - { - TestEnvironment env; - std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>()); - keys->insert("format", "cran_installed"); - keys->insert("library", "cran_installed_repository_TEST_dir/library"); - keys->insert("location", "cran_installed_repository_TEST_dir/repo1"); - keys->insert("builddir", "cran_installed_repository_TEST_dir/tmp"); - std::shared_ptr<Repository> repo(CRANInstalledRepository::repository_factory_create(&env, - std::bind(from_keys, keys, std::placeholders::_1))); - TEST_CHECK(repo->has_category_named(CategoryNamePart("cran"), { })); - } - } test_cran_repository_installed_packages; -} - diff --git a/paludis/repositories/cran/cran_installed_repository_TEST_cleanup.sh b/paludis/repositories/cran/cran_installed_repository_TEST_cleanup.sh deleted file mode 100755 index a571a3d5a..000000000 --- a/paludis/repositories/cran/cran_installed_repository_TEST_cleanup.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -# vim: set ft=sh sw=4 sts=4 et : - -if [ -d cran_installed_repository_TEST_dir ] ; then - rm -fr cran_installed_repository_TEST_dir -else - true -fi - diff --git a/paludis/repositories/cran/cran_installed_repository_TEST_setup.sh b/paludis/repositories/cran/cran_installed_repository_TEST_setup.sh deleted file mode 100755 index ac0c137fa..000000000 --- a/paludis/repositories/cran/cran_installed_repository_TEST_setup.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -# vim: set ft=sh sw=4 sts=4 et : - -mkdir cran_installed_repository_TEST_dir || exit 1 -cd cran_installed_repository_TEST_dir || exit 1 - - diff --git a/paludis/repositories/cran/cran_package_id.cc b/paludis/repositories/cran/cran_package_id.cc deleted file mode 100644 index 63ab526b7..000000000 --- a/paludis/repositories/cran/cran_package_id.cc +++ /dev/null @@ -1,558 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 Danny van Dyk - * Copyright (c) 2007, 2008, 2009, 2010, 2011 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/cran/cran_package_id.hh> -#include <paludis/repositories/cran/cran_dep_parser.hh> -#include <paludis/repositories/cran/description_file.hh> -#include <paludis/repositories/cran/masks.hh> -#include <paludis/repositories/cran/keys.hh> -#include <paludis/repositories/cran/normalise.hh> -#include <paludis/repositories/cran/cran_repository.hh> -#include <paludis/repositories/cran/cran_installed_repository.hh> -#include <paludis/util/config_file.hh> -#include <paludis/repository.hh> -#include <paludis/util/log.hh> -#include <paludis/util/strip.hh> -#include <paludis/util/stringify.hh> -#include <paludis/util/pimp-impl.hh> -#include <paludis/util/return_literal_function.hh> -#include <paludis/util/make_null_shared_ptr.hh> -#include <paludis/util/fs_stat.hh> -#include <paludis/literal_metadata_key.hh> -#include <paludis/name.hh> -#include <paludis/version_spec.hh> -#include <paludis/action.hh> -#include <paludis/dep_label.hh> -#include <paludis/user_dep_spec.hh> -#include <paludis/environment.hh> -#include <paludis/package_database.hh> -#include <paludis/util/tokeniser.hh> -#include <paludis/util/singleton-impl.hh> -#include <paludis/always_enabled_dependency_label.hh> -#include <string> -#include <algorithm> -#include <list> -#include <functional> - -using namespace paludis; -using namespace paludis::cranrepository; - -namespace -{ - struct CRANPackageIDData : - Singleton<CRANPackageIDData> - { - std::shared_ptr<DependenciesLabelSequence> suggests_labels; - std::shared_ptr<DependenciesLabelSequence> depends_labels; - - CRANPackageIDData() : - suggests_labels(std::make_shared<DependenciesLabelSequence>()), - depends_labels(std::make_shared<DependenciesLabelSequence>()) - { - suggests_labels->push_back(std::make_shared<AlwaysEnabledDependencyLabel<DependenciesSuggestionLabelTag> >("Suggests")); - depends_labels->push_back(std::make_shared<AlwaysEnabledDependencyLabel<DependenciesBuildLabelTag> >("Depends")); - } - }; -} - -namespace paludis -{ - template <> - struct Imp<CRANPackageID> - { - const Environment * const env; - const RepositoryName repository_name; - - QualifiedPackageName name; - VersionSpec version; - - std::shared_ptr<LiteralMetadataValueKey<FSPath> > fs_location_key; - std::shared_ptr<LiteralMetadataValueKey<std::string> > url_key; - std::shared_ptr<LiteralMetadataValueKey<std::string> > short_description_key; - std::shared_ptr<LiteralMetadataValueKey<std::string> > long_description_key; - std::shared_ptr<LiteralMetadataValueKey<std::string> > license_key; - std::shared_ptr<PackageIDKey> contained_in_key; - std::shared_ptr<PackageIDSequenceKey> contains_key; - std::shared_ptr<DepKey> depends_key; - std::shared_ptr<DepKey> suggests_key; - - Imp(const Environment * const e, const RepositoryName & r, const FSPath & f) : - env(e), - repository_name(r), - name("cran/" + cran_name_to_internal(strip_trailing_string(f.basename(), ".DESCRIPTION"))), - version("0", { }) - { - } - - Imp(const Environment * const e, const RepositoryName & c, const CRANPackageID * const r, const std::string & t) : - env(e), - repository_name(c), - name("cran/" + cran_name_to_internal(t)), - version(r->version()), - contained_in_key(std::make_shared<PackageIDKey>(e, "Contained", "Contained in", r, mkt_normal)) - { - } - }; -} - -CRANPackageID::CRANPackageID(const Environment * const env, const RepositoryName & r, const FSPath & f) : - _imp(env, r, f) -{ - Context context("When parsing file '" + stringify(f) + "' to create a CRAN Package ID:"); - - if (! f.stat().is_regular_file()) - { - add_mask(std::make_shared<BrokenMask>('B', "Broken", "DESCRIPTION file not a file")); - Log::get_instance()->message("cran.id.not_a_file", ll_warning, lc_context) << "Unexpected irregular file: '" << stringify(f) << "'"; - return; - } - - _imp->fs_location_key = std::make_shared<LiteralMetadataValueKey<FSPath> >("DescriptionFileLocation", "Description File Location", - mkt_internal, f); - add_metadata_key(_imp->fs_location_key); - - try - { - DescriptionFile file(f); - - std::string raw_name; - if (! file.get("Package").empty()) - { - Context local_context("When handling Package: key:"); - raw_name = file.get("Package"); - _imp->name = QualifiedPackageName(CategoryNamePart("cran"), PackageNamePart(cran_name_to_internal(raw_name))); - } - else if (! file.get("Bundle").empty()) - { - Context local_context("When handling Bundle: key:"); - raw_name = file.get("Bundle"); - _imp->name = QualifiedPackageName(CategoryNamePart("cran"), PackageNamePart(cran_name_to_internal(raw_name))); - } - else - { - Log::get_instance()->message("cran.id.broken", ll_warning, lc_context) << "No Package: or Bundle: key in '" << stringify(f) << "'"; - add_mask(std::make_shared<BrokenMask>('B', "Broken", "No Package: or Bundle: key")); - return; - } - - if (file.get("Version").empty()) - { - Context local_context("When handling Version: key:"); - Log::get_instance()->message("cran.id.broken", ll_warning, lc_context) << "No Version: key in '" << stringify(f) << "'"; - _imp->version = VersionSpec("0", { }); - add_mask(std::make_shared<BrokenMask>('B', "Broken", "No Version: key")); - return; - } - else - { - Context local_context("When handling Version: key:"); - _imp->version = VersionSpec(cran_version_to_internal(file.get("Version")), { }); - } - - if (! file.get("License").empty()) - { - /* License often isn't in the format the spec requires, so we can't parse it. */ - Context local_context("When handling License: key:"); - _imp->license_key = std::make_shared<LiteralMetadataValueKey<std::string>>("License", "License", mkt_dependencies, file.get("License")); - add_metadata_key(_imp->license_key); - } - - if (! file.get("URL").empty()) - { - /* URL is also in stupid formats */ - Context local_context("When handling URL: key:"); - _imp->url_key = std::make_shared<LiteralMetadataValueKey<std::string>>("URL", "URL", mkt_significant, file.get("URL")); - add_metadata_key(_imp->url_key); - } - - if (! file.get("Title").empty()) - { - Context local_context("When handling Title: key:"); - _imp->short_description_key = std::make_shared<LiteralMetadataValueKey<std::string>>("Title", "Title", mkt_significant, file.get("Title")); - add_metadata_key(_imp->short_description_key); - } - - if (! file.get("Description").empty()) - { - Context local_context("When handling Description: key:"); - _imp->long_description_key = std::make_shared<LiteralMetadataValueKey<std::string>>("Description", "Description", mkt_normal, file.get("Description")); - add_metadata_key(_imp->long_description_key); - } - else if (! file.get("BundleDescription").empty()) - { - Context local_context("When handling BundleDescription: key:"); - _imp->long_description_key = std::make_shared<LiteralMetadataValueKey<std::string>>("BundleDescription", "Bundle Description", - mkt_normal, file.get("BundleDescription")); - } - - if (! file.get("Date").empty()) - { - Context local_context("When handling Date: key:"); - /* no guarantee on the format */ - add_metadata_key(std::make_shared<LiteralMetadataValueKey<std::string>>("Date", "Date", mkt_normal, file.get("Date"))); - } - - if (! file.get("Author").empty()) - { - Context local_context("When handling Author: key:"); - add_metadata_key(std::make_shared<LiteralMetadataValueKey<std::string>>("Author", "Author", mkt_author, file.get("Author"))); - } - - if (! file.get("Maintainer").empty()) - { - Context local_context("When handling Maintainer: key:"); - add_metadata_key(std::make_shared<LiteralMetadataValueKey<std::string>>("Maintainer", "Maintainer", mkt_author, file.get("Maintainer"))); - } - - if (! file.get("Contains").empty()) - { - Context local_context("When handling Contains: key:"); - std::list<std::string> tokens; - tokenise_whitespace(file.get("Contains"), std::back_inserter(tokens)); - _imp->contains_key = std::make_shared<PackageIDSequenceKey>(_imp->env, "Contains", "Contains", mkt_normal); - add_metadata_key(_imp->contains_key); - for (std::list<std::string>::const_iterator t(tokens.begin()), t_end(tokens.end()) ; - t != t_end ; ++t) - { - if (*t != stringify(name().package())) - _imp->contains_key->push_back(std::make_shared<CRANPackageID>(_imp->env, r, this, *t)); - else - { - /* yay CRAN... */ - Log::get_instance()->message("cran.bundle.recursive", ll_qa, lc_context) - << "Bundle '" << stringify(*this) << "' contains itself, but is not a Klein bundle"; - } - } - } - - if (! file.get("Suggests").empty()) - { - Context local_context("When handling Suggests: key:"); - _imp->suggests_key = std::make_shared<DepKey>(_imp->env, "Suggests", "Suggests", file.get("Suggests"), - CRANPackageIDData::get_instance()->suggests_labels, mkt_dependencies); - add_metadata_key(_imp->suggests_key); - } - - if (! file.get("SystemRequirements").empty()) - { - Context local_context("When handling SystemRequirements: key:"); - add_metadata_key(std::make_shared<LiteralMetadataValueKey<std::string>>("SystemRequirements", "System Requirements", mkt_normal, - file.get("SystemRequirements"))); - } - - if (! file.get("Depends").empty()) - { - Context local_context("When handling Depends: key:"); - _imp->depends_key = std::make_shared<DepKey>(_imp->env, "Depends", "Depends", file.get("Depends") + ", R", - CRANPackageIDData::get_instance()->depends_labels, mkt_dependencies); - } - else - _imp->depends_key = std::make_shared<DepKey>(_imp->env, "Depends", "Depends", "R", - CRANPackageIDData::get_instance()->depends_labels, mkt_dependencies); - add_metadata_key(_imp->depends_key); - } - catch (const InternalError &) - { - throw; - } - catch (const Exception & e) - { - Log::get_instance()->message("cran.id.broken", ll_warning, lc_context) << "Broken CRAN description file '" << stringify(f) << "': '" - << e.message() << "' (" << e.what() << ")"; - add_mask(std::make_shared<BrokenMask>('B', "Broken", "Got exception '" + stringify(e.message()) + "' (" + e.what() + "')")); - } -} - -CRANPackageID::CRANPackageID(const Environment * const e, - const RepositoryName & c, const CRANPackageID * const r, const std::string & t) : - _imp(e, c, r, t) -{ - Context context("When creating contained ID '" + stringify(t) + "' in " + stringify(*r) + "':"); - - add_metadata_key(_imp->contained_in_key); -} - -CRANPackageID::~CRANPackageID() -{ -} - -void -CRANPackageID::need_keys_added() const -{ -} - -void -CRANPackageID::need_masks_added() const -{ -} - - -const QualifiedPackageName -CRANPackageID::name() const -{ - return _imp->name; -} - -const VersionSpec -CRANPackageID::version() const -{ - return _imp->version; -} - -const RepositoryName -CRANPackageID::repository_name() const -{ - return _imp->repository_name; -} - -const std::shared_ptr<const MetadataValueKey<std::shared_ptr<const PackageID> > > -CRANPackageID::virtual_for_key() const -{ - return std::shared_ptr<const MetadataValueKey<std::shared_ptr<const PackageID> > >(); -} - -const std::shared_ptr<const MetadataCollectionKey<KeywordNameSet> > -CRANPackageID::keywords_key() const -{ - return std::shared_ptr<const MetadataCollectionKey<KeywordNameSet> >(); -} - -const std::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> > -CRANPackageID::provide_key() const -{ - return std::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> >(); -} - -const std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > -CRANPackageID::dependencies_key() const -{ - return std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >(); -} - -const std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > -CRANPackageID::build_dependencies_key() const -{ - return std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >(); -} - -const std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > -CRANPackageID::run_dependencies_key() const -{ - return std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >(); -} - -const std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > -CRANPackageID::post_dependencies_key() const -{ - return std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >(); -} - -const std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > -CRANPackageID::suggested_dependencies_key() const -{ - return std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >(); -} - -const std::shared_ptr<const MetadataSpecTreeKey<FetchableURISpecTree> > -CRANPackageID::fetches_key() const -{ - return std::shared_ptr<const MetadataSpecTreeKey<FetchableURISpecTree> >(); -} - -const std::shared_ptr<const MetadataSpecTreeKey<SimpleURISpecTree> > -CRANPackageID::homepage_key() const -{ - return std::shared_ptr<const MetadataSpecTreeKey<SimpleURISpecTree> >(); -} - -const std::shared_ptr<const MetadataValueKey<std::string> > -CRANPackageID::short_description_key() const -{ - return _imp->short_description_key; -} - -const std::shared_ptr<const MetadataValueKey<std::string> > -CRANPackageID::long_description_key() const -{ - return _imp->long_description_key; -} - -const std::shared_ptr<const MetadataValueKey<std::shared_ptr<const Contents> > > -CRANPackageID::contents_key() const -{ - return std::shared_ptr<const MetadataValueKey<std::shared_ptr<const Contents> > >(); -} - -const std::shared_ptr<const MetadataTimeKey> -CRANPackageID::installed_time_key() const -{ - return std::shared_ptr<const MetadataTimeKey>(); -} - -const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > -CRANPackageID::from_repositories_key() const -{ - return std::shared_ptr<const MetadataCollectionKey<Set<std::string> > >(); -} - -const std::shared_ptr<const MetadataValueKey<SlotName> > -CRANPackageID::slot_key() const -{ - return make_null_shared_ptr(); -} - -std::size_t -CRANPackageID::extra_hash_value() const -{ - return 0; -} - -bool -CRANPackageID::arbitrary_less_than_comparison(const PackageID &) const -{ - return false; -} - -std::shared_ptr<const Set<std::string> > -CRANPackageID::breaks_portage() const -{ - std::shared_ptr<Set<std::string> > why(std::make_shared<Set<std::string>>()); - why->insert("format"); - return why; -} - -const std::string -CRANPackageID::canonical_form(const PackageIDCanonicalForm f) const -{ - switch (f) - { - case idcf_full: - return stringify(_imp->name) + "-" + stringify(_imp->version) + "::" + stringify(_imp->repository_name); - - case idcf_version: - return stringify(_imp->version); - - case idcf_no_version: - return stringify(_imp->name) + "::" + stringify(_imp->repository_name); - - case idcf_no_name: - return stringify(version()) + "::" + stringify(_imp->repository_name); - - case last_idcf: - break; - } - - throw InternalError(PALUDIS_HERE, "Bad PackageIDCanonicalForm"); -} - -PackageDepSpec -CRANPackageID::uniquely_identifying_spec() const -{ - return parse_user_package_dep_spec("=" + stringify(name()) + "-" + stringify(version()) + "::" + stringify(_imp->repository_name), - _imp->env, { }); -} - -namespace -{ - struct SupportsActionQuery - { - bool is_installed; - - bool visit(const SupportsActionTest<FetchAction> &) const - { - return ! is_installed; - } - - bool visit(const SupportsActionTest<PretendFetchAction> &) const - { - return ! is_installed; - } - - bool visit(const SupportsActionTest<InstallAction> &) const - { - return ! is_installed; - } - - bool visit(const SupportsActionTest<ConfigAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<PretendAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<UninstallAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<InfoAction> &) const - { - return false; - } - }; -} - -bool -CRANPackageID::supports_action(const SupportsActionTestBase & b) const -{ - auto repo(_imp->env->package_database()->fetch_repository(repository_name())); - SupportsActionQuery q{bool(repo->installed_root_key())}; - return b.accept_returning<bool>(q); -} - -void -CRANPackageID::perform_action(Action & a) const -{ - throw ActionFailedError("Unsupported action '" + a.simple_name() + "'"); -} - -const std::shared_ptr<const MetadataCollectionKey<PackageIDSequence> > -CRANPackageID::contains_key() const -{ - return _imp->contains_key; -} - -const std::shared_ptr<const MetadataValueKey<std::shared_ptr<const PackageID> > > -CRANPackageID::contained_in_key() const -{ - return _imp->contained_in_key; -} - -const std::shared_ptr<const MetadataValueKey<FSPath> > -CRANPackageID::fs_location_key() const -{ - return _imp->fs_location_key; -} - -const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > -CRANPackageID::behaviours_key() const -{ - return make_null_shared_ptr(); -} - -const std::shared_ptr<const MetadataValueKey<std::shared_ptr<const Choices> > > -CRANPackageID::choices_key() const -{ - return std::shared_ptr<const MetadataValueKey<std::shared_ptr<const Choices> > >(); -} - diff --git a/paludis/repositories/cran/cran_package_id.hh b/paludis/repositories/cran/cran_package_id.hh deleted file mode 100644 index 6770d77a0..000000000 --- a/paludis/repositories/cran/cran_package_id.hh +++ /dev/null @@ -1,94 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006 Danny van Dyk - * Copyright (c) 2007, 2008, 2009, 2010, 2011 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_CRAN_PACKAGE_ID_HH -#define PALUDIS_GUARD_PALUDIS_CRAN_PACKAGE_ID_HH 1 - -#include <paludis/package_id.hh> - -namespace paludis -{ - class CRANRepository; - class CRANInstalledRepository; - - namespace cranrepository - { - class PALUDIS_VISIBLE CRANPackageID : - public PackageID, - public std::enable_shared_from_this<CRANPackageID> - { - private: - Pimp<CRANPackageID> _imp; - - protected: - virtual void need_keys_added() const; - virtual void need_masks_added() const; - - public: - CRANPackageID(const Environment * const, const RepositoryName &, - const FSPath &); - CRANPackageID(const Environment * const, const RepositoryName &, - const CRANPackageID * const, const std::string &); - ~CRANPackageID(); - - virtual const std::string canonical_form(const PackageIDCanonicalForm) const; - - virtual const QualifiedPackageName name() const; - virtual const VersionSpec version() const; - virtual const RepositoryName repository_name() 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 MetadataValueKey<std::shared_ptr<const Choices> > > choices_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> > 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<DependencySpecTree> > 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 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<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 MetadataCollectionKey<Set<std::string> > > behaviours_key() const; - virtual const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > from_repositories_key() const; - - virtual bool supports_action(const SupportsActionTestBase &) const PALUDIS_ATTRIBUTE((warn_unused_result)); - virtual void perform_action(Action &) const PALUDIS_ATTRIBUTE((noreturn)); - - virtual std::shared_ptr<const Set<std::string> > breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual bool arbitrary_less_than_comparison(const PackageID &) const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual std::size_t extra_hash_value() const - PALUDIS_ATTRIBUTE((warn_unused_result)); - }; - } -} - -#endif diff --git a/paludis/repositories/cran/cran_repository.cc b/paludis/repositories/cran/cran_repository.cc deleted file mode 100644 index 7920c2dd2..000000000 --- a/paludis/repositories/cran/cran_repository.cc +++ /dev/null @@ -1,596 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 2007 Danny van Dyk - * Copyright (c) 2007, 2008, 2009, 2010, 2011 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/util/config_file.hh> -#include <paludis/dep_spec.hh> -#include <paludis/environment.hh> -#include <paludis/action.hh> -#include <paludis/metadata_key.hh> -#include <paludis/literal_metadata_key.hh> -#include <paludis/repositories/cran/cran_package_id.hh> -#include <paludis/repositories/cran/cran_repository.hh> -#include <paludis/util/set.hh> -#include <paludis/util/sequence.hh> -#include <paludis/util/options.hh> -#include <paludis/util/join.hh> -#include <paludis/util/log.hh> -#include <paludis/util/map.hh> -#include <paludis/util/mutex.hh> -#include <paludis/util/pimp-impl.hh> -#include <paludis/util/stringify.hh> -#include <paludis/util/strip.hh> -#include <paludis/util/system.hh> -#include <paludis/util/tokeniser.hh> -#include <paludis/util/is_file_with_extension.hh> -#include <paludis/util/hashes.hh> -#include <paludis/util/make_named_values.hh> -#include <paludis/util/wrapped_output_iterator.hh> -#include <paludis/util/wrapped_forward_iterator.hh> -#include <paludis/util/extract_host_from_url.hh> -#include <paludis/util/make_null_shared_ptr.hh> -#include <paludis/util/process.hh> -#include <paludis/util/fs_iterator.hh> -#include <paludis/output_manager.hh> -#include <paludis/syncer.hh> -#include <paludis/hook.hh> -#include <unordered_map> -#include <functional> -#include <algorithm> - -using namespace paludis; - -typedef std::unordered_map< - QualifiedPackageName, - std::shared_ptr<const cranrepository::CRANPackageID>, - Hash<QualifiedPackageName> > - IDMap; - -namespace paludis -{ - template <> - struct Imp<CRANRepository> - { - CRANRepositoryParams params; - - mutable std::shared_ptr<Mutex> big_nasty_mutex; - mutable bool has_ids; - mutable IDMap ids; - - Imp(const CRANRepositoryParams &, const std::shared_ptr<Mutex> &); - ~Imp(); - - std::shared_ptr<const MetadataValueKey<FSPath> > location_key; - std::shared_ptr<const MetadataValueKey<FSPath> > distdir_key; - std::shared_ptr<const MetadataValueKey<std::string> > format_key; - std::shared_ptr<const MetadataValueKey<FSPath> > builddir_key; - std::shared_ptr<const MetadataValueKey<FSPath> > library_key; - std::shared_ptr<const MetadataCollectionKey<Map<std::string, std::string> > > sync_key; - std::shared_ptr<Map<std::string, std::string> > sync_hosts; - std::shared_ptr<const MetadataCollectionKey<Map<std::string, std::string> > > sync_host_key; - }; -} - -Imp<CRANRepository>::Imp(const CRANRepositoryParams & p, const std::shared_ptr<Mutex> & m) : - params(p), - big_nasty_mutex(m), - has_ids(false), - location_key(std::make_shared<LiteralMetadataValueKey<FSPath> >("location", "location", mkt_significant, params.location())), - distdir_key(std::make_shared<LiteralMetadataValueKey<FSPath> >("distdir", "distdir", mkt_normal, params.distdir())), - format_key(std::make_shared<LiteralMetadataValueKey<std::string> >("format", "format", mkt_significant, "cran")), - builddir_key(std::make_shared<LiteralMetadataValueKey<FSPath> >("builddir", "builddir", mkt_normal, params.builddir())), - library_key(std::make_shared<LiteralMetadataValueKey<FSPath> >("library", "library", mkt_normal, params.library())), - sync_key(std::make_shared<LiteralMetadataStringStringMapKey>("sync", "sync", mkt_normal, params.sync())), - sync_hosts(std::make_shared<Map<std::string, std::string> >()), - sync_host_key(std::make_shared<LiteralMetadataStringStringMapKey>("sync_host", "sync_host", mkt_internal, sync_hosts)) -{ - for (auto i(params.sync()->begin()), i_end(params.sync()->end()) ; - i != i_end ; ++i) - sync_hosts->insert(i->first, extract_host_from_url(i->second)); -} - -Imp<CRANRepository>::~Imp() -{ -} - - -CRANRepository::CRANRepository(const CRANRepositoryParams & p) : - Repository( - p.environment(), - CRANRepository::fetch_repo_name(stringify(p.location())), - 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) - )), - _imp(p, std::make_shared<Mutex>()) -{ - _add_metadata_keys(); -} - -CRANRepository::~CRANRepository() -{ -} - -void -CRANRepository::_add_metadata_keys() const -{ - clear_metadata_keys(); - add_metadata_key(_imp->location_key); - add_metadata_key(_imp->distdir_key); - add_metadata_key(_imp->format_key); - add_metadata_key(_imp->builddir_key); - add_metadata_key(_imp->library_key); - add_metadata_key(_imp->sync_key); - add_metadata_key(_imp->sync_host_key); -} - -bool -CRANRepository::has_category_named(const CategoryNamePart & c, const RepositoryContentMayExcludes &) const -{ - return "cran" == stringify(c); -} - -bool -CRANRepository::has_package_named(const QualifiedPackageName & q, const RepositoryContentMayExcludes & x) const -{ - Context context("When checking for package '" + stringify(q) + "' in " + stringify(name()) + ":"); - Lock l(*_imp->big_nasty_mutex); - - if (! has_category_named(q.category(), x)) - return false; - - need_ids(); - return _imp->ids.end() != _imp->ids.find(q); -} - -std::shared_ptr<const CategoryNamePartSet> -CRANRepository::category_names(const RepositoryContentMayExcludes &) const -{ - Context context("When fetching category names in " + stringify(name()) + ":"); - Lock l(*_imp->big_nasty_mutex); - - std::shared_ptr<CategoryNamePartSet> result(std::make_shared<CategoryNamePartSet>()); - result->insert(CategoryNamePart("cran")); - - return result; -} - -std::shared_ptr<const QualifiedPackageNameSet> -CRANRepository::package_names(const CategoryNamePart & c, const RepositoryContentMayExcludes & x) const -{ - Context context("When fetching package names in category '" + stringify(c) - + "' in " + stringify(name()) + ":"); - Lock l(*_imp->big_nasty_mutex); - - std::shared_ptr<QualifiedPackageNameSet> result(std::make_shared<QualifiedPackageNameSet>()); - if (! has_category_named(c, x)) - return result; - - need_ids(); - - std::transform(_imp->ids.begin(), _imp->ids.end(), result->inserter(), - std::mem_fn(&std::pair<const QualifiedPackageName, std::shared_ptr<const cranrepository::CRANPackageID> >::first)); - - return result; -} - -std::shared_ptr<const PackageIDSequence> -CRANRepository::package_ids(const QualifiedPackageName & n, const RepositoryContentMayExcludes & x) const -{ - Context context("When fetching versions of '" + stringify(n) + "' in " - + stringify(name()) + ":"); - Lock l(*_imp->big_nasty_mutex); - - std::shared_ptr<PackageIDSequence> result(std::make_shared<PackageIDSequence>()); - if (! has_package_named(n, x)) - return result; - - need_ids(); - - IDMap::const_iterator i(_imp->ids.find(n)); - if (i != _imp->ids.end()) - result->push_back(i->second); - return result; -} - -void -CRANRepository::need_ids() const -{ - Lock l(*_imp->big_nasty_mutex); - - if (_imp->has_ids) - return; - - Context context("When loading IDs for " + stringify(name()) + ":"); - - for (FSIterator d(_imp->params.location(), { fsio_inode_sort }), d_end ; d != d_end ; ++d) - if (is_file_with_extension(*d, ".DESCRIPTION", { })) - { - std::shared_ptr<cranrepository::CRANPackageID> id(std::make_shared<cranrepository::CRANPackageID>(_imp->params.environment(), - name(), *d)); - if (! _imp->ids.insert(std::make_pair(id->name(), id)).second) - Log::get_instance()->message("cran.id.duplicate", ll_warning, lc_context) - << "Couldn't insert package '" << *id << "' due to name collision"; - - if (id->contains_key()) - for (PackageIDSequence::ConstIterator i(id->contains_key()->value()->begin()), - i_end(id->contains_key()->value()->end()) ; i != i_end ; ++i) - if (! _imp->ids.insert(std::make_pair((*i)->name(), - std::static_pointer_cast<const cranrepository::CRANPackageID>(*i))).second) - Log::get_instance()->message("cran.id.duplicate", ll_warning, lc_context) << "Couldn't insert package '" << **i - << "', which is contained in '" << *id << "', due to name collision"; - } - - _imp->has_ids = true; -} - -RepositoryName -CRANRepository::fetch_repo_name(const std::string & location) -{ - std::string modified_location(FSPath(location).basename()); - std::replace(modified_location.begin(), modified_location.end(), '/', '-'); - if (modified_location == "cran") - return RepositoryName("cran"); - else - return RepositoryName("cran-" + modified_location); -} - -#if 0 -void -CRANRepository::do_install(const std::shared_ptr<const PackageID> & id_uncasted, const InstallOptions & o) const -{ - if (id_uncasted->repository().get() != this) - throw PackageInstallActionError("Couldn't install '" + stringify(*id_uncasted) + "' using repository '" + - stringify(name()) + "'"); - - const std::shared_ptr<const CRANPackageID> id(std::static_pointer_cast<const CRANPackageID>(id_uncasted)); - if (id->bundle_member_key()) - return; - - std::shared_ptr<const FSEntrySequence> bashrc_files(_imp->params.environment->bashrc_files()); - - Command cmd(Command(LIBEXECDIR "/paludis/cran.bash fetch") - .with_setenv("CATEGORY", "cran") - .with_setenv("DISTDIR", stringify(_imp->params.distdir)) - .with_setenv("DISTFILE", id->native_package() + "_" + id->native_version() + ".tar.gz") - .with_setenv("PN", id->native_package()) - .with_setenv("PV", id->native_version()) - .with_setenv("PALUDIS_CRAN_MIRRORS", _imp->params.mirror) - .with_setenv("PALUDIS_EBUILD_DIR", std::string(LIBEXECDIR "/paludis/")) - .with_setenv("PALUDIS_EBUILD_LOG_LEVEL", stringify(Log::get_instance()->log_level())) - .with_setenv("PALUDIS_BASHRC_FILES", join(bashrc_files->begin(), bashrc_files->end(), " "))); - - if (0 != run_command(cmd)) - throw PackageInstallActionError("Couldn't fetch sources for '" + stringify(*id) + "'"); - - if (o.fetch_only) - return; - - FSPath image(_imp->params.buildroot / stringify(id->native_package()) / "image"); - FSPath workdir(_imp->params.buildroot / stringify(id->native_package()) / "work"); - - if (! o.destination) - throw PackageInstallActionError("Can't merge '" + stringify(*id) + "' because no destination was provided."); - - cmd = Command(LIBEXECDIR "/paludis/cran.bash clean install") - .with_sandbox() - .with_setenv("CATEGORY", "cran") - .with_setenv("DISTDIR", stringify(_imp->params.distdir)) - .with_setenv("DISTFILE", id->native_package() + "_" + id->native_version() + ".tar.gz") - .with_setenv("IMAGE", stringify(image)) - .with_setenv("IS_BUNDLE", (id->bundle_key() ? "yes" : "")) - .with_setenv("LOCATION", stringify(_imp->params.location)) - .with_setenv("PN", id->native_package()) - .with_setenv("PV", id->native_version()) - .with_setenv("PALUDIS_CRAN_LIBRARY", stringify(_imp->params.library)) - .with_setenv("PALUDIS_EBUILD_DIR", std::string(LIBEXECDIR "/paludis/")) - .with_setenv("PALUDIS_EBUILD_LOG_LEVEL", stringify(Log::get_instance()->log_level())) - .with_setenv("PALUDIS_BASHRC_FILES", join(bashrc_files->begin(), bashrc_files->end(), " ")) - .with_setenv("ROOT", stringify(o.destination->installed_interface->root())) - .with_setenv("WORKDIR", stringify(workdir)); - - if (0 != run_command(cmd)) - throw PackageInstallActionError("Couldn't install '" + stringify(*id) + "' to '" + - stringify(image) + "'"); - - MergeOptions m(id, image, FSPath("/dev/null")); - - if (! o.destination->destination_interface) - throw PackageInstallActionError("Couldn't install '" + stringify(*id) + "' to '" + - stringify(o.destination->name()) + "' because it does not provide destination_interface"); - - if (! o.destination->installed_interface) - throw PackageInstallActionError("Couldn't install '" + stringify(*id) + "' to '" + - stringify(o.destination->name()) + "' because it does not provide installed_interface"); - - o.destination->destination_interface->merge(m); - - cmd = Command(LIBEXECDIR "/paludis/cran.bash clean") - .with_setenv("IMAGE", stringify(image)) - .with_setenv("PN", id->native_package()) - .with_setenv("PV", id->native_version()) - .with_setenv("PALUDIS_CRAN_LIBRARY", stringify(_imp->params.library)) - .with_setenv("PALUDIS_EBUILD_DIR", std::string(LIBEXECDIR "/paludis/")) - .with_setenv("PALUDIS_EBUILD_LOG_LEVEL", stringify(Log::get_instance()->log_level())) - .with_setenv("PALUDIS_BASHRC_FILES", join(bashrc_files->begin(), bashrc_files->end(), " ")) - .with_setenv("ROOT", stringify(o.destination->installed_interface->root())) - .with_setenv("WORKDIR", stringify(workdir)) - .with_setenv("REPOSITORY", stringify(name())); - - if (0 != run_command(cmd)) - throw PackageInstallActionError("Couldn't clean '" + stringify(*id) + "'"); - - return; -} -#endif - -bool -CRANRepository::sync( - const std::string & suffix, - const std::shared_ptr<OutputManager> & output_manager) const -{ - std::string sync_uri; - if (_imp->params.sync()->end() != _imp->params.sync()->find(suffix)) - sync_uri = _imp->params.sync()->find(suffix)->second; - - if (sync_uri.empty()) - return false; - - Context context("When syncing repository '" + stringify(name()) + "':"); - Lock l(*_imp->big_nasty_mutex); - - std::string cmd("rsync --delete --recursive --progress --exclude \"*.html\" --exclude \"*.INDEX\" '" + - sync_uri + "/src/contrib/Descriptions/' ./"); - - Process command1((ProcessCommand(cmd))); - command1.chdir(_imp->params.location()); - - command1 - .capture_stdout(output_manager->stdout_stream()) - .capture_stderr(output_manager->stderr_stream()) - .use_ptys() - ; - - if (0 != command1.run().wait()) - throw SyncFailedError(stringify(_imp->params.location()), sync_uri); - - cmd = "rsync --progress '" + sync_uri + "/src/contrib/PACKAGES' ./"; - - Process command2((ProcessCommand(cmd))); - command2.chdir(_imp->params.location()); - - command2 - .capture_stdout(output_manager->stdout_stream()) - .capture_stderr(output_manager->stderr_stream()) - .use_ptys() - ; - - if (0 != command2.run().wait()) - throw SyncFailedError(stringify(_imp->params.location()), sync_uri); - - cmd = "rsync --progress '" + sync_uri + "/CRAN_mirrors.csv' ./"; - - Process command3((ProcessCommand(cmd))); - command3.chdir(_imp->params.location()); - - command3 - .capture_stdout(output_manager->stdout_stream()) - .capture_stderr(output_manager->stderr_stream()) - .use_ptys() - ; - - if (0 != command3.run().wait()) - throw SyncFailedError(stringify(_imp->params.location()), sync_uri); - - return true; -} - -std::shared_ptr<Repository> -CRANRepository::repository_factory_create( - Environment * const env, - const std::function<std::string (const std::string &)> & f) -{ - Context context("When making CRAN repository from repo_file '" + f("repo_file") + "':"); - - std::string location(f("location")); - if (location.empty()) - throw CRANRepositoryConfigurationError("Key 'location' not specified or empty"); - - std::string library(f("library")); - if (library.empty()) - throw CRANRepositoryConfigurationError("Key 'library' not specified or empty"); - - std::string distdir(f("distdir")); - if (distdir.empty()) - distdir = location + "/distfiles"; - - std::string mirror(f("mirror")); - if (mirror.empty()) - mirror = "http://cran.r-project.org/"; - - auto sync(std::make_shared<Map<std::string, std::string> >()); - std::string empty_sync(f("sync")); - if (empty_sync.empty()) - empty_sync = "rsync://cran.r-project.org/CRAN"; - sync->insert("", empty_sync); - - std::string builddir(f("builddir")); - if (builddir.empty()) - builddir = "/var/tmp/paludis"; - - return std::make_shared<CRANRepository>(make_named_values<CRANRepositoryParams>( - n::builddir() = builddir, - n::distdir() = distdir, - n::environment() = env, - n::library() = library, - n::location() = location, - n::mirror() = mirror, - n::sync() = sync - )); -} - -RepositoryName -CRANRepository::repository_factory_name( - const Environment * const, - const std::function<std::string (const std::string &)> & f) -{ - if (f("location").empty()) - throw CRANRepositoryConfigurationError("Key 'location' not specified or empty"); - return fetch_repo_name(f("location")); -} - -std::shared_ptr<const RepositoryNameSet> -CRANRepository::repository_factory_dependencies( - const Environment * const, - const std::function<std::string (const std::string &)> &) -{ - return std::make_shared<RepositoryNameSet>(); -} - -CRANRepositoryConfigurationError::CRANRepositoryConfigurationError( - const std::string & msg) throw () : - ConfigurationError("CRAN repository configuration error: " + msg) -{ -} - - -void -CRANRepository::invalidate() -{ - _imp.reset(new Imp<CRANRepository>(_imp->params, _imp->big_nasty_mutex)); - _add_metadata_keys(); -} - -void -CRANRepository::invalidate_masks() -{ -} - -namespace -{ - struct SupportsActionQuery - { - bool visit(const SupportsActionTest<InstallAction> &) const - { - return true; - } - - bool visit(const SupportsActionTest<ConfigAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<PretendAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<FetchAction> &) const - { - return true; - } - - bool visit(const SupportsActionTest<PretendFetchAction> &) const - { - return true; - } - - bool visit(const SupportsActionTest<UninstallAction> &) const - { - return false; - } - - bool visit(const SupportsActionTest<InfoAction> &) const - { - return false; - } - }; -} - -const bool -CRANRepository::is_unimportant() const -{ - return false; -} - -bool -CRANRepository::some_ids_might_support_action(const SupportsActionTestBase & a) const -{ - SupportsActionQuery q; - return a.accept_returning<bool>(q); -} - -bool -CRANRepository::some_ids_might_not_be_masked() const -{ - return true; -} - -void -CRANRepository::need_keys_added() const -{ -} - -const std::shared_ptr<const MetadataValueKey<std::string> > -CRANRepository::format_key() const -{ - return _imp->format_key; -} - -const std::shared_ptr<const MetadataValueKey<FSPath> > -CRANRepository::location_key() const -{ - return _imp->location_key; -} - -const std::shared_ptr<const MetadataValueKey<FSPath> > -CRANRepository::installed_root_key() const -{ - return std::shared_ptr<const MetadataValueKey<FSPath> >(); -} - -const std::shared_ptr<const MetadataCollectionKey<Map<std::string, std::string> > > -CRANRepository::sync_host_key() const -{ - return _imp->sync_host_key; -} - -void -CRANRepository::populate_sets() const -{ -} - -HookResult -CRANRepository::perform_hook( - const Hook &, - const std::shared_ptr<OutputManager> &) -{ - return make_named_values<HookResult>(n::max_exit_status() = 0, n::output() = ""); -} - -const std::shared_ptr<const MetadataValueKey<std::string> > -CRANRepository::accept_keywords_key() const -{ - return make_null_shared_ptr(); -} - diff --git a/paludis/repositories/cran/cran_repository.hh b/paludis/repositories/cran/cran_repository.hh deleted file mode 100644 index 68217e95c..000000000 --- a/paludis/repositories/cran/cran_repository.hh +++ /dev/null @@ -1,193 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006 Danny van Dyk - * Copyright (c) 2007, 2008, 2009, 2010, 2011 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_CRAN_REPOSITORY_HH -#define PALUDIS_GUARD_PALUDIS_CRAN_REPOSITORY_HH 1 - -#include <paludis/repository.hh> -#include <paludis/util/pimp.hh> -#include <paludis/environment-fwd.hh> -#include <memory> -#include <string> - -/** \file - * Declaration for the CRANRepository class. - * - * \ingroup grpcranrepository - */ - -namespace paludis -{ - class PackageDatabase; - - namespace n - { - typedef Name<struct name_builddir> builddir; - typedef Name<struct name_distdir> distdir; - typedef Name<struct name_environment> environment; - typedef Name<struct name_library> library; - typedef Name<struct name_location> location; - typedef Name<struct name_mirror> mirror; - typedef Name<struct name_sync> sync; - } - - /** - * Parameters used to create a CRANRepository - * - * \see CRANRepository - * \ingroup grpcranrepository - * \nosubgrouping - */ - struct CRANRepositoryParams - { - NamedValue<n::builddir, FSPath> builddir; - NamedValue<n::distdir, FSPath> distdir; - NamedValue<n::environment, const Environment *> environment; - NamedValue<n::library, FSPath> library; - NamedValue<n::location, FSPath> location; - NamedValue<n::mirror, std::string> mirror; - NamedValue<n::sync, std::shared_ptr<Map<std::string, std::string> > > sync; - }; - - /** - * A CRANRepository is a Repository that handles the layout used by - * the GNU R project for the Comprehensive R Archive Network - * - * \ingroup grpcranrepository - */ - class PALUDIS_VISIBLE CRANRepository : - public Repository, - public std::enable_shared_from_this<CRANRepository> - { - private: - Pimp<CRANRepository> _imp; - - void _add_metadata_keys() const; - - void need_ids() const; - - protected: - virtual void need_keys_added() const; - - protected: - /** - * Try to get the repository name for a particular repository. - */ - static RepositoryName fetch_repo_name(const std::string & location); - - public: - /** - * Constructor. - */ - CRANRepository(const CRANRepositoryParams &); - - ///\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 &)> &); - - ///\} - - /** - * Destructor. - */ - virtual ~CRANRepository(); - - virtual void invalidate(); - virtual void invalidate_masks(); - - /* RepositorySyncableInterface */ - - virtual bool sync(const std::string &, const std::shared_ptr<OutputManager> & output_deviant) const; - - /* Repository */ - - virtual std::shared_ptr<const QualifiedPackageNameSet> package_names( - const CategoryNamePart &, const RepositoryContentMayExcludes &) const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual std::shared_ptr<const CategoryNamePartSet> category_names(const RepositoryContentMayExcludes &) const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual bool has_package_named(const QualifiedPackageName &, const RepositoryContentMayExcludes &) const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual bool has_category_named(const CategoryNamePart &, const RepositoryContentMayExcludes &) const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual std::shared_ptr<const PackageIDSequence> package_ids( - const QualifiedPackageName &, const RepositoryContentMayExcludes &) const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual const bool is_unimportant() const; - - virtual bool some_ids_might_support_action(const SupportsActionTestBase &) const; - - virtual bool some_ids_might_not_be_masked() 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 MetadataCollectionKey<Map<std::string, std::string> > > sync_host_key() const; - - ///\name Set methods - ///\{ - - virtual void populate_sets() const; - - ///\} - - virtual HookResult perform_hook( - const Hook & hook, - const std::shared_ptr<OutputManager> &); - }; - - /** - * Thrown if invalid parameters are provided for - * CRANRepository::make_cran_repository. - * - * \ingroup grpexceptions - * \ingroup grpcranrepository - */ - class PALUDIS_VISIBLE CRANRepositoryConfigurationError : - public ConfigurationError - { - public: - /** - * Constructor. - */ - CRANRepositoryConfigurationError(const std::string & msg) throw (); - }; -} - -#endif diff --git a/paludis/repositories/cran/cran_repository_TEST.cc b/paludis/repositories/cran/cran_repository_TEST.cc deleted file mode 100644 index 144b9fba7..000000000 --- a/paludis/repositories/cran/cran_repository_TEST.cc +++ /dev/null @@ -1,91 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006 Danny van Dyk - * Copyright (c) 2007, 2008, 2010, 2011 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/dep_spec.hh> -#include <paludis/dep_spec_flattener.hh> -#include <paludis/repositories/cran/cran_dep_parser.hh> -#include <paludis/repositories/cran/cran_package_id.hh> -#include <paludis/repositories/cran/cran_repository.hh> -#include <paludis/environments/test/test_environment.hh> -#include <paludis/util/system.hh> -#include <paludis/util/map.hh> -#include <paludis/util/wrapped_forward_iterator.hh> -#include <test/test_framework.hh> -#include <test/test_runner.hh> - -using namespace test; -using namespace paludis; - -namespace -{ - std::string from_keys(const std::shared_ptr<const Map<std::string, std::string> > & m, - const std::string & k) - { - Map<std::string, std::string>::ConstIterator mm(m->find(k)); - if (m->end() == mm) - return ""; - else - return mm->second; - } -} - -namespace test_cases -{ - struct CRANRepositoryPackagesTest : TestCase - { - CRANRepositoryPackagesTest() : TestCase("PACKAGES") { } - - void run() - { - TestEnvironment env; - std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>()); - keys->insert("format", "cran"); - keys->insert("library", "cran_repository_TEST_dir/library"); - keys->insert("location", "cran_repository_TEST_dir/repo1"); - keys->insert("builddir", "cran_repository_TEST_dir/tmp"); - std::shared_ptr<Repository> repo(CRANRepository::repository_factory_create(&env, - std::bind(from_keys, keys, std::placeholders::_1))); - TEST_CHECK(repo->has_category_named(CategoryNamePart("cran"), { })); - TEST_CHECK(repo->has_package_named(QualifiedPackageName("cran/testpackage1"), { })); - TEST_CHECK(repo->has_package_named(QualifiedPackageName("cran/testpackage2"), { })); - } - } test_cran_repository_packages; - - struct CRANRepositoryBundleTest: TestCase - { - CRANRepositoryBundleTest() : TestCase("Bundle") { } - - void run() - { - TestEnvironment env; - std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>()); - keys->insert("format", "cran"); - keys->insert("library", "cran_repository_TEST_dir/library"); - keys->insert("location", "cran_repository_TEST_dir/repo2"); - keys->insert("builddir", "cran_repository_TEST_dir/tmp"); - std::shared_ptr<Repository> repo(CRANRepository::repository_factory_create(&env, - std::bind(from_keys, keys, std::placeholders::_1))); - TEST_CHECK(repo->has_package_named(QualifiedPackageName("cran/testbundle"), { })); - TEST_CHECK(repo->has_package_named(QualifiedPackageName("cran/bundlepkg1"), { })); - TEST_CHECK(repo->has_package_named(QualifiedPackageName("cran/bundlepkg2"), { })); - } - } test_cran_repository_bundle; -} - diff --git a/paludis/repositories/cran/cran_repository_TEST_cleanup.sh b/paludis/repositories/cran/cran_repository_TEST_cleanup.sh deleted file mode 100755 index d30492240..000000000 --- a/paludis/repositories/cran/cran_repository_TEST_cleanup.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# vim: set ft=sh sw=4 sts=4 et : - -if [ -d cran_repository_TEST_dir ] ; then - rm -fr cran_repository_TEST_dir -else - true -fi diff --git a/paludis/repositories/cran/cran_repository_TEST_setup.sh b/paludis/repositories/cran/cran_repository_TEST_setup.sh deleted file mode 100755 index 93fdbee71..000000000 --- a/paludis/repositories/cran/cran_repository_TEST_setup.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/sh -# vim: set ft=sh sw=4 sts=4 et : - -mkdir cran_repository_TEST_dir || exit 1 -cd cran_repository_TEST_dir || exit 1 - -# repo1 -mkdir -p repo1 -cat <<EOF >> repo1/PACKAGES -Package: testpackage1 -Version: 2006.05.08 -Title: Test on a well formed PACKAGES file -Depends: R (>= 2.0.0) - - -Package: testpackage2 -Version: 2006.05.08 -Title: Test on a well formed PACKAGES file -EOF -cat <<EOF >> repo1/testpackage1.DESCRIPTION -Package: testpackage1 -Version: 2006.05.08 -Title: Test on a well formed PACKAGES file -Depends: R (>= 2.0.0) -Description: This description - spans - multiple lines without - trailing backslashes or leading tabs :-/ -License: Some weirdo license string -Packaged: Mon May 08 12:00:00 2006; kugelfang -EOF -cat <<EOF >> repo1/testpackage2.DESCRIPTION -Package: testpackage2 -Version: 1 -Title: 2nd Test Packages -Depends: R, testpackage1 -License: Another weirdo license string -Packaged: Mon May 08 22:00:00 2006; kugelfang -EOF - -mkdir -p repo2 -cat <<EOF >> repo2/PACKAGES -Package: testbundle -Version: 1 -Title: Testbundle for bundlepkg1 and bundlepkg2 -Bundle: testbundle -Contains: bundlepkg1 bundlepkg2 -EOF -cat <<EOF >> repo2/testbundle.DESCRIPTION -Bundle: testbundle -Version: 1 -Date: 21 May 2006 -Title: Testbundle for bundlepkg1 and bundlepkg2 -Contains: bundlepkg1 bundlepkg2 -License: Weird obfuscation of GPL -Packaged: Sun May 21 12:34:56 2006; kugelfang -EOF diff --git a/paludis/repositories/cran/description_file.cc b/paludis/repositories/cran/description_file.cc deleted file mode 100644 index 919fb6298..000000000 --- a/paludis/repositories/cran/description_file.cc +++ /dev/null @@ -1,114 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2008, 2010, 2011 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 "description_file.hh" -#include <paludis/util/pimp-impl.hh> -#include <paludis/util/log.hh> -#include <paludis/util/strip.hh> -#include <paludis/util/stringify.hh> -#include <sstream> -#include <istream> -#include <map> - -using namespace paludis; -using namespace paludis::cranrepository; - -namespace paludis -{ - template <> - struct Imp<DescriptionFile> - { - std::map<std::string, std::string> values; - }; -} - -DescriptionFile::DescriptionFile(const Source & sr) : - _imp() -{ - Context c("When parsing CRAN description file '" + sr.filename() + "':"); - - std::istringstream s(sr.text()); - if (! s) - throw ConfigFileError(sr.filename(), "Cannot read input"); - - std::string line, line_full; - while (std::getline(s, line)) - { - /* cran needs to be taken out and shot in the nuts for this... */ - line = strip_trailing(line, "\r"); - - if ((! line.empty()) && (std::string::npos != std::string(" \t").find_first_of(line.at(0)))) - { - if (line_full.empty()) - throw ConfigFileError(sr.filename(), "Unexpected continuation"); - - line_full += " "; - line_full += strip_leading(strip_trailing(line, " \t"), " \t"); - } - else - { - if (! line_full.empty()) - _line(line_full); - - line_full = strip_leading(strip_trailing(line, " \t"), " \t"); - } - } - - if (! line_full.empty()) - _line(line_full); -} - -DescriptionFile::~DescriptionFile() -{ -} - -void -DescriptionFile::_line(const std::string & l) -{ - std::string::size_type p(l.find(':')); - if (std::string::npos == p) - Log::get_instance()->message("cran.description.malformed", ll_warning, lc_context) << "No colon on line '" << l << "'"; - else - { - std::string key(strip_leading(strip_trailing(l.substr(0, p), " \t"), " \t")), - value(strip_leading(strip_trailing(l.substr(p + 1), " \t"), " \t")); - - if (key.empty()) - ; - else if (value.empty()) - ; - else - { - std::pair<std::map<std::string, std::string>::iterator, bool> r(_imp->values.insert(std::make_pair(key, value))); - if ((! r.second) && (r.first->second != value)) - Log::get_instance()->message("cran.description.duplicate", ll_qa, lc_context) << "Key '" << key << "' already set to '" - << r.first->second << "', ignoring duplicate key value '" << value << "'"; - } - } -} - -std::string -DescriptionFile::get(const std::string & k) const -{ - std::map<std::string, std::string>::const_iterator i(_imp->values.find(k)); - if (i == _imp->values.end()) - return ""; - return i->second; -} - diff --git a/paludis/repositories/cran/description_file.hh b/paludis/repositories/cran/description_file.hh deleted file mode 100644 index 1d292a1bc..000000000 --- a/paludis/repositories/cran/description_file.hh +++ /dev/null @@ -1,50 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2008, 2011 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_CRAN_DESCRIPTION_FILE_HH -#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_CRAN_DESCRIPTION_FILE_HH 1 - -#include <paludis/util/config_file.hh> -#include <paludis/util/attributes.hh> - -namespace paludis -{ - namespace cranrepository - { - class PALUDIS_VISIBLE DescriptionFile : - public ConfigFile - { - private: - Pimp<DescriptionFile> _imp; - - void _line(const std::string &); - - public: - DescriptionFile(const Source &); - ~DescriptionFile(); - - /** - * Fetch the value for a particular key, or an empty string. - */ - std::string get(const std::string &) const PALUDIS_ATTRIBUTE((warn_unused_result)); - }; - } -} - -#endif diff --git a/paludis/repositories/cran/description_file_TEST.cc b/paludis/repositories/cran/description_file_TEST.cc deleted file mode 100644 index 660345e45..000000000 --- a/paludis/repositories/cran/description_file_TEST.cc +++ /dev/null @@ -1,49 +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 <paludis/repositories/cran/description_file.hh> -#include <test/test_runner.hh> -#include <test/test_framework.hh> -#include <sstream> - -using namespace paludis; -using namespace paludis::cranrepository; -using namespace test; - -namespace test_cases -{ - struct DescriptionTest : TestCase - { - DescriptionTest() : TestCase("description test") { } - - void run() - { - std::stringstream s; - s << "Foo: bar bar" << std::endl; - s << " black sheep" << std::endl; - s << "Moo: cow" << std::endl; - - DescriptionFile f(s); - TEST_CHECK_EQUAL(f.get("Foo"), "bar bar black sheep"); - TEST_CHECK_EQUAL(f.get("Moo"), "cow"); - TEST_CHECK_EQUAL(f.get("Oink"), ""); - } - } test_description; -} - diff --git a/paludis/repositories/cran/keys.cc b/paludis/repositories/cran/keys.cc deleted file mode 100644 index 835f4dbdb..000000000 --- a/paludis/repositories/cran/keys.cc +++ /dev/null @@ -1,214 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2008, 2009, 2010, 2011 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/cran/keys.hh> -#include <paludis/repositories/cran/cran_package_id.hh> -#include <paludis/repositories/cran/cran_dep_parser.hh> -#include <paludis/repositories/cran/spec_tree_pretty_printer.hh> -#include <paludis/util/sequence.hh> -#include <paludis/util/stringify.hh> -#include <paludis/util/join.hh> -#include <paludis/util/wrapped_forward_iterator.hh> -#include <paludis/util/indirect_iterator-impl.hh> -#include <paludis/util/set.hh> -#include <paludis/util/pimp-impl.hh> -#include <paludis/dep_spec.hh> -#include <paludis/action.hh> -#include <paludis/repository.hh> -#include <paludis/environment.hh> -#include <paludis/package_database.hh> -#include <paludis/call_pretty_printer.hh> -#include <functional> - -using namespace paludis; -using namespace paludis::cranrepository; - -PackageIDSequenceKey::PackageIDSequenceKey(const Environment * const e, - const std::string & r, const std::string & h, const MetadataKeyType t) : - _env(e), - _v(std::make_shared<PackageIDSequence>()), - _r(r), - _h(h), - _t(t) -{ -} - -const std::shared_ptr<const PackageIDSequence> -PackageIDSequenceKey::value() const -{ - return _v; -} - -const std::string -PackageIDSequenceKey::raw_name() const -{ - return _r; -} - -const std::string -PackageIDSequenceKey::human_name() const -{ - return _h; -} - -MetadataKeyType -PackageIDSequenceKey::type() const -{ - return _t; -} - -void -PackageIDSequenceKey::push_back(const std::shared_ptr<const PackageID> & i) -{ - _v->push_back(i); -} - -const std::string -PackageIDSequenceKey::pretty_print_value( - const PrettyPrinter & p, const PrettyPrintOptions &) const -{ - using namespace std::placeholders; - return join(value()->begin(), value()->end(), " ", CallPrettyPrinter(p)); -} - -PackageIDKey::PackageIDKey(const Environment * const e, const std::string & r, const std::string & h, - const CRANPackageID * const v, const MetadataKeyType t) : - _env(e), - _v(v), - _r(r), - _h(h), - _t(t) -{ -} - -const std::shared_ptr<const PackageID> -PackageIDKey::value() const -{ - return _v->shared_from_this(); -} - -const std::string -PackageIDKey::pretty_print_value(const PrettyPrinter & p, const PrettyPrintOptions &) const -{ - return p.prettify(value()); -} - -const std::string -PackageIDKey::raw_name() const -{ - return _r; -} - -const std::string -PackageIDKey::human_name() const -{ - return _h; -} - -MetadataKeyType -PackageIDKey::type() const -{ - return _t; -} - -namespace paludis -{ - template <> - struct Imp<DepKey> - { - const Environment * const env; - const std::string v; - - mutable Mutex mutex; - mutable std::shared_ptr<const DependencySpecTree> c; - const std::shared_ptr<const DependenciesLabelSequence> labels; - - const std::string raw_name; - const std::string human_name; - const MetadataKeyType type; - - Imp(const Environment * const e, const std::string & vv, - const std::shared_ptr<const DependenciesLabelSequence> & s, - const std::string & r, const std::string & h, const MetadataKeyType & t) : - env(e), - v(vv), - labels(s), - raw_name(r), - human_name(h), - type(t) - { - } - }; -} - -DepKey::DepKey(const Environment * const e, const std::string & r, const std::string & h, const std::string & v, - const std::shared_ptr<const DependenciesLabelSequence> & s, const MetadataKeyType t) : - _imp(e, v, s, r, h, t) -{ -} - -DepKey::~DepKey() -{ -} - -const std::string -DepKey::raw_name() const -{ - return _imp->raw_name; -} - -const std::string -DepKey::human_name() const -{ - return _imp->human_name; -} - -MetadataKeyType -DepKey::type() const -{ - return _imp->type; -} - -const std::shared_ptr<const DependencySpecTree> -DepKey::value() const -{ - Lock l(_imp->mutex); - if (_imp->c) - return _imp->c; - - Context context("When parsing CRAN dependency string:"); - _imp->c = parse_depends(_imp->v); - return _imp->c; -} - -const std::string -DepKey::pretty_print_value( - const PrettyPrinter & printer, const PrettyPrintOptions & options) const -{ - SpecTreePrettyPrinter p(printer, options); - value()->top()->accept(p); - return stringify(p); -} - -const std::shared_ptr<const DependenciesLabelSequence> -DepKey::initial_labels() const -{ - return _imp->labels; -} - diff --git a/paludis/repositories/cran/keys.hh b/paludis/repositories/cran/keys.hh deleted file mode 100644 index 56a8e1c8b..000000000 --- a/paludis/repositories/cran/keys.hh +++ /dev/null @@ -1,118 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2008, 2009, 2010, 2011 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_PALUDIS_REPOSITORIES_CRAN_KEYS_HH -#define PALUDIS_GUARD_PALUDIS_PALUDIS_REPOSITORIES_CRAN_KEYS_HH 1 - -#include <paludis/metadata_key.hh> -#include <paludis/util/mutex.hh> -#include <paludis/util/sequence.hh> - -namespace paludis -{ - namespace cranrepository - { - class CRANPackageID; - - class PackageIDSequenceKey : - public MetadataCollectionKey<PackageIDSequence> - { - private: - const Environment * const _env; - const std::shared_ptr<PackageIDSequence> _v; - - const std::string _r; - const std::string _h; - const MetadataKeyType _t; - - public: - PackageIDSequenceKey(const Environment * const, - const std::string &, const std::string &, const MetadataKeyType); - - virtual const std::shared_ptr<const PackageIDSequence> value() const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - void push_back(const std::shared_ptr<const PackageID> &); - - virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); - virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); - virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual const std::string pretty_print_value( - const PrettyPrinter &, - const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); - }; - - class PackageIDKey : - public MetadataValueKey<std::shared_ptr<const PackageID> > - { - private: - const Environment * const _env; - const CRANPackageID * const _v; - - const std::string _r; - const std::string _h; - const MetadataKeyType _t; - - public: - PackageIDKey(const Environment * const, const std::string &, const std::string &, const CRANPackageID * const, const MetadataKeyType); - - virtual const std::shared_ptr<const PackageID> value() const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); - virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); - virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual const std::string pretty_print_value( - const PrettyPrinter &, - const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); - }; - - class DepKey : - public MetadataSpecTreeKey<DependencySpecTree> - { - private: - Pimp<DepKey> _imp; - - public: - DepKey(const Environment * const, - const std::string &, const std::string &, const std::string &, - const std::shared_ptr<const DependenciesLabelSequence> &, const MetadataKeyType); - - ~DepKey(); - - virtual const std::shared_ptr<const DependencySpecTree> value() const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual const std::shared_ptr<const DependenciesLabelSequence> initial_labels() const - PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); - virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); - virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual const std::string pretty_print_value( - const PrettyPrinter &, - const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); - }; - } -} - -#endif diff --git a/paludis/repositories/cran/masks.cc b/paludis/repositories/cran/masks.cc deleted file mode 100644 index 2afc1123b..000000000 --- a/paludis/repositories/cran/masks.cc +++ /dev/null @@ -1,70 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2008, 2010, 2011 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 "masks.hh" -#include <paludis/util/pimp-impl.hh> - -using namespace paludis; -using namespace paludis::cranrepository; - -namespace paludis -{ - template <> - struct Imp<BrokenMask> - { - const char key; - const std::string description; - const std::string explanation; - - Imp(const char k, const std::string & d, const std::string & e) : - key(k), - description(d), - explanation(e) - { - } - }; -} - -BrokenMask::BrokenMask(const char c, const std::string & d, const std::string & e) : - _imp(c, d, e) -{ -} - -BrokenMask::~BrokenMask() -{ -} - -char -BrokenMask::key() const -{ - return _imp->key; -} - -const std::string -BrokenMask::description() const -{ - return _imp->description; -} - -const std::string -BrokenMask::explanation() const -{ - return _imp->explanation; -} - diff --git a/paludis/repositories/cran/masks.hh b/paludis/repositories/cran/masks.hh deleted file mode 100644 index d2f8209fa..000000000 --- a/paludis/repositories/cran/masks.hh +++ /dev/null @@ -1,47 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2011 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_PALUDIS_REPOSITORIES_CRAN_MASKS_HH -#define PALUDIS_GUARD_PALUDIS_PALUDIS_REPOSITORIES_CRAN_MASKS_HH 1 - -#include <paludis/mask.hh> -#include <paludis/util/pimp.hh> - -namespace paludis -{ - namespace cranrepository - { - class BrokenMask : - public UnsupportedMask - { - private: - Pimp<BrokenMask> _imp; - - public: - BrokenMask(const char, const std::string &, const std::string &); - ~BrokenMask(); - - virtual char key() const; - virtual const std::string description() const; - virtual const std::string explanation() const; - }; - } -} - -#endif diff --git a/paludis/repositories/cran/normalise.cc b/paludis/repositories/cran/normalise.cc deleted file mode 100644 index f07ca771e..000000000 --- a/paludis/repositories/cran/normalise.cc +++ /dev/null @@ -1,40 +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 "normalise.hh" -#include <algorithm> - -using namespace paludis; - -std::string -paludis::cranrepository::cran_name_to_internal(const std::string & s) -{ - std::string result(s); - std::replace(result.begin(),result.end(), '.', '-'); - return result; -} - -std::string -paludis::cranrepository::cran_version_to_internal(const std::string & s) -{ - std::string result(s); - std::replace(result.begin(), result.end(), '-', '.'); - return result; -} - diff --git a/paludis/repositories/cran/normalise.hh b/paludis/repositories/cran/normalise.hh deleted file mode 100644 index 7836647e7..000000000 --- a/paludis/repositories/cran/normalise.hh +++ /dev/null @@ -1,35 +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_PALUDIS_REPOSITORIES_CRAN_NORMALISE_HH -#define PALUDIS_GUARD_PALUDIS_PALUDIS_REPOSITORIES_CRAN_NORMALISE_HH 1 - -#include <string> -#include <paludis/util/attributes.hh> - -namespace paludis -{ - namespace cranrepository - { - std::string cran_name_to_internal(const std::string &) PALUDIS_ATTRIBUTE((warn_unused_result)); - std::string cran_version_to_internal(const std::string &) PALUDIS_ATTRIBUTE((warn_unused_result)); - } -} - -#endif diff --git a/paludis/repositories/cran/package_dep_spec.cc b/paludis/repositories/cran/package_dep_spec.cc deleted file mode 100644 index 2afa19dd1..000000000 --- a/paludis/repositories/cran/package_dep_spec.cc +++ /dev/null @@ -1,209 +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/cran/package_dep_spec.hh> -#include <paludis/repositories/cran/normalise.hh> -#include <paludis/util/strip.hh> -#include <paludis/util/tokeniser.hh> -#include <paludis/util/sequence.hh> -#include <paludis/util/wrapped_forward_iterator.hh> -#include <paludis/util/make_named_values.hh> -#include <paludis/util/options.hh> -#include <paludis/util/make_null_shared_ptr.hh> -#include <paludis/dep_spec.hh> -#include <paludis/dep_spec_data.hh> -#include <paludis/version_operator.hh> -#include <paludis/version_spec.hh> -#include <paludis/version_requirements.hh> -#include <vector> - -using namespace paludis; -using namespace paludis::cranrepository; - -namespace -{ - struct CRANPackageDepSpecData : - PackageDepSpecData - { - std::string unnormalised_package_name; - std::shared_ptr<const QualifiedPackageName> package_v; - std::shared_ptr<VersionRequirements> version_requirements_v; - - virtual std::string as_string() const - { - std::string result(unnormalised_package_name); - - if (version_requirements_v && ! version_requirements_v->empty()) - { - result.append(" ("); - bool first(true); - for (VersionRequirements::ConstIterator r(version_requirements_v->begin()), - r_end(version_requirements_v->end()) ; r != r_end ; ++r) - { - if (! first) - result.append(", "); - first = false; - result.append(stringify(r->version_operator())); - result.append(" "); - result.append(stringify(r->version_spec())); - } - result.append(")"); - } - - return result; - } - - virtual std::shared_ptr<const QualifiedPackageName> package_ptr() const - { - return package_v; - } - - virtual std::shared_ptr<const PackageNamePart> package_name_part_ptr() const - { - return std::shared_ptr<const PackageNamePart>(); - } - - virtual std::shared_ptr<const CategoryNamePart> category_name_part_ptr() const - { - return std::shared_ptr<const CategoryNamePart>(); - } - - virtual std::shared_ptr<const VersionRequirements> version_requirements_ptr() const - { - return version_requirements_v; - } - - virtual VersionRequirementsMode version_requirements_mode() const - { - return vr_and; - } - - virtual std::shared_ptr<const SlotRequirement> slot_requirement_ptr() const - { - return std::shared_ptr<const SlotRequirement>(); - } - - virtual std::shared_ptr<const RepositoryName> from_repository_ptr() const - { - return std::shared_ptr<const RepositoryName>(); - } - - virtual std::shared_ptr<const RepositoryName> in_repository_ptr() const - { - return std::shared_ptr<const RepositoryName>(); - } - - virtual std::shared_ptr<const AdditionalPackageDepSpecRequirements> additional_requirements_ptr() const - { - return std::shared_ptr<const AdditionalPackageDepSpecRequirements>(); - } - - CRANPackageDepSpecData & version_requirement(const VersionRequirement & v) - { - if (! version_requirements_v) - version_requirements_v = std::make_shared<VersionRequirements>(); - version_requirements_v->push_back(v); - return *this; - } - - CRANPackageDepSpecData & package(const std::string & s) - { - unnormalised_package_name = s; - if ("R" == s) - package_v = std::make_shared<QualifiedPackageName>("dev-lang/R"); - else - package_v = std::make_shared<QualifiedPackageName>(CategoryNamePart("cran") + PackageNamePart(cran_name_to_internal(s))); - - return *this; - } - - virtual std::shared_ptr<const InstallableToRepository> installable_to_repository_ptr() const - { - return make_null_shared_ptr(); - } - - virtual std::shared_ptr<const FSPath> installed_at_path_ptr() const - { - return make_null_shared_ptr(); - } - - virtual std::shared_ptr<const InstallableToPath> installable_to_path_ptr() const - { - return make_null_shared_ptr(); - } - - virtual const PartiallyMadePackageDepSpecOptions options_for_partially_made_package_dep_spec() const - { - return { }; - } - }; -} - -PackageDepSpec -paludis::cranrepository::parse_cran_package_dep_spec(const std::string & ss) -{ - Context context("When parsing CRAN package dep spec '" + ss + "':"); - - std::shared_ptr<CRANPackageDepSpecData> data(std::make_shared<CRANPackageDepSpecData>()); - std::string s(ss); - - std::string::size_type p(s.find('(')); - if (std::string::npos != p) - { - std::string restrictions(s.substr(p)); - s.erase(p); - s = strip_trailing(s, " \r\n\t"); - - if (restrictions.empty() || (')' != restrictions.at(restrictions.length() - 1))) - throw PackageDepSpecError("Invalid () part in '" + ss + "'"); - restrictions = strip_leading(strip_trailing(restrictions.substr(1, restrictions.length() - 2), " \r\n\t"), " \r\n\t"); - - std::vector<std::string> tokens; - tokenise<delim_kind::AnyOfTag, delim_mode::DelimiterTag>(restrictions, ",", "", std::back_inserter(tokens)); - if (tokens.empty()) - throw PackageDepSpecError("Invalid empty () part in '" + ss + "'"); - - for (std::vector<std::string>::const_iterator t(tokens.begin()), t_end(tokens.end()) ; - t != t_end ; ++t) - { - std::vector<std::string> subtokens; - tokenise_whitespace(*t, std::back_inserter(subtokens)); - if (subtokens.size() == 1) - { - std::string::size_type vp(subtokens[0].find_first_not_of("<>=")); - if (std::string::npos != vp) - { - subtokens.push_back(subtokens[0].substr(vp)); - subtokens[0].erase(vp); - } - } - - if (subtokens.size() != 2) - throw PackageDepSpecError("Invalid () entry '" + *t + "' in '" + ss + "'"); - data->version_requirement(make_named_values<VersionRequirement>( - n::version_operator() = VersionOperator(subtokens[0]), - n::version_spec() = VersionSpec(cran_version_to_internal(subtokens[1]), { }))); - } - } - - data->package(s); - - return PackageDepSpec(data); -} - diff --git a/paludis/repositories/cran/package_dep_spec.hh b/paludis/repositories/cran/package_dep_spec.hh deleted file mode 100644 index 207cf4bc8..000000000 --- a/paludis/repositories/cran/package_dep_spec.hh +++ /dev/null @@ -1,34 +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_CRAN_PACKAGE_DEP_SPEC_HH -#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_CRAN_PACKAGE_DEP_SPEC_HH 1 - -#include <paludis/dep_spec-fwd.hh> -#include <paludis/util/attributes.hh> - -namespace paludis -{ - namespace cranrepository - { - PackageDepSpec parse_cran_package_dep_spec(const std::string &) PALUDIS_VISIBLE; - } -} - -#endif diff --git a/paludis/repositories/cran/registration.cc b/paludis/repositories/cran/registration.cc deleted file mode 100644 index 811cb89a4..000000000 --- a/paludis/repositories/cran/registration.cc +++ /dev/null @@ -1,74 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2006, 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/cran/cran_repository.hh> -#include <paludis/repositories/cran/cran_installed_repository.hh> -#include <paludis/util/set.hh> -#include <paludis/util/destringify.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::cran>(const repository_groups::cran * const, RepositoryFactory * const factory) - { - std::shared_ptr<Set<std::string> > cran_formats(std::make_shared<Set<std::string>>()); - cran_formats->insert("cran"); - - factory->add_repository_format( - cran_formats, - &CRANRepository::repository_factory_name, - &generic_importance, - &CRANRepository::repository_factory_create, - &CRANRepository::repository_factory_dependencies - ); - - std::shared_ptr<Set<std::string> > installed_cran_formats(std::make_shared<Set<std::string>>()); - installed_cran_formats->insert("installed_cran"); - installed_cran_formats->insert("installed-cran"); - - factory->add_repository_format( - installed_cran_formats, - &CRANInstalledRepository::repository_factory_name, - &generic_importance, - &CRANInstalledRepository::repository_factory_create, - &CRANInstalledRepository::repository_factory_dependencies - ); - } -} - diff --git a/paludis/repositories/cran/spec_tree_pretty_printer.cc b/paludis/repositories/cran/spec_tree_pretty_printer.cc deleted file mode 100644 index bd18c6714..000000000 --- a/paludis/repositories/cran/spec_tree_pretty_printer.cc +++ /dev/null @@ -1,134 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2010, 2011 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/cran/spec_tree_pretty_printer.hh> -#include <paludis/util/pimp-impl.hh> -#include <paludis/util/indirect_iterator-impl.hh> -#include <paludis/util/stringify.hh> -#include <paludis/util/options.hh> -#include <paludis/util/accept_visitor.hh> -#include <paludis/pretty_printer.hh> -#include <algorithm> -#include <ostream> -#include <sstream> - -using namespace paludis; -using namespace paludis::cranrepository; - -namespace paludis -{ - template <> - struct Imp<SpecTreePrettyPrinter> - { - std::stringstream s; - const PrettyPrinter & printer; - const PrettyPrintOptions options; - const unsigned indent; - const bool multiline; - bool need_comma; - - Imp( - const PrettyPrinter & p, const PrettyPrintOptions & o) : - printer(p), - options(o), - indent(0), - multiline(o[ppo_multiline_allowed]), - need_comma(false) - { - } - }; -} - -SpecTreePrettyPrinter::SpecTreePrettyPrinter( - const PrettyPrinter & p, const PrettyPrintOptions & o) : - _imp(p, o) -{ -} - -SpecTreePrettyPrinter::~SpecTreePrettyPrinter() -{ -} - -void -SpecTreePrettyPrinter::visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & node) -{ - if (_imp->multiline) - _imp->s << _imp->printer.indentify(_imp->indent); - else if (_imp->need_comma) - _imp->s << ", "; - else - _imp->need_comma = true; - - _imp->s << _imp->printer.prettify(*node.spec()); - - if (_imp->multiline) - _imp->s << _imp->printer.newline(); -} - -void -SpecTreePrettyPrinter::visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & node) -{ - std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); -} - -void -SpecTreePrettyPrinter::visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & node) -{ - std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); -} - -void -SpecTreePrettyPrinter::visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & node) -{ - std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); -} - -void -SpecTreePrettyPrinter::visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type &) -{ -} - -void -SpecTreePrettyPrinter::visit(const DependencySpecTree::NodeType<DependenciesLabelsDepSpec>::Type &) -{ -} - -void -SpecTreePrettyPrinter::visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type & node) -{ - if (_imp->multiline) - _imp->s << _imp->printer.indentify(_imp->indent); - else if (_imp->need_comma) - _imp->s << ", "; - else - _imp->need_comma = true; - - _imp->s << _imp->printer.prettify(*node.spec()); - - if (_imp->multiline) - _imp->s << _imp->printer.newline(); -} - -std::ostream & -paludis::cranrepository::operator<< (std::ostream & s, const SpecTreePrettyPrinter & p) -{ - s << p._imp->s.str(); - return s; -} - diff --git a/paludis/repositories/cran/spec_tree_pretty_printer.hh b/paludis/repositories/cran/spec_tree_pretty_printer.hh deleted file mode 100644 index e47753e9d..000000000 --- a/paludis/repositories/cran/spec_tree_pretty_printer.hh +++ /dev/null @@ -1,62 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2010, 2011 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_CRAN_SPEC_TREE_PRETTY_PRINTER_HH -#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_CRAN_SPEC_TREE_PRETTY_PRINTER_HH 1 - -#include <paludis/util/pimp.hh> -#include <paludis/spec_tree.hh> -#include <paludis/dep_spec-fwd.hh> -#include <paludis/pretty_print_options-fwd.hh> -#include <paludis/pretty_printer-fwd.hh> -#include <iosfwd> - -namespace paludis -{ - namespace cranrepository - { - class PALUDIS_VISIBLE SpecTreePrettyPrinter - { - friend std::ostream & operator<< (std::ostream &, const SpecTreePrettyPrinter &); - - private: - Pimp<SpecTreePrettyPrinter> _imp; - - public: - SpecTreePrettyPrinter( - const PrettyPrinter & p, const PrettyPrintOptions &); - - ~SpecTreePrettyPrinter(); - - ///\} - - void visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & node); - void visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & node); - void visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & node); - void visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type & node); - void visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & node); - void visit(const DependencySpecTree::NodeType<DependenciesLabelsDepSpec>::Type & node); - void visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type & node); - }; - - std::ostream & operator<< (std::ostream & s, const SpecTreePrettyPrinter & p) PALUDIS_VISIBLE; - } -} - -#endif diff --git a/paludis/repository_factory.cc b/paludis/repository_factory.cc index c6fdb24da..4555933d4 100644 --- a/paludis/repository_factory.cc +++ b/paludis/repository_factory.cc @@ -116,7 +116,6 @@ RepositoryFactory::RepositoryFactory() : using namespace repository_groups; register_repositories(static_cast<const TypeOrNoType<REPOSITORY_GROUP_IF_accounts>::Type *>(0), this); - 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_fake>::Type *>(0), this); |