]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/aptconfiguration.cc
Arch() on a MultiArch:all version should return "all" to be compatible
[apt.git] / apt-pkg / aptconfiguration.cc
index 899004d9f0d964c1482386f4551471047e6d0014..1ec526646d3f97f6e53ed2646f6321906e1c7b3c 100644 (file)
@@ -11,6 +11,7 @@
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/aptconfiguration.h>
 #include <apt-pkg/configuration.h>
+#include <system.h>
 
 #include <vector>
 #include <string>
@@ -223,4 +224,28 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
                return codes;
 }
                                                                        /*}}}*/
+// getArchitectures - Return Vector of prefered Architectures          /*{{{*/
+std::vector<std::string> const Configuration::getArchitectures(bool const &Cached) {
+       using std::string;
+
+       std::vector<string> static archs;
+       if (likely(Cached == true) && archs.empty() == false)
+               return archs;
+
+       string const arch = _config->Find("APT::Architecture");
+       archs = _config->FindVector("APT::Architectures");
+       if (archs.empty() == true ||
+           std::find(archs.begin(), archs.end(), arch) == archs.end())
+               archs.push_back(arch);
+       return archs;
+}
+                                                                       /*}}}*/
+// checkArchitecture - are we interested in the given Architecture?    /*{{{*/
+bool const Configuration::checkArchitecture(std::string const &Arch) {
+       if (Arch == "all")
+               return true;
+       std::vector<std::string> const archs = getArchitectures(true);
+       return (std::find(archs.begin(), archs.end(), Arch) != archs.end());
+}
+                                                                       /*}}}*/
 }