]> git.saurik.com Git - apt.git/commitdiff
Merge remote-tracking branch 'mvo/feature/no-more-acquire-guessing' into debian/exper...
authorMichael Vogt <mvo@ubuntu.com>
Thu, 6 Nov 2014 07:57:59 +0000 (08:57 +0100)
committerMichael Vogt <mvo@ubuntu.com>
Thu, 6 Nov 2014 07:57:59 +0000 (08:57 +0100)
apt-pkg/acquire-item.cc
apt-pkg/acquire-item.h
apt-pkg/deb/debindexfile.cc
apt-pkg/deb/debindexfile.h
test/integration/test-apt-update-filesize-mismatch
test/integration/test-apt-update-hashsum-mismatch
test/integration/test-bug-595691-empty-and-broken-archive-files
test/integration/test-bug-624218-Translation-file-handling

index f684e81f182f0661620fc238e938160879ad80a2..605ca7ae4b31feb87b1708954f14112ff6382278 100644 (file)
@@ -1260,6 +1260,9 @@ string pkgAcqIndex::Custom600Headers() const
    if (stat(Final.c_str(),&Buf) == 0)
       msg += "\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
 
+   if(Target->IsOptional())
+      msg += "\nFail-Ignore: true";
+
    return msg;
 }
                                                                        /*}}}*/
@@ -1283,8 +1286,12 @@ void pkgAcqIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
       unlink(EraseFileName.c_str());
    }
 
-   /// cancel the entire transaction
-   TransactionManager->AbortTransaction();
+   Item::Failed(Message,Cnf);
+
+   if(Target->IsOptional() && ExpectedHashes.empty() && Stage == STAGE_DOWNLOAD)
+      Status = StatDone;
+   else
+      TransactionManager->AbortTransaction();
 }
                                                                        /*}}}*/
 // pkgAcqIndex::GetFinalFilename - Return the full final file path     /*{{{*/
@@ -1476,57 +1483,6 @@ void pkgAcqIndex::StageDecompressDone(string Message,
    return;
 }
                                                                        /*}}}*/
-// AcqIndexTrans::pkgAcqIndexTrans - Constructor                       /*{{{*/
-// ---------------------------------------------------------------------
-/* The Translation file is added to the queue */
-pkgAcqIndexTrans::pkgAcqIndexTrans(pkgAcquire *Owner,
-                           string URI,string URIDesc,string ShortDesc)
-  : pkgAcqIndex(Owner, URI, URIDesc, ShortDesc, HashStringList())
-{
-}
-pkgAcqIndexTrans::pkgAcqIndexTrans(pkgAcquire *Owner,
-                                   pkgAcqMetaBase *TransactionManager,
-                                   IndexTarget const * const Target,
-                                   HashStringList const &ExpectedHashes,
-                                   indexRecords *MetaIndexParser)
-   : pkgAcqIndex(Owner, TransactionManager, Target, ExpectedHashes, MetaIndexParser)
-{
-}
-                                                                       /*}}}*/
-// AcqIndexTrans::Custom600Headers - Insert custom request headers     /*{{{*/
-string pkgAcqIndexTrans::Custom600Headers() const
-{
-   string Final = GetFinalFilename();
-
-   struct stat Buf;
-   if (stat(Final.c_str(),&Buf) != 0)
-      return "\nFail-Ignore: true\nIndex-File: true";
-   return "\nFail-Ignore: true\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
-}
-                                                                       /*}}}*/
-// AcqIndexTrans::Failed - Silence failure messages for missing files  /*{{{*/
-void pkgAcqIndexTrans::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
-{
-   Item::Failed(Message,Cnf);
-
-   size_t const nextExt = CompressionExtensions.find(' ');
-   if (nextExt != std::string::npos)
-   {
-      CompressionExtensions = CompressionExtensions.substr(nextExt+1);
-      Init(RealURI, Desc.Description, Desc.ShortDesc);
-      Status = StatIdle;
-      return;
-   }
-
-   // FIXME: this is used often (e.g. in pkgAcqIndexTrans) so refactor
-   if (Cnf->LocalOnly == true ||
-       StringToBool(LookupTag(Message,"Transient-Failure"),false) == false)
-   {
-      // Ignore this
-      Status = StatDone;
-   }
-}
-                                                                       /*}}}*/
 // AcqMetaBase::Add - Add a item to the current Transaction            /*{{{*/
 void pkgAcqMetaBase::Add(Item *I)
 {
@@ -1973,87 +1929,59 @@ bool pkgAcqMetaBase::CheckDownloadDone(const std::string &Message,
                                                                        /*}}}*/
 void pkgAcqMetaBase::QueueIndexes(bool verify)                         /*{{{*/
 {
-   bool transInRelease = false;
-   {
-      std::vector<std::string> const keys = MetaIndexParser->MetaKeys();
-      for (std::vector<std::string>::const_iterator k = keys.begin(); k != keys.end(); ++k)
-        // FIXME: Feels wrong to check for hardcoded string here, but what should we do elseā€¦
-        if (k->find("Translation-") != std::string::npos)
-        {
-           transInRelease = true;
-           break;
-        }
-   }
-
    // at this point the real Items are loaded in the fetcher
    ExpectedAdditionalItems = 0;
-   for (vector <IndexTarget*>::const_iterator Target = IndexTargets->begin();
+
+   vector <struct IndexTarget*>::const_iterator Target;
+   for (Target = IndexTargets->begin();
         Target != IndexTargets->end();
         ++Target)
    {
       HashStringList ExpectedIndexHashes;
       const indexRecords::checkSum *Record = MetaIndexParser->Lookup((*Target)->MetaKey);
-      bool compressedAvailable = false;
-      if (Record == NULL)
+
+      // optional target that we do not have in the Release file are 
+      // skipped
+      if (verify == true && Record == NULL && (*Target)->IsOptional())
+         continue;
+
+      // targets without a hash record are a error when verify is required
+      if (verify == true && Record == NULL)
       {
-        if ((*Target)->IsOptional() == true)
-        {
-           std::vector<std::string> types = APT::Configuration::getCompressionTypes();
-           for (std::vector<std::string>::const_iterator t = types.begin(); t != types.end(); ++t)
-              if (MetaIndexParser->Exists((*Target)->MetaKey + "." + *t) == true)
-              {
-                 compressedAvailable = true;
-                 break;
-              }
-        }
-        else if (verify == true)
-        {
-           Status = StatAuthError;
-           strprintf(ErrorText, _("Unable to find expected entry '%s' in Release file (Wrong sources.list entry or malformed file)"), (*Target)->MetaKey.c_str());
-           return;
-        }
+         Status = StatAuthError;
+         strprintf(ErrorText, _("Unable to find expected entry '%s' in Release file (Wrong sources.list entry or malformed file)"), (*Target)->MetaKey.c_str());
+         return;
       }
-      else
+
+      if (Record)
+         ExpectedIndexHashes = Record->Hashes;
+      
+      if (_config->FindB("Debug::pkgAcquire::Auth", false))
       {
-        ExpectedIndexHashes = Record->Hashes;
-        if (_config->FindB("Debug::pkgAcquire::Auth", false))
-        {
-           std::cerr << "Queueing: " << (*Target)->URI << std::endl
-              << "Expected Hash:" << std::endl;
-           for (HashStringList::const_iterator hs = ExpectedIndexHashes.begin(); hs != ExpectedIndexHashes.end(); ++hs)
-              std::cerr <<  "\t- " << hs->toStr() << std::endl;
-           std::cerr << "For: " << Record->MetaKeyFilename << std::endl;
-        }
-        if (verify == true && ExpectedIndexHashes.empty() == true && (*Target)->IsOptional() == false)
-        {
-           Status = StatAuthError;
-           strprintf(ErrorText, _("Unable to find hash sum for '%s' in Release file"), (*Target)->MetaKey.c_str());
-           return;
-        }
-      }
+         std::cerr << "Queueing: " << (*Target)->URI << std::endl
+                   << "Expected Hash:" << std::endl;
+         for (HashStringList::const_iterator hs = ExpectedIndexHashes.begin(); hs != ExpectedIndexHashes.end(); ++hs)
+            std::cerr <<  "\t- " << hs->toStr() << std::endl;
+         std::cerr << "For: " << Record->MetaKeyFilename << std::endl;
 
-      if ((*Target)->IsOptional() == true)
+      }
+      if (verify == true && ExpectedIndexHashes.empty() == true)
       {
-        if (transInRelease == false || Record != NULL || compressedAvailable == true)
-        {
-           if (_config->FindB("Acquire::PDiffs",true) == true && transInRelease == true &&
-               MetaIndexParser->Exists((*Target)->MetaKey + ".diff/Index") == true)
-              new pkgAcqDiffIndex(Owner, TransactionManager, *Target, ExpectedIndexHashes, MetaIndexParser);
-           else
-              new pkgAcqIndexTrans(Owner, TransactionManager, *Target, ExpectedIndexHashes, MetaIndexParser);
-        }
-        continue;
+         Status = StatAuthError;
+         strprintf(ErrorText, _("Unable to find hash sum for '%s' in Release file"), (*Target)->MetaKey.c_str());
+         return;
       }
 
-      /* Queue Packages file (either diff or full packages files, depending
+      /* Queue the Index file (Packages, Sources, Translation-$foo
+         (either diff or full packages files, depending
          on the users option) - we also check if the PDiff Index file is listed
          in the Meta-Index file. Ideal would be if pkgAcqDiffIndex would test this
          instead, but passing the required info to it is to much hassle */
       if(_config->FindB("Acquire::PDiffs",true) == true && (verify == false ||
-         MetaIndexParser->Exists((*Target)->MetaKey + ".diff/Index") == true))
-        new pkgAcqDiffIndex(Owner, TransactionManager, *Target, ExpectedIndexHashes, MetaIndexParser);
+          MetaIndexParser->Exists((*Target)->MetaKey + ".diff/Index") == true))
+         new pkgAcqDiffIndex(Owner, TransactionManager, *Target, ExpectedIndexHashes, MetaIndexParser);
       else
-        new pkgAcqIndex(Owner, TransactionManager, *Target, ExpectedIndexHashes, MetaIndexParser);
+         new pkgAcqIndex(Owner, TransactionManager, *Target, ExpectedIndexHashes, MetaIndexParser);
    }
 }
                                                                        /*}}}*/
index ff1bf563a9f00da1bc696588bdefbe747f755eb3..10d7e6a09d71a69f0e15df357168d5f247f34d48 100644 (file)
@@ -1027,43 +1027,6 @@ class pkgAcqIndex : public pkgAcqBaseIndex
              std::string const &ShortDesc);
 };
                                                                        /*}}}*/
-/** \brief An acquire item that is responsible for fetching a          {{{
- *  translated index file.
- *
- *  The only difference from pkgAcqIndex is that transient failures
- *  are suppressed: no error occurs if the translated index file is
- *  missing.
- */
-class pkgAcqIndexTrans : public pkgAcqIndex
-{
-   void *d;
-
-   public:
-  
-   virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
-   virtual std::string Custom600Headers() const;
-
-   /** \brief Create a pkgAcqIndexTrans.
-    *
-    *  \param Owner The pkgAcquire object with which this item is
-    *  associated.
-    *
-    *  \param URI The URI of the index file that is to be downloaded.
-    *
-    *  \param URIDesc A "URI-style" description of this index file.
-    *
-    *  \param ShortDesc A brief description of this index file.
-    */
-   pkgAcqIndexTrans(pkgAcquire *Owner,
-                    std::string URI,std::string URIDesc,
-                   std::string ShortDesc);
-   pkgAcqIndexTrans(pkgAcquire *Owner,
-                    pkgAcqMetaBase *TransactionManager,
-                    IndexTarget const * const Target,
-                    HashStringList const &ExpectedHashes,
-                    indexRecords *MetaIndexParser);
-};
-                                                                       /*}}}*/
 /** \brief Information about an index file. */                         /*{{{*/
 class IndexTarget
 {
index cc1d94d81cbcf9349735d2356b8ace4d681a73c8..335f9d36ef2b043340fc075a22364941a208eda4 100644 (file)
@@ -452,19 +452,6 @@ string debTranslationsIndex::IndexURI(const char *Type) const
    return Res;
 }
                                                                        /*}}}*/
-// TranslationsIndex::GetIndexes - Fetch the index files               /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool debTranslationsIndex::GetIndexes(pkgAcquire *Owner) const
-{
-   string const TranslationFile = string("Translation-").append(Language);
-   new pkgAcqIndexTrans(Owner, IndexURI(Language),
-                        Info(TranslationFile.c_str()),
-                        TranslationFile);
-
-   return true;
-}
-                                                                       /*}}}*/
 // TranslationsIndex::Describe - Give a descriptive path to the index  /*{{{*/
 // ---------------------------------------------------------------------
 /* This should help the user find the index in the sources.list and
index e5a1a7873415d449b45be71af3cfb533f78f295c..d727d9547071afa6217a3ff1ef4c33922fc43fe8 100644 (file)
@@ -114,7 +114,6 @@ class debTranslationsIndex : public pkgIndexFile
 
    // Interface for acquire
    virtual std::string Describe(bool Short) const;   
-   virtual bool GetIndexes(pkgAcquire *Owner) const;
    
    // Interface for the Cache Generator
    virtual bool Exists() const;
index b484c5161645d36a03a456b7f74a3a426101ee62..f78b83b5ff6d1ca858fbe303db948e810235ff49 100755 (executable)
@@ -38,16 +38,11 @@ for get in $(sed -n 's#^GET /\([^ ]\+\.gz\) HTTP.\+$#\1#p' aptarchive/webserver.
                done
                signreleasefiles
 
-               TEST='testfailure'
-               if expr match "$COMPRESSFILE" '^.*Translation-.*$' >/dev/null; then
-                       TEST='testsuccess'
-                       unset COMPRESSFILE
-               fi
-               $TEST aptget update -o Debug::pkgAcquire::Worker=1
-               cp rootdir/tmp/${TEST}.output rootdir/tmp/update.output
+               testfailure aptget update -o Debug::pkgAcquire::Worker=1
+               cp rootdir/tmp/testfailure.output rootdir/tmp/update.output
                testsuccess grep -E "$(basename -s '.gz' "$COMPRESSFILE").*Hash Sum mismatch" rootdir/tmp/update.output
-               $TEST aptcache show foo
-               $TEST aptget install foo -s
+               testfailure aptcache show foo
+               testfailure aptget install foo -s
 
                testfailure aptcache show bar
                testfailure aptget install bar -s
index 747418c53872d7ea3b00071f9997646f3fc74833..c2c5b388797d57c9aea4ee0b778fb128859605e8 100755 (executable)
@@ -33,16 +33,11 @@ for get in $(sed -n 's#^GET /\([^ ]\+\.gz\) HTTP.\+$#\1#p' aptarchive/webserver.
        webserverconfig 'aptwebserver::overwrite' ''
        webserverconfig "aptwebserver::overwrite::$(printf '%s' "${get}" | sed 's#/#%2F#g' )::filename" '%2FDoctorEvil.gz'
 
-       TEST='testfailure'
-       if expr match "$get" '^.*Translation-.*$' >/dev/null; then
-               TEST='testsuccess'
-               unset get
-       fi
-       $TEST aptget update
-       cp rootdir/tmp/${TEST}.output rootdir/tmp/update.output
+       testfailure aptget update
+       cp rootdir/tmp/testfailure.output rootdir/tmp/update.output
        testsuccess grep -E "$(basename -s '.gz' "$get").*Hash Sum mismatch" rootdir/tmp/update.output
-       $TEST aptcache show foo
-       $TEST aptget install foo -s
+       testfailure aptcache show foo
+       testfailure aptget install foo -s
 
        testfailure aptcache show bar
        testfailure aptget install bar -s
index fedf82c92f283cea89ec25ae6b07d188d000d5ff..bca07268cb012064e667b7b6e70dd48e800c0bd7 100755 (executable)
@@ -73,16 +73,6 @@ E: Some index files failed to download. They have been ignored, or old ones used
 testoverhttp() {
        forcecompressor "$1"
 
-       createemptyfile 'en'
-       testaptgetupdate "Get: http://localhost:8080  Packages []
-Get: http://localhost:8080  Translation-en
-Reading package lists..." "empty file en.$COMPRESS over http"
-
-       createemptyarchive 'en'
-       testaptgetupdate "Get: http://localhost:8080  Packages []
-Get: http://localhost:8080  Translation-en []
-Reading package lists..." "empty archive en.$COMPRESS over http"
-
        createemptyarchive 'Packages'
        testaptgetupdate "Get: http://localhost:8080  Packages []
 Reading package lists..." "empty archive Packages.$COMPRESS over http"
index d3c5b08ac2ad65b2a6424131f943ed5cd0eea2ea..d32bd513baa860a97d05f89854f30a69c7c5cb58 100755 (executable)
@@ -47,16 +47,10 @@ translationslisted() {
 translationslisted 'with full Index'
 
 
-# only compressed files available (as it happens on CD-ROM)
-sed -i '/i18n\/Translation-[^.]*$/ d' $(find aptarchive -name 'Release')
-signreleasefiles
-
-translationslisted 'with partial Index'
-
-
-# no records at all about Translation files (fallback to guessing)
-sed -i '/i18n\/Translation-.*$/ d' $(find aptarchive -name 'Release')
-signreleasefiles
+# No Release file at all, so no records about Translation files
+# (fallback to guessing)
+find aptarchive -name 'Release' -or -name 'InRelease' | xargs rm -f
+configallowinsecurerepositories "true";
 
 msgtest 'Download of en as forced language' 'without Index'
 aptget update -o Acquire::Languages=en | grep -q -e 'Translation-en ' && msgpass || msgfail