]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/deb/debmetaindex.cc
Release 1.11~exp11
[apt.git] / apt-pkg / deb / debmetaindex.cc
index 4bb03a9420a502c09cd63221a7951d5c4d8982c7..69e41a6f46ea0572c8c2765c786323414a229ed3 100644 (file)
 #include <string>
 #include <utility>
 #include <vector>
-#include <set>
 #include <algorithm>
 
-#include <sys/types.h>
 #include <sys/stat.h>
-#include <unistd.h>
 #include <string.h>
 
 #include <apti18n.h>
@@ -123,15 +120,17 @@ static void GetIndexTargetsFor(char const * const Type, std::string const &URI,
    std::string const Release = (Dist == "/") ? "" : Dist;
    std::string const Site = ::URI::ArchiveOnly(URI);
 
+   bool const GzipIndex = _config->FindB("Acquire::GzipIndexes", false);
    for (std::vector<debReleaseIndexPrivate::debSectionEntry>::const_iterator E = entries.begin(); E != entries.end(); ++E)
    {
       for (std::vector<std::string>::const_iterator T = E->Targets.begin(); T != E->Targets.end(); ++T)
       {
-#define APT_T_CONFIG(X) _config->Find(std::string("APT::Acquire::Targets::") + Type  + "::" + *T + "::" + (X))
+#define APT_T_CONFIG(X) _config->Find(std::string("Acquire::IndexTargets::") + Type  + "::" + *T + "::" + (X))
         std::string const tplMetaKey = APT_T_CONFIG(flatArchive ? "flatMetaKey" : "MetaKey");
         std::string const tplShortDesc = APT_T_CONFIG("ShortDescription");
-        std::string const tplLongDesc = APT_T_CONFIG(flatArchive ? "flatDescription" : "Description");
-        bool const IsOptional = _config->FindB(std::string("APT::Acquire::Targets::deb-src::") + *T + "::Optional", true);
+        std::string const tplLongDesc = "$(SITE) " + APT_T_CONFIG(flatArchive ? "flatDescription" : "Description");
+        bool const IsOptional = _config->FindB(std::string("Acquire::IndexTargets::") + Type + "::" + *T + "::Optional", true);
+        bool const KeepCompressed = _config->FindB(std::string("Acquire::IndexTargets::") + Type + "::" + *T + "::KeepCompressed", GzipIndex);
 #undef APT_T_CONFIG
         if (tplMetaKey.empty())
            continue;
@@ -155,7 +154,7 @@ static void GetIndexTargetsFor(char const * const Type, std::string const &URI,
                  Options.insert(std::make_pair("ARCHITECTURE", *A));
               Options.insert(std::make_pair("BASE_URI", baseURI));
               Options.insert(std::make_pair("REPO_URI", URI));
-              Options.insert(std::make_pair("TARGET_OF", "deb-src"));
+              Options.insert(std::make_pair("TARGET_OF", Type));
               Options.insert(std::make_pair("CREATED_BY", *T));
 
               std::string MetaKey = tplMetaKey;
@@ -173,6 +172,7 @@ static void GetIndexTargetsFor(char const * const Type, std::string const &URI,
                     LongDesc,
                     Options.find("BASE_URI")->second + MetaKey,
                     IsOptional,
+                    KeepCompressed,
                     Options
                     );
               IndexTargets.push_back(Target);
@@ -413,7 +413,7 @@ bool debReleaseIndex::parseSumData(const char *&Start, const char *End,     /*{{{*/
 bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool const &GetAll)/*{{{*/
 {
    std::vector<IndexTarget> const targets = GetIndexTargets();
-#define APT_TARGET(X) IndexTarget("", X, MetaIndexInfo(X), MetaIndexURI(X), false, std::map<std::string,std::string>())
+#define APT_TARGET(X) IndexTarget("", X, MetaIndexInfo(X), MetaIndexURI(X), false, false, std::map<std::string,std::string>())
    pkgAcqMetaClearSig * const TransactionManager = new pkgAcqMetaClearSig(Owner,
         APT_TARGET("InRelease"), APT_TARGET("Release"), APT_TARGET("Release.gpg"),
         targets, this);
@@ -715,10 +715,25 @@ class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type             /*{{{*/
         List.push_back(Deb);
       }
 
+      std::vector<std::string> const alltargets = _config->FindVector(std::string("Acquire::IndexTargets::") + Name, "", true);
+      std::vector<std::string> mytargets = parsePlusMinusOptions("target", Options, alltargets);
+      if (mytargets.empty() == false)
+        for (auto const &target : alltargets)
+        {
+           std::map<std::string, std::string>::const_iterator const opt = Options.find(target);
+           if (opt == Options.end())
+              continue;
+           auto const tarItr = std::find(mytargets.begin(), mytargets.end(), target);
+           bool const optValue = StringToBool(opt->second);
+           if (optValue == true && tarItr == mytargets.end())
+              mytargets.push_back(target);
+           else if (optValue == false && tarItr != mytargets.end())
+              mytargets.erase(std::remove(mytargets.begin(), mytargets.end(), target), mytargets.end());
+        }
       Deb->AddComponent(
            IsSrc,
            Section,
-           parsePlusMinusOptions("target", Options, _config->FindVector(std::string("APT::Acquire::Targets::") + Name, "", true)),
+           mytargets,
            parsePlusMinusOptions("arch", Options, APT::Configuration::getArchitectures()),
            parsePlusMinusOptions("lang", Options, APT::Configuration::getLanguages(true))
            );
@@ -755,7 +770,7 @@ class APT_HIDDEN debSLTypeDeb : public debSLTypeDebian                      /*{{{*/
 
    bool CreateItem(std::vector<metaIndex *> &List, std::string const &URI,
                   std::string const &Dist, std::string const &Section,
-                  std::map<std::string, std::string> const &Options) const
+                  std::map<std::string, std::string> const &Options) const APT_OVERRIDE
    {
       return CreateItemInternal(List, URI, Dist, Section, false, Options);
    }
@@ -771,7 +786,7 @@ class APT_HIDDEN debSLTypeDebSrc : public debSLTypeDebian           /*{{{*/
 
    bool CreateItem(std::vector<metaIndex *> &List, std::string const &URI,
                   std::string const &Dist, std::string const &Section,
-                  std::map<std::string, std::string> const &Options) const
+                  std::map<std::string, std::string> const &Options) const APT_OVERRIDE
    {
       return CreateItemInternal(List, URI, Dist, Section, true, Options);
    }
@@ -782,34 +797,5 @@ class APT_HIDDEN debSLTypeDebSrc : public debSLTypeDebian          /*{{{*/
 };
                                                                        /*}}}*/
 
-debDebFileMetaIndex::debDebFileMetaIndex(std::string const &DebFile)   /*{{{*/
-   : metaIndex(DebFile, "local-uri", "deb-dist"), d(NULL), DebFile(DebFile)
-{
-   DebIndex = new debDebPkgFileIndex(DebFile);
-   Indexes = new std::vector<pkgIndexFile *>();
-   Indexes->push_back(DebIndex);
-}
-debDebFileMetaIndex::~debDebFileMetaIndex() {}
-                                                                       /*}}}*/
-class APT_HIDDEN debSLTypeDebFile : public pkgSourceList::Type         /*{{{*/
-{
-   public:
-
-   bool CreateItem(std::vector<metaIndex *> &List, std::string const &URI,
-                  std::string const &/*Dist*/, std::string const &/*Section*/,
-                  std::map<std::string, std::string> const &/*Options*/) const
-   {
-      metaIndex *mi = new debDebFileMetaIndex(URI);
-      List.push_back(mi);
-      return true;
-   }
-
-   debSLTypeDebFile() : Type("deb-file", "Debian local deb file")
-   {
-   }
-};
-                                                                       /*}}}*/
-
 APT_HIDDEN debSLTypeDeb _apt_DebType;
 APT_HIDDEN debSLTypeDebSrc _apt_DebSrcType;
-APT_HIDDEN debSLTypeDebFile _apt_DebFileType;