From 26c548161f5502b0f408b7efd9fd748346c93220 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A1n=20Kupec?= Date: Tue, 30 Mar 2010 11:19:28 +0200 Subject: [PATCH] misc.h: pkg_spec_to_poolquery() added --- src/misc.cc | 46 ++++++++++++++++++++++++++++++++++++++++++++++ src/misc.h | 25 ++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/src/misc.cc b/src/misc.cc index 12dce14..a8a8bc7 100644 --- a/src/misc.cc +++ b/src/misc.cc @@ -21,6 +21,7 @@ #include "zypp/PoolQuery.h" +#include "Zypper.h" #include "main.h" #include "utils/misc.h" #include "utils/pager.h" @@ -348,6 +349,8 @@ static SrcPackage::constPtr source_find( const string & arg ) return srcpkg; } +// ---------------------------------------------------------------------------- + void build_deps_install(Zypper & zypper) { /* @@ -391,6 +394,8 @@ void build_deps_install(Zypper & zypper) } } +// ---------------------------------------------------------------------------- + void mark_src_pkgs(Zypper & zypper) { /* @@ -413,6 +418,8 @@ void mark_src_pkgs(Zypper & zypper) } } +// ---------------------------------------------------------------------------- + void install_src_pkgs(Zypper & zypper) { for_(it, zypper.runtimeData().srcpkgs_to_install.begin(), zypper.runtimeData().srcpkgs_to_install.end()) @@ -443,6 +450,45 @@ void install_src_pkgs(Zypper & zypper) } } +// ---------------------------------------------------------------------------- + +zypp::PoolQuery +pkg_spec_to_poolquery( + const string & glob, + const ResKind & kind, + const list & repos) +{ + PoolQuery q; + q.addKind(kind); + q.addAttribute(sat::SolvAttr::name, glob); + q.setMatchGlob(); + for_(it, repos.begin(), repos.end()) + q.addRepo(it->alias()); + return q; +} + +zypp::PoolQuery +pkg_spec_to_poolquery(const Capability & cap, const list & repos) +{ + sat::Solvable::SplitIdent splid(cap.detail().name()); + return pkg_spec_to_poolquery(splid.name().asString(), splid.kind(), repos); +} + +zypp::PoolQuery +pkg_spec_to_poolquery(const Capability & cap, const string & repo) +{ + sat::Solvable::SplitIdent splid(cap.detail().name()); + + if (repo.empty()) + return pkg_spec_to_poolquery(splid.name().asString(), splid.kind()); + + RepoInfo repoinfo; + repoinfo.setAlias(repo); + list repos; + repos.push_back(repoinfo); + return pkg_spec_to_poolquery(splid.name().asString(), splid.kind(), repos); +} + // Local Variables: // c-basic-offset: 2 // End: diff --git a/src/misc.h b/src/misc.h index 6fbc4ee..bca19e0 100644 --- a/src/misc.h +++ b/src/misc.h @@ -8,8 +8,15 @@ #ifndef ZMART_MISC_H #define ZMART_MISC_H -#include "Zypper.h" +#include +#include +#include "zypp/PoolQuery.h" +#include "zypp/ResKind.h" +#include "zypp/RepoInfo.h" +#include "zypp/Capability.h" + +class Zypper; /** * Loops through resolvables, checking if there is license to confirm. When @@ -55,4 +62,20 @@ void install_src_pkgs(Zypper & zypper); */ void build_deps_install(Zypper & zypper); +zypp::PoolQuery +pkg_spec_to_poolquery( + const std::string & glob, + const zypp::ResKind & kind = zypp::ResKind::package, + const std::list & repos = std::list()); + +zypp::PoolQuery +pkg_spec_to_poolquery( + const zypp::Capability & cap, + const std::list & repos = std::list()); + +zypp::PoolQuery +pkg_spec_to_poolquery( + const zypp::Capability & cap, + const std::string & repo = std::string()); + #endif -- 2.7.4