diff options
-rw-r--r-- | paludis/broken_linkage_finder.cc | 27 | ||||
-rw-r--r-- | paludis/broken_linkage_finder.hh | 14 | ||||
-rw-r--r-- | src/clients/cave/cmd_fix_linkage.cc | 40 |
3 files changed, 45 insertions, 36 deletions
diff --git a/paludis/broken_linkage_finder.cc b/paludis/broken_linkage_finder.cc index 601281bb1..617e8bbb3 100644 --- a/paludis/broken_linkage_finder.cc +++ b/paludis/broken_linkage_finder.cc @@ -359,6 +359,12 @@ BrokenLinkageFinder::end_broken_packages() const return BrokenPackageConstIterator(first_iterator(_imp->breakage.end())); } +IteratorRange<BrokenLinkageFinder::BrokenPackageConstIterator> +BrokenLinkageFinder::broken_packages() const +{ + return {begin_broken_packages(), end_broken_packages()}; +} + BrokenLinkageFinder::BrokenFileConstIterator BrokenLinkageFinder::begin_broken_files(const std::shared_ptr<const PackageID> & pkg) const { @@ -389,9 +395,15 @@ BrokenLinkageFinder::end_broken_files(const std::shared_ptr<const PackageID> & p return BrokenFileConstIterator(first_iterator(_imp->orphan_breakage.end())); } +IteratorRange<BrokenLinkageFinder::BrokenFileConstIterator> +BrokenLinkageFinder::broken_files(const std::shared_ptr<const PackageID> & package) const +{ + return {begin_broken_files(package), end_broken_files(package)}; +} + BrokenLinkageFinder::MissingRequirementConstIterator -BrokenLinkageFinder::begin_missing_requirements( - const std::shared_ptr<const PackageID> & pkg, const FSPath & file) const +BrokenLinkageFinder::begin_missing_requirements(const std::shared_ptr<const PackageID> & pkg, + const FSPath & file) const { if (pkg) { @@ -416,8 +428,8 @@ BrokenLinkageFinder::begin_missing_requirements( } BrokenLinkageFinder::MissingRequirementConstIterator -BrokenLinkageFinder::end_missing_requirements( - const std::shared_ptr<const PackageID> & pkg, const FSPath & file) const +BrokenLinkageFinder::end_missing_requirements(const std::shared_ptr<const PackageID> & pkg, + const FSPath & file) const { if (pkg) { @@ -441,6 +453,13 @@ BrokenLinkageFinder::end_missing_requirements( } } +IteratorRange<BrokenLinkageFinder::MissingRequirementConstIterator> +BrokenLinkageFinder::missing_requirements(const std::shared_ptr<const PackageID> & package, + const FSPath & file) const +{ + return {begin_missing_requirements(package, file), end_missing_requirements(package, file)}; +} + namespace paludis { template class PALUDIS_VISIBLE WrappedForwardIterator<BrokenLinkageFinder::BrokenPackageConstIteratorTag, const std::shared_ptr<const PackageID>>; diff --git a/paludis/broken_linkage_finder.hh b/paludis/broken_linkage_finder.hh index 4680a34ad..144da0972 100644 --- a/paludis/broken_linkage_finder.hh +++ b/paludis/broken_linkage_finder.hh @@ -22,6 +22,7 @@ #include <paludis/util/attributes.hh> #include <paludis/util/fs_path-fwd.hh> +#include <paludis/util/iterator_range.hh> #include <paludis/util/pimp.hh> #include <paludis/util/sequence-fwd.hh> #include <paludis/util/wrapped_forward_iterator-fwd.hh> @@ -46,11 +47,10 @@ namespace paludis BrokenLinkageFinder & operator= (const BrokenLinkageFinder &) = delete; struct BrokenPackageConstIteratorTag; - typedef WrappedForwardIterator<BrokenPackageConstIteratorTag, - const std::shared_ptr<const PackageID> - > BrokenPackageConstIterator; + typedef WrappedForwardIterator<BrokenPackageConstIteratorTag, const std::shared_ptr<const PackageID>> BrokenPackageConstIterator; BrokenPackageConstIterator begin_broken_packages() const PALUDIS_ATTRIBUTE((warn_unused_result)); BrokenPackageConstIterator end_broken_packages() const PALUDIS_ATTRIBUTE((warn_unused_result)); + IteratorRange<BrokenPackageConstIterator> broken_packages() const; struct BrokenFileConstIteratorTag; typedef WrappedForwardIterator<BrokenFileConstIteratorTag, const FSPath> BrokenFileConstIterator; @@ -58,15 +58,15 @@ namespace paludis const PALUDIS_ATTRIBUTE((warn_unused_result)); BrokenFileConstIterator end_broken_files(const std::shared_ptr<const PackageID> &) const PALUDIS_ATTRIBUTE((warn_unused_result)); + IteratorRange<BrokenFileConstIterator> broken_files(const std::shared_ptr<const PackageID> &) const; struct MissingRequirementConstIteratorTag; typedef WrappedForwardIterator<MissingRequirementConstIteratorTag, const std::string> MissingRequirementConstIterator; - MissingRequirementConstIterator begin_missing_requirements( - const std::shared_ptr<const PackageID> &, const FSPath &) + MissingRequirementConstIterator begin_missing_requirements(const std::shared_ptr<const PackageID> &, const FSPath &) const PALUDIS_ATTRIBUTE((warn_unused_result)); - MissingRequirementConstIterator end_missing_requirements( - const std::shared_ptr<const PackageID> &, const FSPath &) + MissingRequirementConstIterator end_missing_requirements(const std::shared_ptr<const PackageID> &, const FSPath &) const PALUDIS_ATTRIBUTE((warn_unused_result)); + IteratorRange<MissingRequirementConstIterator> missing_requirements(const std::shared_ptr<const PackageID> &, const FSPath &) const; }; } diff --git a/src/clients/cave/cmd_fix_linkage.cc b/src/clients/cave/cmd_fix_linkage.cc index 1bc925102..f070225a5 100644 --- a/src/clients/cave/cmd_fix_linkage.cc +++ b/src/clients/cave/cmd_fix_linkage.cc @@ -195,36 +195,30 @@ FixLinkageCommand::run(const std::shared_ptr<Environment> & env, std::shared_ptr<Sequence<std::pair<std::string, std::string>>> targets(std::make_shared<Sequence<std::pair<std::string, std::string>>>()); - for (BrokenLinkageFinder::BrokenPackageConstIterator pkg_it(finder->begin_broken_packages()), - pkg_it_end(finder->end_broken_packages()); pkg_it_end != pkg_it; ++pkg_it) + for (const auto & package : finder->broken_packages()) { cout << endl; - cout << "* " << **pkg_it << endl; + cout << "* " << *package << endl; std::set<FSPath, FSPathComparator> broken_files; - for (BrokenLinkageFinder::BrokenFileConstIterator file_it(finder->begin_broken_files(*pkg_it)), - file_it_end(finder->end_broken_files(*pkg_it)); file_it_end != file_it; ++file_it) + for (const auto & file : finder->broken_files(package)) { - cout << " " << *file_it; - cout << " (requires " - << join(finder->begin_missing_requirements(*pkg_it, *file_it), - finder->end_missing_requirements(*pkg_it, *file_it), - " ") << ")"; - std::copy(finder->begin_missing_requirements(*pkg_it, *file_it), finder->end_missing_requirements(*pkg_it, *file_it), - create_inserter<FSPath>(std::inserter(broken_files, broken_files.end()))); + cout << " " << file; + cout << " (requires " << join(finder->begin_missing_requirements(package, file), finder->end_missing_requirements(package, file), " ") << ")"; + std::copy(finder->begin_missing_requirements(package, file), finder->end_missing_requirements(package, file), + create_inserter<FSPath>(std::inserter(broken_files, broken_files.end()))); cout << endl; } PartiallyMadePackageDepSpec part_spec({ }); - part_spec.package((*pkg_it)->name()); - if ((*pkg_it)->slot_key()) - part_spec.slot_requirement(std::make_shared<UserSlotExactPartialRequirement>((*pkg_it)->slot_key()->parse_value().parallel_value())); + part_spec.package(package->name()); + if (package->slot_key()) + part_spec.slot_requirement(std::make_shared<UserSlotExactPartialRequirement>(package->slot_key()->parse_value().parallel_value())); if (cmdline.a_exact.specified()) - part_spec.version_requirement(make_named_values<VersionRequirement>( - n::version_operator() = vo_equal, - n::version_spec() = (*pkg_it)->version())); + part_spec.version_requirement(make_named_values<VersionRequirement>(n::version_operator() = vo_equal, + n::version_spec() = package->version())); targets->push_back(std::make_pair(stringify(PackageDepSpec(part_spec)), join(broken_files.begin(), broken_files.end(), ", "))); } @@ -237,14 +231,10 @@ FixLinkageCommand::run(const std::shared_ptr<Environment> & env, else cout << endl << "The following files that depend on the specified library(ies) are not owned by any installed package:" << endl; - for (BrokenLinkageFinder::BrokenFileConstIterator file_it(finder->begin_broken_files(orphans)), - file_it_end(finder->end_broken_files(orphans)); file_it_end != file_it; ++file_it) + for (const auto & file : finder->broken_files(orphans)) { - cout << " " << *file_it; - cout << " (requires " - << join(finder->begin_missing_requirements(orphans, *file_it), - finder->end_missing_requirements(orphans, *file_it), - " ") << ")"; + cout << " " << file; + cout << " (requires " << join(finder->begin_missing_requirements(orphans, file), finder->end_missing_requirements(orphans, file), " ") << ")"; cout << endl; } } |