merge with debian-experimental-ma
[ntk/apt.git] / apt-pkg / deb / deblistparser.cc
index d1931f9..24df57a 100644 (file)
@@ -19,6 +19,7 @@
 #include <apt-pkg/md5.h>
 #include <apt-pkg/macros.h>
 
+#include <fnmatch.h>
 #include <ctype.h>
                                                                        /*}}}*/
 
@@ -473,6 +474,20 @@ const char *debListParser::ConvertRelation(const char *I,unsigned int &Op)
    return I;
 }
 
+/*
+ * CompleteArch:
+ *
+ * The complete architecture, consisting of <kernel>-<cpu>.
+ */
+static string CompleteArch(std::string& arch) {
+    if (arch == "armel")              return "linux-arm";
+    if (arch == "lpia")               return "linux-i386";
+    if (arch == "powerpcspe")         return "linux-powerpc";
+    if (arch == "uclibc-linux-armel") return "linux-arm";
+    if (arch == "uclinux-armel")      return "uclinux-arm";
+
+    return (arch.find("-") != string::npos) ? arch : "linux-" + arch;
+}
                                                                        /*}}}*/
 // ListParser::ParseDepends - Parse a dependency element               /*{{{*/
 // ---------------------------------------------------------------------
@@ -546,6 +561,7 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
    if (ParseArchFlags == true)
    {
       string arch = _config->Find("APT::Architecture");
+      string completeArch = CompleteArch(arch);
 
       // Parse an architecture
       if (I != Stop && *I == '[')
@@ -573,8 +589,13 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
               I++;
             }
 
-           if (stringcmp(arch,I,End) == 0)
+           if (stringcmp(arch,I,End) == 0) {
               Found = true;
+           } else {
+              std::string wildcard = SubstVar(string(I, End), "any", "*");
+              if (fnmatch(wildcard.c_str(), completeArch.c_str(), 0) == 0)
+                 Found = true;
+           }
            
            if (*End++ == ']') {
               I = End;