瀏覽代碼

fix same-mirror redirection for Release{,.gpg} pair

Commit 9b8034a9fd40b4d05075fda719e61f6eb4c45678 just deals with
InRelease properly and generates broken URIs in case the mirror (or the
achieve really) has no InRelease file.

[As this was in no released version no need to clutter changelog with a
fix notice.]

Git-Dch: Ignore
David Kalnischkies 10 年之前
父節點
當前提交
03a34b88df
共有 2 個文件被更改,包括 23 次插入2 次删除
  1. 2 2
      apt-pkg/acquire-item.cc
  2. 21 0
      test/integration/test-handle-redirect-as-used-mirror-change

+ 2 - 2
apt-pkg/acquire-item.cc

@@ -344,7 +344,7 @@ bool pkgAcqTransactionItem::QueueURI(pkgAcquire::ItemDesc &Item)
    {
       // this ensures we rewrite only once and only the first step
       auto const OldBaseURI = Target.Option(IndexTarget::BASE_URI);
-      if (APT::String::Startswith(Item.URI, OldBaseURI))
+      if (OldBaseURI.empty() == false && APT::String::Startswith(Item.URI, OldBaseURI))
       {
 	 auto const ExtraPath = Item.URI.substr(OldBaseURI.length());
 	 Item.URI = flCombine(TransactionManager->BaseURI, ExtraPath);
@@ -1107,7 +1107,7 @@ bool pkgAcqMetaBase::CheckDownloadDone(pkgAcqTransactionItem * const I, const st
    {
       if (APT::String::Endswith(I->Desc.URI, "InRelease"))
 	 TransactionManager->BaseURI = I->Desc.URI.substr(0, I->Desc.URI.length() - strlen("InRelease"));
-      else
+      else if (APT::String::Endswith(I->Desc.URI, "Release"))
 	 TransactionManager->BaseURI = I->Desc.URI.substr(0, I->Desc.URI.length() - strlen("Release"));
    }
 

+ 21 - 0
test/integration/test-handle-redirect-as-used-mirror-change

@@ -9,6 +9,7 @@ configcompression '.' 'gz'
 
 buildsimplenativepackage 'unrelated' 'all' '0.5~squeeze1' 'unstable'
 
+export APT_DONT_SIGN=''
 setupaptarchive --no-update
 changetowebserver
 webserverconfig 'aptwebserver::redirect::replace::/redirectme/' "http://0.0.0.0:${APTHTTPPORT}/"
@@ -41,3 +42,23 @@ Location: http://0.0.0.0:${APTHTTPPORT}/dists/unstable/main/i18n/Translation-en.
 cd downloaded
 testsuccess apthelper download-file "http://localhost:${APTHTTPPORT}/redirectme/dists/unstable/InRelease" inrelease
 testsuccess test -s inrelease
+cd - >/dev/null
+
+find aptarchive -name 'InRelease' -delete
+rm -rf rootdir/var/lib/apt/lists
+
+testsuccessequal "Ign:1 http://0.0.0.0:${APTHTTPPORT} unstable InRelease
+  404  Not Found
+Get:2 http://0.0.0.0:${APTHTTPPORT} unstable Release [$(stat -c %s aptarchive/dists/unstable/Release) B]
+Get:3 http://0.0.0.0:${APTHTTPPORT} unstable Release.gpg [$(stat -c %s aptarchive/dists/unstable/Release.gpg) B]
+Get:4 http://0.0.0.0:${APTHTTPPORT} unstable/main Sources [$(stat -c %s aptarchive/dists/unstable/main/source/Sources.gz) B]
+Get:5 http://0.0.0.0:${APTHTTPPORT} unstable/main all Packages [$(stat -c %s aptarchive/dists/unstable/main/binary-all/Packages.gz) B]
+Get:6 http://0.0.0.0:${APTHTTPPORT} unstable/main Translation-en [$(stat -c %s aptarchive/dists/unstable/main/i18n/Translation-en.gz) B]
+Reading package lists..." aptget update
+
+testsuccessequal "Ign:1 http://0.0.0.0:${APTHTTPPORT} unstable InRelease
+  404  Not Found
+Hit:2 http://0.0.0.0:${APTHTTPPORT} unstable Release
+Reading package lists..." aptget update
+
+