/* vim: set sw=4 sts=4 et foldmethod=syntax : *//* * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org> * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General * Public License version 2, as published by the Free Software Foundation. * * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place, Suite 330, Boston, MA 02111-1307 USA */#include<paludis/dep_spec.hh>#include<paludis/portage_dep_parser.hh>#include<paludis/package_database_entry.hh>#include<paludis/environment.hh>#include<paludis/qa/pdepend_overlap_check.hh>#include<paludis/util/join.hh>#include<paludis/qa/qa_environment.hh>#include<paludis/repositories/gentoo/portage_repository.hh>#include<set>usingnamespacepaludis;usingnamespacepaludis::qa;namespace{structCollector:DepSpecVisitorTypes::ConstVisitor,DepSpecVisitorTypes::ConstVisitor::VisitChildren<Collector,AllDepSpec>,DepSpecVisitorTypes::ConstVisitor::VisitChildren<Collector,AnyDepSpec>,DepSpecVisitorTypes::ConstVisitor::VisitChildren<Collector,UseDepSpec>{usingDepSpecVisitorTypes::ConstVisitor::VisitChildren<Collector,UseDepSpec>::visit;usingDepSpecVisitorTypes::ConstVisitor::VisitChildren<Collector,AllDepSpec>::visit;usingDepSpecVisitorTypes::ConstVisitor::VisitChildren<Collector,AnyDepSpec>::visit;std::set<QualifiedPackageName>result;Collector(){}voidvisit(constPackageDepSpec*constp){if(p->package_ptr())result.insert(*p->package_ptr());}voidvisit(constBlockDepSpec*const){}voidvisit(constPlainTextDepSpec*const){}};}PdependOverlapCheck::PdependOverlapCheck(){}CheckResultPdependOverlapCheck::operator()(constEbuildCheckData&e)const{CheckResultresult(stringify(e.name)+"-"+stringify(e.version),identifier());try{PackageDatabaseEntryee(e.name,e.version,e.environment->portage_repository()->name());std::tr1::shared_ptr<constVersionMetadata>metadata(e.environment->package_database()->fetch_repository(ee.repository)->version_metadata(ee.name,ee.version));Collectorpdepend_collector;std::stringpdepend(metadata->deps_interface->post_depend_string);PortageDepParser::parse(pdepend)->accept(&pdepend_collector);{Collectordepend_collector;std::stringdepend(metadata->deps_interface->build_depend_string);PortageDepParser::parse(depend)->accept(&depend_collector);std::set<QualifiedPackageName>overlap;std::set_intersection(depend_collector.result.begin(),depend_collector.result.end(),pdepend_collector.result.begin(),pdepend_collector.result.end(),std::inserter(overlap,overlap.begin()));if(!overlap.empty())result<<Message(qal_major,"Overlap between DEPEND and PDEPEND: '"+join(overlap.begin(),overlap.end(),"', ")+"'");}{Collectorrdepend_collector;std::stringrdepend(metadata->deps_interface->run_depend_string);PortageDepParser::parse(rdepend)->accept(&rdepend_collector);std::set<QualifiedPackageName>overlap;std::set_intersection(rdepend_collector.result.begin(),rdepend_collector.result.end(),pdepend_collector.result.begin(),pdepend_collector.result.end(),std::inserter(overlap,overlap.begin()));if(!overlap.empty())result<<Message(qal_major,"Overlap between RDEPEND and PDEPEND: '"+join(overlap.begin(),overlap.end(),"', ")+"'");}}catch(constInternalError&){throw;}catch(constException&err){result<<Message(qal_fatal,"Caught Exception '"+err.message()+"' ("+err.what()+")");}returnresult;}conststd::string&PdependOverlapCheck::identifier(){staticconststd::stringid("pdepend_overlap");returnid;}