]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/deb/debmetaindex.cc
add messages to our deprecation warnings in libapt
[apt.git] / apt-pkg / deb / debmetaindex.cc
index a53d32d346c1c2ef9beca6f1cffc3629dbb9465d..930286a410e3568987e16f85c04b9ebc441c3c67 100644 (file)
@@ -49,6 +49,8 @@ class APT_HIDDEN debReleaseIndexPrivate                                       /*{{{*/
    time_t ValidUntilMin;
    time_t ValidUntilMax;
 
+   std::vector<std::string> Architectures;
+
    debReleaseIndexPrivate() : CheckValidUntil(metaIndex::TRI_UNSET), ValidUntilMin(0), ValidUntilMax(0) {}
 };
                                                                        /*}}}*/
@@ -252,12 +254,20 @@ static void GetIndexTargetsFor(char const * const Type, std::string const &URI,
               Options.insert(std::make_pair("COMPRESSIONTYPES", CompressionTypes));
               Options.insert(std::make_pair("SOURCESENTRY", E->sourcesEntry));
 
+              bool IsOpt = IsOptional;
+              if (IsOpt == false)
+              {
+                 auto const arch = Options.find("ARCHITECTURE");
+                 if (arch != Options.end() && arch->second == "all")
+                    IsOpt = true;
+              }
+
               IndexTarget Target(
                     MetaKey,
                     ShortDesc,
                     LongDesc,
                     Options.find("BASE_URI")->second + MetaKey,
-                    IsOptional,
+                    IsOpt,
                     KeepCompressed,
                     Options
                     );
@@ -331,6 +341,11 @@ bool debReleaseIndex::Load(std::string const &Filename, std::string * const Erro
 
    Suite = Section.FindS("Suite");
    Codename = Section.FindS("Codename");
+   {
+      std::string const archs = Section.FindS("Architectures");
+      if (archs.empty() == false)
+        d->Architectures = VectorizeString(archs, ' ');
+   }
 
    bool FoundHashSum = false;
    for (int i=0;HashString::SupportedHashes()[i] != NULL; i++)
@@ -521,7 +536,7 @@ bool debReleaseIndex::SetTrusted(TriState const pTrusted)
       Trusted = pTrusted;
    else if (Trusted != pTrusted)
       // TRANSLATOR: The first is an option name from sources.list manpage, the other two URI and Suite
-      return _error->Error(_("Conflicting values set for option %s concerning source %s %s"), "Trusted", URI.c_str(), Dist.c_str());
+      return _error->Error(_("Conflicting values set for option %s regarding source %s %s"), "Trusted", URI.c_str(), Dist.c_str());
    return true;
 }
 bool debReleaseIndex::SetCheckValidUntil(TriState const pCheckValidUntil)
@@ -529,7 +544,7 @@ bool debReleaseIndex::SetCheckValidUntil(TriState const pCheckValidUntil)
    if (d->CheckValidUntil == TRI_UNSET)
       d->CheckValidUntil = pCheckValidUntil;
    else if (d->CheckValidUntil != pCheckValidUntil)
-      return _error->Error(_("Conflicting values set for option %s concerning source %s %s"), "Check-Valid-Until", URI.c_str(), Dist.c_str());
+      return _error->Error(_("Conflicting values set for option %s regarding source %s %s"), "Check-Valid-Until", URI.c_str(), Dist.c_str());
    return true;
 }
 bool debReleaseIndex::SetValidUntilMin(time_t const Valid)
@@ -537,7 +552,7 @@ bool debReleaseIndex::SetValidUntilMin(time_t const Valid)
    if (d->ValidUntilMin == 0)
       d->ValidUntilMin = Valid;
    else if (d->ValidUntilMin != Valid)
-      return _error->Error(_("Conflicting values set for option %s concerning source %s %s"), "Min-ValidTime", URI.c_str(), Dist.c_str());
+      return _error->Error(_("Conflicting values set for option %s regarding source %s %s"), "Min-ValidTime", URI.c_str(), Dist.c_str());
    return true;
 }
 bool debReleaseIndex::SetValidUntilMax(time_t const Valid)
@@ -545,7 +560,7 @@ bool debReleaseIndex::SetValidUntilMax(time_t const Valid)
    if (d->ValidUntilMax == 0)
       d->ValidUntilMax = Valid;
    else if (d->ValidUntilMax != Valid)
-      return _error->Error(_("Conflicting values set for option %s concerning source %s %s"), "Max-ValidTime", URI.c_str(), Dist.c_str());
+      return _error->Error(_("Conflicting values set for option %s regarding source %s %s"), "Max-ValidTime", URI.c_str(), Dist.c_str());
    return true;
 }
 bool debReleaseIndex::SetSignedBy(std::string const &pSignedBy)
@@ -563,12 +578,12 @@ bool debReleaseIndex::SetSignedBy(std::string const &pSignedBy)
         finger.erase(std::remove(finger.begin(), finger.end(), ' '), finger.end());
         std::transform(finger.begin(), finger.end(), finger.begin(), ::toupper);
         if (finger.length() != 40 || finger.find_first_not_of("0123456789ABCDEF") != std::string::npos)
-           return _error->Error(_("Invalid value set for option %s concerning source %s %s (%s)"), "Signed-By", URI.c_str(), Dist.c_str(), "not a fingerprint");
+           return _error->Error(_("Invalid value set for option %s regarding source %s %s (%s)"), "Signed-By", URI.c_str(), Dist.c_str(), "not a fingerprint");
       }
       SignedBy = pSignedBy;
    }
    else if (SignedBy != pSignedBy)
-      return _error->Error(_("Conflicting values set for option %s concerning source %s %s"), "Signed-By", URI.c_str(), Dist.c_str());
+      return _error->Error(_("Conflicting values set for option %s regarding source %s %s"), "Signed-By", URI.c_str(), Dist.c_str());
    return true;
 }
                                                                        /*}}}*/
@@ -591,6 +606,13 @@ bool debReleaseIndex::IsTrusted() const
    return FileExists(MetaIndexFile("InRelease"));
 }
                                                                        /*}}}*/
+bool debReleaseIndex::IsArchitectureSupported(std::string const &arch) const/*{{{*/
+{
+   if (d->Architectures.empty())
+      return true;
+   return std::find(d->Architectures.begin(), d->Architectures.end(), arch) != d->Architectures.end();
+}
+                                                                       /*}}}*/
 std::vector <pkgIndexFile *> *debReleaseIndex::GetIndexFiles()         /*{{{*/
 {
    if (Indexes != NULL)
@@ -729,6 +751,10 @@ static std::vector<std::string> parsePlusMinusOptions(std::string const &Name, /
    else
       Values = defaultValues;
 
+   // all is a very special architecture users shouldn't be concerned with explicitly
+   if (Name == "arch" && std::find(Values.begin(), Values.end(), "all") == Values.end())
+      Values.push_back("all");
+
    if ((val = Options.find(Name + "+")) != Options.end())
    {
       std::vector<std::string> const plus = VectorizeString(val->second, ',');