Parcourir la source

apt-pkg/deb/deblistparser.cc: Fix bug in architecture wildcard support.

Previously, linux-any was always matched, because the code simply
appended linux- to the APT::Architecture value. Now, it does this
only if the APT::Architecture value does not contain "-".
Julian Andres Klode il y a 16 ans
Parent
commit
3b20aef1a2
1 fichiers modifiés avec 10 ajouts et 3 suppressions
  1. 10 3
      apt-pkg/deb/deblistparser.cc

+ 10 - 3
apt-pkg/deb/deblistparser.cc

@@ -473,6 +473,14 @@ const char *debListParser::ConvertRelation(const char *I,unsigned int &Op)
    return I;
    return I;
 }
 }
 
 
+/*
+ * CompleteArch:
+ *
+ * The complete architecture, consisting of <kernel>-<cpu>.
+ */
+static string CompleteArch(std::string& arch) {
+    return (arch.find("-") != string::npos) ? arch : "linux-" + arch;
+}
 									/*}}}*/
 									/*}}}*/
 // ListParser::ParseDepends - Parse a dependency element		/*{{{*/
 // ListParser::ParseDepends - Parse a dependency element		/*{{{*/
 // ---------------------------------------------------------------------
 // ---------------------------------------------------------------------
@@ -546,6 +554,7 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
    if (ParseArchFlags == true)
    if (ParseArchFlags == true)
    {
    {
       string arch = _config->Find("APT::Architecture");
       string arch = _config->Find("APT::Architecture");
+      string completeArch = CompleteArch(arch);
 
 
       // Parse an architecture
       // Parse an architecture
       if (I != Stop && *I == '[')
       if (I != Stop && *I == '[')
@@ -577,9 +586,7 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
 	       Found = true;
 	       Found = true;
 	    } else {
 	    } else {
 	       std::string wildcard = SubstVar(string(I, End), "any", "*");
 	       std::string wildcard = SubstVar(string(I, End), "any", "*");
-	       if (fnmatch(wildcard.c_str(), arch.c_str(), 0) == 0)
-	          Found = true;
-	       else if (fnmatch(wildcard.c_str(), ("linux-" + arch).c_str(), 0) == 0)
+	       if (fnmatch(wildcard.c_str(), completeArch.c_str(), 0) == 0)
 	          Found = true;
 	          Found = true;
 	    }
 	    }